Fixes to the Image Extension

Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/b1a8efcc
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/b1a8efcc
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/b1a8efcc

Branch: refs/heads/resource-group-location
Commit: b1a8efcc87553f5fb17b8ae6b239a44514688557
Parents: c9542dc
Author: Ignasi Barrera <n...@apache.org>
Authored: Mon Oct 17 13:01:34 2016 +0200
Committer: Ignasi Barrera <n...@apache.org>
Committed: Mon Oct 17 13:02:10 2016 +0200

----------------------------------------------------------------------
 .../arm/compute/AzureComputeServiceAdapter.java |  1 -
 .../extensions/AzureComputeImageExtension.java  | 23 ++++++++++----------
 .../ResourceDefinitionToCustomImage.java        |  2 +-
 .../arm/functions/CleanupResources.java         |  2 +-
 4 files changed, 13 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b1a8efcc/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 a2660d7..434c92f 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
@@ -368,7 +368,6 @@ public class AzureComputeServiceAdapter implements 
ComputeServiceAdapter<Virtual
       OSProfile.Builder builder = 
OSProfile.builder().adminUsername(adminUsername).adminPassword(adminPassword)
             .computerName(computerName);
 
-      // prefer public key over password
       if (template.getOptions().getPublicKey() != null
             && OsFamily.WINDOWS != 
template.getImage().getOperatingSystem().getFamily()) {
          OSProfile.LinuxConfiguration linuxConfiguration = 
OSProfile.LinuxConfiguration.create("true",

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b1a8efcc/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeImageExtension.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeImageExtension.java
 
b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeImageExtension.java
index 7f163c5..1e57899 100644
--- 
a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeImageExtension.java
+++ 
b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeImageExtension.java
@@ -94,25 +94,23 @@ public class AzureComputeImageExtension implements 
ImageExtension {
    @Override
    public ListenableFuture<Image> createImage(ImageTemplate template) {
       final CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
-      final String id = cloneTemplate.getSourceNodeId();
-      final String name = cloneTemplate.getName();
       
-      RegionAndId regionAndId = RegionAndId.fromSlashEncoded(id);
+      final RegionAndId regionAndId = 
RegionAndId.fromSlashEncoded(cloneTemplate.getSourceNodeId());
       final String group = 
locationToResourceGroupName.apply(regionAndId.region());
 
-      logger.debug(">> stopping node %s...", id);
-      api.getVirtualMachineApi(group).stop(id);
-      checkState(nodeSuspendedPredicate.create(group).apply(id),
-            "Node %s was not suspended within the configured time limit", id);
+      logger.debug(">> stopping node %s...", regionAndId.slashEncode());
+      api.getVirtualMachineApi(group).stop(regionAndId.id());
+      checkState(nodeSuspendedPredicate.create(group).apply(regionAndId.id()),
+            "Node %s was not suspended within the configured time limit", 
regionAndId.slashEncode());
 
       return userExecutor.submit(new Callable<Image>() {
          @Override
          public Image call() throws Exception {
-            logger.debug(">> generalizing virtal machine %s...", id);
-            api.getVirtualMachineApi(group).generalize(id);
+            logger.debug(">> generalizing virtal machine %s...", 
regionAndId.id());
+            api.getVirtualMachineApi(group).generalize(regionAndId.id());
 
-            logger.debug(">> capturing virtual machine %s to container %s...", 
id, CONTAINER_NAME);
-            URI uri = api.getVirtualMachineApi(group).capture(id, 
cloneTemplate.getName(), CONTAINER_NAME);
+            logger.debug(">> capturing virtual machine %s to container %s...", 
regionAndId.id(), CONTAINER_NAME);
+            URI uri = 
api.getVirtualMachineApi(group).capture(regionAndId.id(), 
cloneTemplate.getName(), CONTAINER_NAME);
             checkState(uri != null && imageAvailablePredicate.apply(uri),
                   "Image %s was not created within the configured time limit", 
cloneTemplate.getName());
 
@@ -120,7 +118,8 @@ public class AzureComputeImageExtension implements 
ImageExtension {
             checkState(definitions.size() == 1,
                   "Expected one resource definition after creating the image 
but %s were returned", definitions.size());
 
-            Image image = resourceDefinitionToImage.create(id, 
name).apply(definitions.get(0));
+            Image image = 
resourceDefinitionToImage.create(cloneTemplate.getSourceNodeId(), 
cloneTemplate.getName())
+                  .apply(definitions.get(0));
             logger.debug(">> created %s", image);
             return image;
          }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b1a8efcc/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/ResourceDefinitionToCustomImage.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/ResourceDefinitionToCustomImage.java
 
b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/ResourceDefinitionToCustomImage.java
index e2dae87..02fb0f4 100644
--- 
a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/ResourceDefinitionToCustomImage.java
+++ 
b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/ResourceDefinitionToCustomImage.java
@@ -56,7 +56,7 @@ public class ResourceDefinitionToCustomImage implements 
Function<ResourceDefinit
       
       RegionAndId regionAndId = RegionAndId.fromSlashEncoded(nodeId);
       this.resourceGroup = 
locationToResourceGroupName.apply(regionAndId.region());
-      this.vm = api.getVirtualMachineApi(this.resourceGroup).get(nodeId);
+      this.vm = 
api.getVirtualMachineApi(this.resourceGroup).get(regionAndId.id());
       this.storageAccountName = 
storageProfileToStorageAccountName.apply(vm.properties().storageProfile());
    }
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b1a8efcc/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/CleanupResources.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/CleanupResources.java
 
b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/CleanupResources.java
index 78909c6..ead676a 100644
--- 
a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/CleanupResources.java
+++ 
b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/functions/CleanupResources.java
@@ -80,7 +80,7 @@ public class CleanupResources implements Function<String, 
Boolean> {
          return true;
       }
 
-      logger.debug(">> destroying %s ...", id);
+      logger.debug(">> destroying %s ...", regionAndId.slashEncode());
       boolean vmDeleted = deleteVirtualMachine(group, virtualMachine);
       
       // We don't delete the network here, as it is global to the resource

Reply via email to