def test_enable_module(self): with mock.patch('cloudkitty.messaging.get_client') as rpcmock: rpcmock.return_value = self._fake_rpc self._module.set_state(True) db_api = ck_db_api.get_instance() module_db = db_api.get_module_info() self.assertTrue(module_db.get_state('fake'))
def priority(self): """Get the priority of the module. """ api = db_api.get_instance() module_db = api.get_module_info() return module_db.get_priority(self.module_name)
def setUp(self): super(TestCase, self).setUp() self.conf = self.useFixture(config_fixture.Config()).conf self.conf.set_override('connection', self.db_url, 'database') self.conn = ck_db_api.get_instance() migration = self.conn.get_migration() migration.upgrade('head')
def start_fixture(self): self.conf = None conf = conf_fixture.Config().conf policy_opts.set_defaults(conf) msg_conf = conffixture.ConfFixture(conf) msg_conf.transport_driver = 'fake' conf.import_group('api', 'cloudkitty.api.app') conf.set_override('auth_strategy', 'noauth', enforce_type=True) conf.set_override('connection', 'sqlite:///', 'database', enforce_type=True) conf.set_override('policy_file', os.path.abspath('etc/cloudkitty/policy.json'), group='oslo_policy', enforce_type=True) conf.set_override('api_paste_config', os.path.abspath( 'cloudkitty/tests/gabbi/gabbi_paste.ini') ) conf.import_group('storage', 'cloudkitty.storage') conf.set_override('backend', 'sqlalchemy', 'storage', enforce_type=True) self.conf = conf self.conn = ck_db_api.get_instance() migration = self.conn.get_migration() migration.upgrade('head')
def test_enabled_property(self): db_api = ck_db_api.get_instance() module_db = db_api.get_module_enable_state() module_db.set_state('fake', True) self.assertTrue(self._module.enabled) module_db.set_state('fake', False) self.assertFalse(self._module.enabled)
def test_disable_module(self): with mock.patch('cloudkitty.rpc.get_client') as rpcmock: rpcmock.return_value = self._fake_rpc self._module.set_state(False) db_api = ck_db_api.get_instance() module_db = db_api.get_module_enable_state() self.assertFalse(module_db.get_state('fake'))
def get(self): """Get module status """ api = db_api.get_instance() module_db = api.get_module_enable_state() return module_db.get_state(self.module_name) or False
def enabled(self): """Check if the module is enabled :returns: bool if module is enabled """ api = db_api.get_instance() module_db = api.get_module_info() return module_db.get_state(self.module_name) or False
def enabled(self): """Check if the module is enabled :returns: bool if module is enabled """ api = db_api.get_instance() module_db = api.get_module_enable_state() return module_db.get_state(self.module_name) or False
def put(self, state): """Set module status :param state: State to set. :return: New state set for the module. """ api = db_api.get_instance() module_db = api.get_module_enable_state() return module_db.set_state(self.module_name, state)
def enabled(self): """Check if the module is enabled :returns: bool if module is enabled """ # FIXME(sheeprine): Hardcoded values to check the state api = db_api.get_instance() module_db = api.get_module_enable_state() return module_db.get_state('hashmap') or False
def set_priority(self, priority): """Set the priority of the module. :param priority: (int) The new priority, the higher the number, the higher the priority. """ api = db_api.get_instance() module_db = api.get_module_info() self.notify_reload() return module_db.set_priority(self.module_name, priority)
def __init__(self, transformers, **kwargs): super(MetaCollector, self).__init__(transformers, **kwargs) self._db = db_api.get_instance().get_service_to_collector_mapping() self._collectors = {} self._load_collectors() self._mappings = {} self._load_mappings()
def get_module_migration(self, name): if name == 'cloudkitty': mod_migration = db_api.get_instance().get_migration() else: try: module = self.billing_models[name] mod_migration = module.get_migrate() except IndexError: raise ModuleNotFound(name) return mod_migration
def get_module_migration(self, name): if name == 'cloudkitty': mod_migration = db_api.get_instance().get_migration() else: try: module = self.rating_models[name] mod_migration = module.get_migration() except KeyError: raise ModuleNotFound(name) return mod_migration
def set_state(self, enabled): """Enable or disable a module. :param enabled: (bool) The state to put the module in. :return: bool """ api = db_api.get_instance() module_db = api.get_module_info() client = rpc.get_client().prepare(namespace='rating', fanout=True) if enabled: operation = 'enable_module' else: operation = 'disable_module' client.cast({}, operation, name=self.module_name) return module_db.set_state(self.module_name, enabled)
def put(self, state): """Set module status :param state: State to set. :return: New state set for the module. """ api = db_api.get_instance() module_db = api.get_module_enable_state() client = pecan.request.rpc_client.prepare(namespace='billing', fanout=True) if state: operation = 'enable_module' else: operation = 'disable_module' client.cast({}, operation, name=self.module_name) return module_db.set_state(self.module_name, state)
def set_state(self, enabled): """Enable or disable a module. :param enabled: (bool) The state to put the module in. :return: bool """ api = db_api.get_instance() module_db = api.get_module_info() client = messaging.get_client().prepare(namespace='rating', fanout=True) if enabled: operation = 'enable_module' else: operation = 'disable_module' client.cast({}, operation, name=self.module_name) return module_db.set_state(self.module_name, enabled)
def setUp(self): super(TestCase, self).setUp() self._conf_fixture = self.useFixture(config_fixture.Config()) self.conf = self._conf_fixture.conf self.conf.set_override('connection', self.db_url, 'database') self.conn = ck_db_api.get_instance() migration = self.conn.get_migration() migration.upgrade('head') auth = mock.patch('keystoneauth1.loading.load_auth_from_conf_options', return_value=dict()) auth.start() self.auth = auth session = mock.patch( 'keystoneauth1.loading.load_session_from_conf_options', return_value=ks_sess.Session()) session.start() self.session = session
def setUp(self): super(TestCase, self).setUp() self._conf_fixture = self.useFixture(config_fixture.Config()) self.conf = self._conf_fixture.conf self.conf.set_override('connection', self.db_url, 'database') self.conn = ck_db_api.get_instance() migration = self.conn.get_migration() migration.upgrade('head') auth = mock.patch( 'keystoneauth1.loading.load_auth_from_conf_options', return_value=dict()) auth.start() self.auth = auth session = mock.patch( 'keystoneauth1.loading.load_session_from_conf_options', return_value=dict()) session.start() self.session = session
def __init__(self): self._db = db_api.get_instance().get_module_info()
def _check_enabled(self, name): enable_state = db_api.get_instance().get_module_info() return enable_state.get_state('collector_{}'.format(name))
def _check_enabled(self, name): enable_state = db_api.get_instance().get_module_enable_state() return enable_state.get_state('collector_{}'.format(name))
def __init__(self): self._db = db_api.get_instance().get_service_to_collector_mapping()
def __init__(self): self._db = db_api.get_instance().get_module_enable_state()
def test_set_priority(self): self._module.set_priority(10) db_api = ck_db_api.get_instance() module_db = db_api.get_module_info() self.assertEqual(10, module_db.get_priority('fake'))
def __init__(self, user_id, report_type, distributed=False): self._state_name = self._gen_name(report_type, user_id) self._distributed = distributed self._db = api.get_instance().get_state()