Merge "Add support for OpenStack Swift actions"
This commit is contained in:
commit
75630cfeee
@ -19,7 +19,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'
|
'Trove', 'Ironic', 'Baremetal Introspection', 'Swift'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ from neutronclient.v2_0 import client as neutronclient
|
|||||||
from novaclient import client as novaclient
|
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 troveclient import client as troveclient
|
from troveclient import client as troveclient
|
||||||
|
|
||||||
from mistral.actions.openstack import base
|
from mistral.actions.openstack import base
|
||||||
@ -308,3 +309,21 @@ class BaremetalIntrospectionAction(base.OpenStackAction):
|
|||||||
inspector_url=inspector_endpoint.url,
|
inspector_url=inspector_endpoint.url,
|
||||||
auth_token=ctx.auth_token,
|
auth_token=ctx.auth_token,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class SwiftAction(base.OpenStackAction):
|
||||||
|
_client_class = swift_client.Connection
|
||||||
|
|
||||||
|
def _get_client(self):
|
||||||
|
ctx = context.ctx()
|
||||||
|
|
||||||
|
LOG.debug("Swift action security context: %s" % ctx)
|
||||||
|
|
||||||
|
swift_endpoint = keystone_utils.get_endpoint_for_project('swift')
|
||||||
|
|
||||||
|
kwargs = {
|
||||||
|
'preauthurl': swift_endpoint.url % {'tenant_id': ctx.project_id},
|
||||||
|
'preauthtoken': ctx.auth_token
|
||||||
|
}
|
||||||
|
|
||||||
|
return self._client_class(**kwargs)
|
||||||
|
@ -922,5 +922,20 @@
|
|||||||
"rules_from_json": "rules.from_json",
|
"rules_from_json": "rules.from_json",
|
||||||
"rules_get": "rules.get",
|
"rules_get": "rules.get",
|
||||||
"rules_get_all": "rules.get_all"
|
"rules_get_all": "rules.get_all"
|
||||||
|
},
|
||||||
|
"swift": {
|
||||||
|
"_comment": "It uses swiftclient.v1.",
|
||||||
|
"head_account": "head_account",
|
||||||
|
"get_account": "get_account",
|
||||||
|
"post_account": "post_account",
|
||||||
|
"head_container": "head_container",
|
||||||
|
"get_container": "get_container",
|
||||||
|
"put_container": "put_container",
|
||||||
|
"post_container": "post_container",
|
||||||
|
"delete_container": "delete_container",
|
||||||
|
"get_object": "get_object",
|
||||||
|
"put_object": "put_object",
|
||||||
|
"post_object": "post_object",
|
||||||
|
"get_capabilities": "get_capabilities"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,10 @@ MODULE_MAPPING = {
|
|||||||
'ironic': ['ironic.node_list', actions.IronicAction],
|
'ironic': ['ironic.node_list', actions.IronicAction],
|
||||||
'baremetal_introspection': ['baremetal_introspection.introspect',
|
'baremetal_introspection': ['baremetal_introspection.introspect',
|
||||||
actions.BaremetalIntrospectionAction],
|
actions.BaremetalIntrospectionAction],
|
||||||
|
'swift': ['swift.head_account', actions.SwiftAction],
|
||||||
}
|
}
|
||||||
|
|
||||||
EXTRA_MODULES = ['neutron']
|
EXTRA_MODULES = ['neutron', 'swift']
|
||||||
|
|
||||||
|
|
||||||
class GeneratorTest(base.BaseTest):
|
class GeneratorTest(base.BaseTest):
|
||||||
|
@ -138,3 +138,16 @@ class OpenStackActionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
self.assertTrue(mocked().get_status.called)
|
self.assertTrue(mocked().get_status.called)
|
||||||
mocked().get_status.assert_called_once_with(uuid="1234")
|
mocked().get_status.assert_called_once_with(uuid="1234")
|
||||||
|
|
||||||
|
@mock.patch.object(actions.SwiftAction, '_get_client')
|
||||||
|
def test_swift_action(self, mocked):
|
||||||
|
method_name = "get_object"
|
||||||
|
action_class = actions.SwiftAction
|
||||||
|
action_class.client_method_name = method_name
|
||||||
|
params = {'container': 'foo', 'object': 'bar'}
|
||||||
|
action = action_class(**params)
|
||||||
|
action.run()
|
||||||
|
|
||||||
|
self.assertTrue(mocked().get_object.called)
|
||||||
|
mocked().get_object.assert_called_once_with(container='foo',
|
||||||
|
object='bar')
|
||||||
|
@ -28,6 +28,7 @@ python-heatclient>=0.6.0
|
|||||||
python-keystoneclient!=1.8.0,>=1.6.0
|
python-keystoneclient!=1.8.0,>=1.6.0
|
||||||
python-neutronclient>=2.6.0
|
python-neutronclient>=2.6.0
|
||||||
python-novaclient!=2.33.0,>=2.29.0
|
python-novaclient!=2.33.0,>=2.29.0
|
||||||
|
python-swiftclient>=2.2.0
|
||||||
python-troveclient>=1.2.0
|
python-troveclient>=1.2.0
|
||||||
python-ironicclient>=0.8.0
|
python-ironicclient>=0.8.0
|
||||||
python-ironic-inspector-client>=1.3.0
|
python-ironic-inspector-client>=1.3.0
|
||||||
|
@ -38,6 +38,8 @@ from troveclient.v1 import client as troveclient
|
|||||||
# TODO(nmakhotkin): (e.g. keystone).
|
# TODO(nmakhotkin): (e.g. keystone).
|
||||||
# TODO(dprince): Need to update ironic_inspector_client before we can
|
# TODO(dprince): Need to update ironic_inspector_client before we can
|
||||||
# plug it in cleanly here.
|
# plug it in cleanly here.
|
||||||
|
# TODO(dprince): Swiftclient 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
|
||||||
@ -161,6 +163,7 @@ CLIENTS = {
|
|||||||
'ironic': get_ironic_client,
|
'ironic': get_ironic_client,
|
||||||
# 'neutron': get_nova_client
|
# 'neutron': get_nova_client
|
||||||
# 'baremetal_introspection': ...
|
# 'baremetal_introspection': ...
|
||||||
|
# 'swift': ...
|
||||||
}
|
}
|
||||||
BASE_MANAGERS = {
|
BASE_MANAGERS = {
|
||||||
'nova': BASE_NOVA_MANAGER,
|
'nova': BASE_NOVA_MANAGER,
|
||||||
@ -173,6 +176,7 @@ BASE_MANAGERS = {
|
|||||||
'ironic': BASE_IRONIC_MANAGER,
|
'ironic': BASE_IRONIC_MANAGER,
|
||||||
# 'neutron': BASE_NOVA_MANAGER
|
# 'neutron': BASE_NOVA_MANAGER
|
||||||
# 'baremetal_introspection': ...
|
# 'baremetal_introspection': ...
|
||||||
|
# 'swift': ...
|
||||||
}
|
}
|
||||||
NAMESPACES = {
|
NAMESPACES = {
|
||||||
'glance': GLANCE_NAMESPACE_LIST,
|
'glance': GLANCE_NAMESPACE_LIST,
|
||||||
|
Loading…
Reference in New Issue
Block a user