@Override public String apply(NodeMetadata from) { return from.getLocation().getId(); } }));
@Override public ZoneAndName apply(NodeMetadata input) { String zoneId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return ZoneAndName.fromZoneAndName(zoneId, input.getGroup()); }
@Override public RegionAndName apply(NodeMetadata input) { String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return RegionAndName.fromRegionAndName(regionId, input.getGroup()); }
@Override public ZoneAndName apply(NodeMetadata input) { String zoneId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return ZoneAndName.fromZoneAndName(zoneId, input.getGroup()); }
@Override public ZoneAndName apply(NodeMetadata input) { String zoneId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return ZoneAndName.fromZoneAndName(zoneId, input.getGroup()); }
@Override public RegionAndName apply(NodeMetadata input) { String regionId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation() .getParent().getId() : input.getLocation().getId(); return RegionAndName.fromRegionAndName(regionId, input.getGroup()); }
@Override public DatacenterAndName apply(NodeMetadata input) { String datacenterId = input.getLocation().getId(); return DatacenterAndName.fromDatacenterAndName(datacenterId, input.getGroup()); }
protected String extractNodeLocationId(ConfigBag setup, NodeMetadata node, LocationScope scope) { org.jclouds.domain.Location nodeLoc = node.getLocation(); do { if (nodeLoc.getScope() == scope) return nodeLoc.getId(); nodeLoc = nodeLoc.getParent(); } while (nodeLoc != null); return null; }
private void fetchMemberMetaData(NodeMetadata metadata) { Location location = metadata.getLocation(); while (location != null) { String id = location.getId(); if (location.getScope().equals(LocationScope.ZONE)) { if (id != null) { memberMetaData.put(PARTITION_GROUP_ZONE, id); } } location = location.getParent(); } memberMetaData.put(PARTITION_GROUP_HOST, metadata.getHostname()); }
@Override public DatacenterAndName apply(NodeMetadata input) { String datacenterId = input.getLocation().getId(); return DatacenterAndName.fromDatacenterAndName(datacenterId, input.getGroup()); }
@BeforeMethod public void setUp() throws Exception { node = createMock(NodeMetadata.class); computeService = createMock(GetNodeMetadataStrategy.class); expect(node.getId()).andReturn("myid").anyTimes(); expect(computeService.getNode("myid")).andReturn(node).anyTimes(); expect(node.getLocation()).andReturn(null).anyTimes(); }
@BeforeMethod public void setUp() throws Exception { node = createMock(NodeMetadata.class); computeService = createMock(GetNodeMetadataStrategy.class); expect(node.getId()).andReturn("myid").anyTimes(); expect(computeService.getNode("myid")).andReturn(node).anyTimes(); expect(node.getLocation()).andReturn(null).anyTimes(); }
@BeforeMethod public void setUp() { MockitoAnnotations.initMocks(this); customizer = new JcloudsLocationSecurityGroupCustomizer("testapp", new TestCidrSupplier()); when(computeService.getSecurityGroupExtension()).thenReturn(Optional.of(securityApi)); when(location.getParent()).thenReturn(location); when(location.getId()).thenReturn("aws-ec2"); when(jcloudsMachineLocation.getNode().getId()).thenReturn(NODE_ID); when(jcloudsMachineLocation.getNode().getLocation()).thenReturn(location); when(jcloudsMachineLocation.getParent().getComputeService()).thenReturn(computeService); }
private SecurityGroupEditor makeEditor() { final org.jclouds.domain.Location nodeLocation = jcloudsMachineLocation.getNode().getLocation(); ComputeService computeService = jcloudsMachineLocation.getParent().getComputeService(); final Optional<SecurityGroupExtension> securityGroupExtension = computeService.getSecurityGroupExtension(); if (securityGroupExtension.isPresent()) { return new SecurityGroupEditor(nodeLocation, securityGroupExtension.get()); } else { throw new IllegalArgumentException("Expected SecurityGroupExtension not found in " + computeService); } }
public void testGracefulWhenNoIPs() { 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-none.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.getLocation(), location); assertEquals(node.getPrivateAddresses(), ImmutableSet.of()); assertEquals(node.getPublicAddresses(), ImmutableSet.of()); }
@Test(expectedExceptions = NoSuchElementException.class) public void testGracefulWhenVDCIsNotLocation() { Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/11111").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.getLocation(), location); } }
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()); }