コード例 #1
0
ファイル: _config_driver.py プロジェクト: 4383/castellan
    def get(self, group_name, option_name, opt):
        try:
            group_name = group_name or "DEFAULT"

            castellan_id = self._mapping[group_name][option_name][0]

            return (self._mngr.get("ctx", castellan_id).get_encoded().decode(),
                    cfg.LocationInfo(cfg.Locations.user, castellan_id))

        except KeyError:
            # no mapping 'option = castellan_id'
            LOG.info("option '[%s] %s' not present in '[%s] mapping_file'",
                     group_name, option_name, self._name)

        except KeyManagerError:
            # bad mapping 'option =' without a castellan_id
            LOG.warning(
                "missing castellan_id for option "
                "'[%s] %s' in '[%s] mapping_file'", group_name, option_name,
                self._name)

        except ManagedObjectNotFoundError:
            # good mapping, but unknown castellan_id by secret manager
            LOG.warning(
                "invalid castellan_id for option "
                "'[%s] %s' in '[%s] mapping_file'", group_name, option_name,
                self._name)

        return (sources._NoValue, None)
コード例 #2
0
    def test_only_old_default_policy_file_exist(self, mock_get):
        mock_get.return_value = cfg.LocationInfo(cfg.Locations.set_default,
                                                 'None')
        tmpfilename = os.path.join(self.tmpdir.path, 'policy.json')
        with open(tmpfilename, 'w') as fh:
            jsonutils.dump(self.data, fh)

        selected_policy_file = policy.pick_policy_file(policy_file=None)
        self.assertEqual(policy.CONF.oslo_policy.policy_file, 'policy.yaml')
        self.assertEqual(selected_policy_file, 'policy.json')
コード例 #3
0
 def test_duplicate_registration(self):
     # NOTE(dhellmann): The ZFS driver in Cinder uses multiple Opt
     # instances with the same settings but in different
     # modules. We don't want to break that case with the option
     # location stuff, so we need to test that it works. To
     # reproduce that test we have to simulate the option being
     # created in a different file, so we create a new Opt instance
     # and replace its _set_location data.
     dupe_opt = cfg.StrOpt(
         'normal_opt',
         default='normal_opt_default',
     )
     dupe_opt._set_location = cfg.LocationInfo(
         cfg.Locations.opt_default,
         'an alternative file',
     )
     # We expect register_opt() to return False to indicate that
     # the option was already registered.
     self.assertFalse(self.conf.register_opt(dupe_opt))