public T fromServerWithSecurityGroups(ServerWithSecurityGroups in) { return super.fromServer(in) .securityGroupNames(in.getSecurityGroupNames()); } }
public T fromServerWithSecurityGroups(ServerWithSecurityGroups in) { return super.fromServer(in) .securityGroupNames(in.getSecurityGroupNames()); } }
public T fromServerWithSecurityGroups(ServerWithSecurityGroups in) { return super.fromServer(in) .securityGroupNames(in.getSecurityGroupNames()); } }
public T fromServerWithSecurityGroups(ServerWithSecurityGroups in) { return super.fromServer(in) .securityGroupNames(in.getSecurityGroupNames()); } }
public T fromServerWithSecurityGroups(ServerWithSecurityGroups in) { return super.fromServer(in) .securityGroupNames(in.getSecurityGroupNames()); } }
public T fromServerWithSecurityGroups(ServerWithSecurityGroups in) { return super.fromServer(in) .securityGroupNames(in.getSecurityGroupNames()); } }
@Override public Set<SecurityGroup> listSecurityGroupsForNode(String id) { ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(checkNotNull(id, "id")); String zone = zoneAndId.getZone(); String instanceId = zoneAndId.getId(); Optional<? extends ServerWithSecurityGroupsApi> serverApi = api.getServerWithSecurityGroupsExtensionForZone(zone); Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(zone); if (!serverApi.isPresent() || !sgApi.isPresent()) { return ImmutableSet.of(); } ServerWithSecurityGroups instance = serverApi.get().get(instanceId); if (instance == null) { return ImmutableSet.of(); } Set<String> groupNames = instance.getSecurityGroupNames(); Set<? extends SecurityGroupInZone> rawGroups = sgApi.get().list().filter(nameIn(groupNames)).transform(groupToGroupInZone(zone)).toSet(); return ImmutableSet.copyOf(transform(filter(rawGroups, notNull()), groupConverter)); }
@Override public Set<SecurityGroup> listSecurityGroupsForNode(String id) { RegionAndId regionAndId = RegionAndId.fromSlashEncoded(checkNotNull(id, "id")); String region = regionAndId.getRegion(); String instanceId = regionAndId.getId(); Optional<? extends ServerWithSecurityGroupsApi> serverApi = api.getServerWithSecurityGroupsApi(region); Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupApi(region); if (!serverApi.isPresent() || !sgApi.isPresent()) { return ImmutableSet.of(); } ServerWithSecurityGroups instance = serverApi.get().get(instanceId); if (instance == null) { return ImmutableSet.of(); } Set<String> groupNames = instance.getSecurityGroupNames(); Set<? extends SecurityGroupInRegion> rawGroups = sgApi.get().list().filter(nameIn(groupNames)).transform(groupToGroupInRegion(region)).toSet(); return ImmutableSet.copyOf(transform(filter(rawGroups, notNull()), groupConverter)); }
public void testGetServerWithSecurityGroups() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-create-server-ext/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"); ServerWithSecurityGroupsApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_with_security_groups.json")).build() ).getServerWithSecurityGroupsExtensionForZone("az-1.region-a.geo-1").get(); ServerWithSecurityGroups server = api.get("8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"); assertEquals(server.getId(), "8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"); assertEquals(server.getSecurityGroupNames(), ImmutableSet.of("default", "group1")); }
public void testGetServerWithSecurityGroups() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-create-server-ext/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"); ServerWithSecurityGroupsApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_with_security_groups.json")).build() ).getServerWithSecurityGroupsApi("az-1.region-a.geo-1").get(); ServerWithSecurityGroups server = api.get("8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"); assertEquals(server.getId(), "8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"); assertEquals(server.getSecurityGroupNames(), ImmutableSet.of("default", "group1")); } }
public void testGetServer() { if (apiOption.isPresent()) { for (Resource server : serverApi.list().concat()) { ServerWithSecurityGroups serverWithGroups = apiOption.get().get(server.getId()); assertEquals(serverWithGroups.getId(), server.getId()); assertEquals(serverWithGroups.getName(), server.getName()); assertNotNull(serverWithGroups.getSecurityGroupNames()); } // Create a new server to verify the groups work as expected Server testServer = null; try { testServer = createServerInZone(zone); ServerWithSecurityGroups results = apiOption.get().get(testServer.getId()); assertEquals(results.getId(), testServer.getId()); assertEquals(results.getSecurityGroupNames(), ImmutableSet.of("default")); } finally { if (testServer != null) { serverApi.delete(testServer.getId()); } } } }
public void testGetServer() { if (apiOption.isPresent()) { for (Resource server : serverApi.list().concat()) { ServerWithSecurityGroups serverWithGroups = apiOption.get().get(server.getId()); assertEquals(serverWithGroups.getId(), server.getId()); assertEquals(serverWithGroups.getName(), server.getName()); assertNotNull(serverWithGroups.getSecurityGroupNames()); } // Create a new server to verify the groups work as expected Server testServer = null; try { testServer = createServerInRegion(region); ServerWithSecurityGroups results = apiOption.get().get(testServer.getId()); assertEquals(results.getId(), testServer.getId()); assertEquals(results.getSecurityGroupNames(), ImmutableSet.of("default")); } finally { if (testServer != null) { serverApi.delete(testServer.getId()); } } } }
for (final String securityGroupName : ((ServerWithSecurityGroups)server).getSecurityGroupNames()) { for (SecurityGroup securityGroup : novaApi.getSecurityGroupApi(regionAndId.getRegion()).get().list().toList()) { if (securityGroup.getName().equalsIgnoreCase(securityGroupName)) {