当前位置: 首页>>代码示例>>Java>>正文


Java NetworkInterface.primaryIPConfiguration方法代码示例

本文整理汇总了Java中com.microsoft.azure.management.network.NetworkInterface.primaryIPConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkInterface.primaryIPConfiguration方法的具体用法?Java NetworkInterface.primaryIPConfiguration怎么用?Java NetworkInterface.primaryIPConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.microsoft.azure.management.network.NetworkInterface的用法示例。


在下文中一共展示了NetworkInterface.primaryIPConfiguration方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateResource

import com.microsoft.azure.management.network.NetworkInterface; //导入方法依赖的package包/类
@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());
    return resource;
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:28,代码来源:TestNetworkInterface.java

示例2: afterCreating

import com.microsoft.azure.management.network.NetworkInterface; //导入方法依赖的package包/类
@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();
    }
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:31,代码来源:LoadBalancerImpl.java

示例3: canCreateVirtualMachineWithNetworking

import com.microsoft.azure.management.network.NetworkInterface; //导入方法依赖的package包/类
@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("[email protected]#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());
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:58,代码来源:VirtualMachineOperationsTests.java

示例4: createResource

import com.microsoft.azure.management.network.NetworkInterface; //导入方法依赖的package包/类
@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;
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:54,代码来源:TestNetworkInterface.java

示例5: apply

import com.microsoft.azure.management.network.NetworkInterface; //导入方法依赖的package包/类
@Override
public Machine apply(VirtualMachine vm) {
    Builder builder = Machine.builder();

    builder.id(vm.id());
    builder.cloudProvider(CloudProviders.AZURE);
    builder.region(vm.regionName());
    builder.machineSize(vm.size().toString());

    NetworkInterface nic = vm.getPrimaryNetworkInterface();
    if (nic != null) {
        builder.privateIp(nic.primaryPrivateIP());
        NicIPConfiguration primaryIpConfig = nic.primaryIPConfiguration();
        if (primaryIpConfig.publicIPAddressId() != null) {
            String publicIp = primaryIpConfig.getPublicIPAddress().ipAddress();
            if (publicIp != null) {
                builder.publicIp(publicIp);
            }
        }
    }

    DateTime launchTime = extractProvisioningTime(vm);
    builder.launchTime(launchTime);
    if (launchTime == null) {
        LOG.warn("failed to determine provisioning time for VM {}", vm.id());
    }

    builder.machineState(new VmToMachineState().apply(vm));

    // extract membership status if tag has been set on server
    MembershipStatus membershipStatus = MembershipStatus.defaultStatus();
    if (vm.tags().containsKey(MEMBERSHIP_STATUS_TAG)) {
        membershipStatus = JsonUtils.toObject(JsonUtils.parseJsonString(vm.tags().get(MEMBERSHIP_STATUS_TAG)),
                MembershipStatus.class);
    }
    builder.membershipStatus(membershipStatus);

    // extract service state if tag has been set on server
    ServiceState serviceState = ServiceState.UNKNOWN;
    if (vm.tags().containsKey(SERVICE_STATE_TAG)) {
        serviceState = ServiceState.valueOf(vm.tags().get(SERVICE_STATE_TAG));
    }
    builder.serviceState(serviceState);

    return builder.build();
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:47,代码来源:VmToMachine.java


注:本文中的com.microsoft.azure.management.network.NetworkInterface.primaryIPConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。