Add tacker actions in mistral

Change-Id: Ie5f445fae4aee7bb01a71b3959c0ff2610c52f1f
Implements: blueprint tacker-api-actions
This commit is contained in:
Shaik Apsar
2016-06-20 16:05:44 -04:00
parent 9d00052f61
commit 7e9c04ebb9
8 changed files with 68 additions and 3 deletions

View File

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

View File

@@ -33,6 +33,7 @@ from novaclient import client as novaclient
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log from oslo_log import log
from swiftclient import client as swift_client from swiftclient import client as swift_client
from tackerclient.v1_0 import client as tackerclient
from troveclient.v1 import client as troveclient from troveclient.v1 import client as troveclient
from zaqarclient.queues.v2 import client as zaqarclient from zaqarclient.queues.v2 import client as zaqarclient
@@ -660,3 +661,27 @@ class MuranoAction(base.OpenStackAction):
@classmethod @classmethod
def _get_fake_client(cls): def _get_fake_client(cls):
return cls._client_class() return cls._client_class()
class TackerAction(base.OpenStackAction):
_client_class = tackerclient.Client
def _get_client(self):
ctx = context.ctx()
LOG.debug("Tacker action security context: %s" % ctx)
keystone_endpoint = keystone_utils.get_keystone_endpoint_v2()
tacker_endpoint = keystone_utils.get_endpoint_for_project('tacker')
return self._client_class(
endpoint_url=tacker_endpoint.url,
token=ctx.auth_token,
tenant_id=ctx.project_id,
region_name=tacker_endpoint.region,
auth_url=keystone_endpoint.url
)
@classmethod
def _get_fake_client(cls):
return cls._client_class()

View File

@@ -1245,5 +1245,24 @@
"sessions_delete": "sessions.delete", "sessions_delete": "sessions.delete",
"sessions_deploy": "sessions.deploy", "sessions_deploy": "sessions.deploy",
"sessions_get": "sessions.get" "sessions_get": "sessions.get"
},
"tacker":{
"_comment": "It uses tackerclient.v1_0.",
"list_extensions": "list_extensions",
"show_extension": "show_extension",
"create_vnfd": "create_vnfd",
"delete_vnfd": "delete_vnfd",
"list_vnfds": "list_vnfds",
"show_vnfd": "show_vnfd",
"create_vnf": "create_vnf",
"update_vnf": "update_vnf",
"delete_vnf": "delete_vnf",
"list_vnfs": "list_vnfs",
"show_vnf": "show_vnf",
"create_vim": "create_vim",
"update_vim": "update_vim",
"delete_vim": "delete_vim",
"list_vims": "list_vims",
"show_vim": "show_vim"
} }
} }

View File

@@ -34,10 +34,11 @@ MODULE_MAPPING = {
'mistral': ['mistral.workflows_get', actions.MistralAction], 'mistral': ['mistral.workflows_get', actions.MistralAction],
'designate': ['designate.domains_list', actions.DesignateAction], 'designate': ['designate.domains_list', actions.DesignateAction],
'magnum': ['magnum.bays_list', actions.MagnumAction], 'magnum': ['magnum.bays_list', actions.MagnumAction],
'murano': ['murano.deployments_list', actions.MuranoAction] 'murano': ['murano.deployments_list', actions.MuranoAction],
'tacker': ['tacker.list_vims', actions.TackerAction]
} }
EXTRA_MODULES = ['neutron', 'swift', 'zaqar'] EXTRA_MODULES = ['neutron', 'swift', 'zaqar', 'tacker']
class GeneratorTest(base.BaseTest): class GeneratorTest(base.BaseTest):

View File

@@ -225,3 +225,17 @@ class OpenStackActionTest(base.BaseTestCase):
mocked().categories.get.assert_called_once_with( mocked().categories.get.assert_called_once_with(
category_id="1234-abcd" category_id="1234-abcd"
) )
@mock.patch.object(actions.TackerAction, '_get_client')
def test_tacker_action(self, mocked):
method_name = "show_vim"
action_class = actions.TackerAction
action_class.client_method_name = method_name
params = {'vim_id': '1234-abcd'}
action = action_class(**params)
action.run()
self.assertTrue(mocked().show_vim.called)
mocked().show_vim.assert_called_once_with(
vim_id="1234-abcd"
)

View File

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

View File

@@ -37,6 +37,7 @@ python-muranoclient>=0.8.2 # Apache-2.0
python-neutronclient>=4.2.0 # Apache-2.0 python-neutronclient>=4.2.0 # Apache-2.0
python-novaclient!=2.33.0,>=2.29.0 # Apache-2.0 python-novaclient!=2.33.0,>=2.29.0 # Apache-2.0
python-swiftclient>=2.2.0 # Apache-2.0 python-swiftclient>=2.2.0 # Apache-2.0
python-tackerclient>=0.4.0 # Apache-2.0
python-troveclient>=2.2.0 # Apache-2.0 python-troveclient>=2.2.0 # Apache-2.0
python-ironicclient>=1.1.0 # Apache-2.0 python-ironicclient>=1.1.0 # Apache-2.0
python-ironic-inspector-client>=1.5.0 # Apache-2.0 python-ironic-inspector-client>=1.5.0 # Apache-2.0

View File

@@ -51,6 +51,8 @@ from troveclient.v1 import client as troveclient
# like we do in this class. # like we do in this class.
# TODO(therve): Zaqarclient doesn't currently support discovery # TODO(therve): Zaqarclient doesn't currently support discovery
# like we do in this class. # like we do in this class.
# TODO(sa709c): Tackerclient doesn't currently support discovery
# like we do in this class.
"""It is simple CLI tool which allows to see and update mapping.json file """It is simple CLI tool which allows to see and update mapping.json file
if needed. mapping.json contains all allowing OpenStack actions sorted by if needed. mapping.json contains all allowing OpenStack actions sorted by