/** * Remove the IP name. * * @param resourceGroupName * @param vmName * @throws AzureCloudException */ public void removeIPName(String resourceGroupName, String vmName) throws AzureCloudException { final String nic = vmName + "NIC"; try { LOGGER.log(Level.INFO, "Remove NIC {0}", nic); azureClient.networkInterfaces().deleteByResourceGroup(resourceGroupName, nic); } catch (Exception e) { LOGGER.log(Level.WARNING, "AzureVMManagementServiceDelegate: removeIPName: while deleting NIC", e); } final String ip = vmName + "IPName"; try { LOGGER.log(Level.INFO, "Remove IP {0}", ip); azureClient.publicIPAddresses().deleteByResourceGroup(resourceGroupName, ip); } catch (Exception e) { LOGGER.log(Level.WARNING, "AzureVMManagementServiceDelegate: removeIPName: while deleting IPName", e); } }
@Override public PublicIPAddress getPublicIPAddress() { String id = publicIPAddressId(); if (id == null) { return null; } return this.networkManager.publicIPAddresses().getById(id); }
private Creatable<PublicIPAddress> ensureDefaultPipDefinition() { if (this.creatablePip == null) { final String pipName = SdkContext.randomResourceName("pip", 9); this.creatablePip = this.manager().publicIPAddresses().define(pipName) .withRegion(this.regionName()) .withExistingResourceGroup(this.resourceGroupName()); } return this.creatablePip; }
public static void deleteDockerHostAll(Azure azureClient, String resourceGroup, String vmName) { if (azureClient == null || resourceGroup == null || vmName == null ) { throw new AzureDockerException("Unexpected param values; Azure instance, resource group and VM name cannot be null"); } VirtualMachine vm = azureClient.virtualMachines().getByResourceGroup(resourceGroup, vmName); if (vm == null) { throw new AzureDockerException(String.format("Unexpected error retrieving VM %s from Azure", vmName)); } try { PublicIPAddress publicIp = vm.getPrimaryPublicIPAddress(); NicIPConfiguration nicIPConfiguration = publicIp.getAssignedNetworkInterfaceIPConfiguration(); Network vnet = nicIPConfiguration.getNetwork(); NetworkInterface nic = vm.getPrimaryNetworkInterface(); azureClient.virtualMachines().deleteById(vm.id()); azureClient.networkInterfaces().deleteById(nic.id()); azureClient.publicIPAddresses().deleteById(publicIp.id()); azureClient.networks().deleteById(vnet.id()); } catch (Exception e) { throw new AzureDockerException(String.format("Unexpected error while deleting VM %s and its associated resources", vmName)); } }
@Override public VirtualNetworkGatewayImpl withNewPublicIPAddress() { final String pipName = SdkContext.randomResourceName("pip", 9); this.creatablePip = this.manager().publicIPAddresses().define(pipName) .withRegion(this.regionName()) .withExistingResourceGroup(this.resourceGroupName()); return this; }
private Creatable<PublicIPAddress> ensureDefaultPipDefinition() { if (this.creatablePip == null) { final String pipName = SdkContext.randomResourceName("pip", 9); this.creatablePip = this.manager().publicIPAddresses().define(pipName) .withRegion(this.regionName()) .withExistingResourceGroup(this.resourceGroupName()); } return this.creatablePip; }
@Override public PublicIPAddress getPublicIPAddress() { String id = publicIPAddressId(); if (id == null) { return null; } return this.networkManager.publicIPAddresses().getById(id); }
@Override public VirtualNetworkGatewayImpl withNewPublicIPAddress() { final String pipName = SdkContext.randomResourceName("pip", 9); this.creatablePip = this.manager().publicIPAddresses().define(pipName) .withRegion(this.regionName()) .withExistingResourceGroup(this.resourceGroupName()); return this; }
@Override public PublicIPAddress getPublicIPAddress() { final String pipId = this.publicIPAddressId(); if (pipId == null) { return null; } else { return this.parent().manager().publicIPAddresses().getById(pipId); } }
private Creatable<PublicIPAddress> ensureDefaultPipDefinition() { if (this.creatablePip == null) { final String pipName = SdkContext.randomResourceName("pip", 9); this.creatablePip = this.manager().publicIPAddresses().define(pipName) .withRegion(this.regionName()) .withExistingResourceGroup(this.resourceGroupName()); } return this.creatablePip; }
@Override public PublicIPAddress getPublicIPAddress() { final String pipId = this.publicIPAddressId(); if (pipId == null) { return null; } else { return this.parent().manager().publicIPAddresses().getById(pipId); } } }
private Creatable<PublicIPAddress> ensureDefaultPipDefinition() { if (this.creatablePip == null) { final String pipName = SdkContext.randomResourceName("pip", 9); this.creatablePip = this.manager().publicIPAddresses().define(pipName) .withRegion(this.regionName()) .withExistingResourceGroup(this.resourceGroupName()); } return this.creatablePip; }
@Override public PublicIPAddress getPublicIPAddress() { final String pipId = this.publicIPAddressId(); return (pipId != null) ? this.parent().manager().publicIPAddresses().getById(pipId) : null; }
LoadBalancerImpl withNewPublicIPAddress(String dnsLeafLabel, String frontendName) { PublicIPAddress.DefinitionStages.WithGroup precreatablePIP = manager().publicIPAddresses().define(dnsLeafLabel) .withRegion(this.regionName()); Creatable<PublicIPAddress> creatablePip; if (super.creatableGroup == null) { creatablePip = precreatablePIP.withExistingResourceGroup(this.resourceGroupName()).withLeafDomainLabel(dnsLeafLabel); } else { creatablePip = precreatablePIP.withNewResourceGroup(super.creatableGroup).withLeafDomainLabel(dnsLeafLabel); } return withNewPublicIPAddress(creatablePip, frontendName); }
@Override public PublicIPAddress getPublicIPAddress() { final String pipId = this.publicIPAddressId(); if (pipId == null) { return null; } else { return this.parent().manager().publicIPAddresses().getById(pipId); } }
LoadBalancerImpl withNewPublicIPAddress(String dnsLeafLabel, String frontendName) { PublicIPAddress.DefinitionStages.WithGroup precreatablePIP = manager().publicIPAddresses().define(dnsLeafLabel) .withRegion(this.regionName()); Creatable<PublicIPAddress> creatablePip; if (super.creatableGroup == null) { creatablePip = precreatablePIP.withExistingResourceGroup(this.resourceGroupName()).withLeafDomainLabel(dnsLeafLabel); } else { creatablePip = precreatablePIP.withNewResourceGroup(super.creatableGroup).withLeafDomainLabel(dnsLeafLabel); } return withNewPublicIPAddress(creatablePip, frontendName); }
@Override public PublicIPAddress getPublicIPAddress() { final String pipId = this.publicIPAddressId(); if (pipId == null) { return null; } else { return this.parent().manager().publicIPAddresses().getById(pipId); } }
private Creatable<PublicIPAddress> prepareCreatablePublicIP(String name, String leafDnsLabel) { PublicIPAddress.DefinitionStages.WithGroup definitionWithGroup = this.networkManager.publicIPAddresses() .define(name) .withRegion(this.parent().regionName()); PublicIPAddress.DefinitionStages.WithCreate definitionAfterGroup; if (this.parent().newGroup() != null) { definitionAfterGroup = definitionWithGroup.withNewResourceGroup(this.parent().newGroup()); } else { definitionAfterGroup = definitionWithGroup.withExistingResourceGroup(this.parent().resourceGroupName()); } return definitionAfterGroup.withLeafDomainLabel(leafDnsLabel); }
@Override public PublicIPAddress getPublicIPAddress() { final String pipId = this.publicIPAddressId(); return (pipId != null) ? this.parent().manager().publicIPAddresses().getById(pipId) : null; }
private Creatable<PublicIPAddress> prepareCreatablePublicIP(String name, String leafDnsLabel) { PublicIPAddress.DefinitionStages.WithGroup definitionWithGroup = this.networkManager.publicIPAddresses() .define(name) .withRegion(this.parent().regionName()); PublicIPAddress.DefinitionStages.WithCreate definitionAfterGroup; if (this.parent().newGroup() != null) { definitionAfterGroup = definitionWithGroup.withNewResourceGroup(this.parent().newGroup()); } else { definitionAfterGroup = definitionWithGroup.withExistingResourceGroup(this.parent().resourceGroupName()); } return definitionAfterGroup.withLeafDomainLabel(leafDnsLabel); }