コード例 #1
0
ファイル: cli.py プロジェクト: Simplit-openapps/ceilometer
def agent_notification():
    service.prepare_service()
    launcher = os_service.ProcessLauncher()
    launcher.launch_service(
        notification.NotificationService(),
        workers=service.get_workers('notification'))
    launcher.wait()
コード例 #2
0
ファイル: test_client.py プロジェクト: Hopebaytech/ceilometer
    def setUp(self):
        super(TestClientHTTPBasicAuth, self).setUp()
        self.conf = self.useFixture(config_fixture.Config())
        ceilometer_service.prepare_service(argv=[], config_files=[])
        self.parsed_url = urlparse.urlparse(
            'http://127.0.0.1:8080/controller/nb/v2?container_name=default&'
            'container_name=egg&auth=%s&user=admin&password=admin_pass&'
            'scheme=%s' % (self.auth_way, self.scheme))
        self.params = urlparse.parse_qs(self.parsed_url.query)
        self.endpoint = urlparse.urlunparse(
            urlparse.ParseResult(self.scheme,
                                 self.parsed_url.netloc,
                                 self.parsed_url.path,
                                 None, None, None))
        odl_params = {'auth': self.params.get('auth')[0],
                      'user': self.params.get('user')[0],
                      'password': self.params.get('password')[0]}
        self.client = client.Client(self.endpoint, odl_params)

        self.resp = mock.MagicMock()
        self.get = mock.patch('requests.get',
                              return_value=self.resp).start()

        self.resp.raw.version = 1.1
        self.resp.status_code = 200
        self.resp.reason = 'OK'
        self.resp.headers = {}
        self.resp.content = 'dummy'
コード例 #3
0
ファイル: cli.py プロジェクト: Simplit-openapps/ceilometer
def collector_service():
    service.prepare_service()
    launcher = os_service.ProcessLauncher()
    launcher.launch_service(
        collector.CollectorService(),
        workers=service.get_workers('collector'))
    launcher.wait()
コード例 #4
0
ファイル: storage.py プロジェクト: cloudbase/ceilometer
def upgrade():
    conf = cfg.ConfigOpts()
    conf.register_cli_opts([
        cfg.BoolOpt('skip-metering-database',
                    help='Skip metering database upgrade.',
                    default=False),
        cfg.BoolOpt('skip-gnocchi-resource-types',
                    help='Skip gnocchi resource-types upgrade.',
                    default=False),
    ])

    service.prepare_service(conf=conf)
    if conf.skip_metering_database:
        LOG.info("Skipping metering database upgrade")
    else:

        url = (getattr(conf.database, 'metering_connection') or
               conf.database.connection)
        if url:
            LOG.debug("Upgrading metering database")
            storage.get_connection(conf, url).upgrade()
        else:
            LOG.info("Skipping metering database upgrade, "
                     "legacy database backend not configured.")

    if conf.skip_gnocchi_resource_types:
        LOG.info("Skipping Gnocchi resource types upgrade")
    else:
        LOG.debug("Upgrading Gnocchi resource types")
        from ceilometer import gnocchi_client
        gnocchi_client.upgrade_resource_types(conf)
コード例 #5
0
ファイル: api.py プロジェクト: gyliu513/ceilometer
 def setUp(self):
     super(FunctionalTest, self).setUp()
     service.prepare_service()
     cfg.CONF.set_override("auth_version", "v2.0", group=acl.OPT_GROUP_NAME)
     cfg.CONF.set_override("policy_file",
                           self.path_get('tests/policy.json'))
     self.app = self._make_app()
コード例 #6
0
 def setUp(self):
     super(TestHardwareDiscovery, self).setUp()
     self.CONF = self.useFixture(fixture_config.Config()).conf
     service.prepare_service([], [], self.CONF)
     self.discovery = hardware.NodesDiscoveryTripleO(self.CONF)
     self.discovery.nova_cli = mock.MagicMock()
     self.manager = mock.MagicMock()
コード例 #7
0
def main():
    service.prepare_service()

    sm = cotyledon.ServiceManager()
    sm.add(notification.NotificationService,
           workers=CONF.notification.workers)
    sm.run()
コード例 #8
0
ファイル: base.py プロジェクト: andymcc/ceilometer
    def setUp(self):
        super(TestPollsterBase, self).setUp()
        self.CONF = self.useFixture(fixture_config.Config()).conf
        service.prepare_service([], [], self.CONF)

        self.inspector = mock.Mock()
        self.instance = mock.MagicMock()
        self.instance.name = 'instance-00000001'
        setattr(self.instance, 'OS-EXT-SRV-ATTR:instance_name',
                self.instance.name)
        setattr(self.instance, 'OS-EXT-STS:vm_state',
                'active')
        setattr(self.instance, 'OS-EXT-STS:task_state', None)
        self.instance.id = 1
        self.instance.flavor = {'name': 'm1.small', 'id': 2, 'vcpus': 1,
                                'ram': 512, 'disk': 20, 'ephemeral': 0}
        self.instance.status = 'active'
        self.instance.metadata = {
            'fqdn': 'vm_fqdn',
            'metering.stack': '2cadc4b4-8789-123c-b4eg-edd2f0a9c128',
            'project_cos': 'dev'}

        patch_virt = mockpatch.Patch(
            'ceilometer.compute.virt.inspector.get_hypervisor_inspector',
            new=mock.Mock(return_value=self.inspector))
        self.useFixture(patch_virt)

        # as we're having lazy hypervisor inspector singleton object in the
        # base compute pollster class, that leads to the fact that we
        # need to mock all this class property to avoid context sharing between
        # the tests
        patch_inspector = mockpatch.Patch(
            'ceilometer.compute.pollsters.BaseComputePollster.inspector',
            self.inspector)
        self.useFixture(patch_inspector)
コード例 #9
0
ファイル: storage.py プロジェクト: openstack/ceilometer
def upgrade():
    conf = cfg.ConfigOpts()
    conf.register_cli_opts([
        cfg.BoolOpt('skip-gnocchi-resource-types',
                    help='Skip gnocchi resource-types upgrade.',
                    default=False),
        cfg.IntOpt('retry',
                   min=0,
                   help='Number of times to retry on failure. '
                   'Default is to retry forever.'),
    ])

    service.prepare_service(conf=conf)
    if conf.skip_gnocchi_resource_types:
        LOG.info("Skipping Gnocchi resource types upgrade")
    else:
        LOG.debug("Upgrading Gnocchi resource types")
        from ceilometer import gnocchi_client
        from gnocchiclient import exceptions
        if conf.retry is None:
            stop = tenacity.stop_never
        else:
            stop = tenacity.stop_after_attempt(conf.retry)
        tenacity.Retrying(
            stop=stop,
            retry=tenacity.retry_if_exception_type((
                exceptions.ConnectionFailure,
                exceptions.UnknownConnectionError,
                exceptions.ConnectionTimeout,
                exceptions.SSLError,
            ))
        )(gnocchi_client.upgrade_resource_types, conf)
コード例 #10
0
ファイル: storage.py プロジェクト: andymcc/ceilometer
def upgrade():
    conf = cfg.ConfigOpts()
    conf.register_cli_opts([
        cfg.BoolOpt('skip-metering-database',
                    help='Skip metering database upgrade.',
                    default=False),
        cfg.BoolOpt('skip-event-database',
                    help='Skip event database upgrade.',
                    default=False),
        cfg.BoolOpt('skip-gnocchi-resource-types',
                    help='Skip gnocchi resource-types upgrade.',
                    default=False),
    ])

    service.prepare_service(conf=conf)
    if conf.skip_metering_database:
        LOG.info("Skipping metering database upgrade")
    else:
        LOG.debug("Upgrading metering database")
        storage.get_connection_from_config(conf, 'metering').upgrade()

    if conf.skip_event_database:
        LOG.info("Skipping event database upgrade")
    else:
        LOG.debug("Upgrading event database")
        storage.get_connection_from_config(conf, 'event').upgrade()

    if conf.skip_gnocchi_resource_types:
        LOG.info("Skipping Gnocchi resource types upgrade")
    else:
        LOG.debug("Upgrading Gnocchi resource types")
        from ceilometer import gnocchi_client
        gnocchi_client.upgrade_resource_types(conf)
コード例 #11
0
ファイル: test_gnocchi.py プロジェクト: dtsapikov/ceilometer
    def setUp(self):
        super(DispatcherWorkflowTest, self).setUp()
        self.conf = self.useFixture(config_fixture.Config())
        # Set this explicitly to avoid conflicts with any existing
        # configuration.
        self.conf.config(url='http://localhost:8041',
                         group='dispatcher_gnocchi')
        ks_client = mock.Mock()
        ks_client.projects.find.return_value = mock.Mock(
            name='gnocchi', id='a2d42c23-d518-46b6-96ab-3fba2e146859')
        self.useFixture(mockpatch.Patch(
            'ceilometer.keystone_client.get_client',
            return_value=ks_client))
        self.ks_client = ks_client

        ceilometer_service.prepare_service(argv=[], config_files=[])
        self.conf.config(
            resources_definition_file=self.path_get(
                'etc/ceilometer/gnocchi_resources.yaml'),
            group="dispatcher_gnocchi"
        )

        self.sample['resource_id'] = str(uuid.uuid4()) + "/foobar"
        self.sample['message_signature'] = utils.compute_signature(
            self.sample, self.conf.conf.publisher.telemetry_secret)
コード例 #12
0
ファイル: test_converter.py プロジェクト: ityaptin/ceilometer
    def setUp(self):
        super(TestNotificationConverter, self).setUp()
        self.CONF = self.useFixture(fixture_config.Config()).conf
        ceilometer_service.prepare_service(argv=[], config_files=[])
        self.valid_event_def1 = [{
            'event_type': 'compute.instance.create.*',
            'traits': {
                'instance_id': {
                    'type': 'text',
                    'fields': ['payload.instance_uuid',
                               'payload.instance_id'],
                },
                'host': {
                    'type': 'text',
                    'fields': 'payload.host',
                },
            },
        }]

        self.test_notification1 = self._create_test_notification(
            "compute.instance.create.start",
            "uuid-for-notif-0001",
            instance_id="uuid-for-instance-0001",
            host='host-1-2-3')
        self.test_notification2 = self._create_test_notification(
            "bogus.notification.from.mars",
            "uuid-for-notif-0002",
            weird='true',
            host='cydonia')
        self.fake_plugin_mgr = {}
コード例 #13
0
ファイル: fixtures.py プロジェクト: gitter-badger/ceilometer
    def start_fixture(self):
        """Set up config."""

        service.prepare_service([])
        conf = fixture_config.Config().conf
        self.conf = conf
        conf.import_opt('policy_file', 'ceilometer.openstack.common.policy')
        conf.set_override('policy_file',
                          os.path.abspath('etc/ceilometer/policy.json'))

        # A special pipeline is required to use the direct publisher.
        conf.set_override('pipeline_cfg_file',
                          'etc/ceilometer/gabbi_pipeline.yaml')

        # Determine the database connection.
        db_url = None
        for engine in ENGINES:
            try:
                db_url = os.environ['CEILOMETER_TEST_%s_URL' % engine]
            except KeyError:
                pass
        if db_url is None:
            raise case.SkipTest('No database connection configured')

        database_name = '%s-%s' % (db_url, str(uuid.uuid4()))
        conf.set_override('connection', database_name, group='database')
        conf.set_override('metering_connection', '', group='database')
        conf.set_override('event_connection', '', group='database')
        conf.set_override('alarm_connection', '', group='database')

        conf.set_override('pecan_debug', True, group='api')
コード例 #14
0
def expirer():
    service.prepare_service()

    if cfg.CONF.database.metering_time_to_live > 0:
        LOG.debug(_("Clearing expired metering data"))
        storage_conn = storage.get_connection_from_config(cfg.CONF, 'metering')
        storage_conn.clear_expired_metering_data(
            cfg.CONF.database.metering_time_to_live)
    else:
        LOG.info(_LI("Nothing to clean, database metering time to live "
                     "is disabled"))

    if cfg.CONF.database.event_time_to_live > 0:
        LOG.debug(_("Clearing expired event data"))
        event_conn = storage.get_connection_from_config(cfg.CONF, 'event')
        event_conn.clear_expired_event_data(
            cfg.CONF.database.event_time_to_live)
    else:
        LOG.info(_LI("Nothing to clean, database event time to live "
                     "is disabled"))

    if cfg.CONF.database.alarm_history_time_to_live > 0:
        LOG.debug("Clearing expired alarm history data")
        storage_conn = storage.get_connection_from_config(cfg.CONF, 'alarm')
        storage_conn.clear_expired_alarm_history_data(
            cfg.CONF.database.alarm_history_time_to_live)
    else:
        LOG.info(_LI("Nothing to clean, database alarm history time to live "
                     "is disabled"))
コード例 #15
0
ファイル: cli.py プロジェクト: savi-dev/ceilometer
def agent_notification():
    service.prepare_service()
    launcher = os_service.ProcessLauncher()
    launcher.launch_service(
        notification.NotificationService(cfg.CONF.host,
                                         'ceilometer.agent.notification'),
        workers=service.get_workers('notification'))
    launcher.wait()
コード例 #16
0
ファイル: cli.py プロジェクト: savi-dev/ceilometer
def collector_service():
    service.prepare_service()
    launcher = os_service.ProcessLauncher()
    launcher.launch_service(
        collector.CollectorService(cfg.CONF.host,
                                   'ceilometer.collector'),
        workers=service.get_workers('collector'))
    launcher.wait()
コード例 #17
0
ファイル: polling.py プロジェクト: andymcc/ceilometer
def main():
    conf = cfg.ConfigOpts()
    conf.register_cli_opts(CLI_OPTS)
    service.prepare_service(conf=conf)
    sm = cotyledon.ServiceManager()
    sm.add(create_polling_service, args=(conf,))
    oslo_config_glue.setup(sm, conf)
    sm.run()
コード例 #18
0
ファイル: send_test_data.py プロジェクト: isyippee/ceilometer
def get_notifier(config_file):
    service.prepare_service(argv=['/', '--config-file', config_file])
    return oslo_messaging.Notifier(
        messaging.get_transport(),
        driver='messagingv2',
        publisher_id='telemetry.publisher.test',
        topic='metering',
    )
コード例 #19
0
 def setUp(self):
     super(TestEndpointDiscovery, self).setUp()
     self.CONF = self.useFixture(fixture_config.Config()).conf
     service.prepare_service([], [], self.CONF)
     self.CONF.set_override("interface", "publicURL", group="service_credentials")
     self.CONF.set_override("region_name", "test-region-name", group="service_credentials")
     self.discovery = endpoint.EndpointDiscovery(self.CONF)
     self.manager = mock.MagicMock()
     self.catalog = self.manager.keystone.session.auth.get_access.return_value.service_catalog
コード例 #20
0
ファイル: test_app.py プロジェクト: gyliu513/ceilometer
 def test_keystone_middleware_conf(self):
     service.prepare_service()
     cfg.CONF.set_override("auth_protocol", "foottp",
                           group=acl.OPT_GROUP_NAME)
     cfg.CONF.set_override("auth_version", "v2.0", group=acl.OPT_GROUP_NAME)
     cfg.CONF.set_override("pipeline_cfg_file",
                           self.path_get("etc/ceilometer/pipeline.yaml"))
     api_app = app.setup_app()
     self.assertEqual(api_app.auth_protocol, 'foottp')
コード例 #21
0
 def setUp(self):
     super(TestGenericPollsters, self).setUp()
     self.conf = self.useFixture(fixture_config.Config()).conf
     self.resources = ["snmp://test", "snmp://test2"]
     self.useFixture(mockpatch.Patch(
         'ceilometer.hardware.inspector.get_inspector',
         self.faux_get_inspector))
     ceilometer_service.prepare_service(argv=[], config_files=[])
     self.pollster = generic.GenericHardwareDeclarativePollster()
コード例 #22
0
ファイル: cli.py プロジェクト: Simplit-openapps/ceilometer
def storage_expirer():
    service.prepare_service()
    if cfg.CONF.database.time_to_live > 0:
        LOG.debug(_("Clearing expired metering data"))
        storage_conn = storage.get_connection_from_config(cfg.CONF)
        storage_conn.clear_expired_metering_data(
            cfg.CONF.database.time_to_live)
    else:
        LOG.info(_("Nothing to clean, database time to live is disabled"))
コード例 #23
0
ファイル: polling.py プロジェクト: openstack/ceilometer
def main():
    conf = cfg.ConfigOpts()
    conf.register_cli_opts(CLI_OPTS)
    service.prepare_service(conf=conf)
    priv_context.init(root_helper=shlex.split(utils._get_root_helper()))
    sm = cotyledon.ServiceManager()
    sm.add(create_polling_service, args=(conf,))
    oslo_config_glue.setup(sm, conf)
    sm.run()
コード例 #24
0
ファイル: alarm.py プロジェクト: StarThinking/Ceilometer-Test
def evaluator():
    service.prepare_service()
    eval_service_mgr = driver.DriverManager(
        "ceilometer.alarm.evaluator_service",
        cfg.CONF.alarm.evaluation_service,
        invoke_on_load=True)
    LOG.debug("Alarm evaluator loaded: %s" %
              eval_service_mgr.driver.__class__.__name__)
    os_service.launch(eval_service_mgr.driver).wait()
コード例 #25
0
ファイル: test_app.py プロジェクト: 100PercentIT/ceilometer
 def test_keystone_middleware_parse_conffile(self):
     tmpfile = tempfile.mktemp()
     with open(tmpfile, "w") as f:
         f.write("[%s]\nauth_protocol = barttp" % acl.OPT_GROUP_NAME)
     service.prepare_service(['ceilometer-api',
                              '--config-file=%s' % tmpfile])
     api_app = app.make_app(cfg.CONF, attach_storage=False)
     self.assertEqual(api_app.wsgi_app.auth_protocol, 'barttp')
     os.unlink(tmpfile)
コード例 #26
0
ファイル: test_gnocchi.py プロジェクト: dtsapikov/ceilometer
    def setUp(self):
        super(DispatcherTest, self).setUp()
        self.conf = self.useFixture(config_fixture.Config())
        ceilometer_service.prepare_service(argv=[], config_files=[])
        self.conf.config(
            resources_definition_file=self.path_get(
                'etc/ceilometer/gnocchi_resources.yaml'),
            group="dispatcher_gnocchi"
        )
        self.resource_id = str(uuid.uuid4())
        self.samples = [{
            'counter_name': 'disk.root.size',
            'counter_unit': 'GB',
            'counter_type': 'gauge',
            'counter_volume': '2',
            'user_id': 'test_user',
            'project_id': 'test_project',
            'source': 'openstack',
            'timestamp': '2012-05-08 20:23:48.028195',
            'resource_id': self.resource_id,
            'resource_metadata': {
                'host': 'foo',
                'image_ref': 'imageref!',
                'instance_flavor_id': 1234,
                'display_name': 'myinstance',
                }
            },
            {
                'counter_name': 'disk.root.size',
                'counter_unit': 'GB',
                'counter_type': 'gauge',
                'counter_volume': '2',
                'user_id': 'test_user',
                'project_id': 'test_project',
                'source': 'openstack',
                'timestamp': '2014-05-08 20:23:48.028195',
                'resource_id': self.resource_id,
                'resource_metadata': {
                    'host': 'foo',
                    'image_ref': 'imageref!',
                    'instance_flavor_id': 1234,
                    'display_name': 'myinstance',
                }
            }]
        for sample in self.samples:
            sample['message_signature'] = utils.compute_signature(
                sample, self.conf.conf.publisher.telemetry_secret)

        ks_client = mock.Mock(auth_token='fake_token')
        ks_client.projects.find.return_value = mock.Mock(
            name='gnocchi', id='a2d42c23-d518-46b6-96ab-3fba2e146859')
        self.useFixture(mockpatch.Patch(
            'ceilometer.keystone_client.get_client',
            return_value=ks_client))
        self.ks_client = ks_client
        self.conf.conf.dispatcher_gnocchi.filter_service_activity = True
コード例 #27
0
    def __init__(self, app, conf):
        self.app = app
        service.prepare_service()
        publisher_manager = dispatch.NameDispatchExtensionManager(
            namespace=pipeline.PUBLISHER_NAMESPACE,
            check_func=lambda x: True,
            invoke_on_load=True,
        )

        self.pipeline_manager = pipeline.setup_pipeline(publisher_manager)
コード例 #28
0
ファイル: test_app.py プロジェクト: JioCloud/ceilometer
 def test_keystone_middleware_parse_conffile(self):
     tmpfile = self.temp_config_file_path()
     with open(tmpfile, "w") as f:
         f.write("[%s]\nauth_protocol = file" % acl.OPT_GROUP_NAME)
         f.write("\nauth_version = v2.0")
     service.prepare_service(['ceilometer-api',
                              '--config-file=%s' % tmpfile])
     api_app = app.make_app(cfg.CONF, attach_storage=False)
     self.assertTrue(api_app.wsgi_app.auth_uri.startswith('file'))
     os.unlink(tmpfile)
コード例 #29
0
ファイル: test_app.py プロジェクト: shaoyexin/ceilometer
 def test_keystone_middleware_parse_conffile(self):
     tmpfile = tempfile.mktemp()
     with open(tmpfile, "w") as f:
         f.write("[%s]\nauth_protocol = barttp" % acl.OPT_GROUP_NAME)
         f.write("\nauth_version = v2.0")
     service.prepare_service(['ceilometer-api',
                              '--config-file=%s' % tmpfile])
     api_app = app.setup_app()
     self.assertEqual(api_app.auth_protocol, 'barttp')
     os.unlink(tmpfile)
コード例 #30
0
ファイル: test_app.py プロジェクト: Adrian-Turjak/ceilometer
 def test_keystone_middleware_parse_conffile(self):
     content = "[{0}]\nauth_protocol = barttp"\
               "\nauth_version = v2.0".format(acl.OPT_GROUP_NAME)
     tmpfile = fileutils.write_to_tempfile(content=content,
                                           prefix='ceilometer',
                                           suffix='.conf')
     service.prepare_service(['ceilometer-api',
                              '--config-file=%s' % tmpfile])
     api_app = app.make_app(self.CONF, attach_storage=False)
     self.assertTrue(api_app.wsgi_app.auth_uri.startswith('barttp'))
     os.unlink(tmpfile)
コード例 #31
0
ファイル: test_discovery.py プロジェクト: hulaile/ceilometer
 def setUp(self):
     super(TestEndpointDiscovery, self).setUp()
     conf = service.prepare_service([], [])
     self.CONF = self.useFixture(fixture_config.Config(conf)).conf
     self.CONF.set_override('interface',
                            'publicURL',
                            group='service_credentials')
     self.CONF.set_override('region_name',
                            'test-region-name',
                            group='service_credentials')
     self.discovery = endpoint.EndpointDiscovery(self.CONF)
     self.manager = mock.MagicMock()
     self.catalog = (self.manager.keystone.session.auth.get_access.
                     return_value.service_catalog)
コード例 #32
0
ファイル: test_gnocchi.py プロジェクト: crowdy/ceilometer
    def setUp(self):
        super(PublisherTest, self).setUp()
        conf = ceilometer_service.prepare_service(argv=[], config_files=[])
        self.conf = self.useFixture(config_fixture.Config(conf))
        self.resource_id = str(uuid.uuid4())
        self.samples = [
            sample.Sample(name='disk.root.size',
                          unit='GB',
                          type=sample.TYPE_GAUGE,
                          volume=2,
                          user_id='test_user',
                          project_id='test_project',
                          source='openstack',
                          timestamp='2012-05-08 20:23:48.028195',
                          resource_id=self.resource_id,
                          resource_metadata={
                              'host': 'foo',
                              'image_ref': 'imageref!',
                              'instance_flavor_id': 1234,
                              'display_name': 'myinstance',
                          }),
            sample.Sample(
                name='disk.root.size',
                unit='GB',
                type=sample.TYPE_GAUGE,
                volume=2,
                user_id='test_user',
                project_id='test_project',
                source='openstack',
                timestamp='2014-05-08 20:23:48.028195',
                resource_id=self.resource_id,
                resource_metadata={
                    'host': 'foo',
                    'image_ref': 'imageref!',
                    'instance_flavor_id': 1234,
                    'display_name': 'myinstance',
                },
            ),
        ]

        ks_client = mock.Mock(auth_token='fake_token')
        ks_client.projects.find.return_value = mock.Mock(
            name='gnocchi', id='a2d42c23-d518-46b6-96ab-3fba2e146859')
        self.useFixture(
            fixtures.MockPatch('ceilometer.keystone_client.get_client',
                               return_value=ks_client))
        self.useFixture(
            fixtures.MockPatch('gnocchiclient.v1.client.Client',
                               return_value=mock.Mock()))
        self.ks_client = ks_client
コード例 #33
0
ファイル: api.py プロジェクト: larsbutler/ceilometer
    def setUp(self):
        super(TestBase, self).setUp()
        service.prepare_service([])
        self.CONF.set_override("auth_version",
                               "v2.0",
                               group=acl.OPT_GROUP_NAME)
        self.CONF.set_override("policy_file",
                               self.path_get('tests/policy.json'))
        sources_file = self.path_get('tests/sources.json')
        self.app = v1_app.make_app(self.CONF,
                                   enable_acl=False,
                                   attach_storage=False,
                                   sources_file=sources_file)

        # this is needed to pass over unhandled exceptions
        self.app.debug = True

        self.app.register_blueprint(v1_blueprint.blueprint)
        self.test_app = self.app.test_client()

        @self.app.before_request
        def attach_storage_connection():
            flask.request.storage_conn = self.conn
コード例 #34
0
 def setUp(self):
     super(TestNovaClient, self).setUp()
     self.CONF = service.prepare_service([], [])
     self._flavors_count = 0
     self._images_count = 0
     self.nv = nova_client.Client(self.CONF)
     self.useFixture(
         fixtures.MockPatchObject(self.nv.nova_client.flavors,
                                  'get',
                                  side_effect=self.fake_flavors_get))
     self.useFixture(
         fixtures.MockPatchObject(self.nv.glance_client.images,
                                  'get',
                                  side_effect=self.fake_images_get))
コード例 #35
0
    def setUp(self):
        super(DispatcherWorkflowTest, self).setUp()
        self.conf = self.useFixture(config_fixture.Config())
        # Set this explicitly to avoid conflicts with any existing
        # configuration.
        self.conf.config(url='http://localhost:8041',
                         group='dispatcher_gnocchi')
        ks_client = mock.Mock(auth_token='fake_token')
        ks_client.tenants.find.return_value = mock.Mock(
            name='gnocchi', id='a2d42c23-d518-46b6-96ab-3fba2e146859')
        self.useFixture(mockpatch.Patch(
            'ceilometer.keystone_client.get_client',
            return_value=ks_client))
        self.ks_client = ks_client

        ceilometer_service.prepare_service(argv=[], config_files=[])
        self.conf.config(
            resources_definition_file=self.path_get(
                'etc/ceilometer/gnocchi_resources.yaml'),
            group="dispatcher_gnocchi"
        )

        self.sample['resource_id'] = str(uuid.uuid4()) + "/foobar"
コード例 #36
0
    def start_fixture(self):
        """Set up config."""

        global LOAD_APP_KWARGS

        self.conf = None

        # Determine the database connection.
        db_url = os.environ.get('PIFPAF_URL',
                                "sqlite://").replace("mysql://",
                                                     "mysql+pymysql://")
        if not db_url:
            raise case.SkipTest('No database connection configured')

        engine = urlparse.urlparse(db_url).scheme
        if engine not in ENGINES:
            raise case.SkipTest('Database engine not supported')

        conf = service.prepare_service([], [])
        conf = fixture_config.Config(conf).conf
        self.conf = conf

        content = ('{"default": ""}')
        if six.PY3:
            content = content.encode('utf-8')
        self.tempfile = fileutils.write_to_tempfile(content=content,
                                                    prefix='policy',
                                                    suffix='.json')

        conf.set_override("policy_file", self.tempfile, group='oslo_policy')
        conf.set_override(
            'api_paste_config',
            os.path.abspath(
                'ceilometer/tests/functional/gabbi/gabbi_paste.ini'))

        # A special pipeline is required to use the direct publisher.
        conf.set_override('pipeline_cfg_file',
                          'ceilometer/tests/functional/gabbi_pipeline.yaml')

        database_name = '%s-%s' % (db_url, str(uuid.uuid4()))
        conf.set_override('connection', database_name, group='database')
        conf.set_override('metering_connection', '', group='database')

        conf.set_override('gnocchi_is_enabled', False, group='api')
        conf.set_override('aodh_is_enabled', False, group='api')
        conf.set_override('panko_is_enabled', False, group='api')

        LOAD_APP_KWARGS = {
            'conf': conf,
        }
コード例 #37
0
    def start_fixture(self):
        """Set up config."""

        service.prepare_service([])
        conf = fixture_config.Config().conf
        self.conf = conf
        opts.set_defaults(self.conf)
        conf.import_opt('store_events',
                        'ceilometer.notification',
                        group='notification')
        conf.set_override('policy_file',
                          os.path.abspath('etc/ceilometer/policy.json'),
                          group='oslo_policy')

        # A special pipeline is required to use the direct publisher.
        conf.set_override('pipeline_cfg_file',
                          'etc/ceilometer/gabbi_pipeline.yaml')

        # Determine the database connection.
        db_url = None
        for engine in ENGINES:
            try:
                db_url = os.environ['CEILOMETER_TEST_%s_URL' % engine]
            except KeyError:
                pass
        if db_url is None:
            raise case.SkipTest('No database connection configured')

        database_name = '%s-%s' % (db_url, str(uuid.uuid4()))
        conf.set_override('connection', database_name, group='database')
        conf.set_override('metering_connection', '', group='database')
        conf.set_override('event_connection', '', group='database')
        conf.set_override('alarm_connection', '', group='database')

        conf.set_override('pecan_debug', True, group='api')

        conf.set_override('store_events', True, group='notification')
コード例 #38
0
ファイル: __init__.py プロジェクト: bopopescu/OpenStack-Ocata
    def setUp(self):
        super(FunctionalTest, self).setUp()
        conf = service.prepare_service([], [])
        self.CONF = self.useFixture(fixture_config.Config(conf)).conf
        self.setup_messaging(self.CONF)

        self.CONF.set_override("policy_file",
                               self.path_get('etc/ceilometer/policy.json'),
                               group='oslo_policy')

        self.CONF.set_override('gnocchi_is_enabled', False, group='api')
        self.CONF.set_override('aodh_is_enabled', False, group='api')
        self.CONF.set_override('panko_is_enabled', False, group='api')

        self.app = self._make_app()
コード例 #39
0
def upgrade():
    conf = cfg.ConfigOpts()
    conf.register_cli_opts([
        cfg.BoolOpt('skip-metering-database',
                    help='Skip metering database upgrade.',
                    default=False),
        cfg.BoolOpt('skip-gnocchi-resource-types',
                    help='Skip gnocchi resource-types upgrade.',
                    default=False),
    ])

    service.prepare_service(conf=conf)
    if conf.skip_metering_database:
        LOG.info("Skipping metering database upgrade")
    else:
        LOG.debug("Upgrading metering database")
        storage.get_connection_from_config(conf).upgrade()

    if conf.skip_gnocchi_resource_types:
        LOG.info("Skipping Gnocchi resource types upgrade")
    else:
        LOG.debug("Upgrading Gnocchi resource types")
        from ceilometer import gnocchi_client
        gnocchi_client.upgrade_resource_types(conf)
コード例 #40
0
ファイル: test_endpoint.py プロジェクト: hulaile/ceilometer
    def setUp(self):
        super(TestEventEndpoint, self).setUp()
        conf = service.prepare_service([], [])
        self.CONF = self.useFixture(fixture_config.Config(conf)).conf
        self.CONF.set_override("connection", "log://", group='database')
        self.setup_messaging(self.CONF)

        self.useFixture(
            mockpatch.PatchObject(publisher,
                                  'get_publisher',
                                  side_effect=self.get_publisher))
        self.fake_publisher = mock.Mock()
        self.useFixture(
            mockpatch.Patch('ceilometer.publisher.test.TestPublisher',
                            return_value=self.fake_publisher))
コード例 #41
0
 def setUp(self):
     super(TestDispatchManager, self).setUp()
     conf = service.prepare_service([], [])
     self.conf = self.useFixture(fixture.Config(conf))
     self.conf.config(meter_dispatchers=['database', 'gnocchi'],
                      event_dispatchers=['database'])
     self.CONF = self.conf.conf
     self.useFixture(
         fixtures.MockPatch(
             'ceilometer.dispatcher.gnocchi.GnocchiDispatcher',
             new=FakeMeterDispatcher))
     self.useFixture(
         fixtures.MockPatch(
             'ceilometer.dispatcher.database.MeterDatabaseDispatcher',
             new=FakeMeterDispatcher))
コード例 #42
0
    def setUp(self):
        super(TestLibvirtInspection, self).setUp()
        conf = service.prepare_service([], [])

        self.instance = VMInstance()
        libvirt_inspector.libvirt = mock.Mock()
        libvirt_inspector.libvirt.getVersion.return_value = 5001001
        libvirt_inspector.libvirt.VIR_DOMAIN_SHUTOFF = 5
        libvirt_inspector.libvirt.libvirtError = FakeLibvirtError
        utils.libvirt = libvirt_inspector.libvirt
        with mock.patch(
                'ceilometer.compute.virt.libvirt.utils.'
                'refresh_libvirt_connection',
                return_value=None):
            self.inspector = libvirt_inspector.LibvirtInspector(conf)
コード例 #43
0
    def __init__(self, conf):
        super(_BaseDiscovery, self).__init__(conf)

        # TODO: check if we can skip this loading of cfg
        from ceilometer import service
        from ceilometer.cmd.polling import CLI_OPTS
        conf = cfg.ConfigOpts()
        conf.register_cli_opts(CLI_OPTS)
        conf = service.prepare_service(conf=conf)

        creds = conf.service_credentials
        self.client = nova_client.Client(
            version='2',
            session=keystone_client.get_session(conf),
        )
コード例 #44
0
    def setUp(self):
        conf = service.prepare_service([], [])
        self.CONF = self.useFixture(fixture_config.Config(conf)).conf
        self.manager = manager.AgentManager(0, self.CONF)
        super(TestLocationMetadata, self).setUp()

        # Mimics an instance returned from nova api call
        self.INSTANCE_PROPERTIES = {
            'name': 'display name',
            'id': ('234cbe81-4e09-4f64-9b2a-'
                   '714f6b9046e3'),
            'OS-EXT-SRV-ATTR:instance_name': 'instance-000001',
            'OS-EXT-AZ:availability_zone': 'foo-zone',
            'reservation_id': 'reservation id',
            'architecture': 'x86_64',
            'kernel_id': 'kernel id',
            'os_type': 'linux',
            'ramdisk_id': 'ramdisk id',
            'status': 'active',
            'ephemeral_gb': 0,
            'root_gb': 20,
            'disk_gb': 20,
            'image': {
                'id': 1,
                'links': [{
                    "rel": "bookmark",
                    'href': 2
                }]
            },
            'hostId': '1234-5678',
            'OS-EXT-SRV-ATTR:host': 'host-test',
            'flavor': {
                'name': 'm1.tiny',
                'id': 1,
                'disk': 20,
                'ram': 512,
                'vcpus': 2,
                'ephemeral': 0
            },
            'metadata': {
                'metering.autoscale.group': 'X' * 512,
                'metering.ephemeral_gb': 42
            }
        }

        self.instance = FauxInstance(**self.INSTANCE_PROPERTIES)
コード例 #45
0
    def setUp(self):
        super(TestRealNotificationMultipleAgents, self).setUp()
        self.CONF = service.prepare_service([], [])
        self.setup_messaging(self.CONF, 'nova')

        pipeline_cfg_file = self.setup_pipeline(['instance', 'memory'])
        event_pipeline_cfg_file = self.setup_event_pipeline()
        self.CONF.set_override("pipeline_cfg_file", pipeline_cfg_file)
        self.CONF.set_override("event_pipeline_cfg_file",
                               event_pipeline_cfg_file)
        self.CONF.set_override("backend_url", "zake://", group="coordination")
        self.CONF.set_override('workload_partitioning', True,
                               group='notification')
        self.CONF.set_override('pipeline_processing_queues', 2,
                               group='notification')
        self.publisher = test_publisher.TestPublisher(self.CONF, "")
        self.publisher2 = test_publisher.TestPublisher(self.CONF, "")
コード例 #46
0
    def setUp(self):
        super(BaseRealNotification, self).setUp()
        self.CONF = service.prepare_service([], [])
        self.setup_messaging(self.CONF, 'nova')

        pipeline_cfg_file = self.setup_pipeline(['vcpus', 'memory'])
        self.CONF.set_override("pipeline_cfg_file", pipeline_cfg_file)

        self.expected_samples = 2

        ev_pipeline_cfg_file = self.setup_event_pipeline(
            ['compute.instance.*'])
        self.expected_events = 1

        self.CONF.set_override("event_pipeline_cfg_file", ev_pipeline_cfg_file)

        self.publisher = test_publisher.TestPublisher(self.CONF, "")
コード例 #47
0
ファイル: test_discovery.py プロジェクト: hulaile/ceilometer
    def setUp(self):
        super(TestDiscovery, self).setUp()

        self.instance = mock.MagicMock()
        self.instance.name = 'instance-00000001'
        setattr(self.instance, 'OS-EXT-SRV-ATTR:instance_name',
                self.instance.name)
        setattr(self.instance, 'OS-EXT-STS:vm_state', 'active')
        # FIXME(sileht): This is wrong, this should be a uuid
        # The internal id of nova can't be retrieved via API or notification
        self.instance.id = 1
        self.instance.flavor = {
            'name': 'm1.small',
            'id': 2,
            'vcpus': 1,
            'ram': 512,
            'disk': 20,
            'ephemeral': 0
        }
        self.instance.status = 'active'
        self.instance.metadata = {
            'fqdn': 'vm_fqdn',
            'metering.stack': '2cadc4b4-8789-123c-b4eg-edd2f0a9c128',
            'project_cos': 'dev'
        }

        # as we're having lazy hypervisor inspector singleton object in the
        # base compute pollster class, that leads to the fact that we
        # need to mock all this class property to avoid context sharing between
        # the tests
        self.client = mock.MagicMock()
        self.client.instance_get_all_by_host.return_value = [self.instance]
        patch_client = mockpatch.Patch('ceilometer.nova_client.Client',
                                       return_value=self.client)
        self.useFixture(patch_client)

        self.utc_now = mock.MagicMock(return_value=datetime.datetime(
            2016, 1, 1, tzinfo=iso8601.iso8601.UTC))
        patch_timeutils = mockpatch.Patch('oslo_utils.timeutils.utcnow',
                                          self.utc_now)
        self.useFixture(patch_timeutils)

        conf = service.prepare_service([], [])
        self.CONF = self.useFixture(fixture_config.Config(conf)).conf
        self.CONF.set_override('host', 'test')
コード例 #48
0
    def setUp(self):
        super(TestBase, self).setUp()
        db_url = os.environ.get('PIFPAF_URL',
                                "sqlite://").replace("mysql://",
                                                     "mysql+pymysql://")

        engine = urlparse.urlparse(db_url).scheme
        # in case some drivers have additional specification, for example:
        # PyMySQL will have scheme mysql+pymysql
        engine = engine.split('+')[0]

        # NOTE(Alexei_987) Shortcut to skip expensive db setUp
        test_method = self._get_test_method()
        if (hasattr(test_method, '_run_with')
                and engine not in test_method._run_with):
            raise testcase.TestSkipped('Test is not applicable for %s' %
                                       engine)

        conf = service.prepare_service([], [])
        self.CONF = self.useFixture(fixture_config.Config(conf)).conf

        manager = self.DRIVER_MANAGERS.get(engine)
        if not manager:
            self.skipTest("missing driver manager: %s" % engine)

        self.db_manager = manager(self.CONF, db_url)

        self.useFixture(self.db_manager)

        self.conn = self.db_manager.connection
        self.conn.upgrade()

        self.event_conn = self.db_manager.event_connection
        self.event_conn.upgrade()

        self.useFixture(
            mockpatch.Patch('ceilometer.storage.get_connection',
                            side_effect=self._get_connection))

        # Set a default location for the pipeline config file so the
        # tests work even if ceilometer is not installed globally on
        # the system.
        self.CONF.import_opt('pipeline_cfg_file', 'ceilometer.pipeline')
        self.CONF.set_override('pipeline_cfg_file',
                               self.path_get('etc/ceilometer/pipeline.yaml'))
コード例 #49
0
def main():
    args = get_parser().parse_known_args()[0]
    make_data_args = make_test_data.get_parser().parse_known_args()[0]
    conf = service.prepare_service(
        argv=['/', '--config-file', args.config_file])
    notifier = get_notifier(conf)
    send_batch = functools.partial(send_batch_notifier, notifier)
    result_dir = args.result_dir
    del args.config_file
    del args.result_dir

    resource_writes = generate_data(conf, send_batch, make_data_args,
                                    **args.__dict__)
    result_file = "%s/sample-by-resource-%s" % (result_dir,
                                                random.getrandbits(32))
    with open(result_file, 'w') as f:
        f.write(json.dumps(resource_writes))
    return result_file
コード例 #50
0
ファイル: test_gnocchi.py プロジェクト: viinay/ceilometer
    def setUp(self):
        super(DispatcherWorkflowTest, self).setUp()
        conf = ceilometer_service.prepare_service(argv=[], config_files=[])
        self.conf = self.useFixture(config_fixture.Config(conf))
        ks_client = mock.Mock()
        ks_client.projects.find.return_value = mock.Mock(
            name='gnocchi', id='a2d42c23-d518-46b6-96ab-3fba2e146859')
        self.useFixture(
            fixtures.MockPatch('ceilometer.keystone_client.get_client',
                               return_value=ks_client))
        self.ks_client = ks_client

        self.conf.config(resources_definition_file=self.path_get(
            'etc/ceilometer/gnocchi_resources.yaml'),
                         group="dispatcher_gnocchi")

        self.sample['resource_id'] = str(uuid.uuid4()) + "_foobar"
        self.sample['message_signature'] = utils.compute_signature(
            self.sample, self.conf.conf.publisher.telemetry_secret)
コード例 #51
0
ファイル: base.py プロジェクト: hulaile/ceilometer
    def setUp(self):
        super(TestPollsterBase, self).setUp()
        conf = service.prepare_service([], [])
        self.CONF = self.useFixture(fixture_config.Config(conf)).conf

        self.inspector = mock.Mock()
        self.instance = mock.MagicMock()
        self.instance.name = 'instance-00000001'
        setattr(self.instance, 'OS-EXT-SRV-ATTR:instance_name',
                self.instance.name)
        setattr(self.instance, 'OS-EXT-STS:vm_state', 'active')
        setattr(self.instance, 'OS-EXT-STS:task_state', None)
        self.instance.id = 1
        self.instance.flavor = {
            'name': 'm1.small',
            'id': 2,
            'vcpus': 1,
            'ram': 512,
            'disk': 20,
            'ephemeral': 0
        }
        self.instance.status = 'active'
        self.instance.metadata = {
            'fqdn': 'vm_fqdn',
            'metering.stack': '2cadc4b4-8789-123c-b4eg-edd2f0a9c128',
            'project_cos': 'dev'
        }

        self.useFixture(
            mockpatch.Patch(
                'ceilometer.compute.virt.inspector.get_hypervisor_inspector',
                new=mock.Mock(return_value=self.inspector)))

        # as we're having lazy hypervisor inspector singleton object in the
        # base compute pollster class, that leads to the fact that we
        # need to mock all this class property to avoid context sharing between
        # the tests
        self.useFixture(
            mockpatch.Patch(
                'ceilometer.compute.pollsters.'
                'GenericComputePollster._get_inspector',
                return_value=self.inspector))
コード例 #52
0
    def setUp(self):
        super(EventPipelineTestCase, self).setUp()
        self.CONF = service.prepare_service([], [])

        self.p_type = pipeline.EVENT_TYPE
        self.transformer_manager = None

        self.test_event = models.Event(
            message_id=uuid.uuid4(),
            event_type='a',
            generated=datetime.datetime.utcnow(),
            traits=[
                models.Trait('t_text', 1, 'text_trait'),
                models.Trait('t_int', 2, 'int_trait'),
                models.Trait('t_float', 3, 'float_trait'),
                models.Trait('t_datetime', 4, 'datetime_trait')
            ],
            raw={'status': 'started'})

        self.test_event2 = models.Event(
            message_id=uuid.uuid4(),
            event_type='b',
            generated=datetime.datetime.utcnow(),
            traits=[
                models.Trait('t_text', 1, 'text_trait'),
                models.Trait('t_int', 2, 'int_trait'),
                models.Trait('t_float', 3, 'float_trait'),
                models.Trait('t_datetime', 4, 'datetime_trait')
            ],
            raw={'status': 'stopped'})

        self.useFixture(
            mockpatch.PatchObject(publisher,
                                  'get_publisher',
                                  side_effect=self.get_publisher))

        self._setup_pipeline_cfg()

        self._reraise_exception = True
        self.useFixture(
            mockpatch.Patch('ceilometer.pipeline.LOG.exception',
                            side_effect=self._handle_reraise_exception))
コード例 #53
0
    def setUp(self):
        super(BaseRealNotification, self).setUp()
        conf = service.prepare_service([], [])
        self.CONF = self.useFixture(fixture_config.Config(conf)).conf
        self.setup_messaging(self.CONF, 'nova')

        pipeline_cfg_file = self.setup_pipeline(['vcpus', 'memory'])
        self.CONF.set_override("pipeline_cfg_file", pipeline_cfg_file)

        self.expected_samples = 2

        self.CONF.set_override("backend_url", None, group="coordination")

        ev_pipeline_cfg_file = self.setup_event_pipeline(
            ['compute.instance.*'])
        self.expected_events = 1

        self.CONF.set_override("event_pipeline_cfg_file", ev_pipeline_cfg_file)

        self.publisher = test_publisher.TestPublisher(self.CONF, "")
コード例 #54
0
ファイル: test_driver.py プロジェクト: yungjinzhou/ceilometer
    def setUp(self):
        super(TestOpencontrailDriver, self).setUp()

        self.nc_ports = mock.patch(
            'ceilometer.neutron_client'
            '.Client.port_get_all',
            return_value=self.fake_ports())
        self.nc_ports.start()

        self.CONF = service.prepare_service([], [])
        self.driver = driver.OpencontrailDriver(self.CONF)
        self.parse_url = urlparse.ParseResult('opencontrail', '127.0.0.1:8143',
                                              '/', None, None, None)
        self.params = {
            'password': ['admin'],
            'scheme': ['http'],
            'username': ['admin'],
            'verify_ssl': ['false'],
            'resource': ['if_stats_list']
        }
コード例 #55
0
def main():

    args = get_parser().parse_args()
    conf = service.prepare_service([])

    # Connect to the metering database
    conn = storage.get_connection_from_config(conf)

    # Find the user and/or project for a real resource
    if not (args.user_id or args.project_id):
        for r in conn.get_resources():
            if r.resource_id == args.resource_id:
                args.user_id = r.user_id
                args.project_id = r.project_id
                break

    # Compute the correct time span
    format = '%Y-%m-%dT%H:%M:%S'

    try:
        start = datetime.datetime.utcnow() - datetime.timedelta(
            days=int(args.start))
    except ValueError:
        try:
            start = datetime.datetime.strptime(args.start, format)
        except ValueError:
            raise

    try:
        end = datetime.datetime.utcnow() + datetime.timedelta(
            days=int(args.end))
    except ValueError:
        try:
            end = datetime.datetime.strptime(args.end, format)
        except ValueError:
            raise
    args.start = start
    args.end = end
    record_test_data(conf, conn=conn, **args.__dict__)

    return 0
コード例 #56
0
ファイル: storage.py プロジェクト: zhangyang9/ceilometer
def expirer():
    conf = service.prepare_service()

    if conf.database.metering_time_to_live > 0:
        LOG.debug("Clearing expired metering data")
        storage_conn = storage.get_connection_from_config(conf, 'metering')
        storage_conn.clear_expired_metering_data(
            conf.database.metering_time_to_live)
    else:
        LOG.info(
            _LI("Nothing to clean, database metering time to live "
                "is disabled"))

    if conf.database.event_time_to_live > 0:
        LOG.debug("Clearing expired event data")
        event_conn = storage.get_connection_from_config(conf, 'event')
        event_conn.clear_expired_event_data(conf.database.event_time_to_live)
    else:
        LOG.info(
            _LI("Nothing to clean, database event time to live "
                "is disabled"))
コード例 #57
0
 def setUp(self):
     super(BaseAgent, self).setUp()
     self.notified_samples = []
     self.notifier = mock.Mock()
     self.notifier.sample.side_effect = self.fake_notifier_sample
     self.useFixture(fixtures.MockPatch('oslo_messaging.Notifier',
                                        return_value=self.notifier))
     self.useFixture(fixtures.MockPatch('keystoneclient.v2_0.client.Client',
                                        return_value=mock.Mock()))
     self.CONF = service.prepare_service([], [])
     self.CONF.set_override(
         'cfg_file',
         self.path_get('etc/ceilometer/polling_all.yaml'), group='polling'
     )
     self.polling_cfg = {
         'sources': [{
             'name': 'test_polling',
             'interval': 60,
             'meters': ['test'],
             'resources': ['test://']}]
     }
コード例 #58
0
    def setUp(self):
        super(TestCollector, self).setUp()
        conf = service.prepare_service([], [])
        self.CONF = self.useFixture(fixture_config.Config(conf)).conf
        self.CONF.import_opt("connection", "oslo_db.options", group="database")
        self.CONF.set_override("connection", "log://", group='database')
        self.CONF.set_override('telemetry_secret',
                               'not-so-secret',
                               group='publisher')
        self._setup_messaging()

        self.sample = utils.meter_message_from_counter(
            sample.Sample(
                name='foobar',
                type='bad',
                unit='F',
                volume=1,
                user_id='jd',
                project_id='ceilometer',
                resource_id='cat',
                timestamp=timeutils.utcnow().isoformat(),
                resource_metadata={},
            ), self.CONF.publisher.telemetry_secret)

        self.utf8_msg = utils.meter_message_from_counter(
            sample.Sample(
                name=u'test',
                type=sample.TYPE_CUMULATIVE,
                unit=u'',
                volume=1,
                user_id=u'test',
                project_id=u'test',
                resource_id=u'test_run_tasks',
                timestamp=timeutils.utcnow().isoformat(),
                resource_metadata={u'name': [([u'TestPublish'])]},
                source=u'testsource',
            ), 'not-so-secret')

        self.mock_dispatcher = self._setup_fake_dispatcher()
        self.srv = collector.CollectorService(0, self.CONF)
コード例 #59
0
ファイル: agentbase.py プロジェクト: yaochi/ceilometer
 def setUp(self):
     super(BaseAgentManagerTestCase, self).setUp()
     self.CONF = service.prepare_service([], [])
     self.CONF.set_override('cfg_file',
                            self.path_get('etc/ceilometer/polling.yaml'),
                            group='polling')
     self.mgr = self.create_manager()
     self.mgr.extensions = self.create_extension_list()
     self.mgr.partition_coordinator = mock.MagicMock()
     fake_subset = lambda _, x: x
     p_coord = self.mgr.partition_coordinator
     p_coord.extract_my_subset.side_effect = fake_subset
     self.mgr.tg = mock.MagicMock()
     self.polling_cfg = {
         'sources': [{
             'name': 'test_polling',
             'interval': 60,
             'meters': ['test'],
             'resources': ['test://']
         }]
     }
     self.setup_polling()
コード例 #60
0
    def setUp(self):
        super(TestRealNotificationMultipleAgents, self).setUp()
        conf = service.prepare_service([], [])
        self.CONF = self.useFixture(fixture_config.Config(conf)).conf
        self.setup_messaging(self.CONF, 'nova')

        pipeline_cfg_file = self.setup_pipeline(['instance', 'memory'])
        event_pipeline_cfg_file = self.setup_event_pipeline()
        self.CONF.set_override("pipeline_cfg_file", pipeline_cfg_file)
        self.CONF.set_override("event_pipeline_cfg_file",
                               event_pipeline_cfg_file)
        self.CONF.set_override("backend_url", None, group="coordination")
        self.CONF.set_override("disable_non_metric_meters",
                               False,
                               group="notification")
        self.CONF.set_override('workload_partitioning',
                               True,
                               group='notification')
        self.CONF.set_override('pipeline_processing_queues',
                               2,
                               group='notification')
        self.publisher = test_publisher.TestPublisher(self.CONF, "")
        self.publisher2 = test_publisher.TestPublisher(self.CONF, "")