Ejemplo n.º 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'))
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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'))
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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'))
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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()
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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()
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 30
0
 def __init__(self):
     self._db = db_api.get_instance().get_module_info()
Ejemplo n.º 31
0
 def _check_enabled(self, name):
     enable_state = db_api.get_instance().get_module_info()
     return enable_state.get_state('collector_{}'.format(name))
Ejemplo n.º 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))
Ejemplo n.º 33
0
 def __init__(self):
     self._db = db_api.get_instance().get_service_to_collector_mapping()
Ejemplo n.º 34
0
 def __init__(self):
     self._db = db_api.get_instance().get_module_enable_state()
Ejemplo n.º 35
0
 def __init__(self):
     self._db = db_api.get_instance().get_module_info()
Ejemplo n.º 36
0
 def __init__(self):
     self._db = db_api.get_instance().get_service_to_collector_mapping()
Ejemplo n.º 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'))
Ejemplo n.º 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()