PR Fixes
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/c9542dc0 Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/c9542dc0 Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/c9542dc0 Branch: refs/heads/resource-group-location Commit: c9542dc03d3df396d28225bdec14dd06d561a0e7 Parents: e678546 Author: Ignasi Barrera <n...@apache.org> Authored: Mon Oct 17 12:01:09 2016 +0200 Committer: Ignasi Barrera <n...@apache.org> Committed: Mon Oct 17 12:01:09 2016 +0200 ---------------------------------------------------------------------- .../arm/compute/AzureComputeServiceAdapter.java | 211 +++++++++---------- .../compute/AzureComputeServiceLiveTest.java | 23 +- .../compute/AzureTemplateBuilderLiveTest.java | 14 +- .../AzureComputeImageExtensionLiveTest.java | 23 +- .../arm/internal/AzureLiveTestUtils.java | 25 ++- 5 files changed, 125 insertions(+), 171 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c9542dc0/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java index 94f255c..a2660d7 100644 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java +++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java @@ -89,8 +89,8 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; /** - * Defines the connection between the {@link AzureComputeApi} implementation and the jclouds - * {@link org.jclouds.compute.ComputeService}. + * Defines the connection between the {@link AzureComputeApi} implementation and + * the jclouds {@link org.jclouds.compute.ComputeService}. */ @Singleton public class AzureComputeServiceAdapter implements ComputeServiceAdapter<VirtualMachine, VMHardware, VMImage, Location> { @@ -105,8 +105,7 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual @Inject AzureComputeServiceAdapter(final AzureComputeApi api, final AzureComputeConstants azureComputeConstants, CleanupResources cleanupResources, @Region Supplier<Set<String>> regionIds, - PublicIpAvailablePredicateFactory publicIpAvailable, - LocationToResourceGroupName locationToResourceGroupName) { + PublicIpAvailablePredicateFactory publicIpAvailable, LocationToResourceGroupName locationToResourceGroupName) { this.api = api; this.azureComputeConstants = azureComputeConstants; this.cleanupResources = cleanupResources; @@ -116,38 +115,41 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual } @Override - public NodeAndInitialCredentials<VirtualMachine> createNodeWithGroupEncodedIntoName( - final String group, final String name, final Template template) { + public NodeAndInitialCredentials<VirtualMachine> createNodeWithGroupEncodedIntoName(final String group, + final String name, final Template template) { AzureTemplateOptions templateOptions = template.getOptions().as(AzureTemplateOptions.class); String azureGroup = locationToResourceGroupName.apply(template.getLocation().getId()); - // TODO Store group apart from the name to be able to identify nodes with custom names in the configured group + // TODO Store group apart from the name to be able to identify nodes with + // custom names in the configured group // TODO ARM specific options // TODO user metadata and tags // TODO network ids => create one nic in each network // TODO inbound ports - + String locationName = template.getLocation().getId(); String subnetId = templateOptions.getSubnetId(); NetworkInterfaceCard nic = createNetworkInterfaceCard(subnetId, name, locationName, azureGroup); StorageProfile storageProfile = createStorageProfile(name, template.getImage(), templateOptions.getBlob()); HardwareProfile hardwareProfile = HardwareProfile.builder().vmSize(template.getHardware().getId()).build(); OSProfile osProfile = createOsProfile(name, template); - NetworkProfile networkProfile = NetworkProfile.builder().networkInterfaces(ImmutableList.of(IdReference.create(nic.id()))).build(); + NetworkProfile networkProfile = NetworkProfile.builder() + .networkInterfaces(ImmutableList.of(IdReference.create(nic.id()))).build(); VirtualMachineProperties virtualMachineProperties = VirtualMachineProperties.builder() - .licenseType(null) // TODO - .availabilitySet(null) // TODO - .hardwareProfile(hardwareProfile) - .storageProfile(storageProfile) - .osProfile(osProfile) - .networkProfile(networkProfile) - .build(); - - VirtualMachine virtualMachine = api.getVirtualMachineApi(azureGroup).create(name, template.getLocation().getId(), virtualMachineProperties); - - // Safe to pass null credentials here, as jclouds will default populate the node with the default credentials from the image, or the ones in the options, if provided. - return new NodeAndInitialCredentials<VirtualMachine>(virtualMachine, name, null); + .licenseType(null) // TODO + .availabilitySet(null) // TODO + .hardwareProfile(hardwareProfile).storageProfile(storageProfile).osProfile(osProfile) + .networkProfile(networkProfile).build(); + + VirtualMachine virtualMachine = api.getVirtualMachineApi(azureGroup).create(name, template.getLocation().getId(), + virtualMachineProperties); + + // Safe to pass null credentials here, as jclouds will default populate + // the node with the default credentials from the image, or the ones in + // the options, if provided. + RegionAndId regionAndId = RegionAndId.fromRegionAndId(template.getLocation().getId(), name); + return new NodeAndInitialCredentials<VirtualMachine>(virtualMachine, regionAndId.slashEncode(), null); } @Override @@ -155,16 +157,11 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual final List<VMHardware> hwProfiles = Lists.newArrayList(); for (Location location : listLocations()) { Iterable<VMSize> vmSizes = api.getVMSizeApi(location.name()).list(); - for (VMSize vmSize : vmSizes){ - VMHardware hwProfile = VMHardware.create( - vmSize.name(), - vmSize.numberOfCores(), - vmSize.osDiskSizeInMB(), - vmSize.resourceDiskSizeInMB(), - vmSize.memoryInMB(), - vmSize.maxDataDiskCount(), - location.name(), - false); + for (VMSize vmSize : vmSizes) { + VMHardware hwProfile = VMHardware + .create(vmSize.name(), vmSize.numberOfCores(), vmSize.osDiskSizeInMB(), + vmSize.resourceDiskSizeInMB(), vmSize.memoryInMB(), vmSize.maxDataDiskCount(), location.name(), + false); hwProfiles.add(hwProfile); } } @@ -193,7 +190,8 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual private List<VMImage> listImagesByLocation(String location) { final List<VMImage> osImages = Lists.newArrayList(); - Iterable<String> publishers = Splitter.on(',').trimResults().omitEmptyStrings().split(this.azureComputeConstants.azureImagePublishers()); + Iterable<String> publishers = Splitter.on(',').trimResults().omitEmptyStrings() + .split(this.azureComputeConstants.azureImagePublishers()); for (String publisher : publishers) { osImages.addAll(getImagesFromPublisher(publisher, location)); } @@ -204,15 +202,15 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual public Iterable<VMImage> listImages() { final List<VMImage> osImages = Lists.newArrayList(); - for (Location location : listLocations()){ + for (Location location : listLocations()) { osImages.addAll(listImagesByLocation(location.name())); } - + // list custom images for (ResourceGroup resourceGroup : api.getResourceGroupApi().list()) { String azureGroup = resourceGroup.name(); List<StorageService> storages = api.getStorageAccountApi(azureGroup).list(); - + for (StorageService storage : storages) { String name = storage.name(); StorageService storageService = api.getStorageAccountApi(azureGroup).get(name); @@ -230,7 +228,7 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual } } } - + return osImages; } @@ -238,15 +236,16 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual public VMImage getImage(final String id) { VMImage image = decodeFieldsFromUniqueId(id); String azureGroup = locationToResourceGroupName.apply(image.location()); - + if (image.custom()) { VMImage customImage = null; StorageServiceKeys keys = api.getStorageAccountApi(azureGroup).getKeys(image.storage()); if (keys == null) { - // If the storage account for the image does not exist, it means the image was deleted + // If the storage account for the image does not exist, it means the + // image was deleted return null; } - + BlobHelper blobHelper = new BlobHelper(image.storage(), keys.key1()); try { if (blobHelper.customImageExists()) { @@ -282,33 +281,29 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual @Override public Iterable<Location> listLocations() { final Iterable<String> vmLocations = FluentIterable.from(api.getResourceProviderApi().get("Microsoft.Compute")) - .filter(new Predicate<ResourceProviderMetaData>() { - @Override - public boolean apply(ResourceProviderMetaData input) { - return input.resourceType().equals("virtualMachines"); - } - }) - .transformAndConcat(new Function<ResourceProviderMetaData, Iterable<String>>() { - @Override - public Iterable<String> apply(ResourceProviderMetaData resourceProviderMetaData) { - return resourceProviderMetaData.locations(); - } - }); - - List<Location> locations = FluentIterable.from(api.getLocationApi().list()) - .filter(new Predicate<Location>() { - @Override - public boolean apply(Location location) { - return Iterables.contains(vmLocations, location.displayName()); - } - }) - .filter(new Predicate<Location>() { - @Override - public boolean apply(Location location) { - return regionIds.get().isEmpty() ? true : regionIds.get().contains(location.name()); - } - }) - .toList(); + .filter(new Predicate<ResourceProviderMetaData>() { + @Override + public boolean apply(ResourceProviderMetaData input) { + return input.resourceType().equals("virtualMachines"); + } + }).transformAndConcat(new Function<ResourceProviderMetaData, Iterable<String>>() { + @Override + public Iterable<String> apply(ResourceProviderMetaData resourceProviderMetaData) { + return resourceProviderMetaData.locations(); + } + }); + + List<Location> locations = FluentIterable.from(api.getLocationApi().list()).filter(new Predicate<Location>() { + @Override + public boolean apply(Location location) { + return Iterables.contains(vmLocations, location.displayName()); + } + }).filter(new Predicate<Location>() { + @Override + public boolean apply(Location location) { + return regionIds.get().isEmpty() ? true : regionIds.get().contains(location.name()); + } + }).toList(); return locations; } @@ -317,7 +312,7 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual public VirtualMachine getNode(final String id) { RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id); String azureGroup = locationToResourceGroupName.apply(regionAndId.region()); - return api.getVirtualMachineApi(azureGroup).get(id); + return api.getVirtualMachineApi(azureGroup).get(regionAndId.id()); } @Override @@ -329,21 +324,21 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual public void rebootNode(final String id) { RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id); String azureGroup = locationToResourceGroupName.apply(regionAndId.region()); - api.getVirtualMachineApi(azureGroup).restart(id); + api.getVirtualMachineApi(azureGroup).restart(regionAndId.id()); } @Override public void resumeNode(final String id) { RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id); String azureGroup = locationToResourceGroupName.apply(regionAndId.region()); - api.getVirtualMachineApi(azureGroup).start(id); + api.getVirtualMachineApi(azureGroup).start(regionAndId.id()); } @Override public void suspendNode(final String id) { RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id); String azureGroup = locationToResourceGroupName.apply(regionAndId.region()); - api.getVirtualMachineApi(azureGroup).stop(id); + api.getVirtualMachineApi(azureGroup).stop(regionAndId.id()); } @Override @@ -365,59 +360,55 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual }); } - private OSProfile createOsProfile(String computerName, Template template) { String defaultLoginUser = template.getImage().getDefaultCredentials().getUser(); String defaultLoginPassword = template.getImage().getDefaultCredentials().getOptionalPassword().get(); String adminUsername = Objects.firstNonNull(template.getOptions().getLoginUser(), defaultLoginUser); String adminPassword = Objects.firstNonNull(template.getOptions().getLoginPassword(), defaultLoginPassword); - OSProfile.Builder builder = OSProfile.builder().adminUsername(adminUsername).computerName(computerName); + OSProfile.Builder builder = OSProfile.builder().adminUsername(adminUsername).adminPassword(adminPassword) + .computerName(computerName); + // prefer public key over password - if (template.getOptions().getPublicKey() != null) { + if (template.getOptions().getPublicKey() != null + && OsFamily.WINDOWS != template.getImage().getOperatingSystem().getFamily()) { OSProfile.LinuxConfiguration linuxConfiguration = OSProfile.LinuxConfiguration.create("true", - OSProfile.LinuxConfiguration.SSH.create(ImmutableList.of( - OSProfile.LinuxConfiguration.SSH.SSHPublicKey.create( - String.format("/home/%s/.ssh/authorized_keys", adminUsername), - template.getOptions().getPublicKey()) - )) - ); + OSProfile.LinuxConfiguration.SSH.create(ImmutableList.of(OSProfile.LinuxConfiguration.SSH.SSHPublicKey + .create(String.format("/home/%s/.ssh/authorized_keys", adminUsername), template.getOptions() + .getPublicKey())))); builder.linuxConfiguration(linuxConfiguration); - } else { - builder.adminPassword(adminPassword); } + return builder.build(); } - private NetworkInterfaceCard createNetworkInterfaceCard(String subnetId, String name, String locationName, String azureGroup) { + private NetworkInterfaceCard createNetworkInterfaceCard(String subnetId, String name, String locationName, + String azureGroup) { final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(azureGroup); - PublicIPAddressProperties properties = - PublicIPAddressProperties.builder() - .publicIPAllocationMethod("Static") - .idleTimeoutInMinutes(4) - .build(); + PublicIPAddressProperties properties = PublicIPAddressProperties.builder().publicIPAllocationMethod("Static") + .idleTimeoutInMinutes(4).build(); String publicIpAddressName = "public-address-" + name; - PublicIPAddress ip = ipApi.createOrUpdate(publicIpAddressName, locationName, ImmutableMap.of("jclouds", name), properties); - + PublicIPAddress ip = ipApi.createOrUpdate(publicIpAddressName, locationName, ImmutableMap.of("jclouds", name), + properties); + checkState(publicIpAvailable.create(azureGroup).apply(publicIpAddressName), "Public IP was not provisioned in the configured timeout"); - final NetworkInterfaceCardProperties networkInterfaceCardProperties = - NetworkInterfaceCardProperties.builder() - .ipConfigurations(ImmutableList.of( - IpConfiguration.builder() - .name("ipConfig-" + name) - .properties(IpConfigurationProperties.builder() - .privateIPAllocationMethod("Dynamic") - .publicIPAddress(IdReference.create(ip.id())) - .subnet(IdReference.create(subnetId)) - .build()) - .build())) - .build(); + final NetworkInterfaceCardProperties networkInterfaceCardProperties = NetworkInterfaceCardProperties + .builder() + .ipConfigurations( + ImmutableList.of(IpConfiguration + .builder() + .name("ipConfig-" + name) + .properties( + IpConfigurationProperties.builder().privateIPAllocationMethod("Dynamic") + .publicIPAddress(IdReference.create(ip.id())).subnet(IdReference.create(subnetId)) + .build()).build())).build(); String networkInterfaceCardName = "jc-nic-" + name; - return api.getNetworkInterfaceCardApi(azureGroup).createOrUpdate(networkInterfaceCardName, locationName, networkInterfaceCardProperties, ImmutableMap.of("jclouds", name)); + return api.getNetworkInterfaceCardApi(azureGroup).createOrUpdate(networkInterfaceCardName, locationName, + networkInterfaceCardProperties, ImmutableMap.of("jclouds", name)); } private StorageProfile createStorageProfile(String name, Image image, String blob) { @@ -425,14 +416,10 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual ImageReference imageReference = null; VHD sourceImage = null; String osType = null; - + if (!imageRef.custom()) { - imageReference = ImageReference.builder() - .publisher(image.getProviderId()) - .offer(image.getName()) - .sku(image.getVersion()) - .version("latest") - .build(); + imageReference = ImageReference.builder().publisher(image.getProviderId()).offer(image.getName()) + .sku(image.getVersion()).version("latest").build(); } else { sourceImage = VHD.create(image.getProviderId()); @@ -440,10 +427,10 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual OsFamily osFamily = image.getOperatingSystem().getFamily(); osType = osFamily == OsFamily.WINDOWS ? "Windows" : "Linux"; } - + VHD vhd = VHD.create(blob + "vhds/" + name + ".vhd"); OSDisk osDisk = OSDisk.create(osType, name, vhd, "ReadWrite", "FromImage", sourceImage); - - return StorageProfile.create(imageReference, osDisk, ImmutableList.<DataDisk>of()); + + return StorageProfile.create(imageReference, osDisk, ImmutableList.<DataDisk> of()); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c9542dc0/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceLiveTest.java index a0ad66c..c59509f 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceLiveTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceLiveTest.java @@ -16,19 +16,9 @@ */ package org.jclouds.azurecompute.arm.compute; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.IMAGE_PUBLISHERS; -import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_PREFIX; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_PORT_OPEN; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_SCRIPT_COMPLETE; import static org.jclouds.compute.options.TemplateOptions.Builder.authorizePublicKey; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; -import java.util.concurrent.TimeUnit; import org.jclouds.azurecompute.arm.AzureComputeProviderMetadata; import org.jclouds.azurecompute.arm.internal.AzureLiveTestUtils; @@ -78,19 +68,8 @@ public class AzureComputeServiceLiveTest extends BaseComputeServiceLiveTest { @Override protected Properties setupProperties() { Properties properties = super.setupProperties(); - String defaultTimeout = String.valueOf(TimeUnit.MILLISECONDS.convert(60, TimeUnit.MINUTES)); - properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, defaultTimeout); - properties.setProperty(TIMEOUT_NODE_RUNNING, defaultTimeout); - properties.setProperty(TIMEOUT_PORT_OPEN, defaultTimeout); - properties.setProperty(TIMEOUT_NODE_TERMINATED, defaultTimeout); - properties.setProperty(TIMEOUT_NODE_SUSPENDED, defaultTimeout); - properties.put(RESOURCENAME_PREFIX, "jc"); - properties.put(PROPERTY_REGIONS, "eastus"); - properties.put(IMAGE_PUBLISHERS, "Canonical"); - AzureLiveTestUtils.defaultProperties(properties); - checkNotNull(setIfTestSystemPropertyPresent(properties, "oauth.endpoint"), "test.oauth.endpoint"); - + setIfTestSystemPropertyPresent(properties, "oauth.endpoint"); return properties; } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c9542dc0/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureTemplateBuilderLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureTemplateBuilderLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureTemplateBuilderLiveTest.java index 794bde2..56200c4 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureTemplateBuilderLiveTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureTemplateBuilderLiveTest.java @@ -16,8 +16,6 @@ */ package org.jclouds.azurecompute.arm.compute; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_PREFIX; import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -58,25 +56,23 @@ public class AzureTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { @Override protected Properties setupProperties() { Properties properties = super.setupProperties(); - properties.put(RESOURCENAME_PREFIX, "jc"); - AzureLiveTestUtils.defaultProperties(properties); - checkNotNull(setIfTestSystemPropertyPresent(properties, "oauth.endpoint"), "test.oauth.endpoint"); - + setIfTestSystemPropertyPresent(properties, "oauth.endpoint"); return properties; } - + @Override @Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = view.getComputeService().templateBuilder().build(); assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[45]\\.[01][04]\\.[0-9]-LTS"), - "Version mismatch, expected dd.dd.d-LTS, found: " + defaultTemplate.getImage().getOperatingSystem().getVersion()); + "Version mismatch, expected dd.dd.d-LTS, found: " + + defaultTemplate.getImage().getOperatingSystem().getVersion()); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); } - + @Override protected Set<String> getIso3166Codes() { return Region.iso3166Codes(); http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c9542dc0/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeImageExtensionLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeImageExtensionLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeImageExtensionLiveTest.java index 4d1a094..c8a9259 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeImageExtensionLiveTest.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeImageExtensionLiveTest.java @@ -16,20 +16,10 @@ */ package org.jclouds.azurecompute.arm.compute.extensions; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.IMAGE_PUBLISHERS; -import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_PREFIX; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_PORT_OPEN; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_SCRIPT_COMPLETE; import static org.jclouds.compute.options.TemplateOptions.Builder.authorizePublicKey; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Map; import java.util.Properties; -import java.util.concurrent.TimeUnit; import org.jclouds.azurecompute.arm.AzureComputeProviderMetadata; import org.jclouds.azurecompute.arm.internal.AzureLiveTestUtils; @@ -63,19 +53,8 @@ public class AzureComputeImageExtensionLiveTest extends BaseImageExtensionLiveTe @Override protected Properties setupProperties() { Properties properties = super.setupProperties(); - String defaultTimeout = String.valueOf(TimeUnit.MILLISECONDS.convert(60, TimeUnit.MINUTES)); - properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, defaultTimeout); - properties.setProperty(TIMEOUT_NODE_RUNNING, defaultTimeout); - properties.setProperty(TIMEOUT_PORT_OPEN, defaultTimeout); - properties.setProperty(TIMEOUT_NODE_TERMINATED, defaultTimeout); - properties.setProperty(TIMEOUT_NODE_SUSPENDED, defaultTimeout); - properties.put(RESOURCENAME_PREFIX, "jc"); - properties.put(PROPERTY_REGIONS, "eastus"); - properties.put(IMAGE_PUBLISHERS, "Canonical"); - AzureLiveTestUtils.defaultProperties(properties); - checkNotNull(setIfTestSystemPropertyPresent(properties, "oauth.endpoint"), "test.oauth.endpoint"); - + setIfTestSystemPropertyPresent(properties, "oauth.endpoint"); return properties; } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/c9542dc0/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AzureLiveTestUtils.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AzureLiveTestUtils.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AzureLiveTestUtils.java index 3f69e59..125e11a 100644 --- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AzureLiveTestUtils.java +++ b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AzureLiveTestUtils.java @@ -16,21 +16,34 @@ */ package org.jclouds.azurecompute.arm.internal; -import java.util.Properties; - +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.IMAGE_PUBLISHERS; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_PORT_OPEN; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_SCRIPT_COMPLETE; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import static org.jclouds.oauth.v2.config.CredentialType.CLIENT_CREDENTIALS_SECRET; import static org.jclouds.oauth.v2.config.OAuthProperties.CREDENTIAL_TYPE; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + public class AzureLiveTestUtils { public static Properties defaultProperties(Properties properties) { properties = properties == null ? new Properties() : properties; - properties.put("oauth.identity", "foo"); - properties.put("oauth.credential", "password"); - properties.put("oauth.endpoint", "https://login.microsoftonline.com/oauth2/token"); properties.put(CREDENTIAL_TYPE, CLIENT_CREDENTIALS_SECRET.toString()); - properties.put(PROPERTY_REGIONS, "northeurope"); + properties.put(PROPERTY_REGIONS, "eastus"); + properties.put(IMAGE_PUBLISHERS, "Canonical"); + + String defaultTimeout = String.valueOf(TimeUnit.MILLISECONDS.convert(60, TimeUnit.MINUTES)); + properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, defaultTimeout); + properties.setProperty(TIMEOUT_NODE_RUNNING, defaultTimeout); + properties.setProperty(TIMEOUT_PORT_OPEN, defaultTimeout); + properties.setProperty(TIMEOUT_NODE_TERMINATED, defaultTimeout); + properties.setProperty(TIMEOUT_NODE_SUSPENDED, defaultTimeout); + return properties; } }