com.microsoft.azure.management.network.NicIPConfiguration Java Examples

The following examples show how to use com.microsoft.azure.management.network.NicIPConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NetworkInterfaceInventoryCollector.java    From pacbot with Apache License 2.0 6 votes vote down vote up
private void setipConfigurations(Map<String, NicIPConfiguration> ipConfigurations,
		NetworkInterfaceVH networkInterfaceVH) {
	List<NIIPConfigVH> ipConfigurationList = new ArrayList<>();
	for (Map.Entry<String, NicIPConfiguration> entry : ipConfigurations.entrySet()) {
		NIIPConfigVH niipConfigVH = new NIIPConfigVH();
		niipConfigVH.setName(entry.getValue().name());
		niipConfigVH.setPrivateIPAddress(entry.getValue().privateIPAddress());
		niipConfigVH.setPrivateIPAddressVersion(entry.getValue().privateIPAddressVersion() != null
				? entry.getValue().privateIPAddressVersion().toString()
				: "");
		niipConfigVH.setNetworkName(entry.getValue().getNetwork().name());
		niipConfigVH.setSubnetName(entry.getValue().subnetName());
		niipConfigVH.setPrimary(entry.getValue().isPrimary());
		niipConfigVH.setPublicIPAddress(
				entry.getValue().getPublicIPAddress() != null ? entry.getValue().getPublicIPAddress().ipAddress()
						: "");
		ipConfigurationList.add(niipConfigVH);
	}
	networkInterfaceVH.setIpConfigurationList(ipConfigurationList);
}
 
Example #2
Source File: NetworkInterfaceImpl.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * @return the primary IP configuration of the network interface
 */
@Override
public NicIPConfigurationImpl primaryIPConfiguration() {
    NicIPConfigurationImpl primaryIPConfig = null;
    if (this.nicIPConfigurations.size() == 0) {
        // If no primary IP config found yet, then create one automatically, otherwise the NIC is in a bad state
        primaryIPConfig = prepareNewNicIPConfiguration("primary");
        primaryIPConfig.inner().withPrimary(true);
        withIPConfiguration(primaryIPConfig);
    } else if (this.nicIPConfigurations.size() == 1) {
        // If there is only one IP config, assume it is primary, regardless of the Primary flag
        primaryIPConfig = (NicIPConfigurationImpl) this.nicIPConfigurations.values().iterator().next();
    } else {
        // If multiple IP configs, then find the one marked as primary
        for (NicIPConfiguration ipConfig : this.nicIPConfigurations.values()) {
            if (ipConfig.isPrimary()) {
                primaryIPConfig = (NicIPConfigurationImpl) ipConfig;
                break;
            }
        }
    }

    // Return the found primary IP config, including null, if no primary IP config can be identified
    // in which case the NIC is in a bad state anyway
    return primaryIPConfig;
}
 
Example #3
Source File: ApplicationGatewayBackendServerHealthImpl.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
@Override
public NicIPConfiguration getNetworkInterfaceIPConfiguration() {
    if (this.inner().ipConfiguration() == null) {
        return null;
    }
    String nicIPConfigId = this.inner().ipConfiguration().id();
    if (nicIPConfigId == null) {
        return null;
    }

    String nicIPConfigName = ResourceUtils.nameFromResourceId(nicIPConfigId);
    String nicId = ResourceUtils.parentResourceIdFromResourceId(nicIPConfigId);
    NetworkInterface nic = this.parent().parent().parent().manager().networkInterfaces().getById(nicId);
    if (nic == null) {
        return null;
    } else {
        return nic.ipConfigurations().get(nicIPConfigName);
    }
}
 
Example #4
Source File: AzureMetadataCollectorTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private VirtualMachine createVirtualMachine(String name) {
    VirtualMachine virtualMachine = mock(VirtualMachine.class);
    NetworkInterface networkInterface = mock(NetworkInterface.class);
    NicIPConfiguration nicIPConfiguration = mock(NicIPConfiguration.class);
    when(virtualMachine.name()).thenReturn(name);
    when(virtualMachine.getPrimaryNetworkInterface()).thenReturn(networkInterface);
    when(networkInterface.primaryIPConfiguration()).thenReturn(nicIPConfiguration);
    when(networkInterface.primaryPrivateIP()).thenReturn(PRIVATE_IP);
    when(nicIPConfiguration.subnetName()).thenReturn(SUBNET_NAME);
    return virtualMachine;
}
 
Example #5
Source File: NetworkInterfaceImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public Update withoutLoadBalancerInboundNatRules() {
    for (NicIPConfiguration ipConfig : this.ipConfigurations().values()) {
        this.updateIPConfiguration(ipConfig.name())
            .withoutLoadBalancerInboundNatRules();
    }
    return this;
}
 
Example #6
Source File: NetworkInterfaceImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public Update withoutLoadBalancerBackends() {
    for (NicIPConfiguration ipConfig : this.ipConfigurations().values()) {
        this.updateIPConfiguration(ipConfig.name())
            .withoutLoadBalancerBackends();
    }
    return this;
}
 
Example #7
Source File: LoadBalancerImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
protected void afterCreating() {
    if (this.nicsInBackends != null) {
        List<Exception> nicExceptions = new ArrayList<>();

        // Update the NICs to point to the backend pool
        for (Entry<String, String> nicInBackend : this.nicsInBackends.entrySet()) {
            String nicId = nicInBackend.getKey();
            String backendName = nicInBackend.getValue();
            try {
                NetworkInterface nic = this.manager().networkInterfaces().getById(nicId);
                NicIPConfiguration nicIP = nic.primaryIPConfiguration();
                nic.update()
                    .updateIPConfiguration(nicIP.name())
                        .withExistingLoadBalancerBackend(this, backendName)
                        .parent()
                    .apply();
            } catch (Exception e) {
                nicExceptions.add(e);
            }
        }

        if (!nicExceptions.isEmpty()) {
            throw new CompositeException(nicExceptions);
        }

        this.nicsInBackends.clear();
        this.refresh();
    }
}
 
Example #8
Source File: SubnetImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public Collection<NicIPConfiguration> listNetworkInterfaceIPConfigurations() {
    Collection<NicIPConfiguration> ipConfigs = new ArrayList<>();
    Map<String, NetworkInterface> nics = new TreeMap<>();
    List<IPConfiguration> ipConfigRefs = this.inner().ipConfigurations();
    if (ipConfigRefs == null) {
        return ipConfigs;
    }

    for (IPConfiguration ipConfigRef : ipConfigRefs) {
        String nicID = ResourceUtils.parentResourceIdFromResourceId(ipConfigRef.id());
        String ipConfigName = ResourceUtils.nameFromResourceId(ipConfigRef.id());
        // Check if NIC already cached
        NetworkInterface nic = nics.get(nicID.toLowerCase());
        if (nic == null) {
            //  NIC not previously found, so ask Azure for it
            nic = this.parent().manager().networkInterfaces().getById(nicID);
        }

        if (nic == null) {
            // NIC doesn't exist so ignore this bad reference
            continue;
        }

        // Cache the NIC
        nics.put(nic.id().toLowerCase(), nic);

        // Get the IP config
        NicIPConfiguration ipConfig = nic.ipConfigurations().get(ipConfigName);
        if (ipConfig == null) {
            // IP config not found, so ignore this bad reference
            continue;
        }

        ipConfigs.add(ipConfig);
    }

    return Collections.unmodifiableCollection(ipConfigs);
}
 
Example #9
Source File: PublicIPAddressImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public NicIPConfiguration getAssignedNetworkInterfaceIPConfiguration() {
    if (this.hasAssignedNetworkInterface()) {
        final String refId = this.inner().ipConfiguration().id();
        final String parentId = ResourceUtils.parentResourceIdFromResourceId(refId);
        final NetworkInterface nic = this.myManager.networkInterfaces().getById(parentId);
        final String childName = ResourceUtils.nameFromResourceId(refId);
        return nic.ipConfigurations().get(childName);
    } else {
        return null;
    }
}
 
Example #10
Source File: NicIPConfigurationImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
protected static void ensureConfigurations(Collection<NicIPConfiguration> nicIPConfigurations) {
    for (NicIPConfiguration nicIPConfiguration : nicIPConfigurations) {
        NicIPConfigurationImpl config = (NicIPConfigurationImpl) nicIPConfiguration;
        config.inner().withSubnet(config.subnetToAssociate());
        config.inner().withPublicIPAddress(config.publicIPToAssociate());
    }
}
 
Example #11
Source File: TestNetworkInterface.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public NetworkInterface updateResource(NetworkInterface resource) throws Exception {
    resource =  resource.update()
            .withoutIPForwarding()
            .withoutAcceleratedNetworking()
            .withSubnet("subnet2")
            .updateIPConfiguration("primary")  // Updating the primary IP configuration
                .withPrivateIPAddressDynamic() // Equivalent to ..update().withPrimaryPrivateIPAddressDynamic()
                .withoutPublicIPAddress()      // Equivalent to ..update().withoutPrimaryPublicIPAddress()
                .parent()
            .withTag("tag1", "value1")
            .withTag("tag2", "value2")
            .apply();

    // Verifications
    Assert.assertFalse(resource.isAcceleratedNetworkingEnabled());
    Assert.assertFalse(resource.isIPForwardingEnabled());
    NicIPConfiguration primaryIpConfig = resource.primaryIPConfiguration();
    Assert.assertNotNull(primaryIpConfig);
    Assert.assertTrue(primaryIpConfig.isPrimary());
    Assert.assertTrue("subnet2".equalsIgnoreCase(primaryIpConfig.subnetName()));
    Assert.assertNull(primaryIpConfig.publicIPAddressId());
    Assert.assertTrue(resource.tags().containsKey("tag1"));

    Assert.assertEquals(1,  resource.ipConfigurations().size());

    resource.updateTags()
            .withoutTag("tag1")
            .withTag("tag3", "value3")
            .applyTags();
    Assert.assertFalse(resource.tags().containsKey("tag1"));
    Assert.assertEquals("value3", resource.tags().get("tag3"));
    return resource;
}
 
Example #12
Source File: TestPublicIPAddress.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
public static void printPIP(PublicIPAddress resource) {
    StringBuilder info = new StringBuilder().append("Public IP Address: ").append(resource.id())
            .append("\n\tName: ").append(resource.name())
            .append("\n\tResource group: ").append(resource.resourceGroupName())
            .append("\n\tRegion: ").append(resource.region())
            .append("\n\tTags: ").append(resource.tags())
            .append("\n\tIP Address: ").append(resource.ipAddress())
            .append("\n\tLeaf domain label: ").append(resource.leafDomainLabel())
            .append("\n\tFQDN: ").append(resource.fqdn())
            .append("\n\tReverse FQDN: ").append(resource.reverseFqdn())
            .append("\n\tIdle timeout (minutes): ").append(resource.idleTimeoutInMinutes())
            .append("\n\tIP allocation method: ").append(resource.ipAllocationMethod().toString())
            .append("\n\tIP version: ").append(resource.version().toString());

    // Show the associated load balancer if any
    info.append("\n\tLoad balancer association: ");
    if (resource.hasAssignedLoadBalancer()) {
        final LoadBalancerPublicFrontend frontend = resource.getAssignedLoadBalancerFrontend();
        final LoadBalancer lb = frontend.parent();
        info.append("\n\t\tLoad balancer ID: ").append(lb.id())
            .append("\n\t\tFrontend name: ").append(frontend.name());
    } else {
        info.append("(None)");
    }

    // Show the associated NIC if any
    info.append("\n\tNetwork interface association: ");
    if (resource.hasAssignedNetworkInterface()) {
        final NicIPConfiguration nicIp = resource.getAssignedNetworkInterfaceIPConfiguration();
        final NetworkInterface nic = nicIp.parent();
        info.append("\n\t\tNetwork interface ID: ").append(nic.id())
            .append("\n\t\tIP config name: ").append(nicIp.name());
    } else {
        info.append("(None)");
    }

    System.out.println(info.toString());
}
 
Example #13
Source File: SubnetImpl.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
@Override
public Set<NicIPConfiguration> getNetworkInterfaceIPConfigurations() {
    return Collections.unmodifiableSet(new TreeSet<NicIPConfiguration>(listNetworkInterfaceIPConfigurations()));
}
 
Example #14
Source File: DockerUtils.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
/**
 * It creates a new Azure virtual machine and it instantiate a Java Docker client.
 * @param azure - instance of Azure
 * @param rgName - name of the Azure resource group to be used when creating a virtual machine
 * @param region - region to be used when creating a virtual machine
 * @param registryServerUrl - address of the private container registry
 * @param username - user name to connect with to the private container registry
 * @param password - password to connect with to the private container registry
 * @return an instance of DockerClient
 * @throws Exception exception thrown
 */
public static DockerClient fromNewDockerVM(Azure azure, String rgName, Region region,
                                           String registryServerUrl, String username, String password) throws Exception {
    final String dockerVMName = SdkContext.randomResourceName("dockervm", 15);
    final String publicIPDnsLabel = SdkContext.randomResourceName("pip", 10);
    final String vmUserName = "dockerUser";
    // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Serves as an example, not for deployment. Please change when using this in your code.")]
    final String vmPassword = "12NewPA!!w0rd!";

    // Could not find a Docker environment; presume that there is no local Docker engine running and
    //    attempt to configure a Docker engine running inside a new    Azure virtual machine
    System.out.println("Creating an Azure virtual machine running Docker");

    Date t1 = new Date();

    VirtualMachine dockerVM = azure.virtualMachines().define(dockerVMName)
            .withRegion(region)
            .withExistingResourceGroup(rgName)
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withNewPrimaryPublicIPAddress(publicIPDnsLabel)
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
            .withRootUsername(vmUserName)
            .withRootPassword(vmPassword)
            .withSize(VirtualMachineSizeTypes.STANDARD_D2_V2)
            .create();

    Date t2 = new Date();
    System.out.println("Created Azure Virtual Machine: (took " + ((t2.getTime() - t1.getTime()) / 1000) + " seconds) " + dockerVM.id());

    // Wait for a minute for PIP to be available
    SdkContext.sleep(60 * 1000);
    // Get the IP of the Docker host
    NicIPConfiguration nicIPConfiguration = dockerVM.getPrimaryNetworkInterface().primaryIPConfiguration();
    PublicIPAddress publicIp = nicIPConfiguration.getPublicIPAddress();
    String dockerHostIP = publicIp.ipAddress();

    DockerClient dockerClient = installDocker(dockerHostIP, vmUserName, vmPassword, registryServerUrl, username, password);
    System.out.println("List Docker host info");
    System.out.println("\tFound Docker version: " + dockerClient.versionCmd().exec().toString());
    System.out.println("\tFound Docker info: " + dockerClient.infoCmd().exec().toString());

    return dockerClient;
}
 
Example #15
Source File: TestNetworkInterface.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
public static void printNic(NetworkInterface resource) {
    StringBuilder info = new StringBuilder();
    info.append("NetworkInterface: ").append(resource.id())
            .append("Name: ").append(resource.name())
            .append("\n\tResource group: ").append(resource.resourceGroupName())
            .append("\n\tRegion: ").append(resource.region())
            .append("\n\tTags: ").append(resource.tags())
            .append("\n\tInternal DNS name label: ").append(resource.internalDnsNameLabel())
            .append("\n\tInternal FQDN: ").append(resource.internalFqdn())
            .append("\n\tInternal domain name suffix: ").append(resource.internalDomainNameSuffix())
            .append("\n\tVirtual machine ID: ").append(resource.virtualMachineId())
            .append("\n\tApplied DNS servers: ").append(resource.appliedDnsServers().toString())
            .append("\n\tDNS server IPs: ");

    // Output dns servers
    for (String dnsServerIp : resource.dnsServers()) {
        info.append("\n\t\t").append(dnsServerIp);
    }

    info.append("\n\tIP forwarding enabled? ").append(resource.isIPForwardingEnabled())
            .append("\n\tAccelerated networking enabled? ").append(resource.isAcceleratedNetworkingEnabled())
            .append("\n\tMAC Address:").append(resource.macAddress())
            .append("\n\tPrivate IP:").append(resource.primaryPrivateIP())
            .append("\n\tPrivate allocation method:").append(resource.primaryPrivateIPAllocationMethod())
            .append("\n\tPrimary virtual network ID: ").append(resource.primaryIPConfiguration().networkId())
            .append("\n\tPrimary subnet name: ").append(resource.primaryIPConfiguration().subnetName())
            .append("\n\tIP configurations: ");

    // Output IP configs
    for (NicIPConfiguration ipConfig : resource.ipConfigurations().values()) {
        info.append("\n\t\tName: ").append(ipConfig.name())
            .append("\n\t\tPrivate IP: ").append(ipConfig.privateIPAddress())
            .append("\n\t\tPrivate IP allocation method: ").append(ipConfig.privateIPAllocationMethod().toString())
            .append("\n\t\tPrivate IP version: ").append(ipConfig.privateIPAddressVersion().toString())
            .append("\n\t\tPIP id: ").append(ipConfig.publicIPAddressId())
            .append("\n\t\tAssociated network ID: ").append(ipConfig.networkId())
            .append("\n\t\tAssociated subnet name: ").append(ipConfig.subnetName());

        // Show associated load balancer backends
        final List<LoadBalancerBackend> backends = ipConfig.listAssociatedLoadBalancerBackends();
        info.append("\n\t\tAssociated load balancer backends: ").append(backends.size());
        for (LoadBalancerBackend backend : backends) {
            info.append("\n\t\t\tLoad balancer ID: ").append(backend.parent().id())
                .append("\n\t\t\t\tBackend name: ").append(backend.name());
        }

        // Show associated load balancer inbound NAT rules
        final List<LoadBalancerInboundNatRule> natRules = ipConfig.listAssociatedLoadBalancerInboundNatRules();
        info.append("\n\t\tAssociated load balancer inbound NAT rules: ").append(natRules.size());
        for (LoadBalancerInboundNatRule natRule : natRules) {
            info.append("\n\t\t\tLoad balancer ID: ").append(natRule.parent().id())
                .append("\n\t\t\tInbound NAT rule name: ").append(natRule.name());
        }
    }

    System.out.println(info.toString());
}
 
Example #16
Source File: TestNetworkInterface.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
@Override
public NetworkInterface createResource(NetworkInterfaces networkInterfaces) throws Exception {
    final String nicName = "nic" + this.testId;
    final String vnetName = "net" + this.testId;
    final String pipName = "pip" + this.testId;
    final Region region = Region.US_EAST;

    Network network = networkInterfaces.manager().networks().define(vnetName)
            .withRegion(region)
            .withNewResourceGroup()
            .withAddressSpace("10.0.0.0/28")
            .withSubnet("subnet1", "10.0.0.0/29")
            .withSubnet("subnet2", "10.0.0.8/29")
            .create();

    NetworkInterface nic = networkInterfaces.define(nicName)
            .withRegion(region)
            .withExistingResourceGroup(network.resourceGroupName())
            .withExistingPrimaryNetwork(network)
            .withSubnet("subnet1")
            .withPrimaryPrivateIPAddressDynamic()
            .withNewPrimaryPublicIPAddress(pipName)
            .withIPForwarding()
            .withAcceleratedNetworking()
            .create();

    // Verify NIC settings
    Assert.assertTrue(nic.isAcceleratedNetworkingEnabled());
    Assert.assertTrue(nic.isIPForwardingEnabled());

    // Verify IP configs
    NicIPConfiguration ipConfig = nic.primaryIPConfiguration();
    Assert.assertNotNull(ipConfig);
    network = ipConfig.getNetwork();
    Assert.assertNotNull(network);
    Subnet subnet = network.subnets().get(ipConfig.subnetName());
    Assert.assertNotNull(subnet);
    Assert.assertEquals(1, subnet.networkInterfaceIPConfigurationCount());
    Collection<NicIPConfiguration> ipConfigs = subnet.listNetworkInterfaceIPConfigurations();
    Assert.assertNotNull(ipConfigs);
    Assert.assertEquals(1, ipConfigs.size());
    NicIPConfiguration ipConfig2 = null;
    for (NicIPConfiguration i : ipConfigs) {
        if (i.name().equalsIgnoreCase(ipConfig.name())) {
            ipConfig2 = i;
            break;
        }
    }
    Assert.assertNotNull(ipConfig2);
    Assert.assertTrue(ipConfig.name().equalsIgnoreCase(ipConfig2.name()));

    return nic;
}
 
Example #17
Source File: NetworkInterfaceImpl.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
@Override
public Map<String, NicIPConfiguration> ipConfigurations() {
    return Collections.unmodifiableMap(this.nicIPConfigurations);
}
 
Example #18
Source File: VirtualMachineOperationsTests.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
@Test
public void canCreateVirtualMachineWithNetworking() throws Exception {
    NetworkSecurityGroup nsg = this.networkManager.networkSecurityGroups().define("nsg")
        .withRegion(REGION)
        .withNewResourceGroup(RG_NAME)
        .defineRule("rule1")
            .allowInbound()
            .fromAnyAddress()
            .fromPort(80)
            .toAnyAddress()
            .toPort(80)
            .withProtocol(SecurityRuleProtocol.TCP)
            .attach()
        .create();

    Creatable<Network> networkDefinition = this.networkManager.networks().define("network1")
        .withRegion(REGION)
        .withNewResourceGroup(RG_NAME)
        .withAddressSpace("10.0.0.0/28")
        .defineSubnet("subnet1")
            .withAddressPrefix("10.0.0.0/29")
            .withExistingNetworkSecurityGroup(nsg)
            .attach();

    // Create
    VirtualMachine vm = computeManager.virtualMachines()
        .define(VMNAME)
            .withRegion(REGION)
            .withNewResourceGroup(RG_NAME)
            .withNewPrimaryNetwork(networkDefinition)
            .withPrimaryPrivateIPAddressDynamic()
            .withoutPrimaryPublicIPAddress()
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
            .withRootUsername("Foo12")
            .withRootPassword("abc!@#F0orL")
        .create();

    NetworkInterface primaryNic = vm.getPrimaryNetworkInterface();
    Assert.assertNotNull(primaryNic);
    NicIPConfiguration primaryIpConfig = primaryNic.primaryIPConfiguration();
    Assert.assertNotNull(primaryIpConfig);

    // Fetch the NSG the way before v1.2
    Assert.assertNotNull(primaryIpConfig.networkId());
    Network network = primaryIpConfig.getNetwork();
    Assert.assertNotNull(primaryIpConfig.subnetName());
    Subnet subnet = network.subnets().get(primaryIpConfig.subnetName());
    Assert.assertNotNull(subnet);
    nsg = subnet.getNetworkSecurityGroup();
    Assert.assertNotNull(nsg);
    Assert.assertEquals("nsg", nsg.name());
    Assert.assertEquals(1, nsg.securityRules().size());

    // Fetch the NSG the v1.2 way
    nsg = primaryIpConfig.getNetworkSecurityGroup();
    Assert.assertEquals("nsg", nsg.name());
}
 
Example #19
Source File: VMInventoryCollector.java    From pacbot with Apache License 2.0 3 votes vote down vote up
private void setVnetInfo(VirtualMachine virtualMachine, VirtualMachineVH vmVH) {

		NicIPConfiguration ipConfiguration = virtualMachine.getPrimaryNetworkInterface().primaryIPConfiguration();

		vmVH.setVnet(ipConfiguration.networkId());
		vmVH.setVnetName(ipConfiguration.getNetwork().name());
		vmVH.setSubnet(ipConfiguration.subnetName());

	}