Search in sources :

Example 21 with PublicIPAddress

use of com.microsoft.azure.management.network.PublicIPAddress in project azure-sdk-for-java by Azure.

the class ManageDns method runSample.

/**
     * Main function which runs the actual sample.
     * @param azure instance of the azure client
     * @return true if sample runs successfully
     */
public static boolean runSample(Azure azure) {
    final String customDomainName = "THE CUSTOM DOMAIN THAT YOU OWN (e.g. contoso.com)";
    final String rgName = SdkContext.randomResourceName("rgNEMV_", 24);
    final String appServicePlanName = SdkContext.randomResourceName("jplan1_", 15);
    final String webAppName = SdkContext.randomResourceName("webapp1-", 20);
    try {
        ResourceGroup resourceGroup = azure.resourceGroups().define(rgName).withRegion(Region.US_EAST2).create();
        //============================================================
        // Creates root DNS Zone
        System.out.println("Creating root DNS zone " + customDomainName + "...");
        DnsZone rootDnsZone = azure.dnsZones().define(customDomainName).withExistingResourceGroup(resourceGroup).create();
        System.out.println("Created root DNS zone " + rootDnsZone.name());
        Utils.print(rootDnsZone);
        //============================================================
        // Sets NS records in the parent zone (hosting custom domain) to make Azure DNS the authoritative
        // source for name resolution for the zone
        System.out.println("Go to your registrar portal and configure your domain " + customDomainName + " with following name server addresses");
        for (String nameServer : rootDnsZone.nameServers()) {
            System.out.println(" " + nameServer);
        }
        System.out.println("Press a key after finishing above step");
        System.in.read();
        //============================================================
        // Creates a web App
        System.out.println("Creating Web App " + webAppName + "...");
        WebApp webApp = azure.webApps().define(webAppName).withRegion(Region.US_EAST2).withExistingResourceGroup(rgName).withNewWindowsPlan(PricingTier.BASIC_B1).defineSourceControl().withPublicGitRepository("https://github.com/jianghaolu/azure-site-test").withBranch("master").attach().create();
        System.out.println("Created web app " + webAppName);
        Utils.print(webApp);
        //============================================================
        // Creates a CName record and bind it with the web app
        // Step 1: Adds CName Dns record to root DNS zone that specify web app host domain as an
        // alias for www.[customDomainName]
        System.out.println("Updating DNS zone by adding a CName record...");
        rootDnsZone = rootDnsZone.update().withCNameRecordSet("www", webApp.defaultHostName()).apply();
        System.out.println("DNS zone updated");
        Utils.print(rootDnsZone);
        // Waiting for a minute for DNS CName entry to propagate
        System.out.println("Waiting a minute for CName record entry to propagate...");
        Thread.sleep(60 * 1000);
        // Step 2: Adds a web app host name binding for www.[customDomainName]
        //         This binding action will fail if the CName record propagation is not yet completed
        System.out.println("Updating Web app with host name binding...");
        webApp.update().defineHostnameBinding().withThirdPartyDomain(customDomainName).withSubDomain("www").withDnsRecordType(CustomHostNameDnsRecordType.CNAME).attach().apply();
        System.out.println("Web app updated");
        Utils.print(webApp);
        //============================================================
        // Creates a virtual machine with public IP
        System.out.println("Creating a virtual machine with public IP...");
        VirtualMachine virtualMachine1 = azure.virtualMachines().define(SdkContext.randomResourceName("employeesvm-", 20)).withRegion(Region.US_EAST).withExistingResourceGroup(resourceGroup).withNewPrimaryNetwork("10.0.0.0/28").withPrimaryPrivateIPAddressDynamic().withNewPrimaryPublicIPAddress(SdkContext.randomResourceName("empip-", 20)).withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_R2_DATACENTER).withAdminUsername("testuser").withAdminPassword("12NewPA$$w0rd!").withSize(VirtualMachineSizeTypes.STANDARD_D1_V2).create();
        System.out.println("Virtual machine created");
        //============================================================
        // Update DNS zone by adding a A record in root DNS zone pointing to virtual machine IPv4 address
        PublicIPAddress vm1PublicIPAddress = virtualMachine1.getPrimaryPublicIPAddress();
        System.out.println("Updating root DNS zone " + customDomainName + "...");
        rootDnsZone = rootDnsZone.update().defineARecordSet("employees").withIPv4Address(vm1PublicIPAddress.ipAddress()).attach().apply();
        System.out.println("Updated root DNS zone " + rootDnsZone.name());
        Utils.print(rootDnsZone);
        // Prints the CName and A Records in the root DNS zone
        //
        System.out.println("Getting CName record set in the root DNS zone " + customDomainName + "...");
        PagedList<CNameRecordSet> cnameRecordSets = rootDnsZone.cNameRecordSets().list();
        for (CNameRecordSet cnameRecordSet : cnameRecordSets) {
            System.out.println("Name: " + cnameRecordSet.name() + " Canonical Name: " + cnameRecordSet.canonicalName());
        }
        System.out.println("Getting ARecord record set in the root DNS zone " + customDomainName + "...");
        PagedList<ARecordSet> aRecordSets = rootDnsZone.aRecordSets().list();
        for (ARecordSet aRecordSet : aRecordSets) {
            System.out.println("Name: " + aRecordSet.name());
            for (String ipv4Address : aRecordSet.ipv4Addresses()) {
                System.out.println("  " + ipv4Address);
            }
        }
        //============================================================
        // Creates a child DNS zone
        String partnerSubDomainName = "partners." + customDomainName;
        System.out.println("Creating child DNS zone " + partnerSubDomainName + "...");
        DnsZone partnersDnsZone = azure.dnsZones().define(partnerSubDomainName).withExistingResourceGroup(resourceGroup).create();
        System.out.println("Created child DNS zone " + partnersDnsZone.name());
        Utils.print(partnersDnsZone);
        //============================================================
        // Adds NS records in the root dns zone to delegate partners.[customDomainName] to child dns zone
        System.out.println("Updating root DNS zone " + rootDnsZone + "...");
        DnsRecordSet.UpdateDefinitionStages.WithNSRecordNameServerOrAttachable<DnsZone.Update> nsRecordStage = rootDnsZone.update().defineNSRecordSet("partners").withNameServer(partnersDnsZone.nameServers().get(0));
        for (int i = 1; i < partnersDnsZone.nameServers().size(); i++) {
            nsRecordStage = nsRecordStage.withNameServer(partnersDnsZone.nameServers().get(i));
        }
        nsRecordStage.attach().apply();
        System.out.println("Root DNS zone updated");
        Utils.print(rootDnsZone);
        //============================================================
        // Creates a virtual machine with public IP
        System.out.println("Creating a virtual machine with public IP...");
        VirtualMachine virtualMachine2 = azure.virtualMachines().define(SdkContext.randomResourceName("partnersvm-", 20)).withRegion(Region.US_EAST).withExistingResourceGroup(resourceGroup).withNewPrimaryNetwork("10.0.0.0/28").withPrimaryPrivateIPAddressDynamic().withNewPrimaryPublicIPAddress(SdkContext.randomResourceName("ptnerpip-", 20)).withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_R2_DATACENTER).withAdminUsername("testuser").withAdminPassword("12NewPA$$w0rd!").withSize(VirtualMachineSizeTypes.STANDARD_D1_V2).create();
        System.out.println("Virtual machine created");
        //============================================================
        // Update child DNS zone by adding a A record pointing to virtual machine IPv4 address
        PublicIPAddress vm2PublicIPAddress = virtualMachine2.getPrimaryPublicIPAddress();
        System.out.println("Updating child DNS zone " + partnerSubDomainName + "...");
        partnersDnsZone = partnersDnsZone.update().defineARecordSet("@").withIPv4Address(vm2PublicIPAddress.ipAddress()).attach().apply();
        System.out.println("Updated child DNS zone " + partnersDnsZone.name());
        Utils.print(partnersDnsZone);
        //============================================================
        // Removes A record entry from the root DNS zone
        System.out.println("Removing A Record from root DNS zone " + rootDnsZone.name() + "...");
        rootDnsZone = rootDnsZone.update().withoutARecordSet("employees").apply();
        System.out.println("Removed A Record from root DNS zone");
        Utils.print(rootDnsZone);
        //============================================================
        // Deletes the DNS zone
        System.out.println("Deleting child DNS zone " + partnersDnsZone.name() + "...");
        azure.dnsZones().deleteById(partnersDnsZone.id());
        System.out.println("Deleted child DNS zone " + partnersDnsZone.name());
        return true;
    } catch (Exception e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
    } finally {
        try {
            System.out.println("Deleting Resource Group: " + rgName);
            azure.resourceGroups().beginDeleteByName(rgName);
            System.out.println("Deleted Resource Group: " + rgName);
        } catch (NullPointerException npe) {
            System.out.println("Did not create any resources in Azure. No clean up is necessary");
        } catch (Exception g) {
            g.printStackTrace();
        }
    }
    return false;
}
Also used : ARecordSet(com.microsoft.azure.management.dns.ARecordSet) CNameRecordSet(com.microsoft.azure.management.dns.CNameRecordSet) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress) DnsZone(com.microsoft.azure.management.dns.DnsZone) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) WebApp(com.microsoft.azure.management.appservice.WebApp) VirtualMachine(com.microsoft.azure.management.compute.VirtualMachine)

Example 22 with PublicIPAddress

use of com.microsoft.azure.management.network.PublicIPAddress in project photon-model by vmware.

the class AzureComputeEnumerationAdapterService method processCreateUpdateNicRequest.

/**
 * Processes request for creating and updating Network interface resources.
 */
private void processCreateUpdateNicRequest(NetworkInterfaceState nic, NetworkInterfaceInner remoteNic, EnumerationContext ctx, List<DeferredResult<NetworkInterfaceState>> ops, Map<String, String> subnetPerNicId, boolean isCreate) {
    nic.name = remoteNic.name();
    nic.subnetLink = subnetPerNicId.get(remoteNic.id());
    NicMetadata nicMeta = new NicMetadata();
    nicMeta.state = nic;
    nicMeta.macAddress = remoteNic.macAddress();
    // else will default to original ID for PATCH requests
    if (isCreate) {
        nic.id = remoteNic.id();
        nic.endpointLink = ctx.request.endpointLink;
        AdapterUtils.addToEndpointLinks(nic, ctx.request.endpointLink);
        nic.tenantLinks = ctx.parentCompute.tenantLinks;
        nic.regionId = remoteNic.location();
        nic.computeHostLink = ctx.parentCompute.documentSelfLink;
    } else {
        if (StringUtils.isEmpty(nic.endpointLink)) {
            nic.endpointLink = ctx.request.endpointLink;
        }
        nic.endpointLinks.add(ctx.request.endpointLink);
    }
    List<NetworkInterfaceIPConfigurationInner> ipConfigurations = remoteNic.ipConfigurations();
    if (ipConfigurations == null || ipConfigurations.isEmpty()) {
        executeNicCreateUpdateRequest(nic, remoteNic, ctx, ops, nicMeta, isCreate);
        return;
    }
    NetworkInterfaceIPConfigurationInner nicIPConf = ipConfigurations.get(0);
    nic.address = nicIPConf.privateIPAddress();
    if (nicIPConf.publicIPAddress() == null) {
        executeNicCreateUpdateRequest(nic, remoteNic, ctx, ops, nicMeta, isCreate);
        return;
    }
    // IP address is not directly available in NetworkInterfaceIPConfigurationInner.
    // It is available as a SubResource, We use the SubResource ID of IP address from
    // NetworkInterfaceIPConfigurationInner to obtain the IP address.
    Consumer<Throwable> failure = e -> {
        logWarning("Error getting public IP address from Azure [endpointLink:%s], [Exception:%s]", ctx.request.endpointLink, e.getMessage());
        handleError(ctx, e);
    };
    PhotonModelUtils.runInExecutor(this.executorService, () -> {
        Azure azure = ctx.azureSdkClients.getAzureClient();
        azure.publicIPAddresses().getByIdAsync(nicIPConf.publicIPAddress().id()).subscribe(injectOperationContext(new Action1<PublicIPAddress>() {

            @Override
            public void call(PublicIPAddress publicIPAddress) {
                nicMeta.publicIp = publicIPAddress.ipAddress();
                if (publicIPAddress.inner().dnsSettings() != null) {
                    nicMeta.publicDnsName = publicIPAddress.inner().dnsSettings().fqdn();
                }
                executeNicCreateUpdateRequest(nic, remoteNic, ctx, ops, nicMeta, isCreate);
            }
        }));
    }, failure);
}
Also used : PowerState(com.vmware.photon.controller.model.resources.ComputeService.PowerState) Arrays(java.util.Arrays) ComputeEnumerateResourceRequest(com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) LifecycleState(com.vmware.photon.controller.model.resources.ComputeService.LifecycleState) DISK_CONTROLLER_NUMBER(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.DISK_CONTROLLER_NUMBER) Action1(rx.functions.Action1) StringUtils(org.apache.commons.lang3.StringUtils) Azure(com.microsoft.azure.management.Azure) Utils(com.vmware.xenon.common.Utils) Pair(org.apache.commons.lang3.tuple.Pair) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) Map(java.util.Map) StorageDescription(com.vmware.photon.controller.model.resources.StorageDescriptionService.StorageDescription) OSDisk(com.microsoft.azure.management.compute.OSDisk) ResourceEnumerationTaskService(com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService) NetworkInterfaceState(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState) StatelessService(com.vmware.xenon.common.StatelessService) Set(java.util.Set) NetworkInterfaceService(com.vmware.photon.controller.model.resources.NetworkInterfaceService) StorageAccountTypes(com.microsoft.azure.management.compute.StorageAccountTypes) TagService(com.vmware.photon.controller.model.resources.TagService) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) SOURCE_TASK_LINK(com.vmware.photon.controller.model.constants.PhotonModelConstants.SOURCE_TASK_LINK) InstanceViewStatus(com.microsoft.azure.management.compute.InstanceViewStatus) DeferredResult(com.vmware.xenon.common.DeferredResult) UriUtils(com.vmware.xenon.common.UriUtils) ComputeService(com.vmware.photon.controller.model.resources.ComputeService) NumericRange(com.vmware.xenon.services.common.QueryTask.NumericRange) AZURE_DATA_DISK_CACHING(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_DATA_DISK_CACHING) ImageReferenceInner(com.microsoft.azure.management.compute.implementation.ImageReferenceInner) VirtualMachinesInner(com.microsoft.azure.management.compute.implementation.VirtualMachinesInner) ComputeDescriptionService(com.vmware.photon.controller.model.resources.ComputeDescriptionService) PhotonModelUtils(com.vmware.photon.controller.model.resources.util.PhotonModelUtils) RegionInfo(com.vmware.photon.controller.model.adapterapi.RegionEnumerationResponse.RegionInfo) TagsUtil(com.vmware.photon.controller.model.adapters.util.TagsUtil) ArrayList(java.util.ArrayList) TagState(com.vmware.photon.controller.model.resources.TagService.TagState) ServiceStateCollectionUpdateRequest(com.vmware.xenon.common.ServiceStateCollectionUpdateRequest) Query(com.vmware.xenon.services.common.QueryTask.Query) EnumerationStages(com.vmware.photon.controller.model.adapters.util.enums.EnumerationStages) OperatingSystemTypes(com.microsoft.azure.management.compute.OperatingSystemTypes) BiConsumer(java.util.function.BiConsumer) AZURE_DIAGNOSTIC_STORAGE_ACCOUNT_LINK(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_DIAGNOSTIC_STORAGE_ACCOUNT_LINK) AZURE_STORAGE_ACCOUNT_URI(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_STORAGE_ACCOUNT_URI) VirtualMachineInner(com.microsoft.azure.management.compute.implementation.VirtualMachineInner) AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) DataDisk(com.microsoft.azure.management.compute.DataDisk) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) ENVIRONMENT_NAME_AZURE(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ENVIRONMENT_NAME_AZURE) QueryTop(com.vmware.photon.controller.model.query.QueryUtils.QueryTop) CUSTOM_OS_TYPE(com.vmware.photon.controller.model.ComputeProperties.CUSTOM_OS_TYPE) ComputeStateWithDescription(com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription) PhotonModelConstants(com.vmware.photon.controller.model.constants.PhotonModelConstants) ComputeEnumerateAdapterRequest(com.vmware.photon.controller.model.adapters.util.ComputeEnumerateAdapterRequest) RegionEnumerationResponse(com.vmware.photon.controller.model.adapterapi.RegionEnumerationResponse) QuerySpecification(com.vmware.xenon.services.common.QueryTask.QuerySpecification) PhotonModelUriUtils.createInventoryUri(com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) QueryTask(com.vmware.xenon.services.common.QueryTask) AZURE_RESOURCE_GROUP_NAME(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_RESOURCE_GROUP_NAME) OSType(com.vmware.photon.controller.model.ComputeProperties.OSType) AzureUriPaths(com.vmware.photon.controller.model.adapters.azure.AzureUriPaths) AZURE_MANAGED_DISK_TYPE(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_MANAGED_DISK_TYPE) ComputeType(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ComputeType) AzureSdkClients(com.vmware.photon.controller.model.adapters.azure.utils.AzureSdkClients) AzureUtils.injectOperationContext(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils.injectOperationContext) CUSTOM_PROP_ENDPOINT_LINK(com.vmware.photon.controller.model.constants.PhotonModelConstants.CUSTOM_PROP_ENDPOINT_LINK) URI(java.net.URI) TagsUtil.newTagState(com.vmware.photon.controller.model.adapters.util.TagsUtil.newTagState) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) AzureConstants(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants) AzureConstants.getQueryResultLimit(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.getQueryResultLimit) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) Occurance(com.vmware.xenon.services.common.QueryTask.Query.Occurance) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) List(java.util.List) AzureUtils(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils) AzureUtils.getResourceGroupName(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils.getResourceGroupName) TAG_KEY_TYPE(com.vmware.photon.controller.model.constants.PhotonModelConstants.TAG_KEY_TYPE) Entry(java.util.Map.Entry) NetworkInterfacesInner(com.microsoft.azure.management.network.implementation.NetworkInterfacesInner) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) InstanceViewTypes(com.microsoft.azure.management.compute.InstanceViewTypes) TagsUtil.setTagLinksToResourceState(com.vmware.photon.controller.model.adapters.util.TagsUtil.setTagLinksToResourceState) Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder) DiskService(com.vmware.photon.controller.model.resources.DiskService) AzureUtils.isDiskManaged(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils.isDiskManaged) Default(com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback.Default) QueryByPages(com.vmware.photon.controller.model.query.QueryUtils.QueryByPages) AZURE_OSDISK_CACHING(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_OSDISK_CACHING) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress) HashMap(java.util.HashMap) HashSet(java.util.HashSet) AuthCredentialsService(com.vmware.xenon.services.common.AuthCredentialsService) TagsUtil.updateLocalTagStates(com.vmware.photon.controller.model.adapters.util.TagsUtil.updateLocalTagStates) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) EnumerationAction(com.vmware.photon.controller.model.adapterapi.EnumerationAction) AzureResourceType(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AzureResourceType) ExecutorService(java.util.concurrent.ExecutorService) Iterator(java.util.Iterator) NetworkInterfaceIPConfigurationInner(com.microsoft.azure.management.network.implementation.NetworkInterfaceIPConfigurationInner) Operation(com.vmware.xenon.common.Operation) Page(com.microsoft.azure.Page) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) NetworkInterfaceReferenceInner(com.microsoft.azure.management.compute.implementation.NetworkInterfaceReferenceInner) AzureDeferredResultServiceCallback(com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback) NetworkInterfaceInner(com.microsoft.azure.management.network.implementation.NetworkInterfaceInner) Collections(java.util.Collections) OperationJoin(com.vmware.xenon.common.OperationJoin) RESOURCE_GROUP_NAME(com.vmware.photon.controller.model.ComputeProperties.RESOURCE_GROUP_NAME) Azure(com.microsoft.azure.management.Azure) NetworkInterfaceIPConfigurationInner(com.microsoft.azure.management.network.implementation.NetworkInterfaceIPConfigurationInner) Action1(rx.functions.Action1) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress)

Example 23 with PublicIPAddress

use of com.microsoft.azure.management.network.PublicIPAddress in project azure-tools-for-java by Microsoft.

the class SettingsStep method retrievePublicIpAddresses.

private void retrievePublicIpAddresses() {
    AzureTaskManager.getInstance().runInBackground("Loading public ip addresses...", new Runnable() {

        @Override
        public void run() {
            if (publicIpAddresses == null) {
                publicIpAddresses = wizard.getAzure().publicIPAddresses().list();
            }
            DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

                @Override
                public void run() {
                    pipCombo.removeAll();
                    pipCombo.add(NONE);
                    pipCombo.add(CREATE_NEW);
                    for (PublicIPAddress pip : filterPip()) {
                        pipCombo.add(pip.name());
                        pipCombo.setData(pip.name(), pip);
                    }
                    pipCombo.select(0);
                }
            });
        }
    });
    pipCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (NONE.equals(pipCombo.getText())) {
                wizard.setPublicIpAddress(null);
                wizard.setWithNewPip(false);
            } else if (CREATE_NEW.equals(pipCombo.getText())) {
                wizard.setWithNewPip(true);
                wizard.setPublicIpAddress(null);
            // showNewPipForm();
            } else if (pipCombo.getData(pipCombo.getText()) instanceof PublicIPAddress) {
                wizard.setPublicIpAddress((PublicIPAddress) pipCombo.getData(pipCombo.getText()));
                wizard.setWithNewPip(false);
            }
        }
    });
    if (publicIpAddresses == null) {
        DefaultLoader.getIdeHelper().invokeAndWait(new Runnable() {

            @Override
            public void run() {
                pipCombo.setItems(new String[] { NONE, CREATE_NEW, LOADING });
                pipCombo.select(0);
                wizard.setPublicIpAddress(null);
                wizard.setWithNewPip(false);
            }
        });
    }
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress)

Example 24 with PublicIPAddress

use of com.microsoft.azure.management.network.PublicIPAddress in project cloudbreak by hortonworks.

the class AzureClient method getLoadBalancerIps.

public List<String> getLoadBalancerIps(String name, String loadBalancerName) {
    List<String> ipList = new ArrayList<>();
    List<String> publicIpAddressIds = getLoadBalancer(name, loadBalancerName).publicIPAddressIds();
    for (String publicIpAddressId : publicIpAddressIds) {
        PublicIPAddress publicIpAddress = getPublicIpAddressById(publicIpAddressId);
        ipList.add(publicIpAddress.ipAddress());
    }
    return ipList;
}
Also used : ArrayList(java.util.ArrayList) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress)

Aggregations

PublicIPAddress (com.microsoft.azure.management.network.PublicIPAddress)24 VirtualMachine (com.microsoft.azure.management.compute.VirtualMachine)10 Network (com.microsoft.azure.management.network.Network)10 ArrayList (java.util.ArrayList)10 LoadBalancer (com.microsoft.azure.management.network.LoadBalancer)7 Region (com.microsoft.azure.management.resources.fluentcore.arm.Region)7 Creatable (com.microsoft.azure.management.resources.fluentcore.model.Creatable)6 LoadBalancerInboundNatRule (com.microsoft.azure.management.network.LoadBalancerInboundNatRule)5 NetworkInterface (com.microsoft.azure.management.network.NetworkInterface)4 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)4 Date (java.util.Date)4 VirtualMachineScaleSet (com.microsoft.azure.management.compute.VirtualMachineScaleSet)3 VirtualMachineScaleSetVM (com.microsoft.azure.management.compute.VirtualMachineScaleSetVM)3 VirtualMachineScaleSetNetworkInterface (com.microsoft.azure.management.network.VirtualMachineScaleSetNetworkInterface)3 VirtualMachineScaleSetNicIPConfiguration (com.microsoft.azure.management.network.VirtualMachineScaleSetNicIPConfiguration)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 JSch (com.jcraft.jsch.JSch)2 Session (com.jcraft.jsch.Session)2 HashSet (java.util.HashSet)2