diff --git a/ceilometer/collector/service.py b/ceilometer/collector/service.py index 2a57af9b4..e79df52d9 100644 --- a/ceilometer/collector/service.py +++ b/ceilometer/collector/service.py @@ -21,7 +21,7 @@ import msgpack import socket from stevedore import extension -from ceilometer.publisher import meter as publisher_meter +from ceilometer.publisher import rpc as publisher_rpc from ceilometer.service import prepare_service from ceilometer.openstack.common import context from ceilometer.openstack.common import log @@ -134,9 +134,9 @@ class CollectorService(rpc_service.Service): # Set ourselves up as a separate worker for the metering data, # since the default for service is to use create_consumer(). self.conn.create_worker( - cfg.CONF.publisher_meter.metering_topic, + cfg.CONF.publisher_rpc.metering_topic, rpc_dispatcher.RpcDispatcher([self]), - 'ceilometer.collector.' + cfg.CONF.publisher_meter.metering_topic, + 'ceilometer.collector.' + cfg.CONF.publisher_rpc.metering_topic, ) def _setup_subscription(self, ext, *args, **kwds): @@ -186,9 +186,9 @@ class CollectorService(rpc_service.Service): meter['resource_id'], meter.get('timestamp', 'NO TIMESTAMP'), meter['counter_volume']) - if publisher_meter.verify_signature( + if publisher_rpc.verify_signature( meter, - cfg.CONF.publisher_meter.metering_secret): + cfg.CONF.publisher_rpc.metering_secret): try: # Convert the timestamp to a datetime instance. # Storage engines are responsible for converting diff --git a/ceilometer/publisher/meter.py b/ceilometer/publisher/rpc.py similarity index 94% rename from ceilometer/publisher/meter.py rename to ceilometer/publisher/rpc.py index 19f14ea69..8ec8e3cb1 100644 --- a/ceilometer/publisher/meter.py +++ b/ceilometer/publisher/rpc.py @@ -51,7 +51,7 @@ METER_PUBLISH_OPTS = [ def register_opts(config): """Register the options for publishing metering messages. """ - config.register_opts(METER_PUBLISH_OPTS, group="publisher_meter") + config.register_opts(METER_PUBLISH_OPTS, group="publisher_rpc") register_opts(cfg.CONF) @@ -102,7 +102,7 @@ def meter_message_from_counter(counter, secret, source): return msg -class MeterPublisher(publisher.PublisherBase): +class RPCPublisher(publisher.PublisherBase): def publish_counters(self, context, counters, source): """Send a metering message for publishing @@ -114,12 +114,12 @@ class MeterPublisher(publisher.PublisherBase): meters = [ meter_message_from_counter( counter, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, source) for counter in counters ] - topic = cfg.CONF.publisher_meter.metering_topic + topic = cfg.CONF.publisher_rpc.metering_topic msg = { 'method': 'record_metering_data', 'version': '1.0', diff --git a/etc/ceilometer/ceilometer.conf.sample b/etc/ceilometer/ceilometer.conf.sample index b402c93d7..1d7313b77 100644 --- a/etc/ceilometer/ceilometer.conf.sample +++ b/etc/ceilometer/ceilometer.conf.sample @@ -437,6 +437,20 @@ #cinder_control_exchange=cinder +[publisher_rpc] + +# +# Options defined in ceilometer.publisher.rpc +# + +# the topic ceilometer uses for metering messages (string +# value) +#metering_topic=metering + +# Secret value for signing metering messages (string value) +#metering_secret=change this or be hacked + + [database] # @@ -500,20 +514,6 @@ #pool_timeout= -[publisher_meter] - -# -# Options defined in ceilometer.publisher.meter -# - -# the topic ceilometer uses for metering messages (string -# value) -#metering_topic=metering - -# Secret value for signing metering messages (string value) -#metering_secret=change this or be hacked - - [rpc_notifier2] # diff --git a/etc/ceilometer/pipeline.yaml b/etc/ceilometer/pipeline.yaml index cad1160ab..8aa4d2bd8 100644 --- a/etc/ceilometer/pipeline.yaml +++ b/etc/ceilometer/pipeline.yaml @@ -6,4 +6,4 @@ - "*" transformers: publishers: - - meter:// + - rpc:// diff --git a/setup.cfg b/setup.cfg index 28fe54741..dbfe2731e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -78,8 +78,9 @@ ceilometer.transformer = ceilometer.publisher = test = ceilometer.publisher.test:TestPublisher - meter_publisher = ceilometer.publisher.meter:MeterPublisher - meter = ceilometer.publisher.meter:MeterPublisher + meter_publisher = ceilometer.publisher.rpc:RPCPublisher + meter = ceilometer.publisher.rpc:RPCPublisher + rpc = ceilometer.publisher.rpc:RPCPublisher udp = ceilometer.publisher.udp:UDPPublisher paste.filter_factory = diff --git a/tests/api/v1/list_events.py b/tests/api/v1/list_events.py index 80967067e..8830ec86c 100644 --- a/tests/api/v1/list_events.py +++ b/tests/api/v1/list_events.py @@ -23,7 +23,7 @@ import datetime from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer.tests import api as tests_api @@ -71,9 +71,9 @@ class TestListEvents(tests_api.TestBase): 'tag': 'self.counter2'} ), ]: - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( cnt, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'source1') self.conn.record_metering_data(msg) diff --git a/tests/api/v1/list_meters.py b/tests/api/v1/list_meters.py index 8aa247aad..bbc0c3b28 100644 --- a/tests/api/v1/list_meters.py +++ b/tests/api/v1/list_meters.py @@ -24,7 +24,7 @@ import logging from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer.tests import api as tests_api @@ -100,9 +100,9 @@ class TestListMeters(tests_api.TestBase): timestamp=datetime.datetime(2012, 7, 2, 10, 43), resource_metadata={'display_name': 'test-server', 'tag': 'four.counter'})]: - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( cnt, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test_list_resources') self.conn.record_metering_data(msg) diff --git a/tests/api/v1/list_projects.py b/tests/api/v1/list_projects.py index b6cc026f4..8c391b52b 100644 --- a/tests/api/v1/list_projects.py +++ b/tests/api/v1/list_projects.py @@ -24,7 +24,7 @@ import logging from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer.tests import api as tests_api @@ -55,9 +55,9 @@ class TestListProjects(tests_api.TestBase): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter'} ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test_list_projects', ) self.conn.record_metering_data(msg) @@ -74,9 +74,9 @@ class TestListProjects(tests_api.TestBase): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2'} ) - msg2 = meter.meter_message_from_counter( + msg2 = rpc.meter_message_from_counter( counter2, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test_list_users', ) self.conn.record_metering_data(msg2) diff --git a/tests/api/v1/list_resources.py b/tests/api/v1/list_resources.py index 57a3fbebc..a6722cc88 100644 --- a/tests/api/v1/list_resources.py +++ b/tests/api/v1/list_resources.py @@ -24,7 +24,7 @@ import logging from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer.tests import api as tests_api @@ -93,9 +93,9 @@ class TestListResourcesBase(tests_api.TestBase): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter4'} )]: - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( cnt, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test_list_resources') self.conn.record_metering_data(msg) diff --git a/tests/api/v1/list_users.py b/tests/api/v1/list_users.py index 303d00622..f15b5369e 100644 --- a/tests/api/v1/list_users.py +++ b/tests/api/v1/list_users.py @@ -24,7 +24,7 @@ import logging from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer.tests import api as tests_api @@ -57,9 +57,9 @@ class TestListUsers(tests_api.TestBase): 'tag': 'self.counter', } ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test_list_users', ) self.conn.record_metering_data(msg) @@ -77,9 +77,9 @@ class TestListUsers(tests_api.TestBase): 'tag': 'self.counter2', } ) - msg2 = meter.meter_message_from_counter( + msg2 = rpc.meter_message_from_counter( counter2, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'not-test', ) self.conn.record_metering_data(msg2) diff --git a/tests/api/v1/max_project_volume.py b/tests/api/v1/max_project_volume.py index 27709b296..d576f7359 100644 --- a/tests/api/v1/max_project_volume.py +++ b/tests/api/v1/max_project_volume.py @@ -23,7 +23,7 @@ import datetime from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer.tests import api as tests_api @@ -52,9 +52,9 @@ class TestMaxProjectVolume(tests_api.TestBase): } ) self.counters.append(c) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'source1', ) self.conn.record_metering_data(msg) diff --git a/tests/api/v1/max_resource_volume.py b/tests/api/v1/max_resource_volume.py index 73b03e2a0..d134bc4a5 100644 --- a/tests/api/v1/max_resource_volume.py +++ b/tests/api/v1/max_resource_volume.py @@ -22,7 +22,7 @@ import datetime from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer.tests import api as tests_api @@ -51,9 +51,9 @@ class TestMaxResourceVolume(tests_api.TestBase): } ) self.counters.append(c) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'source1', ) self.conn.record_metering_data(msg) diff --git a/tests/api/v1/sum_project_volume.py b/tests/api/v1/sum_project_volume.py index 3d22cf950..60b9f849e 100644 --- a/tests/api/v1/sum_project_volume.py +++ b/tests/api/v1/sum_project_volume.py @@ -23,7 +23,7 @@ import datetime from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer.tests import api as tests_api @@ -52,9 +52,9 @@ class TestSumProjectVolume(tests_api.TestBase): } ) self.counters.append(c) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'source1', ) self.conn.record_metering_data(msg) diff --git a/tests/api/v1/sum_resource_volume.py b/tests/api/v1/sum_resource_volume.py index 99a159a30..3e160fc02 100644 --- a/tests/api/v1/sum_resource_volume.py +++ b/tests/api/v1/sum_resource_volume.py @@ -23,7 +23,7 @@ import datetime from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer.tests import api as tests_api @@ -52,9 +52,9 @@ class TestSumResourceVolume(tests_api.TestBase): } ) self.counters.append(c) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'source1', ) self.conn.record_metering_data(msg) diff --git a/tests/api/v2/test_acl.py b/tests/api/v2/test_acl.py index 94ca7c31d..2c7f79ffc 100644 --- a/tests/api/v2/test_acl.py +++ b/tests/api/v2/test_acl.py @@ -22,7 +22,7 @@ from oslo.config import cfg from ceilometer import counter from ceilometer.api import acl -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from .base import FunctionalTest @@ -98,9 +98,9 @@ class TestAPIACL(FunctionalTest): timestamp=datetime.datetime(2012, 7, 2, 10, 43), resource_metadata={'display_name': 'test-server', 'tag': 'self.counter4'})]: - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( cnt, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test_source') self.conn.record_metering_data(msg) diff --git a/tests/api/v2/test_list_events.py b/tests/api/v2/test_list_events.py index 4c9743471..e8cedddcf 100644 --- a/tests/api/v2/test_list_events.py +++ b/tests/api/v2/test_list_events.py @@ -24,7 +24,7 @@ import webtest.app from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from .base import FunctionalTest @@ -51,9 +51,9 @@ class TestListEvents(FunctionalTest): 'ignored_list': ['not-returned'], } ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( self.counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test_source', ) self.conn.record_metering_data(msg) @@ -71,9 +71,9 @@ class TestListEvents(FunctionalTest): 'tag': 'self.counter2', } ) - msg2 = meter.meter_message_from_counter( + msg2 = rpc.meter_message_from_counter( self.counter2, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'source2', ) self.conn.record_metering_data(msg2) diff --git a/tests/api/v2/test_list_meters.py b/tests/api/v2/test_list_meters.py index d88369aad..f6b10c05e 100644 --- a/tests/api/v2/test_list_meters.py +++ b/tests/api/v2/test_list_meters.py @@ -23,7 +23,7 @@ import logging from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from .base import FunctionalTest @@ -99,9 +99,9 @@ class TestListMeters(FunctionalTest): timestamp=datetime.datetime(2012, 7, 2, 10, 43), resource_metadata={'display_name': 'test-server', 'tag': 'self.counter4'})]: - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( cnt, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test_source') self.conn.record_metering_data(msg) diff --git a/tests/api/v2/test_list_resources.py b/tests/api/v2/test_list_resources.py index ff45121db..a2112b953 100644 --- a/tests/api/v2/test_list_resources.py +++ b/tests/api/v2/test_list_resources.py @@ -23,7 +23,7 @@ import logging from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from .base import FunctionalTest @@ -51,9 +51,9 @@ class TestListResources(FunctionalTest): timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata=None ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test', ) self.conn.record_metering_data(msg) @@ -75,9 +75,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter', } ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test', ) self.conn.record_metering_data(msg) @@ -95,9 +95,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter2', } ) - msg2 = meter.meter_message_from_counter( + msg2 = rpc.meter_message_from_counter( counter2, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test', ) self.conn.record_metering_data(msg2) @@ -119,9 +119,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter', } ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test', ) self.conn.record_metering_data(msg) @@ -139,9 +139,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter2', } ) - msg2 = meter.meter_message_from_counter( + msg2 = rpc.meter_message_from_counter( counter2, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test', ) self.conn.record_metering_data(msg2) @@ -163,9 +163,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter', } ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test_list_resources', ) self.conn.record_metering_data(msg) @@ -183,9 +183,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter2', } ) - msg2 = meter.meter_message_from_counter( + msg2 = rpc.meter_message_from_counter( counter2, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'not-test', ) self.conn.record_metering_data(msg2) @@ -210,9 +210,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter', } ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test_list_resources', ) self.conn.record_metering_data(msg) @@ -230,9 +230,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter2', } ) - msg2 = meter.meter_message_from_counter( + msg2 = rpc.meter_message_from_counter( counter2, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'not-test', ) self.conn.record_metering_data(msg2) @@ -257,9 +257,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter', } ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test_list_resources', ) self.conn.record_metering_data(msg) @@ -277,9 +277,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter2', } ) - msg2 = meter.meter_message_from_counter( + msg2 = rpc.meter_message_from_counter( counter2, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'not-test', ) self.conn.record_metering_data(msg2) @@ -304,9 +304,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter1', } ) - msg2 = meter.meter_message_from_counter( + msg2 = rpc.meter_message_from_counter( counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'not-test', ) self.conn.record_metering_data(msg2) @@ -331,9 +331,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter1', } ) - msg2 = meter.meter_message_from_counter( + msg2 = rpc.meter_message_from_counter( counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'not-test', ) self.conn.record_metering_data(msg2) @@ -360,9 +360,9 @@ class TestListResources(FunctionalTest): 'ignored_list': ['not-returned'], } ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test', ) self.conn.record_metering_data(msg) @@ -389,9 +389,9 @@ class TestListResources(FunctionalTest): 'tag': 'self.counter', } ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( counter1, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test_list_resources', ) self.conn.record_metering_data(msg) diff --git a/tests/api/v2/test_max_project_volume.py b/tests/api/v2/test_max_project_volume.py index ed1f7694f..87942bea4 100644 --- a/tests/api/v2/test_max_project_volume.py +++ b/tests/api/v2/test_max_project_volume.py @@ -22,7 +22,7 @@ import datetime from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer.storage.impl_mongodb import require_map_reduce @@ -54,9 +54,9 @@ class TestMaxProjectVolume(FunctionalTest): } ) self.counters.append(c) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'source1', ) self.conn.record_metering_data(msg) diff --git a/tests/api/v2/test_max_resource_volume.py b/tests/api/v2/test_max_resource_volume.py index bd15a7c66..51bb9bdcb 100644 --- a/tests/api/v2/test_max_resource_volume.py +++ b/tests/api/v2/test_max_resource_volume.py @@ -22,7 +22,7 @@ import datetime from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from .base import FunctionalTest @@ -53,9 +53,9 @@ class TestMaxResourceVolume(FunctionalTest): } ) self.counters.append(c) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'source1', ) self.conn.record_metering_data(msg) diff --git a/tests/api/v2/test_sum_project_volume.py b/tests/api/v2/test_sum_project_volume.py index 9d86d9cb7..9f059e4f5 100644 --- a/tests/api/v2/test_sum_project_volume.py +++ b/tests/api/v2/test_sum_project_volume.py @@ -22,7 +22,7 @@ import datetime from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from .base import FunctionalTest @@ -53,9 +53,9 @@ class TestSumProjectVolume(FunctionalTest): } ) self.counters.append(c) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'source1', ) self.conn.record_metering_data(msg) diff --git a/tests/api/v2/test_sum_resource_volume.py b/tests/api/v2/test_sum_resource_volume.py index b4737dd5e..8a9f519f8 100644 --- a/tests/api/v2/test_sum_resource_volume.py +++ b/tests/api/v2/test_sum_resource_volume.py @@ -22,7 +22,7 @@ import datetime from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from .base import FunctionalTest @@ -53,9 +53,9 @@ class TestSumResourceVolume(FunctionalTest): } ) self.counters.append(c) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'source1', ) self.conn.record_metering_data(msg) diff --git a/tests/collector/test_manager.py b/tests/collector/test_manager.py index 11b308432..1a59c7002 100644 --- a/tests/collector/test_manager.py +++ b/tests/collector/test_manager.py @@ -29,7 +29,7 @@ from stevedore import extension from stevedore.tests import manager as test_manager from ceilometer import counter -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer.collector import service from ceilometer.storage import base from ceilometer.tests import base as tests_base @@ -184,9 +184,9 @@ class TestCollectorService(TestCollector): 'resource_id': self.id(), 'counter_volume': 1, } - msg['message_signature'] = meter.compute_signature( + msg['message_signature'] = rpc.compute_signature( msg, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, ) self.srv.storage_conn = self.mox.CreateMock(base.Connection) @@ -223,9 +223,9 @@ class TestCollectorService(TestCollector): 'counter_volume': 1, 'timestamp': '2012-07-02T13:53:40Z', } - msg['message_signature'] = meter.compute_signature( + msg['message_signature'] = rpc.compute_signature( msg, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, ) expected = {} @@ -244,9 +244,9 @@ class TestCollectorService(TestCollector): 'counter_volume': 1, 'timestamp': '2012-09-30T15:31:50.262-08:00', } - msg['message_signature'] = meter.compute_signature( + msg['message_signature'] = rpc.compute_signature( msg, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, ) expected = {} diff --git a/tests/publisher/test_meter_publisher.py b/tests/publisher/test_rpc_publisher.py similarity index 79% rename from tests/publisher/test_meter_publisher.py rename to tests/publisher/test_rpc_publisher.py index e60a866da..7ddd32067 100644 --- a/tests/publisher/test_meter_publisher.py +++ b/tests/publisher/test_rpc_publisher.py @@ -24,66 +24,66 @@ from oslo.config import cfg from ceilometer import counter from ceilometer.openstack.common import jsonutils -from ceilometer.openstack.common import rpc -from ceilometer.publisher import meter +from ceilometer.openstack.common import rpc as oslo_rpc +from ceilometer.publisher import rpc from ceilometer.tests import base def test_compute_signature_change_key(): - sig1 = meter.compute_signature({'a': 'A', 'b': 'B'}, - 'not-so-secret') - sig2 = meter.compute_signature({'A': 'A', 'b': 'B'}, - 'not-so-secret') + sig1 = rpc.compute_signature({'a': 'A', 'b': 'B'}, + 'not-so-secret') + sig2 = rpc.compute_signature({'A': 'A', 'b': 'B'}, + 'not-so-secret') assert sig1 != sig2 def test_compute_signature_change_value(): - sig1 = meter.compute_signature({'a': 'A', 'b': 'B'}, - 'not-so-secret') - sig2 = meter.compute_signature({'a': 'a', 'b': 'B'}, - 'not-so-secret') + sig1 = rpc.compute_signature({'a': 'A', 'b': 'B'}, + 'not-so-secret') + sig2 = rpc.compute_signature({'a': 'a', 'b': 'B'}, + 'not-so-secret') assert sig1 != sig2 def test_compute_signature_same(): - sig1 = meter.compute_signature({'a': 'A', 'b': 'B'}, - 'not-so-secret') - sig2 = meter.compute_signature({'a': 'A', 'b': 'B'}, - 'not-so-secret') + sig1 = rpc.compute_signature({'a': 'A', 'b': 'B'}, + 'not-so-secret') + sig2 = rpc.compute_signature({'a': 'A', 'b': 'B'}, + 'not-so-secret') assert sig1 == sig2 def test_compute_signature_signed(): data = {'a': 'A', 'b': 'B'} - sig1 = meter.compute_signature(data, 'not-so-secret') + sig1 = rpc.compute_signature(data, 'not-so-secret') data['message_signature'] = sig1 - sig2 = meter.compute_signature(data, 'not-so-secret') + sig2 = rpc.compute_signature(data, 'not-so-secret') assert sig1 == sig2 def test_compute_signature_use_configured_secret(): data = {'a': 'A', 'b': 'B'} - sig1 = meter.compute_signature(data, 'not-so-secret') - sig2 = meter.compute_signature(data, 'different-value') + sig1 = rpc.compute_signature(data, 'not-so-secret') + sig2 = rpc.compute_signature(data, 'different-value') assert sig1 != sig2 def test_verify_signature_signed(): data = {'a': 'A', 'b': 'B'} - sig1 = meter.compute_signature(data, 'not-so-secret') + sig1 = rpc.compute_signature(data, 'not-so-secret') data['message_signature'] = sig1 - assert meter.verify_signature(data, 'not-so-secret') + assert rpc.verify_signature(data, 'not-so-secret') def test_verify_signature_unsigned(): data = {'a': 'A', 'b': 'B'} - assert not meter.verify_signature(data, 'not-so-secret') + assert not rpc.verify_signature(data, 'not-so-secret') def test_verify_signature_incorrect(): data = {'a': 'A', 'b': 'B', 'message_signature': 'Not the same'} - assert not meter.verify_signature(data, 'not-so-secret') + assert not rpc.verify_signature(data, 'not-so-secret') def test_verify_signature_nested(): @@ -93,10 +93,10 @@ def test_verify_signature_nested(): 'b': 'B', }, } - data['message_signature'] = meter.compute_signature( + data['message_signature'] = rpc.compute_signature( data, 'not-so-secret') - assert meter.verify_signature(data, 'not-so-secret') + assert rpc.verify_signature(data, 'not-so-secret') def test_verify_signature_nested_json(): @@ -108,11 +108,11 @@ def test_verify_signature_nested_json(): 'd': ['d'] }, } - data['message_signature'] = meter.compute_signature( + data['message_signature'] = rpc.compute_signature( data, 'not-so-secret') jsondata = jsonutils.loads(jsonutils.dumps(data)) - assert meter.verify_signature(jsondata, 'not-so-secret') + assert rpc.verify_signature(jsondata, 'not-so-secret') TEST_COUNTER = counter.Counter(name='name', @@ -165,7 +165,7 @@ TEST_NOTICE = { def test_meter_message_from_counter_signed(): - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( TEST_COUNTER, 'not-so-secret', 'src') @@ -175,7 +175,7 @@ def test_meter_message_from_counter_signed(): def test_meter_message_from_counter_field(): def compare(f, c, msg_f, msg): assert msg == c - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( TEST_COUNTER, 'not-so-secret', 'src') name_map = {'name': 'counter_name', @@ -254,8 +254,8 @@ class TestPublish(base.TestCase): def setUp(self): super(TestPublish, self).setUp() self.published = [] - self.stubs.Set(rpc, 'cast', self.faux_cast) - publisher = meter.MeterPublisher(None) + self.stubs.Set(oslo_rpc, 'cast', self.faux_cast) + publisher = rpc.RPCPublisher(None) publisher.publish_counters(None, self.test_data, 'test') @@ -265,7 +265,7 @@ class TestPublish(base.TestCase): for topic, rpc_call in self.published: meters = rpc_call['args']['data'] self.assertIsInstance(meters, list) - if topic != cfg.CONF.publisher_meter.metering_topic: + if topic != cfg.CONF.publisher_rpc.metering_topic: self.assertEqual(len(set(meter['counter_name'] for meter in meters)), 1, @@ -273,10 +273,10 @@ class TestPublish(base.TestCase): def test_published_topics(self): topics = [topic for topic, meter in self.published] - self.assertIn(cfg.CONF.publisher_meter.metering_topic, topics) + self.assertIn(cfg.CONF.publisher_rpc.metering_topic, topics) self.assertIn( - cfg.CONF.publisher_meter.metering_topic + '.' + 'test', topics) + cfg.CONF.publisher_rpc.metering_topic + '.' + 'test', topics) self.assertIn( - cfg.CONF.publisher_meter.metering_topic + '.' + 'test2', topics) + cfg.CONF.publisher_rpc.metering_topic + '.' + 'test2', topics) self.assertIn( - cfg.CONF.publisher_meter.metering_topic + '.' + 'test3', topics) + cfg.CONF.publisher_rpc.metering_topic + '.' + 'test3', topics) diff --git a/tests/storage/base.py b/tests/storage/base.py index 7bac5c91f..0496af1e4 100644 --- a/tests/storage/base.py +++ b/tests/storage/base.py @@ -25,7 +25,7 @@ import datetime from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer import storage from ceilometer.tests import db as test_db @@ -55,9 +55,9 @@ class DBTestBase(test_db.TestBase): 'tag': 'self.counter', } ) - self.msg1 = meter.meter_message_from_counter( + self.msg1 = rpc.meter_message_from_counter( self.counter, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test-1', ) self.conn.record_metering_data(self.msg1) @@ -76,9 +76,9 @@ class DBTestBase(test_db.TestBase): 'tag': 'self.counter2', } ) - self.msg2 = meter.meter_message_from_counter( + self.msg2 = rpc.meter_message_from_counter( self.counter2, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test-2', ) self.conn.record_metering_data(self.msg2) @@ -97,9 +97,9 @@ class DBTestBase(test_db.TestBase): 'tag': 'self.counter3', } ) - self.msg3 = meter.meter_message_from_counter( + self.msg3 = rpc.meter_message_from_counter( self.counter3, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test-3', ) self.conn.record_metering_data(self.msg3) @@ -118,9 +118,9 @@ class DBTestBase(test_db.TestBase): resource_metadata={'display_name': 'test-server', 'tag': 'counter-%s' % i}, ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test', ) self.conn.record_metering_data(msg) @@ -391,7 +391,7 @@ class StatisticsTest(DBTestBase): } ) self.counters.append(c) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, secret='not-so-secret', source='test', @@ -412,7 +412,7 @@ class StatisticsTest(DBTestBase): } ) self.counters.append(c) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, secret='not-so-secret', source='test', @@ -554,9 +554,9 @@ class CounterDataTypeTest(DBTestBase): timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata={} ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test-1', ) @@ -573,9 +573,9 @@ class CounterDataTypeTest(DBTestBase): timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata={} ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test-1', ) self.conn.record_metering_data(msg) @@ -591,9 +591,9 @@ class CounterDataTypeTest(DBTestBase): timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata={} ) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'test-1', ) self.conn.record_metering_data(msg) diff --git a/tests/storage/test_impl_mongodb.py b/tests/storage/test_impl_mongodb.py index 108e8627d..8e891c3ff 100644 --- a/tests/storage/test_impl_mongodb.py +++ b/tests/storage/test_impl_mongodb.py @@ -51,7 +51,7 @@ import datetime from tests.storage import base -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer.storage.impl_mongodb import require_map_reduce @@ -162,7 +162,7 @@ class CompatibilityTest(MongoDBEngineTestBase): } ) self.counters.append(c) - msg = meter.meter_message_from_counter( + msg = rpc.meter_message_from_counter( c, secret='not-so-secret', source='test') diff --git a/tools/make_test_data.py b/tools/make_test_data.py index d8ec483b7..c24c2115b 100755 --- a/tools/make_test_data.py +++ b/tools/make_test_data.py @@ -27,7 +27,7 @@ import sys from oslo.config import cfg -from ceilometer.publisher import meter +from ceilometer.publisher import rpc from ceilometer import counter from ceilometer import storage from ceilometer.openstack.common import timeutils @@ -129,9 +129,9 @@ def main(): timestamp=timestamp, resource_metadata={}, ) - data = meter.meter_message_from_counter( + data = rpc.meter_message_from_counter( c, - cfg.CONF.publisher_meter.metering_secret, + cfg.CONF.publisher_rpc.metering_secret, 'artificial') conn.record_metering_data(data) n += 1