@Override public boolean apply(NodeMetadata input) { return input.getTags().contains(tag); } };
@Override public boolean apply(NodeMetadata node) { if (tags == null) { return true; } else { return node.getTags().containsAll(Arrays.asList(tags)); } }
@Override public boolean apply(NodeMetadata node) { if (tags == null) { return true; } else { return node.getTags().containsAll(Arrays.asList(tags)); } }
@Override protected void checkTagsInNodeEquals(NodeMetadata node, ImmutableSet<String> tags) { Set<String> nodeTags = node.getTags(); for (String tag : tags){ assert nodeTags.contains(tag) : String.format("node tags did not match %s %s node %s:", tags, nodeTags, node); } }
@Override protected void checkTagsInNodeEquals(final NodeMetadata node, final ImmutableSet<String> tags) { assert node.getTags().equals(ImmutableSet.<String> of()) : String.format("node tags did not match %s %s", tags, node); }
protected void checkTagsInNodeEquals(NodeMetadata node, ImmutableSet<String> tags) { assert node.getTags().equals(tags) : format("node tags did not match %s %s", tags, node); }
protected void checkTagsInNodeEquals(NodeMetadata node, ImmutableSet<String> tags) { assert node.getTags().equals(tags) : format("node tags did not match %s %s", tags, node); }
@Override public Boolean apply(NodeMetadata node) { final RegionAndId regionAndId = RegionAndId.fromSlashEncoded(node.getId()); removeFloatingIpFromNodeifAny(regionAndId); return removeSecurityGroupCreatedByJcloudsAndInvalidateCache(node.getTags()); }
@Override public Boolean apply(NodeMetadata node) { final RegionAndId regionAndId = RegionAndId.fromSlashEncoded(node.getId()); removeFloatingIpFromNodeifAny(regionAndId); return removeSecurityGroupCreatedByJcloudsAndInvalidateCache(node.getTags()); }
@Test public final void testInstanceWithGroupNull() { NodeMetadata nodeMetadata = groupNullNodeParser.apply(instance); assertEquals(nodeMetadata.getId(), instance.selfLink().toString()); assertEquals(nodeMetadata.getTags(), ImmutableSet.of("aTag", "Group-port-42")); }
@Override protected void checkTagsInNodeEquals(NodeMetadata node, ImmutableSet<String> tags) { if (view.unwrapApi(EC2Api.class).getTagApi().isPresent()) { super.checkTagsInNodeEquals(node, tags); } else { assertTrue(node.getTags().isEmpty(), "not expecting tags when tag extension isn't present: " + node); } }
public void testWhenVDCIsLocation() { Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description") .scope(LocationScope.PROVIDER).build(); Injector injector = createInjectorWithLocation(location); InputStream is = getClass().getResourceAsStream("/vapp-pool.xml"); Factory factory = injector.getInstance(ParseSax.Factory.class); VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class); NodeMetadata node = converter.apply(result); assertNotNull(node); assertEquals(node.getUserMetadata(), ImmutableMap.<String, String>of()); assertEquals(node.getTags(), ImmutableSet.<String>of()); assertEquals(node.getLocation(), location); assertEquals(node.getPrivateAddresses(), ImmutableSet.of("172.16.7.230")); assertEquals(node.getPublicAddresses(), ImmutableSet.of()); }
public void testWithEncodedMetadata() { Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description") .scope(LocationScope.PROVIDER).build(); Injector injector = createInjectorWithLocation(location); InputStream is = getClass().getResourceAsStream("/vapp-pool.xml"); Factory factory = injector.getInstance(ParseSax.Factory.class); VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class); ImmutableMap<String, String> metadata = ImmutableMap.<String, String>of("foo", "bar"); ImmutableSet<String> tags = ImmutableSet.<String>of("tag1", "tag2"); String description = Joiner .on('\n') .withKeyValueSeparator("=") .join(ImmutableMap.<String, String> builder().putAll(metadata) .put("jclouds_tags", Joiner.on(',').join(tags)).build()); result = new VAppImpl(result.getName(), result.getType(), result.getHref(), result.getStatus(), result.getVDC(), description, result.getTasks(), result.isOvfDescriptorUploaded(), result.getChildren(), result.getNetworkSection()); NodeMetadata node = converter.apply(result); assertNotNull(node); assertEquals(node.getUserMetadata(), metadata); assertEquals(node.getTags(), tags); }
public void testWithMetadataParseException() { Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description") .scope(LocationScope.PROVIDER).build(); Injector injector = createInjectorWithLocation(location); InputStream is = getClass().getResourceAsStream("/vapp-pool.xml"); Factory factory = injector.getInstance(ParseSax.Factory.class); VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class); ImmutableMap<String, String> metadata = ImmutableMap.<String, String>of(); ImmutableSet<String> tags = ImmutableSet.<String>of(); String description = " user=user_ssoid_1\nuid=3b7bb605-bb30-4e62-a3de-9076b052dee7 label='foo-DEVELOPMENT' date=2013-01-22 17:39:28.252"; result = new VAppImpl(result.getName(), result.getType(), result.getHref(), result.getStatus(), result.getVDC(), description, result.getTasks(), result.isOvfDescriptorUploaded(), result.getChildren(), result.getNetworkSection()); NodeMetadata node = converter.apply(result); assertNotNull(node); assertEquals(node.getUserMetadata(), metadata); assertEquals(node.getTags(), tags); }
public void testWithMetadataNoNewLines() { Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description") .scope(LocationScope.PROVIDER).build(); Injector injector = createInjectorWithLocation(location); InputStream is = getClass().getResourceAsStream("/vapp-pool.xml"); Factory factory = injector.getInstance(ParseSax.Factory.class); VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class); ImmutableMap<String, String> metadata = ImmutableMap.<String, String>of(); ImmutableSet<String> tags = ImmutableSet.<String>of(); String description = " user=user_ssoid_1 uid=3b7bb605-bb30-4e62-a3de-9076b052dee7 label='foo-DEVELOPMENT' date=2013-01-22 17:39:28.252"; result = new VAppImpl(result.getName(), result.getType(), result.getHref(), result.getStatus(), result.getVDC(), description, result.getTasks(), result.isOvfDescriptorUploaded(), result.getChildren(), result.getNetworkSection()); NodeMetadata node = converter.apply(result); assertNotNull(node); assertEquals(node.getUserMetadata(), metadata); assertEquals(node.getTags(), tags); }
@Override public NodeMetadata apply(@Nullable org.jclouds.compute.domain.NodeMetadata input) { if (input == null) { return null; } return NodeMetadata.builder().id(input.getId()).name(input.getName()).status(input.getStatus().name()) .hostname(input.getHostname()) .loginPort(input.getLoginPort()).group(input.getGroup()) .tags(input.getTags()).metadata(input.getUserMetadata()) .locationId(input.getLocation() != null ? input.getLocation().getId() : null) .imageId(input.getImageId()) .defaultCredentials(ToLoginCredentials.INSTANCE.apply(input.getCredentials())).build(); } }
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group( node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem( node.getOperatingSystem()).status(node.getStatus()).backendStatus(node.getBackendStatus()).loginPort( node.getLoginPort()).publicAddresses(node.getPublicAddresses()).privateAddresses( node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname()); }
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group( node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem( node.getOperatingSystem()).status(node.getStatus()).backendStatus(node.getBackendStatus()).loginPort( node.getLoginPort()).publicAddresses(node.getPublicAddresses()).privateAddresses( node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname()); }
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group( node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem( node.getOperatingSystem()).status(node.getStatus()).backendStatus(node.getBackendStatus()).loginPort( node.getLoginPort()).publicAddresses(node.getPublicAddresses()).privateAddresses( node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname()); }
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) { return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location( node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group( node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem( node.getOperatingSystem()).status(node.getStatus()).backendStatus(node.getBackendStatus()).loginPort( node.getLoginPort()).publicAddresses(node.getPublicAddresses()).privateAddresses( node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname()); }