예제 #1
0
    def __init__(self, write_orchestrator, user_id, backend, basepath=None):
        self._write_orchestrator = write_orchestrator
        self._backend = backend
        self._uid = user_id
        self._sm = state.DBStateManager(self._uid,
                                        self.report_type)
        self._report = None
        self._period = 3600

        self._basepath = basepath

        # State vars
        self.checked_first_line = False
        self.usage_start = None
        self.usage_start_dt = None
        self.usage_end = None
        self.usage_end_dt = None

        # Current total
        self.total = 0

        # Current usage period lines
        self._usage_data = {}
예제 #2
0
    def __init__(self,
                 backend,
                 tenant_id,
                 storage,
                 basepath=None,
                 period=3600):
        self._backend = backend
        self._tenant_id = tenant_id
        self._storage = storage
        self._storage_state = storage_state.StateManager()
        self._basepath = basepath
        if self._basepath:
            fileutils.ensure_tree(self._basepath)
        self._period = period
        self._sm = state.DBStateManager(self._tenant_id, 'writer_status')
        self._write_pipeline = []

        # State vars
        self.usage_start = None
        self.usage_end = None

        # Current total
        self.total = 0
예제 #3
0
    def __init__(self):
        self.keystone = kclient.Client(username=CONF.auth.username,
                                       password=CONF.auth.password,
                                       tenant_name=CONF.auth.tenant,
                                       region_name=CONF.auth.region,
                                       auth_url=CONF.auth.url)

        s_backend = i_utils.import_class(CONF.state.backend)
        self.sm = state.DBStateManager(self.keystone.user_id, 'osrtf')

        collector_args = {
            'user': CONF.auth.username,
            'password': CONF.auth.password,
            'tenant': CONF.auth.tenant,
            'region': CONF.auth.region,
            'keystone_url': CONF.auth.url,
            'period': CONF.collect.period
        }
        self.collector = driver.DriverManager(
            'cloudkitty.collector.backends',
            CONF.collect.collector,
            invoke_on_load=True,
            invoke_kwds=collector_args).driver

        w_backend = i_utils.import_class(CONF.output.backend)
        self.wo = w_orch.WriteOrchestrator(w_backend, s_backend,
                                           self.keystone.user_id, self.sm)

        # Billing processors
        self.b_processors = {}
        self._load_billing_processors()

        # Output settings
        output_pipeline = named.NamedExtensionManager(
            'cloudkitty.output.writers', CONF.output.pipeline)
        for writer in output_pipeline:
            self.wo.add_writer(writer.plugin)
예제 #4
0
 def setUp(self):
     super(DBStateManagerTest, self).setUp()
     self.sm = state.DBStateManager('testuser', 'osrtf')