summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgord chung <gord@live.ca>2017-01-11 22:52:26 +0000
committergord chung <gord@live.ca>2017-01-11 23:11:36 +0000
commit72ea5ef82461d12644f0be6b80ac7dd07a4a2cec (patch)
tree35862ac0cb577ca5e7ff24af9c8460249575eef3
parent45f4f9584bb46e1d7f47d32ac9cfaab04a209d34 (diff)
downloadpython-ceilometerclient-72ea5ef82461d12644f0be6b80ac7dd07a4a2cec.tar.gz
panko redirect
same as aodh but with panko_endpoint Change-Id: Iae7d60e1cf139b79e74caf81ed7bdbd0bf2bc473
-rw-r--r--ceilometerclient/client.py3
-rw-r--r--ceilometerclient/tests/unit/test_client.py10
-rw-r--r--ceilometerclient/tests/unit/test_shell.py18
-rw-r--r--ceilometerclient/v2/client.py35
-rw-r--r--releasenotes/notes/panko-redirect-9d03598dbf51f8fd.yaml7
5 files changed, 45 insertions, 28 deletions
diff --git a/ceilometerclient/client.py b/ceilometerclient/client.py
index 7e4f1c0..dd404e4 100644
--- a/ceilometerclient/client.py
+++ b/ceilometerclient/client.py
@@ -403,8 +403,9 @@ def _construct_http_client(**kwargs):
# Drop legacy options
for opt in LEGACY_OPTS:
kwargs.pop(opt, None)
- # Drop aodh_endpoint from kwargs
+ # Drop redirect endpoints from kwargs
kwargs.pop('aodh_endpoint', None)
+ kwargs.pop('panko_endpoint', None)
return SessionClient(
session=kwargs.pop('session'),
diff --git a/ceilometerclient/tests/unit/test_client.py b/ceilometerclient/tests/unit/test_client.py
index 2beaf73..400e997 100644
--- a/ceilometerclient/tests/unit/test_client.py
+++ b/ceilometerclient/tests/unit/test_client.py
@@ -43,8 +43,9 @@ class ClientTest(utils.BaseTestCase):
def create_client(env, api_version=2, endpoint=None, exclude=[]):
env = dict((k, v) for k, v in env.items()
if k not in exclude)
- with mock.patch('ceilometerclient.v2.client.Client._get_alarm_client',
- return_value=None):
+ with mock.patch(
+ 'ceilometerclient.v2.client.Client._get_redirect_client',
+ return_value=None):
return client.get_client(api_version, **env)
def test_client_v2_with_session(self):
@@ -184,8 +185,9 @@ class ClientTest2(ClientTest):
def create_client(env, api_version=2, endpoint=None, exclude=[]):
env = dict((k, v) for k, v in env.items()
if k not in exclude)
- with mock.patch('ceilometerclient.v2.client.Client._get_alarm_client',
- return_value=None):
+ with mock.patch(
+ 'ceilometerclient.v2.client.Client._get_redirect_client',
+ return_value=None):
return client.Client(api_version, endpoint, **env)
diff --git a/ceilometerclient/tests/unit/test_shell.py b/ceilometerclient/tests/unit/test_shell.py
index 41f6f54..d666594 100644
--- a/ceilometerclient/tests/unit/test_shell.py
+++ b/ceilometerclient/tests/unit/test_shell.py
@@ -112,7 +112,7 @@ class ShellBashCompletionTest(ShellTestBase):
class ShellKeystoneV2Test(ShellTestBase):
@mock.patch.object(ks_session, 'Session')
- @mock.patch('ceilometerclient.v2.client.Client._get_alarm_client',
+ @mock.patch('ceilometerclient.v2.client.Client._get_redirect_client',
mock.Mock(return_value=None))
def test_debug_switch_raises_error(self, mock_ksclient):
mock_ksclient.side_effect = exc.HTTPUnauthorized
@@ -121,7 +121,7 @@ class ShellKeystoneV2Test(ShellTestBase):
self.assertRaises(exc.CommandError, ceilometer_shell.main, args)
@mock.patch.object(ks_session, 'Session')
- @mock.patch('ceilometerclient.v2.client.Client._get_alarm_client',
+ @mock.patch('ceilometerclient.v2.client.Client._get_redirect_client',
mock.Mock(return_value=None))
def test_dash_d_switch_raises_error(self, mock_ksclient):
mock_ksclient.side_effect = exc.CommandError("FAIL")
@@ -141,7 +141,7 @@ class ShellKeystoneV2Test(ShellTestBase):
class ShellKeystoneV3Test(ShellTestBase):
@mock.patch.object(ks_session, 'Session')
- @mock.patch('ceilometerclient.v2.client.Client._get_alarm_client',
+ @mock.patch('ceilometerclient.v2.client.Client._get_redirect_client',
mock.Mock(return_value=None))
def test_debug_switch_raises_error(self, mock_ksclient):
mock_ksclient.side_effect = exc.HTTPUnauthorized
@@ -194,7 +194,7 @@ class ShellTimeoutTest(ShellTestBase):
self._test_timeout('0', expected_msg)
@mock.patch.object(ks_session, 'Session')
- @mock.patch('ceilometerclient.v2.client.Client._get_alarm_client',
+ @mock.patch('ceilometerclient.v2.client.Client._get_redirect_client',
mock.Mock(return_value=None))
def test_timeout_keystone_session(self, mocked_session):
mocked_session.side_effect = exc.HTTPUnauthorized("FAIL")
@@ -208,7 +208,7 @@ class ShellTimeoutTest(ShellTestBase):
class ShellInsecureTest(ShellTestBase):
@mock.patch.object(api_client, 'HTTPClient')
- @mock.patch('ceilometerclient.v2.client.Client._get_alarm_client',
+ @mock.patch('ceilometerclient.v2.client.Client._get_redirect_client',
mock.Mock(return_value=None))
def test_insecure_true_ceilometer(self, mocked_client):
self.make_env(FAKE_V2_ENV)
@@ -218,7 +218,7 @@ class ShellInsecureTest(ShellTestBase):
self.assertFalse(kwargs.get('verify'))
@mock.patch.object(ks_session, 'Session')
- @mock.patch('ceilometerclient.v2.client.Client._get_alarm_client',
+ @mock.patch('ceilometerclient.v2.client.Client._get_redirect_client',
mock.Mock(return_value=None))
def test_insecure_true_keystone(self, mocked_session):
mocked_session.side_effect = exc.HTTPUnauthorized("FAIL")
@@ -229,7 +229,7 @@ class ShellInsecureTest(ShellTestBase):
self.assertFalse(kwargs.get('verify'))
@mock.patch.object(api_client, 'HTTPClient')
- @mock.patch('ceilometerclient.v2.client.Client._get_alarm_client',
+ @mock.patch('ceilometerclient.v2.client.Client._get_redirect_client',
mock.Mock(return_value=None))
def test_insecure_false_ceilometer(self, mocked_client):
self.make_env(FAKE_V2_ENV)
@@ -239,7 +239,7 @@ class ShellInsecureTest(ShellTestBase):
self.assertTrue(kwargs.get('verify'))
@mock.patch.object(ks_session, 'Session')
- @mock.patch('ceilometerclient.v2.client.Client._get_alarm_client',
+ @mock.patch('ceilometerclient.v2.client.Client._get_redirect_client',
mock.Mock(return_value=None))
def test_insecure_false_keystone(self, mocked_session):
mocked_session.side_effect = exc.HTTPUnauthorized("FAIL")
@@ -270,7 +270,7 @@ class ShellEndpointTest(ShellTestBase):
class ShellAlarmUpdateRepeatAction(ShellTestBase):
@mock.patch('ceilometerclient.v2.alarms.AlarmManager.update')
- @mock.patch('ceilometerclient.v2.client.Client._get_alarm_client',
+ @mock.patch('ceilometerclient.v2.client.Client._get_redirect_client',
mock.Mock())
def test_repeat_action_not_specified(self, mocked):
self.make_env(FAKE_V2_ENV)
diff --git a/ceilometerclient/v2/client.py b/ceilometerclient/v2/client.py
index dbabe28..8b672dd 100644
--- a/ceilometerclient/v2/client.py
+++ b/ceilometerclient/v2/client.py
@@ -62,21 +62,28 @@ class Client(object):
self.auth_plugin = kwargs.get('auth_plugin')
self.http_client = ceiloclient._construct_http_client(**kwargs)
- self.alarm_client = self._get_alarm_client(**kwargs)
+ self.alarm_client = self._get_redirect_client(
+ 'alarming', 'aodh', **kwargs)
aodh_enabled = self.alarm_client is not None
if not aodh_enabled:
self.alarm_client = self.http_client
+ self.event_client = self._get_redirect_client(
+ 'event', 'panko', **kwargs)
+ panko_enabled = self.event_client is not None
+ if not panko_enabled:
+ self.event_client = self.http_client
+
self.meters = meters.MeterManager(self.http_client)
self.samples = samples.OldSampleManager(self.http_client)
self.new_samples = samples.SampleManager(self.http_client)
self.statistics = statistics.StatisticsManager(self.http_client)
self.resources = resources.ResourceManager(self.http_client)
self.alarms = alarms.AlarmManager(self.alarm_client, aodh_enabled)
- self.events = events.EventManager(self.http_client)
- self.event_types = event_types.EventTypeManager(self.http_client)
- self.traits = traits.TraitManager(self.http_client)
+ self.events = events.EventManager(self.event_client)
+ self.event_types = event_types.EventTypeManager(self.event_client)
+ self.traits = traits.TraitManager(self.event_client)
self.trait_descriptions = trait_descriptions.\
- TraitDescriptionManager(self.http_client)
+ TraitDescriptionManager(self.event_client)
self.query_samples = query.QuerySamplesManager(
self.http_client)
@@ -86,36 +93,36 @@ class Client(object):
self.capabilities = capabilities.CapabilitiesManager(self.http_client)
@staticmethod
- def _get_alarm_client(**ceilo_kwargs):
- """Get client for alarm manager that redirect to aodh."""
+ def _get_redirect_client(new_service_type, new_service, **ceilo_kwargs):
+ """Get client for new service manager to redirect to."""
# NOTE(sileht): the auth_plugin/keystone session cannot be copied
# because they rely on threading module.
auth_plugin = ceilo_kwargs.pop('auth_plugin', None)
session = ceilo_kwargs.pop('session', None)
kwargs = copy.deepcopy(ceilo_kwargs)
- kwargs["service_type"] = "alarming"
- aodh_endpoint = ceilo_kwargs.get('aodh_endpoint')
+ kwargs["service_type"] = new_service_type
+ endpoint = ceilo_kwargs.get('%s_endpoint' % new_service)
if session:
# keystone session can be shared between client
ceilo_kwargs['session'] = kwargs['session'] = session
- if aodh_endpoint:
- kwargs['endpoint_override'] = aodh_endpoint
+ if endpoint:
+ kwargs['endpoint_override'] = endpoint
elif auth_plugin and kwargs.get('auth_url'):
ceilo_kwargs['auth_plugin'] = auth_plugin
kwargs.pop('endpoint', None)
kwargs['auth_plugin'] = ceiloclient.get_auth_plugin(
- aodh_endpoint, **kwargs)
+ endpoint, **kwargs)
else:
# Users may just provide ceilometer endpoint and token, and no
# auth_url, in this case, we need 'aodh_endpoint' also to be
# provided, otherwise we cannot get aodh endpoint from
- # keystone, and assume aodh is unavailable.
+ # keystone, and assume aodh is unavailable. Same applies to panko.
return None
try:
- # NOTE(sileht): try to use aodh
+ # NOTE(sileht): try to use redirect
c = ceiloclient._construct_http_client(**kwargs)
c.get("/")
return c
diff --git a/releasenotes/notes/panko-redirect-9d03598dbf51f8fd.yaml b/releasenotes/notes/panko-redirect-9d03598dbf51f8fd.yaml
new file mode 100644
index 0000000..36f1c8e
--- /dev/null
+++ b/releasenotes/notes/panko-redirect-9d03598dbf51f8fd.yaml
@@ -0,0 +1,7 @@
+---
+prelude: >
+ Panko replaces the API and storage of events previously in Ceilometer
+features:
+ - |
+ Similar to aodh redirect support, specify `panko_endpoint` as a redirect
+ to Panko API.