Commit e2972895 authored by Samuel GAIST's avatar Samuel GAIST

[dock] Add method to return database environment based on name

This replaces the database name based search.
parent 13b7549f
......@@ -57,6 +57,8 @@ from packaging import version
from beat.core import stats
from .utils import build_env_name
logger = logging.getLogger(__name__)
......@@ -91,9 +93,10 @@ class Host(object):
) = self._discover_environments_using_labels()
if not self.db_environments and not self.processing_environments:
self.processing_environments, self.db_environments = (
self._discover_environments_using_describe()
)
(
self.processing_environments,
self.db_environments,
) = self._discover_environments_using_describe()
# (If necessary) Save the known infos about the images
if self.images_cache_filename is not None:
......@@ -131,6 +134,12 @@ class Host(object):
return attrs["image"]
def dbenv2docker(self, key):
"""Returns a nice docker image name given a BEAT database environment key"""
attrs = self.db_environments[key]
return attrs["image"]
def teardown(self):
for container in self.containers:
self.rm(container)
......@@ -312,7 +321,7 @@ class Host(object):
logger.debug("Description not found for", image)
continue
key = description["name"] + " (" + description["version"] + ")"
key = build_env_name(description)
if "databases" in description:
if (key in db_environments) and not _must_replace(
......@@ -400,7 +409,7 @@ class Host(object):
continue
image_info = _parse_image_info(image)
key = "{} ({})".format(image_info["name"], image_info["version"])
key = build_env_name(image_info)
image_name = image_info["image"]
if key in environments:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment