Exemple #1
0
 def __init__(self, image, autostart=False):
     self.image = image
     self.name_tag = image.split('/')[-1]
     self.logger = logutil.EntityLoggingAdapter(logger, {'entity': '{}'.format(self.name_tag)})
     self.cid = None
     if autostart:
         self.start()
Exemple #2
0
    def __init__(self, runtime, pull_url, repo_file, enabled_checks, distgit=''):
        """
        :param Runtime runtime: Program runtime object

        :param string pull_url: The host/name:tag URL of the image to verify

        :param string repo_file: The full path to the repo file which
        is installed in the container later

        :param list enabled_checks: List of check names to run on the
        image. Each check is an Image() method.
        """
        self.runtime = runtime
        self.pull_url = pull_url
        self.enabled_checks = enabled_checks
        # registry.redhat.com:8888/openshift3/ose:v3.4.1.44.38-12 => ose:v3.4.1.44.38-12
        self.name_tag = pull_url.split('/')[-1]
        self.logger = logutil.EntityLoggingAdapter(logger=logger, extra={'entity': '{}'.format(self.name_tag)})
        self.distgit = distgit

        # I must apologize for this...... Trim the version. Remove any
        # possible leaving 'v' characters, split on hyphen to isolate
        # the image release (-NN), take first item
        self.image_version = self.name_tag.split(':')[-1].lstrip('v').split('-')[0]
        self.container = container.DockerContainer(pull_url)
        # Full and abbreviated container IDs once started
        self.cid = None
        self.failures = {}
        self.repo_file = repo_file
        self.status = 'passed'
Exemple #3
0
    def __init__(self, meta_type, runtime, data_obj):
        """
        :param: meta_type - a string. Index to the sub-class <'rpm'|'image'>.
        :param: runtime - a Runtime object.
        :param: name - a filename to load as metadata
        """
        self.meta_type = meta_type
        self.runtime = runtime
        self.data_obj = data_obj
        self.base_dir = data_obj.base_dir
        self.config_filename = data_obj.filename
        self.full_config_path = data_obj.path

        # Some config filenames have suffixes to avoid name collisions; strip off the suffix to find the real
        # distgit repo name (which must be combined with the distgit namespace).
        # e.g. openshift-enterprise-mediawiki.apb.yml
        #      distgit_key=openshift-enterprise-mediawiki.apb
        #      name (repo name)=openshift-enterprise-mediawiki

        self.distgit_key = data_obj.key
        self.name = self.distgit_key.split('.')[
            0]  # Split off any '.apb' style differentiator (if present)

        self.runtime.logger.debug("Loading metadata from {}".format(
            self.full_config_path))

        self.config = Model(data_obj.data)

        self.mode = self.config.get('mode', CONFIG_MODE_DEFAULT).lower()
        if self.mode not in CONFIG_MODES:
            raise ValueError('Invalid mode for {}'.format(
                self.config_filename))

        self.enabled = (self.mode == CONFIG_MODE_DEFAULT)

        # Basic config validation. All images currently required to have a name in the metadata.
        # This is required because from.member uses these data to populate FROM in images.
        # It would be possible to query this data from the distgit Dockerflie label, but
        # not implementing this until we actually need it.
        assert (self.config.name is not Missing)

        # Choose default namespace for config data
        if meta_type is "image":
            self.namespace = "containers"
        else:
            self.namespace = "rpms"

        # Allow config data to override
        if self.config.distgit.namespace is not Missing:
            self.namespace = self.config.distgit.namespace

        self.qualified_name = "%s/%s" % (self.namespace, self.name)
        self.qualified_key = "%s/%s" % (self.namespace, self.distgit_key)

        # Includes information to identify the metadata being used with each log message
        self.logger = logutil.EntityLoggingAdapter(
            logger=self.runtime.logger, extra={'entity': self.qualified_key})

        self._distgit_repo = None