Checks existence of node before getting SecurityGroups and Images

This commit is contained in:
Daniel Estevez 2017-02-09 14:07:43 -05:00 committed by Ignasi Barrera
parent efb3dd53d0
commit 21cda804b8
3 changed files with 8 additions and 1 deletions

View File

@ -115,7 +115,7 @@ public class AzureComputeImageExtension implements ImageExtension {
URI uri = api.getVirtualMachineApi(resourceGroupName)
.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());
"Image for node %s was not created within the configured time limit", cloneTemplate.getName());
List<ResourceDefinition> definitions = api.getJobApi().captureStatus(uri);
checkState(definitions.size() == 1,
@ -123,6 +123,7 @@ public class AzureComputeImageExtension implements ImageExtension {
Image image = resourceDefinitionToImage.create(cloneTemplate.getSourceNodeId(), cloneTemplate.getName())
.apply(definitions.get(0));
checkState(image != null, "Image for node %s was not created", cloneTemplate.getSourceNodeId());
logger.debug(">> created %s", image);
return image;
}

View File

@ -123,6 +123,9 @@ public class AzureComputeSecurityGroupExtension implements SecurityGroupExtensio
ResourceGroup resourceGroup = resourceGroupMap.getUnchecked(regionAndId.region());
VirtualMachine vm = api.getVirtualMachineApi(resourceGroup.name()).get(regionAndId.id());
if (vm == null) {
throw new IllegalArgumentException("Node " + regionAndId.id() + " was not found");
}
List<IdReference> networkInterfacesIdReferences = vm.properties().networkProfile().networkInterfaces();
List<NetworkSecurityGroup> networkGroups = new ArrayList<NetworkSecurityGroup>();

View File

@ -68,6 +68,9 @@ public class ResourceDefinitionToCustomImage implements Function<ResourceDefinit
ResourceGroup resourceGroup = resourceGroupMap.getUnchecked(regionAndId.region());
VirtualMachine vm = api.getVirtualMachineApi(resourceGroup.name()).get(regionAndId.id());
if (vm == null) {
return null;
}
String storageAccountName = storageProfileToStorageAccountName.apply(vm.properties().storageProfile());
VMImage.Builder builder = VMImage.customImage().group(resourceGroup.name()).storage(storageAccountName)