def __init__(self, name, config, config_path, manifest_file, service, group=None, environment=None, prefix=None): self._archive = None self._config = config self._config_path = config_path self._consul_prefix = prefix or self.CONSUL_PREFIX self._environment = environment self._manifest_file = manifest_file self._service = service self._group = group self._unit_name = name self._unit_template = DEFAULT_UNIT_TEMPLATE unit_template_file = path.join(config_path, 'file-unit.template') if path.exists(unit_template_file): with open(unit_template_file, 'r') as handle: self._unit_template = handle.read() kwargs = utils.parse_endpoint(self._config['consul']) self._consul = consulate.Consul(**kwargs) self._temp_dir = tempfile.mkdtemp() try: self._file_list = self._get_file_list() except ValueError as error: LOGGER.info(error) self._file_list = [] self._archive_key = '{0}/{1}'.format(self._consul_prefix, name)
def test_unix_socket_endpoint(self): value = 'unix:///var/run/consul.sock' expectation = { 'scheme': 'unix', 'host': '/var/run/consul.sock', 'port': None } self.assertDictEqual(utils.parse_endpoint(value), expectation)
def test_https_with_specified_port(self): value = 'https://consul.ec2.local:8500' expectation = { 'scheme': 'https', 'host': 'consul.ec2.local', 'port': 8500 } self.assertDictEqual(utils.parse_endpoint(value), expectation)
def test_http_with_default_port(self): value = 'http://consul.ec2.local' expectation = { 'scheme': 'http', 'host': 'consul.ec2.local', 'port': 80 } self.assertDictEqual(utils.parse_endpoint(value), expectation)
def __init__(self, name, config, config_path, service): self._config = config self._config_path = config_path self._service = service self._unit_name = name kwargs = utils.parse_endpoint(self._config['consul']) self._consul = consulate.Consul(**kwargs) self._temp_dir = tempfile.mkdtemp() try: self._file_list = self._get_file_list() except ValueError as error: LOGGER.info(error) self._file_list = [] if self._file_list: self._build_filesystem() self._archive = self._create_archive() self._remove_artifacts() self._archive_key = '{0}/{1}'.format(self.CONSUL_PREFIX, name)
def __init__(self, config_path, environment, command, name, group, version, delay, max_tries, no_dependencies, no_removal, skip_consul, remove_units): self._config_path = self._normalize_path(config_path) self._environment = environment self._command = command self._name = name or ('' if command != 'global' else 'global') self._group = group self._version = version self._deployed_units = [] self._delay = delay self._max_tries = max_tries self._no_dependencies = no_dependencies self._no_removal = no_removal self._skip_consul = skip_consul self._remove_unit_files = remove_units self._config = self._load_config(CONFIG_FILE) if environment not in self._config.get('environments', {}): raise ValueError('environment not found') kwargs = utils.parse_endpoint(self.env_config['consul']) self._consul = consulate.Consul(**kwargs) self._file_deployment = None self._fleet = fleetpy.Client(self.env_config.get('fleet'))
def test_unix_socket_endpoint(self): value = 'unix:///var/run/consul.sock' expectation = {'scheme': 'unix', 'host': '/var/run/consul.sock', 'port': None} self.assertDictEqual(utils.parse_endpoint(value), expectation)
def test_https_with_specified_port(self): value = 'https://consul.ec2.local:8500' expectation = {'scheme': 'https', 'host': 'consul.ec2.local', 'port': 8500} self.assertDictEqual(utils.parse_endpoint(value), expectation)
def test_http_with_default_port(self): value = 'http://consul.ec2.local' expectation = {'scheme': 'http', 'host': 'consul.ec2.local', 'port': 80} self.assertDictEqual(utils.parse_endpoint(value), expectation)