示例#1
0
 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'))
示例#2
0
    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)
示例#3
0
 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')
示例#4
0
 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')
示例#5
0
 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')
示例#6
0
 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)
示例#7
0
 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'))
示例#8
0
    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
示例#9
0
    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)
示例#10
0
    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
示例#11
0
 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'))
示例#12
0
    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
示例#13
0
    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
示例#14
0
    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)
示例#15
0
    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)
示例#16
0
    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
示例#17
0
    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
示例#18
0
    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)
示例#19
0
    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()
示例#20
0
 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
示例#21
0
    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)
示例#22
0
 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
示例#23
0
    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()
示例#24
0
    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)
示例#25
0
    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)
示例#26
0
    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)
示例#27
0
    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)
示例#28
0
 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
示例#29
0
 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
示例#30
0
 def __init__(self):
     self._db = db_api.get_instance().get_module_info()
示例#31
0
 def _check_enabled(self, name):
     enable_state = db_api.get_instance().get_module_info()
     return enable_state.get_state('collector_{}'.format(name))
示例#32
0
 def _check_enabled(self, name):
     enable_state = db_api.get_instance().get_module_enable_state()
     return enable_state.get_state('collector_{}'.format(name))
示例#33
0
 def __init__(self):
     self._db = db_api.get_instance().get_service_to_collector_mapping()
示例#34
0
 def __init__(self):
     self._db = db_api.get_instance().get_module_enable_state()
示例#35
0
 def __init__(self):
     self._db = db_api.get_instance().get_module_info()
示例#36
0
 def __init__(self):
     self._db = db_api.get_instance().get_service_to_collector_mapping()
示例#37
0
 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'))
示例#38
0
 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()