@BeforeClass @Override public void setup() { super.setup(); subscriptionid = getSubscriptionId(); createTestResourceGroup(); virtualNetworkName = String.format("vn-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); // Subnets belong to a virtual network so that needs to be created first assertNotNull(createDefaultVirtualNetwork(resourceGroupName, virtualNetworkName, "10.2.0.0/16", LOCATION)); //Subnet needs to be up & running before NIC can be created String subnetName = String.format("s-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); Subnet subnet = createDefaultSubnet(resourceGroupName, subnetName, virtualNetworkName, "10.2.0.0/23"); assertNotNull(subnet); assertNotNull(subnet.id()); subnetId = subnet.id(); NetworkInterfaceCard nic = createNetworkInterfaceCard(resourceGroupName, "jc-nic-" + RAND, LOCATION, "ipConfig-" + RAND); assertNotNull(nic); nicName = nic.name(); vmName = String.format("%3.24s", System.getProperty("user.name") + RAND + this.getClass().getSimpleName()).toLowerCase().substring(0, 15); }
@Test(dependsOnMethods = "createNetworkInterfaceCard") public void getNetworkInterfaceCard() { NetworkInterfaceCard nic = api().get(nicName); assertEquals(nic.name(), nicName); assertEquals(nic.location(), LOCATION); assertTrue(nic.properties().ipConfigurations().size() > 0); assertEquals(nic.properties().ipConfigurations().get(0).name(), "myipconfig"); assertEquals(nic.properties().ipConfigurations().get(0).properties().privateIPAllocationMethod(), "Dynamic"); assertEquals(nic.properties().ipConfigurations().get(0).properties().subnet().id(), subnetId); }
public void getNetworkInterfaceCard() throws InterruptedException { server.enqueue(jsonResponse("/getnetworkinterfacecard.json")); final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourcegroup); NetworkInterfaceCard nic = nicApi.get(nicName); String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkInterfaces/%s?%s", subscriptionid, resourcegroup, nicName, apiVersion); assertSent(server, "GET", path); assertNotNull(nic); assertEquals(nic.name(), nicName); assertTrue(nic.properties().primary()); assertEquals(nic.properties().ipConfigurations().get(0).name(), "myip1"); assertTrue(nic.properties().ipConfigurations().get(0).properties().primary()); assertEquals(nic.tags().get("mycustomtag"), "foobar"); }
api().createOrUpdate(captureVmName, LOCATION, getProperties(nic.name(), blob), Collections.<String, String> emptyMap(), null); waitUntilReady(captureVmName);
@Test public void createNetworkInterfaceCard() { //Create properties object final NetworkInterfaceCardProperties networkInterfaceCardProperties = NetworkInterfaceCardProperties.builder() .ipConfigurations(Arrays.asList(IpConfiguration.builder().name("myipconfig") .properties(IpConfigurationProperties.builder().privateIPAllocationMethod("Dynamic").primary (TRUE) .subnet(IdReference.create(subnetId)).build() ).build() )).build(); final Map<String, String> tags = ImmutableMap.of("jclouds", "livetest"); NetworkInterfaceCard nic = api().createOrUpdate(nicName, LOCATION, networkInterfaceCardProperties, tags); assertEquals(nic.name(), nicName); assertEquals(nic.location(), LOCATION); assertTrue(nic.properties().ipConfigurations().size() > 0); assertEquals(nic.properties().ipConfigurations().get(0).name(), "myipconfig"); assertEquals(nic.properties().ipConfigurations().get(0).properties().privateIPAllocationMethod(), "Dynamic"); assertTrue(nic.properties().ipConfigurations().get(0).properties().primary()); assertEquals(nic.properties().ipConfigurations().get(0).properties().subnet().id(), subnetId); assertEquals(nic.tags().get("jclouds"), "livetest"); }