tests: Convert volume tests to use 'parse_output'
Change-Id: Iec8ca873f6bc3993e0ba557f68895d9aefb6f9c6 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
dc03ce98de
commit
686fabef31
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import time
|
||||
|
||||
from openstackclient.tests.functional import base
|
||||
@ -27,10 +26,12 @@ class BaseVolumeTests(base.TestCase):
|
||||
failures = ['error']
|
||||
total_sleep = 0
|
||||
while total_sleep < wait:
|
||||
output = json.loads(cls.openstack(
|
||||
check_type + ' show -f json ' + check_name))
|
||||
output = cls.openstack(
|
||||
check_type + ' show ' + check_name,
|
||||
parse_output=True,
|
||||
)
|
||||
current_status = output['status']
|
||||
if (current_status == desired_status):
|
||||
if current_status == desired_status:
|
||||
print('{} {} now has status {}'
|
||||
.format(check_type, check_name, current_status))
|
||||
return
|
||||
@ -51,7 +52,7 @@ class BaseVolumeTests(base.TestCase):
|
||||
total_sleep = 0
|
||||
name_field = name_field or 'Name'
|
||||
while total_sleep < wait:
|
||||
result = json.loads(cls.openstack(check_type + ' list -f json'))
|
||||
result = cls.openstack(check_type + ' list', parse_output=True)
|
||||
names = [x[name_field] for x in result]
|
||||
if check_name not in names:
|
||||
print('{} {} is now deleted'.format(check_type, check_name))
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v1 import common
|
||||
@ -22,29 +21,32 @@ class QosTests(common.BaseVolumeTests):
|
||||
def test_volume_qos_create_list(self):
|
||||
"""Test create, list, delete multiple"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos create -f json ' +
|
||||
name1
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos create ' +
|
||||
name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name1,
|
||||
cmd_output['name']
|
||||
)
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos create -f json ' +
|
||||
name2
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos create ' +
|
||||
name2,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name2,
|
||||
cmd_output['name']
|
||||
)
|
||||
|
||||
# Test list
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos list -f json'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos list',
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
@ -57,12 +59,13 @@ class QosTests(common.BaseVolumeTests):
|
||||
"""Tests create volume qos, set, unset, show, delete"""
|
||||
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume qos create ' +
|
||||
'--consumer front-end '
|
||||
'--property Alpha=a ' +
|
||||
name
|
||||
))
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume qos delete ' + name)
|
||||
self.assertEqual(
|
||||
name,
|
||||
@ -84,10 +87,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
# Test volume qos show
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name,
|
||||
cmd_output['name']
|
||||
@ -105,10 +109,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name,
|
||||
cmd_output['name']
|
||||
|
@ -10,8 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
from openstackclient.tests.functional.volume.v1 import common
|
||||
|
||||
|
||||
@ -19,18 +17,18 @@ class VolumeServiceTests(common.BaseVolumeTests):
|
||||
"""Functional tests for volume service."""
|
||||
|
||||
def test_volume_service_list(self):
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume service list -f json'))
|
||||
cmd_output = self.openstack('volume service list', parse_output=True)
|
||||
|
||||
# Get the nonredundant services and hosts
|
||||
services = list(set([x['Binary'] for x in cmd_output]))
|
||||
|
||||
# Test volume service list --service
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume service list -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume service list ' +
|
||||
'--service ' +
|
||||
services[0]
|
||||
))
|
||||
services[0],
|
||||
parse_output=True,
|
||||
)
|
||||
for x in cmd_output:
|
||||
self.assertEqual(
|
||||
services[0],
|
||||
@ -43,9 +41,10 @@ class VolumeServiceTests(common.BaseVolumeTests):
|
||||
def test_volume_service_set(self):
|
||||
|
||||
# Get a service and host
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume service list -f json'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume service list',
|
||||
parse_output=True,
|
||||
)
|
||||
service_1 = cmd_output[0]['Binary']
|
||||
host_1 = cmd_output[0]['Host']
|
||||
|
||||
@ -57,9 +56,10 @@ class VolumeServiceTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume service list -f json --long'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume service list --long',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
'enabled',
|
||||
cmd_output[0]['Status']
|
||||
@ -77,9 +77,10 @@ class VolumeServiceTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume service list -f json --long'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume service list --long',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
'disabled',
|
||||
cmd_output[0]['Status']
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v1 import common
|
||||
@ -25,11 +24,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
def setUpClass(cls):
|
||||
super(VolumeSnapshotTests, cls).setUpClass()
|
||||
# create a volume for all tests to create snapshot
|
||||
cmd_output = json.loads(cls.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = cls.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
cls.VOLLY
|
||||
))
|
||||
cls.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
cls.wait_for_status('volume', cls.VOLLY, 'available')
|
||||
cls.VOLUME_ID = cmd_output['id']
|
||||
|
||||
@ -45,22 +45,24 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
def test_volume_snapshot_delete(self):
|
||||
"""Test create, delete multiple"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
name1 +
|
||||
' --volume ' + self.VOLLY
|
||||
))
|
||||
' --volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name1,
|
||||
cmd_output["display_name"],
|
||||
)
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
name2 +
|
||||
' --volume ' + self.VOLLY
|
||||
))
|
||||
' --volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name2,
|
||||
cmd_output["display_name"],
|
||||
@ -78,11 +80,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
def test_volume_snapshot_list(self):
|
||||
"""Test create, list filter"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
name1 +
|
||||
' --volume ' + self.VOLLY
|
||||
))
|
||||
' --volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.wait_for_delete, 'volume snapshot', name1)
|
||||
self.addCleanup(self.openstack, 'volume snapshot delete ' + name1)
|
||||
self.assertEqual(
|
||||
@ -100,11 +103,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
self.wait_for_status('volume snapshot', name1, 'available')
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
name2 +
|
||||
' --volume ' + self.VOLLY
|
||||
))
|
||||
' --volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.wait_for_delete, 'volume snapshot', name2)
|
||||
self.addCleanup(self.openstack, 'volume snapshot delete ' + name2)
|
||||
self.assertEqual(
|
||||
@ -122,29 +126,32 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
self.wait_for_status('volume snapshot', name2, 'available')
|
||||
|
||||
# Test list --long, --status
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot list -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot list ' +
|
||||
'--long ' +
|
||||
'--status error'
|
||||
))
|
||||
'--status error',
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertNotIn(name1, names)
|
||||
self.assertNotIn(name2, names)
|
||||
|
||||
# Test list --volume
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot list -f json ' +
|
||||
'--volume ' + self.VOLLY
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot list ' +
|
||||
'--volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
|
||||
# Test list --name
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot list -f json ' +
|
||||
'--name ' + name1
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot list ' +
|
||||
'--name ' + name1,
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertNotIn(name2, names)
|
||||
@ -153,12 +160,13 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
"""Test create, set, unset, show, delete volume snapshot"""
|
||||
name = uuid.uuid4().hex
|
||||
new_name = name + "_"
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
'--volume ' + self.VOLLY +
|
||||
' --description aaaa ' +
|
||||
name
|
||||
))
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.wait_for_delete, 'volume snapshot', new_name)
|
||||
self.addCleanup(self.openstack, 'volume snapshot delete ' + new_name)
|
||||
self.assertEqual(
|
||||
@ -187,10 +195,11 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
# Show snapshot set result
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
new_name,
|
||||
cmd_output["display_name"],
|
||||
@ -216,10 +225,11 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
{'Beta': 'b'},
|
||||
cmd_output["properties"],
|
||||
@ -232,8 +242,9 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
new_name,
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({}, cmd_output["properties"])
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v1 import common
|
||||
@ -25,8 +24,10 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TransferRequestTests, cls).setUpClass()
|
||||
cmd_output = json.loads(cls.openstack(
|
||||
'volume create -f json --size 1 ' + cls.VOLUME_NAME))
|
||||
cmd_output = cls.openstack(
|
||||
'volume create --size 1 ' + cls.VOLUME_NAME,
|
||||
parse_output=True,
|
||||
)
|
||||
cls.assertOutput(cls.VOLUME_NAME, cmd_output['name'])
|
||||
|
||||
cls.wait_for_status("volume", cls.VOLUME_NAME, "available")
|
||||
@ -45,26 +46,31 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
name = uuid.uuid4().hex
|
||||
|
||||
# create a volume
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json --size 1 ' + volume_name))
|
||||
cmd_output = self.openstack(
|
||||
'volume create --size 1 ' + volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(volume_name, cmd_output['name'])
|
||||
|
||||
# create volume transfer request for the volume
|
||||
# and get the auth_key of the new transfer request
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume transfer request create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume transfer request create ' +
|
||||
volume_name +
|
||||
' --name ' + name))
|
||||
' --name ' + name,
|
||||
parse_output=True,
|
||||
)
|
||||
auth_key = cmd_output['auth_key']
|
||||
self.assertTrue(auth_key)
|
||||
|
||||
# accept the volume transfer request
|
||||
json_output = json.loads(self.openstack(
|
||||
'volume transfer request accept -f json ' +
|
||||
output = self.openstack(
|
||||
'volume transfer request accept ' +
|
||||
name + ' ' +
|
||||
'--auth-key ' + auth_key
|
||||
))
|
||||
self.assertEqual(name, json_output.get('name'))
|
||||
'--auth-key ' + auth_key,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(name, output.get('name'))
|
||||
|
||||
# the volume transfer will be removed by default after accepted
|
||||
# so just need to delete the volume here
|
||||
@ -74,11 +80,12 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
|
||||
def test_volume_transfer_request_list_show(self):
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume transfer request create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume transfer request create ' +
|
||||
' --name ' + name + ' ' +
|
||||
self.VOLUME_NAME
|
||||
))
|
||||
self.VOLUME_NAME,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume transfer request delete ' + name
|
||||
@ -87,13 +94,15 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
auth_key = cmd_output['auth_key']
|
||||
self.assertTrue(auth_key)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume transfer request list -f json'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume transfer request list',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIn(name, [req['Name'] for req in cmd_output])
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume transfer request show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume transfer request show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(name, cmd_output['name'])
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v1 import common
|
||||
@ -22,22 +21,24 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
def test_volume_create_and_delete(self):
|
||||
"""Test create, delete multiple"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
name1
|
||||
))
|
||||
name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
1,
|
||||
cmd_output["size"],
|
||||
)
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 2 ' +
|
||||
name2
|
||||
))
|
||||
name2,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
2,
|
||||
cmd_output["size"],
|
||||
@ -51,11 +52,12 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
def test_volume_list(self):
|
||||
"""Test create, list filter"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
name1
|
||||
))
|
||||
name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + name1)
|
||||
self.assertEqual(
|
||||
1,
|
||||
@ -64,11 +66,12 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
self.wait_for_status("volume", name1, "available")
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 2 ' +
|
||||
name2
|
||||
))
|
||||
name2,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + name2)
|
||||
self.assertEqual(
|
||||
2,
|
||||
@ -77,25 +80,28 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
self.wait_for_status("volume", name2, "available")
|
||||
|
||||
# Test list
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume list -f json '
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume list ',
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
|
||||
# Test list --long
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume list -f json --long'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume list --long',
|
||||
parse_output=True,
|
||||
)
|
||||
bootable = [x["Bootable"] for x in cmd_output]
|
||||
self.assertIn('false', bootable)
|
||||
|
||||
# Test list --name
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume list -f json ' +
|
||||
'--name ' + name1
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume list ' +
|
||||
'--name ' + name1,
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertNotIn(name2, names)
|
||||
@ -103,13 +109,14 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
def test_volume_set_and_unset(self):
|
||||
"""Tests create volume, set, unset, show, delete"""
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
'--description aaaa ' +
|
||||
'--property Alpha=a ' +
|
||||
name
|
||||
))
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name,
|
||||
cmd_output["name"],
|
||||
@ -148,10 +155,11 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
new_name,
|
||||
cmd_output["name"],
|
||||
@ -181,10 +189,11 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
{'Gamma': 'c'},
|
||||
cmd_output["properties"],
|
||||
@ -193,42 +202,46 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
def test_volume_create_and_list_and_show_backward_compatibility(self):
|
||||
"""Test backward compatibility of create, list, show"""
|
||||
name1 = uuid.uuid4().hex
|
||||
json_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
output = self.openstack(
|
||||
'volume create ' +
|
||||
'-c display_name -c id ' +
|
||||
'--size 1 ' +
|
||||
name1
|
||||
))
|
||||
self.assertIn('display_name', json_output)
|
||||
self.assertEqual(name1, json_output['display_name'])
|
||||
self.assertIn('id', json_output)
|
||||
volume_id = json_output['id']
|
||||
name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIn('display_name', output)
|
||||
self.assertEqual(name1, output['display_name'])
|
||||
self.assertIn('id', output)
|
||||
volume_id = output['id']
|
||||
self.assertIsNotNone(volume_id)
|
||||
self.assertNotIn('name', json_output)
|
||||
self.assertNotIn('name', output)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + volume_id)
|
||||
|
||||
self.wait_for_status("volume", name1, "available")
|
||||
|
||||
json_output = json.loads(self.openstack(
|
||||
'volume list -f json ' +
|
||||
'-c "Display Name"'
|
||||
))
|
||||
for each_volume in json_output:
|
||||
output = self.openstack(
|
||||
'volume list ' +
|
||||
'-c "Display Name"',
|
||||
parse_output=True,
|
||||
)
|
||||
for each_volume in output:
|
||||
self.assertIn('Display Name', each_volume)
|
||||
|
||||
json_output = json.loads(self.openstack(
|
||||
'volume list -f json ' +
|
||||
'-c "Name"'
|
||||
))
|
||||
for each_volume in json_output:
|
||||
output = self.openstack(
|
||||
'volume list ' +
|
||||
'-c "Name"',
|
||||
parse_output=True,
|
||||
)
|
||||
for each_volume in output:
|
||||
self.assertIn('Name', each_volume)
|
||||
|
||||
json_output = json.loads(self.openstack(
|
||||
'volume show -f json ' +
|
||||
output = self.openstack(
|
||||
'volume show ' +
|
||||
'-c display_name -c id ' +
|
||||
name1
|
||||
))
|
||||
self.assertIn('display_name', json_output)
|
||||
self.assertEqual(name1, json_output['display_name'])
|
||||
self.assertIn('id', json_output)
|
||||
self.assertNotIn('name', json_output)
|
||||
name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIn('display_name', output)
|
||||
self.assertEqual(name1, output['display_name'])
|
||||
self.assertIn('id', output)
|
||||
self.assertNotIn('name', output)
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import time
|
||||
import uuid
|
||||
|
||||
@ -22,10 +21,11 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
|
||||
def test_volume_type_create_list(self):
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' +
|
||||
@ -33,26 +33,29 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertEqual(name, cmd_output['name'])
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(self.NAME, cmd_output['name'])
|
||||
|
||||
cmd_output = json.loads(self.openstack('volume type list -f json'))
|
||||
cmd_output = self.openstack('volume type list', parse_output=True)
|
||||
self.assertIn(self.NAME, [t['Name'] for t in cmd_output])
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type list -f json --default'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type list --default',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(1, len(cmd_output))
|
||||
self.assertEqual('lvmdriver-1', cmd_output[0]['Name'])
|
||||
|
||||
def test_volume_type_set_unset_properties(self):
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name
|
||||
@ -63,26 +66,29 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'volume type set --property a=b --property c=d %s' % name
|
||||
)
|
||||
self.assertEqual("", raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
||||
|
||||
raw_output = self.openstack(
|
||||
'volume type unset --property a %s' % name
|
||||
)
|
||||
self.assertEqual("", raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({'c': 'd'}, cmd_output['properties'])
|
||||
|
||||
def test_volume_type_set_unset_multiple_properties(self):
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name
|
||||
@ -93,18 +99,20 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'volume type set --property a=b --property c=d %s' % name
|
||||
)
|
||||
self.assertEqual("", raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
||||
|
||||
raw_output = self.openstack(
|
||||
'volume type unset --property a --property c %s' % name
|
||||
)
|
||||
self.assertEqual("", raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({}, cmd_output['properties'])
|
||||
|
||||
def test_multi_delete(self):
|
||||
@ -125,13 +133,13 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
def test_encryption_type(self):
|
||||
encryption_type = uuid.uuid4().hex
|
||||
# test create new encryption type
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json '
|
||||
cmd_output = self.openstack(
|
||||
'volume type create '
|
||||
'--encryption-provider LuksEncryptor '
|
||||
'--encryption-cipher aes-xts-plain64 '
|
||||
'--encryption-key-size 128 '
|
||||
'--encryption-control-location front-end ' +
|
||||
encryption_type))
|
||||
encryption_type)
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
'key_size': 128,
|
||||
@ -139,8 +147,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
for attr, value in expected.items():
|
||||
self.assertEqual(value, cmd_output['encryption'][attr])
|
||||
# test show encryption type
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json --encryption-type ' + encryption_type))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show --encryption-type ' + encryption_type,
|
||||
parse_output=True,
|
||||
)
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
'key_size': 128,
|
||||
@ -148,8 +158,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
for attr, value in expected.items():
|
||||
self.assertEqual(value, cmd_output['encryption'][attr])
|
||||
# test list encryption type
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type list -f json --encryption-type'))
|
||||
cmd_output = self.openstack(
|
||||
'volume type list --encryption-type',
|
||||
parse_output=True,
|
||||
)
|
||||
encryption_output = [t['Encryption'] for t in cmd_output
|
||||
if t['Name'] == encryption_type][0]
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
@ -169,19 +181,20 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
self.assertEqual('', raw_output)
|
||||
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
name,
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' + name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name,
|
||||
)
|
||||
self.assertEqual(name, cmd_output['name'])
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json --encryption-type ' + name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show --encryption-type ' + name,
|
||||
parse_output=True,
|
||||
)
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
'key_size': 128,
|
||||
@ -193,9 +206,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'volume type unset --encryption-type ' + name
|
||||
)
|
||||
self.assertEqual('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json --encryption-type ' + name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show --encryption-type ' + name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({}, cmd_output['encryption'])
|
||||
# test delete encryption type
|
||||
raw_output = self.openstack('volume type delete ' + encryption_type)
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v2 import common
|
||||
@ -22,29 +21,32 @@ class QosTests(common.BaseVolumeTests):
|
||||
def test_volume_qos_create_delete_list(self):
|
||||
"""Test create, list, delete multiple"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos create -f json ' +
|
||||
name1
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos create ' +
|
||||
name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name1,
|
||||
cmd_output['name']
|
||||
)
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos create -f json ' +
|
||||
name2
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos create ' +
|
||||
name2,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name2,
|
||||
cmd_output['name']
|
||||
)
|
||||
|
||||
# Test list
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos list -f json'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos list',
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
@ -57,12 +59,13 @@ class QosTests(common.BaseVolumeTests):
|
||||
"""Tests create volume qos, set, unset, show, delete"""
|
||||
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume qos create ' +
|
||||
'--consumer front-end '
|
||||
'--property Alpha=a ' +
|
||||
name
|
||||
))
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume qos delete ' + name)
|
||||
self.assertEqual(
|
||||
name,
|
||||
@ -88,10 +91,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
# Test volume qos show
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name,
|
||||
cmd_output['name']
|
||||
@ -109,10 +113,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name,
|
||||
cmd_output['name']
|
||||
@ -125,10 +130,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
def test_volume_qos_asso_disasso(self):
|
||||
"""Tests associate and disassociate qos with volume type"""
|
||||
vol_type1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json ' +
|
||||
vol_type1
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type create ' +
|
||||
vol_type1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
vol_type1,
|
||||
cmd_output['name']
|
||||
@ -136,10 +142,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
self.addCleanup(self.openstack, 'volume type delete ' + vol_type1)
|
||||
|
||||
vol_type2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json ' +
|
||||
vol_type2
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type create ' +
|
||||
vol_type2,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
vol_type2,
|
||||
cmd_output['name']
|
||||
@ -147,10 +154,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
self.addCleanup(self.openstack, 'volume type delete ' + vol_type2)
|
||||
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos create -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos create ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name,
|
||||
cmd_output['name']
|
||||
@ -169,10 +177,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
types = cmd_output["associations"]
|
||||
self.assertIn(vol_type1, types)
|
||||
self.assertIn(vol_type2, types)
|
||||
@ -184,10 +193,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
' ' + name
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
types = cmd_output["associations"]
|
||||
self.assertNotIn(vol_type1, types)
|
||||
self.assertIn(vol_type2, types)
|
||||
@ -198,10 +208,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
name + ' ' + vol_type1
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
types = cmd_output["associations"]
|
||||
self.assertIn(vol_type1, types)
|
||||
self.assertIn(vol_type2, types)
|
||||
@ -211,8 +222,9 @@ class QosTests(common.BaseVolumeTests):
|
||||
'--all ' + name
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertNotIn("associations", cmd_output.keys())
|
||||
|
@ -10,8 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
from openstackclient.tests.functional.volume.v2 import common
|
||||
|
||||
|
||||
@ -19,19 +17,19 @@ class VolumeServiceTests(common.BaseVolumeTests):
|
||||
"""Functional tests for volume service."""
|
||||
|
||||
def test_volume_service_list(self):
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume service list -f json'))
|
||||
cmd_output = self.openstack('volume service list', parse_output=True)
|
||||
|
||||
# Get the nonredundant services and hosts
|
||||
services = list(set([x['Binary'] for x in cmd_output]))
|
||||
hosts = list(set([x['Host'] for x in cmd_output]))
|
||||
|
||||
# Test volume service list --service
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume service list -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume service list ' +
|
||||
'--service ' +
|
||||
services[0]
|
||||
))
|
||||
services[0],
|
||||
parse_output=True,
|
||||
)
|
||||
for x in cmd_output:
|
||||
self.assertEqual(
|
||||
services[0],
|
||||
@ -39,11 +37,12 @@ class VolumeServiceTests(common.BaseVolumeTests):
|
||||
)
|
||||
|
||||
# Test volume service list --host
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume service list -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume service list ' +
|
||||
'--host ' +
|
||||
hosts[0]
|
||||
))
|
||||
hosts[0],
|
||||
parse_output=True,
|
||||
)
|
||||
for x in cmd_output:
|
||||
self.assertIn(
|
||||
hosts[0],
|
||||
@ -53,9 +52,10 @@ class VolumeServiceTests(common.BaseVolumeTests):
|
||||
def test_volume_service_set(self):
|
||||
|
||||
# Get a service and host
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume service list -f json'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume service list',
|
||||
parse_output=True,
|
||||
)
|
||||
service_1 = cmd_output[0]['Binary']
|
||||
host_1 = cmd_output[0]['Host']
|
||||
|
||||
@ -67,9 +67,10 @@ class VolumeServiceTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume service list -f json --long'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume service list --long',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
'enabled',
|
||||
cmd_output[0]['Status']
|
||||
@ -89,9 +90,10 @@ class VolumeServiceTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume service list -f json --long'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume service list --long',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
'disabled',
|
||||
cmd_output[0]['Status']
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v2 import common
|
||||
@ -26,11 +25,12 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
xfer_name = uuid.uuid4().hex
|
||||
|
||||
# create a volume
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
volume_name
|
||||
))
|
||||
volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(volume_name, cmd_output['name'])
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
@ -42,12 +42,13 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
|
||||
# create volume transfer request for the volume
|
||||
# and get the auth_key of the new transfer request
|
||||
cmd_output = json.loads(self.openstack(
|
||||
cmd_output = self.openstack(
|
||||
'--os-volume-api-version ' + self.API_VERSION + ' ' +
|
||||
'volume transfer request create -f json ' +
|
||||
'volume transfer request create ' +
|
||||
' --name ' + xfer_name + ' ' +
|
||||
volume_name
|
||||
))
|
||||
volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(xfer_name, cmd_output['name'])
|
||||
xfer_id = cmd_output['id']
|
||||
auth_key = cmd_output['auth_key']
|
||||
@ -55,12 +56,13 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
self.wait_for_status("volume", volume_name, "awaiting-transfer")
|
||||
|
||||
# accept the volume transfer request
|
||||
cmd_output = json.loads(self.openstack(
|
||||
cmd_output = self.openstack(
|
||||
'--os-volume-api-version ' + self.API_VERSION + ' ' +
|
||||
'volume transfer request accept -f json ' +
|
||||
'volume transfer request accept ' +
|
||||
'--auth-key ' + auth_key + ' ' +
|
||||
xfer_id
|
||||
))
|
||||
xfer_id,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(xfer_name, cmd_output['name'])
|
||||
self.wait_for_status("volume", volume_name, "available")
|
||||
|
||||
@ -69,11 +71,12 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
xfer_name = uuid.uuid4().hex
|
||||
|
||||
# create a volume
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
volume_name
|
||||
))
|
||||
volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(volume_name, cmd_output['name'])
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
@ -83,29 +86,32 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.wait_for_status("volume", volume_name, "available")
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
cmd_output = self.openstack(
|
||||
'--os-volume-api-version ' + self.API_VERSION + ' ' +
|
||||
'volume transfer request create -f json ' +
|
||||
'volume transfer request create ' +
|
||||
' --name ' + xfer_name + ' ' +
|
||||
volume_name
|
||||
))
|
||||
volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(xfer_name, cmd_output['name'])
|
||||
xfer_id = cmd_output['id']
|
||||
auth_key = cmd_output['auth_key']
|
||||
self.assertTrue(auth_key)
|
||||
self.wait_for_status("volume", volume_name, "awaiting-transfer")
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
cmd_output = self.openstack(
|
||||
'--os-volume-api-version ' + self.API_VERSION + ' ' +
|
||||
'volume transfer request list -f json'
|
||||
))
|
||||
'volume transfer request list',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIn(xfer_name, [req['Name'] for req in cmd_output])
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
cmd_output = self.openstack(
|
||||
'--os-volume-api-version ' + self.API_VERSION + ' ' +
|
||||
'volume transfer request show -f json ' +
|
||||
xfer_id
|
||||
))
|
||||
'volume transfer request show ' +
|
||||
xfer_id,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(xfer_name, cmd_output['name'])
|
||||
|
||||
# NOTE(dtroyer): We need to delete the transfer request to allow the
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v2 import common
|
||||
@ -22,22 +21,24 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
def test_volume_delete(self):
|
||||
"""Test create, delete multiple"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
name1
|
||||
))
|
||||
name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
1,
|
||||
cmd_output["size"],
|
||||
)
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 2 ' +
|
||||
name2
|
||||
))
|
||||
name2,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
2,
|
||||
cmd_output["size"],
|
||||
@ -51,11 +52,12 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
def test_volume_list(self):
|
||||
"""Test create, list filter"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
name1
|
||||
))
|
||||
name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + name1)
|
||||
self.assertEqual(
|
||||
1,
|
||||
@ -64,11 +66,12 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
self.wait_for_status("volume", name1, "available")
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 2 ' +
|
||||
name2
|
||||
))
|
||||
name2,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + name2)
|
||||
self.assertEqual(
|
||||
2,
|
||||
@ -83,19 +86,21 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
# Test list --long
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume list -f json ' +
|
||||
'--long'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume list ' +
|
||||
'--long',
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
|
||||
# Test list --status
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume list -f json ' +
|
||||
'--status error'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume list ' +
|
||||
'--status error',
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertNotIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
@ -107,13 +112,14 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
"""Tests create volume, set, unset, show, delete"""
|
||||
name = uuid.uuid4().hex
|
||||
new_name = name + "_"
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
'--description aaaa ' +
|
||||
'--property Alpha=a ' +
|
||||
name
|
||||
))
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + new_name)
|
||||
self.assertEqual(
|
||||
name,
|
||||
@ -153,10 +159,11 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
new_name,
|
||||
cmd_output["name"],
|
||||
@ -191,10 +198,11 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
{'Gamma': 'c'},
|
||||
cmd_output["properties"],
|
||||
@ -210,30 +218,33 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
volume_name = uuid.uuid4().hex
|
||||
snapshot_name = uuid.uuid4().hex
|
||||
# Make a snapshot
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
volume_name
|
||||
))
|
||||
volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.wait_for_status("volume", volume_name, "available")
|
||||
self.assertEqual(
|
||||
volume_name,
|
||||
cmd_output["name"],
|
||||
)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
snapshot_name +
|
||||
' --volume ' + volume_name
|
||||
))
|
||||
' --volume ' + volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.wait_for_status("volume snapshot", snapshot_name, "available")
|
||||
|
||||
name = uuid.uuid4().hex
|
||||
# Create volume from snapshot
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--snapshot ' + snapshot_name +
|
||||
' ' + name
|
||||
))
|
||||
' ' + name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + name)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + volume_name)
|
||||
self.assertEqual(
|
||||
@ -253,11 +264,12 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
def test_volume_list_backward_compatibility(self):
|
||||
"""Test backward compatibility of list command"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
name1
|
||||
))
|
||||
name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + name1)
|
||||
self.assertEqual(
|
||||
1,
|
||||
@ -266,17 +278,19 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
self.wait_for_status("volume", name1, "available")
|
||||
|
||||
# Test list -c "Display Name"
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume list -f json ' +
|
||||
'-c "Display Name"'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume list ' +
|
||||
'-c "Display Name"',
|
||||
parse_output=True,
|
||||
)
|
||||
for each_volume in cmd_output:
|
||||
self.assertIn('Display Name', each_volume)
|
||||
|
||||
# Test list -c "Name"
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume list -f json ' +
|
||||
'-c "Name"'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume list ' +
|
||||
'-c "Name"',
|
||||
parse_output=True,
|
||||
)
|
||||
for each_volume in cmd_output:
|
||||
self.assertIn('Name', each_volume)
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v2 import common
|
||||
@ -22,7 +21,7 @@ class VolumeBackupTests(common.BaseVolumeTests):
|
||||
def setUp(self):
|
||||
super(VolumeBackupTests, self).setUp()
|
||||
self.backup_enabled = False
|
||||
serv_list = json.loads(self.openstack('volume service list -f json'))
|
||||
serv_list = self.openstack('volume service list', parse_output=True)
|
||||
for service in serv_list:
|
||||
if service['Binary'] == 'cinder-backup':
|
||||
if service['Status'] == 'enabled':
|
||||
@ -34,24 +33,28 @@ class VolumeBackupTests(common.BaseVolumeTests):
|
||||
self.skipTest('Backup service is not enabled')
|
||||
vol_id = uuid.uuid4().hex
|
||||
# create a volume
|
||||
json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
vol_id
|
||||
))
|
||||
vol_id,
|
||||
parse_output=True,
|
||||
)
|
||||
self.wait_for_status("volume", vol_id, "available")
|
||||
|
||||
# create a backup
|
||||
backup = json.loads(self.openstack(
|
||||
'volume backup create -f json ' +
|
||||
vol_id
|
||||
))
|
||||
backup = self.openstack(
|
||||
'volume backup create ' +
|
||||
vol_id,
|
||||
parse_output=True,
|
||||
)
|
||||
self.wait_for_status("volume backup", backup['id'], "available")
|
||||
|
||||
# restore the backup
|
||||
backup_restored = json.loads(self.openstack(
|
||||
'volume backup restore -f json %s %s'
|
||||
% (backup['id'], vol_id)))
|
||||
backup_restored = self.openstack(
|
||||
'volume backup restore %s %s'
|
||||
% (backup['id'], vol_id),
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(backup_restored['backup_id'], backup['id'])
|
||||
self.wait_for_status("volume backup", backup['id'], "available")
|
||||
self.wait_for_status("volume", backup_restored['volume_id'],
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v2 import common
|
||||
@ -25,11 +24,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
def setUpClass(cls):
|
||||
super(VolumeSnapshotTests, cls).setUpClass()
|
||||
# create a volume for all tests to create snapshot
|
||||
cmd_output = json.loads(cls.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = cls.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
cls.VOLLY
|
||||
))
|
||||
cls.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
cls.wait_for_status('volume', cls.VOLLY, 'available')
|
||||
cls.VOLUME_ID = cmd_output['id']
|
||||
|
||||
@ -46,22 +46,24 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
def test_volume_snapshot_delete(self):
|
||||
"""Test create, delete multiple"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
name1 +
|
||||
' --volume ' + self.VOLLY
|
||||
))
|
||||
' --volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name1,
|
||||
cmd_output["name"],
|
||||
)
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
name2 +
|
||||
' --volume ' + self.VOLLY
|
||||
))
|
||||
' --volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name2,
|
||||
cmd_output["name"],
|
||||
@ -79,11 +81,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
def test_volume_snapshot_list(self):
|
||||
"""Test create, list filter"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
name1 +
|
||||
' --volume ' + self.VOLLY
|
||||
))
|
||||
' --volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.wait_for_delete, 'volume snapshot', name1)
|
||||
self.addCleanup(self.openstack, 'volume snapshot delete ' + name1)
|
||||
self.assertEqual(
|
||||
@ -101,11 +104,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
self.wait_for_status('volume snapshot', name1, 'available')
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
name2 +
|
||||
' --volume ' + self.VOLLY
|
||||
))
|
||||
' --volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.wait_for_delete, 'volume snapshot', name2)
|
||||
self.addCleanup(self.openstack, 'volume snapshot delete ' + name2)
|
||||
self.assertEqual(
|
||||
@ -130,11 +134,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
# Test list --long, --status
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot list -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot list ' +
|
||||
'--long ' +
|
||||
'--status error_deleting'
|
||||
))
|
||||
'--status error_deleting',
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertNotIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
@ -147,29 +152,32 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
# Test list --long, --status
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot list -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot list ' +
|
||||
'--long ' +
|
||||
'--status error'
|
||||
))
|
||||
'--status error',
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertNotIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
|
||||
# Test list --volume
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot list -f json ' +
|
||||
'--volume ' + self.VOLLY
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot list ' +
|
||||
'--volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
|
||||
# Test list --name
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot list -f json ' +
|
||||
'--name ' + name1
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot list ' +
|
||||
'--name ' + name1,
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertNotIn(name2, names)
|
||||
@ -178,13 +186,14 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
"""Test create, set, unset, show, delete volume snapshot"""
|
||||
name = uuid.uuid4().hex
|
||||
new_name = name + "_"
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
'--volume ' + self.VOLLY +
|
||||
' --description aaaa ' +
|
||||
'--property Alpha=a ' +
|
||||
name
|
||||
))
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.wait_for_delete, 'volume snapshot', new_name)
|
||||
self.addCleanup(self.openstack, 'volume snapshot delete ' + new_name)
|
||||
self.assertEqual(
|
||||
@ -217,10 +226,11 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
# Show snapshot set result
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
new_name,
|
||||
cmd_output["name"],
|
||||
@ -246,10 +256,11 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
{'Beta': 'b'},
|
||||
cmd_output["properties"],
|
||||
@ -262,10 +273,11 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
new_name,
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertNotIn(
|
||||
{'Beta': 'b'},
|
||||
cmd_output["properties"],
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import time
|
||||
import uuid
|
||||
|
||||
@ -22,36 +21,40 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
|
||||
def test_volume_type_create_list(self):
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name,
|
||||
)
|
||||
self.assertEqual(name, cmd_output['name'])
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(name, cmd_output['name'])
|
||||
|
||||
cmd_output = json.loads(self.openstack('volume type list -f json'))
|
||||
cmd_output = self.openstack('volume type list', parse_output=True)
|
||||
self.assertIn(name, [t['Name'] for t in cmd_output])
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type list -f json --default'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type list --default',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(1, len(cmd_output))
|
||||
self.assertEqual('lvmdriver-1', cmd_output[0]['Name'])
|
||||
|
||||
def test_volume_type_set_unset_properties(self):
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name
|
||||
@ -62,26 +65,29 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'volume type set --property a=b --property c=d %s' % name
|
||||
)
|
||||
self.assertEqual("", raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
||||
|
||||
raw_output = self.openstack(
|
||||
'volume type unset --property a %s' % name
|
||||
)
|
||||
self.assertEqual("", raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({'c': 'd'}, cmd_output['properties'])
|
||||
|
||||
def test_volume_type_set_unset_multiple_properties(self):
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name
|
||||
@ -92,26 +98,29 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'volume type set --property a=b --property c=d %s' % name
|
||||
)
|
||||
self.assertEqual("", raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
||||
|
||||
raw_output = self.openstack(
|
||||
'volume type unset --property a --property c %s' % name
|
||||
)
|
||||
self.assertEqual("", raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({}, cmd_output['properties'])
|
||||
|
||||
def test_volume_type_set_unset_project(self):
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name
|
||||
@ -147,13 +156,15 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
name = uuid.uuid4().hex
|
||||
encryption_type = uuid.uuid4().hex
|
||||
# test create new encryption type
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json '
|
||||
cmd_output = self.openstack(
|
||||
'volume type create '
|
||||
'--encryption-provider LuksEncryptor '
|
||||
'--encryption-cipher aes-xts-plain64 '
|
||||
'--encryption-key-size 128 '
|
||||
'--encryption-control-location front-end ' +
|
||||
encryption_type))
|
||||
encryption_type,
|
||||
parse_output=True,
|
||||
)
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
'key_size': 128,
|
||||
@ -161,8 +172,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
for attr, value in expected.items():
|
||||
self.assertEqual(value, cmd_output['encryption'][attr])
|
||||
# test show encryption type
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json --encryption-type ' + encryption_type))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show --encryption-type ' + encryption_type,
|
||||
parse_output=True,
|
||||
)
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
'key_size': 128,
|
||||
@ -170,8 +183,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
for attr, value in expected.items():
|
||||
self.assertEqual(value, cmd_output['encryption'][attr])
|
||||
# test list encryption type
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type list -f json --encryption-type'))
|
||||
cmd_output = self.openstack(
|
||||
'volume type list --encryption-type',
|
||||
parse_output=True,
|
||||
)
|
||||
encryption_output = [t['Encryption'] for t in cmd_output
|
||||
if t['Name'] == encryption_type][0]
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
@ -187,8 +202,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'--encryption-control-location back-end ' +
|
||||
encryption_type)
|
||||
self.assertEqual('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json --encryption-type ' + encryption_type))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show --encryption-type ' + encryption_type,
|
||||
parse_output=True,
|
||||
)
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
'key_size': 256,
|
||||
@ -196,10 +213,11 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
for attr, value in expected.items():
|
||||
self.assertEqual(value, cmd_output['encryption'][attr])
|
||||
# test set new encryption type
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name,
|
||||
@ -215,9 +233,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
name)
|
||||
self.assertEqual('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json --encryption-type ' + name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show --encryption-type ' + name,
|
||||
parse_output=True,
|
||||
)
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
'key_size': 128,
|
||||
@ -229,9 +248,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'volume type unset --encryption-type ' + name
|
||||
)
|
||||
self.assertEqual('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json --encryption-type ' + name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show --encryption-type ' + name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({}, cmd_output['encryption'])
|
||||
# test delete encryption type
|
||||
raw_output = self.openstack('volume type delete ' + encryption_type)
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v3 import common
|
||||
@ -22,29 +21,32 @@ class QosTests(common.BaseVolumeTests):
|
||||
def test_volume_qos_create_delete_list(self):
|
||||
"""Test create, list, delete multiple"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos create -f json ' +
|
||||
name1
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos create ' +
|
||||
name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name1,
|
||||
cmd_output['name']
|
||||
)
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos create -f json ' +
|
||||
name2
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos create ' +
|
||||
name2,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name2,
|
||||
cmd_output['name']
|
||||
)
|
||||
|
||||
# Test list
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos list -f json'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos list',
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
@ -57,12 +59,13 @@ class QosTests(common.BaseVolumeTests):
|
||||
"""Tests create volume qos, set, unset, show, delete"""
|
||||
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume qos create ' +
|
||||
'--consumer front-end '
|
||||
'--property Alpha=a ' +
|
||||
name
|
||||
))
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume qos delete ' + name)
|
||||
self.assertEqual(
|
||||
name,
|
||||
@ -88,10 +91,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
# Test volume qos show
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name,
|
||||
cmd_output['name']
|
||||
@ -109,10 +113,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name,
|
||||
cmd_output['name']
|
||||
@ -125,10 +130,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
def test_volume_qos_asso_disasso(self):
|
||||
"""Tests associate and disassociate qos with volume type"""
|
||||
vol_type1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json ' +
|
||||
vol_type1
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type create ' +
|
||||
vol_type1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
vol_type1,
|
||||
cmd_output['name']
|
||||
@ -136,10 +142,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
self.addCleanup(self.openstack, 'volume type delete ' + vol_type1)
|
||||
|
||||
vol_type2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json ' +
|
||||
vol_type2
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type create ' +
|
||||
vol_type2,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
vol_type2,
|
||||
cmd_output['name']
|
||||
@ -147,10 +154,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
self.addCleanup(self.openstack, 'volume type delete ' + vol_type2)
|
||||
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos create -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos create ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name,
|
||||
cmd_output['name']
|
||||
@ -169,10 +177,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
types = cmd_output["associations"]
|
||||
self.assertIn(vol_type1, types)
|
||||
self.assertIn(vol_type2, types)
|
||||
@ -184,10 +193,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
' ' + name
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
types = cmd_output["associations"]
|
||||
self.assertNotIn(vol_type1, types)
|
||||
self.assertIn(vol_type2, types)
|
||||
@ -198,10 +208,11 @@ class QosTests(common.BaseVolumeTests):
|
||||
name + ' ' + vol_type1
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
types = cmd_output["associations"]
|
||||
self.assertIn(vol_type1, types)
|
||||
self.assertIn(vol_type2, types)
|
||||
@ -211,8 +222,9 @@ class QosTests(common.BaseVolumeTests):
|
||||
'--all ' + name
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume qos show -f json ' +
|
||||
name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume qos show ' +
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertNotIn("associations", cmd_output.keys())
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v3 import common
|
||||
@ -26,11 +25,12 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
xfer_name = uuid.uuid4().hex
|
||||
|
||||
# create a volume
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
volume_name
|
||||
))
|
||||
volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(volume_name, cmd_output['name'])
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
@ -42,12 +42,12 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
|
||||
# create volume transfer request for the volume
|
||||
# and get the auth_key of the new transfer request
|
||||
cmd_output = json.loads(self.openstack(
|
||||
cmd_output = self.openstack(
|
||||
'--os-volume-api-version ' + self.API_VERSION + ' ' +
|
||||
'volume transfer request create -f json ' +
|
||||
' --name ' + xfer_name + ' ' +
|
||||
volume_name
|
||||
))
|
||||
'volume transfer request create ' +
|
||||
' --name ' + xfer_name + ' ' + volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(xfer_name, cmd_output['name'])
|
||||
xfer_id = cmd_output['id']
|
||||
auth_key = cmd_output['auth_key']
|
||||
@ -55,12 +55,12 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
self.wait_for_status("volume", volume_name, "awaiting-transfer")
|
||||
|
||||
# accept the volume transfer request
|
||||
cmd_output = json.loads(self.openstack(
|
||||
cmd_output = self.openstack(
|
||||
'--os-volume-api-version ' + self.API_VERSION + ' ' +
|
||||
'volume transfer request accept -f json ' +
|
||||
'--auth-key ' + auth_key + ' ' +
|
||||
xfer_id
|
||||
))
|
||||
'volume transfer request accept ' +
|
||||
'--auth-key ' + auth_key + ' ' + xfer_id,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(xfer_name, cmd_output['name'])
|
||||
self.wait_for_status("volume", volume_name, "available")
|
||||
|
||||
@ -69,11 +69,11 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
xfer_name = uuid.uuid4().hex
|
||||
|
||||
# create a volume
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
'--size 1 ' +
|
||||
volume_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' + volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(volume_name, cmd_output['name'])
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
@ -83,29 +83,31 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.wait_for_status("volume", volume_name, "available")
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
cmd_output = self.openstack(
|
||||
'--os-volume-api-version ' + self.API_VERSION + ' ' +
|
||||
'volume transfer request create -f json ' +
|
||||
' --name ' + xfer_name + ' ' +
|
||||
volume_name
|
||||
))
|
||||
'volume transfer request create ' +
|
||||
' --name ' + xfer_name + ' ' + volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(xfer_name, cmd_output['name'])
|
||||
xfer_id = cmd_output['id']
|
||||
auth_key = cmd_output['auth_key']
|
||||
self.assertTrue(auth_key)
|
||||
self.wait_for_status("volume", volume_name, "awaiting-transfer")
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
cmd_output = self.openstack(
|
||||
'--os-volume-api-version ' + self.API_VERSION + ' ' +
|
||||
'volume transfer request list -f json'
|
||||
))
|
||||
'volume transfer request list',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIn(xfer_name, [req['Name'] for req in cmd_output])
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
cmd_output = self.openstack(
|
||||
'--os-volume-api-version ' + self.API_VERSION + ' ' +
|
||||
'volume transfer request show -f json ' +
|
||||
xfer_id
|
||||
))
|
||||
'volume transfer request show ' +
|
||||
xfer_id,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(xfer_name, cmd_output['name'])
|
||||
|
||||
# NOTE(dtroyer): We need to delete the transfer request to allow the
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v3 import common
|
||||
@ -22,22 +21,20 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
def test_volume_delete(self):
|
||||
"""Test create, delete multiple"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
'--size 1 ' +
|
||||
name1
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume create --size 1 ' + name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
1,
|
||||
cmd_output["size"],
|
||||
)
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
'--size 2 ' +
|
||||
name2
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume create --size 2 ' + name2,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
2,
|
||||
cmd_output["size"],
|
||||
@ -51,11 +48,10 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
def test_volume_list(self):
|
||||
"""Test create, list filter"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
'--size 1 ' +
|
||||
name1
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume create --size 1 ' + name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + name1)
|
||||
self.assertEqual(
|
||||
1,
|
||||
@ -64,11 +60,10 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
self.wait_for_status("volume", name1, "available")
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
'--size 2 ' +
|
||||
name2
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume create --size 2 ' + name2,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + name2)
|
||||
self.assertEqual(
|
||||
2,
|
||||
@ -83,19 +78,19 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
# Test list --long
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume list -f json ' +
|
||||
'--long'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume list --long',
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
|
||||
# Test list --status
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume list -f json ' +
|
||||
'--status error'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume list --status error',
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertNotIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
@ -107,13 +102,14 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
"""Tests create volume, set, unset, show, delete"""
|
||||
name = uuid.uuid4().hex
|
||||
new_name = name + "_"
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
'--description aaaa ' +
|
||||
'--property Alpha=a ' +
|
||||
name
|
||||
))
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + new_name)
|
||||
self.assertEqual(
|
||||
name,
|
||||
@ -154,10 +150,10 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
self.assertOutput('', raw_output)
|
||||
self.wait_for_status("volume", new_name, "available")
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume show ' + new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
new_name,
|
||||
cmd_output["name"],
|
||||
@ -192,10 +188,10 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume show ' + new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
{'Gamma': 'c'},
|
||||
cmd_output["properties"],
|
||||
@ -211,30 +207,31 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
volume_name = uuid.uuid4().hex
|
||||
snapshot_name = uuid.uuid4().hex
|
||||
# Make a snapshot
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
'--size 1 ' +
|
||||
volume_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume create --size 1 ' + volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.wait_for_status("volume", volume_name, "available")
|
||||
self.assertEqual(
|
||||
volume_name,
|
||||
cmd_output["name"],
|
||||
)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
snapshot_name +
|
||||
' --volume ' + volume_name
|
||||
))
|
||||
' --volume ' + volume_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.wait_for_status("volume snapshot", snapshot_name, "available")
|
||||
|
||||
name = uuid.uuid4().hex
|
||||
# Create volume from snapshot
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume create ' +
|
||||
'--snapshot ' + snapshot_name +
|
||||
' ' + name
|
||||
))
|
||||
' ' + name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + name)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + volume_name)
|
||||
self.assertEqual(
|
||||
@ -254,11 +251,10 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
def test_volume_list_backward_compatibility(self):
|
||||
"""Test backward compatibility of list command"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume create -f json ' +
|
||||
'--size 1 ' +
|
||||
name1
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume create --size 1 ' + name1,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.openstack, 'volume delete ' + name1)
|
||||
self.assertEqual(
|
||||
1,
|
||||
@ -267,17 +263,17 @@ class VolumeTests(common.BaseVolumeTests):
|
||||
self.wait_for_status("volume", name1, "available")
|
||||
|
||||
# Test list -c "Display Name"
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume list -f json ' +
|
||||
'-c "Display Name"'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume list -c "Display Name"',
|
||||
parse_output=True,
|
||||
)
|
||||
for each_volume in cmd_output:
|
||||
self.assertIn('Display Name', each_volume)
|
||||
|
||||
# Test list -c "Name"
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume list -f json ' +
|
||||
'-c "Name"'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume list -c "Name"',
|
||||
parse_output=True,
|
||||
)
|
||||
for each_volume in cmd_output:
|
||||
self.assertIn('Name', each_volume)
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from openstackclient.tests.functional.volume.v3 import common
|
||||
@ -25,11 +24,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
def setUpClass(cls):
|
||||
super(VolumeSnapshotTests, cls).setUpClass()
|
||||
# create a volume for all tests to create snapshot
|
||||
cmd_output = json.loads(cls.openstack(
|
||||
'volume create -f json ' +
|
||||
cmd_output = cls.openstack(
|
||||
'volume create ' +
|
||||
'--size 1 ' +
|
||||
cls.VOLLY
|
||||
))
|
||||
cls.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
cls.wait_for_status('volume', cls.VOLLY, 'available')
|
||||
cls.VOLUME_ID = cmd_output['id']
|
||||
|
||||
@ -46,22 +46,24 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
def test_volume_snapshot_delete(self):
|
||||
"""Test create, delete multiple"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
name1 +
|
||||
' --volume ' + self.VOLLY
|
||||
))
|
||||
' --volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name1,
|
||||
cmd_output["name"],
|
||||
)
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
name2 +
|
||||
' --volume ' + self.VOLLY
|
||||
))
|
||||
' --volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name2,
|
||||
cmd_output["name"],
|
||||
@ -79,11 +81,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
def test_volume_snapshot_list(self):
|
||||
"""Test create, list filter"""
|
||||
name1 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
name1 +
|
||||
' --volume ' + self.VOLLY
|
||||
))
|
||||
' --volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.wait_for_delete, 'volume snapshot', name1)
|
||||
self.addCleanup(self.openstack, 'volume snapshot delete ' + name1)
|
||||
self.assertEqual(
|
||||
@ -101,11 +104,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
self.wait_for_status('volume snapshot', name1, 'available')
|
||||
|
||||
name2 = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
name2 +
|
||||
' --volume ' + self.VOLLY
|
||||
))
|
||||
' --volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.wait_for_delete, 'volume snapshot', name2)
|
||||
self.addCleanup(self.openstack, 'volume snapshot delete ' + name2)
|
||||
self.assertEqual(
|
||||
@ -129,29 +133,32 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
# Test list --long, --status
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot list -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot list ' +
|
||||
'--long ' +
|
||||
'--status error'
|
||||
))
|
||||
'--status error',
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertNotIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
|
||||
# Test list --volume
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot list -f json ' +
|
||||
'--volume ' + self.VOLLY
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot list ' +
|
||||
'--volume ' + self.VOLLY,
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertIn(name2, names)
|
||||
|
||||
# Test list --name
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot list -f json ' +
|
||||
'--name ' + name1
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot list ' +
|
||||
'--name ' + name1,
|
||||
parse_output=True,
|
||||
)
|
||||
names = [x["Name"] for x in cmd_output]
|
||||
self.assertIn(name1, names)
|
||||
self.assertNotIn(name2, names)
|
||||
@ -160,13 +167,14 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
"""Test create, set, unset, show, delete volume snapshot"""
|
||||
name = uuid.uuid4().hex
|
||||
new_name = name + "_"
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot create -f json ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot create ' +
|
||||
'--volume ' + self.VOLLY +
|
||||
' --description aaaa ' +
|
||||
'--property Alpha=a ' +
|
||||
name
|
||||
))
|
||||
name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self.wait_for_delete, 'volume snapshot', new_name)
|
||||
self.addCleanup(self.openstack, 'volume snapshot delete ' + new_name)
|
||||
self.assertEqual(
|
||||
@ -199,10 +207,11 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
# Show snapshot set result
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
new_name,
|
||||
cmd_output["name"],
|
||||
@ -228,10 +237,11 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
{'Beta': 'b'},
|
||||
cmd_output["properties"],
|
||||
@ -244,10 +254,11 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
new_name,
|
||||
)
|
||||
self.assertOutput('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume snapshot show -f json ' +
|
||||
new_name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume snapshot show ' +
|
||||
new_name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertNotIn(
|
||||
{'Beta': 'b'},
|
||||
cmd_output["properties"],
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import time
|
||||
import uuid
|
||||
|
||||
@ -22,36 +21,40 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
|
||||
def test_volume_type_create_list(self):
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name,
|
||||
)
|
||||
self.assertEqual(name, cmd_output['name'])
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(name, cmd_output['name'])
|
||||
|
||||
cmd_output = json.loads(self.openstack('volume type list -f json'))
|
||||
cmd_output = self.openstack('volume type list', parse_output=True)
|
||||
self.assertIn(name, [t['Name'] for t in cmd_output])
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type list -f json --default'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type list --default',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(1, len(cmd_output))
|
||||
self.assertEqual('lvmdriver-1', cmd_output[0]['Name'])
|
||||
|
||||
def test_volume_type_set_unset_properties(self):
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name
|
||||
@ -62,26 +65,29 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'volume type set --property a=b --property c=d %s' % name
|
||||
)
|
||||
self.assertEqual("", raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
||||
|
||||
raw_output = self.openstack(
|
||||
'volume type unset --property a %s' % name
|
||||
)
|
||||
self.assertEqual("", raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({'c': 'd'}, cmd_output['properties'])
|
||||
|
||||
def test_volume_type_set_unset_multiple_properties(self):
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name
|
||||
@ -92,26 +98,29 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'volume type set --property a=b --property c=d %s' % name
|
||||
)
|
||||
self.assertEqual("", raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
|
||||
|
||||
raw_output = self.openstack(
|
||||
'volume type unset --property a --property c %s' % name
|
||||
)
|
||||
self.assertEqual("", raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json %s' % name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show %s' % name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({}, cmd_output['properties'])
|
||||
|
||||
def test_volume_type_set_unset_project(self):
|
||||
name = uuid.uuid4().hex
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name
|
||||
@ -147,13 +156,15 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
name = uuid.uuid4().hex
|
||||
encryption_type = uuid.uuid4().hex
|
||||
# test create new encryption type
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json '
|
||||
cmd_output = self.openstack(
|
||||
'volume type create '
|
||||
'--encryption-provider LuksEncryptor '
|
||||
'--encryption-cipher aes-xts-plain64 '
|
||||
'--encryption-key-size 128 '
|
||||
'--encryption-control-location front-end ' +
|
||||
encryption_type))
|
||||
encryption_type,
|
||||
parse_output=True,
|
||||
)
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
'key_size': 128,
|
||||
@ -161,8 +172,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
for attr, value in expected.items():
|
||||
self.assertEqual(value, cmd_output['encryption'][attr])
|
||||
# test show encryption type
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json --encryption-type ' + encryption_type))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show --encryption-type ' + encryption_type,
|
||||
parse_output=True,
|
||||
)
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
'key_size': 128,
|
||||
@ -170,8 +183,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
for attr, value in expected.items():
|
||||
self.assertEqual(value, cmd_output['encryption'][attr])
|
||||
# test list encryption type
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type list -f json --encryption-type'))
|
||||
cmd_output = self.openstack(
|
||||
'volume type list --encryption-type',
|
||||
parse_output=True,
|
||||
)
|
||||
encryption_output = [t['Encryption'] for t in cmd_output
|
||||
if t['Name'] == encryption_type][0]
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
@ -187,8 +202,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'--encryption-control-location back-end ' +
|
||||
encryption_type)
|
||||
self.assertEqual('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json --encryption-type ' + encryption_type))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show --encryption-type ' + encryption_type,
|
||||
parse_output=True,
|
||||
)
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
'key_size': 256,
|
||||
@ -196,10 +213,11 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
for attr, value in expected.items():
|
||||
self.assertEqual(value, cmd_output['encryption'][attr])
|
||||
# test set new encryption type
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type create -f json --private ' +
|
||||
cmd_output = self.openstack(
|
||||
'volume type create --private ' +
|
||||
name,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'volume type delete ' + name,
|
||||
@ -215,9 +233,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
name)
|
||||
self.assertEqual('', raw_output)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json --encryption-type ' + name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show --encryption-type ' + name,
|
||||
parse_output=True,
|
||||
)
|
||||
expected = {'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
'key_size': 128,
|
||||
@ -229,9 +248,10 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'volume type unset --encryption-type ' + name
|
||||
)
|
||||
self.assertEqual('', raw_output)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'volume type show -f json --encryption-type ' + name
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'volume type show --encryption-type ' + name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual({}, cmd_output['encryption'])
|
||||
# test delete encryption type
|
||||
raw_output = self.openstack('volume type delete ' + encryption_type)
|
||||
|
Loading…
x
Reference in New Issue
Block a user