@Override public Set<String> getTags() { return delegate.getTags(); }
@Override public Set<String> getTags() { return delegate.getTags(); }
@Override public Set<String> getTags() { return delegate.getTags(); }
@Override public Set<String> getTags() { return delegate.getTags(); }
/** * For cloud apis that need to namespace tags as the value of the key {@code jclouds.tags} */ public static Map<String, String> metadataAndTagsAsCommaDelimitedValue(TemplateOptions options) { Builder<String, String> builder = ImmutableMap.<String, String> builder(); builder.putAll(options.getUserMetadata()); if (options.getTags().size() > 0) builder.put("jclouds_tags", Joiner.on(',').join(options.getTags())); return builder.build(); }
/** * For cloud apis that need to namespace tags as the value of the key {@code jclouds.tags} */ public static Map<String, String> metadataAndTagsAsCommaDelimitedValue(TemplateOptions options) { Builder<String, String> builder = ImmutableMap.<String, String> builder(); builder.putAll(options.getUserMetadata()); if (!options.getTags().isEmpty()) builder.put("jclouds_tags", Joiner.on(',').join(options.getTags())); return builder.build(); }
/** * For cloud apis that need to namespace tags as the value of the key {@code jclouds.tags} */ public static Map<String, String> metadataAndTagsAsCommaDelimitedValue(TemplateOptions options) { Builder<String, String> builder = ImmutableMap.<String, String> builder(); builder.putAll(options.getUserMetadata()); if (!options.getTags().isEmpty()) builder.put("jclouds_tags", Joiner.on(',').join(options.getTags())); return builder.build(); }
/** * For cloud apis that need to namespace tags as the value of the key {@code jclouds.tags} */ public static Map<String, String> metadataAndTagsAsCommaDelimitedValue(TemplateOptions options) { Builder<String, String> builder = ImmutableMap.<String, String> builder(); builder.putAll(options.getUserMetadata()); if (options.getTags().size() > 0) builder.put("jclouds_tags", Joiner.on(',').join(options.getTags())); return builder.build(); }
/** * For cloud apis that have a pattern of using empty strings as tags, return a map that contains * that. */ public static Map<String, String> metadataAndTagsAsValuesOfEmptyString(TemplateOptions options) { Builder<String, String> builder = ImmutableMap.<String, String> builder(); builder.putAll(options.getUserMetadata()); for (String tag : options.getTags()) builder.put(tag, ""); return builder.build(); }
/** * For cloud apis that have a pattern of using empty strings as tags, return a map that contains * that. */ public static Map<String, String> metadataAndTagsAsValuesOfEmptyString(TemplateOptions options) { Builder<String, String> builder = ImmutableMap.<String, String> builder(); builder.putAll(options.getUserMetadata()); for (String tag : options.getTags()) builder.put(tag, ""); return builder.build(); }
/** computes the tags that this template will set (argument true) or require to match (argument false) */ public Set<String> getTags(boolean includeOptional) { return ImmutableSet.copyOf(computeAggregatedOptions(includeOptional).getTags()); }
/** * For cloud apis that have a pattern of using empty strings as tags, return a map that contains * that. */ public static Map<String, String> metadataAndTagsAsValuesOfEmptyString(TemplateOptions options) { Builder<String, String> builder = ImmutableMap.<String, String> builder(); builder.putAll(options.getUserMetadata()); for (String tag : options.getTags()) builder.put(tag, ""); return builder.build(); }
/** * For cloud apis that have a pattern of using empty strings as tags, return a map that contains * that. */ public static Map<String, String> metadataAndTagsAsValuesOfEmptyString(TemplateOptions options) { Builder<String, String> builder = ImmutableMap.<String, String> builder(); builder.putAll(options.getUserMetadata()); for (String tag : options.getTags()) builder.put(tag, ""); return builder.build(); }
protected String makeNonTrivialArgumentsString() { String s = super.makeNonTrivialArgumentsString(); TemplateOptions aggr = computeAggregatedOptions(false); if (aggr.getInboundPorts().length>0) s = "ports="+Ints.asList(aggr.getInboundPorts())+(s!=null && s.length()>0 ? ", "+s : ""); if (!aggr.getUserMetadata().isEmpty()) s = "metadata="+aggr.getUserMetadata()+(s!=null && s.length()>0 ? ", "+s : ""); if (!aggr.getTags().isEmpty()) s = "tags="+aggr.getTags()+(s!=null && s.length()>0 ? ", "+s : ""); return s; }
/** like TemplateOptions.copyTo but additive wrt arrays, collections, and maps, * putting moreOptions in on top of / at the end of options. * currently applies to inboundPorts, tags, and userMetadata. */ public static TemplateOptions addTemplateOptions(TemplateOptions options, TemplateOptions moreOptions) { TemplateOptions result = options.clone(); moreOptions.copyTo(result); Set<String> tags = new LinkedHashSet<String>(options.getTags()); tags.addAll(moreOptions.getTags()); result.tags(tags); Map<String,String> userMetadata = new LinkedHashMap<String,String>(options.getUserMetadata()); userMetadata.putAll(moreOptions.getUserMetadata()); result.userMetadata(userMetadata); Set<Integer> inboundPorts = new TreeSet<Integer>(); for (int port: options.getInboundPorts()) inboundPorts.add(port); for (int port: moreOptions.getInboundPorts()) inboundPorts.add(port); int[] inboundPortsArray = new int[inboundPorts.size()]; int i=0; for (Iterator<Integer> portI=inboundPorts.iterator(); portI.hasNext();) { inboundPortsArray[i++] = portI.next(); } result.inboundPorts(inboundPortsArray); return result; }
public void copyTo(TemplateOptions to) { super.copyTo(to); if (!Arrays.equals(to.getInboundPorts(), this.getInboundPorts())) to.inboundPorts(this.getInboundPorts()); if (this.getRunScript() != null) to.runScript(this.getRunScript()); if (!this.getGroups().isEmpty()) to.securityGroups(this.getGroups()); if (this.getPrivateKey() != null) to.installPrivateKey(this.getPrivateKey()); if (this.getPublicKey() != null) to.authorizePublicKey(this.getPublicKey()); if (!this.getUserMetadata().isEmpty()) to.userMetadata(this.getUserMetadata()); if (!this.getTags().isEmpty()) to.tags(getTags()); if (!this.getNodeNames().isEmpty()) to.nodeNames(getNodeNames()); if (!this.shouldBlockUntilRunning()) to.blockUntilRunning(false); if (!this.getNetworks().isEmpty()) to.networks(this.getNetworks()); }
@Override public NodeWithInitialCredentials createNodeWithGroupEncodedIntoName(String group, String name, Template template) { NodeMetadataBuilder builder = new NodeMetadataBuilder(); String id = idProvider.get() + ""; builder.ids(id); builder.name(name); // using a predictable name so tests will pass builder.hostname(group); builder.tags(template.getOptions().getTags()); builder.userMetadata(template.getOptions().getUserMetadata()); builder.group(group); builder.location(location.get()); builder.imageId(template.getImage().getId()); builder.operatingSystem(template.getImage().getOperatingSystem()); builder.status(Status.PENDING); builder.publicAddresses(ImmutableSet.<String> of(publicIpPrefix + id)); builder.privateAddresses(ImmutableSet.<String> of(privateIpPrefix + id)); builder.credentials(LoginCredentials.builder().user("root").password(passwordPrefix + id).build()); NodeMetadata node = builder.build(); nodes.put(node.getId(), node); setStateOnNodeAfterDelay(Status.RUNNING, node, 100); return new NodeWithInitialCredentials(node); }
@Override protected NodeMetadata newNode(String group, Template template) { NodeMetadata result = new NodeMetadataBuilder() .id("myNodeId") .credentials(LoginCredentials.builder().identity("myuser").credential("mypassword").build()) .loginPort(serverSocket.getLocalPort()) .status(Status.RUNNING) .publicAddresses(ImmutableList.of(serverSocket.getInetAddress().getHostAddress())) .privateAddresses(ImmutableList.of("1.2.3.4")) .imageId(template.getImage().getId()) .tags(template.getOptions().getTags()) .hardware(includeNodeHardwareMetadata ? template.getHardware() : null) .group(template.getOptions().getGroups().isEmpty() ? "myGroup" : Iterables.get(template.getOptions().getGroups(), 0)) .build(); return result; } };
@Override public NodeAndInitialCredentials<ServerInfo> createNodeWithGroupEncodedIntoName(String tag, String name, Template template) { long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l); logger.debug(">> creating boot drive bytes(%d)", bootSize); DriveInfo drive = client .createDrive(new Drive.Builder().name(template.getImage().getId()).size(bootSize).build()); logger.debug("<< drive(%s)", drive.getUuid()); logger.debug(">> imaging boot drive source(%s)", template.getImage().getId()); client.imageDrive(template.getImage().getId(), drive.getUuid(), ImageConversionType.GUNZIP); boolean success = driveNotClaimed.apply(drive); logger.debug("<< imaged (%s)", success); if (!success) { client.destroyDrive(drive.getUuid()); throw new IllegalStateException("could not image drive in time!"); } Server toCreate = small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam()) .cpu((int) (template.getHardware().getProcessors().get(0).getSpeed())) .tags(template.getOptions().getTags()).userMetadata(template.getOptions().getUserMetadata()).build(); ServerInfo from = client.createServer(toCreate); client.startServer(from.getUuid()); from = client.getServerInfo(from.getUuid()); return new NodeAndInitialCredentials<ServerInfo>(from, from.getUuid(), LoginCredentials.builder() .password(defaultVncPassword).build()); }
@Override public NodeAndInitialCredentials<ServerInfo> createNodeWithGroupEncodedIntoName(String tag, String name, Template template) { long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l); logger.debug(">> creating boot drive bytes(%d)", bootSize); DriveInfo drive = client .createDrive(new Drive.Builder().name(template.getImage().getId()).size(bootSize).build()); logger.debug("<< drive(%s)", drive.getUuid()); logger.debug(">> imaging boot drive source(%s)", template.getImage().getId()); client.imageDrive(template.getImage().getId(), drive.getUuid(), ImageConversionType.GUNZIP); boolean success = driveNotClaimed.apply(drive); logger.debug("<< imaged (%s)", success); if (!success) { client.destroyDrive(drive.getUuid()); throw new IllegalStateException("could not image drive in time!"); } template.getOptions().userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, tag); Server toCreate = small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam()) .cpu((int) (template.getHardware().getProcessors().get(0).getSpeed())) .tags(template.getOptions().getTags()).userMetadata(template.getOptions().getUserMetadata()).build(); ServerInfo from = client.createServer(toCreate); client.startServer(from.getUuid()); from = client.getServerInfo(from.getUuid()); return new NodeAndInitialCredentials<ServerInfo>(from, from.getUuid(), LoginCredentials.builder() .password(defaultVncPassword).build()); }