Beispiel #1
0
def test_install_vm(flops_client, flops_debian_distributions,
                    flops_linux_tariffs):
    name = '__test_install_vm'
    distribution = flops_debian_distributions[-1]
    distribution_id = distribution['id']
    tariff = flops_linux_tariffs[0]
    tariff_id = tariff['id']

    res_install = flops_client.install_vm(name=name,
                                          distribution_id=distribution_id,
                                          tariff_id=tariff_id,
                                          send_password=False,
                                          password=generate_password(32),
                                          public_key_ids=[])

    assert res_install
    operation_id = res_install['operation_id']
    vm_id = res_install['vm_id']

    operation_result = flops_client.wait_for_operation(
        operation_id, timeout=OPERATION_TIMEOUT)
    assert operation_result
    assert operation_result['id'] == operation_id
    assert operation_result['percentage'] == 100
    assert operation_result['vm_id'] == vm_id
    assert operation_result['operation_type'] == 'VM_INSTALL'

    res_get = flops_client.get_vm(vm_id)
    assert res_get
    assert res_get['id'] == vm_id
    assert res_get['name'] == name
    assert res_get['tariff_id'] == tariff_id
    assert res_get['cpu'] == tariff['cpu']
    assert res_get['disk'] == tariff['disk']
    assert res_get['memory'] == tariff['memory']
Beispiel #2
0
def test_change_vm_password(flops_client, flops_vm_single):
    vm_id = flops_vm_single['id']
    vm_ip = get_vm_1st_puplic_ip(flops_vm_single)
    password = generate_password(16)
    Ping(vm_ip, 22).wait_for_ping(blocking_timeout=VM_READY_TIMEOUT)
    res = flops_client.change_vm_password(vm_id, password)
    assert res
    operation_id = res['operation_id']

    operation_result = flops_client.get_operation_status(operation_id)
    assert operation_result['operation_type'] == 'VM_PASSWORD_CHANGE'
Beispiel #3
0
def flops_vm(flops_client, flops_debian_distributions, flops_linux_tariffs):
    name = generate_name('__test_flops_vm')
    distribution = flops_debian_distributions[-1]
    distribution_id = distribution['id']
    tariff = flops_linux_tariffs[0]
    tariff_id = tariff['id']

    res = flops_client.install_vm(
        name=name,
        distribution_id=distribution_id,
        tariff_id=tariff_id,
        send_password=False,
        password=generate_password(
            32))  # password is required for send_password=False
    operation_id = res['operation_id']
    vm_id = res['vm_id']
    flops_client.wait_for_operation(operation_id, timeout=5)
    yield flops_client.get_vm(vm_id)
    try:
        flops_client.delete_pubkey(vm_id)
    except NotFoundError:
        pass
Beispiel #4
0
def flops_2nd_vm_single(flops_client, flops_debian_distributions):
    name = generate_name('__test_flops_2nd_vm_session')
    distribution = flops_debian_distributions[-1]
    distribution_id = distribution['id']
    tariff = flops_client.get_tariffs(on_demand=True, for_windows=False)[0]
    tariff_id = tariff['id']

    res = flops_client.install_vm(name=name,
                                  distribution_id=distribution_id,
                                  tariff_id=tariff_id,
                                  send_password=False,
                                  password=generate_password(32),
                                  disk=8192,
                                  memory=512,
                                  cpu=1,
                                  ip_count=1)
    operation_id = res['operation_id']
    vm_id = res['vm_id']
    flops_client.wait_for_operation(operation_id, timeout=10)
    yield flops_client.get_vm(vm_id)
    try:
        flops_client.delete_pubkey(vm_id)
    except NotFoundError:
        pass