Exemplo n.º 1
0
    def _create_bad_env(self, env):
        # This environment setup is used because it was reported with
        # bug #1646136
        override = """
            physical_skel:
              local-compute_containers:
                belongs_to:
                - compute_containers
              local-compute_hosts:
                belongs_to:
                - compute_hosts
              rbd-compute_containers:
                belongs_to:
                - compute_containers
              rbd-compute_hosts:
                belongs_to:
                - compute_hosts
        """

        bad_env = yaml.load(override)

        # This is essentially what load_environment does, after all the file
        # system walking
        dictutils.merge_dict(env, bad_env)

        return env
Exemplo n.º 2
0
    def _create_bad_env(self, env):
        # This environment setup is used because it was reported with
        # bug #1646136
        override = """
            physical_skel:
              local-compute_containers:
                belongs_to:
                - compute_containers
              local-compute_hosts:
                belongs_to:
                - compute_hosts
              rbd-compute_containers:
                belongs_to:
                - compute_containers
              rbd-compute_hosts:
                belongs_to:
                - compute_hosts
        """

        bad_env = yaml.load(override)

        # This is essentially what load_environment does, after all the file
        # system walking
        dictutils.merge_dict(env, bad_env)

        return env
Exemplo n.º 3
0
def _extra_config(user_defined_config, base_dir):
    """Discover new items in any extra directories and add the new values.

    :param user_defined_config: ``dict``
    :param base_dir: ``str``
    """
    for root_dir, _, files in os.walk(base_dir):
        for name in files:
            if name.endswith(('.yml', '.yaml')):
                with open(os.path.join(root_dir, name), 'rb') as f:
                    du.merge_dict(user_defined_config,
                                  yaml.safe_load(f.read()) or {})
                    logger.debug("Merged overrides from file {}".format(name))
Exemplo n.º 4
0
def _extra_config(user_defined_config, base_dir):
    """Discover new items in any extra directories and add the new values.

    :param user_defined_config: ``dict``
    :param base_dir: ``str``
    """
    for root_dir, _, files in os.walk(base_dir):
        for name in files:
            if name.endswith(('.yml', '.yaml')):
                with open(os.path.join(root_dir, name), 'rb') as f:
                    merge_dict(
                        user_defined_config,
                        yaml.safe_load(f.read()) or {}
                    )
                    logger.debug("Merged overrides from file %s", name)
    def test_base_dict_is_modified(self):
        base = {'key1': 'value1'}
        target = {'key2': 'value2'}

        new = du.merge_dict(base, target)

        self.assertIs(base, new)
Exemplo n.º 6
0
    def test_base_dict_is_modified(self):
        base = {'key1': 'value1'}
        target = {'key2': 'value2'}

        new = du.merge_dict(base, target)

        self.assertIs(base, new)
Exemplo n.º 7
0
    def test_base_dict_is_modified(self):
        base = {"key1": "value1"}
        target = {"key2": "value2"}

        new = du.merge_dict(base, target)

        self.assertIs(base, new)
    def test_merging_nested_dicts(self):
        base = {'key1': 'value1'}
        target = {'key2': {'key2.1': 'value2'}}

        new = du.merge_dict(base, target)

        self.assertIn('key2', new.keys())
        self.assertIn('key2.1', new['key2'].keys())
    def test_merging_dict(self):
        base = {'key1': 'value1'}
        target = {'key2': 'value2'}

        new = du.merge_dict(base, target)

        self.assertIn('key2', new.keys())
        self.assertEqual('value2', new['key2'])
Exemplo n.º 10
0
    def test_merging_nested_dicts(self):
        base = {'key1': 'value1'}
        target = {'key2': {'key2.1': 'value2'}}

        new = du.merge_dict(base, target)

        self.assertIn('key2', new.keys())
        self.assertIn('key2.1', new['key2'].keys())
Exemplo n.º 11
0
    def test_merging_dict(self):
        base = {'key1': 'value1'}
        target = {'key2': 'value2'}

        new = du.merge_dict(base, target)

        self.assertIn('key2', new.keys())
        self.assertEqual('value2', new['key2'])
Exemplo n.º 12
0
    def test_merging_nested_dicts(self):
        base = {"key1": "value1"}
        target = {"key2": {"key2.1": "value2"}}

        new = du.merge_dict(base, target)

        self.assertIn("key2", new.keys())
        self.assertIn("key2.1", new["key2"].keys())
Exemplo n.º 13
0
    def test_merging_dict(self):
        base = {"key1": "value1"}
        target = {"key2": "value2"}

        new = du.merge_dict(base, target)

        self.assertIn("key2", new.keys())
        self.assertEqual("value2", new["key2"])