Support actions for zun

Add ZunAction for zun. Zun is an OpenStack Container service. It aims to
provide an API service for running application containers without the
need to manage servers or clusters.

Change-Id: Ibbe4777528b5af6fdb3a6c2ed3345f8f9c804bef
Signed-off-by: pengdake <19921207pq@gmail.com>
This commit is contained in:
pengdake 2018-03-21 19:47:21 +08:00
parent 94e20726b2
commit 11896ba733
8 changed files with 95 additions and 2 deletions

View File

@ -129,6 +129,7 @@ python-tackerclient==0.8.0
python-troveclient==2.2.0
python-vitrageclient==2.0.0
python-zaqarclient==1.0.0
python-zunclient==1.0.0
pytz==2013.6
PyYAML==3.12
reno==2.5.0

View File

@ -21,7 +21,7 @@ SUPPORTED_MODULES = [
'Nova', 'Glance', 'Keystone', 'Heat', 'Neutron', 'Cinder',
'Trove', 'Ironic', 'Baremetal Introspection', 'Swift', 'SwiftService',
'Zaqar', 'Barbican', 'Mistral', 'Designate', 'Magnum', 'Murano', 'Tacker',
'Aodh', 'Gnocchi', 'Glare', 'Vitrage', 'Senlin'
'Aodh', 'Gnocchi', 'Glare', 'Vitrage', 'Senlin', 'Zun'
]

View File

@ -72,6 +72,7 @@ tackerclient = _try_import('tackerclient.v1_0.client')
troveclient = _try_import('troveclient.v1.client')
vitrageclient = _try_import('vitrageclient.v1.client')
zaqarclient = _try_import('zaqarclient.queues.client')
zunclient = _try_import('zunclient.v1.client')
class NovaAction(base.OpenStackAction):
@ -940,3 +941,36 @@ class VitrageAction(base.OpenStackAction):
@classmethod
def _get_fake_client(cls):
return cls._get_client_class()()
class ZunAction(base.OpenStackAction):
_service_name = 'appcontainer'
@classmethod
def _get_client_class(cls):
return zunclient.Client
def _create_client(self, context):
LOG.debug("Zun action security context: %s", context)
keystone_endpoint = keystone_utils.get_keystone_endpoint_v2()
zun_endpoint = self.get_service_endpoint()
session_and_auth = self.get_session_and_auth(context)
client = self._get_client_class()(
'1',
endpoint_override=zun_endpoint.url,
auth_url=keystone_endpoint.url,
session=session_and_auth['session']
)
return client
@classmethod
def _get_fake_client(cls):
session = keystone_utils.get_admin_session()
return cls._get_client_class()(
endpoint_override="http://127.0.0.1:9517/",
session=session
)

View File

@ -1268,5 +1268,42 @@
"webhook_show": "webhook.show",
"webhook_add": "webhook.add",
"webhook_delete": "webhook.delete"
},
"zun":{
"_comment": "It uses zunclient.v1. ",
"containers_add_security_group": "containers.add_security_group",
"containers_attach": "containers.attach",
"containers_commit": "containers.commit",
"containers_create": "containers.create",
"containers_delete": "containers.delete",
"containers_execute": "containers.execute",
"containers_execute_resize": "containers.execute_resize",
"containers_get": "containers.get",
"containers_get_archive": "containers.get_archive",
"containers_kill": "containers.kill",
"containers_list": "containers.list",
"containers_logs": "containers.logs",
"containers_network_attach": "containers.network_attach",
"containers_network_detach": "containers.network_detach",
"containers_pause": "containers.pause",
"containers_put_archive": "containers.put_archive",
"containers_remove_security_group": "containers.remove_security_group",
"containers_rename": "containers.rename",
"containers_resize": "containers.resize",
"containers_restart": "containers.restart",
"containers_run": "containers.run",
"containers_start": "containers.start",
"containers_stats": "containers.stats",
"containers_stop": "containers.stop",
"containers_top": "containers.top",
"containers_update": "containers.update",
"hosts_list": "hosts.list",
"hosts_get": "hosts.get",
"images_delete": "images.delete",
"images_list": "images.list",
"services_delete": "services.delete",
"services_disable": "services.disable",
"services_enable": "services.enable",
"services_list": "services.list"
}
}

View File

@ -55,7 +55,8 @@ MODULE_MAPPING = {
'aodh': ['aodh.alarm_list', actions.AodhAction],
'gnocchi': ['gnocchi.metric_list', actions.GnocchiAction],
'glare': ['glare.artifacts_list', actions.GlareAction],
'vitrage': ['vitrage.alarm_get', actions.VitrageAction]
'vitrage': ['vitrage.alarm_get', actions.VitrageAction],
'zun': ['zun.containers_list', actions.ZunAction]
}
EXTRA_MODULES = ['neutron', 'swift', 'zaqar', 'tacker', 'senlin']

View File

@ -359,3 +359,18 @@ class OpenStackActionTest(base.BaseTestCase):
self.assertTrue(mocked().alarm.get.called)
mocked().alarm.get.assert_called_once_with(vitrage_id="1234-abcd")
@mock.patch.object(actions.ZunAction, '_get_client')
def test_zun_action(self, mocked):
mock_ctx = mock.Mock()
method_name = "containers.get"
action_class = actions.ZunAction
action_class.client_method_name = method_name
params = {'container_id': '1234-abcd'}
action = action_class(**params)
action.run(mock_ctx)
self.assertTrue(mocked().containers.get.called)
mocked().containers.get.assert_called_once_with(
container_id="1234-abcd"
)

View File

@ -0,0 +1,4 @@
---
features:
- |
Add Mistral actions for Openstack Zun, the container service.

View File

@ -50,6 +50,7 @@ python-ironicclient>=2.3.0 # Apache-2.0
python-ironic-inspector-client>=1.5.0 # Apache-2.0
python-vitrageclient>=2.0.0 # Apache-2.0
python-zaqarclient>=1.0.0 # Apache-2.0
python-zunclient>=1.0.0 # Apache-2.0
PyJWT>=1.0.1 # MIT
PyYAML>=3.12 # MIT
requests>=2.14.2 # Apache-2.0