Exemplo n.º 1
0
async def async_snapshots_creater(instance):
    vm = Instance(instance)
    logger.info(f'Preparing instance {vm.name} to create a snapshot')
    if vm.get_data():
        if vm.status not in NEGATIVE_STATES:
            stop_vm = vm.operation_complete(vm.stop())
            STOPPED_INSTANCES.append(instance)
            if stop_vm:
                await vm.async_operation_complete(vm.create_snapshot())

        else:
            logger.info(f'Instance {vm.name} already stopped.')
            await vm.async_operation_complete(vm.create_snapshot())
Exemplo n.º 2
0
def snapshots_creater():
    logger.info('Preparing instances to create a snapshot')
    for instance in INSTANCES:
        vm = Instance(instance)

        if vm.get_data():
            if vm.status not in NEGATIVE_STATES:
                stop_vm = vm.stop()
                if vm.operation_complete(stop_vm):
                    snap_create = vm.create_snapshot()
                if vm.operation_complete(snap_create):
                    if vm.status not in POSITIVE_STATES:
                        start_vm = vm.start()
                        if vm.operation_complete(start_vm):
                            continue

            else:
                logger.info(f'Instance {vm.name} already stopped.')
                create_snap = vm.create_snapshot()
                if vm.operation_complete(create_snap):
                    continue