Merge "Rename instance_actions v3 to server_actions"
This commit is contained in:
commit
2f4cabff32
@ -1,5 +1,5 @@
|
||||
{
|
||||
"instance_action": {
|
||||
"server_action": {
|
||||
"action": "reboot",
|
||||
"events": [
|
||||
{
|
||||
@ -17,11 +17,11 @@
|
||||
"traceback": ""
|
||||
}
|
||||
],
|
||||
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
|
||||
"server_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
|
||||
"message": "",
|
||||
"project_id": "147",
|
||||
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
|
||||
"start_time": "2012-12-05T00:00:00.000000",
|
||||
"user_id": "789"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"instance_actions": [
|
||||
"server_actions": [
|
||||
{
|
||||
"action": "resize",
|
||||
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
|
||||
"server_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
|
||||
"message": "",
|
||||
"project_id": "842",
|
||||
"request_id": "req-25517360-b757-47d3-be45-0e8d2a01b36a",
|
||||
@ -11,7 +11,7 @@
|
||||
},
|
||||
{
|
||||
"action": "reboot",
|
||||
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
|
||||
"server_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
|
||||
"message": "",
|
||||
"project_id": "147",
|
||||
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
|
||||
@ -19,4 +19,4 @@
|
||||
"user_id": "789"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -155,10 +155,10 @@
|
||||
"compute_extension:v3:os-hypervisors:discoverable": "",
|
||||
"compute_extension:image_size": "",
|
||||
"compute_extension:instance_actions": "",
|
||||
"compute_extension:v3:os-instance-actions": "",
|
||||
"compute_extension:v3:os-instance-actions:discoverable": "",
|
||||
"compute_extension:v3:os-server-actions": "",
|
||||
"compute_extension:v3:os-server-actions:discoverable": "",
|
||||
"compute_extension:instance_actions:events": "rule:admin_api",
|
||||
"compute_extension:v3:os-instance-actions:events": "rule:admin_api",
|
||||
"compute_extension:v3:os-server-actions:events": "rule:admin_api",
|
||||
"compute_extension:instance_usage_audit_log": "rule:admin_api",
|
||||
"compute_extension:v3:ips:discoverable": "",
|
||||
"compute_extension:keypairs": "",
|
||||
|
@ -21,7 +21,7 @@ from nova.api.openstack import wsgi
|
||||
from nova import compute
|
||||
from nova.openstack.common.gettextutils import _
|
||||
|
||||
ALIAS = "os-instance-actions"
|
||||
ALIAS = "os-server-actions"
|
||||
authorize_actions = extensions.extension_authorizer('compute',
|
||||
'v3:' + ALIAS)
|
||||
authorize_events = extensions.soft_extension_authorizer('compute',
|
||||
@ -32,17 +32,20 @@ ACTION_KEYS = ['action', 'instance_uuid', 'request_id', 'user_id',
|
||||
EVENT_KEYS = ['event', 'start_time', 'finish_time', 'result', 'traceback']
|
||||
|
||||
|
||||
class InstanceActionsController(wsgi.Controller):
|
||||
class ServerActionsController(wsgi.Controller):
|
||||
|
||||
def __init__(self):
|
||||
super(InstanceActionsController, self).__init__()
|
||||
super(ServerActionsController, self).__init__()
|
||||
self.compute_api = compute.API()
|
||||
self.action_api = compute.InstanceActionAPI()
|
||||
|
||||
def _format_action(self, action_raw):
|
||||
action = {}
|
||||
for key in ACTION_KEYS:
|
||||
action[key] = action_raw.get(key)
|
||||
if key == 'instance_uuid':
|
||||
action['server_uuid'] = action_raw.get(key)
|
||||
else:
|
||||
action[key] = action_raw.get(key)
|
||||
return action
|
||||
|
||||
def _format_event(self, event_raw):
|
||||
@ -59,7 +62,7 @@ class InstanceActionsController(wsgi.Controller):
|
||||
authorize_actions(context, target=instance)
|
||||
actions_raw = self.action_api.actions_get(context, instance)
|
||||
actions = [self._format_action(action) for action in actions_raw]
|
||||
return {'instance_actions': actions}
|
||||
return {'server_actions': actions}
|
||||
|
||||
@extensions.expected_errors(404)
|
||||
def show(self, req, server_id, id):
|
||||
@ -79,19 +82,19 @@ class InstanceActionsController(wsgi.Controller):
|
||||
events_raw = self.action_api.action_events_get(context, instance,
|
||||
action_id)
|
||||
action['events'] = [self._format_event(evt) for evt in events_raw]
|
||||
return {'instance_action': action}
|
||||
return {'server_action': action}
|
||||
|
||||
|
||||
class InstanceActions(extensions.V3APIExtensionBase):
|
||||
class ServerActions(extensions.V3APIExtensionBase):
|
||||
"""View a log of actions and events taken on an instance."""
|
||||
|
||||
name = "InstanceActions"
|
||||
name = "ServerActions"
|
||||
alias = ALIAS
|
||||
version = 1
|
||||
|
||||
def get_resources(self):
|
||||
ext = extensions.ResourceExtension('os-instance-actions',
|
||||
InstanceActionsController(),
|
||||
ext = extensions.ResourceExtension('os-server-actions',
|
||||
ServerActionsController(),
|
||||
parent=dict(
|
||||
member_name='server',
|
||||
collection_name='servers'))
|
@ -28,10 +28,10 @@ from nova.openstack.common import policy
|
||||
from nova import test
|
||||
from nova.tests.api.openstack import fakes
|
||||
from nova.tests import fake_instance
|
||||
from nova.tests import fake_instance_actions
|
||||
from nova.tests import fake_server_actions
|
||||
|
||||
FAKE_UUID = fake_instance_actions.FAKE_UUID
|
||||
FAKE_REQUEST_ID = fake_instance_actions.FAKE_REQUEST_ID1
|
||||
FAKE_UUID = fake_server_actions.FAKE_UUID
|
||||
FAKE_REQUEST_ID = fake_server_actions.FAKE_REQUEST_ID1
|
||||
|
||||
|
||||
def format_action(action):
|
||||
@ -112,8 +112,8 @@ class InstanceActionsTest(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(InstanceActionsTest, self).setUp()
|
||||
self.controller = instance_actions.InstanceActionsController()
|
||||
self.fake_actions = copy.deepcopy(fake_instance_actions.FAKE_ACTIONS)
|
||||
self.fake_events = copy.deepcopy(fake_instance_actions.FAKE_EVENTS)
|
||||
self.fake_actions = copy.deepcopy(fake_server_actions.FAKE_ACTIONS)
|
||||
self.fake_events = copy.deepcopy(fake_server_actions.FAKE_EVENTS)
|
||||
|
||||
def fake_get(self, context, instance_uuid, expected_attrs=None,
|
||||
want_objects=False):
|
||||
@ -222,8 +222,8 @@ class InstanceActionsTest(test.NoDBTestCase):
|
||||
class InstanceActionsSerializerTest(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(InstanceActionsSerializerTest, self).setUp()
|
||||
self.fake_actions = copy.deepcopy(fake_instance_actions.FAKE_ACTIONS)
|
||||
self.fake_events = copy.deepcopy(fake_instance_actions.FAKE_EVENTS)
|
||||
self.fake_actions = copy.deepcopy(fake_server_actions.FAKE_ACTIONS)
|
||||
self.fake_events = copy.deepcopy(fake_server_actions.FAKE_EVENTS)
|
||||
|
||||
def _verify_instance_action_attachment(self, attach, tree):
|
||||
for key in attach.keys():
|
||||
|
@ -18,7 +18,7 @@ import uuid
|
||||
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack.compute.plugins.v3 import instance_actions
|
||||
from nova.api.openstack.compute.plugins.v3 import server_actions
|
||||
from nova.compute import api as compute_api
|
||||
from nova import db
|
||||
from nova.db.sqlalchemy import models
|
||||
@ -27,10 +27,10 @@ from nova.openstack.common import policy
|
||||
from nova import test
|
||||
from nova.tests.api.openstack import fakes
|
||||
from nova.tests import fake_instance
|
||||
from nova.tests import fake_instance_actions
|
||||
from nova.tests import fake_server_actions
|
||||
|
||||
FAKE_UUID = fake_instance_actions.FAKE_UUID
|
||||
FAKE_REQUEST_ID = fake_instance_actions.FAKE_REQUEST_ID1
|
||||
FAKE_UUID = fake_server_actions.FAKE_UUID
|
||||
FAKE_REQUEST_ID = fake_server_actions.FAKE_REQUEST_ID1
|
||||
|
||||
|
||||
def format_action(action):
|
||||
@ -46,6 +46,9 @@ def format_action(action):
|
||||
action['start_time'] = str(action['start_time'].replace(tzinfo=None))
|
||||
for event in action.get('events', []):
|
||||
format_event(event)
|
||||
|
||||
if 'instance_uuid' in action:
|
||||
action['server_uuid'] = action.pop('instance_uuid')
|
||||
return action
|
||||
|
||||
|
||||
@ -67,14 +70,14 @@ def format_event(event):
|
||||
return event
|
||||
|
||||
|
||||
class InstanceActionsPolicyTest(test.NoDBTestCase):
|
||||
class ServerActionsPolicyTest(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(InstanceActionsPolicyTest, self).setUp()
|
||||
self.controller = instance_actions.InstanceActionsController()
|
||||
super(ServerActionsPolicyTest, self).setUp()
|
||||
self.controller = server_actions.ServerActionsController()
|
||||
|
||||
def test_list_actions_restricted_by_project(self):
|
||||
rules = policy.Rules({'compute:get': policy.parse_rule(''),
|
||||
'compute_extension:v3:os-instance-actions':
|
||||
'compute_extension:v3:os-server-actions':
|
||||
policy.parse_rule('project_id:%(project_id)s')})
|
||||
policy.set_rules(rules)
|
||||
|
||||
@ -85,13 +88,13 @@ class InstanceActionsPolicyTest(test.NoDBTestCase):
|
||||
context.project_id})
|
||||
|
||||
self.stubs.Set(db, 'instance_get_by_uuid', fake_instance_get_by_uuid)
|
||||
req = fakes.HTTPRequestV3.blank('/servers/12/os-instance-actions')
|
||||
req = fakes.HTTPRequestV3.blank('/servers/12/os-server-actions')
|
||||
self.assertRaises(exception.NotAuthorized, self.controller.index, req,
|
||||
str(uuid.uuid4()))
|
||||
|
||||
def test_get_action_restricted_by_project(self):
|
||||
rules = policy.Rules({'compute:get': policy.parse_rule(''),
|
||||
'compute_extension:v3:os-instance-actions':
|
||||
'compute_extension:v3:os-server-actions':
|
||||
policy.parse_rule('project_id:%(project_id)s')})
|
||||
policy.set_rules(rules)
|
||||
|
||||
@ -103,17 +106,17 @@ class InstanceActionsPolicyTest(test.NoDBTestCase):
|
||||
|
||||
self.stubs.Set(db, 'instance_get_by_uuid', fake_instance_get_by_uuid)
|
||||
req = fakes.HTTPRequestV3.blank(
|
||||
'/servers/12/os-instance-actions/1')
|
||||
'/servers/12/os-server-actions/1')
|
||||
self.assertRaises(exception.NotAuthorized, self.controller.show, req,
|
||||
str(uuid.uuid4()), '1')
|
||||
|
||||
|
||||
class InstanceActionsTest(test.NoDBTestCase):
|
||||
class ServerActionsTest(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(InstanceActionsTest, self).setUp()
|
||||
self.controller = instance_actions.InstanceActionsController()
|
||||
self.fake_actions = copy.deepcopy(fake_instance_actions.FAKE_ACTIONS)
|
||||
self.fake_events = copy.deepcopy(fake_instance_actions.FAKE_EVENTS)
|
||||
super(ServerActionsTest, self).setUp()
|
||||
self.controller = server_actions.ServerActionsController()
|
||||
self.fake_actions = copy.deepcopy(fake_server_actions.FAKE_ACTIONS)
|
||||
self.fake_events = copy.deepcopy(fake_server_actions.FAKE_EVENTS)
|
||||
|
||||
def fake_get(self, context, instance_uuid, expected_attrs=None,
|
||||
want_objects=False):
|
||||
@ -138,9 +141,9 @@ class InstanceActionsTest(test.NoDBTestCase):
|
||||
return actions
|
||||
|
||||
self.stubs.Set(db, 'actions_get', fake_get_actions)
|
||||
req = fakes.HTTPRequestV3.blank('/servers/12/os-instance-actions')
|
||||
req = fakes.HTTPRequestV3.blank('/servers/12/os-server-actions')
|
||||
res_dict = self.controller.index(req, FAKE_UUID)
|
||||
for res in res_dict['instance_actions']:
|
||||
for res in res_dict['server_actions']:
|
||||
fake_action = self.fake_actions[FAKE_UUID][res['request_id']]
|
||||
self.assertEqual(format_action(fake_action),
|
||||
format_action(res))
|
||||
@ -162,14 +165,14 @@ class InstanceActionsTest(test.NoDBTestCase):
|
||||
self.stubs.Set(db, 'action_get_by_request_id', fake_get_action)
|
||||
self.stubs.Set(db, 'action_events_get', fake_get_events)
|
||||
req = fakes.HTTPRequestV3.blank(
|
||||
'/servers/12/os-instance-actions/1',
|
||||
'/servers/12/os-server-actions/1',
|
||||
use_admin_context=True)
|
||||
res_dict = self.controller.show(req, FAKE_UUID, FAKE_REQUEST_ID)
|
||||
fake_action = self.fake_actions[FAKE_UUID][FAKE_REQUEST_ID]
|
||||
fake_events = self.fake_events[fake_action['id']]
|
||||
fake_action['events'] = fake_events
|
||||
self.assertEqual(format_action(fake_action),
|
||||
format_action(res_dict['instance_action']))
|
||||
format_action(res_dict['server_action']))
|
||||
|
||||
def test_get_action_with_events_not_allowed(self):
|
||||
def fake_get_action(context, uuid, request_id):
|
||||
@ -182,17 +185,17 @@ class InstanceActionsTest(test.NoDBTestCase):
|
||||
self.stubs.Set(db, 'action_events_get', fake_get_events)
|
||||
rules = policy.Rules({
|
||||
'compute:get': policy.parse_rule(''),
|
||||
'compute_extension:v3:os-instance-actions':
|
||||
'compute_extension:v3:os-server-actions':
|
||||
policy.parse_rule(''),
|
||||
'compute_extension:v3:os-instance-actions:events':
|
||||
'compute_extension:v3:os-server-actions:events':
|
||||
policy.parse_rule('is_admin:True')})
|
||||
policy.set_rules(rules)
|
||||
req = fakes.HTTPRequestV3.blank(
|
||||
'/servers/12/os-instance-actions/1')
|
||||
'/servers/12/os-server-actions/1')
|
||||
res_dict = self.controller.show(req, FAKE_UUID, FAKE_REQUEST_ID)
|
||||
fake_action = self.fake_actions[FAKE_UUID][FAKE_REQUEST_ID]
|
||||
self.assertEqual(format_action(fake_action),
|
||||
format_action(res_dict['instance_action']))
|
||||
format_action(res_dict['server_action']))
|
||||
|
||||
def test_action_not_found(self):
|
||||
def fake_no_action(context, uuid, action_id):
|
||||
@ -200,7 +203,7 @@ class InstanceActionsTest(test.NoDBTestCase):
|
||||
|
||||
self.stubs.Set(db, 'action_get_by_request_id', fake_no_action)
|
||||
req = fakes.HTTPRequestV3.blank(
|
||||
'/servers/12/os-instance-actions/1')
|
||||
'/servers/12/os-server-actions/1')
|
||||
self.assertRaises(exc.HTTPNotFound, self.controller.show, req,
|
||||
FAKE_UUID, FAKE_REQUEST_ID)
|
||||
|
||||
@ -209,7 +212,7 @@ class InstanceActionsTest(test.NoDBTestCase):
|
||||
want_objects=False):
|
||||
raise exception.InstanceNotFound(instance_id=instance_uuid)
|
||||
self.stubs.Set(compute_api.API, 'get', fake_get)
|
||||
req = fakes.HTTPRequestV3.blank('/servers/12/os-instance-actions')
|
||||
req = fakes.HTTPRequestV3.blank('/servers/12/os-server-actions')
|
||||
self.assertRaises(exc.HTTPNotFound, self.controller.index, req,
|
||||
FAKE_UUID)
|
||||
|
||||
@ -218,6 +221,6 @@ class InstanceActionsTest(test.NoDBTestCase):
|
||||
want_objects=False):
|
||||
raise exception.InstanceNotFound(instance_id=instance_uuid)
|
||||
self.stubs.Set(compute_api.API, 'get', fake_get)
|
||||
req = fakes.HTTPRequestV3.blank('/servers/12/os-instance-actions/1')
|
||||
req = fakes.HTTPRequestV3.blank('/servers/12/os-server-actions/1')
|
||||
self.assertRaises(exc.HTTPNotFound, self.controller.show, req,
|
||||
FAKE_UUID, FAKE_REQUEST_ID)
|
||||
|
@ -27,7 +27,7 @@ from nova import context
|
||||
from nova.openstack.common import timeutils
|
||||
from nova import test
|
||||
from nova.tests.cells import fakes
|
||||
from nova.tests import fake_instance_actions
|
||||
from nova.tests import fake_server_actions
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_topic', 'nova.compute.rpcapi')
|
||||
@ -490,9 +490,9 @@ class CellsManagerClassTestCase(test.NoDBTestCase):
|
||||
self.assertEqual(expected_response, response)
|
||||
|
||||
def test_actions_get(self):
|
||||
fake_uuid = fake_instance_actions.FAKE_UUID
|
||||
fake_req_id = fake_instance_actions.FAKE_REQUEST_ID1
|
||||
fake_act = fake_instance_actions.FAKE_ACTIONS[fake_uuid][fake_req_id]
|
||||
fake_uuid = fake_server_actions.FAKE_UUID
|
||||
fake_req_id = fake_server_actions.FAKE_REQUEST_ID1
|
||||
fake_act = fake_server_actions.FAKE_ACTIONS[fake_uuid][fake_req_id]
|
||||
fake_response = messaging.Response('fake-cell', [fake_act], False)
|
||||
expected_response = [fake_act]
|
||||
self.mox.StubOutWithMock(self.msg_runner, 'actions_get')
|
||||
@ -504,9 +504,9 @@ class CellsManagerClassTestCase(test.NoDBTestCase):
|
||||
self.assertEqual(expected_response, response)
|
||||
|
||||
def test_action_get_by_request_id(self):
|
||||
fake_uuid = fake_instance_actions.FAKE_UUID
|
||||
fake_req_id = fake_instance_actions.FAKE_REQUEST_ID1
|
||||
fake_act = fake_instance_actions.FAKE_ACTIONS[fake_uuid][fake_req_id]
|
||||
fake_uuid = fake_server_actions.FAKE_UUID
|
||||
fake_req_id = fake_server_actions.FAKE_REQUEST_ID1
|
||||
fake_act = fake_server_actions.FAKE_ACTIONS[fake_uuid][fake_req_id]
|
||||
fake_response = messaging.Response('fake-cell', fake_act, False)
|
||||
expected_response = fake_act
|
||||
self.mox.StubOutWithMock(self.msg_runner, 'action_get_by_request_id')
|
||||
@ -520,8 +520,8 @@ class CellsManagerClassTestCase(test.NoDBTestCase):
|
||||
self.assertEqual(expected_response, response)
|
||||
|
||||
def test_action_events_get(self):
|
||||
fake_action_id = fake_instance_actions.FAKE_ACTION_ID1
|
||||
fake_events = fake_instance_actions.FAKE_EVENTS[fake_action_id]
|
||||
fake_action_id = fake_server_actions.FAKE_ACTION_ID1
|
||||
fake_events = fake_server_actions.FAKE_EVENTS[fake_action_id]
|
||||
fake_response = messaging.Response('fake-cell', fake_events, False)
|
||||
expected_response = fake_events
|
||||
self.mox.StubOutWithMock(self.msg_runner, 'action_events_get')
|
||||
|
@ -38,7 +38,7 @@ from nova.openstack.common import uuidutils
|
||||
from nova import rpc
|
||||
from nova import test
|
||||
from nova.tests.cells import fakes
|
||||
from nova.tests import fake_instance_actions
|
||||
from nova.tests import fake_server_actions
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('name', 'nova.cells.opts', group='cells')
|
||||
@ -1002,9 +1002,9 @@ class CellsTargetedMethodsTestCase(test.TestCase):
|
||||
self.assertEqual('fake_result', result)
|
||||
|
||||
def test_actions_get(self):
|
||||
fake_uuid = fake_instance_actions.FAKE_UUID
|
||||
fake_req_id = fake_instance_actions.FAKE_REQUEST_ID1
|
||||
fake_act = fake_instance_actions.FAKE_ACTIONS[fake_uuid][fake_req_id]
|
||||
fake_uuid = fake_server_actions.FAKE_UUID
|
||||
fake_req_id = fake_server_actions.FAKE_REQUEST_ID1
|
||||
fake_act = fake_server_actions.FAKE_ACTIONS[fake_uuid][fake_req_id]
|
||||
|
||||
self.mox.StubOutWithMock(self.tgt_db_inst, 'actions_get')
|
||||
self.tgt_db_inst.actions_get(self.ctxt,
|
||||
@ -1018,9 +1018,9 @@ class CellsTargetedMethodsTestCase(test.TestCase):
|
||||
self.assertEqual([jsonutils.to_primitive(fake_act)], result)
|
||||
|
||||
def test_action_get_by_request_id(self):
|
||||
fake_uuid = fake_instance_actions.FAKE_UUID
|
||||
fake_req_id = fake_instance_actions.FAKE_REQUEST_ID1
|
||||
fake_act = fake_instance_actions.FAKE_ACTIONS[fake_uuid][fake_req_id]
|
||||
fake_uuid = fake_server_actions.FAKE_UUID
|
||||
fake_req_id = fake_server_actions.FAKE_REQUEST_ID1
|
||||
fake_act = fake_server_actions.FAKE_ACTIONS[fake_uuid][fake_req_id]
|
||||
|
||||
self.mox.StubOutWithMock(self.tgt_db_inst, 'action_get_by_request_id')
|
||||
self.tgt_db_inst.action_get_by_request_id(self.ctxt,
|
||||
@ -1033,8 +1033,8 @@ class CellsTargetedMethodsTestCase(test.TestCase):
|
||||
self.assertEqual(jsonutils.to_primitive(fake_act), result)
|
||||
|
||||
def test_action_events_get(self):
|
||||
fake_action_id = fake_instance_actions.FAKE_ACTION_ID1
|
||||
fake_events = fake_instance_actions.FAKE_EVENTS[fake_action_id]
|
||||
fake_action_id = fake_server_actions.FAKE_ACTION_ID1
|
||||
fake_events = fake_server_actions.FAKE_EVENTS[fake_action_id]
|
||||
|
||||
self.mox.StubOutWithMock(self.tgt_db_inst, 'action_events_get')
|
||||
self.tgt_db_inst.action_events_get(self.ctxt,
|
||||
|
@ -74,10 +74,10 @@ from nova.tests.compute import fake_resource_tracker
|
||||
from nova.tests.db import fakes as db_fakes
|
||||
from nova.tests import fake_block_device
|
||||
from nova.tests import fake_instance
|
||||
from nova.tests import fake_instance_actions
|
||||
from nova.tests import fake_network
|
||||
from nova.tests import fake_network_cache_model
|
||||
from nova.tests import fake_notifier
|
||||
from nova.tests import fake_server_actions
|
||||
from nova.tests.image import fake as fake_image
|
||||
from nova.tests import matchers
|
||||
from nova.tests.objects import test_flavor
|
||||
@ -234,7 +234,7 @@ class BaseTestCase(test.TestCase):
|
||||
fake_rpcapi = FakeSchedulerAPI()
|
||||
self.stubs.Set(self.compute, 'scheduler_rpcapi', fake_rpcapi)
|
||||
fake_network.set_stub_network_methods(self.stubs)
|
||||
fake_instance_actions.stub_out_action_events(self.stubs)
|
||||
fake_server_actions.stub_out_action_events(self.stubs)
|
||||
|
||||
def fake_get_nw_info(cls, ctxt, instance, *args, **kwargs):
|
||||
self.assertTrue(ctxt.is_admin)
|
||||
|
@ -39,9 +39,9 @@ from nova import rpc
|
||||
from nova import test
|
||||
from nova.tests import fake_block_device
|
||||
from nova.tests import fake_instance
|
||||
from nova.tests import fake_instance_actions
|
||||
from nova.tests import fake_network
|
||||
from nova.tests import fake_notifier
|
||||
from nova.tests import fake_server_actions
|
||||
import nova.tests.image.fake
|
||||
from nova.tests import matchers
|
||||
from nova.virt import driver
|
||||
@ -412,7 +412,7 @@ class UsageInfoTestCase(test.TestCase):
|
||||
self.stubs.Set(nova.tests.image.fake._FakeImageService,
|
||||
'show', fake_show)
|
||||
fake_network.set_stub_network_methods(self.stubs)
|
||||
fake_instance_actions.stub_out_action_events(self.stubs)
|
||||
fake_server_actions.stub_out_action_events(self.stubs)
|
||||
|
||||
def _create_instance(self, params={}):
|
||||
"""Create a test instance."""
|
||||
|
@ -49,8 +49,8 @@ from nova import test
|
||||
from nova.tests import cast_as_call
|
||||
from nova.tests.compute import test_compute
|
||||
from nova.tests import fake_instance
|
||||
from nova.tests import fake_instance_actions
|
||||
from nova.tests import fake_notifier
|
||||
from nova.tests import fake_server_actions
|
||||
from nova.tests.objects import test_migration
|
||||
from nova import utils
|
||||
|
||||
@ -1272,7 +1272,7 @@ class _BaseTaskTestCase(object):
|
||||
self.user_id = 'fake'
|
||||
self.project_id = 'fake'
|
||||
self.context = FakeContext(self.user_id, self.project_id)
|
||||
fake_instance_actions.stub_out_action_events(self.stubs)
|
||||
fake_server_actions.stub_out_action_events(self.stubs)
|
||||
|
||||
def fake_deserialize_context(serializer, ctxt_dict):
|
||||
self.assertEqual(self.context.user_id, ctxt_dict['user_id'])
|
||||
|
@ -210,9 +210,9 @@ policy_data = """
|
||||
"compute_extension:v3:os-hypervisors": "rule:admin_api",
|
||||
"compute_extension:image_size": "",
|
||||
"compute_extension:instance_actions": "",
|
||||
"compute_extension:v3:os-instance-actions": "",
|
||||
"compute_extension:v3:os-server-actions": "",
|
||||
"compute_extension:instance_actions:events": "is_admin:True",
|
||||
"compute_extension:v3:os-instance-actions:events": "is_admin:True",
|
||||
"compute_extension:v3:os-server-actions:events": "is_admin:True",
|
||||
"compute_extension:instance_usage_audit_log": "",
|
||||
"compute_extension:keypairs": "",
|
||||
"compute_extension:keypairs:index": "",
|
||||
|
@ -57,9 +57,9 @@ from nova.tests.api.openstack.compute.contrib import test_services
|
||||
from nova.tests.api.openstack import fakes
|
||||
from nova.tests import fake_block_device
|
||||
from nova.tests import fake_instance
|
||||
from nova.tests import fake_instance_actions
|
||||
from nova.tests import fake_network
|
||||
from nova.tests import fake_network_cache_model
|
||||
from nova.tests import fake_server_actions
|
||||
from nova.tests import fake_utils
|
||||
from nova.tests.image import fake
|
||||
from nova.tests.integrated import api_samples_test_base
|
||||
@ -3269,18 +3269,18 @@ class InstanceActionsSampleJsonTest(ApiSampleTestBaseV2):
|
||||
|
||||
def setUp(self):
|
||||
super(InstanceActionsSampleJsonTest, self).setUp()
|
||||
self.actions = fake_instance_actions.FAKE_ACTIONS
|
||||
self.events = fake_instance_actions.FAKE_EVENTS
|
||||
self.actions = fake_server_actions.FAKE_ACTIONS
|
||||
self.events = fake_server_actions.FAKE_EVENTS
|
||||
self.instance = test_utils.get_test_instance()
|
||||
|
||||
def fake_instance_action_get_by_request_id(context, uuid, request_id):
|
||||
def fake_server_action_get_by_request_id(context, uuid, request_id):
|
||||
return copy.deepcopy(self.actions[uuid][request_id])
|
||||
|
||||
def fake_instance_actions_get(context, uuid):
|
||||
def fake_server_actions_get(context, uuid):
|
||||
return [copy.deepcopy(value) for value in
|
||||
self.actions[uuid].itervalues()]
|
||||
|
||||
def fake_instance_action_events_get(context, action_id):
|
||||
def fake_server_action_events_get(context, action_id):
|
||||
return copy.deepcopy(self.events[action_id])
|
||||
|
||||
def fake_instance_get_by_uuid(context, instance_id):
|
||||
@ -3291,16 +3291,16 @@ class InstanceActionsSampleJsonTest(ApiSampleTestBaseV2):
|
||||
return {'uuid': instance_uuid}
|
||||
|
||||
self.stubs.Set(db, 'action_get_by_request_id',
|
||||
fake_instance_action_get_by_request_id)
|
||||
self.stubs.Set(db, 'actions_get', fake_instance_actions_get)
|
||||
fake_server_action_get_by_request_id)
|
||||
self.stubs.Set(db, 'actions_get', fake_server_actions_get)
|
||||
self.stubs.Set(db, 'action_events_get',
|
||||
fake_instance_action_events_get)
|
||||
fake_server_action_events_get)
|
||||
self.stubs.Set(db, 'instance_get_by_uuid', fake_instance_get_by_uuid)
|
||||
self.stubs.Set(compute_api.API, 'get', fake_get)
|
||||
|
||||
def test_instance_action_get(self):
|
||||
fake_uuid = fake_instance_actions.FAKE_UUID
|
||||
fake_request_id = fake_instance_actions.FAKE_REQUEST_ID1
|
||||
fake_uuid = fake_server_actions.FAKE_UUID
|
||||
fake_request_id = fake_server_actions.FAKE_REQUEST_ID1
|
||||
fake_action = self.actions[fake_uuid][fake_request_id]
|
||||
|
||||
response = self._do_get('servers/%s/os-instance-actions/%s' %
|
||||
@ -3316,7 +3316,7 @@ class InstanceActionsSampleJsonTest(ApiSampleTestBaseV2):
|
||||
self._verify_response('instance-action-get-resp', subs, response, 200)
|
||||
|
||||
def test_instance_actions_list(self):
|
||||
fake_uuid = fake_instance_actions.FAKE_UUID
|
||||
fake_uuid = fake_server_actions.FAKE_UUID
|
||||
response = self._do_get('servers/%s/os-instance-actions' % (fake_uuid))
|
||||
subs = self._get_regexes()
|
||||
subs['action'] = '(reboot)|(resize)'
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"instance_action": {
|
||||
"server_action": {
|
||||
"action": "%(action)s",
|
||||
"instance_uuid": "%(instance_uuid)s",
|
||||
"server_uuid": "%(instance_uuid)s",
|
||||
"request_id": "%(request_id)s",
|
||||
"user_id": "%(integer_id)s",
|
||||
"project_id": "%(integer_id)s",
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"instance_actions": [
|
||||
"server_actions": [
|
||||
{
|
||||
"action": "%(action)s",
|
||||
"instance_uuid": "%(uuid)s",
|
||||
"server_uuid": "%(uuid)s",
|
||||
"request_id": "%(request_id)s",
|
||||
"user_id": "%(integer_id)s",
|
||||
"project_id": "%(integer_id)s",
|
||||
@ -11,7 +11,7 @@
|
||||
},
|
||||
{
|
||||
"action": "%(action)s",
|
||||
"instance_uuid": "%(uuid)s",
|
||||
"server_uuid": "%(uuid)s",
|
||||
"request_id": "%(request_id)s",
|
||||
"user_id": "%(integer_id)s",
|
||||
"project_id": "%(integer_id)s",
|
@ -17,28 +17,28 @@ import copy
|
||||
|
||||
from nova.compute import api as compute_api
|
||||
from nova import db
|
||||
from nova.tests import fake_instance_actions
|
||||
from nova.tests import fake_server_actions
|
||||
from nova.tests.integrated.v3 import api_sample_base
|
||||
from nova.tests import utils as test_utils
|
||||
|
||||
|
||||
class InstanceActionsSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
|
||||
extension_name = 'os-instance-actions'
|
||||
class ServerActionsSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
|
||||
extension_name = 'os-server-actions'
|
||||
|
||||
def setUp(self):
|
||||
super(InstanceActionsSampleJsonTest, self).setUp()
|
||||
self.actions = fake_instance_actions.FAKE_ACTIONS
|
||||
self.events = fake_instance_actions.FAKE_EVENTS
|
||||
super(ServerActionsSampleJsonTest, self).setUp()
|
||||
self.actions = fake_server_actions.FAKE_ACTIONS
|
||||
self.events = fake_server_actions.FAKE_EVENTS
|
||||
self.instance = test_utils.get_test_instance()
|
||||
|
||||
def fake_instance_action_get_by_request_id(context, uuid, request_id):
|
||||
def fake_server_action_get_by_request_id(context, uuid, request_id):
|
||||
return copy.deepcopy(self.actions[uuid][request_id])
|
||||
|
||||
def fake_instance_actions_get(context, uuid):
|
||||
def fake_server_actions_get(context, uuid):
|
||||
return [copy.deepcopy(value) for value in
|
||||
self.actions[uuid].itervalues()]
|
||||
|
||||
def fake_instance_action_events_get(context, action_id):
|
||||
def fake_server_action_events_get(context, action_id):
|
||||
return copy.deepcopy(self.events[action_id])
|
||||
|
||||
def fake_instance_get_by_uuid(context, instance_id):
|
||||
@ -48,19 +48,19 @@ class InstanceActionsSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
|
||||
return {'uuid': instance_uuid}
|
||||
|
||||
self.stubs.Set(db, 'action_get_by_request_id',
|
||||
fake_instance_action_get_by_request_id)
|
||||
self.stubs.Set(db, 'actions_get', fake_instance_actions_get)
|
||||
fake_server_action_get_by_request_id)
|
||||
self.stubs.Set(db, 'actions_get', fake_server_actions_get)
|
||||
self.stubs.Set(db, 'action_events_get',
|
||||
fake_instance_action_events_get)
|
||||
fake_server_action_events_get)
|
||||
self.stubs.Set(db, 'instance_get_by_uuid', fake_instance_get_by_uuid)
|
||||
self.stubs.Set(compute_api.API, 'get', fake_get)
|
||||
|
||||
def test_instance_action_get(self):
|
||||
fake_uuid = fake_instance_actions.FAKE_UUID
|
||||
fake_request_id = fake_instance_actions.FAKE_REQUEST_ID1
|
||||
def test_server_action_get(self):
|
||||
fake_uuid = fake_server_actions.FAKE_UUID
|
||||
fake_request_id = fake_server_actions.FAKE_REQUEST_ID1
|
||||
fake_action = self.actions[fake_uuid][fake_request_id]
|
||||
|
||||
response = self._do_get('servers/%s/os-instance-actions/%s' %
|
||||
response = self._do_get('servers/%s/os-server-actions/%s' %
|
||||
(fake_uuid, fake_request_id))
|
||||
subs = self._get_regexes()
|
||||
subs['action'] = '(reboot)|(resize)'
|
||||
@ -70,15 +70,15 @@ class InstanceActionsSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
|
||||
subs['start_time'] = fake_action['start_time']
|
||||
subs['result'] = '(Success)|(Error)'
|
||||
subs['event'] = '(schedule)|(compute_create)'
|
||||
self._verify_response('instance-action-get-resp', subs, response, 200)
|
||||
self._verify_response('server-action-get-resp', subs, response, 200)
|
||||
|
||||
def test_instance_actions_list(self):
|
||||
fake_uuid = fake_instance_actions.FAKE_UUID
|
||||
response = self._do_get('servers/%s/os-instance-actions' % (fake_uuid))
|
||||
def test_server_actions_list(self):
|
||||
fake_uuid = fake_server_actions.FAKE_UUID
|
||||
response = self._do_get('servers/%s/os-server-actions' % (fake_uuid))
|
||||
subs = self._get_regexes()
|
||||
subs['action'] = '(reboot)|(resize)'
|
||||
subs['integer_id'] = '[0-9]+'
|
||||
subs['request_id'] = ('req-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}'
|
||||
'-[0-9a-f]{4}-[0-9a-f]{12}')
|
||||
self._verify_response('instance-actions-list-resp', subs,
|
||||
self._verify_response('server-actions-list-resp', subs,
|
||||
response, 200)
|
@ -40,7 +40,7 @@ from nova.scheduler import manager
|
||||
from nova import servicegroup
|
||||
from nova import test
|
||||
from nova.tests import fake_instance
|
||||
from nova.tests import fake_instance_actions
|
||||
from nova.tests import fake_server_actions
|
||||
from nova.tests.image import fake as fake_image
|
||||
from nova.tests import matchers
|
||||
from nova.tests.scheduler import fakes
|
||||
@ -65,7 +65,7 @@ class SchedulerManagerTestCase(test.NoDBTestCase):
|
||||
self.topic = 'fake_topic'
|
||||
self.fake_args = (1, 2, 3)
|
||||
self.fake_kwargs = {'cat': 'meow', 'dog': 'woof'}
|
||||
fake_instance_actions.stub_out_action_events(self.stubs)
|
||||
fake_server_actions.stub_out_action_events(self.stubs)
|
||||
|
||||
def test_1_correct_init(self):
|
||||
# Correct scheduler driver
|
||||
|
@ -84,7 +84,7 @@ nova.api.v3.extensions =
|
||||
hide_server_addresses = nova.api.openstack.compute.plugins.v3.hide_server_addresses:HideServerAddresses
|
||||
hosts = nova.api.openstack.compute.plugins.v3.hosts:Hosts
|
||||
hypervisors = nova.api.openstack.compute.plugins.v3.hypervisors:Hypervisors
|
||||
instance_actions = nova.api.openstack.compute.plugins.v3.instance_actions:InstanceActions
|
||||
server_actions = nova.api.openstack.compute.plugins.v3.server_actions:ServerActions
|
||||
ips = nova.api.openstack.compute.plugins.v3.ips:IPs
|
||||
keypairs = nova.api.openstack.compute.plugins.v3.keypairs:Keypairs
|
||||
lock_server = nova.api.openstack.compute.plugins.v3.lock_server:LockServer
|
||||
|
Loading…
x
Reference in New Issue
Block a user