
The show command currently just dumps the entire attachments dictionary into the output which is a real mess and completely screws up the displayed output (shell command). There's really no reason to do this, we can just give the attachment ID's and then when you're on the newer versions you can do an attachment-show for all the crazy details if you want. Keep in mind that the list command already shows the server-id we're attached too, but that might also be nice from the show command rather than jumping through multiple commands. To try and accomodate various use cases we'll also add an "attached_servers" field to the show command, but you'll have to coorelate manually from there. Change-Id: I45ac49d8d9a185c52727c5bc24a6a1323be83689 Closes-Bug: #1494941
97 lines
4.1 KiB
Python
97 lines
4.1 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
|
|
from cinderclient.tests.functional import base
|
|
|
|
|
|
class CinderVolumeTests(base.ClientTestBase):
|
|
"""Check of base cinder volume commands."""
|
|
|
|
VOLUME_PROPERTY = ('attachment_ids', 'attached_servers',
|
|
'availability_zone', 'bootable',
|
|
'created_at', 'description', 'encrypted', 'id',
|
|
'metadata', 'name', 'size', 'status',
|
|
'user_id', 'volume_type')
|
|
|
|
def test_volume_create_delete_id(self):
|
|
"""Create and delete a volume by ID."""
|
|
volume = self.object_create('volume', params='1')
|
|
self.assert_object_details(self.VOLUME_PROPERTY, volume.keys())
|
|
self.object_delete('volume', volume['id'])
|
|
self.check_object_deleted('volume', volume['id'])
|
|
|
|
def test_volume_create_delete_name(self):
|
|
"""Create and delete a volume by name."""
|
|
volume = self.object_create('volume',
|
|
params='1 --name TestVolumeNamedCreate')
|
|
|
|
self.cinder('delete', params='TestVolumeNamedCreate')
|
|
self.check_object_deleted('volume', volume['id'])
|
|
|
|
def test_volume_show(self):
|
|
"""Show volume details."""
|
|
volume = self.object_create('volume', params='1 --name TestVolumeShow')
|
|
output = self.cinder('show', params='TestVolumeShow')
|
|
volume = self._get_property_from_output(output)
|
|
self.assertEqual('TestVolumeShow', volume['name'])
|
|
self.assert_object_details(self.VOLUME_PROPERTY, volume.keys())
|
|
|
|
self.object_delete('volume', volume['id'])
|
|
self.check_object_deleted('volume', volume['id'])
|
|
|
|
def test_volume_extend(self):
|
|
"""Extend a volume size."""
|
|
volume = self.object_create('volume',
|
|
params='1 --name TestVolumeExtend')
|
|
self.cinder('extend', params="%s %s" % (volume['id'], 2))
|
|
self.wait_for_object_status('volume', volume['id'], 'available')
|
|
output = self.cinder('show', params=volume['id'])
|
|
volume = self._get_property_from_output(output)
|
|
self.assertEqual('2', volume['size'])
|
|
|
|
self.object_delete('volume', volume['id'])
|
|
self.check_object_deleted('volume', volume['id'])
|
|
|
|
|
|
class CinderSnapshotTests(base.ClientTestBase):
|
|
"""Check of base cinder snapshot commands."""
|
|
|
|
SNAPSHOT_PROPERTY = ('created_at', 'description', 'metadata', 'id',
|
|
'name', 'size', 'status', 'volume_id')
|
|
|
|
def test_snapshot_create_and_delete(self):
|
|
"""Create a volume snapshot and then delete."""
|
|
volume = self.object_create('volume', params='1')
|
|
snapshot = self.object_create('snapshot', params=volume['id'])
|
|
self.assert_object_details(self.SNAPSHOT_PROPERTY, snapshot.keys())
|
|
self.object_delete('snapshot', snapshot['id'])
|
|
self.check_object_deleted('snapshot', snapshot['id'])
|
|
self.object_delete('volume', volume['id'])
|
|
self.check_object_deleted('volume', volume['id'])
|
|
|
|
|
|
class CinderBackupTests(base.ClientTestBase):
|
|
"""Check of base cinder backup commands."""
|
|
|
|
BACKUP_PROPERTY = ('id', 'name', 'volume_id')
|
|
|
|
def test_backup_create_and_delete(self):
|
|
"""Create a volume backup and then delete."""
|
|
volume = self.object_create('volume', params='1')
|
|
backup = self.object_create('backup', params=volume['id'])
|
|
self.assert_object_details(self.BACKUP_PROPERTY, backup.keys())
|
|
self.object_delete('volume', volume['id'])
|
|
self.check_object_deleted('volume', volume['id'])
|
|
self.object_delete('backup', backup['id'])
|
|
self.check_object_deleted('backup', backup['id'])
|