コード例 #1
0
ファイル: docker.py プロジェクト: KongNan/treadmill
def _get_docker_registry(tm_env, app_environment):
    """Return the registry to use.
    """
    # get registry address from node.json
    data = nodedata.get(tm_env.configs_dir)
    registry_conf = data['docker_registries']
    if isinstance(registry_conf, list):
        # Backward compatibility: If the conf is a list turn in to dict
        registries = collections.defaultdict(lambda: list(registry_conf))
    else:
        # If the conf is a dict, ensure it has all necessary keys
        registries = collections.defaultdict(lambda: [])
        registries.update(registry_conf)

    for registry in registries[app_environment]:
        if ':' in registry:
            host, _sep, port = registry.partition(':')
        else:
            host = registry
            port = None

        # Ensure we have teh FQDN for the registry host.
        host = socket.getfqdn(host)
        res = [host, port] if port is not None else [host]
        yield ':'.join(res)
コード例 #2
0
    def __init__(self, root):
        self.root = root

        self.alerts_dir = os.path.join(self.root, self.ALERTS_DIR)
        self.apps_dir = os.path.join(self.root, self.APPS_DIR)
        self.bin_dir = os.path.join(self.root, self.BIN_DIR)
        self.watchdog_dir = os.path.join(self.root, self.WATCHDOG_DIR)
        self.running_dir = os.path.join(self.root, self.RUNNING_DIR)
        self.cache_dir = os.path.join(self.root, self.CACHE_DIR)
        self.cleaning_dir = os.path.join(self.root, self.CLEANING_DIR)
        self.cleanup_dir = os.path.join(self.root, self.CLEANUP_DIR)
        self.cleanup_apps_dir = os.path.join(self.root, self.CLEANUP_APPS_DIR)
        self.configs_dir = os.path.join(self.root, self.CONFIG_DIR)
        self.app_events_dir = os.path.join(self.root, self.APP_EVENTS_DIR)
        self.archives_dir = os.path.join(self.root, self.ARCHIVES_DIR)
        self.images_dir = os.path.join(self.root, self.IMAGES_DIR)
        self.init_dir = os.path.join(self.root, self.INIT_DIR)
        self.init1_dir = os.path.join(self.root, self.INIT1_DIR)
        self.tombstones_dir = os.path.join(self.root, self.TOMBSTONES_DIR)
        self.cleanup_tombstone_dir = os.path.join(self.tombstones_dir,
                                                  self.CLEANUP_DIR)
        self.running_tombstone_dir = os.path.join(self.tombstones_dir,
                                                  self.RUNNING_DIR)
        self.init_tombstone_dir = os.path.join(self.tombstones_dir,
                                               self.INIT_DIR)
        self.endpoints_dir = os.path.join(self.root, self.ENDPOINTS_DIR)

        self.watchdogs = watchdog.Watchdog(self.watchdog_dir)
        # Load the local config data.
        self.data = nodedata.get(self.configs_dir)
コード例 #3
0
    def __init__(self, tm_env):
        data = nodedata.get(tm_env.configs_dir)
        self._config = GMSAConfig(data['nt_group_ou'],
                                  data['nt_group_pattern'])

        dc_name = win32security.DsGetDcName()
        self._dc = dc_name['DomainControllerName'].replace('\\\\', '').lower()
        self._dn = win32api.GetComputerObjectName(
            win32con.NameFullyQualifiedDN).lower()
コード例 #4
0
ファイル: docker.py プロジェクト: linbai/treadmill
def _get_tls_conf(tm_env):
    """Return the paths to the TLS certificates on the host.

    :returns:
        ``dict(ca_cert=str, host_cert=str, host_key=str)`` -- Paths to the
        CA root certificate, host certificate and host key.
    """
    # get registry address from node.json
    data = nodedata.get(tm_env.configs_dir)
    tls_conf = data['tls_certs']
    return {
        'ca_cert': tls_conf.get('ca_cert', ''),
        'host_cert': tls_conf.get('host_cert', ''),
        'host_key': tls_conf.get('host_key', ''),
    }
コード例 #5
0
ファイル: docker.py プロジェクト: bretttegartms/treadmill
def _get_docker_registry(tm_env):
    """Return the registry to use.
    """
    # get registry address from node.json
    data = nodedata.get(tm_env.configs_dir)
    registries = data['docker_registries']

    for registry in registries:
        if ':' in registry:
            host, _sep, port = registry.partition(':')
        else:
            host = registry
            port = '5000'

        # Ensure we have teh FQDN for the registry host.
        host = socket.getfqdn(host)
        yield ':'.join([host, port])
コード例 #6
0
    def configure(self, manifest):
        _LOGGER.info('Configuring dockerd.')
        # TODO: we need to move dockerd and docker authz to system-services
        # when they are stable

        # get registry address from node.json
        node_data = nodedata.get(self._tm_env.configs_dir)
        docker_conf = dockerutils.get_conf(manifest['environment'], node_data)

        manifest['services'].append(_generate_dockerd_service(docker_conf))
        manifest['services'].append(
            _generate_docker_authz_service(docker_conf))
        manifest['environ'].append({
            'name': 'DOCKER_HOST',
            'value': 'tcp://127.0.0.1:2375'
        })
        manifest['docker'] = True
コード例 #7
0
 def test_get_data(self):
     """Test get data from cell config file
     """
     data = nodedata.get(self.root)
     self.assertEqual(data, {'foo': 'bar'})