Ejemplo n.º 1
0
def test_get_by_ip_public_ip_nodes(create_connection_from_config,
                                   compute_instances):
    driver = gcp_driver.GCPDriver(config=GCLOUD_CONFIG)
    driver.remote_servers = compute_instances
    node_index = 1
    nodes = driver.get_by_ip(PUBLIC_IPS[node_index])
    assert compute_instances[node_index]['id'] is nodes.id
    assert compute_instances[node_index]['zone'] == 'url/' + nodes.az
    assert compute_instances[node_index]['networkInterfaces'][0][
        'accessConfigs'][0]['natIP'] == nodes.extIp
Ejemplo n.º 2
0
def test_get_by_ip_public_ip_nodes(create_compute, gcp_instances):
    driver = gcp_driver.GCPDriver()
    driver.remote_servers = gcp_instances
    node = driver.get_by_ip('33.10.0.1')

    assert node.id == gcp_instances[0]['id']
    assert node.name == gcp_instances[0]['name']
    assert node.ip == '10.10.0.1'
    assert node.extIp == '33.10.0.1'
    assert node.az == 'us-west1-a'
    assert node.state == NodeState.UP

    assert driver.get_by_ip('33.10.0.2') is None
Ejemplo n.º 3
0
def test_get_by_ip_no_nodes(create_connection_from_config, compute_instances):
    driver = gcp_driver.GCPDriver(config=GCLOUD_CONFIG)
    driver.remote_servers = compute_instances
    nodes = driver.get_by_ip(INVALID_IP)
    assert nodes is None