Merge "Added gnocchi action pack"

This commit is contained in:
Jenkins 2017-01-11 06:34:13 +00:00 committed by Gerrit Code Review
commit 7f0f09f410
8 changed files with 98 additions and 3 deletions

View File

@ -20,7 +20,7 @@ from mistral.actions.openstack.action_generator import base
SUPPORTED_MODULES = [
'Nova', 'Glance', 'Keystone', 'Heat', 'Neutron', 'Cinder', 'Ceilometer',
'Trove', 'Ironic', 'Baremetal Introspection', 'Swift', 'Zaqar', 'Barbican',
'Mistral', 'Designate', 'Magnum', 'Murano', 'Tacker', 'Aodh'
'Mistral', 'Designate', 'Magnum', 'Murano', 'Tacker', 'Aodh', 'Gnocchi',
]

View File

@ -27,10 +27,11 @@ ceilometerclient = importutils.try_import('ceilometerclient.v2.client')
cinderclient = importutils.try_import('cinderclient.v2.client')
designateclient = importutils.try_import('designateclient.v1')
glanceclient = importutils.try_import('glanceclient.v2.client')
gnocchiclient = importutils.try_import('gnocchiclient.v1.client')
heatclient = importutils.try_import('heatclient.v1.client')
keystoneclient = importutils.try_import('keystoneclient.v3.client')
ironic_inspector_client = importutils.try_import('ironic_inspector_client.v1')
ironicclient = importutils.try_import('ironicclient.v1.client')
keystoneclient = importutils.try_import('keystoneclient.v3.client')
magnumclient = importutils.try_import('magnumclient.v1.client')
mistralclient = importutils.try_import('mistralclient.api.v2.client')
muranoclient = importutils.try_import('muranoclient.v1.client')
@ -830,3 +831,35 @@ class AodhAction(base.OpenStackAction):
@classmethod
def _get_fake_client(cls):
return cls._get_client_class()()
class GnocchiAction(base.OpenStackAction):
@classmethod
def _get_client_class(cls):
return gnocchiclient.Client
def _create_client(self):
ctx = context.ctx()
LOG.debug("Gnocchi action security context: %s" % ctx)
gnocchi_endpoint = keystone_utils.get_endpoint_for_project(
'gnocchi'
)
endpoint_url = keystone_utils.format_url(
gnocchi_endpoint.url,
{'tenant_id': ctx.project_id}
)
return self._get_client_class()(
endpoint_url,
region_name=gnocchi_endpoint.region,
token=ctx.auth_token,
username=ctx.user_name
)
@classmethod
def _get_fake_client(cls):
return cls._get_client_class()()

View File

@ -535,6 +535,42 @@
"alarm_history_get": "alarm_history.get",
"alarm_history_search": "alarm_history.search"
},
"gnocchi":{
"_comment": "It uses gnocchiclient.v1.",
"archive_policy_create": "archive_policy.create",
"archive_policy_delete": "archive_policy.delete",
"archive_policy_get": "archive_policy.get",
"archive_policy_list": "archive_policy.list",
"archive_policy_update": "archive_policy.update",
"archive_policy_rule_create": "archive_policy_rule.create",
"archive_policy_rule_delete": "archive_policy_rule.delete",
"archive_policy_rule_get": "archive_policy_rule.get",
"archive_polociy_rule_list": "archive_policy_rule.list",
"capabilities_list": "capabilities.list",
"measures_add": "metric.add_measures",
"metric_batch_metrics_measures": "metric.batch_metrics_measures",
"metric_batch_resources_metrics_measures": "metric.batch_resources_metrics_measures",
"metric_create": "metric.create",
"metric_delete": "metric.delete",
"metric_get": "metric.get",
"measures_get": "metric.get_measures",
"metric_list": "metric.list",
"resource_batch_delete_resource": "resource.batch_delete",
"resource_create": "resource.create",
"resource_delete": "resource.delete",
"resource_get": "resource.get",
"resource_history": "resource.history",
"resource_list": "resource.list",
"resource_search": "resource.search",
"resource_update": "resource.update",
"resource_type_create": "resource_type.create",
"resource_type_delete": "resource_type.delete",
"resource_type_get": "resource_type.get",
"resource_type_list": "resource_type.list",
"resource_type_update": "resource_type.update",
"measures_aggregation": "metric.aggregation",
"status": "status.get"
},
"neutron": {
"_comment": "It uses neutronclient.v2_0.",
"add_gateway_router": "add_gateway_router",

View File

@ -37,7 +37,8 @@ MODULE_MAPPING = {
'murano': ['murano.deployments_list', actions.MuranoAction],
'tacker': ['tacker.list_vims', actions.TackerAction],
'senlin': ['senlin.get_profile', actions.SenlinAction],
'aodh': ['aodh.alarm_list', actions.AodhAction]
'aodh': ['aodh.alarm_list', actions.AodhAction],
'gnocchi': ['gnocchi.metric_list', actions.GnocchiAction],
}
EXTRA_MODULES = ['neutron', 'swift', 'zaqar', 'tacker']

View File

@ -385,3 +385,15 @@ class OpenStackActionTest(base.BaseTestCase):
self.assertTrue(mocked().alarm.get.called)
mocked().alarm.get.assert_called_once_with(alarm_id="1234-abcd")
@mock.patch.object(actions.GnocchiAction, '_get_client')
def test_gnocchi_action(self, mocked):
method_name = "metric.get"
action_class = actions.GnocchiAction
action_class.client_method_name = method_name
params = {'metric_id': '1234-abcd'}
action = action_class(**params)
action.run()
self.assertTrue(mocked().metric.get.called)
mocked().metric.get.assert_called_once_with(metric_id="1234-abcd")

View File

@ -0,0 +1,3 @@
---
features:
- Gnocchi actions are now supported.

View File

@ -8,6 +8,7 @@ Babel>=2.3.4 # BSD
croniter>=0.3.4 # MIT License
cachetools>=1.1.0 # MIT License
eventlet!=0.18.3,>=0.18.2 # MIT
gnocchiclient>=2.7.0 # Apache-2.0
Jinja2>=2.8 # BSD License (3 clause)
jsonschema!=2.5.0,<3.0.0,>=2.0.0 # MIT
keystonemiddleware>=4.12.0 # Apache-2.0

View File

@ -27,6 +27,8 @@ from cinderclient.openstack.common.apiclient import base as cinder_base
from cinderclient.v2 import client as cinderclient
from designateclient import client as designateclient
from glanceclient.v2 import client as glanceclient
from gnocchiclient.v1 import base as gnocchi_base
from gnocchiclient.v1 import client as gnocchiclient
from heatclient.openstack.common.apiclient import base as heat_base
from heatclient.v1 import client as heatclient
from ironicclient.common import base as ironic_base
@ -89,6 +91,7 @@ BASE_BARBICAN_MANAGER = barbican_base.BaseEntityManager
BASE_MAGNUM_MANAGER = magnum_base.Manager
BASE_MURANO_MANAGER = murano_base.Manager
BASE_AODH_MANAGER = aodh_base.Manager
BASE_GNOCCHI_MANAGER = gnocchi_base.Manager
def get_parser():
@ -206,6 +209,10 @@ def get_aodh_client(**kwargs):
return aodhclient.Client('')
def get_gnocchi_client(**kwargs):
return gnocchiclient.Client()
CLIENTS = {
'nova': get_nova_client,
'heat': get_heat_client,
@ -221,6 +228,7 @@ CLIENTS = {
'magnum': get_magnum_client,
'murano': get_murano_client,
'aodh': get_aodh_client,
'gnocchi': get_gnocchi_client,
# 'neutron': get_nova_client
# 'baremetal_introspection': ...
# 'swift': ...
@ -241,6 +249,7 @@ BASE_MANAGERS = {
'magnum': BASE_MAGNUM_MANAGER,
'murano': BASE_MURANO_MANAGER,
'aodh': BASE_AODH_MANAGER,
'gnocchi': BASE_GNOCCHI_MANAGER,
# 'neutron': BASE_NOVA_MANAGER
# 'baremetal_introspection': ...
# 'swift': ...