/** * Specifies the customizationScript used to run instances with */ public VCloudTemplateOptions customizationScript(String customizationScript) { Utils.checkNotEmpty(customizationScript, "customizationScript must be non-empty"); this.customizationScript = customizationScript; return this; }
/** * Specifies the subnetId used to run instances in */ public EC2TemplateOptions subnetId(String subnetId) { checkNotNull(subnetId, "subnetId cannot be null"); Utils.checkNotEmpty(subnetId, "subnetId must be non-empty"); this.subnetId = subnetId; return this; }
/** * Specifies the keypair used to run instances with */ public EC2TemplateOptions placementGroup(String placementGroup) { checkNotNull(placementGroup, "use noPlacementGroup option to request boot without a keypair"); checkState(!noPlacementGroup, "you cannot specify both options placementGroup and noPlacementGroup"); Utils.checkNotEmpty(placementGroup, "placementGroup must be non-empty"); this.placementGroup = placementGroup; return this; }
/** * Specifies the keypair used to run instances with */ public EC2TemplateOptions keyPair(String keyPair) { checkNotNull(keyPair, "use noKeyPair option to request boot without a keypair"); checkState(!noKeyPair, "you cannot specify both options keyPair and noKeyPair"); Utils.checkNotEmpty(keyPair, "keypair must be non-empty"); this.keyPair = keyPair; return this; }
/** * Specifies the security groups to be used for nodes with this template */ public EC2TemplateOptions securityGroups(Iterable<String> groupIds) { checkArgument(Iterables.size(groupIds) > 0, "you must specify at least one security group"); for (String groupId : groupIds) Utils.checkNotEmpty(groupId, "all security groups must be non-empty"); this.groupIds = ImmutableSet.copyOf(groupIds); return this; }
@VisibleForTesting void deleteSecurityGroup(String region, String tag) { checkNotEmpty(tag, "tag"); String group = String.format("jclouds#%s#%s", tag, region); if (ec2Client.getSecurityGroupServices().describeSecurityGroupsInRegion(region, group).size() > 0) { logger.debug(">> deleting securityGroup(%s)", group); ec2Client.getSecurityGroupServices().deleteSecurityGroupInRegion(region, group); // TODO: test this clear happens securityGroupMap.remove(new RegionNameAndIngressRules(region, tag, null, false)); logger.debug("<< deleted securityGroup(%s)", group); } }
@VisibleForTesting void deletePlacementGroup(String region, String tag) { checkNotEmpty(tag, "tag"); String group = String.format("jclouds#%s#%s", tag, region); try { if (ec2Client.getPlacementGroupServices().describePlacementGroupsInRegion(region, group).size() > 0) { logger.debug(">> deleting placementGroup(%s)", group); try { ec2Client.getPlacementGroupServices().deletePlacementGroupInRegion(region, group); checkState(placementGroupDeleted.apply(new PlacementGroup(region, group, "cluster", State.PENDING)), String.format("placementGroup region(%s) name(%s) failed to delete", region, group)); placementGroupMap.remove(new RegionAndName(region, tag)); logger.debug("<< deleted placementGroup(%s)", group); } catch (AWSResponseException e) { if (e.getError().getCode().equals("InvalidPlacementGroup.InUse")) { logger.debug("<< inUse placementGroup(%s)", group); } else { throw e; } } } } catch (HttpResponseException e) { // Eucalyptus does not support placement groups yet. if (!(e.getResponse().getStatusCode() == 400 && context.getProviderSpecificContext().getProvider() .equals("eucalyptus"))) throw e; } }