示例#1
0
class NovaCycle(object):

    def __init__(self, nova):

        self.timer = wait.Wait()
        self.nova_server = NovaActions(nova.nova)
        self.vm = None

    def boot_server(self, image, name):

        add_test_info.sub_test_info('2', 'Create VM')
        vm = self.nova_server.boot_vm(image=image, name=name)
        assert vm.status, 'Vm creation initialization error'
        log.info('server name: %s' % vm.server.name)
        self.timer.wait_for_state_change(vm.server.status, 'BUILD')
        self.vm = self.nova_server.vm_details(vm.server)
        log.debug('status: %s' % self.vm.vm.status)
        log.info('VM created')

        add_test_info.sub_test_completed_info()

    def delete_server(self):

        add_test_info.sub_test_info('3', 'Delete VM')

        vm_to_delete = self.nova_server.vm_delete(self.vm.vm)
        assert vm_to_delete.execute, 'VM deletion error'
        vm_exists = self.nova_server.vm_details(self.vm.vm)
        self.timer.wait_for_state_change(vm_exists.vm.status, 'ACTIVE')
        time.sleep(10)

        log.info('status: %s' % vm_exists.vm.status)

        vm_exists = self.nova_server.vm_details(self.vm.vm)

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

        add_test_info.sub_test_completed_info()
class NovaCycle(object):
    def __init__(self, nova):

        self.timer = wait.Wait()
        self.nova_server = NovaActions(nova.nova)
        self.vm = None

    def boot_server(self, image, name):

        add_test_info.sub_test_info("2", "Create VM")
        vm = self.nova_server.boot_vm(image=image, name=name)
        assert vm.status, "Vm creation initialization error"
        log.info("server name: %s" % vm.server.name)
        self.timer.wait_for_state_change(vm.server.status, "BUILD")
        self.vm = self.nova_server.vm_details(vm.server)
        log.debug("status: %s" % self.vm.vm.status)
        log.info("VM created")

        add_test_info.sub_test_completed_info()

    def delete_server(self):

        add_test_info.sub_test_info("3", "Delete VM")

        vm_to_delete = self.nova_server.vm_delete(self.vm.vm)
        assert vm_to_delete.execute, "VM deletion error"
        vm_exists = self.nova_server.vm_details(self.vm.vm)
        self.timer.wait_for_state_change(vm_exists.vm.status, "ACTIVE")
        time.sleep(10)

        log.info("status: %s" % vm_exists.vm.status)

        vm_exists = self.nova_server.vm_details(self.vm.vm)

        if not vm_exists.status:
            log.info("VM deleted")
        else:
            log.error("VM status: %s" % vm_exists.vm.status)
            raise AssertionError("VM still exists")

        add_test_info.sub_test_completed_info()
示例#3
0
class NovaCycle(object):
    def __init__(self, nova):

        self.timer = wait.Wait()
        self.nova_server = NovaActions(nova.nova)
        self.vm = None
        self.attached_volume = None

    def boot_server(self, volume, name):

        add_test_info.sub_test_info('3', 'Create VM')

        vm = self.nova_server.boot_vm(name=name, volume_id=volume)
        assert vm.status, 'Vm creation initialization error'
        log.info('server name: %s' % vm.server.name)
        self.timer.wait_for_state_change(vm.server.status, 'BUILD')
        time.sleep(10)
        self.vm = self.nova_server.vm_details(vm.server)
        log.debug('status: %s' % self.vm.vm.status)
        log.info('VM created')

        add_test_info.sub_test_completed_info()

    def delete_server(self):

        add_test_info.sub_test_info('4', 'Delete server')
        vm_delete = self.nova_server.vm_delete(self.vm.vm.id)
        assert vm_delete.execute, "Server delete initialize error"

        time.sleep(5)

        vm_exists = self.nova_server.vm_details(self.vm.vm)

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

        add_test_info.sub_test_completed_info()
    def __init__(self, nova):

        self.timer = wait.Wait()
        self.nova_server = NovaActions(nova.nova)
        self.vm = None
示例#5
0
    def __init__(self, nova):

        self.timer = wait.Wait()
        self.nova_server = NovaActions(nova.nova)
        self.vm = None
        self.attached_volume = None
class NovaCycle(object):
    def __init__(self, nova):

        self.timer = wait.Wait()
        self.nova_server = NovaActions(nova.nova)
        self.vm = None

    def boot_server(self, image, name):

        add_test_info.sub_test_info('2', 'Create VM')
        vm = self.nova_server.boot_vm(image=image, name=name)
        assert vm.status, 'Vm creation initialization error'
        log.info('server name: %s' % vm.server.name)
        self.timer.wait_for_state_change(vm.server.status, 'BUILD')
        self.vm = self.nova_server.vm_details(vm.server)
        log.debug('status: %s' % self.vm.vm.status)
        log.info('VM created')

        add_test_info.sub_test_completed_info()
        return self.vm.vm

    def create_snap(self, name):

        add_test_info.sub_test_info('3', 'Create VM snap')
        snapshot = self.nova_server.vm_snap(self.vm.vm, name=name)
        assert snapshot.status, 'Vm snap creation error'
        self.snap = self.nova_server.get_snap(snapshot.snap)
        log.info('VM snap name: %s' % self.snap.snap.name)
        time.sleep(10)
        self.timer.wait_for_state_change(self.snap.snap.status, 'SAVING')
        if self.snap:
            log.info('Snap %s created' % self.snap)
        else:
            log.error('Snap creation failed')

        add_test_info.sub_test_completed_info()

    def boot_from_snap(self, name):

        add_test_info.sub_test_info('4', 'Boot VM from snap')
        server = self.nova_server.boot_from_snap(self.snap.snap.id, name=name)
        assert server.status, 'VM frm snap creation successful'
        log.info('VM name: %s' % server.server.name)
        self.timer.wait_for_state_change(server.server.status, 'BUILD')
        vm = self.nova_server.vm_details(server.server)
        log.debug('status: %s' % vm.vm.status)
        log.info('VM from snap created')

        add_test_info.sub_test_completed_info()
        return vm.vm

    def delete_server(self, server):

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

        vm_to_delete = self.nova_server.vm_delete(server)
        assert vm_to_delete.execute, 'VM deletion error'
        vm_exists = self.nova_server.vm_details(server)
        self.timer.wait_for_state_change(vm_exists.vm.status, 'ACTIVE')

        log.info('status: %s' % vm_exists.vm.status)
        time.sleep(10)

        vm_exists = self.nova_server.vm_details(server)

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

        add_test_info.sub_test_completed_info()

    def delete_snap(self):

        add_test_info.sub_test_info('6', 'Delete VM snap')
        snap_to_delete = self.nova_server.snap_delete(self.snap.snap)
        assert snap_to_delete.execute, 'Snap deletion error'
        snapshot = self.nova_server.get_snap(self.snap.snap)
        self.timer.wait_for_state_change(snapshot.snap.status, 'ACTIVE')

        log.info('status: %s' % snapshot.snap.status)

        snap_exists = self.nova_server.get_snap(self.snap.snap)

        if snap_exists.snap.status == 'DELETED':
            log.info('VM snap deleted')
        else:
            log.error('Snap status: %s' % snap_exists.snap.status)
            raise AssertionError('VM snap still exists')

        add_test_info.sub_test_completed_info()
class NovaCycle(object):
    def __init__(self, nova):

        self.timer = wait.Wait()
        self.nova_server = NovaActions(nova.nova)
        self.vm = None
        self.attached_volume = None

    def boot_server(self, image, name):

        add_test_info.sub_test_info("3", "Create VM")

        vm = self.nova_server.boot_vm(image=image, name=name)
        assert vm.status, "Vm creation initialization error"
        log.info("server name: %s" % vm.server.name)
        self.timer.wait_for_state_change(vm.server.status, "BUILD")
        time.sleep(10)
        self.vm = self.nova_server.vm_details(vm.server)
        log.debug("status: %s" % self.vm.vm.status)
        log.info("VM created")

        add_test_info.sub_test_completed_info()

    def attach_vol(self, volume, device):

        add_test_info.sub_test_info("4", "Attach volume to VM")

        self.attached_volume = self.nova_server.attach_volume(
            self.vm.vm.id, volume=volume.id, device=device
        )
        time.sleep(10)

        assert self.attached_volume.status, "volume attach failed"

        log.debug(
            "volume %s attached to server %s"
            % (self.attached_volume.vol.id, self.vm.vm.name)
        )
        log.info("Volume attached to VM successfully")

        add_test_info.sub_test_completed_info()

    def detach_vol(self, volume):

        add_test_info.sub_test_info("5", "Detach volume to VM")

        self.nova_server.detach_volume(self.vm.vm.id, volume=volume.id)
        time.sleep(10)
        log.debug(
            "volume %s detached from server %s"
            % (self.attached_volume.vol.volumeId, self.vm.vm.name)
        )
        log.info("Volume detached successfully")

        add_test_info.sub_test_completed_info()

    def delete_server(self):

        add_test_info.sub_test_info("7", "Delete server")
        vm_delete = self.nova_server.vm_delete(self.vm.vm.id)
        assert vm_delete.execute, "Server delete initialize error"

        time.sleep(5)

        vm_exists = self.nova_server.vm_details(self.vm.vm)

        if not vm_exists.status:
            log.info("Server deleted")
        else:
            log.error("Server status: %s" % vm_exists.vm.status)
            raise AssertionError("Server still exists")

        add_test_info.sub_test_completed_info()
class NovaCycle(object):
    def __init__(self, nova):

        self.timer = wait.Wait()
        self.nova_server = NovaActions(nova.nova)
        self.vm = None

    def boot_server(self, image, name):

        add_test_info.sub_test_info("2", "Create VM")
        vm = self.nova_server.boot_vm(image=image, name=name)
        assert vm.status, "Vm creation initialization error"
        log.info("server name: %s" % vm.server.name)
        self.timer.wait_for_state_change(vm.server.status, "BUILD")
        self.vm = self.nova_server.vm_details(vm.server)
        log.debug("status: %s" % self.vm.vm.status)
        log.info("VM created")

        add_test_info.sub_test_completed_info()
        return self.vm.vm

    def create_snap(self, name):

        add_test_info.sub_test_info("3", "Create VM snap")
        snapshot = self.nova_server.vm_snap(self.vm.vm, name=name)
        assert snapshot.status, "Vm snap creation error"
        self.snap = self.nova_server.get_snap(snapshot.snap)
        log.info("VM snap name: %s" % self.snap.snap.name)
        time.sleep(10)
        self.timer.wait_for_state_change(self.snap.snap.status, "SAVING")
        if self.snap:
            log.info("Snap %s created" % self.snap)
        else:
            log.error("Snap creation failed")

        add_test_info.sub_test_completed_info()

    def boot_from_snap(self, name):

        add_test_info.sub_test_info("4", "Boot VM from snap")
        server = self.nova_server.boot_from_snap(self.snap.snap.id, name=name)
        assert server.status, "VM frm snap creation successful"
        log.info("VM name: %s" % server.server.name)
        self.timer.wait_for_state_change(server.server.status, "BUILD")
        vm = self.nova_server.vm_details(server.server)
        log.debug("status: %s" % vm.vm.status)
        log.info("VM from snap created")

        add_test_info.sub_test_completed_info()
        return vm.vm

    def delete_server(self, server):

        add_test_info.sub_test_info("5", "Delete VM")

        vm_to_delete = self.nova_server.vm_delete(server)
        assert vm_to_delete.execute, "VM deletion error"
        vm_exists = self.nova_server.vm_details(server)
        self.timer.wait_for_state_change(vm_exists.vm.status, "ACTIVE")

        log.info("status: %s" % vm_exists.vm.status)
        time.sleep(10)

        vm_exists = self.nova_server.vm_details(server)

        if not vm_exists.status:
            log.info("VM deleted")
        else:
            log.error("VM status: %s" % vm_exists.vm.status)
            raise AssertionError("VM still exists")

        add_test_info.sub_test_completed_info()

    def delete_snap(self):

        add_test_info.sub_test_info("6", "Delete VM snap")
        snap_to_delete = self.nova_server.snap_delete(self.snap.snap)
        assert snap_to_delete.execute, "Snap deletion error"
        snapshot = self.nova_server.get_snap(self.snap.snap)
        self.timer.wait_for_state_change(snapshot.snap.status, "ACTIVE")

        log.info("status: %s" % snapshot.snap.status)

        snap_exists = self.nova_server.get_snap(self.snap.snap)

        if snap_exists.snap.status == "DELETED":
            log.info("VM snap deleted")
        else:
            log.error("Snap status: %s" % snap_exists.snap.status)
            raise AssertionError("VM snap still exists")

        add_test_info.sub_test_completed_info()