@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(); } }
vm.getPrimaryNetworkInterface() .update() .withNewPrimaryPublicIPAddress( azureClient.publicIPAddresses() .define(azureAgent.getNodeName() + "IPName") .withExistingResourceGroup(template.getResourceGroupName()) .withLeafDomainLabel(azureAgent.getNodeName()) ).apply(); } catch (Exception e) { throw AzureCloudException.create(e);
@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(); } }
@Override public Completable deleteByResourceGroupAsync(String groupName, String name) { // Clear NIC references if any NetworkSecurityGroupImpl nsg = (NetworkSecurityGroupImpl) getByResourceGroup(groupName, name); if (nsg != null) { Set<String> nicIds = nsg.networkInterfaceIds(); if (nicIds != null) { for (String nicRef : nsg.networkInterfaceIds()) { NetworkInterface nic = this.manager().networkInterfaces().getById(nicRef); if (nic == null) { continue; } else if (!nsg.id().equalsIgnoreCase(nic.networkSecurityGroupId())) { continue; } else { nic.update().withoutNetworkSecurityGroup().apply(); } } } } return this.deleteInnerAsync(groupName, name); }
@Override public Completable deleteByResourceGroupAsync(String groupName, String name) { // Clear NIC references if any NetworkSecurityGroupImpl nsg = (NetworkSecurityGroupImpl) getByResourceGroup(groupName, name); if (nsg != null) { Set<String> nicIds = nsg.networkInterfaceIds(); if (nicIds != null) { for (String nicRef : nsg.networkInterfaceIds()) { NetworkInterface nic = this.manager().networkInterfaces().getById(nicRef); if (nic == null) { continue; } else if (!nsg.id().equalsIgnoreCase(nic.networkSecurityGroupId())) { continue; } else { nic.update().withoutNetworkSecurityGroup().apply(); } } } } return this.deleteInnerAsync(groupName, name); }