Exemplo n.º 1
0
def test_construct_instance_ip(vmi_model, project, security_group):
    vmi_model.parent = project
    vmi_model.security_group = security_group
    vmi_model.vn_model.vnc_vn.external_ipam = None

    vmi_model.construct_instance_ip()
    instance_ip = vmi_model.vnc_instance_ip

    assert instance_ip.instance_ip_address is None
    assert instance_ip.virtual_machine_interface_refs[0]['uuid'] == vmi_model.uuid
    expected_uuid = VirtualMachineInterfaceModel.construct_instance_ip_uuid(instance_ip.display_name)
    assert instance_ip.uuid == expected_uuid
Exemplo n.º 2
0
def instance_ip(vnc_vmi, vnc_vn_1, vnc_vm):
    ip_name = 'ip-' + vnc_vn_1.name + '-' + vnc_vm.name
    ip_uuid = VirtualMachineInterfaceModel.construct_instance_ip_uuid(ip_name)

    ip = vnc_api.InstanceIp(
        name=ip_uuid,
        display_name=ip_name,
        id_perms=ID_PERMS,
    )

    ip.set_instance_ip_address('10.10.10.1')
    ip.set_uuid(ip_uuid)
    ip.set_virtual_network(vnc_vn_1)
    ip.set_virtual_machine_interface(vnc_vmi)
    ip.annotations = ip.annotations or vnc_api.KeyValuePairs()
    ip.annotations.add_key_value_pair(
        vnc_api.KeyValuePair('vrouter-uuid', 'vrouter-uuid-1'))
    ip.annotations.add_key_value_pair(vnc_api.KeyValuePair('key-1', 'value-1'))
    return ip