compute: Fix bug with start/stop server
A mistake was introduced during the conversion from novaclient to SDK in change I5ebfa6b2468d5f20b99ea0eab1aea9377be09b8c. Fix the issue and add functional tests to prevent it being reintroduced. Change-Id: I6b314eab31bcf452e88b8b6a239ac2e296497cb9 Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Story: 2010750 Task: 48004
This commit is contained in:
parent
3c9afe69bb
commit
0a63f8603e
@ -4721,10 +4721,10 @@ class StartServer(command.Command):
|
|||||||
for server in parsed_args.server:
|
for server in parsed_args.server:
|
||||||
try:
|
try:
|
||||||
server_id = compute_client.find_server(
|
server_id = compute_client.find_server(
|
||||||
name=server,
|
server,
|
||||||
|
ignore_missing=False,
|
||||||
details=False,
|
details=False,
|
||||||
all_projects=parsed_args.all_projects,
|
all_projects=parsed_args.all_projects,
|
||||||
ignore_missing=False,
|
|
||||||
).id
|
).id
|
||||||
except sdk_exceptions.HttpException as exc:
|
except sdk_exceptions.HttpException as exc:
|
||||||
if exc.status_code == 403:
|
if exc.status_code == 403:
|
||||||
@ -4761,10 +4761,10 @@ class StopServer(command.Command):
|
|||||||
for server in parsed_args.server:
|
for server in parsed_args.server:
|
||||||
try:
|
try:
|
||||||
server_id = compute_client.find_server(
|
server_id = compute_client.find_server(
|
||||||
name=server,
|
server,
|
||||||
|
ignore_missing=False,
|
||||||
details=False,
|
details=False,
|
||||||
all_projects=parsed_args.all_projects,
|
all_projects=parsed_args.all_projects,
|
||||||
ignore_missing=False,
|
|
||||||
).id
|
).id
|
||||||
except sdk_exceptions.HttpException as exc:
|
except sdk_exceptions.HttpException as exc:
|
||||||
if exc.status_code == 403:
|
if exc.status_code == 403:
|
||||||
|
@ -27,11 +27,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(ServerTests, cls).setUpClass()
|
super().setUpClass()
|
||||||
cls.haz_network = cls.is_service_enabled('network')
|
cls.haz_network = cls.is_service_enabled('network')
|
||||||
|
|
||||||
def test_server_list(self):
|
def test_server_list(self):
|
||||||
"""Test server list, set"""
|
"""Test server list"""
|
||||||
cmd_output = self.server_create()
|
cmd_output = self.server_create()
|
||||||
name1 = cmd_output['name']
|
name1 = cmd_output['name']
|
||||||
cmd_output = self.server_create()
|
cmd_output = self.server_create()
|
||||||
@ -1447,6 +1447,46 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
raw_output = self.openstack('server volume list ' + server_name)
|
raw_output = self.openstack('server volume list ' + server_name)
|
||||||
self.assertEqual('\n', raw_output)
|
self.assertEqual('\n', raw_output)
|
||||||
|
|
||||||
|
def test_server_stop_start(self):
|
||||||
|
"""Test server stop, start"""
|
||||||
|
server_name = uuid.uuid4().hex
|
||||||
|
cmd_output = self.openstack(
|
||||||
|
'server create '
|
||||||
|
+ '--network private '
|
||||||
|
+ '--flavor '
|
||||||
|
+ self.flavor_name
|
||||||
|
+ ' '
|
||||||
|
+ '--image '
|
||||||
|
+ self.image_name
|
||||||
|
+ ' '
|
||||||
|
+ '--wait '
|
||||||
|
+ server_name,
|
||||||
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertIsNotNone(cmd_output['id'])
|
||||||
|
self.assertEqual(server_name, cmd_output['name'])
|
||||||
|
self.addCleanup(self.openstack, 'server delete --wait ' + server_name)
|
||||||
|
server_id = cmd_output['id']
|
||||||
|
|
||||||
|
cmd_output = self.openstack(
|
||||||
|
'server stop ' + server_name,
|
||||||
|
)
|
||||||
|
self.assertEqual("", cmd_output)
|
||||||
|
|
||||||
|
# This is our test that the request succeeded. If it doesn't transition
|
||||||
|
# to SHUTOFF then it didn't work.
|
||||||
|
self.wait_for_status(server_id, "SHUTOFF")
|
||||||
|
|
||||||
|
cmd_output = self.openstack(
|
||||||
|
'server start ' + server_name,
|
||||||
|
)
|
||||||
|
self.assertEqual("", cmd_output)
|
||||||
|
|
||||||
|
# As above, this is our test that the request succeeded. If it doesn't
|
||||||
|
# transition to ACTIVE then it didn't work.
|
||||||
|
self.wait_for_status(server_id, "ACTIVE")
|
||||||
|
|
||||||
def test_server_migration_list(self):
|
def test_server_migration_list(self):
|
||||||
# Verify that the command does not raise an exception when we list
|
# Verify that the command does not raise an exception when we list
|
||||||
# migrations, including when we specify a query.
|
# migrations, including when we specify a query.
|
||||||
|
@ -8577,10 +8577,10 @@ class TestServerStart(TestServer):
|
|||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.sdk_client.find_server.assert_called_once_with(
|
self.sdk_client.find_server.assert_called_once_with(
|
||||||
name=servers[0].id,
|
servers[0].id,
|
||||||
|
ignore_missing=False,
|
||||||
details=False,
|
details=False,
|
||||||
all_projects=True,
|
all_projects=True,
|
||||||
ignore_missing=False,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -8612,10 +8612,10 @@ class TestServerStop(TestServer):
|
|||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.sdk_client.find_server.assert_called_once_with(
|
self.sdk_client.find_server.assert_called_once_with(
|
||||||
name=servers[0].id,
|
servers[0].id,
|
||||||
|
ignore_missing=False,
|
||||||
details=False,
|
details=False,
|
||||||
all_projects=True,
|
all_projects=True,
|
||||||
ignore_missing=False,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user