Search in sources :

Example 36 with Region

use of com.microsoft.azure.management.resources.fluentcore.arm.Region in project azure-sdk-for-java by Azure.

the class TestNSG method createResource.

@Override
public NetworkSecurityGroup createResource(NetworkSecurityGroups nsgs) throws Exception {
    final String newName = "nsg" + this.testId;
    final String resourceGroupName = "rg" + this.testId;
    final String nicName = "nic" + this.testId;
    final Region region = Region.US_WEST;
    final SettableFuture<NetworkSecurityGroup> nsgFuture = SettableFuture.create();
    // Create
    Observable<Indexable> resourceStream = nsgs.define(newName).withRegion(region).withNewResourceGroup(resourceGroupName).defineRule("rule1").allowOutbound().fromAnyAddress().fromPort(80).toAnyAddress().toPort(80).withProtocol(SecurityRuleProtocol.TCP).attach().defineRule("rule2").allowInbound().fromAnyAddress().fromAnyPort().toAnyAddress().toPortRange(22, 25).withAnyProtocol().withPriority(200).withDescription("foo!!").attach().createAsync();
    Utils.<NetworkSecurityGroup>rootResource(resourceStream).subscribe(new Subscriber<NetworkSecurityGroup>() {

        @Override
        public void onCompleted() {
            System.out.print("completed");
        }

        @Override
        public void onError(Throwable throwable) {
            nsgFuture.setException(throwable);
        }

        @Override
        public void onNext(NetworkSecurityGroup networkSecurityGroup) {
            nsgFuture.set(networkSecurityGroup);
        }
    });
    NetworkSecurityGroup nsg = nsgFuture.get();
    NetworkInterface nic = nsgs.manager().networkInterfaces().define(nicName).withRegion(region).withExistingResourceGroup(resourceGroupName).withNewPrimaryNetwork("10.0.0.0/28").withPrimaryPrivateIPAddressDynamic().withExistingNetworkSecurityGroup(nsg).create();
    nsg.refresh();
    // Verify
    Assert.assertTrue(nsg.region().equals(region));
    Assert.assertTrue(nsg.securityRules().size() == 2);
    // Confirm NIC association
    Assert.assertEquals(1, nsg.networkInterfaceIds().size());
    Assert.assertTrue(nsg.networkInterfaceIds().contains(nic.id()));
    return nsg;
}
Also used : NetworkSecurityGroup(com.microsoft.azure.management.network.NetworkSecurityGroup) Region(com.microsoft.azure.management.resources.fluentcore.arm.Region) NetworkInterface(com.microsoft.azure.management.network.NetworkInterface) Indexable(com.microsoft.azure.management.resources.fluentcore.model.Indexable)

Example 37 with Region

use of com.microsoft.azure.management.resources.fluentcore.arm.Region in project azure-sdk-for-java by Azure.

the class AzureTests method testApplicationGatewaysInParallel.

@Test
public void testApplicationGatewaysInParallel() throws Exception {
    String rgName = SdkContext.randomResourceName("rg", 13);
    Region region = Region.US_EAST;
    Creatable<ResourceGroup> resourceGroup = azure.resourceGroups().define(rgName).withRegion(region);
    List<Creatable<ApplicationGateway>> agCreatables = new ArrayList<>();
    agCreatables.add(azure.applicationGateways().define(SdkContext.randomResourceName("ag", 13)).withRegion(Region.US_EAST).withNewResourceGroup(resourceGroup).defineRequestRoutingRule("rule1").fromPrivateFrontend().fromFrontendHttpPort(80).toBackendHttpPort(8080).toBackendIPAddress("10.0.0.1").toBackendIPAddress("10.0.0.2").attach());
    agCreatables.add(azure.applicationGateways().define(SdkContext.randomResourceName("ag", 13)).withRegion(Region.US_EAST).withNewResourceGroup(resourceGroup).defineRequestRoutingRule("rule1").fromPrivateFrontend().fromFrontendHttpPort(80).toBackendHttpPort(8080).toBackendIPAddress("10.0.0.3").toBackendIPAddress("10.0.0.4").attach());
    CreatedResources<ApplicationGateway> created = azure.applicationGateways().create(agCreatables);
    List<ApplicationGateway> ags = new ArrayList<>();
    List<String> agIds = new ArrayList<>();
    for (Creatable<ApplicationGateway> creatable : agCreatables) {
        ApplicationGateway ag = created.get(creatable.key());
        Assert.assertNotNull(ag);
        ags.add(ag);
        agIds.add(ag.id());
    }
    azure.applicationGateways().stop(agIds);
    for (ApplicationGateway ag : ags) {
        Assert.assertEquals(ApplicationGatewayOperationalState.STOPPED, ag.refresh().operationalState());
    }
    azure.applicationGateways().start(agIds);
    for (ApplicationGateway ag : ags) {
        Assert.assertEquals(ApplicationGatewayOperationalState.RUNNING, ag.refresh().operationalState());
    }
    azure.applicationGateways().deleteByIds(agIds);
    for (String id : agIds) {
        Assert.assertNull(azure.applicationGateways().getById(id));
    }
    azure.resourceGroups().beginDeleteByName(rgName);
}
Also used : ApplicationGateway(com.microsoft.azure.management.network.ApplicationGateway) ArrayList(java.util.ArrayList) Region(com.microsoft.azure.management.resources.fluentcore.arm.Region) Creatable(com.microsoft.azure.management.resources.fluentcore.model.Creatable) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) Test(org.junit.Test)

Example 38 with Region

use of com.microsoft.azure.management.resources.fluentcore.arm.Region in project azure-sdk-for-java by Azure.

the class AzureTests method listLocations.

/**
     * Tests location listing.
     * @throws Exception
     */
@Test
public void listLocations() throws Exception {
    Subscription subscription = azure.getCurrentSubscription();
    Assert.assertNotNull(subscription);
    for (Location location : subscription.listLocations()) {
        Region region = Region.findByLabelOrName(location.name());
        Assert.assertNotNull(region);
        Assert.assertEquals(region, location.region());
        Assert.assertEquals(region.name().toLowerCase(), location.name().toLowerCase());
    }
    Location location = subscription.getLocationByRegion(Region.US_WEST);
    Assert.assertNotNull(location);
    Assert.assertTrue(Region.US_WEST.name().equalsIgnoreCase(location.name()));
}
Also used : Region(com.microsoft.azure.management.resources.fluentcore.arm.Region) Subscription(com.microsoft.azure.management.resources.Subscription) Location(com.microsoft.azure.management.resources.Location) Test(org.junit.Test)

Example 39 with Region

use of com.microsoft.azure.management.resources.fluentcore.arm.Region in project azure-sdk-for-java by Azure.

the class TestCdn method createResource.

@Override
public CdnProfile createResource(CdnProfiles profiles) throws Exception {
    final Region region = Region.US_EAST;
    final String groupName = "rg" + this.testId;
    final String cdnProfileName = "cdnProfile" + this.testId;
    final String cdnEndpointName = "cdnEndpoint" + this.testId;
    final String cdnOriginHostName = "mylinuxapp.azurewebsites.net";
    CdnProfile cdnProfile = profiles.define(cdnProfileName).withRegion(region).withNewResourceGroup(groupName).withStandardAkamaiSku().defineNewEndpoint(cdnEndpointName).withOrigin(cdnOriginHostName).withGeoFilter("/path/videos", GeoFilterActions.BLOCK, CountryIsoCode.ARGENTINA).withGeoFilter("/path/images", GeoFilterActions.BLOCK, CountryIsoCode.BELGIUM).withContentTypeToCompress("text/plain").withCompressionEnabled(true).withQueryStringCachingBehavior(QueryStringCachingBehavior.BYPASS_CACHING).withHttpsAllowed(true).withHttpsPort(444).withHttpAllowed(false).withHttpPort(85).attach().create();
    Assert.assertTrue(cdnProfile.sku().name().equals(SkuName.STANDARD_AKAMAI));
    Assert.assertNotNull(cdnProfile.endpoints());
    Assert.assertEquals(1, cdnProfile.endpoints().size());
    CdnEndpoint endpoint = cdnProfile.endpoints().get(cdnEndpointName);
    Assert.assertNotNull(endpoint);
    Assert.assertEquals(cdnOriginHostName, endpoint.originHostName());
    Assert.assertEquals(444, endpoint.httpsPort());
    Assert.assertEquals(85, endpoint.httpPort());
    Assert.assertFalse(endpoint.isHttpAllowed());
    Assert.assertTrue(endpoint.isHttpsAllowed());
    Assert.assertTrue(endpoint.isCompressionEnabled());
    Assert.assertEquals(QueryStringCachingBehavior.BYPASS_CACHING, endpoint.queryStringCachingBehavior());
    Assert.assertNotNull(endpoint.geoFilters());
    Assert.assertEquals(QueryStringCachingBehavior.BYPASS_CACHING, endpoint.queryStringCachingBehavior());
    for (ResourceUsage usage : profiles.listResourceUsage()) {
        Assert.assertNotNull(usage);
        Assert.assertEquals("profile", usage.resourceType());
    }
    for (EdgeNode node : profiles.listEdgeNodes()) {
        Assert.assertNotNull(node);
    }
    for (ResourceUsage usage : cdnProfile.listResourceUsage()) {
        Assert.assertNotNull(usage);
        Assert.assertEquals("endpoint", usage.resourceType());
    }
    for (CdnEndpoint ep : cdnProfile.endpoints().values()) {
        for (ResourceUsage usage : ep.listResourceUsage()) {
            Assert.assertNotNull(usage);
            Assert.assertTrue("customdomain".equals(usage.resourceType()) || "geofilter".equals(usage.resourceType()));
        }
    }
    return cdnProfile;
}
Also used : CdnProfile(com.microsoft.azure.management.cdn.CdnProfile) CdnEndpoint(com.microsoft.azure.management.cdn.CdnEndpoint) ResourceUsage(com.microsoft.azure.management.cdn.ResourceUsage) EdgeNode(com.microsoft.azure.management.cdn.EdgeNode) Region(com.microsoft.azure.management.resources.fluentcore.arm.Region)

Example 40 with Region

use of com.microsoft.azure.management.resources.fluentcore.arm.Region in project azure-tools-for-java by Microsoft.

the class AzureNewDockerConfigPage method updateDockerLocationGroup.

private void updateDockerLocationGroup(Composite mainContainer) {
    AzureDockerSubscription currentSubscription = getCurrentSubscription();
    dockerLocationComboBox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String region = dockerLocationComboBox.getText();
            if (!region.equals(SELECT_REGION)) {
                Region regionObj = Region.findByLabelOrName(region);
                String selectedRegion = regionObj != null ? regionObj.name() : region;
                if (preferredLocation == null && selectedRegion != null) {
                    // remove the SELECT_REGION entry (first entry in the
                    // list)
                    dockerLocationComboBox.remove(SELECT_REGION);
                }
                preferredLocation = selectedRegion;
                updateDockerSelectVnetComboBox(mainContainer, currentSubscription, selectedRegion);
                setPageComplete(doValidate());
            } else {
                updateDockerSelectVnetComboBox(mainContainer, currentSubscription, null);
                setPageComplete(false);
            }
            updateDockerHostVMSizeComboBox(mainContainer, dockerHostVMPreferredSizesCheckBox.getSelection());
        }
    });
    updateDockerLocationComboBox(mainContainer, currentSubscription);
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AzureDockerSubscription(com.microsoft.azure.docker.model.AzureDockerSubscription) Region(com.microsoft.azure.management.resources.fluentcore.arm.Region)

Aggregations

Region (com.microsoft.azure.management.resources.fluentcore.arm.Region)52 VirtualMachine (com.microsoft.azure.management.compute.VirtualMachine)20 ArrayList (java.util.ArrayList)19 Network (com.microsoft.azure.management.network.Network)16 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)14 Test (org.junit.Test)12 Disk (com.microsoft.azure.management.compute.Disk)8 PublicIPAddress (com.microsoft.azure.management.network.PublicIPAddress)8 Date (java.util.Date)8 Creatable (com.microsoft.azure.management.resources.fluentcore.model.Creatable)7 VirtualMachineDataDisk (com.microsoft.azure.management.compute.VirtualMachineDataDisk)6 NetworkInterface (com.microsoft.azure.management.network.NetworkInterface)6 StorageAccount (com.microsoft.azure.management.storage.StorageAccount)6 VirtualMachineScaleSet (com.microsoft.azure.management.compute.VirtualMachineScaleSet)4 LoadBalancer (com.microsoft.azure.management.network.LoadBalancer)4 Indexable (com.microsoft.azure.management.resources.fluentcore.model.Indexable)4 StopWatch (org.apache.commons.lang3.time.StopWatch)4 JSchException (com.jcraft.jsch.JSchException)3 VirtualMachineCustomImage (com.microsoft.azure.management.compute.VirtualMachineCustomImage)3 TrafficManagerProfile (com.microsoft.azure.management.trafficmanager.TrafficManagerProfile)3