public static boolean isDeletingDockerHostAllSafe(Azure azureClient, String resourceGroup, String vmName) { if (azureClient == null || resourceGroup == null || vmName == null ) { return false; } VirtualMachine vm = azureClient.virtualMachines().getByResourceGroup(resourceGroup, vmName); if (vm == null) { return false; } PublicIPAddress publicIp = vm.getPrimaryPublicIPAddress(); NicIPConfiguration nicIPConfiguration = publicIp.getAssignedNetworkInterfaceIPConfiguration(); Network vnet = nicIPConfiguration.getNetwork(); NetworkInterface nic = vm.getPrimaryNetworkInterface(); return nic.ipConfigurations().size() == 1 && vnet.subnets().size() == 1 && vnet.subnets().values().toArray(new Subnet[1])[0].inner().ipConfigurations().size() == 1; }
azureClient.virtualMachines().getByResourceGroup(template.getResourceGroupName(), vmname); final PublicIPAddress publicIP = vm.getPrimaryPublicIPAddress(); String privateIP = vm.getPrimaryNetworkInterface().primaryPrivateIP(); String fqdn = "";
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)); } }
final PublicIPAddress publicIP = vm.getPrimaryPublicIPAddress(); String publicIPStr = ""; String privateIP = vm.getPrimaryNetworkInterface().primaryPrivateIP();
if (vm != null) { if (vm.getPrimaryPublicIPAddress() == null) { try { vm.getPrimaryNetworkInterface()