Merge "Deduplicate get_opts methods"

This commit is contained in:
Jenkins 2016-07-06 15:31:42 +00:00 committed by Gerrit Code Review
commit 272d193401
29 changed files with 117 additions and 122 deletions

View File

@ -54,17 +54,13 @@ class TestCase(testtools.TestCase):
@classmethod @classmethod
def get_openstack_configuration_value(cls, configuration): def get_openstack_configuration_value(cls, configuration):
opts = cls.get_show_opts([configuration]) opts = cls.get_opts([configuration])
return cls.openstack('configuration show ' + opts) return cls.openstack('configuration show ' + opts)
@classmethod @classmethod
def get_show_opts(cls, fields=[]): def get_opts(cls, fields):
return ' -f value ' + ' '.join(['-c ' + it for it in fields]) return ' -f value ' + ' '.join(['-c ' + it for it in fields])
@classmethod
def get_list_opts(cls, headers=[]):
return ' -f csv ' + ' '.join(['-c ' + it for it in headers])
@classmethod @classmethod
def assertOutput(cls, expected, actual): def assertOutput(cls, expected, actual):
if expected != actual: if expected != actual:

View File

@ -20,6 +20,6 @@ class AvailabilityZoneTests(test.TestCase):
DEFAULT_AZ_NAME = 'nova' DEFAULT_AZ_NAME = 'nova'
def test_availability_zone_list(self): def test_availability_zone_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('availability zone list' + opts) raw_output = self.openstack('availability zone list' + opts)
self.assertIn(self.DEFAULT_AZ_NAME, raw_output) self.assertIn(self.DEFAULT_AZ_NAME, raw_output)

View File

@ -27,7 +27,7 @@ class QuotaTests(test.TestCase):
def test_quota_set(self): def test_quota_set(self):
self.openstack('quota set --instances 11 --volumes 11 --networks 11 ' self.openstack('quota set --instances 11 --volumes 11 --networks 11 '
+ self.PROJECT_NAME) + self.PROJECT_NAME)
opts = self.get_show_opts(self.EXPECTED_FIELDS) opts = self.get_opts(self.EXPECTED_FIELDS)
raw_output = self.openstack('quota show ' + self.PROJECT_NAME + opts) raw_output = self.openstack('quota show ' + self.PROJECT_NAME + opts)
self.assertEqual("11\n11\n11\n", raw_output) self.assertEqual("11\n11\n11\n", raw_output)

View File

@ -31,7 +31,7 @@ class ComputeAgentTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
opts = cls.get_show_opts(cls.HEADERS) opts = cls.get_opts(cls.HEADERS)
raw_output = cls.openstack('compute agent create ' + raw_output = cls.openstack('compute agent create ' +
cls.OS + ' ' + cls.ARCH + ' ' + cls.OS + ' ' + cls.ARCH + ' ' +
cls.VER + ' ' + cls.URL + ' ' + cls.VER + ' ' + cls.URL + ' ' +

View File

@ -24,7 +24,7 @@ class AggregateTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
# Use the default 'nova' availability zone for the aggregate. # Use the default 'nova' availability zone for the aggregate.
raw_output = cls.openstack( raw_output = cls.openstack(
'aggregate create --zone nova ' + cls.NAME + opts 'aggregate create --zone nova ' + cls.NAME + opts
@ -38,17 +38,17 @@ class AggregateTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_aggregate_list(self): def test_aggregate_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('aggregate list' + opts) raw_output = self.openstack('aggregate list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_aggregate_show(self): def test_aggregate_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('aggregate show ' + self.NAME + opts) raw_output = self.openstack('aggregate show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)
def test_aggregate_properties(self): def test_aggregate_properties(self):
opts = self.get_show_opts(['properties']) opts = self.get_opts(['properties'])
raw_output = self.openstack( raw_output = self.openstack(
'aggregate set --property a=b --property c=d ' + self.NAME 'aggregate set --property a=b --property c=d ' + self.NAME

View File

@ -24,7 +24,7 @@ class FlavorTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack( raw_output = cls.openstack(
'flavor create --property a=b --property c=d ' + cls.NAME + opts) 'flavor create --property a=b --property c=d ' + cls.NAME + opts)
expected = cls.NAME + '\n' expected = cls.NAME + '\n'
@ -36,18 +36,18 @@ class FlavorTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_flavor_list(self): def test_flavor_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('flavor list' + opts) raw_output = self.openstack('flavor list' + opts)
self.assertIn("small", raw_output) self.assertIn("small", raw_output)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_flavor_show(self): def test_flavor_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('flavor show ' + self.NAME + opts) raw_output = self.openstack('flavor show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)
def test_flavor_properties(self): def test_flavor_properties(self):
opts = self.get_show_opts(['properties']) opts = self.get_opts(['properties'])
# check the properties we added in create command. # check the properties we added in create command.
raw_output = self.openstack('flavor show ' + self.NAME + opts) raw_output = self.openstack('flavor show ' + self.NAME + opts)
self.assertEqual("a='b', c='d'\n", raw_output) self.assertEqual("a='b', c='d'\n", raw_output)

View File

@ -58,7 +58,7 @@ class ServerTests(test.TestCase):
def server_create(self, name=None): def server_create(self, name=None):
"""Create server. Add cleanup.""" """Create server. Add cleanup."""
name = name or data_utils.rand_uuid() name = name or data_utils.rand_uuid()
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
flavor = self.get_flavor() flavor = self.get_flavor()
image = self.get_image() image = self.get_image()
network = self.get_network() network = self.get_network()
@ -72,7 +72,7 @@ class ServerTests(test.TestCase):
def server_list(self, params=[]): def server_list(self, params=[]):
"""List servers.""" """List servers."""
opts = self.get_list_opts(params) opts = self.get_opts(params)
return self.openstack('server list' + opts) return self.openstack('server list' + opts)
def server_delete(self, name): def server_delete(self, name):
@ -114,7 +114,7 @@ class ServerTests(test.TestCase):
2) List servers 2) List servers
3) Check output 3) Check output
""" """
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('server list' + opts) raw_output = self.openstack('server list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
@ -126,7 +126,7 @@ class ServerTests(test.TestCase):
2) Show server 2) Show server
3) Check output 3) Check output
""" """
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('server show ' + self.NAME + opts) raw_output = self.openstack('server show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)
@ -144,13 +144,13 @@ class ServerTests(test.TestCase):
# metadata # metadata
raw_output = self.openstack( raw_output = self.openstack(
'server set --property a=b --property c=d ' + self.NAME) 'server set --property a=b --property c=d ' + self.NAME)
opts = self.get_show_opts(["name", "properties"]) opts = self.get_opts(["name", "properties"])
raw_output = self.openstack('server show ' + self.NAME + opts) raw_output = self.openstack('server show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output) self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output)
raw_output = self.openstack( raw_output = self.openstack(
'server unset --property a ' + self.NAME) 'server unset --property a ' + self.NAME)
opts = self.get_show_opts(["name", "properties"]) opts = self.get_opts(["name", "properties"])
raw_output = self.openstack('server show ' + self.NAME + opts) raw_output = self.openstack('server show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\nc='d'\n", raw_output) self.assertEqual(self.NAME + "\nc='d'\n", raw_output)
@ -224,7 +224,7 @@ class ServerTests(test.TestCase):
""" """
self.wait_for_status("ACTIVE") self.wait_for_status("ACTIVE")
# rescue # rescue
opts = self.get_show_opts(["adminPass"]) opts = self.get_opts(["adminPass"])
raw_output = self.openstack('server rescue ' + self.NAME + opts) raw_output = self.openstack('server rescue ' + self.NAME + opts)
self.assertNotEqual("", raw_output) self.assertNotEqual("", raw_output)
self.wait_for_status("RESCUE") self.wait_for_status("RESCUE")
@ -248,7 +248,7 @@ class ServerTests(test.TestCase):
""" """
self.wait_for_status("ACTIVE") self.wait_for_status("ACTIVE")
# attach ip # attach ip
opts = self.get_show_opts(["id", "floating_ip_address"]) opts = self.get_opts(["id", "floating_ip_address"])
raw_output = self.openstack('ip floating create ' + raw_output = self.openstack('ip floating create ' +
self.IP_POOL + self.IP_POOL +
opts) opts)
@ -288,7 +288,7 @@ class ServerTests(test.TestCase):
# TODO(thowe): Add a server wait command to osc # TODO(thowe): Add a server wait command to osc
failures = ['ERROR'] failures = ['ERROR']
total_sleep = 0 total_sleep = 0
opts = self.get_show_opts(['status']) opts = self.get_opts(['status'])
while total_sleep < wait: while total_sleep < wait:
status = self.openstack('server show ' + self.NAME + opts) status = self.openstack('server show ' + self.NAME + opts)
status = status.rstrip() status = status.rstrip()

View File

@ -24,7 +24,7 @@ class ServerGroupTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('server group create --policy affinity ' + raw_output = cls.openstack('server group create --policy affinity ' +
cls.NAME + opts) cls.NAME + opts)
expected = cls.NAME + '\n' expected = cls.NAME + '\n'
@ -36,11 +36,11 @@ class ServerGroupTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_server_group_list(self): def test_server_group_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('server group list' + opts) raw_output = self.openstack('server group list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_server_group_show(self): def test_server_group_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('server group show ' + self.NAME + opts) raw_output = self.openstack('server group show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)

View File

@ -27,7 +27,7 @@ class ImageTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
os.environ['OS_IMAGE_API_VERSION'] = '1' os.environ['OS_IMAGE_API_VERSION'] = '1'
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('image create ' + cls.NAME + opts) raw_output = cls.openstack('image create ' + cls.NAME + opts)
expected = cls.NAME + '\n' expected = cls.NAME + '\n'
cls.assertOutput(expected, raw_output) cls.assertOutput(expected, raw_output)
@ -43,17 +43,17 @@ class ImageTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_image_list(self): def test_image_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('image list' + opts) raw_output = self.openstack('image list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_image_show(self): def test_image_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('image show ' + self.NAME + opts) raw_output = self.openstack('image show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)
def test_image_set(self): def test_image_set(self):
opts = self.get_show_opts([ opts = self.get_opts([
"disk_format", "is_public", "min_disk", "min_ram", "name"]) "disk_format", "is_public", "min_disk", "min_ram", "name"])
self.openstack('image set --min-disk 4 --min-ram 5 ' + self.openstack('image set --min-disk 4 --min-ram 5 ' +
'--disk-format qcow2 --public ' + self.NAME) '--disk-format qcow2 --public ' + self.NAME)
@ -61,7 +61,7 @@ class ImageTests(test.TestCase):
self.assertEqual("qcow2\nTrue\n4\n5\n" + self.NAME + '\n', raw_output) self.assertEqual("qcow2\nTrue\n4\n5\n" + self.NAME + '\n', raw_output)
def test_image_metadata(self): def test_image_metadata(self):
opts = self.get_show_opts(["name", "properties"]) opts = self.get_opts(["name", "properties"])
self.openstack('image set --property a=b --property c=d ' + self.NAME) self.openstack('image set --property a=b --property c=d ' + self.NAME)
raw_output = self.openstack('image show ' + self.NAME + opts) raw_output = self.openstack('image show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output) self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output)

View File

@ -29,7 +29,7 @@ class ImageTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
os.environ['OS_IMAGE_API_VERSION'] = '2' os.environ['OS_IMAGE_API_VERSION'] = '2'
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('image create ' + cls.NAME + opts) raw_output = cls.openstack('image create ' + cls.NAME + opts)
expected = cls.NAME + '\n' expected = cls.NAME + '\n'
cls.assertOutput(expected, raw_output) cls.assertOutput(expected, raw_output)
@ -45,17 +45,17 @@ class ImageTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_image_list(self): def test_image_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('image list' + opts) raw_output = self.openstack('image list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_image_show(self): def test_image_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('image show ' + self.NAME + opts) raw_output = self.openstack('image show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)
def test_image_set(self): def test_image_set(self):
opts = self.get_show_opts([ opts = self.get_opts([
"disk_format", "visibility", "min_disk", "min_ram", "name"]) "disk_format", "visibility", "min_disk", "min_ram", "name"])
self.openstack('image set --min-disk 4 --min-ram 5 ' + self.openstack('image set --min-disk 4 --min-ram 5 ' +
'--public ' + self.NAME) '--public ' + self.NAME)
@ -63,14 +63,14 @@ class ImageTests(test.TestCase):
self.assertEqual("raw\n4\n5\n" + self.NAME + '\npublic\n', raw_output) self.assertEqual("raw\n4\n5\n" + self.NAME + '\npublic\n', raw_output)
def test_image_metadata(self): def test_image_metadata(self):
opts = self.get_show_opts(["name", "properties"]) opts = self.get_opts(["name", "properties"])
self.openstack('image set --property a=b --property c=d ' + self.NAME) self.openstack('image set --property a=b --property c=d ' + self.NAME)
raw_output = self.openstack('image show ' + self.NAME + opts) raw_output = self.openstack('image show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output) self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output)
@testtools.skip("skip until bug 1596573 is resolved") @testtools.skip("skip until bug 1596573 is resolved")
def test_image_unset(self): def test_image_unset(self):
opts = self.get_show_opts(["name", "tags", "properties"]) opts = self.get_opts(["name", "tags", "properties"])
self.openstack('image set --tag 01 ' + self.NAME) self.openstack('image set --tag 01 ' + self.NAME)
self.openstack('image unset --tag 01 ' + self.NAME) self.openstack('image unset --tag 01 ' + self.NAME)
# test_image_metadata has set image properties "a" and "c" # test_image_metadata has set image properties "a" and "c"

View File

@ -23,7 +23,7 @@ class AddressScopeTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('address scope create ' + cls.NAME + opts) raw_output = cls.openstack('address scope create ' + cls.NAME + opts)
cls.assertOutput(cls.NAME + "\n", raw_output) cls.assertOutput(cls.NAME + "\n", raw_output)
@ -33,17 +33,17 @@ class AddressScopeTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_address_scope_list(self): def test_address_scope_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('address scope list' + opts) raw_output = self.openstack('address scope list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_address_scope_show(self): def test_address_scope_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('address scope show ' + self.NAME + opts) raw_output = self.openstack('address scope show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)
def test_address_scope_set(self): def test_address_scope_set(self):
self.openstack('address scope set --share ' + self.NAME) self.openstack('address scope set --share ' + self.NAME)
opts = self.get_show_opts(['shared']) opts = self.get_opts(['shared'])
raw_output = self.openstack('address scope show ' + self.NAME + opts) raw_output = self.openstack('address scope show ' + self.NAME + opts)
self.assertEqual("True\n", raw_output) self.assertEqual("True\n", raw_output)

View File

@ -33,7 +33,7 @@ class FloatingIpTests(test.TestCase):
' --subnet-range 10.10.10.0/24 ' + ' --subnet-range 10.10.10.0/24 ' +
cls.SUBNET_NAME cls.SUBNET_NAME
) )
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack( raw_output = cls.openstack(
'ip floating create ' + cls.NETWORK_NAME + opts) 'ip floating create ' + cls.NETWORK_NAME + opts)
cls.ID = raw_output.strip('\n') cls.ID = raw_output.strip('\n')
@ -48,11 +48,11 @@ class FloatingIpTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_floating_ip_list(self): def test_floating_ip_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('ip floating list' + opts) raw_output = self.openstack('ip floating list' + opts)
self.assertIn(self.ID, raw_output) self.assertIn(self.ID, raw_output)
def test_floating_ip_show(self): def test_floating_ip_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('ip floating show ' + self.ID + opts) raw_output = self.openstack('ip floating show ' + self.ID + opts)
self.assertEqual(self.ID + "\n", raw_output) self.assertEqual(self.ID + "\n", raw_output)

View File

@ -25,7 +25,7 @@ class IPAvailabilityTests(test.TestCase):
def setUpClass(cls): def setUpClass(cls):
# Create a network for the subnet. # Create a network for the subnet.
cls.openstack('network create ' + cls.NETWORK_NAME) cls.openstack('network create ' + cls.NETWORK_NAME)
opts = cls.get_show_opts(['name']) opts = cls.get_opts(['name'])
raw_output = cls.openstack( raw_output = cls.openstack(
'subnet create --network ' + cls.NETWORK_NAME + 'subnet create --network ' + cls.NETWORK_NAME +
' --subnet-range 10.10.10.0/24 ' + ' --subnet-range 10.10.10.0/24 ' +
@ -47,7 +47,7 @@ class IPAvailabilityTests(test.TestCase):
self.assertIn(self.NETWORK_NAME, raw_output) self.assertIn(self.NETWORK_NAME, raw_output)
def test_ip_availability_show(self): def test_ip_availability_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack( raw_output = self.openstack(
'ip availability show ' + self.NETWORK_NAME + opts) 'ip availability show ' + self.NETWORK_NAME + opts)
self.assertEqual(self.NETWORK_NAME + "\n", raw_output) self.assertEqual(self.NETWORK_NAME + "\n", raw_output)

View File

@ -23,7 +23,7 @@ class NetworkTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('network create ' + cls.NAME + opts) raw_output = cls.openstack('network create ' + cls.NAME + opts)
expected = cls.NAME + '\n' expected = cls.NAME + '\n'
cls.assertOutput(expected, raw_output) cls.assertOutput(expected, raw_output)
@ -34,17 +34,17 @@ class NetworkTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_network_list(self): def test_network_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('network list' + opts) raw_output = self.openstack('network list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_network_set(self): def test_network_set(self):
raw_output = self.openstack('network set --disable ' + self.NAME) raw_output = self.openstack('network set --disable ' + self.NAME)
opts = self.get_show_opts(['name', 'admin_state_up']) opts = self.get_opts(['name', 'admin_state_up'])
raw_output = self.openstack('network show ' + self.NAME + opts) raw_output = self.openstack('network show ' + self.NAME + opts)
self.assertEqual("DOWN\n" + self.NAME + "\n", raw_output) self.assertEqual("DOWN\n" + self.NAME + "\n", raw_output)
def test_network_show(self): def test_network_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('network show ' + self.NAME + opts) raw_output = self.openstack('network show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)

View File

@ -28,12 +28,12 @@ class NetworkSegmentTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
# Create a network for the segment. # Create a network for the segment.
opts = cls.get_show_opts(['id']) opts = cls.get_opts(['id'])
raw_output = cls.openstack('network create ' + cls.NETWORK_NAME + opts) raw_output = cls.openstack('network create ' + cls.NETWORK_NAME + opts)
cls.NETWORK_ID = raw_output.strip('\n') cls.NETWORK_ID = raw_output.strip('\n')
# Get the segment for the network. # Get the segment for the network.
opts = cls.get_show_opts(['ID', 'Network']) opts = cls.get_opts(['ID', 'Network'])
raw_output = cls.openstack('--os-beta-command ' raw_output = cls.openstack('--os-beta-command '
'network segment list ' 'network segment list '
' --network ' + cls.NETWORK_NAME + ' --network ' + cls.NETWORK_NAME +
@ -47,13 +47,13 @@ class NetworkSegmentTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_network_segment_list(self): def test_network_segment_list(self):
opts = self.get_list_opts(['ID']) opts = self.get_opts(['ID'])
raw_output = self.openstack('--os-beta-command ' raw_output = self.openstack('--os-beta-command '
'network segment list' + opts) 'network segment list' + opts)
self.assertIn(self.NETWORK_SEGMENT_ID, raw_output) self.assertIn(self.NETWORK_SEGMENT_ID, raw_output)
def test_network_segment_show(self): def test_network_segment_show(self):
opts = self.get_show_opts(['network_id']) opts = self.get_opts(['network_id'])
raw_output = self.openstack('--os-beta-command ' raw_output = self.openstack('--os-beta-command '
'network segment show ' + 'network segment show ' +
self.NETWORK_SEGMENT_ID + opts) self.NETWORK_SEGMENT_ID + opts)

View File

@ -26,7 +26,7 @@ class PortTests(test.TestCase):
def setUpClass(cls): def setUpClass(cls):
# Create a network for the subnet. # Create a network for the subnet.
cls.openstack('network create ' + cls.NETWORK_NAME) cls.openstack('network create ' + cls.NETWORK_NAME)
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack( raw_output = cls.openstack(
'port create --network ' + cls.NETWORK_NAME + ' ' + 'port create --network ' + cls.NETWORK_NAME + ' ' +
cls.NAME + opts cls.NAME + opts
@ -42,17 +42,17 @@ class PortTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_port_list(self): def test_port_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('port list' + opts) raw_output = self.openstack('port list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_port_set(self): def test_port_set(self):
self.openstack('port set --disable ' + self.NAME) self.openstack('port set --disable ' + self.NAME)
opts = self.get_show_opts(['name', 'admin_state_up']) opts = self.get_opts(['name', 'admin_state_up'])
raw_output = self.openstack('port show ' + self.NAME + opts) raw_output = self.openstack('port show ' + self.NAME + opts)
self.assertEqual("DOWN\n" + self.NAME + "\n", raw_output) self.assertEqual("DOWN\n" + self.NAME + "\n", raw_output)
def test_port_show(self): def test_port_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('port show ' + self.NAME + opts) raw_output = self.openstack('port show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)

View File

@ -23,7 +23,7 @@ class RouterTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('router create ' + cls.NAME + opts) raw_output = cls.openstack('router create ' + cls.NAME + opts)
expected = cls.NAME + '\n' expected = cls.NAME + '\n'
cls.assertOutput(expected, raw_output) cls.assertOutput(expected, raw_output)
@ -34,17 +34,17 @@ class RouterTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_router_list(self): def test_router_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('router list' + opts) raw_output = self.openstack('router list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_router_set(self): def test_router_set(self):
self.openstack('router set --disable ' + self.NAME) self.openstack('router set --disable ' + self.NAME)
opts = self.get_show_opts(['name', 'admin_state_up']) opts = self.get_opts(['name', 'admin_state_up'])
raw_output = self.openstack('router show ' + self.NAME + opts) raw_output = self.openstack('router show ' + self.NAME + opts)
self.assertEqual("DOWN\n" + self.NAME + "\n", raw_output) self.assertEqual("DOWN\n" + self.NAME + "\n", raw_output)
def test_router_show(self): def test_router_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('router show ' + self.NAME + opts) raw_output = self.openstack('router show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)

View File

@ -24,7 +24,7 @@ class SecurityGroupTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('security group create ' + cls.NAME + opts) raw_output = cls.openstack('security group create ' + cls.NAME + opts)
expected = cls.NAME + '\n' expected = cls.NAME + '\n'
cls.assertOutput(expected, raw_output) cls.assertOutput(expected, raw_output)
@ -40,7 +40,7 @@ class SecurityGroupTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_security_group_list(self): def test_security_group_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('security group list' + opts) raw_output = self.openstack('security group list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
@ -50,11 +50,11 @@ class SecurityGroupTests(test.TestCase):
) )
self.assertEqual('', raw_output) self.assertEqual('', raw_output)
opts = self.get_show_opts(['description']) opts = self.get_opts(['description'])
raw_output = self.openstack('security group show ' + self.NAME + opts) raw_output = self.openstack('security group show ' + self.NAME + opts)
self.assertEqual("NSA\n", raw_output) self.assertEqual("NSA\n", raw_output)
def test_security_group_show(self): def test_security_group_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('security group show ' + self.NAME + opts) raw_output = self.openstack('security group show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)

View File

@ -26,7 +26,7 @@ class SecurityGroupRuleTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
# Create the security group to hold the rule. # Create the security group to hold the rule.
opts = cls.get_show_opts(cls.NAME_FIELD) opts = cls.get_opts(cls.NAME_FIELD)
raw_output = cls.openstack('security group create ' + raw_output = cls.openstack('security group create ' +
cls.SECURITY_GROUP_NAME + cls.SECURITY_GROUP_NAME +
opts) opts)
@ -34,7 +34,7 @@ class SecurityGroupRuleTests(test.TestCase):
cls.assertOutput(expected, raw_output) cls.assertOutput(expected, raw_output)
# Create the security group rule. # Create the security group rule.
opts = cls.get_show_opts(cls.ID_FIELD) opts = cls.get_opts(cls.ID_FIELD)
raw_output = cls.openstack('security group rule create ' + raw_output = cls.openstack('security group rule create ' +
cls.SECURITY_GROUP_NAME + cls.SECURITY_GROUP_NAME +
' --protocol tcp --dst-port 80:80' + ' --protocol tcp --dst-port 80:80' +
@ -53,14 +53,14 @@ class SecurityGroupRuleTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_security_group_rule_list(self): def test_security_group_rule_list(self):
opts = self.get_list_opts(self.ID_HEADER) opts = self.get_opts(self.ID_HEADER)
raw_output = self.openstack('security group rule list ' + raw_output = self.openstack('security group rule list ' +
self.SECURITY_GROUP_NAME + self.SECURITY_GROUP_NAME +
opts) opts)
self.assertIn(self.SECURITY_GROUP_RULE_ID, raw_output) self.assertIn(self.SECURITY_GROUP_RULE_ID, raw_output)
def test_security_group_rule_show(self): def test_security_group_rule_show(self):
opts = self.get_show_opts(self.ID_FIELD) opts = self.get_opts(self.ID_FIELD)
raw_output = self.openstack('security group rule show ' + raw_output = self.openstack('security group rule show ' +
self.SECURITY_GROUP_RULE_ID + self.SECURITY_GROUP_RULE_ID +
opts) opts)

View File

@ -26,7 +26,7 @@ class SubnetTests(test.TestCase):
def setUpClass(cls): def setUpClass(cls):
# Create a network for the subnet. # Create a network for the subnet.
cls.openstack('network create ' + cls.NETWORK_NAME) cls.openstack('network create ' + cls.NETWORK_NAME)
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack( raw_output = cls.openstack(
'subnet create --network ' + cls.NETWORK_NAME + 'subnet create --network ' + cls.NETWORK_NAME +
' --subnet-range 10.10.10.0/24 ' + ' --subnet-range 10.10.10.0/24 ' +
@ -43,17 +43,17 @@ class SubnetTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_subnet_list(self): def test_subnet_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('subnet list' + opts) raw_output = self.openstack('subnet list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_subnet_set(self): def test_subnet_set(self):
self.openstack('subnet set --no-dhcp ' + self.NAME) self.openstack('subnet set --no-dhcp ' + self.NAME)
opts = self.get_show_opts(['name', 'enable_dhcp']) opts = self.get_opts(['name', 'enable_dhcp'])
raw_output = self.openstack('subnet show ' + self.NAME + opts) raw_output = self.openstack('subnet show ' + self.NAME + opts)
self.assertEqual("False\n" + self.NAME + "\n", raw_output) self.assertEqual("False\n" + self.NAME + "\n", raw_output)
def test_subnet_show(self): def test_subnet_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('subnet show ' + self.NAME + opts) raw_output = self.openstack('subnet show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)

View File

@ -25,7 +25,7 @@ class SubnetPoolTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('subnet pool create --pool-prefix ' + raw_output = cls.openstack('subnet pool create --pool-prefix ' +
cls.CREATE_POOL_PREFIX + ' ' + cls.CREATE_POOL_PREFIX + ' ' +
cls.NAME + opts) cls.NAME + opts)
@ -37,19 +37,19 @@ class SubnetPoolTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_subnet_list(self): def test_subnet_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('subnet pool list' + opts) raw_output = self.openstack('subnet pool list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_subnet_set(self): def test_subnet_set(self):
self.openstack('subnet pool set --pool-prefix ' + self.openstack('subnet pool set --pool-prefix ' +
self.SET_POOL_PREFIX + ' ' + self.NAME) self.SET_POOL_PREFIX + ' ' + self.NAME)
opts = self.get_show_opts(['prefixes', 'name']) opts = self.get_opts(['prefixes', 'name'])
raw_output = self.openstack('subnet pool show ' + self.NAME + opts) raw_output = self.openstack('subnet pool show ' + self.NAME + opts)
self.assertEqual(self.NAME + '\n' + self.SET_POOL_PREFIX + '\n', self.assertEqual(self.NAME + '\n' + self.SET_POOL_PREFIX + '\n',
raw_output) raw_output)
def test_subnet_show(self): def test_subnet_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('subnet pool show ' + self.NAME + opts) raw_output = self.openstack('subnet pool show ' + self.NAME + opts)
self.assertEqual(self.NAME + '\n', raw_output) self.assertEqual(self.NAME + '\n', raw_output)

View File

@ -21,10 +21,9 @@ class ContainerTests(test.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
opts = cls.get_list_opts(['container']) opts = cls.get_opts(['container'])
raw_output = cls.openstack('container create ' + cls.NAME + opts) raw_output = cls.openstack('container create ' + cls.NAME + opts)
expected = '"container"\n"' + cls.NAME + '"\n' cls.assertOutput(cls.NAME + '\n', raw_output)
cls.assertOutput(expected, raw_output)
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
@ -32,11 +31,11 @@ class ContainerTests(test.TestCase):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_container_list(self): def test_container_list(self):
opts = self.get_list_opts(['Name']) opts = self.get_opts(['Name'])
raw_output = self.openstack('container list' + opts) raw_output = self.openstack('container list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_container_show(self): def test_container_show(self):
opts = self.get_show_opts(['container']) opts = self.get_opts(['container'])
raw_output = self.openstack('container show ' + self.NAME + opts) raw_output = self.openstack('container show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)

View File

@ -26,7 +26,7 @@ class QosTests(common.BaseVolumeTests):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(QosTests, cls).setUpClass() super(QosTests, cls).setUpClass()
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('volume qos create ' + cls.NAME + opts) raw_output = cls.openstack('volume qos create ' + cls.NAME + opts)
cls.ID, name, rol = raw_output.split('\n') cls.ID, name, rol = raw_output.split('\n')
cls.assertOutput(cls.NAME, name) cls.assertOutput(cls.NAME, name)
@ -37,12 +37,12 @@ class QosTests(common.BaseVolumeTests):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_volume_qos_list(self): def test_volume_qos_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('volume qos list' + opts) raw_output = self.openstack('volume qos list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_volume_qos_show(self): def test_volume_qos_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('volume qos show ' + self.ID + opts) raw_output = self.openstack('volume qos show ' + self.ID + opts)
self.assertEqual(self.ID + "\n" + self.NAME + "\n", raw_output) self.assertEqual(self.ID + "\n" + self.NAME + "\n", raw_output)
@ -50,6 +50,6 @@ class QosTests(common.BaseVolumeTests):
raw_output = self.openstack( raw_output = self.openstack(
'volume qos set --property a=b --property c=d ' + self.ID) 'volume qos set --property a=b --property c=d ' + self.ID)
self.assertEqual("", raw_output) self.assertEqual("", raw_output)
opts = self.get_show_opts(['name', 'specs']) opts = self.get_opts(['name', 'specs'])
raw_output = self.openstack('volume qos show ' + self.ID + opts) raw_output = self.openstack('volume qos show ' + self.ID + opts)
self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output) self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output)

View File

@ -26,7 +26,7 @@ class VolumeTests(common.BaseVolumeTests):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(VolumeTests, cls).setUpClass() super(VolumeTests, cls).setUpClass()
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('volume create --size 1 ' + cls.NAME + opts) raw_output = cls.openstack('volume create --size 1 ' + cls.NAME + opts)
expected = cls.NAME + '\n' expected = cls.NAME + '\n'
cls.assertOutput(expected, raw_output) cls.assertOutput(expected, raw_output)
@ -42,12 +42,12 @@ class VolumeTests(common.BaseVolumeTests):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_volume_list(self): def test_volume_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('volume list' + opts) raw_output = self.openstack('volume list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_volume_show(self): def test_volume_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('volume show ' + self.NAME + opts) raw_output = self.openstack('volume show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)
@ -55,7 +55,7 @@ class VolumeTests(common.BaseVolumeTests):
raw_output = self.openstack( raw_output = self.openstack(
'volume set --property a=b --property c=d ' + self.NAME) 'volume set --property a=b --property c=d ' + self.NAME)
self.assertEqual("", raw_output) self.assertEqual("", raw_output)
opts = self.get_show_opts(["properties"]) opts = self.get_opts(["properties"])
raw_output = self.openstack('volume show ' + self.NAME + opts) raw_output = self.openstack('volume show ' + self.NAME + opts)
self.assertEqual("a='b', c='d'\n", raw_output) self.assertEqual("a='b', c='d'\n", raw_output)
@ -66,12 +66,12 @@ class VolumeTests(common.BaseVolumeTests):
def test_volume_set(self): def test_volume_set(self):
self.openstack('volume set --description RAMAC ' + self.NAME) self.openstack('volume set --description RAMAC ' + self.NAME)
opts = self.get_show_opts(["display_description", "display_name"]) opts = self.get_opts(["display_description", "display_name"])
raw_output = self.openstack('volume show ' + self.NAME + opts) raw_output = self.openstack('volume show ' + self.NAME + opts)
self.assertEqual("RAMAC\n" + self.NAME + "\n", raw_output) self.assertEqual("RAMAC\n" + self.NAME + "\n", raw_output)
def test_volume_set_size(self): def test_volume_set_size(self):
self.openstack('volume set --size 2 ' + self.NAME) self.openstack('volume set --size 2 ' + self.NAME)
opts = self.get_show_opts(["display_name", "size"]) opts = self.get_opts(["display_name", "size"])
raw_output = self.openstack('volume show ' + self.NAME + opts) raw_output = self.openstack('volume show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n2\n", raw_output) self.assertEqual(self.NAME + "\n2\n", raw_output)

View File

@ -26,7 +26,7 @@ class VolumeTypeTests(common.BaseVolumeTests):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(VolumeTypeTests, cls).setUpClass() super(VolumeTypeTests, cls).setUpClass()
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('volume type create ' + cls.NAME + opts) raw_output = cls.openstack('volume type create ' + cls.NAME + opts)
expected = cls.NAME + '\n' expected = cls.NAME + '\n'
cls.assertOutput(expected, raw_output) cls.assertOutput(expected, raw_output)
@ -37,12 +37,12 @@ class VolumeTypeTests(common.BaseVolumeTests):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_volume_type_list(self): def test_volume_type_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('volume type list' + opts) raw_output = self.openstack('volume type list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_volume_type_show(self): def test_volume_type_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('volume type show ' + self.NAME + opts) raw_output = self.openstack('volume type show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)
@ -51,7 +51,7 @@ class VolumeTypeTests(common.BaseVolumeTests):
'volume type set --property a=b --property c=d ' + self.NAME) 'volume type set --property a=b --property c=d ' + self.NAME)
self.assertEqual("", raw_output) self.assertEqual("", raw_output)
opts = self.get_show_opts(["properties"]) opts = self.get_opts(["properties"])
raw_output = self.openstack('volume type show ' + self.NAME + opts) raw_output = self.openstack('volume type show ' + self.NAME + opts)
self.assertEqual("a='b', c='d'\n", raw_output) self.assertEqual("a='b', c='d'\n", raw_output)

View File

@ -26,7 +26,7 @@ class QosTests(common.BaseVolumeTests):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(QosTests, cls).setUpClass() super(QosTests, cls).setUpClass()
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('volume qos create ' + cls.NAME + opts) raw_output = cls.openstack('volume qos create ' + cls.NAME + opts)
cls.ID, name, rol = raw_output.split('\n') cls.ID, name, rol = raw_output.split('\n')
cls.assertOutput(cls.NAME, name) cls.assertOutput(cls.NAME, name)
@ -37,12 +37,12 @@ class QosTests(common.BaseVolumeTests):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_volume_qos_list(self): def test_volume_qos_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('volume qos list' + opts) raw_output = self.openstack('volume qos list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_volume_qos_show(self): def test_volume_qos_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('volume qos show ' + self.ID + opts) raw_output = self.openstack('volume qos show ' + self.ID + opts)
self.assertEqual(self.ID + "\n" + self.NAME + "\n", raw_output) self.assertEqual(self.ID + "\n" + self.NAME + "\n", raw_output)
@ -50,13 +50,13 @@ class QosTests(common.BaseVolumeTests):
raw_output = self.openstack( raw_output = self.openstack(
'volume qos set --property a=b --property c=d ' + self.ID) 'volume qos set --property a=b --property c=d ' + self.ID)
self.assertEqual("", raw_output) self.assertEqual("", raw_output)
opts = self.get_show_opts(['name', 'specs']) opts = self.get_opts(['name', 'specs'])
raw_output = self.openstack('volume qos show ' + self.ID + opts) raw_output = self.openstack('volume qos show ' + self.ID + opts)
self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output) self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output)
raw_output = self.openstack( raw_output = self.openstack(
'volume qos unset --property a ' + self.ID) 'volume qos unset --property a ' + self.ID)
self.assertEqual("", raw_output) self.assertEqual("", raw_output)
opts = self.get_show_opts(['name', 'specs']) opts = self.get_opts(['name', 'specs'])
raw_output = self.openstack('volume qos show ' + self.ID + opts) raw_output = self.openstack('volume qos show ' + self.ID + opts)
self.assertEqual(self.NAME + "\nc='d'\n", raw_output) self.assertEqual(self.NAME + "\nc='d'\n", raw_output)

View File

@ -26,7 +26,7 @@ class SnapshotTests(common.BaseVolumeTests):
@classmethod @classmethod
def wait_for_status(cls, command, status, tries): def wait_for_status(cls, command, status, tries):
opts = cls.get_show_opts(['status']) opts = cls.get_opts(['status'])
for attempt in range(tries): for attempt in range(tries):
time.sleep(1) time.sleep(1)
raw_output = cls.openstack(command + opts) raw_output = cls.openstack(command + opts)
@ -39,7 +39,7 @@ class SnapshotTests(common.BaseVolumeTests):
super(SnapshotTests, cls).setUpClass() super(SnapshotTests, cls).setUpClass()
cls.openstack('volume create --size 1 ' + cls.VOLLY) cls.openstack('volume create --size 1 ' + cls.VOLLY)
cls.wait_for_status('volume show ' + cls.VOLLY, 'available\n', 3) cls.wait_for_status('volume show ' + cls.VOLLY, 'available\n', 3)
opts = cls.get_show_opts(['status']) opts = cls.get_opts(['status'])
raw_output = cls.openstack('snapshot create --name ' + cls.NAME + raw_output = cls.openstack('snapshot create --name ' + cls.NAME +
' ' + cls.VOLLY + opts) ' ' + cls.VOLLY + opts)
cls.assertOutput('creating\n', raw_output) cls.assertOutput('creating\n', raw_output)
@ -57,7 +57,7 @@ class SnapshotTests(common.BaseVolumeTests):
cls.openstack('volume delete --force ' + cls.VOLLY, fail_ok=True) cls.openstack('volume delete --force ' + cls.VOLLY, fail_ok=True)
def test_snapshot_list(self): def test_snapshot_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('snapshot list' + opts) raw_output = self.openstack('snapshot list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
@ -65,7 +65,7 @@ class SnapshotTests(common.BaseVolumeTests):
raw_output = self.openstack( raw_output = self.openstack(
'snapshot set --property a=b --property c=d ' + self.NAME) 'snapshot set --property a=b --property c=d ' + self.NAME)
self.assertEqual("", raw_output) self.assertEqual("", raw_output)
opts = self.get_show_opts(["properties"]) opts = self.get_opts(["properties"])
raw_output = self.openstack('snapshot show ' + self.NAME + opts) raw_output = self.openstack('snapshot show ' + self.NAME + opts)
self.assertEqual("a='b', c='d'\n", raw_output) self.assertEqual("a='b', c='d'\n", raw_output)
@ -78,6 +78,6 @@ class SnapshotTests(common.BaseVolumeTests):
raw_output = self.openstack( raw_output = self.openstack(
'snapshot set --description backup ' + self.NAME) 'snapshot set --description backup ' + self.NAME)
self.assertEqual("", raw_output) self.assertEqual("", raw_output)
opts = self.get_show_opts(["description", "name"]) opts = self.get_opts(["description", "name"])
raw_output = self.openstack('snapshot show ' + self.NAME + opts) raw_output = self.openstack('snapshot show ' + self.NAME + opts)
self.assertEqual("backup\n" + self.NAME + "\n", raw_output) self.assertEqual("backup\n" + self.NAME + "\n", raw_output)

View File

@ -29,7 +29,7 @@ class VolumeTests(common.BaseVolumeTests):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(VolumeTests, cls).setUpClass() super(VolumeTests, cls).setUpClass()
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
# Create test volume # Create test volume
raw_output = cls.openstack('volume create --size 1 ' + cls.NAME + opts) raw_output = cls.openstack('volume create --size 1 ' + cls.NAME + opts)
@ -48,12 +48,12 @@ class VolumeTests(common.BaseVolumeTests):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_volume_list(self): def test_volume_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('volume list' + opts) raw_output = self.openstack('volume list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_volume_show(self): def test_volume_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('volume show ' + self.NAME + opts) raw_output = self.openstack('volume show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)
@ -61,7 +61,7 @@ class VolumeTests(common.BaseVolumeTests):
raw_output = self.openstack( raw_output = self.openstack(
'volume set --property a=b --property c=d ' + self.NAME) 'volume set --property a=b --property c=d ' + self.NAME)
self.assertEqual("", raw_output) self.assertEqual("", raw_output)
opts = self.get_show_opts(["properties"]) opts = self.get_opts(["properties"])
raw_output = self.openstack('volume show ' + self.NAME + opts) raw_output = self.openstack('volume show ' + self.NAME + opts)
self.assertEqual("a='b', c='d'\n", raw_output) self.assertEqual("a='b', c='d'\n", raw_output)
@ -74,18 +74,18 @@ class VolumeTests(common.BaseVolumeTests):
discription = uuid.uuid4().hex discription = uuid.uuid4().hex
self.openstack('volume set --description ' + discription + ' ' + self.openstack('volume set --description ' + discription + ' ' +
self.NAME) self.NAME)
opts = self.get_show_opts(["description", "name"]) opts = self.get_opts(["description", "name"])
raw_output = self.openstack('volume show ' + self.NAME + opts) raw_output = self.openstack('volume show ' + self.NAME + opts)
self.assertEqual(discription + "\n" + self.NAME + "\n", raw_output) self.assertEqual(discription + "\n" + self.NAME + "\n", raw_output)
def test_volume_set_size(self): def test_volume_set_size(self):
self.openstack('volume set --size 2 ' + self.NAME) self.openstack('volume set --size 2 ' + self.NAME)
opts = self.get_show_opts(["name", "size"]) opts = self.get_opts(["name", "size"])
raw_output = self.openstack('volume show ' + self.NAME + opts) raw_output = self.openstack('volume show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n2\n", raw_output) self.assertEqual(self.NAME + "\n2\n", raw_output)
def test_volume_snapshot(self): def test_volume_snapshot(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
# Create snapshot from test volume # Create snapshot from test volume
raw_output = self.openstack('snapshot create ' + self.NAME + raw_output = self.openstack('snapshot create ' + self.NAME +
@ -116,7 +116,7 @@ class VolumeTests(common.BaseVolumeTests):
interval=5, failures=['ERROR']): interval=5, failures=['ERROR']):
status = "notset" status = "notset"
total_sleep = 0 total_sleep = 0
opts = self.get_show_opts(['status']) opts = self.get_opts(['status'])
while total_sleep < wait: while total_sleep < wait:
status = self.openstack(check_type + ' show ' + check_name + opts) status = self.openstack(check_type + ' show ' + check_name + opts)
status = status.rstrip() status = status.rstrip()

View File

@ -26,7 +26,7 @@ class VolumeTypeTests(common.BaseVolumeTests):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(VolumeTypeTests, cls).setUpClass() super(VolumeTypeTests, cls).setUpClass()
opts = cls.get_show_opts(cls.FIELDS) opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack( raw_output = cls.openstack(
'volume type create --private ' + cls.NAME + opts) 'volume type create --private ' + cls.NAME + opts)
expected = cls.NAME + '\n' expected = cls.NAME + '\n'
@ -38,12 +38,12 @@ class VolumeTypeTests(common.BaseVolumeTests):
cls.assertOutput('', raw_output) cls.assertOutput('', raw_output)
def test_volume_type_list(self): def test_volume_type_list(self):
opts = self.get_list_opts(self.HEADERS) opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('volume type list' + opts) raw_output = self.openstack('volume type list' + opts)
self.assertIn(self.NAME, raw_output) self.assertIn(self.NAME, raw_output)
def test_volume_type_show(self): def test_volume_type_show(self):
opts = self.get_show_opts(self.FIELDS) opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('volume type show ' + self.NAME + opts) raw_output = self.openstack('volume type show ' + self.NAME + opts)
self.assertEqual(self.NAME + "\n", raw_output) self.assertEqual(self.NAME + "\n", raw_output)
@ -52,7 +52,7 @@ class VolumeTypeTests(common.BaseVolumeTests):
'volume type set --property a=b --property c=d ' + self.NAME) 'volume type set --property a=b --property c=d ' + self.NAME)
self.assertEqual("", raw_output) self.assertEqual("", raw_output)
opts = self.get_show_opts(["properties"]) opts = self.get_opts(["properties"])
raw_output = self.openstack('volume type show ' + self.NAME + opts) raw_output = self.openstack('volume type show ' + self.NAME + opts)
self.assertEqual("a='b', c='d'\n", raw_output) self.assertEqual("a='b', c='d'\n", raw_output)