コード例 #1
0
class CinderCycle(object):
    def __init__(self, cinder):

        self.timer = wait.Wait()
        self.cinder_vol = CinderVolumes(cinder.cinder)
        self.volume = None

    def vol_create(self, name, size, image):

        add_test_info.sub_test_info('2', 'Create volume from image')

        init_create_volume = self.cinder_vol.create_volume(name,
                                                           size,
                                                           image_id=image)
        assert init_create_volume.status, "Volume create initialize error"
        log.info('volume name: %s' % init_create_volume.vol.name)
        self.timer.wait_for_state_change(init_create_volume.vol.status,
                                         'creating')
        volume = self.cinder_vol.get_volume(init_create_volume.vol)
        self.volume = volume.volume
        log.info('Volume exists')

        add_test_info.sub_test_completed_info()
        return self.volume

    def delete_vol(self):

        add_test_info.sub_test_info('5', 'Delete volume')

        vol_delete = self.cinder_vol.delete_volume(self.volume)
        assert vol_delete.execute, "volume delete initialize error"
        time.sleep(10)
        volume_exists = self.cinder_vol.get_volume(self.volume)
        if not volume_exists.status:
            log.info('volume deleted')
        else:
            log.error('volume status: %s' % volume_exists.volume.status)
            raise AssertionError("volume still exists")

        add_test_info.sub_test_completed_info()
コード例 #2
0
class CinderSnapCycle(object):
    def __init__(self, cinder):
        self.timer = wait.Wait()
        self.cinder_volume = CinderVolumes(cinder.cinder)
        self.cinder_snap = CinderSnapshot(cinder.cinder)
        self.volume = None
        self.snapshot = None

    def vol_create(self, name, size):

        add_test_info.sub_test_info('1', 'create_volume')
        init_create_volume = self.cinder_volume.create_volume(name, size)
        assert init_create_volume.status, "Volume create initialize error"
        log.info('volume name: %s' % init_create_volume.vol.name)
        self.timer.wait_for_state_change(init_create_volume.vol.status,
                                         'creating')
        volume = self.cinder_volume.get_volume(init_create_volume.vol)
        self.volume = volume.volume
        log.info('Volume exists')

        add_test_info.sub_test_completed_info()
        return self.volume

    def snapshot_create(self, name):

        add_test_info.sub_test_info('2', 'Snapshot creation')

        snap = self.cinder_snap.create_snapshot(self.volume, name)

        assert snap.status, "Snap create initialize error"

        log.info('snap name: %s' % snap.volume_snapshot.name)

        self.timer.wait_for_state_change(snap.volume_snapshot.status,
                                         'creating')
        snapshot = self.cinder_snap.get_snapshot(snap.volume_snapshot)

        self.snapshot = snapshot.snapshot
        log.info('Snapshot exists')

        add_test_info.sub_test_completed_info()

    def create_volume_from_snap(self, name, size):

        add_test_info.sub_test_info('3', "Create volume out of snapshot")

        snap_vol = self.cinder_snap.create_vol_from_snap(self.snapshot.id,
                                                         name=name,
                                                         size=size)
        assert snap_vol.status, "Volume from snap create initialize error"
        log.info('snapshot volume name: %s' % snap_vol.volume.name)
        self.timer.wait_for_state_change(snap_vol.volume.status, 'creating')
        snapshot_volume = self.cinder_volume.get_volume(snap_vol.volume)
        self.snapshot_volume = snapshot_volume.volume
        log.debug('status %s' % self.snapshot_volume.status)
        log.info('Snapshot volume exists')

        add_test_info.sub_test_completed_info()
        return self.snapshot_volume

    def delete_vol(self, volume):

        add_test_info.sub_test_info('4', 'delete volume')
        vol_to_delete = self.cinder_volume.delete_volume(volume=volume)

        assert vol_to_delete.execute, "snapshot volume delete initialize error"

        volume_exists = self.cinder_volume.get_volume(volume)
        self.timer.wait_for_state_change(volume_exists.volume.status,
                                         'deleting')

        log.info('status: %s' % volume_exists.volume.status)
        volume_exists = self.cinder_volume.get_volume(volume)

        if not volume_exists.status:
            log.info('snapshot volume deleted')
        else:
            log.error('volume status: %s' % volume_exists.volume.status)
            raise AssertionError("snapshot volume still exists")

        add_test_info.sub_test_completed_info()

    def snapshot_delete(self):

        add_test_info.sub_test_info('5', 'delete snapshot')
        snap_delete = self.cinder_snap.delete_snapshot(self.snapshot)

        assert snap_delete, "Snapshot delete initialize error"

        snapshot_exists = self.cinder_snap.get_snapshot(self.snapshot)
        self.timer.wait_for_state_change(snapshot_exists.snapshot.status,
                                         'deleting')

        log.info('status: %s' % snapshot_exists.snapshot.status)
        snapshot_exists = self.cinder_snap.get_snapshot(self.snapshot)

        if not snapshot_exists.status:
            log.info('snapshot deleted')
        else:
            log.error('snapshot status: %s' % snapshot_exists.snapshot.status)
            raise AssertionError("snapshot still exists")

        add_test_info.sub_test_completed_info()
コード例 #3
0
class CindeVolumeTest(object):
    def __init__(self, cinder):
        self.timer = wait.Wait()
        self.cinder_volume = CinderVolumes(cinder.cinder)
        self.cinder_backup = CinderBackup(cinder.cinder)
        self.volume = None
        self.backup = None

    def create_vol(self, name, size):

        add_test_info.sub_test_info('1', 'create volume')

        init_create_volume = self.cinder_volume.create_volume(name, size)

        assert init_create_volume.status, "Volume Create initialize error"

        log.info('volume_name %s' % init_create_volume.vol.name)

        self.timer.wait_for_state_change(init_create_volume.vol.status,
                                         'creating')
        volume = self.cinder_volume.get_volume(init_create_volume.vol)

        assert volume.status, "Volumes Does Exist, hence did not create"

        self.volume = volume.volume

        log.info('volume exist status: %s' % volume.volume.status)

        add_test_info.sub_test_completed_info()

        return self.volume

    def delete_vol(self, volume):

        add_test_info.sub_test_info('4', 'delete volume')
        vol_to_delete = self.cinder_volume.delete_volume(volume=volume)

        assert vol_to_delete.execute, "snapshot volume delete initialize error"

        volume_exists = self.cinder_volume.get_volume(volume)
        self.timer.wait_for_state_change(volume_exists.status, 'deleting')

        log.info('status: %s' % volume_exists.status)
        volume_exists = self.cinder_volume.get_volume(volume)

        if not volume_exists.status:
            log.info('snapshot volume deleted')
        else:
            log.error('volume status: %s' % volume_exists.volume.status)
            raise AssertionError("snapshot volume still exists")

        add_test_info.sub_test_completed_info()

    def take_backup(self, volume, backup_name):

        add_test_info.sub_test_info('2', 'Create volume backup')

        backup = self.cinder_backup.create_backup(volume, name=backup_name)
        assert backup.status, "creating backup failed"

        self.backup = backup.volume_backup
        self.timer.wait_for_state_change(self.backup.status, 'backing-up')

        add_test_info.sub_test_completed_info()

        return self.backup

    def restore_backup(self, backup, volume):

        add_test_info.sub_test_info('3', 'Restore volume backup')

        restore = self.cinder_backup.restore_backup(backup, volume)
        restored_vol = self.cinder_volume.get_volume(volume)
        self.timer.wait_for_state_change(restored_vol.volume.status,
                                         'restoring-backup')

        assert restore.execute, "Restoring Failed"
        add_test_info.sub_test_completed_info()

        return restore

    def delete_backup(self, backup):

        add_test_info.sub_test_info('5', 'delete backup')
        backup_to_delete = self.cinder_backup.delete_backup(backup)

        assert backup_to_delete.execute, "Backup delete initialize error"

        backup_exists = self.cinder_backup.get_backup(backup_to_delete)
        self.timer.wait_for_state_change(backup_exists.status, 'deleting')

        log.info('status: %s' % backup_exists.status)
        backup_exists = self.cinder_backup.get_backup(backup_to_delete)

        if not backup_exists.status:
            log.info('backup deleted')
        else:
            log.error('Backup status: %s' % backup_exists.status)
            raise AssertionError("Backup still exists")

        add_test_info.sub_test_completed_info()
コード例 #4
0
class CinderVolumeTest(object):
    def __init__(self, cinder):
        self.timer = wait.Wait()
        self.cinder_volume = CinderVolumes(cinder.cinder)
        self.volume = None

    def create_vol(self, name, size):

        add_test_info.sub_test_info('1', 'create volume')

        init_create_volume = self.cinder_volume.create_volume(name, size)

        assert init_create_volume.status, "Volume Create initialize error"

        log.info('volume_name %s' % init_create_volume.vol.name)

        self.timer.wait_for_state_change(init_create_volume.vol.status,
                                         'creating')
        volume = self.cinder_volume.get_volume(init_create_volume.vol)

        assert volume.status, "Volumes Does Exist, hence did not create"

        self.volume = volume.volume

        log.info('volume exist status: %s' % volume.volume.status)

        add_test_info.sub_test_completed_info()

    def extend_vol(self, extend_size):

        add_test_info.sub_test_info('2', 'extend volume')

        old_size = self.volume.size
        new_size = old_size + extend_size
        log.info('new size: %s' % new_size)
        log.info('old size: %s' % old_size)
        extended = self.cinder_volume.extend_volume(self.volume, new_size)

        assert extended.execute, "volume extend initialize error"

        volume = self.cinder_volume.get_volume(self.volume)
        self.timer.wait_for_state_change(volume.volume.status, 'extending')
        volume = self.cinder_volume.get_volume(self.volume)

        if volume.volume.size == new_size:
            log.info('volume extended, size: %s' % volume.volume.size)
            self.volume = volume.volume
        else:
            raise AssertionError("volume did not extend")

        add_test_info.sub_test_completed_info()

    def delete_vol(self):

        add_test_info.sub_test_info('3', 'delete volume')

        vol_delete = self.cinder_volume.delete_volume(self.volume)

        assert vol_delete.execute, "volume delete initialize error"
        volume_exists = self.cinder_volume.get_volume(self.volume)
        self.timer.wait_for_state_change(volume_exists.volume.status,
                                         'deleting')
        volume_exists = self.cinder_volume.get_volume(self.volume)

        if not volume_exists.status:
            log.info('volume deleted')
        else:
            log.error('volume status: %s' % volume_exists.volume.status)
            raise AssertionError("volume still exists")

        add_test_info.sub_test_completed_info()