Merge "tests: Convert compute tests to use 'parse_output'"
This commit is contained in:
commit
f9d2d69ed2
openstackclient/tests/functional/compute/v2
@ -11,7 +11,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import json
|
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@ -38,9 +37,7 @@ class ComputeTestCase(base.TestCase):
|
|||||||
def get_flavor(cls):
|
def get_flavor(cls):
|
||||||
# NOTE(rtheis): Get cirros256 or m1.tiny flavors since functional
|
# NOTE(rtheis): Get cirros256 or m1.tiny flavors since functional
|
||||||
# tests may create other flavors.
|
# tests may create other flavors.
|
||||||
flavors = json.loads(cls.openstack(
|
flavors = cls.openstack("flavor list", parse_output=True)
|
||||||
"flavor list -f json "
|
|
||||||
))
|
|
||||||
server_flavor = None
|
server_flavor = None
|
||||||
for flavor in flavors:
|
for flavor in flavors:
|
||||||
if flavor['Name'] in ['m1.tiny', 'cirros256']:
|
if flavor['Name'] in ['m1.tiny', 'cirros256']:
|
||||||
@ -53,9 +50,7 @@ class ComputeTestCase(base.TestCase):
|
|||||||
# NOTE(rtheis): Get first Cirros image since functional tests may
|
# NOTE(rtheis): Get first Cirros image since functional tests may
|
||||||
# create other images. Image may be named '-uec' or
|
# create other images. Image may be named '-uec' or
|
||||||
# '-disk'.
|
# '-disk'.
|
||||||
images = json.loads(cls.openstack(
|
images = cls.openstack("image list", parse_output=True)
|
||||||
"image list -f json "
|
|
||||||
))
|
|
||||||
server_image = None
|
server_image = None
|
||||||
for image in images:
|
for image in images:
|
||||||
if (image['Name'].startswith('cirros-') and
|
if (image['Name'].startswith('cirros-') and
|
||||||
@ -70,9 +65,10 @@ class ComputeTestCase(base.TestCase):
|
|||||||
try:
|
try:
|
||||||
# NOTE(rtheis): Get private network since functional tests may
|
# NOTE(rtheis): Get private network since functional tests may
|
||||||
# create other networks.
|
# create other networks.
|
||||||
cmd_output = json.loads(cls.openstack(
|
cmd_output = cls.openstack(
|
||||||
'network show private -f json'
|
'network show private',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
except exceptions.CommandFailed:
|
except exceptions.CommandFailed:
|
||||||
return ''
|
return ''
|
||||||
return '--nic net-id=' + cmd_output['id']
|
return '--nic net-id=' + cmd_output['id']
|
||||||
@ -86,14 +82,15 @@ class ComputeTestCase(base.TestCase):
|
|||||||
if not self.network_arg:
|
if not self.network_arg:
|
||||||
self.network_arg = self.get_network()
|
self.network_arg = self.get_network()
|
||||||
name = name or uuid.uuid4().hex
|
name = name or uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server create -f json ' +
|
'server create ' +
|
||||||
'--flavor ' + self.flavor_name + ' ' +
|
'--flavor ' + self.flavor_name + ' ' +
|
||||||
'--image ' + self.image_name + ' ' +
|
'--image ' + self.image_name + ' ' +
|
||||||
self.network_arg + ' ' +
|
self.network_arg + ' ' +
|
||||||
'--wait ' +
|
'--wait ' +
|
||||||
name
|
name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(cmd_output["id"])
|
self.assertIsNotNone(cmd_output["id"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name,
|
name,
|
||||||
@ -120,10 +117,11 @@ class ComputeTestCase(base.TestCase):
|
|||||||
failures = ['ERROR']
|
failures = ['ERROR']
|
||||||
total_sleep = 0
|
total_sleep = 0
|
||||||
while total_sleep < wait:
|
while total_sleep < wait:
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' +
|
'server show ' +
|
||||||
name
|
name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
status = cmd_output['status']
|
status = cmd_output['status']
|
||||||
if status == expected_status:
|
if status == expected_status:
|
||||||
print('Server {} now has status {}'.format(
|
print('Server {} now has status {}'.format(
|
||||||
@ -135,10 +133,11 @@ class ComputeTestCase(base.TestCase):
|
|||||||
time.sleep(interval)
|
time.sleep(interval)
|
||||||
total_sleep += interval
|
total_sleep += interval
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' +
|
'server show ' +
|
||||||
name
|
name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
status = cmd_output['status']
|
status = cmd_output['status']
|
||||||
self.assertEqual(status, expected_status)
|
self.assertEqual(status, expected_status)
|
||||||
# give it a little bit more time
|
# give it a little bit more time
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional import base
|
from openstackclient.tests.functional import base
|
||||||
@ -27,12 +26,13 @@ class AggregateTests(base.TestCase):
|
|||||||
'aggregate delete ' + name1,
|
'aggregate delete ' + name1,
|
||||||
fail_ok=True,
|
fail_ok=True,
|
||||||
)
|
)
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'aggregate create -f json ' +
|
'aggregate create ' +
|
||||||
'--zone nova ' +
|
'--zone nova ' +
|
||||||
'--property a=b ' +
|
'--property a=b ' +
|
||||||
name1
|
name1,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name1,
|
name1,
|
||||||
cmd_output['name']
|
cmd_output['name']
|
||||||
@ -45,8 +45,10 @@ class AggregateTests(base.TestCase):
|
|||||||
'a',
|
'a',
|
||||||
cmd_output['properties']
|
cmd_output['properties']
|
||||||
)
|
)
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'aggregate show -f json ' + name1))
|
'aggregate show ' + name1,
|
||||||
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(name1, cmd_output['name'])
|
self.assertEqual(name1, cmd_output['name'])
|
||||||
|
|
||||||
name2 = uuid.uuid4().hex
|
name2 = uuid.uuid4().hex
|
||||||
@ -55,11 +57,12 @@ class AggregateTests(base.TestCase):
|
|||||||
'aggregate delete ' + name2,
|
'aggregate delete ' + name2,
|
||||||
fail_ok=True,
|
fail_ok=True,
|
||||||
)
|
)
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'aggregate create -f json ' +
|
'aggregate create ' +
|
||||||
'--zone external ' +
|
'--zone external ' +
|
||||||
name2
|
name2,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name2,
|
name2,
|
||||||
cmd_output['name']
|
cmd_output['name']
|
||||||
@ -68,8 +71,10 @@ class AggregateTests(base.TestCase):
|
|||||||
'external',
|
'external',
|
||||||
cmd_output['availability_zone']
|
cmd_output['availability_zone']
|
||||||
)
|
)
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'aggregate show -f json ' + name2))
|
'aggregate show ' + name2,
|
||||||
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(name2, cmd_output['name'])
|
self.assertEqual(name2, cmd_output['name'])
|
||||||
|
|
||||||
# Test aggregate set
|
# Test aggregate set
|
||||||
@ -89,10 +94,11 @@ class AggregateTests(base.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'aggregate show -f json ' +
|
'aggregate show ' +
|
||||||
name3
|
name3,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name3,
|
name3,
|
||||||
cmd_output['name']
|
cmd_output['name']
|
||||||
@ -111,9 +117,10 @@ class AggregateTests(base.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Test aggregate list
|
# Test aggregate list
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'aggregate list -f json'
|
'aggregate list',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
names = [x['Name'] for x in cmd_output]
|
names = [x['Name'] for x in cmd_output]
|
||||||
self.assertIn(name3, names)
|
self.assertIn(name3, names)
|
||||||
self.assertIn(name2, names)
|
self.assertIn(name2, names)
|
||||||
@ -122,9 +129,10 @@ class AggregateTests(base.TestCase):
|
|||||||
self.assertIn('internal', zones)
|
self.assertIn('internal', zones)
|
||||||
|
|
||||||
# Test aggregate list --long
|
# Test aggregate list --long
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'aggregate list --long -f json'
|
'aggregate list --long',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
names = [x['Name'] for x in cmd_output]
|
names = [x['Name'] for x in cmd_output]
|
||||||
self.assertIn(name3, names)
|
self.assertIn(name3, names)
|
||||||
self.assertIn(name2, names)
|
self.assertIn(name2, names)
|
||||||
@ -143,10 +151,11 @@ class AggregateTests(base.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'aggregate show -f json ' +
|
'aggregate show ' +
|
||||||
name3
|
name3,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertNotIn(
|
self.assertNotIn(
|
||||||
"c='d'",
|
"c='d'",
|
||||||
cmd_output['properties']
|
cmd_output['properties']
|
||||||
@ -163,9 +172,10 @@ class AggregateTests(base.TestCase):
|
|||||||
def test_aggregate_add_and_remove_host(self):
|
def test_aggregate_add_and_remove_host(self):
|
||||||
"""Test aggregate add and remove host"""
|
"""Test aggregate add and remove host"""
|
||||||
# Get a host
|
# Get a host
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'host list -f json'
|
'host list',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
host_name = cmd_output[0]['Host Name']
|
host_name = cmd_output[0]['Host Name']
|
||||||
|
|
||||||
# NOTE(dtroyer): Cells v1 is not operable with aggregates. Hostnames
|
# NOTE(dtroyer): Cells v1 is not operable with aggregates. Hostnames
|
||||||
@ -181,22 +191,24 @@ class AggregateTests(base.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Test add host
|
# Test add host
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'aggregate add host -f json ' +
|
'aggregate add host ' +
|
||||||
name + ' ' +
|
name + ' ' +
|
||||||
host_name
|
host_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
host_name,
|
host_name,
|
||||||
cmd_output['hosts']
|
cmd_output['hosts']
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test remove host
|
# Test remove host
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'aggregate remove host -f json ' +
|
'aggregate remove host ' +
|
||||||
name + ' ' +
|
name + ' ' +
|
||||||
host_name
|
host_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertNotIn(
|
self.assertNotIn(
|
||||||
host_name,
|
host_name,
|
||||||
cmd_output['hosts']
|
cmd_output['hosts']
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional import base
|
from openstackclient.tests.functional import base
|
||||||
@ -25,9 +24,10 @@ class FlavorTests(base.TestCase):
|
|||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(FlavorTests, cls).setUpClass()
|
super(FlavorTests, cls).setUpClass()
|
||||||
# Make a project
|
# Make a project
|
||||||
cmd_output = json.loads(cls.openstack(
|
cmd_output = cls.openstack(
|
||||||
"project create -f json --enable " + cls.PROJECT_NAME
|
"project create --enable " + cls.PROJECT_NAME,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
cls.project_id = cmd_output["id"]
|
cls.project_id = cmd_output["id"]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -41,22 +41,24 @@ class FlavorTests(base.TestCase):
|
|||||||
def test_flavor_delete(self):
|
def test_flavor_delete(self):
|
||||||
"""Test create w/project, delete multiple"""
|
"""Test create w/project, delete multiple"""
|
||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
"flavor create -f json " +
|
"flavor create " +
|
||||||
"--project " + self.PROJECT_NAME + " " +
|
"--project " + self.PROJECT_NAME + " " +
|
||||||
"--private " +
|
"--private " +
|
||||||
name1
|
name1,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(cmd_output["id"])
|
self.assertIsNotNone(cmd_output["id"])
|
||||||
|
|
||||||
name2 = uuid.uuid4().hex
|
name2 = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
"flavor create -f json " +
|
"flavor create " +
|
||||||
"--id qaz " +
|
"--id qaz " +
|
||||||
"--project " + self.PROJECT_NAME + " " +
|
"--project " + self.PROJECT_NAME + " " +
|
||||||
"--private " +
|
"--private " +
|
||||||
name2
|
name2,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(cmd_output["id"])
|
self.assertIsNotNone(cmd_output["id"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"qaz",
|
"qaz",
|
||||||
@ -71,12 +73,13 @@ class FlavorTests(base.TestCase):
|
|||||||
def test_flavor_list(self):
|
def test_flavor_list(self):
|
||||||
"""Test create defaults, list filters, delete"""
|
"""Test create defaults, list filters, delete"""
|
||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
"flavor create -f json " +
|
"flavor create " +
|
||||||
"--property a=b " +
|
"--property a=b " +
|
||||||
"--property c=d " +
|
"--property c=d " +
|
||||||
name1
|
name1,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.addCleanup(self.openstack, "flavor delete " + name1)
|
self.addCleanup(self.openstack, "flavor delete " + name1)
|
||||||
self.assertIsNotNone(cmd_output["id"])
|
self.assertIsNotNone(cmd_output["id"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -85,15 +88,16 @@ class FlavorTests(base.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
name2 = uuid.uuid4().hex
|
name2 = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
"flavor create -f json " +
|
"flavor create " +
|
||||||
"--id qaz " +
|
"--id qaz " +
|
||||||
"--ram 123 " +
|
"--ram 123 " +
|
||||||
"--private " +
|
"--private " +
|
||||||
"--property a=b2 " +
|
"--property a=b2 " +
|
||||||
"--property b=d2 " +
|
"--property b=d2 " +
|
||||||
name2
|
name2,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.addCleanup(self.openstack, "flavor delete " + name2)
|
self.addCleanup(self.openstack, "flavor delete " + name2)
|
||||||
self.assertIsNotNone(cmd_output["id"])
|
self.assertIsNotNone(cmd_output["id"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -121,18 +125,20 @@ class FlavorTests(base.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Test list
|
# Test list
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
"flavor list -f json"
|
"flavor list",
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
col_name = [x["Name"] for x in cmd_output]
|
col_name = [x["Name"] for x in cmd_output]
|
||||||
self.assertIn(name1, col_name)
|
self.assertIn(name1, col_name)
|
||||||
self.assertNotIn(name2, col_name)
|
self.assertNotIn(name2, col_name)
|
||||||
|
|
||||||
# Test list --long
|
# Test list --long
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
"flavor list -f json " +
|
"flavor list " +
|
||||||
"--long"
|
"--long",
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
# We have list of complex json objects
|
# We have list of complex json objects
|
||||||
# Iterate through the list setting flags
|
# Iterate through the list setting flags
|
||||||
found_expected = False
|
found_expected = False
|
||||||
@ -147,28 +153,31 @@ class FlavorTests(base.TestCase):
|
|||||||
self.assertTrue(found_expected)
|
self.assertTrue(found_expected)
|
||||||
|
|
||||||
# Test list --public
|
# Test list --public
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
"flavor list -f json " +
|
"flavor list " +
|
||||||
"--public"
|
"--public",
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
col_name = [x["Name"] for x in cmd_output]
|
col_name = [x["Name"] for x in cmd_output]
|
||||||
self.assertIn(name1, col_name)
|
self.assertIn(name1, col_name)
|
||||||
self.assertNotIn(name2, col_name)
|
self.assertNotIn(name2, col_name)
|
||||||
|
|
||||||
# Test list --private
|
# Test list --private
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
"flavor list -f json " +
|
"flavor list " +
|
||||||
"--private"
|
"--private",
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
col_name = [x["Name"] for x in cmd_output]
|
col_name = [x["Name"] for x in cmd_output]
|
||||||
self.assertNotIn(name1, col_name)
|
self.assertNotIn(name1, col_name)
|
||||||
self.assertIn(name2, col_name)
|
self.assertIn(name2, col_name)
|
||||||
|
|
||||||
# Test list --all
|
# Test list --all
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
"flavor list -f json " +
|
"flavor list " +
|
||||||
"--all"
|
"--all",
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
col_name = [x["Name"] for x in cmd_output]
|
col_name = [x["Name"] for x in cmd_output]
|
||||||
self.assertIn(name1, col_name)
|
self.assertIn(name1, col_name)
|
||||||
self.assertIn(name2, col_name)
|
self.assertIn(name2, col_name)
|
||||||
@ -176,16 +185,17 @@ class FlavorTests(base.TestCase):
|
|||||||
def test_flavor_properties(self):
|
def test_flavor_properties(self):
|
||||||
"""Test create defaults, list filters, delete"""
|
"""Test create defaults, list filters, delete"""
|
||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
"flavor create -f json " +
|
"flavor create " +
|
||||||
"--id qaz " +
|
"--id qaz " +
|
||||||
"--ram 123 " +
|
"--ram 123 " +
|
||||||
"--disk 20 " +
|
"--disk 20 " +
|
||||||
"--private " +
|
"--private " +
|
||||||
"--property a=first " +
|
"--property a=first " +
|
||||||
"--property b=second " +
|
"--property b=second " +
|
||||||
name1
|
name1,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.addCleanup(self.openstack, "flavor delete " + name1)
|
self.addCleanup(self.openstack, "flavor delete " + name1)
|
||||||
self.assertIsNotNone(cmd_output["id"])
|
self.assertIsNotNone(cmd_output["id"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -220,10 +230,11 @@ class FlavorTests(base.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertEqual('', raw_output)
|
self.assertEqual('', raw_output)
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
"flavor show -f json " +
|
"flavor show " +
|
||||||
name1
|
name1,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"qaz",
|
"qaz",
|
||||||
cmd_output["id"],
|
cmd_output["id"],
|
||||||
@ -245,9 +256,10 @@ class FlavorTests(base.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertEqual('', raw_output)
|
self.assertEqual('', raw_output)
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
"flavor show -f json " +
|
"flavor show " +
|
||||||
name1
|
name1,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
self.assertNotIn('b', cmd_output['properties'])
|
self.assertNotIn('b', cmd_output['properties'])
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from tempest.lib.common.utils import data_utils
|
from tempest.lib.common.utils import data_utils
|
||||||
@ -109,9 +108,10 @@ class KeypairTests(KeypairBase):
|
|||||||
2) Delete keypair
|
2) Delete keypair
|
||||||
"""
|
"""
|
||||||
with tempfile.NamedTemporaryFile(mode='w+') as f:
|
with tempfile.NamedTemporaryFile(mode='w+') as f:
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'keypair create -f json --private-key %s tmpkey' % f.name,
|
'keypair create --private-key %s tmpkey' % f.name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.addCleanup(self.openstack, 'keypair delete tmpkey')
|
self.addCleanup(self.openstack, 'keypair delete tmpkey')
|
||||||
self.assertEqual('tmpkey', cmd_output.get('name'))
|
self.assertEqual('tmpkey', cmd_output.get('name'))
|
||||||
self.assertIsNotNone(cmd_output.get('user_id'))
|
self.assertIsNotNone(cmd_output.get('user_id'))
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@ -39,9 +38,10 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
self.wait_for_status(name1, "ACTIVE")
|
self.wait_for_status(name1, "ACTIVE")
|
||||||
self.wait_for_status(name2, "ACTIVE")
|
self.wait_for_status(name2, "ACTIVE")
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server list -f json'
|
'server list',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
col_name = [x["Name"] for x in cmd_output]
|
col_name = [x["Name"] for x in cmd_output]
|
||||||
self.assertIn(name1, col_name)
|
self.assertIn(name1, col_name)
|
||||||
self.assertIn(name2, col_name)
|
self.assertIn(name2, col_name)
|
||||||
@ -50,17 +50,19 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
raw_output = self.openstack('server pause ' + name2)
|
raw_output = self.openstack('server pause ' + name2)
|
||||||
self.assertEqual("", raw_output)
|
self.assertEqual("", raw_output)
|
||||||
self.wait_for_status(name2, "PAUSED")
|
self.wait_for_status(name2, "PAUSED")
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server list -f json ' +
|
'server list ' +
|
||||||
'--status ACTIVE'
|
'--status ACTIVE',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
col_name = [x["Name"] for x in cmd_output]
|
col_name = [x["Name"] for x in cmd_output]
|
||||||
self.assertIn(name1, col_name)
|
self.assertIn(name1, col_name)
|
||||||
self.assertNotIn(name2, col_name)
|
self.assertNotIn(name2, col_name)
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server list -f json ' +
|
'server list ' +
|
||||||
'--status PAUSED'
|
'--status PAUSED',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
col_name = [x["Name"] for x in cmd_output]
|
col_name = [x["Name"] for x in cmd_output]
|
||||||
self.assertNotIn(name1, col_name)
|
self.assertNotIn(name1, col_name)
|
||||||
self.assertIn(name2, col_name)
|
self.assertIn(name2, col_name)
|
||||||
@ -76,16 +78,18 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
self.wait_for_status(name2, "ACTIVE")
|
self.wait_for_status(name2, "ACTIVE")
|
||||||
|
|
||||||
# Test list --marker with ID
|
# Test list --marker with ID
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server list -f json --marker ' + id2
|
'server list --marker ' + id2,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
col_name = [x["Name"] for x in cmd_output]
|
col_name = [x["Name"] for x in cmd_output]
|
||||||
self.assertIn(name1, col_name)
|
self.assertIn(name1, col_name)
|
||||||
|
|
||||||
# Test list --marker with Name
|
# Test list --marker with Name
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server list -f json --marker ' + name2
|
'server list --marker ' + name2,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
col_name = [x["Name"] for x in cmd_output]
|
col_name = [x["Name"] for x in cmd_output]
|
||||||
self.assertIn(name1, col_name)
|
self.assertIn(name1, col_name)
|
||||||
|
|
||||||
@ -93,17 +97,19 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
self.openstack('server delete --wait ' + name2)
|
self.openstack('server delete --wait ' + name2)
|
||||||
|
|
||||||
# Test list --deleted --marker with ID
|
# Test list --deleted --marker with ID
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server list -f json --deleted --marker ' + id2
|
'server list --deleted --marker ' + id2,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
col_name = [x["Name"] for x in cmd_output]
|
col_name = [x["Name"] for x in cmd_output]
|
||||||
self.assertIn(name1, col_name)
|
self.assertIn(name1, col_name)
|
||||||
|
|
||||||
# Test list --deleted --marker with Name
|
# Test list --deleted --marker with Name
|
||||||
try:
|
try:
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server list -f json --deleted --marker ' + name2
|
'server list --deleted --marker ' + name2,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
except exceptions.CommandFailed as e:
|
except exceptions.CommandFailed as e:
|
||||||
self.assertIn('marker [%s] not found' % (name2),
|
self.assertIn('marker [%s] not found' % (name2),
|
||||||
e.stderr.decode('utf-8'))
|
e.stderr.decode('utf-8'))
|
||||||
@ -124,11 +130,12 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
cmd_output = self.server_create()
|
cmd_output = self.server_create()
|
||||||
server_name3 = cmd_output['name']
|
server_name3 = cmd_output['name']
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'--os-compute-api-version 2.66 ' +
|
'--os-compute-api-version 2.66 ' +
|
||||||
'server list -f json '
|
'server list '
|
||||||
'--changes-before ' + updated_at2
|
'--changes-before ' + updated_at2,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
col_updated = [server["Name"] for server in cmd_output]
|
col_updated = [server["Name"] for server in cmd_output]
|
||||||
self.assertIn(server_name1, col_updated)
|
self.assertIn(server_name1, col_updated)
|
||||||
@ -149,10 +156,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
cmd_output = self.server_create()
|
cmd_output = self.server_create()
|
||||||
server_name3 = cmd_output['name']
|
server_name3 = cmd_output['name']
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server list -f json '
|
'server list '
|
||||||
'--changes-since ' + updated_at2
|
'--changes-since ' + updated_at2,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
col_updated = [server["Name"] for server in cmd_output]
|
col_updated = [server["Name"] for server in cmd_output]
|
||||||
self.assertNotIn(server_name1, col_updated)
|
self.assertNotIn(server_name1, col_updated)
|
||||||
@ -174,12 +182,13 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
server_name3 = cmd_output['name']
|
server_name3 = cmd_output['name']
|
||||||
updated_at3 = cmd_output['updated']
|
updated_at3 = cmd_output['updated']
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'--os-compute-api-version 2.66 ' +
|
'--os-compute-api-version 2.66 ' +
|
||||||
'server list -f json ' +
|
'server list ' +
|
||||||
'--changes-since ' + updated_at2 +
|
'--changes-since ' + updated_at2 +
|
||||||
' --changes-before ' + updated_at3
|
' --changes-before ' + updated_at3,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
col_updated = [server["Name"] for server in cmd_output]
|
col_updated = [server["Name"] for server in cmd_output]
|
||||||
self.assertNotIn(server_name1, col_updated)
|
self.assertNotIn(server_name1, col_updated)
|
||||||
@ -193,10 +202,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
# self.wait_for_status(name, "ACTIVE")
|
# self.wait_for_status(name, "ACTIVE")
|
||||||
|
|
||||||
# Have a look at some other fields
|
# Have a look at some other fields
|
||||||
flavor = json.loads(self.openstack(
|
flavor = self.openstack(
|
||||||
'flavor show -f json ' +
|
'flavor show ' +
|
||||||
self.flavor_name
|
self.flavor_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.flavor_name,
|
self.flavor_name,
|
||||||
flavor['name'],
|
flavor['name'],
|
||||||
@ -205,10 +215,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
'%s (%s)' % (flavor['name'], flavor['id']),
|
'%s (%s)' % (flavor['name'], flavor['id']),
|
||||||
cmd_output["flavor"],
|
cmd_output["flavor"],
|
||||||
)
|
)
|
||||||
image = json.loads(self.openstack(
|
image = self.openstack(
|
||||||
'image show -f json ' +
|
'image show ' +
|
||||||
self.image_name
|
self.image_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.image_name,
|
self.image_name,
|
||||||
image['name'],
|
image['name'],
|
||||||
@ -226,10 +237,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' +
|
'server show ' +
|
||||||
name
|
name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
# Really, shouldn't this be a list?
|
# Really, shouldn't this be a list?
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
{'a': 'b', 'c': 'd'},
|
{'a': 'b', 'c': 'd'},
|
||||||
@ -241,10 +253,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
'--property a ' +
|
'--property a ' +
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' +
|
'server show ' +
|
||||||
name
|
name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
{'c': 'd'},
|
{'c': 'd'},
|
||||||
cmd_output['properties'],
|
cmd_output['properties'],
|
||||||
@ -258,10 +271,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
name
|
name
|
||||||
)
|
)
|
||||||
self.assertOutput("", raw_output)
|
self.assertOutput("", raw_output)
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' +
|
'server show ' +
|
||||||
new_name
|
new_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
new_name,
|
new_name,
|
||||||
cmd_output["name"],
|
cmd_output["name"],
|
||||||
@ -360,10 +374,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
self.wait_for_status(name, "ACTIVE")
|
self.wait_for_status(name, "ACTIVE")
|
||||||
|
|
||||||
# attach ip
|
# attach ip
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'floating ip create -f json ' +
|
'floating ip create ' +
|
||||||
'public'
|
'public',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
# Look for Neutron value first, then nova-net
|
# Look for Neutron value first, then nova-net
|
||||||
floating_ip = cmd_output.get(
|
floating_ip = cmd_output.get(
|
||||||
@ -392,10 +407,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
# racy we shouldn't have to wait too long, a minute seems reasonable
|
# racy we shouldn't have to wait too long, a minute seems reasonable
|
||||||
wait_time = 0
|
wait_time = 0
|
||||||
while wait_time < 60:
|
while wait_time < 60:
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' +
|
'server show ' +
|
||||||
name
|
name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
if floating_ip not in _chain_addresses(cmd_output['addresses']):
|
if floating_ip not in _chain_addresses(cmd_output['addresses']):
|
||||||
# Hang out for a bit and try again
|
# Hang out for a bit and try again
|
||||||
print('retrying floating IP check')
|
print('retrying floating IP check')
|
||||||
@ -422,10 +438,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
# racy we shouldn't have to wait too long, a minute seems reasonable
|
# racy we shouldn't have to wait too long, a minute seems reasonable
|
||||||
wait_time = 0
|
wait_time = 0
|
||||||
while wait_time < 60:
|
while wait_time < 60:
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' +
|
'server show ' +
|
||||||
name
|
name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
if floating_ip in _chain_addresses(cmd_output['addresses']):
|
if floating_ip in _chain_addresses(cmd_output['addresses']):
|
||||||
# Hang out for a bit and try again
|
# Hang out for a bit and try again
|
||||||
print('retrying floating IP check')
|
print('retrying floating IP check')
|
||||||
@ -434,10 +451,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' +
|
'server show ' +
|
||||||
name
|
name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertNotIn(
|
self.assertNotIn(
|
||||||
floating_ip,
|
floating_ip,
|
||||||
_chain_addresses(cmd_output['addresses']),
|
_chain_addresses(cmd_output['addresses']),
|
||||||
@ -459,10 +477,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
volume_wait_for = volume_common.BaseVolumeTests.wait_for_status
|
volume_wait_for = volume_common.BaseVolumeTests.wait_for_status
|
||||||
|
|
||||||
# get image size
|
# get image size
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'image show -f json ' +
|
'image show ' +
|
||||||
self.image_name
|
self.image_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
image_size = cmd_output['min_disk']
|
image_size = cmd_output['min_disk']
|
||||||
if image_size < 1:
|
if image_size < 1:
|
||||||
@ -472,12 +491,13 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# create volume from image
|
# create volume from image
|
||||||
volume_name = uuid.uuid4().hex
|
volume_name = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume create -f json ' +
|
'volume create ' +
|
||||||
'--image ' + self.image_name + ' ' +
|
'--image ' + self.image_name + ' ' +
|
||||||
'--size ' + str(image_size) + ' ' +
|
'--size ' + str(image_size) + ' ' +
|
||||||
volume_name
|
volume_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(cmd_output["id"])
|
self.assertIsNotNone(cmd_output["id"])
|
||||||
self.addCleanup(self.openstack, 'volume delete ' + volume_name)
|
self.addCleanup(self.openstack, 'volume delete ' + volume_name)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -488,11 +508,12 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# create empty volume
|
# create empty volume
|
||||||
empty_volume_name = uuid.uuid4().hex
|
empty_volume_name = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume create -f json ' +
|
'volume create ' +
|
||||||
'--size ' + str(image_size) + ' ' +
|
'--size ' + str(image_size) + ' ' +
|
||||||
empty_volume_name
|
empty_volume_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(cmd_output["id"])
|
self.assertIsNotNone(cmd_output["id"])
|
||||||
self.addCleanup(self.openstack, 'volume delete ' + empty_volume_name)
|
self.addCleanup(self.openstack, 'volume delete ' + empty_volume_name)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -503,15 +524,16 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# create server
|
# create server
|
||||||
server_name = uuid.uuid4().hex
|
server_name = uuid.uuid4().hex
|
||||||
server = json.loads(self.openstack(
|
server = self.openstack(
|
||||||
'server create -f json ' +
|
'server create ' +
|
||||||
'--flavor ' + self.flavor_name + ' ' +
|
'--flavor ' + self.flavor_name + ' ' +
|
||||||
'--volume ' + volume_name + ' ' +
|
'--volume ' + volume_name + ' ' +
|
||||||
'--block-device-mapping vdb=' + empty_volume_name + ' ' +
|
'--block-device-mapping vdb=' + empty_volume_name + ' ' +
|
||||||
self.network_arg + ' ' +
|
self.network_arg + ' ' +
|
||||||
'--wait ' +
|
'--wait ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(server["id"])
|
self.assertIsNotNone(server["id"])
|
||||||
self.addCleanup(self.openstack, 'server delete --wait ' + server_name)
|
self.addCleanup(self.openstack, 'server delete --wait ' + server_name)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -525,19 +547,21 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
server['image'],
|
server['image'],
|
||||||
)
|
)
|
||||||
# check server list too
|
# check server list too
|
||||||
servers = json.loads(self.openstack(
|
servers = self.openstack(
|
||||||
'server list -f json'
|
'server list',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
v2_server.IMAGE_STRING_FOR_BFV,
|
v2_server.IMAGE_STRING_FOR_BFV,
|
||||||
servers[0]['Image']
|
servers[0]['Image']
|
||||||
)
|
)
|
||||||
|
|
||||||
# check volumes
|
# check volumes
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume show -f json ' +
|
'volume show ' +
|
||||||
volume_name
|
volume_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
attachments = cmd_output['attachments']
|
attachments = cmd_output['attachments']
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1,
|
1,
|
||||||
@ -556,10 +580,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
# --block-device-mapping was ignored if --volume
|
# --block-device-mapping was ignored if --volume
|
||||||
# present on the command line. Now we should see the
|
# present on the command line. Now we should see the
|
||||||
# attachment.
|
# attachment.
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume show -f json ' +
|
'volume show ' +
|
||||||
empty_volume_name
|
empty_volume_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
attachments = cmd_output['attachments']
|
attachments = cmd_output['attachments']
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1,
|
1,
|
||||||
@ -581,11 +606,12 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# create source empty volume
|
# create source empty volume
|
||||||
volume_name = uuid.uuid4().hex
|
volume_name = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume create -f json ' +
|
'volume create ' +
|
||||||
'--size 1 ' +
|
'--size 1 ' +
|
||||||
volume_name
|
volume_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
volume_id = cmd_output["id"]
|
volume_id = cmd_output["id"]
|
||||||
self.assertIsNotNone(volume_id)
|
self.assertIsNotNone(volume_id)
|
||||||
self.addCleanup(self.openstack, 'volume delete ' + volume_name)
|
self.addCleanup(self.openstack, 'volume delete ' + volume_name)
|
||||||
@ -603,15 +629,16 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# create server
|
# create server
|
||||||
server_name = uuid.uuid4().hex
|
server_name = uuid.uuid4().hex
|
||||||
server = json.loads(self.openstack(
|
server = self.openstack(
|
||||||
'server create -f json ' +
|
'server create ' +
|
||||||
'--flavor ' + self.flavor_name + ' ' +
|
'--flavor ' + self.flavor_name + ' ' +
|
||||||
'--image ' + self.image_name + ' ' +
|
'--image ' + self.image_name + ' ' +
|
||||||
bdm_arg + ' ' +
|
bdm_arg + ' ' +
|
||||||
self.network_arg + ' ' +
|
self.network_arg + ' ' +
|
||||||
'--wait ' +
|
'--wait ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(server["id"])
|
self.assertIsNotNone(server["id"])
|
||||||
self.addCleanup(self.openstack, 'server delete --wait ' + server_name)
|
self.addCleanup(self.openstack, 'server delete --wait ' + server_name)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -621,18 +648,20 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# check server volumes_attached, format is
|
# check server volumes_attached, format is
|
||||||
# {"volumes_attached": "id='2518bc76-bf0b-476e-ad6b-571973745bb5'",}
|
# {"volumes_attached": "id='2518bc76-bf0b-476e-ad6b-571973745bb5'",}
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' +
|
'server show ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
volumes_attached = cmd_output['volumes_attached']
|
volumes_attached = cmd_output['volumes_attached']
|
||||||
self.assertIsNotNone(volumes_attached)
|
self.assertIsNotNone(volumes_attached)
|
||||||
|
|
||||||
# check volumes
|
# check volumes
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume show -f json ' +
|
'volume show ' +
|
||||||
volume_name
|
volume_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
attachments = cmd_output['attachments']
|
attachments = cmd_output['attachments']
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1,
|
1,
|
||||||
@ -665,11 +694,12 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# create source empty volume
|
# create source empty volume
|
||||||
empty_volume_name = uuid.uuid4().hex
|
empty_volume_name = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume create -f json ' +
|
'volume create ' +
|
||||||
'--size 1 ' +
|
'--size 1 ' +
|
||||||
empty_volume_name
|
empty_volume_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(cmd_output["id"])
|
self.assertIsNotNone(cmd_output["id"])
|
||||||
self.addCleanup(self.openstack, 'volume delete ' + empty_volume_name)
|
self.addCleanup(self.openstack, 'volume delete ' + empty_volume_name)
|
||||||
self.assertEqual(empty_volume_name, cmd_output['name'])
|
self.assertEqual(empty_volume_name, cmd_output['name'])
|
||||||
@ -677,11 +707,12 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# create snapshot of source empty volume
|
# create snapshot of source empty volume
|
||||||
empty_snapshot_name = uuid.uuid4().hex
|
empty_snapshot_name = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume snapshot create -f json ' +
|
'volume snapshot create ' +
|
||||||
'--volume ' + empty_volume_name + ' ' +
|
'--volume ' + empty_volume_name + ' ' +
|
||||||
empty_snapshot_name
|
empty_snapshot_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
empty_snapshot_id = cmd_output["id"]
|
empty_snapshot_id = cmd_output["id"]
|
||||||
self.assertIsNotNone(empty_snapshot_id)
|
self.assertIsNotNone(empty_snapshot_id)
|
||||||
# Deleting volume snapshot take time, so we need to wait until the
|
# Deleting volume snapshot take time, so we need to wait until the
|
||||||
@ -712,15 +743,16 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# create server with bdm snapshot
|
# create server with bdm snapshot
|
||||||
server_name = uuid.uuid4().hex
|
server_name = uuid.uuid4().hex
|
||||||
server = json.loads(self.openstack(
|
server = self.openstack(
|
||||||
'server create -f json ' +
|
'server create ' +
|
||||||
'--flavor ' + self.flavor_name + ' ' +
|
'--flavor ' + self.flavor_name + ' ' +
|
||||||
'--image ' + self.image_name + ' ' +
|
'--image ' + self.image_name + ' ' +
|
||||||
bdm_arg + ' ' +
|
bdm_arg + ' ' +
|
||||||
self.network_arg + ' ' +
|
self.network_arg + ' ' +
|
||||||
'--wait ' +
|
'--wait ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(server["id"])
|
self.assertIsNotNone(server["id"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
server_name,
|
server_name,
|
||||||
@ -730,19 +762,21 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# check server volumes_attached, format is
|
# check server volumes_attached, format is
|
||||||
# {"volumes_attached": "id='2518bc76-bf0b-476e-ad6b-571973745bb5'",}
|
# {"volumes_attached": "id='2518bc76-bf0b-476e-ad6b-571973745bb5'",}
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' +
|
'server show ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
volumes_attached = cmd_output['volumes_attached']
|
volumes_attached = cmd_output['volumes_attached']
|
||||||
self.assertIsNotNone(volumes_attached)
|
self.assertIsNotNone(volumes_attached)
|
||||||
attached_volume_id = volumes_attached[0]["id"]
|
attached_volume_id = volumes_attached[0]["id"]
|
||||||
|
|
||||||
# check the volume that attached on server
|
# check the volume that attached on server
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume show -f json ' +
|
'volume show ' +
|
||||||
attached_volume_id
|
attached_volume_id,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
attachments = cmd_output['attachments']
|
attachments = cmd_output['attachments']
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1,
|
1,
|
||||||
@ -760,9 +794,10 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
# delete server, then check the attached volume had been deleted,
|
# delete server, then check the attached volume had been deleted,
|
||||||
# <delete-on-terminate>=true
|
# <delete-on-terminate>=true
|
||||||
self.openstack('server delete --wait ' + server_name)
|
self.openstack('server delete --wait ' + server_name)
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume list -f json'
|
'volume list',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
target_volume = [each_volume
|
target_volume = [each_volume
|
||||||
for each_volume in cmd_output
|
for each_volume in cmd_output
|
||||||
if each_volume['ID'] == attached_volume_id]
|
if each_volume['ID'] == attached_volume_id]
|
||||||
@ -801,10 +836,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# get image ID
|
# get image ID
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'image show -f json ' +
|
'image show ' +
|
||||||
self.image_name
|
self.image_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
image_id = cmd_output['id']
|
image_id = cmd_output['id']
|
||||||
|
|
||||||
# This means create a 1GB volume from the specified image, attach
|
# This means create a 1GB volume from the specified image, attach
|
||||||
@ -824,15 +860,16 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
# as expected where nova creates a volume from the image and attaches
|
# as expected where nova creates a volume from the image and attaches
|
||||||
# that volume to the server.
|
# that volume to the server.
|
||||||
server_name = uuid.uuid4().hex
|
server_name = uuid.uuid4().hex
|
||||||
server = json.loads(self.openstack(
|
server = self.openstack(
|
||||||
'server create -f json ' +
|
'server create ' +
|
||||||
'--flavor ' + self.flavor_name + ' ' +
|
'--flavor ' + self.flavor_name + ' ' +
|
||||||
'--image ' + self.image_name + ' ' +
|
'--image ' + self.image_name + ' ' +
|
||||||
bdm_arg + ' ' +
|
bdm_arg + ' ' +
|
||||||
self.network_arg + ' ' +
|
self.network_arg + ' ' +
|
||||||
'--wait ' +
|
'--wait ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(server["id"])
|
self.assertIsNotNone(server["id"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
server_name,
|
server_name,
|
||||||
@ -842,19 +879,21 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# check server volumes_attached, format is
|
# check server volumes_attached, format is
|
||||||
# {"volumes_attached": "id='2518bc76-bf0b-476e-ad6b-571973745bb5'",}
|
# {"volumes_attached": "id='2518bc76-bf0b-476e-ad6b-571973745bb5'",}
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' +
|
'server show ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
volumes_attached = cmd_output['volumes_attached']
|
volumes_attached = cmd_output['volumes_attached']
|
||||||
self.assertIsNotNone(volumes_attached)
|
self.assertIsNotNone(volumes_attached)
|
||||||
attached_volume_id = volumes_attached[0]["id"]
|
attached_volume_id = volumes_attached[0]["id"]
|
||||||
|
|
||||||
# check the volume that attached on server
|
# check the volume that attached on server
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume show -f json ' +
|
'volume show ' +
|
||||||
attached_volume_id
|
attached_volume_id,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
attachments = cmd_output['attachments']
|
attachments = cmd_output['attachments']
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1,
|
1,
|
||||||
@ -879,9 +918,10 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# delete server, then check the attached volume has been deleted
|
# delete server, then check the attached volume has been deleted
|
||||||
self.openstack('server delete --wait ' + server_name)
|
self.openstack('server delete --wait ' + server_name)
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume list -f json'
|
'volume list',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
target_volume = [each_volume
|
target_volume = [each_volume
|
||||||
for each_volume in cmd_output
|
for each_volume in cmd_output
|
||||||
if each_volume['ID'] == attached_volume_id]
|
if each_volume['ID'] == attached_volume_id]
|
||||||
@ -906,15 +946,16 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
# using the provided image, attach it as the root disk for the server
|
# using the provided image, attach it as the root disk for the server
|
||||||
# and not delete the volume when the server is deleted.
|
# and not delete the volume when the server is deleted.
|
||||||
server_name = uuid.uuid4().hex
|
server_name = uuid.uuid4().hex
|
||||||
server = json.loads(self.openstack(
|
server = self.openstack(
|
||||||
'server create -f json ' +
|
'server create ' +
|
||||||
'--flavor ' + self.flavor_name + ' ' +
|
'--flavor ' + self.flavor_name + ' ' +
|
||||||
'--image ' + self.image_name + ' ' +
|
'--image ' + self.image_name + ' ' +
|
||||||
'--boot-from-volume 1 ' + # create a 1GB volume from the image
|
'--boot-from-volume 1 ' + # create a 1GB volume from the image
|
||||||
self.network_arg + ' ' +
|
self.network_arg + ' ' +
|
||||||
'--wait ' +
|
'--wait ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(server["id"])
|
self.assertIsNotNone(server["id"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
server_name,
|
server_name,
|
||||||
@ -924,10 +965,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# check server volumes_attached, format is
|
# check server volumes_attached, format is
|
||||||
# {"volumes_attached": "id='2518bc76-bf0b-476e-ad6b-571973745bb5'",}
|
# {"volumes_attached": "id='2518bc76-bf0b-476e-ad6b-571973745bb5'",}
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' +
|
'server show ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
volumes_attached = cmd_output['volumes_attached']
|
volumes_attached = cmd_output['volumes_attached']
|
||||||
self.assertIsNotNone(volumes_attached)
|
self.assertIsNotNone(volumes_attached)
|
||||||
attached_volume_id = volumes_attached[0]["id"]
|
attached_volume_id = volumes_attached[0]["id"]
|
||||||
@ -941,10 +983,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
self.assertEqual(v2_server.IMAGE_STRING_FOR_BFV, cmd_output['image'])
|
self.assertEqual(v2_server.IMAGE_STRING_FOR_BFV, cmd_output['image'])
|
||||||
|
|
||||||
# check the volume that attached on server
|
# check the volume that attached on server
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume show -f json ' +
|
'volume show ' +
|
||||||
volumes_attached[0]["id"]
|
volumes_attached[0]["id"],
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
# The volume size should be what we specified on the command line.
|
# The volume size should be what we specified on the command line.
|
||||||
self.assertEqual(1, int(cmd_output['size']))
|
self.assertEqual(1, int(cmd_output['size']))
|
||||||
attachments = cmd_output['attachments']
|
attachments = cmd_output['attachments']
|
||||||
@ -971,32 +1014,35 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
# delete server, then check the attached volume was not deleted
|
# delete server, then check the attached volume was not deleted
|
||||||
self.openstack('server delete --wait ' + server_name)
|
self.openstack('server delete --wait ' + server_name)
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume show -f json ' +
|
'volume show ' +
|
||||||
attached_volume_id
|
attached_volume_id,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
# check the volume is in 'available' status
|
# check the volume is in 'available' status
|
||||||
self.assertEqual('available', cmd_output['status'])
|
self.assertEqual('available', cmd_output['status'])
|
||||||
|
|
||||||
def test_server_create_with_none_network(self):
|
def test_server_create_with_none_network(self):
|
||||||
"""Test server create with none network option."""
|
"""Test server create with none network option."""
|
||||||
server_name = uuid.uuid4().hex
|
server_name = uuid.uuid4().hex
|
||||||
server = json.loads(self.openstack(
|
server = self.openstack(
|
||||||
# auto/none enable in nova micro version (v2.37+)
|
# auto/none enable in nova micro version (v2.37+)
|
||||||
'--os-compute-api-version 2.37 ' +
|
'--os-compute-api-version 2.37 ' +
|
||||||
'server create -f json ' +
|
'server create ' +
|
||||||
'--flavor ' + self.flavor_name + ' ' +
|
'--flavor ' + self.flavor_name + ' ' +
|
||||||
'--image ' + self.image_name + ' ' +
|
'--image ' + self.image_name + ' ' +
|
||||||
'--nic none ' +
|
'--nic none ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(server["id"])
|
self.assertIsNotNone(server["id"])
|
||||||
self.addCleanup(self.openstack, 'server delete --wait ' + server_name)
|
self.addCleanup(self.openstack, 'server delete --wait ' + server_name)
|
||||||
self.assertEqual(server_name, server['name'])
|
self.assertEqual(server_name, server['name'])
|
||||||
self.wait_for_status(server_name, "ACTIVE")
|
self.wait_for_status(server_name, "ACTIVE")
|
||||||
server = json.loads(self.openstack(
|
server = self.openstack(
|
||||||
'server show -f json ' + server_name
|
'server show ' + server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual({}, server['addresses'])
|
self.assertEqual({}, server['addresses'])
|
||||||
|
|
||||||
def test_server_create_with_security_group(self):
|
def test_server_create_with_security_group(self):
|
||||||
@ -1011,27 +1057,30 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
self.skipTest("No Network service present")
|
self.skipTest("No Network service present")
|
||||||
# Create two security group, use name and ID to create server
|
# Create two security group, use name and ID to create server
|
||||||
sg_name1 = uuid.uuid4().hex
|
sg_name1 = uuid.uuid4().hex
|
||||||
security_group1 = json.loads(self.openstack(
|
security_group1 = self.openstack(
|
||||||
'security group create -f json ' + sg_name1
|
'security group create ' + sg_name1,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.addCleanup(self.openstack, 'security group delete ' + sg_name1)
|
self.addCleanup(self.openstack, 'security group delete ' + sg_name1)
|
||||||
sg_name2 = uuid.uuid4().hex
|
sg_name2 = uuid.uuid4().hex
|
||||||
security_group2 = json.loads(self.openstack(
|
security_group2 = self.openstack(
|
||||||
'security group create -f json ' + sg_name2
|
'security group create ' + sg_name2,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.addCleanup(self.openstack, 'security group delete ' + sg_name2)
|
self.addCleanup(self.openstack, 'security group delete ' + sg_name2)
|
||||||
|
|
||||||
server_name = uuid.uuid4().hex
|
server_name = uuid.uuid4().hex
|
||||||
server = json.loads(self.openstack(
|
server = self.openstack(
|
||||||
'server create -f json ' +
|
'server create ' +
|
||||||
'--flavor ' + self.flavor_name + ' ' +
|
'--flavor ' + self.flavor_name + ' ' +
|
||||||
'--image ' + self.image_name + ' ' +
|
'--image ' + self.image_name + ' ' +
|
||||||
# Security group id is integer in nova-network, convert to string
|
# Security group id is integer in nova-network, convert to string
|
||||||
'--security-group ' + str(security_group1['id']) + ' ' +
|
'--security-group ' + str(security_group1['id']) + ' ' +
|
||||||
'--security-group ' + security_group2['name'] + ' ' +
|
'--security-group ' + security_group2['name'] + ' ' +
|
||||||
self.network_arg + ' ' +
|
self.network_arg + ' ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.addCleanup(self.openstack, 'server delete --wait ' + server_name)
|
self.addCleanup(self.openstack, 'server delete --wait ' + server_name)
|
||||||
|
|
||||||
self.assertIsNotNone(server['id'])
|
self.assertIsNotNone(server['id'])
|
||||||
@ -1042,9 +1091,10 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
self.assertIn(str(security_group1['id']), sec_grp)
|
self.assertIn(str(security_group1['id']), sec_grp)
|
||||||
self.assertIn(str(security_group2['id']), sec_grp)
|
self.assertIn(str(security_group2['id']), sec_grp)
|
||||||
self.wait_for_status(server_name, 'ACTIVE')
|
self.wait_for_status(server_name, 'ACTIVE')
|
||||||
server = json.loads(self.openstack(
|
server = self.openstack(
|
||||||
'server show -f json ' + server_name
|
'server show ' + server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
# check if security group exists in list
|
# check if security group exists in list
|
||||||
sec_grp = ""
|
sec_grp = ""
|
||||||
for sec in server['security_groups']:
|
for sec in server['security_groups']:
|
||||||
@ -1059,7 +1109,7 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
self.openstack(
|
self.openstack(
|
||||||
# auto/none enable in nova micro version (v2.37+)
|
# auto/none enable in nova micro version (v2.37+)
|
||||||
'--os-compute-api-version 2.37 ' +
|
'--os-compute-api-version 2.37 ' +
|
||||||
'server create -f json ' +
|
'server create ' +
|
||||||
'--flavor ' + self.flavor_name + ' ' +
|
'--flavor ' + self.flavor_name + ' ' +
|
||||||
'--image ' + self.image_name + ' ' +
|
'--image ' + self.image_name + ' ' +
|
||||||
server_name
|
server_name
|
||||||
@ -1074,14 +1124,15 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
def test_server_add_remove_network(self):
|
def test_server_add_remove_network(self):
|
||||||
name = uuid.uuid4().hex
|
name = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server create -f json ' +
|
'server create ' +
|
||||||
'--network private ' +
|
'--network private ' +
|
||||||
'--flavor ' + self.flavor_name + ' ' +
|
'--flavor ' + self.flavor_name + ' ' +
|
||||||
'--image ' + self.image_name + ' ' +
|
'--image ' + self.image_name + ' ' +
|
||||||
'--wait ' +
|
'--wait ' +
|
||||||
name
|
name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
self.assertIsNotNone(cmd_output['id'])
|
self.assertIsNotNone(cmd_output['id'])
|
||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
@ -1093,9 +1144,10 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
wait_time = 0
|
wait_time = 0
|
||||||
while wait_time < 60:
|
while wait_time < 60:
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' + name
|
'server show ' + name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
if 'public' not in cmd_output['addresses']:
|
if 'public' not in cmd_output['addresses']:
|
||||||
# Hang out for a bit and try again
|
# Hang out for a bit and try again
|
||||||
print('retrying add network check')
|
print('retrying add network check')
|
||||||
@ -1111,9 +1163,10 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
wait_time = 0
|
wait_time = 0
|
||||||
while wait_time < 60:
|
while wait_time < 60:
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' + name
|
'server show ' + name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
if 'public' in cmd_output['addresses']:
|
if 'public' in cmd_output['addresses']:
|
||||||
# Hang out for a bit and try again
|
# Hang out for a bit and try again
|
||||||
print('retrying remove network check')
|
print('retrying remove network check')
|
||||||
@ -1127,14 +1180,15 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
def test_server_add_remove_port(self):
|
def test_server_add_remove_port(self):
|
||||||
name = uuid.uuid4().hex
|
name = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server create -f json ' +
|
'server create ' +
|
||||||
'--network private ' +
|
'--network private ' +
|
||||||
'--flavor ' + self.flavor_name + ' ' +
|
'--flavor ' + self.flavor_name + ' ' +
|
||||||
'--image ' + self.image_name + ' ' +
|
'--image ' + self.image_name + ' ' +
|
||||||
'--wait ' +
|
'--wait ' +
|
||||||
name
|
name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
self.assertIsNotNone(cmd_output['id'])
|
self.assertIsNotNone(cmd_output['id'])
|
||||||
self.assertEqual(name, cmd_output['name'])
|
self.assertEqual(name, cmd_output['name'])
|
||||||
@ -1143,15 +1197,17 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
# create port, record one of its ip address
|
# create port, record one of its ip address
|
||||||
port_name = uuid.uuid4().hex
|
port_name = uuid.uuid4().hex
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'port list -f json'
|
'port list',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertNotIn(port_name, cmd_output)
|
self.assertNotIn(port_name, cmd_output)
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'port create -f json ' +
|
'port create ' +
|
||||||
'--network private ' + port_name
|
'--network private ' + port_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertIsNotNone(cmd_output['id'])
|
self.assertIsNotNone(cmd_output['id'])
|
||||||
ip_address = cmd_output['fixed_ips'][0]['ip_address']
|
ip_address = cmd_output['fixed_ips'][0]['ip_address']
|
||||||
self.addCleanup(self.openstack, 'port delete ' + port_name)
|
self.addCleanup(self.openstack, 'port delete ' + port_name)
|
||||||
@ -1161,9 +1217,10 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
wait_time = 0
|
wait_time = 0
|
||||||
while wait_time < 60:
|
while wait_time < 60:
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' + name
|
'server show ' + name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
if ip_address not in cmd_output['addresses']['private']:
|
if ip_address not in cmd_output['addresses']['private']:
|
||||||
# Hang out for a bit and try again
|
# Hang out for a bit and try again
|
||||||
print('retrying add port check')
|
print('retrying add port check')
|
||||||
@ -1179,9 +1236,10 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
wait_time = 0
|
wait_time = 0
|
||||||
while wait_time < 60:
|
while wait_time < 60:
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server show -f json ' + name
|
'server show ' + name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
if ip_address in cmd_output['addresses']['private']:
|
if ip_address in cmd_output['addresses']['private']:
|
||||||
# Hang out for a bit and try again
|
# Hang out for a bit and try again
|
||||||
print('retrying add port check')
|
print('retrying add port check')
|
||||||
@ -1196,14 +1254,15 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
volume_wait_for = volume_common.BaseVolumeTests.wait_for_status
|
volume_wait_for = volume_common.BaseVolumeTests.wait_for_status
|
||||||
|
|
||||||
server_name = uuid.uuid4().hex
|
server_name = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server create -f json ' +
|
'server create ' +
|
||||||
'--network private ' +
|
'--network private ' +
|
||||||
'--flavor ' + self.flavor_name + ' ' +
|
'--flavor ' + self.flavor_name + ' ' +
|
||||||
'--image ' + self.image_name + ' ' +
|
'--image ' + self.image_name + ' ' +
|
||||||
'--wait ' +
|
'--wait ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
self.assertIsNotNone(cmd_output['id'])
|
self.assertIsNotNone(cmd_output['id'])
|
||||||
self.assertEqual(server_name, cmd_output['name'])
|
self.assertEqual(server_name, cmd_output['name'])
|
||||||
@ -1211,11 +1270,12 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
server_id = cmd_output['id']
|
server_id = cmd_output['id']
|
||||||
|
|
||||||
volume_name = uuid.uuid4().hex
|
volume_name = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'volume create -f json ' +
|
'volume create ' +
|
||||||
'--size 1 ' +
|
'--size 1 ' +
|
||||||
volume_name
|
volume_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
self.assertIsNotNone(cmd_output['id'])
|
self.assertIsNotNone(cmd_output['id'])
|
||||||
self.assertEqual(volume_name, cmd_output['name'])
|
self.assertEqual(volume_name, cmd_output['name'])
|
||||||
@ -1223,22 +1283,24 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
self.addCleanup(self.openstack, 'volume delete ' + volume_name)
|
self.addCleanup(self.openstack, 'volume delete ' + volume_name)
|
||||||
volume_id = cmd_output['id']
|
volume_id = cmd_output['id']
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server add volume -f json ' +
|
'server add volume ' +
|
||||||
server_name + ' ' +
|
server_name + ' ' +
|
||||||
volume_name + ' ' +
|
volume_name + ' ' +
|
||||||
'--tag bar'
|
'--tag bar',
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
self.assertIsNotNone(cmd_output['ID'])
|
self.assertIsNotNone(cmd_output['ID'])
|
||||||
self.assertEqual(server_id, cmd_output['Server ID'])
|
self.assertEqual(server_id, cmd_output['Server ID'])
|
||||||
self.assertEqual(volume_id, cmd_output['Volume ID'])
|
self.assertEqual(volume_id, cmd_output['Volume ID'])
|
||||||
volume_attachment_id = cmd_output['ID']
|
volume_attachment_id = cmd_output['ID']
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server volume list -f json ' +
|
'server volume list ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(volume_attachment_id, cmd_output[0]['ID'])
|
self.assertEqual(volume_attachment_id, cmd_output[0]['ID'])
|
||||||
self.assertEqual(server_id, cmd_output[0]['Server ID'])
|
self.assertEqual(server_id, cmd_output[0]['Server ID'])
|
||||||
@ -1246,10 +1308,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
|
|
||||||
volume_wait_for('volume', volume_name, 'in-use')
|
volume_wait_for('volume', volume_name, 'in-use')
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server event list -f json ' +
|
'server event list ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(2, len(cmd_output))
|
self.assertEqual(2, len(cmd_output))
|
||||||
self.assertIn('attach_volume', {x['Action'] for x in cmd_output})
|
self.assertIn('attach_volume', {x['Action'] for x in cmd_output})
|
||||||
|
|
||||||
@ -1258,10 +1321,11 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
)
|
)
|
||||||
volume_wait_for('volume', volume_name, 'available')
|
volume_wait_for('volume', volume_name, 'available')
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server event list -f json ' +
|
'server event list ' +
|
||||||
server_name
|
server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(3, len(cmd_output))
|
self.assertEqual(3, len(cmd_output))
|
||||||
self.assertIn('detach_volume', {x['Action'] for x in cmd_output})
|
self.assertIn('detach_volume', {x['Action'] for x in cmd_output})
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from openstackclient.tests.functional.compute.v2 import common
|
from openstackclient.tests.functional.compute.v2 import common
|
||||||
|
|
||||||
|
|
||||||
@ -33,9 +31,10 @@ class ServerEventTests(common.ComputeTestCase):
|
|||||||
def test_server_event_list_and_show(self):
|
def test_server_event_list_and_show(self):
|
||||||
"""Test list, show server event"""
|
"""Test list, show server event"""
|
||||||
# Test 'server event list' for creating
|
# Test 'server event list' for creating
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server event list -f json ' + self.server_name
|
'server event list ' + self.server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
request_id = None
|
request_id = None
|
||||||
for each_event in cmd_output:
|
for each_event in cmd_output:
|
||||||
self.assertNotIn('Message', each_event)
|
self.assertNotIn('Message', each_event)
|
||||||
@ -47,9 +46,10 @@ class ServerEventTests(common.ComputeTestCase):
|
|||||||
break
|
break
|
||||||
self.assertIsNotNone(request_id)
|
self.assertIsNotNone(request_id)
|
||||||
# Test 'server event show' for creating
|
# Test 'server event show' for creating
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server event show -f json ' + self.server_name + ' ' + request_id
|
'server event show ' + self.server_name + ' ' + request_id,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(self.server_id, cmd_output.get('instance_uuid'))
|
self.assertEqual(self.server_id, cmd_output.get('instance_uuid'))
|
||||||
self.assertEqual(request_id, cmd_output.get('request_id'))
|
self.assertEqual(request_id, cmd_output.get('request_id'))
|
||||||
self.assertEqual('create', cmd_output.get('action'))
|
self.assertEqual('create', cmd_output.get('action'))
|
||||||
@ -59,9 +59,10 @@ class ServerEventTests(common.ComputeTestCase):
|
|||||||
# Reboot server, trigger reboot event
|
# Reboot server, trigger reboot event
|
||||||
self.openstack('server reboot --wait ' + self.server_name)
|
self.openstack('server reboot --wait ' + self.server_name)
|
||||||
# Test 'server event list --long' for rebooting
|
# Test 'server event list --long' for rebooting
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server event list --long -f json ' + self.server_name
|
'server event list --long ' + self.server_name,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
request_id = None
|
request_id = None
|
||||||
for each_event in cmd_output:
|
for each_event in cmd_output:
|
||||||
self.assertIn('Message', each_event)
|
self.assertIn('Message', each_event)
|
||||||
@ -73,9 +74,10 @@ class ServerEventTests(common.ComputeTestCase):
|
|||||||
break
|
break
|
||||||
self.assertIsNotNone(request_id)
|
self.assertIsNotNone(request_id)
|
||||||
# Test 'server event show' for rebooting
|
# Test 'server event show' for rebooting
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server event show -f json ' + self.server_name + ' ' + request_id
|
'server event show ' + self.server_name + ' ' + request_id,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(self.server_id, cmd_output.get('instance_uuid'))
|
self.assertEqual(self.server_id, cmd_output.get('instance_uuid'))
|
||||||
self.assertEqual(request_id, cmd_output.get('request_id'))
|
self.assertEqual(request_id, cmd_output.get('request_id'))
|
||||||
@ -93,10 +95,11 @@ class ServerEventTests(common.ComputeTestCase):
|
|||||||
self.openstack('server delete --wait ' + server_id)
|
self.openstack('server delete --wait ' + server_id)
|
||||||
# And verify we can get the event list after it's deleted
|
# And verify we can get the event list after it's deleted
|
||||||
# Test 'server event list' for deleting
|
# Test 'server event list' for deleting
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'--os-compute-api-version 2.21 '
|
'--os-compute-api-version 2.21 '
|
||||||
'server event list -f json ' + server_id
|
'server event list ' + server_id,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
request_id = None
|
request_id = None
|
||||||
for each_event in cmd_output:
|
for each_event in cmd_output:
|
||||||
self.assertNotIn('Message', each_event)
|
self.assertNotIn('Message', each_event)
|
||||||
@ -108,10 +111,11 @@ class ServerEventTests(common.ComputeTestCase):
|
|||||||
break
|
break
|
||||||
self.assertIsNotNone(request_id)
|
self.assertIsNotNone(request_id)
|
||||||
# Test 'server event show' for deleting
|
# Test 'server event show' for deleting
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'--os-compute-api-version 2.21 '
|
'--os-compute-api-version 2.21 '
|
||||||
'server event show -f json ' + server_id + ' ' + request_id
|
'server event show ' + server_id + ' ' + request_id,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(server_id, cmd_output.get('instance_uuid'))
|
self.assertEqual(server_id, cmd_output.get('instance_uuid'))
|
||||||
self.assertEqual(request_id, cmd_output.get('request_id'))
|
self.assertEqual(request_id, cmd_output.get('request_id'))
|
||||||
self.assertEqual('delete', cmd_output.get('action'))
|
self.assertEqual('delete', cmd_output.get('action'))
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional import base
|
from openstackclient.tests.functional import base
|
||||||
@ -23,11 +22,12 @@ class ServerGroupTests(base.TestCase):
|
|||||||
"""Test create, delete multiple"""
|
"""Test create, delete multiple"""
|
||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
name2 = uuid.uuid4().hex
|
name2 = uuid.uuid4().hex
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server group create -f json ' +
|
'server group create ' +
|
||||||
'--policy affinity ' +
|
'--policy affinity ' +
|
||||||
name1
|
name1,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name1,
|
name1,
|
||||||
cmd_output['name']
|
cmd_output['name']
|
||||||
@ -37,11 +37,12 @@ class ServerGroupTests(base.TestCase):
|
|||||||
cmd_output['policy']
|
cmd_output['policy']
|
||||||
)
|
)
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server group create -f json ' +
|
'server group create ' +
|
||||||
'--policy anti-affinity ' +
|
'--policy anti-affinity ' +
|
||||||
name2
|
name2,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name2,
|
name2,
|
||||||
cmd_output['name']
|
cmd_output['name']
|
||||||
@ -61,14 +62,17 @@ class ServerGroupTests(base.TestCase):
|
|||||||
name2 = uuid.uuid4().hex
|
name2 = uuid.uuid4().hex
|
||||||
|
|
||||||
# test server group show
|
# test server group show
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server group create -f json ' +
|
'server group create ' +
|
||||||
'--policy affinity ' +
|
'--policy affinity ' +
|
||||||
name1
|
name1,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.addCleanup(self.openstack, 'server group delete ' + name1)
|
self.addCleanup(self.openstack, 'server group delete ' + name1)
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server group show -f json ' + name1))
|
'server group show ' + name1,
|
||||||
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name1,
|
name1,
|
||||||
cmd_output['name']
|
cmd_output['name']
|
||||||
@ -78,14 +82,17 @@ class ServerGroupTests(base.TestCase):
|
|||||||
cmd_output['policy']
|
cmd_output['policy']
|
||||||
)
|
)
|
||||||
|
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server group create -f json ' +
|
'server group create ' +
|
||||||
'--policy anti-affinity ' +
|
'--policy anti-affinity ' +
|
||||||
name2
|
name2,
|
||||||
))
|
parse_output=True,
|
||||||
|
)
|
||||||
self.addCleanup(self.openstack, 'server group delete ' + name2)
|
self.addCleanup(self.openstack, 'server group delete ' + name2)
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server group show -f json ' + name2))
|
'server group show ' + name2,
|
||||||
|
parse_output=True,
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name2,
|
name2,
|
||||||
cmd_output['name']
|
cmd_output['name']
|
||||||
@ -96,8 +103,10 @@ class ServerGroupTests(base.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# test server group list
|
# test server group list
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = self.openstack(
|
||||||
'server group list -f json'))
|
'server group list',
|
||||||
|
parse_output=True,
|
||||||
|
)
|
||||||
names = [x["Name"] for x in cmd_output]
|
names = [x["Name"] for x in cmd_output]
|
||||||
self.assertIn(name1, names)
|
self.assertIn(name1, names)
|
||||||
self.assertIn(name2, names)
|
self.assertIn(name2, names)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user