Adds support for networks in the NovaComputeServiceAdapter Related to https://issues.apache.org/jira/browse/JCLOUDS-416

This commit is contained in:
Zack Shoylev 2014-01-09 14:14:56 -06:00
parent 50f1a0c5c0
commit 859ca920c6
3 changed files with 78 additions and 0 deletions

View File

@ -109,6 +109,7 @@ public class NovaComputeServiceAdapter implements
options.securityGroupNames(templateOptions.getSecurityGroupNames().get());
options.userData(templateOptions.getUserData());
options.diskConfig(templateOptions.getDiskConfig());
options.networks(templateOptions.getNetworks());
Optional<String> privateKey = Optional.absent();
if (templateOptions.getKeyPairName() != null) {

View File

@ -61,6 +61,41 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
HttpResponse serverDetailResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResource("/server_details.json")).build();
public void testCreateNodeWithGroupEncodedIntoNameWithNetworks() throws Exception {
HttpRequest createServer = HttpRequest
.builder()
.method("POST")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers")
.addHeader("Accept", "application/json")
.addHeader("X-Auth-Token", authToken)
.payload(payloadFromStringWithContentType(
"{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"networks\": [{\"uuid\": \"4ebd35cf-bfe7-4d93-b0d8-eb468ce2245a\"}]}}","application/json"))
.build();
HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
.payload(payloadFromResourceWithContentType("/new_server_networks_response.json","application/json; charset=UTF-8")).build();
Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
.put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess)
.put(extensionsOfNovaRequest, extensionsOfNovaResponse)
.put(listDetail, listDetailResponse)
.put(listFlavorsDetail, listFlavorsDetailResponse)
.put(createServer, createServerResponse)
.put(serverDetail, serverDetailResponse).build();
Injector forNetworks = requestsSendResponses(requestResponseMap);
Template template = forNetworks.getInstance(TemplateBuilder.class).build();
template.getOptions().as(NovaTemplateOptions.class).networks("4ebd35cf-bfe7-4d93-b0d8-eb468ce2245a");
NovaComputeServiceAdapter adapter = forNetworks.getInstance(NovaComputeServiceAdapter.class);
NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template);
assertNotNull(server);
// Response irrelevant in this expect test - just verifying the request.
}
public void testCreateNodeWithGroupEncodedIntoNameWithDiskConfig() throws Exception {
HttpRequest createServer = HttpRequest

View File

@ -0,0 +1,42 @@
{
"server": {
"status": "BUILD(scheduling)",
"updated": "2012-03-19T06:21:13Z",
"hostId": "",
"user_id": "54297837463082",
"name": "test-e92",
"links": [{
"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752",
"rel": "self"
}, {
"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752",
"rel": "bookmark"
}],
"addresses": {},
"tenant_id": "37936628937291",
"image": {
"id": "1241",
"links": [{
"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241",
"rel": "bookmark"
}]
},
"created": "2012-03-19T06:21:13Z",
"uuid": "47491020-6a78-4f63-9475-23195ac4515c",
"accessIPv4": "",
"accessIPv6": "",
"key_name": null,
"adminPass": "ZWuHcmTMQ7eXoHeM",
"flavor": {
"id": "100",
"links": [{
"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100",
"rel": "bookmark"
}]
},
"config_drive": "",
"id": 71752,
"metadata": {},
"OS-DCF:diskConfig": "AUTO"
}
}