mirror of https://github.com/apache/jclouds.git
fix issue #1254 cloudstack renamed deployvirtualmachineresponse in version 4.1
This commit is contained in:
parent
6edaae8dce
commit
c58440f601
|
@ -80,7 +80,7 @@ public interface VirtualMachineAsyncClient {
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@QueryParams(keys = "command", values = "deployVirtualMachine")
|
@QueryParams(keys = "command", values = "deployVirtualMachine")
|
||||||
@Unwrap
|
@SelectJson({ "deployvirtualmachine", "deployvirtualmachineresponse" })
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
ListenableFuture<AsyncCreateResponse> deployVirtualMachineInZone(@QueryParam("zoneid") String zoneId,
|
ListenableFuture<AsyncCreateResponse> deployVirtualMachineInZone(@QueryParam("zoneid") String zoneId,
|
||||||
@QueryParam("serviceofferingid") String serviceOfferingId, @QueryParam("templateid") String templateId,
|
@QueryParam("serviceofferingid") String serviceOfferingId, @QueryParam("templateid") String templateId,
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.cloudstack.options.AssignVirtualMachineOptions;
|
import org.jclouds.cloudstack.options.AssignVirtualMachineOptions;
|
||||||
import org.jclouds.cloudstack.options.DeployVirtualMachineOptions;
|
|
||||||
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
@ -103,25 +102,6 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeployVirtualMachineInZone() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = VirtualMachineAsyncClient.class.getMethod("deployVirtualMachineInZone", String.class, String.class,
|
|
||||||
String.class, DeployVirtualMachineOptions[].class);
|
|
||||||
HttpRequest httpRequest = processor.createRequest(method, 6, 4, 5);
|
|
||||||
|
|
||||||
assertRequestLineEquals(
|
|
||||||
httpRequest,
|
|
||||||
"GET http://localhost:8080/client/api?response=json&command=deployVirtualMachine&zoneid=6&templateid=5&serviceofferingid=4 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
|
||||||
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testRebootVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
public void testRebootVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VirtualMachineAsyncClient.class.getMethod("rebootVirtualMachine", String.class);
|
Method method = VirtualMachineAsyncClient.class.getMethod("rebootVirtualMachine", String.class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.CloudStackContext;
|
import org.jclouds.cloudstack.CloudStackContext;
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||||
import org.jclouds.cloudstack.domain.EncryptedPasswordAndPrivateKey;
|
import org.jclouds.cloudstack.domain.EncryptedPasswordAndPrivateKey;
|
||||||
import org.jclouds.cloudstack.functions.WindowsLoginCredentialsFromEncryptedData;
|
import org.jclouds.cloudstack.functions.WindowsLoginCredentialsFromEncryptedData;
|
||||||
import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest;
|
import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest;
|
||||||
|
@ -59,11 +60,8 @@ public class VirtualMachineClientExpectTest extends BaseCloudStackExpectTest<Vir
|
||||||
"-----END RSA PRIVATE KEY-----";
|
"-----END RSA PRIVATE KEY-----";
|
||||||
|
|
||||||
VirtualMachineClient client = requestSendsResponse(
|
VirtualMachineClient client = requestSendsResponse(
|
||||||
HttpRequest.builder()
|
HttpRequest.builder().method("GET")
|
||||||
.method("GET")
|
.endpoint("http://localhost:8080/client/api?response=json&command=getVMPassword&id=1&apiKey=identity&signature=SVA2r1KRj4yG03rATMLPZWS%2BKnw%3D")
|
||||||
.endpoint(
|
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
|
||||||
"command=getVMPassword&id=1&apiKey=identity&signature=SVA2r1KRj4yG03rATMLPZWS%2BKnw%3D"))
|
|
||||||
.addHeader("Accept", "application/json")
|
.addHeader("Accept", "application/json")
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
|
@ -84,6 +82,41 @@ public class VirtualMachineClientExpectTest extends BaseCloudStackExpectTest<Vir
|
||||||
EncryptedPasswordAndPrivateKey.builder().encryptedPassword(actual).privateKey(privateKey).build()).getPassword(), "bX7vvptvw");
|
EncryptedPasswordAndPrivateKey.builder().encryptedPassword(actual).privateKey(privateKey).build()).getPassword(), "bX7vvptvw");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HttpRequest deployVirtualMachineInZone = HttpRequest.builder().method("GET")
|
||||||
|
.endpoint("http://localhost:8080/client/api")
|
||||||
|
.addQueryParam("response", "json")
|
||||||
|
.addQueryParam("command", "deployVirtualMachine")
|
||||||
|
.addQueryParam("zoneid", "zone1")
|
||||||
|
.addQueryParam("templateid", "template1")
|
||||||
|
.addQueryParam("serviceofferingid", "serviceOffering1")
|
||||||
|
.addQueryParam("apiKey", "identity")
|
||||||
|
.addQueryParam("signature", "pBjjnTq7/ezN94Uj0gpy2T//cJQ%3D")
|
||||||
|
.addHeader("Accept", "application/json")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
public void testDeployVirtualMachineIs2xxVersion3x() {
|
||||||
|
HttpResponse deployVirtualMachineInZoneResponse = HttpResponse.builder().statusCode(200)
|
||||||
|
.payload(payloadFromResource("/deployvirtualmachineresponse.json")).build();
|
||||||
|
VirtualMachineClient client = requestSendsResponse(deployVirtualMachineInZone, deployVirtualMachineInZoneResponse);
|
||||||
|
|
||||||
|
AsyncCreateResponse async = client.deployVirtualMachineInZone("zone1", "serviceOffering1", "template1");
|
||||||
|
|
||||||
|
assertEquals(async, AsyncCreateResponse.builder().id("1234").jobId("50006").build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDeployVirtualMachineIs2xxVersion4x() {
|
||||||
|
HttpResponse deployVirtualMachineInZoneResponse = HttpResponse.builder().statusCode(200)
|
||||||
|
.payload(payloadFromResource("/deployvirtualmachineresponse4x.json")).build();
|
||||||
|
VirtualMachineClient client = requestSendsResponse(deployVirtualMachineInZone, deployVirtualMachineInZoneResponse);
|
||||||
|
|
||||||
|
AsyncCreateResponse async = client.deployVirtualMachineInZone("zone1", "serviceOffering1", "template1");
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
async,
|
||||||
|
AsyncCreateResponse.builder().id("1cce6cb7-2268-47ff-9696-d9e610f6619a")
|
||||||
|
.jobId("13330fc9-8b3e-4582-aa3e-90883c041ff0").build());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected VirtualMachineClient clientFrom(CloudStackContext context) {
|
protected VirtualMachineClient clientFrom(CloudStackContext context) {
|
||||||
return context.getProviderSpecificContext().getApi().getVirtualMachineClient();
|
return context.getProviderSpecificContext().getApi().getVirtualMachineClient();
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.cloudstack.parse;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||||
|
import org.jclouds.json.BaseItemParserTest;
|
||||||
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "DeployVirtualMachineResponse3xTest")
|
||||||
|
public class DeployVirtualMachineResponse3xTest extends BaseItemParserTest<AsyncCreateResponse> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String resource() {
|
||||||
|
return "/deployvirtualmachineresponse.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SelectJson({ "deployvirtualmachine", "deployvirtualmachineresponse" })
|
||||||
|
public AsyncCreateResponse expected() {
|
||||||
|
return AsyncCreateResponse.builder().id("1234").jobId("50006").build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.cloudstack.parse;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||||
|
import org.jclouds.json.BaseItemParserTest;
|
||||||
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "DeployVirtualMachineResponse3xTest")
|
||||||
|
public class DeployVirtualMachineResponse4xTest extends BaseItemParserTest<AsyncCreateResponse> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String resource() {
|
||||||
|
return "/deployvirtualmachineresponse4x.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SelectJson({ "deployvirtualmachine", "deployvirtualmachineresponse" })
|
||||||
|
public AsyncCreateResponse expected() {
|
||||||
|
return AsyncCreateResponse.builder().id("1cce6cb7-2268-47ff-9696-d9e610f6619a")
|
||||||
|
.jobId("13330fc9-8b3e-4582-aa3e-90883c041ff0").build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
{ "deployvirtualmachineresponse" : {"id":"1cce6cb7-2268-47ff-9696-d9e610f6619a","jobid":"13330fc9-8b3e-4582-aa3e-90883c041ff0"}, "cloudstack-version": "4.1.0-SNAPSHOT" }
|
Loading…
Reference in New Issue