mirror of https://github.com/apache/jclouds.git
cloudstack: added virtualmachine and asyncjob features
This commit is contained in:
parent
5dcf7e6df9
commit
4ce474e43c
|
@ -772,6 +772,12 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
ListenableFuture<? extends Set<String>> testUnwrapDepth2();
|
ListenableFuture<? extends Set<String>> testUnwrapDepth2();
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/")
|
||||||
|
@Unwrap(depth = 2)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
ListenableFuture<Long> testUnwrapDepth2Long();
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@Unwrap(depth = 3, edgeCollection = Set.class)
|
@Unwrap(depth = 3, edgeCollection = Set.class)
|
||||||
|
@ -960,11 +966,26 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
||||||
|
|
||||||
assertEquals(parser.apply(new HttpResponse(200, "ok",
|
assertEquals(parser.apply(new HttpResponse(200, "ok",
|
||||||
newStringPayload("{\"runit\":{\"runit\":[\"0.7.0\",\"0.7.1\"]}}"))), ImmutableSet.of("0.7.0", "0.7.1"));
|
newStringPayload("{\"runit\":{\"runit\":[\"0.7.0\",\"0.7.1\"]}}"))), ImmutableSet.of("0.7.0", "0.7.1"));
|
||||||
|
|
||||||
assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{\"runit\":{}}"))),
|
assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{\"runit\":{}}"))),
|
||||||
ImmutableSet.<String> of());
|
ImmutableSet.<String> of());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void testUnwrapDepth2Long() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = TestPut.class.getMethod("testUnwrapDepth2Long");
|
||||||
|
HttpRequest request = factory(TestPut.class).createRequest(method);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, UnwrapOnlyNestedJsonValue.class);
|
||||||
|
// now test that it works!
|
||||||
|
|
||||||
|
Function<HttpResponse, Map<String, String>> parser = (Function<HttpResponse, Map<String, String>>) RestAnnotationProcessor
|
||||||
|
.createResponseParser(parserFactory, injector, method, request);
|
||||||
|
|
||||||
|
assertEquals(parser.apply(new HttpResponse(200, "ok",
|
||||||
|
newStringPayload("{ \"destroyvirtualmachineresponse\" : {\"jobid\":4} }"))), new Long(4));
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void testUnwrapDepth3() throws SecurityException, NoSuchMethodException, IOException {
|
public void testUnwrapDepth3() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = TestPut.class.getMethod("testUnwrapDepth3");
|
Method method = TestPut.class.getMethod("testUnwrapDepth3");
|
||||||
|
|
|
@ -19,8 +19,10 @@
|
||||||
|
|
||||||
package org.jclouds.cloudstack;
|
package org.jclouds.cloudstack;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.features.AsyncJobAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.NetworkAsyncClient;
|
import org.jclouds.cloudstack.features.NetworkAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.OfferingAsyncClient;
|
import org.jclouds.cloudstack.features.OfferingAsyncClient;
|
||||||
|
import org.jclouds.cloudstack.features.SecurityGroupAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.TemplateAsyncClient;
|
import org.jclouds.cloudstack.features.TemplateAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.VirtualMachineAsyncClient;
|
import org.jclouds.cloudstack.features.VirtualMachineAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.ZoneAsyncClient;
|
import org.jclouds.cloudstack.features.ZoneAsyncClient;
|
||||||
|
@ -59,10 +61,22 @@ public interface CloudStackAsyncClient {
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
NetworkAsyncClient getNetworkClient();
|
NetworkAsyncClient getNetworkClient();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to VirtualMachine features.
|
* Provides asynchronous access to VirtualMachine features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
VirtualMachineAsyncClient getVirtualMachineClient();
|
VirtualMachineAsyncClient getVirtualMachineClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to SecurityGroup features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
SecurityGroupAsyncClient getSecurityGroupClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to AsyncJob features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
AsyncJobAsyncClient getAsyncJobClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,10 @@ package org.jclouds.cloudstack;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.features.AsyncJobClient;
|
||||||
import org.jclouds.cloudstack.features.NetworkClient;
|
import org.jclouds.cloudstack.features.NetworkClient;
|
||||||
import org.jclouds.cloudstack.features.OfferingClient;
|
import org.jclouds.cloudstack.features.OfferingClient;
|
||||||
|
import org.jclouds.cloudstack.features.SecurityGroupClient;
|
||||||
import org.jclouds.cloudstack.features.TemplateClient;
|
import org.jclouds.cloudstack.features.TemplateClient;
|
||||||
import org.jclouds.cloudstack.features.VirtualMachineClient;
|
import org.jclouds.cloudstack.features.VirtualMachineClient;
|
||||||
import org.jclouds.cloudstack.features.ZoneClient;
|
import org.jclouds.cloudstack.features.ZoneClient;
|
||||||
|
@ -68,4 +70,16 @@ public interface CloudStackClient {
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
VirtualMachineClient getVirtualMachineClient();
|
VirtualMachineClient getVirtualMachineClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to SecurityGroup features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
SecurityGroupClient getSecurityGroupClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to AsyncJob features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
AsyncJobClient getAsyncJobClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,14 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.CloudStackAsyncClient;
|
import org.jclouds.cloudstack.CloudStackAsyncClient;
|
||||||
import org.jclouds.cloudstack.CloudStackClient;
|
import org.jclouds.cloudstack.CloudStackClient;
|
||||||
|
import org.jclouds.cloudstack.features.AsyncJobAsyncClient;
|
||||||
|
import org.jclouds.cloudstack.features.AsyncJobClient;
|
||||||
import org.jclouds.cloudstack.features.NetworkAsyncClient;
|
import org.jclouds.cloudstack.features.NetworkAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.NetworkClient;
|
import org.jclouds.cloudstack.features.NetworkClient;
|
||||||
import org.jclouds.cloudstack.features.OfferingAsyncClient;
|
import org.jclouds.cloudstack.features.OfferingAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.OfferingClient;
|
import org.jclouds.cloudstack.features.OfferingClient;
|
||||||
|
import org.jclouds.cloudstack.features.SecurityGroupAsyncClient;
|
||||||
|
import org.jclouds.cloudstack.features.SecurityGroupClient;
|
||||||
import org.jclouds.cloudstack.features.TemplateAsyncClient;
|
import org.jclouds.cloudstack.features.TemplateAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.TemplateClient;
|
import org.jclouds.cloudstack.features.TemplateClient;
|
||||||
import org.jclouds.cloudstack.features.VirtualMachineAsyncClient;
|
import org.jclouds.cloudstack.features.VirtualMachineAsyncClient;
|
||||||
|
@ -56,12 +60,14 @@ import com.google.common.collect.ImmutableMap;
|
||||||
public class CloudStackRestClientModule extends RestClientModule<CloudStackClient, CloudStackAsyncClient> {
|
public class CloudStackRestClientModule extends RestClientModule<CloudStackClient, CloudStackAsyncClient> {
|
||||||
|
|
||||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
||||||
.put(ZoneClient.class, ZoneAsyncClient.class)//
|
.put(ZoneClient.class, ZoneAsyncClient.class)//
|
||||||
.put(TemplateClient.class, TemplateAsyncClient.class)//
|
.put(TemplateClient.class, TemplateAsyncClient.class)//
|
||||||
.put(OfferingClient.class, OfferingAsyncClient.class)//
|
.put(OfferingClient.class, OfferingAsyncClient.class)//
|
||||||
.put(NetworkClient.class, NetworkAsyncClient.class)//
|
.put(NetworkClient.class, NetworkAsyncClient.class)//
|
||||||
.put(VirtualMachineClient.class, VirtualMachineAsyncClient.class)//
|
.put(VirtualMachineClient.class, VirtualMachineAsyncClient.class)//
|
||||||
.build();
|
.put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)//
|
||||||
|
.put(AsyncJobClient.class, AsyncJobAsyncClient.class)//
|
||||||
|
.build();
|
||||||
|
|
||||||
public CloudStackRestClientModule() {
|
public CloudStackRestClientModule() {
|
||||||
super(CloudStackClient.class, CloudStackAsyncClient.class, DELEGATE_MAP);
|
super(CloudStackClient.class, CloudStackAsyncClient.class, DELEGATE_MAP);
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.domain;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class AsyncCreateResponse {
|
||||||
|
private long id;
|
||||||
|
@SerializedName("jobid")
|
||||||
|
private long jobId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* present only for serializer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
AsyncCreateResponse() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return id of the resource being created
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return id of the job in progress
|
||||||
|
*/
|
||||||
|
public long getJobId() {
|
||||||
|
return jobId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,245 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.domain;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class AsyncJob {
|
||||||
|
@SerializedName("accountid")
|
||||||
|
private long accountId = -1;
|
||||||
|
private String cmd;
|
||||||
|
private Date created;
|
||||||
|
@SerializedName("jobid")
|
||||||
|
private long id = -1;
|
||||||
|
@SerializedName("jobinstanceid")
|
||||||
|
private long instanceId = -1;
|
||||||
|
@SerializedName("jobinstancetype")
|
||||||
|
private String instanceType;
|
||||||
|
@SerializedName("jobinstancetype")
|
||||||
|
private String progress;
|
||||||
|
@SerializedName("jobresult")
|
||||||
|
private Map<String, Object> result = ImmutableMap.of();
|
||||||
|
@SerializedName("jobresultcode")
|
||||||
|
private int resultCode = -1;
|
||||||
|
@SerializedName("jobresulttype")
|
||||||
|
private String resultType;
|
||||||
|
@SerializedName("jobstatus")
|
||||||
|
private int status = -1;
|
||||||
|
@SerializedName("userid")
|
||||||
|
private int userId = -1;
|
||||||
|
|
||||||
|
public AsyncJob(int accountId, String cmd, Date created, long id, long instanceId, String instanceType,
|
||||||
|
String progress, Map<String, Object> result, int resultCode, String resultType, int status, int userId) {
|
||||||
|
this.accountId = accountId;
|
||||||
|
this.cmd = cmd;
|
||||||
|
this.created = created;
|
||||||
|
this.id = id;
|
||||||
|
this.instanceId = instanceId;
|
||||||
|
this.instanceType = instanceType;
|
||||||
|
this.progress = progress;
|
||||||
|
this.result = result;
|
||||||
|
this.resultCode = resultCode;
|
||||||
|
this.resultType = resultType;
|
||||||
|
this.status = status;
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* present only for serializer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
AsyncJob() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the account that executed the async command
|
||||||
|
*/
|
||||||
|
public long getAccountId() {
|
||||||
|
return accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the async command executed
|
||||||
|
*/
|
||||||
|
public String getCmd() {
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the created date of the job
|
||||||
|
*/
|
||||||
|
public Date getCreated() {
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return async job ID
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the unique ID of the instance/entity object related to the job
|
||||||
|
*/
|
||||||
|
public long getInstanceId() {
|
||||||
|
return instanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the instance/entity object related to the job
|
||||||
|
*/
|
||||||
|
public String getInstanceType() {
|
||||||
|
return instanceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the progress information of the PENDING job
|
||||||
|
*/
|
||||||
|
public String getProgress() {
|
||||||
|
return progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the result reason
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the result code for the job
|
||||||
|
*/
|
||||||
|
public int getResultCode() {
|
||||||
|
return resultCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the result type
|
||||||
|
*/
|
||||||
|
public String getResultType() {
|
||||||
|
return resultType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the current job status-should be 0 for PENDING
|
||||||
|
*/
|
||||||
|
public int getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the user that executed the async command
|
||||||
|
*/
|
||||||
|
public int getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + (int) (accountId ^ (accountId >>> 32));
|
||||||
|
result = prime * result + ((cmd == null) ? 0 : cmd.hashCode());
|
||||||
|
result = prime * result + ((created == null) ? 0 : created.hashCode());
|
||||||
|
result = prime * result + (int) (id ^ (id >>> 32));
|
||||||
|
result = prime * result + (int) (instanceId ^ (instanceId >>> 32));
|
||||||
|
result = prime * result + ((instanceType == null) ? 0 : instanceType.hashCode());
|
||||||
|
result = prime * result + ((progress == null) ? 0 : progress.hashCode());
|
||||||
|
result = prime * result + ((this.result == null) ? 0 : this.result.hashCode());
|
||||||
|
result = prime * result + resultCode;
|
||||||
|
result = prime * result + ((resultType == null) ? 0 : resultType.hashCode());
|
||||||
|
result = prime * result + status;
|
||||||
|
result = prime * result + userId;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
AsyncJob other = (AsyncJob) obj;
|
||||||
|
if (accountId != other.accountId)
|
||||||
|
return false;
|
||||||
|
if (cmd == null) {
|
||||||
|
if (other.cmd != null)
|
||||||
|
return false;
|
||||||
|
} else if (!cmd.equals(other.cmd))
|
||||||
|
return false;
|
||||||
|
if (created == null) {
|
||||||
|
if (other.created != null)
|
||||||
|
return false;
|
||||||
|
} else if (!created.equals(other.created))
|
||||||
|
return false;
|
||||||
|
if (id != other.id)
|
||||||
|
return false;
|
||||||
|
if (instanceId != other.instanceId)
|
||||||
|
return false;
|
||||||
|
if (instanceType == null) {
|
||||||
|
if (other.instanceType != null)
|
||||||
|
return false;
|
||||||
|
} else if (!instanceType.equals(other.instanceType))
|
||||||
|
return false;
|
||||||
|
if (progress == null) {
|
||||||
|
if (other.progress != null)
|
||||||
|
return false;
|
||||||
|
} else if (!progress.equals(other.progress))
|
||||||
|
return false;
|
||||||
|
if (result == null) {
|
||||||
|
if (other.result != null)
|
||||||
|
return false;
|
||||||
|
} else if (!result.equals(other.result))
|
||||||
|
return false;
|
||||||
|
if (resultCode != other.resultCode)
|
||||||
|
return false;
|
||||||
|
if (resultType == null) {
|
||||||
|
if (other.resultType != null)
|
||||||
|
return false;
|
||||||
|
} else if (!resultType.equals(other.resultType))
|
||||||
|
return false;
|
||||||
|
if (status != other.status)
|
||||||
|
return false;
|
||||||
|
if (userId != other.userId)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[accountId=" + accountId + ", cmd=" + cmd + ", created=" + created + ", id=" + id + ", instanceId="
|
||||||
|
+ instanceId + ", instanceType=" + instanceType + ", progress=" + progress + ", result=" + result
|
||||||
|
+ ", resultCode=" + resultCode + ", resultType=" + resultType + ", status=" + status + ", userId=" + userId
|
||||||
|
+ "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,192 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.domain;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class IngressRule {
|
||||||
|
private String account;
|
||||||
|
@SerializedName("cidr")
|
||||||
|
private String CIDR;
|
||||||
|
@SerializedName("endport")
|
||||||
|
private int endPort;
|
||||||
|
@SerializedName("icmpcode")
|
||||||
|
private int ICMPCode;
|
||||||
|
@SerializedName("icmptype")
|
||||||
|
private int ICMPType;
|
||||||
|
private String protocol;
|
||||||
|
@SerializedName("ruleid")
|
||||||
|
private long id;
|
||||||
|
@SerializedName("securitygroupname")
|
||||||
|
private String securityGroupName;
|
||||||
|
@SerializedName("startport")
|
||||||
|
private int startPort;
|
||||||
|
|
||||||
|
// for serialization
|
||||||
|
IngressRule() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public IngressRule(String account, String cIDR, int endPort, int iCMPCode, int iCMPType, String protocol, long id,
|
||||||
|
String securityGroupName, int startPort) {
|
||||||
|
this.account = account;
|
||||||
|
this.CIDR = cIDR;
|
||||||
|
this.endPort = endPort;
|
||||||
|
this.ICMPCode = iCMPCode;
|
||||||
|
this.ICMPType = iCMPType;
|
||||||
|
this.protocol = protocol;
|
||||||
|
this.id = id;
|
||||||
|
this.securityGroupName = securityGroupName;
|
||||||
|
this.startPort = startPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return account owning the ingress rule
|
||||||
|
*/
|
||||||
|
public String getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the CIDR notation for the base IP address of the ingress rule
|
||||||
|
*/
|
||||||
|
public String getCIDR() {
|
||||||
|
return CIDR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the ending IP of the ingress rule
|
||||||
|
*/
|
||||||
|
public int getEndPort() {
|
||||||
|
return endPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the code for the ICMP message response
|
||||||
|
*/
|
||||||
|
public int getICMPCode() {
|
||||||
|
return ICMPCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the type of the ICMP message response
|
||||||
|
*/
|
||||||
|
public int getICMPType() {
|
||||||
|
return ICMPType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the protocol of the ingress rule
|
||||||
|
*/
|
||||||
|
public String getProtocol() {
|
||||||
|
return protocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the id of the ingress rule
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return security group name
|
||||||
|
*/
|
||||||
|
public String getSecurityGroupName() {
|
||||||
|
return securityGroupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the starting IP of the ingress rule
|
||||||
|
*/
|
||||||
|
public int getStartPort() {
|
||||||
|
return startPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((CIDR == null) ? 0 : CIDR.hashCode());
|
||||||
|
result = prime * result + ICMPCode;
|
||||||
|
result = prime * result + ICMPType;
|
||||||
|
result = prime * result + ((account == null) ? 0 : account.hashCode());
|
||||||
|
result = prime * result + endPort;
|
||||||
|
result = prime * result + (int) (id ^ (id >>> 32));
|
||||||
|
result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
|
||||||
|
result = prime * result + ((securityGroupName == null) ? 0 : securityGroupName.hashCode());
|
||||||
|
result = prime * result + startPort;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
IngressRule other = (IngressRule) obj;
|
||||||
|
if (CIDR == null) {
|
||||||
|
if (other.CIDR != null)
|
||||||
|
return false;
|
||||||
|
} else if (!CIDR.equals(other.CIDR))
|
||||||
|
return false;
|
||||||
|
if (ICMPCode != other.ICMPCode)
|
||||||
|
return false;
|
||||||
|
if (ICMPType != other.ICMPType)
|
||||||
|
return false;
|
||||||
|
if (account == null) {
|
||||||
|
if (other.account != null)
|
||||||
|
return false;
|
||||||
|
} else if (!account.equals(other.account))
|
||||||
|
return false;
|
||||||
|
if (endPort != other.endPort)
|
||||||
|
return false;
|
||||||
|
if (id != other.id)
|
||||||
|
return false;
|
||||||
|
if (protocol == null) {
|
||||||
|
if (other.protocol != null)
|
||||||
|
return false;
|
||||||
|
} else if (!protocol.equals(other.protocol))
|
||||||
|
return false;
|
||||||
|
if (securityGroupName == null) {
|
||||||
|
if (other.securityGroupName != null)
|
||||||
|
return false;
|
||||||
|
} else if (!securityGroupName.equals(other.securityGroupName))
|
||||||
|
return false;
|
||||||
|
if (startPort != other.startPort)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + id + ", securityGroupName=" + securityGroupName + ", account=" + account + ", startPort="
|
||||||
|
+ startPort + ", endPort=" + endPort + ", protocol=" + protocol + ", CIDR=" + CIDR + ", ICMPCode="
|
||||||
|
+ ICMPCode + ", ICMPType=" + ICMPType + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,181 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class SecurityGroup {
|
||||||
|
private long id;
|
||||||
|
private String account;
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private String domain;
|
||||||
|
@SerializedName("domainid")
|
||||||
|
private long domainId;
|
||||||
|
@SerializedName("ingressrule")
|
||||||
|
private Set<IngressRule> ingressRules = ImmutableSet.of();
|
||||||
|
|
||||||
|
public SecurityGroup(long id, String account, String name, String description, String domain, long domainId,
|
||||||
|
Set<IngressRule> ingressRules) {
|
||||||
|
this.id = id;
|
||||||
|
this.account = account;
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
this.domain = domain;
|
||||||
|
this.domainId = domainId;
|
||||||
|
this.ingressRules = ImmutableSet.copyOf(checkNotNull(ingressRules, "ingressRules"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* present only for serializer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
SecurityGroup() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the id of the security group
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the name of the security group
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return an alternate display text of the security group.
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Domain name for the security group
|
||||||
|
*/
|
||||||
|
public String getDomain() {
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the domain id of the security group
|
||||||
|
*/
|
||||||
|
public long getDomainId() {
|
||||||
|
return domainId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the account owning the security group
|
||||||
|
*/
|
||||||
|
public String getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the list of ingress rules associated with the security group
|
||||||
|
*/
|
||||||
|
public Set<IngressRule> getIngressRules() {
|
||||||
|
return ingressRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((account == null) ? 0 : account.hashCode());
|
||||||
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
|
result = prime * result + ((domain == null) ? 0 : domain.hashCode());
|
||||||
|
result = prime * result + (int) (domainId ^ (domainId >>> 32));
|
||||||
|
result = prime * result + (int) (id ^ (id >>> 32));
|
||||||
|
result = prime * result + ((ingressRules == null) ? 0 : ingressRules.hashCode());
|
||||||
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
SecurityGroup other = (SecurityGroup) obj;
|
||||||
|
if (account == null) {
|
||||||
|
if (other.account != null)
|
||||||
|
return false;
|
||||||
|
} else if (!account.equals(other.account))
|
||||||
|
return false;
|
||||||
|
if (description == null) {
|
||||||
|
if (other.description != null)
|
||||||
|
return false;
|
||||||
|
} else if (!description.equals(other.description))
|
||||||
|
return false;
|
||||||
|
if (domain == null) {
|
||||||
|
if (other.domain != null)
|
||||||
|
return false;
|
||||||
|
} else if (!domain.equals(other.domain))
|
||||||
|
return false;
|
||||||
|
if (domainId != other.domainId)
|
||||||
|
return false;
|
||||||
|
if (id != other.id)
|
||||||
|
return false;
|
||||||
|
if (ingressRules == null) {
|
||||||
|
if (other.ingressRules != null)
|
||||||
|
return false;
|
||||||
|
} else if (!ingressRules.equals(other.ingressRules))
|
||||||
|
return false;
|
||||||
|
if (name == null) {
|
||||||
|
if (other.name != null)
|
||||||
|
return false;
|
||||||
|
} else if (!name.equals(other.name))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + id + ", account=" + account + ", name=" + name + ", description=" + description + ", domain="
|
||||||
|
+ domain + ", domainId=" + domainId + ", ingressRules=" + ingressRules + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,8 +27,6 @@ import java.util.Set;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.CaseFormat;
|
import com.google.common.base.CaseFormat;
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
@ -108,8 +106,6 @@ public class VirtualMachine {
|
||||||
private long rootDeviceId;
|
private long rootDeviceId;
|
||||||
@SerializedName("rootdevicetype")
|
@SerializedName("rootdevicetype")
|
||||||
private String rootDeviceType;
|
private String rootDeviceType;
|
||||||
@SerializedName("securitygrouplist")
|
|
||||||
private String securityGroupList;
|
|
||||||
@SerializedName("serviceofferingid")
|
@SerializedName("serviceofferingid")
|
||||||
private long serviceOfferingId;
|
private long serviceOfferingId;
|
||||||
@SerializedName("serviceofferingname")
|
@SerializedName("serviceofferingname")
|
||||||
|
@ -126,17 +122,19 @@ public class VirtualMachine {
|
||||||
@SerializedName("zonename")
|
@SerializedName("zonename")
|
||||||
private String zoneName;
|
private String zoneName;
|
||||||
@SerializedName("nic")
|
@SerializedName("nic")
|
||||||
private Set<? extends NIC> nics = ImmutableSet.<NIC> of();
|
private Set<NIC> nics = ImmutableSet.<NIC> of();
|
||||||
private String hypervisor;
|
private String hypervisor;
|
||||||
|
@SerializedName("securitygroup")
|
||||||
|
private Set<SecurityGroup> securityGroups = ImmutableSet.<SecurityGroup> of();
|
||||||
|
|
||||||
public VirtualMachine(long id, String account, long cpuCount, long cpuSpeed, long cpuUsed, String displayName,
|
public VirtualMachine(long id, String account, long cpuCount, long cpuSpeed, long cpuUsed, String displayName,
|
||||||
Date created, String domain, long domainId, boolean usesVirtualNetwork, String group, long groupId,
|
Date created, String domain, long domainId, boolean usesVirtualNetwork, String group, long groupId,
|
||||||
long guestOSId, boolean hAEnabled, long hostId, String hostname, String iPAddress, String iSODisplayText,
|
long guestOSId, boolean hAEnabled, long hostId, String hostname, String iPAddress, String iSODisplayText,
|
||||||
long iSOId, String iSOName, Long jobId, String jobStatus, long memory, String name, Long networkKbsRead,
|
long iSOId, String iSOName, Long jobId, String jobStatus, long memory, String name, Long networkKbsRead,
|
||||||
Long networkKbsWrite, String password, boolean passwordEnabled, long rootDeviceId, String rootDeviceType,
|
Long networkKbsWrite, String password, boolean passwordEnabled, long rootDeviceId, String rootDeviceType,
|
||||||
Set<String> securityGroupList, long serviceOfferingId, String serviceOfferingName, State state,
|
Set<SecurityGroup> securityGroups, long serviceOfferingId, String serviceOfferingName, State state,
|
||||||
String templateDisplayText, long templateId, String templateName, long zoneId, String zoneName,
|
String templateDisplayText, long templateId, String templateName, long zoneId, String zoneName,
|
||||||
Set<? extends NIC> nics, String hypervisor) {
|
Set<NIC> nics, String hypervisor) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.cpuCount = cpuCount;
|
this.cpuCount = cpuCount;
|
||||||
|
@ -167,7 +165,7 @@ public class VirtualMachine {
|
||||||
this.passwordEnabled = passwordEnabled;
|
this.passwordEnabled = passwordEnabled;
|
||||||
this.rootDeviceId = rootDeviceId;
|
this.rootDeviceId = rootDeviceId;
|
||||||
this.rootDeviceType = rootDeviceType;
|
this.rootDeviceType = rootDeviceType;
|
||||||
this.securityGroupList = Joiner.on(',').join(checkNotNull(securityGroupList, "securityGroupList"));
|
this.securityGroups =ImmutableSet.copyOf(checkNotNull(securityGroups, "securityGroups"));
|
||||||
this.serviceOfferingId = serviceOfferingId;
|
this.serviceOfferingId = serviceOfferingId;
|
||||||
this.serviceOfferingName = serviceOfferingName;
|
this.serviceOfferingName = serviceOfferingName;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
@ -405,9 +403,8 @@ public class VirtualMachine {
|
||||||
/**
|
/**
|
||||||
* @return list of security groups associated with the virtual machine
|
* @return list of security groups associated with the virtual machine
|
||||||
*/
|
*/
|
||||||
public Set<String> getSecurityGroupList() {
|
public Set<SecurityGroup> getSecurityGroups() {
|
||||||
return securityGroupList == null ? ImmutableSet.<String> of() : ImmutableSet.copyOf(Splitter.on(',').split(
|
return securityGroups;
|
||||||
securityGroupList));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -470,7 +467,7 @@ public class VirtualMachine {
|
||||||
/**
|
/**
|
||||||
* @return the list of nics associated with vm
|
* @return the list of nics associated with vm
|
||||||
*/
|
*/
|
||||||
public Set<? extends NIC> getNICs() {
|
public Set<NIC> getNICs() {
|
||||||
return nics;
|
return nics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,7 +513,7 @@ public class VirtualMachine {
|
||||||
result = prime * result + (passwordEnabled ? 1231 : 1237);
|
result = prime * result + (passwordEnabled ? 1231 : 1237);
|
||||||
result = prime * result + (int) (rootDeviceId ^ (rootDeviceId >>> 32));
|
result = prime * result + (int) (rootDeviceId ^ (rootDeviceId >>> 32));
|
||||||
result = prime * result + ((rootDeviceType == null) ? 0 : rootDeviceType.hashCode());
|
result = prime * result + ((rootDeviceType == null) ? 0 : rootDeviceType.hashCode());
|
||||||
result = prime * result + ((securityGroupList == null) ? 0 : securityGroupList.hashCode());
|
result = prime * result + ((securityGroups == null) ? 0 : securityGroups.hashCode());
|
||||||
result = prime * result + (int) (serviceOfferingId ^ (serviceOfferingId >>> 32));
|
result = prime * result + (int) (serviceOfferingId ^ (serviceOfferingId >>> 32));
|
||||||
result = prime * result + ((serviceOfferingName == null) ? 0 : serviceOfferingName.hashCode());
|
result = prime * result + ((serviceOfferingName == null) ? 0 : serviceOfferingName.hashCode());
|
||||||
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
||||||
|
@ -657,10 +654,10 @@ public class VirtualMachine {
|
||||||
return false;
|
return false;
|
||||||
} else if (!rootDeviceType.equals(other.rootDeviceType))
|
} else if (!rootDeviceType.equals(other.rootDeviceType))
|
||||||
return false;
|
return false;
|
||||||
if (securityGroupList == null) {
|
if (securityGroups == null) {
|
||||||
if (other.securityGroupList != null)
|
if (other.securityGroups != null)
|
||||||
return false;
|
return false;
|
||||||
} else if (!securityGroupList.equals(other.securityGroupList))
|
} else if (!securityGroups.equals(other.securityGroups))
|
||||||
return false;
|
return false;
|
||||||
if (serviceOfferingId != other.serviceOfferingId)
|
if (serviceOfferingId != other.serviceOfferingId)
|
||||||
return false;
|
return false;
|
||||||
|
@ -705,7 +702,7 @@ public class VirtualMachine {
|
||||||
+ ISOName + ", jobId=" + jobId + ", jobStatus=" + jobStatus + ", memory=" + memory + ", name=" + name
|
+ ISOName + ", jobId=" + jobId + ", jobStatus=" + jobStatus + ", memory=" + memory + ", name=" + name
|
||||||
+ ", networkKbsRead=" + networkKbsRead + ", networkKbsWrite=" + networkKbsWrite + ", password=" + password
|
+ ", networkKbsRead=" + networkKbsRead + ", networkKbsWrite=" + networkKbsWrite + ", password=" + password
|
||||||
+ ", passwordEnabled=" + passwordEnabled + ", rootDeviceId=" + rootDeviceId + ", rootDeviceType="
|
+ ", passwordEnabled=" + passwordEnabled + ", rootDeviceId=" + rootDeviceId + ", rootDeviceType="
|
||||||
+ rootDeviceType + ", securityGroupList=" + securityGroupList + ", serviceOfferingId=" + serviceOfferingId
|
+ rootDeviceType + ", securityGroups=" + securityGroups + ", serviceOfferingId=" + serviceOfferingId
|
||||||
+ ", serviceOfferingName=" + serviceOfferingName + ", state=" + state + ", templateDisplayText="
|
+ ", serviceOfferingName=" + serviceOfferingName + ", state=" + state + ", templateDisplayText="
|
||||||
+ templateDisplayText + ", templateId=" + templateId + ", templateName=" + templateName + ", zoneId="
|
+ templateDisplayText + ", templateId=" + templateId + ", templateName=" + templateName + ", zoneId="
|
||||||
+ zoneId + ", zoneName=" + zoneName + ", nics=" + nics + ", hypervisor=" + hypervisor + "]";
|
+ zoneId + ", zoneName=" + zoneName + ", nics=" + nics + ", hypervisor=" + hypervisor + "]";
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.features;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||||
|
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||||
|
import org.jclouds.cloudstack.options.ListAsyncJobsOptions;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.QueryParams;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.Unwrap;
|
||||||
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to cloudstack via their REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see AsyncJobClient
|
||||||
|
* @see <a href="http://download.cloud.com/releases/2.2/api/TOC_User.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@RequestFilters(QuerySigner.class)
|
||||||
|
@QueryParams(keys = "response", values = "json")
|
||||||
|
public interface AsyncJobAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AsyncJobClient#listAsyncJobs
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "listAsyncJobs")
|
||||||
|
@Unwrap(depth = 2)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Set<AsyncJob>> listAsyncJobs(ListAsyncJobsOptions... options);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.features;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||||
|
import org.jclouds.cloudstack.options.ListAsyncJobsOptions;
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to CloudStack asyncJob features.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see AsyncJobAsyncClient
|
||||||
|
* @see <a href="http://download.cloud.com/releases/2.2/api/TOC_User.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface AsyncJobClient {
|
||||||
|
/**
|
||||||
|
* Lists asyncJobs
|
||||||
|
*
|
||||||
|
* @param options
|
||||||
|
* if present, how to constrain the list.
|
||||||
|
* @return asyncJobs matching query, or empty set, if no asyncJobs are found
|
||||||
|
*/
|
||||||
|
Set<AsyncJob> listAsyncJobs(ListAsyncJobsOptions... options);
|
||||||
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.features;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.SecurityGroup;
|
||||||
|
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||||
|
import org.jclouds.cloudstack.options.ListSecurityGroupsOptions;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.QueryParams;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.Unwrap;
|
||||||
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to cloudstack via their REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see OfferingClient
|
||||||
|
* @see <a href="http://download.cloud.com/releases/2.2/api/TOC_User.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@RequestFilters(QuerySigner.class)
|
||||||
|
@QueryParams(keys = "response", values = "json")
|
||||||
|
public interface SecurityGroupAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SecurityGroupClient#listSecurityGroups
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "listSecurityGroups")
|
||||||
|
@Unwrap(depth = 2)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Set<SecurityGroup>> listSecurityGroups(ListSecurityGroupsOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SecurityGroupClient#getSecurityGroup
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "listSecurityGroups")
|
||||||
|
@Unwrap(depth = 3, edgeCollection = Set.class)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<SecurityGroup> getSecurityGroup(@QueryParam("id") long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SecurityGroupClient#createSecurityGroup
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "createSecurityGroup")
|
||||||
|
@Unwrap(depth = 3, edgeCollection = Set.class)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
ListenableFuture<SecurityGroup> createSecurityGroup(@QueryParam("name") String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SecurityGroupClient#deleteSecurityGroup
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "deleteSecurityGroup")
|
||||||
|
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Void> deleteSecurityGroup(@QueryParam("id") long id);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.features;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.SecurityGroup;
|
||||||
|
import org.jclouds.cloudstack.options.ListSecurityGroupsOptions;
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to CloudStack security group features.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see SecurityGroupAsyncClient
|
||||||
|
* @see <a href="http://download.cloud.com/releases/2.2/api/TOC_User.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface SecurityGroupClient {
|
||||||
|
/**
|
||||||
|
* Lists security groups
|
||||||
|
*
|
||||||
|
* @param options
|
||||||
|
* if present, how to constrain the list.
|
||||||
|
* @return security groups matching query, or empty set, if no security groups are found
|
||||||
|
*/
|
||||||
|
Set<SecurityGroup> listSecurityGroups(ListSecurityGroupsOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get a specific security group by id
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* group to get
|
||||||
|
* @return security group or null if not found
|
||||||
|
*/
|
||||||
|
SecurityGroup getSecurityGroup(long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a security group
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* name of the security group
|
||||||
|
* @return security group
|
||||||
|
*/
|
||||||
|
SecurityGroup createSecurityGroup(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete a specific security group by id
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* group to delete
|
||||||
|
*/
|
||||||
|
void deleteSecurityGroup(long id);
|
||||||
|
}
|
|
@ -26,8 +26,10 @@ import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||||
import org.jclouds.cloudstack.filters.QuerySigner;
|
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||||
|
import org.jclouds.cloudstack.options.DeployVirtualMachineOptions;
|
||||||
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.QueryParams;
|
import org.jclouds.rest.annotations.QueryParams;
|
||||||
|
@ -70,4 +72,25 @@ public interface VirtualMachineAsyncClient {
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<VirtualMachine> getVirtualMachine(@QueryParam("id") long id);
|
ListenableFuture<VirtualMachine> getVirtualMachine(@QueryParam("id") long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualMachineClient#deployVirtualMachine
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "deployVirtualMachine")
|
||||||
|
@Unwrap
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
ListenableFuture<AsyncCreateResponse> deployVirtualMachine(@QueryParam("serviceofferingid") long serviceOfferingId,
|
||||||
|
@QueryParam("templateid") long templateId, @QueryParam("zoneid") long zoneId,
|
||||||
|
DeployVirtualMachineOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualMachineClient#destroyVirtualMachine
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "destroyVirtualMachine")
|
||||||
|
@Unwrap(depth = 2)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Long> destroyVirtualMachine(@QueryParam("id") long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,9 @@ package org.jclouds.cloudstack.features;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||||
|
import org.jclouds.cloudstack.options.DeployVirtualMachineOptions;
|
||||||
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
|
@ -53,4 +55,28 @@ public interface VirtualMachineClient {
|
||||||
* @return VirtualMachine or null if not found
|
* @return VirtualMachine or null if not found
|
||||||
*/
|
*/
|
||||||
VirtualMachine getVirtualMachine(long id);
|
VirtualMachine getVirtualMachine(long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and automatically starts a virtual machine based on a service offering, disk offering,
|
||||||
|
* and template.
|
||||||
|
*
|
||||||
|
* @param serviceOfferingId
|
||||||
|
* the ID of the service offering for the virtual machine
|
||||||
|
* @param templateId
|
||||||
|
* the ID of the template for the virtual machine
|
||||||
|
* @param zoneId
|
||||||
|
* availability zone for the virtual machine
|
||||||
|
* @return virtual machine
|
||||||
|
*/
|
||||||
|
AsyncCreateResponse deployVirtualMachine(long serviceOfferingId, long templateId, long zoneId,
|
||||||
|
DeployVirtualMachineOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys a virtual machine. Once destroyed, only the administrator can recover it.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* vm to destroy
|
||||||
|
* @return job id related to destroying the VM, or null if resource was not found
|
||||||
|
*/
|
||||||
|
Long destroyVirtualMachine(long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,299 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.options;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.encryption.internal.Base64;
|
||||||
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options used to control what disk offerings are returned
|
||||||
|
*
|
||||||
|
* @see <a href="http://download.cloud.com/releases/2.2/api/user/deployVirtualMachine.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class DeployVirtualMachineOptions extends BaseHttpRequestOptions {
|
||||||
|
|
||||||
|
public static final DeployVirtualMachineOptions NONE = new DeployVirtualMachineOptions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param account
|
||||||
|
* an optional account for the virtual machine
|
||||||
|
* @param domain
|
||||||
|
* domain id
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions accountInDomain(String account, long domain) {
|
||||||
|
this.queryParameters.replaceValues("account", ImmutableSet.of(account + ""));
|
||||||
|
return domainId(domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the ID of the disk offering for the virtual machine. If the template is of ISO format, the
|
||||||
|
* diskOfferingId is for the root disk volume. Otherwise this parameter is used to dinidcate the
|
||||||
|
* offering for the data disk volume. If the templateId parameter passed is from a Template
|
||||||
|
* object, the diskOfferingId refers to a DATA Disk Volume created. If the templateId parameter
|
||||||
|
* passed is from an ISO object, the diskOfferingId refers to a ROOT Disk Volume created.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* the ID of the disk offering
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions diskOfferingId(long diskofferingid) {
|
||||||
|
checkArgument(!queryParameters.containsKey("size"), "Mutually exclusive with size");
|
||||||
|
this.queryParameters.replaceValues("diskofferingid", ImmutableSet.of(diskofferingid + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param displayName
|
||||||
|
* an optional user generated name for the virtual machine
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions displayName(String displayName) {
|
||||||
|
this.queryParameters.replaceValues("displayname", ImmutableSet.of(displayName));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param domainId
|
||||||
|
* an optional domainId for the virtual machine
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions domainId(long domainId) {
|
||||||
|
this.queryParameters.replaceValues("domainid", ImmutableSet.of(domainId + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param group
|
||||||
|
* an optional group for the virtual machine
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions group(String group) {
|
||||||
|
this.queryParameters.replaceValues("group", ImmutableSet.of(group));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param hypervisor
|
||||||
|
* the hypervisor on which to deploy the virtual machine
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions hypervisor(String hypervisor) {
|
||||||
|
this.queryParameters.replaceValues("hypervisor", ImmutableSet.of(hypervisor));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param keyPair
|
||||||
|
* name of the ssh key pair used to login to the virtual machine
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions keyPair(String keyPair) {
|
||||||
|
this.queryParameters.replaceValues("keypair", ImmutableSet.of(keyPair));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* host name for the virtual machine
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions name(String name) {
|
||||||
|
this.queryParameters.replaceValues("name", ImmutableSet.of(name));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param networkId
|
||||||
|
* network id used by virtual machine
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions networkId(long networkId) {
|
||||||
|
this.queryParameters.replaceValues("networkids", ImmutableSet.of(networkId + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param networkIds
|
||||||
|
* network ids used by virtual machine
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions networkIds(Iterable<Long> networkIds) {
|
||||||
|
this.queryParameters.replaceValues("networkids", ImmutableSet.of(Joiner.on(',').join(networkIds)));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param securityGroupId
|
||||||
|
* security group applied to the virtual machine. Should be passed only when vm is
|
||||||
|
* created from a zone with Basic Network support
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions securityGroupId(long securityGroupId) {
|
||||||
|
this.queryParameters.replaceValues("securitygroupids", ImmutableSet.of(securityGroupId + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param securityGroupIds
|
||||||
|
* security groups applied to the virtual machine. Should be passed only when vm is
|
||||||
|
* created from a zone with Basic Network support
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions securityGroupIds(Iterable<Long> securityGroupIds) {
|
||||||
|
this.queryParameters.replaceValues("securitygroupids", ImmutableSet.of(Joiner.on(',').join(securityGroupIds)));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dataDiskSize
|
||||||
|
* the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions dataDiskSize(long dataDiskSize) {
|
||||||
|
checkArgument(!queryParameters.containsKey("diskofferingid"), "Mutually exclusive with diskOfferingId");
|
||||||
|
this.queryParameters.replaceValues("size", ImmutableSet.of(dataDiskSize + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param unencodedData
|
||||||
|
* an optional binary data that can be sent to the virtual machine upon a successful
|
||||||
|
* deployment. This binary data must be base64 encoded before adding it to the request.
|
||||||
|
* Currently only HTTP GET is supported. Using HTTP GET (via querystring), you can send
|
||||||
|
* up to 2KB of data after base64 encoding.
|
||||||
|
*/
|
||||||
|
public DeployVirtualMachineOptions userData(byte[] unencodedData) {
|
||||||
|
int length = checkNotNull(unencodedData, "unencodedData").length;
|
||||||
|
checkArgument(length > 0, "userData cannot be empty");
|
||||||
|
checkArgument(length <= 2 * 1024, "userData cannot be larger than 2kb");
|
||||||
|
this.queryParameters.replaceValues("userdata", ImmutableSet.of(Base64.encodeBytes(unencodedData)));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#accountInDomain
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions accountInDomain(String account, long domain) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.accountInDomain(account, domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#diskOfferingId
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions diskOfferingId(long diskOfferingId) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.diskOfferingId(diskOfferingId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#displayName
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions displayName(String displayName) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.displayName(displayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#domainId
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions domainId(long id) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.domainId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#group
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions group(String group) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.group(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#hypervisor
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions hypervisor(String hypervisor) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.hypervisor(hypervisor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#keyPair
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions keyPair(String keyPair) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.keyPair(keyPair);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#name
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions name(String name) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.name(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#networkId
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions networkId(long id) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.networkId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#networkIds
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions networkIds(Iterable<Long> networkIds) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.networkIds(networkIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#securityGroupId
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions securityGroupId(long id) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.securityGroupId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#securityGroupIds
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions securityGroupIds(Iterable<Long> securityGroupIds) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.securityGroupIds(securityGroupIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#dataDiskSize
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions dataDiskSize(long id) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.dataDiskSize(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DeployVirtualMachineOptions#userData
|
||||||
|
*/
|
||||||
|
public static DeployVirtualMachineOptions userData(byte[] unencodedData) {
|
||||||
|
DeployVirtualMachineOptions options = new DeployVirtualMachineOptions();
|
||||||
|
return options.userData(unencodedData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,102 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.options;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options used to control what asyncJobs information is returned
|
||||||
|
*
|
||||||
|
* @see <a href="http://download.cloud.com/releases/2.2/api/user/listAsyncJobs.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class ListAsyncJobsOptions extends BaseHttpRequestOptions {
|
||||||
|
private final static DateService dateService = new SimpleDateFormatDateService();
|
||||||
|
|
||||||
|
public static final ListAsyncJobsOptions NONE = new ListAsyncJobsOptions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param account
|
||||||
|
* an optional account for the virtual machine
|
||||||
|
* @param domain
|
||||||
|
* domain id
|
||||||
|
*/
|
||||||
|
public ListAsyncJobsOptions accountInDomain(String account, long domain) {
|
||||||
|
this.queryParameters.replaceValues("account", ImmutableSet.of(account + ""));
|
||||||
|
return domainId(domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param domainId
|
||||||
|
* the ID of the domain associated with the asyncJob
|
||||||
|
*/
|
||||||
|
public ListAsyncJobsOptions domainId(long domainId) {
|
||||||
|
this.queryParameters.replaceValues("domainid", ImmutableSet.of(domainId + ""));
|
||||||
|
return this;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param startDate
|
||||||
|
* the start date of the async job
|
||||||
|
*/
|
||||||
|
public ListAsyncJobsOptions startDate(Date startDate) {
|
||||||
|
this.queryParameters.replaceValues("startdate",
|
||||||
|
ImmutableSet.of(dateService.iso8601SecondsDateFormat(checkNotNull(startDate, "startDate"))));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListAsyncJobsOptions#startDate
|
||||||
|
*/
|
||||||
|
public static ListAsyncJobsOptions startDate(Date startDate) {
|
||||||
|
ListAsyncJobsOptions options = new ListAsyncJobsOptions();
|
||||||
|
return options.startDate(startDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListAsyncJobsOptions#domainId
|
||||||
|
*/
|
||||||
|
public static ListAsyncJobsOptions domainId(long id) {
|
||||||
|
ListAsyncJobsOptions options = new ListAsyncJobsOptions();
|
||||||
|
return options.domainId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListAsyncJobsOptions#accountInDomain
|
||||||
|
*/
|
||||||
|
public static ListAsyncJobsOptions accountInDomain(String account, long domain) {
|
||||||
|
ListAsyncJobsOptions options = new ListAsyncJobsOptions();
|
||||||
|
return options.accountInDomain(account, domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,126 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.options;
|
||||||
|
|
||||||
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options used to control what security groups are returned
|
||||||
|
*
|
||||||
|
* @see <a href="http://download.cloud.com/releases/2.2/api/user/listSecurityGroups.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class ListSecurityGroupsOptions extends BaseHttpRequestOptions {
|
||||||
|
|
||||||
|
public static final ListSecurityGroupsOptions NONE = new ListSecurityGroupsOptions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id
|
||||||
|
* the ID of the security group
|
||||||
|
*/
|
||||||
|
public ListSecurityGroupsOptions id(long id) {
|
||||||
|
this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param domainId
|
||||||
|
* the ID of the domain associated with the security group
|
||||||
|
*/
|
||||||
|
public ListSecurityGroupsOptions domainId(long domainId) {
|
||||||
|
this.queryParameters.replaceValues("domainid", ImmutableSet.of(domainId + ""));
|
||||||
|
return this;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param account
|
||||||
|
* the security group account
|
||||||
|
*/
|
||||||
|
public ListSecurityGroupsOptions account(String account) {
|
||||||
|
this.queryParameters.replaceValues("account", ImmutableSet.of(account));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param securityGroupName
|
||||||
|
* lists security groups by name
|
||||||
|
*/
|
||||||
|
public ListSecurityGroupsOptions securityGroupName(String securityGroupName) {
|
||||||
|
this.queryParameters.replaceValues("securitygroupname", ImmutableSet.of(securityGroupName));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param virtualMachineId
|
||||||
|
* the ID of the virtual machine. Pass this in if you want to see the available service
|
||||||
|
* offering that a virtual machine can be changed to.
|
||||||
|
*/
|
||||||
|
public ListSecurityGroupsOptions virtualMachineId(long virtualMachineId) {
|
||||||
|
this.queryParameters.replaceValues("virtualmachineid", ImmutableSet.of(virtualMachineId + ""));
|
||||||
|
return this;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListSecurityGroupsOptions#account
|
||||||
|
*/
|
||||||
|
public static ListSecurityGroupsOptions account(String account) {
|
||||||
|
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions();
|
||||||
|
return options.account(account);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListSecurityGroupsOptions#securityGroupName
|
||||||
|
*/
|
||||||
|
public static ListSecurityGroupsOptions securityGroupName(String securityGroupName) {
|
||||||
|
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions();
|
||||||
|
return options.securityGroupName(securityGroupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListSecurityGroupsOptions#domainId
|
||||||
|
*/
|
||||||
|
public static ListSecurityGroupsOptions domainId(long id) {
|
||||||
|
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions();
|
||||||
|
return options.domainId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListSecurityGroupsOptions#id
|
||||||
|
*/
|
||||||
|
public static ListSecurityGroupsOptions id(long id) {
|
||||||
|
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions();
|
||||||
|
return options.id(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListSecurityGroupsOptions#virtualMachineId
|
||||||
|
*/
|
||||||
|
public static ListSecurityGroupsOptions virtualMachineId(long virtualMachineId) {
|
||||||
|
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions();
|
||||||
|
return options.virtualMachineId(virtualMachineId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -62,7 +62,7 @@ public class ListTemplatesOptions extends BaseHttpRequestOptions {
|
||||||
* @param domain
|
* @param domain
|
||||||
* domain id
|
* domain id
|
||||||
*/
|
*/
|
||||||
public ListTemplatesOptions accountInDomain(long account, long domain) {
|
public ListTemplatesOptions accountInDomain(String account, long domain) {
|
||||||
this.queryParameters.replaceValues("account", ImmutableSet.of(account + ""));
|
this.queryParameters.replaceValues("account", ImmutableSet.of(account + ""));
|
||||||
return domainId(domain);
|
return domainId(domain);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class ListTemplatesOptions extends BaseHttpRequestOptions {
|
||||||
/**
|
/**
|
||||||
* @see ListTemplatesOptions#accountInDomain
|
* @see ListTemplatesOptions#accountInDomain
|
||||||
*/
|
*/
|
||||||
public static ListTemplatesOptions accountInDomain(long account, long domain) {
|
public static ListTemplatesOptions accountInDomain(String account, long domain) {
|
||||||
ListTemplatesOptions options = new ListTemplatesOptions();
|
ListTemplatesOptions options = new ListTemplatesOptions();
|
||||||
return options.accountInDomain(account, domain);
|
return options.accountInDomain(account, domain);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,8 +77,8 @@ public class ListVirtualMachinesOptions extends BaseHttpRequestOptions {
|
||||||
* @param domain
|
* @param domain
|
||||||
* domain id
|
* domain id
|
||||||
*/
|
*/
|
||||||
public ListVirtualMachinesOptions accountInDomain(long account, long domain) {
|
public ListVirtualMachinesOptions accountInDomain(String account, long domain) {
|
||||||
this.queryParameters.replaceValues("account", ImmutableSet.of(account + ""));
|
this.queryParameters.replaceValues("account", ImmutableSet.of(account));
|
||||||
return domainId(domain);
|
return domainId(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ public class ListVirtualMachinesOptions extends BaseHttpRequestOptions {
|
||||||
/**
|
/**
|
||||||
* @see ListVirtualMachinesOptions#accountInDomain
|
* @see ListVirtualMachinesOptions#accountInDomain
|
||||||
*/
|
*/
|
||||||
public static ListVirtualMachinesOptions accountInDomain(long account, long domain) {
|
public static ListVirtualMachinesOptions accountInDomain(String account, long domain) {
|
||||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
||||||
return options.accountInDomain(account, domain);
|
return options.accountInDomain(account, domain);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.features;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.options.ListAsyncJobsOptions;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||||
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code AsyncJobAsyncClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
|
@Test(groups = "unit", testName = "AsyncJobAsyncClientTest")
|
||||||
|
public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest<AsyncJobAsyncClient> {
|
||||||
|
public void testListAsyncJobs() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = AsyncJobAsyncClient.class.getMethod("listAsyncJobs", ListAsyncJobsOptions[].class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=listAsyncJobs HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListAsyncJobsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = AsyncJobAsyncClient.class.getMethod("listAsyncJobs", ListAsyncJobsOptions[].class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method,
|
||||||
|
ListAsyncJobsOptions.Builder.accountInDomain("adrian", 5));
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=listAsyncJobs&account=adrian&domainid=5 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TypeLiteral<RestAnnotationProcessor<AsyncJobAsyncClient>> createTypeLiteral() {
|
||||||
|
return new TypeLiteral<RestAnnotationProcessor<AsyncJobAsyncClient>>() {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.features;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code AsyncJobClientLiveTest}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", sequential = true, testName = "AsyncJobClientLiveTest")
|
||||||
|
public class AsyncJobClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
|
public void testListAsyncJobs() throws Exception {
|
||||||
|
Set<AsyncJob> response = client.getAsyncJobClient().listAsyncJobs();
|
||||||
|
assert null != response;
|
||||||
|
long asyncJobCount = response.size();
|
||||||
|
assertTrue(asyncJobCount >= 0);
|
||||||
|
for (AsyncJob asyncJob : response) {
|
||||||
|
assert asyncJob.getId() > 0 : asyncJob;
|
||||||
|
assert asyncJob.getAccountId() >= 0 : asyncJob;
|
||||||
|
assert asyncJob.getCmd() != null : asyncJob;
|
||||||
|
assert asyncJob.getCreated() != null : asyncJob;
|
||||||
|
// seemingly unused fields
|
||||||
|
assert asyncJob.getInstanceId() == -1 : asyncJob;
|
||||||
|
assert asyncJob.getInstanceType() == null : asyncJob;
|
||||||
|
assert asyncJob.getResultType() == null : asyncJob;
|
||||||
|
// end
|
||||||
|
if (asyncJob.getProgress() != null) {
|
||||||
|
assert asyncJob.getResult() == null : asyncJob;
|
||||||
|
assert asyncJob.getResultCode() == -1 : asyncJob;
|
||||||
|
} else {
|
||||||
|
assert asyncJob.getResult() != null : asyncJob;
|
||||||
|
assert asyncJob.getResultCode() >= 0 : asyncJob;
|
||||||
|
}
|
||||||
|
assert asyncJob.getStatus() >= 0 : asyncJob;
|
||||||
|
assert asyncJob.getUserId() >= 0 : asyncJob;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -45,6 +45,7 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class BaseCloudStackClientLiveTest {
|
public class BaseCloudStackClientLiveTest {
|
||||||
|
protected String prefix = System.getProperty("user.name");
|
||||||
|
|
||||||
protected CloudStackClient client;
|
protected CloudStackClient client;
|
||||||
protected RestContext<CloudStackClient, CloudStackAsyncClient> context;
|
protected RestContext<CloudStackClient, CloudStackAsyncClient> context;
|
||||||
|
@ -57,11 +58,11 @@ public class BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
protected void setupCredentials() {
|
protected void setupCredentials() {
|
||||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider
|
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider
|
||||||
+ ".identity must be set. ex. apiKey");
|
+ ".identity must be set. ex. apiKey");
|
||||||
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
||||||
+ ".credential must be set. ex. secretKey");
|
+ ".credential must be set. ex. secretKey");
|
||||||
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider
|
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider
|
||||||
+ ".endpoint must be set. ex. http://localhost:8080/client/api");
|
+ ".endpoint must be set. ex. http://localhost:8080/client/api");
|
||||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
apiversion = System.getProperty("test." + provider + ".apiversion");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ public class BaseCloudStackClientLiveTest {
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
Properties overrides = setupProperties();
|
Properties overrides = setupProperties();
|
||||||
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
|
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
|
||||||
overrides);
|
overrides);
|
||||||
|
|
||||||
client = context.getApi();
|
client = context.getApi();
|
||||||
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS);
|
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS);
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.features;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.options.ListSecurityGroupsOptions;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
|
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||||
|
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
|
||||||
|
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||||
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code SecurityGroupAsyncClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
|
@Test(groups = "unit", testName = "SecurityGroupAsyncClientTest")
|
||||||
|
public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<SecurityGroupAsyncClient> {
|
||||||
|
|
||||||
|
public void testListSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = SecurityGroupAsyncClient.class.getMethod("listSecurityGroups", ListSecurityGroupsOptions[].class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=listSecurityGroups HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListSecurityGroupsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = SecurityGroupAsyncClient.class.getMethod("listSecurityGroups", ListSecurityGroupsOptions[].class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, ListSecurityGroupsOptions.Builder.virtualMachineId(4)
|
||||||
|
.domainId(5).id(6));
|
||||||
|
|
||||||
|
assertRequestLineEquals(
|
||||||
|
httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&virtualmachineid=4&domainid=5&id=6 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = SecurityGroupAsyncClient.class.getMethod("getSecurityGroup", long.class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&id=5 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = SecurityGroupAsyncClient.class.getMethod("createSecurityGroup", String.class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, "goo");
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=createSecurityGroup&name=goo HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroup", long.class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=deleteSecurityGroup&id=5 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TypeLiteral<RestAnnotationProcessor<SecurityGroupAsyncClient>> createTypeLiteral() {
|
||||||
|
return new TypeLiteral<RestAnnotationProcessor<SecurityGroupAsyncClient>>() {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.features;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.SecurityGroup;
|
||||||
|
import org.jclouds.cloudstack.options.ListSecurityGroupsOptions;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code SecurityGroupClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", sequential = true, testName = "SecurityGroupClientLiveTest")
|
||||||
|
public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
|
public void testCreateDestroySecurityGroup() throws Exception {
|
||||||
|
SecurityGroup group = null;
|
||||||
|
try {
|
||||||
|
group = client.getSecurityGroupClient().createSecurityGroup(prefix);
|
||||||
|
assertEquals(group.getName(), prefix);
|
||||||
|
checkGroup(group);
|
||||||
|
} finally {
|
||||||
|
if (group != null) {
|
||||||
|
client.getSecurityGroupClient().deleteSecurityGroup(group.getId());
|
||||||
|
assertEquals(client.getSecurityGroupClient().getSecurityGroup(group.getId()), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListSecurityGroups() throws Exception {
|
||||||
|
Set<SecurityGroup> response = client.getSecurityGroupClient().listSecurityGroups();
|
||||||
|
assert null != response;
|
||||||
|
long groupCount = response.size();
|
||||||
|
assertTrue(groupCount >= 0);
|
||||||
|
for (SecurityGroup group : response) {
|
||||||
|
SecurityGroup newDetails = Iterables.getOnlyElement(client.getSecurityGroupClient().listSecurityGroups(
|
||||||
|
ListSecurityGroupsOptions.Builder.id(group.getId())));
|
||||||
|
assertEquals(group, newDetails);
|
||||||
|
checkGroup(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void checkGroup(SecurityGroup group) {
|
||||||
|
assertEquals(group, client.getSecurityGroupClient().getSecurityGroup(group.getId()));
|
||||||
|
assert group.getId() > 0 : group;
|
||||||
|
assert group.getName() != null : group;
|
||||||
|
assert group.getAccount() != null : group;
|
||||||
|
assert group.getDescription() != null : group;
|
||||||
|
assert group.getDomain() != null : group;
|
||||||
|
assert group.getDomainId() >= 0 : group;
|
||||||
|
assert group.getIngressRules() != null : group;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -61,12 +61,15 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
||||||
|
|
||||||
public void testListTemplatesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testListTemplatesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = TemplateAsyncClient.class.getMethod("listTemplates", ListTemplatesOptions.class);
|
Method method = TemplateAsyncClient.class.getMethod("listTemplates", ListTemplatesOptions.class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, ListTemplatesOptions.Builder.accountInDomain(5, 6)
|
HttpRequest httpRequest = processor
|
||||||
.hypervisor("xen").filter(TemplateFilter.FEATURED));
|
.createRequest(
|
||||||
|
method,
|
||||||
|
ListTemplatesOptions.Builder.accountInDomain("adrian", 6).hypervisor("xen")
|
||||||
|
.filter(TemplateFilter.FEATURED));
|
||||||
|
|
||||||
assertRequestLineEquals(
|
assertRequestLineEquals(
|
||||||
httpRequest,
|
httpRequest,
|
||||||
"GET http://localhost:8080/client/api?response=json&command=listTemplates&account=5&domainid=6&hypervisor=xen&templatefilter=featured HTTP/1.1");
|
"GET http://localhost:8080/client/api?response=json&command=listTemplates&account=adrian&domainid=6&hypervisor=xen&templatefilter=featured HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,13 @@ package org.jclouds.cloudstack.features;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.options.DeployVirtualMachineOptions;
|
||||||
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
|
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
|
||||||
|
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
@ -63,11 +66,11 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
||||||
Method method = VirtualMachineAsyncClient.class.getMethod("listVirtualMachines",
|
Method method = VirtualMachineAsyncClient.class.getMethod("listVirtualMachines",
|
||||||
ListVirtualMachinesOptions[].class);
|
ListVirtualMachinesOptions[].class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method,
|
HttpRequest httpRequest = processor.createRequest(method,
|
||||||
ListVirtualMachinesOptions.Builder.accountInDomain(5, 6).usesVirtualNetwork(true));
|
ListVirtualMachinesOptions.Builder.accountInDomain("adrian", 6).usesVirtualNetwork(true));
|
||||||
|
|
||||||
assertRequestLineEquals(
|
assertRequestLineEquals(
|
||||||
httpRequest,
|
httpRequest,
|
||||||
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&account=5&domainid=6&forvirtualnetwork=true HTTP/1.1");
|
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&account=adrian&domainid=6&forvirtualnetwork=true HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
@ -96,6 +99,42 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDeployVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = VirtualMachineAsyncClient.class.getMethod("deployVirtualMachine", long.class, long.class,
|
||||||
|
long.class, DeployVirtualMachineOptions[].class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, 4, 5, 6);
|
||||||
|
|
||||||
|
assertRequestLineEquals(
|
||||||
|
httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=deployVirtualMachine&serviceofferingid=4&zoneid=6&templateid=5 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 testDestroyVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = VirtualMachineAsyncClient.class.getMethod("destroyVirtualMachine", long.class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=destroyVirtualMachine&id=5 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeLiteral<RestAnnotationProcessor<VirtualMachineAsyncClient>> createTypeLiteral() {
|
protected TypeLiteral<RestAnnotationProcessor<VirtualMachineAsyncClient>> createTypeLiteral() {
|
||||||
return new TypeLiteral<RestAnnotationProcessor<VirtualMachineAsyncClient>>() {
|
return new TypeLiteral<RestAnnotationProcessor<VirtualMachineAsyncClient>>() {
|
||||||
|
|
|
@ -24,8 +24,10 @@ import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||||
import org.jclouds.cloudstack.domain.NIC;
|
import org.jclouds.cloudstack.domain.NIC;
|
||||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||||
|
import org.jclouds.cloudstack.options.DeployVirtualMachineOptions;
|
||||||
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -38,6 +40,31 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", sequential = true, testName = "VirtualMachineClientLiveTest")
|
@Test(groups = "live", sequential = true, testName = "VirtualMachineClientLiveTest")
|
||||||
public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
|
public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
public void testCreateDestroyVirtualMachine() throws Exception {
|
||||||
|
VirtualMachine vm = null;
|
||||||
|
try {
|
||||||
|
long serviceOfferingId = Iterables.get(client.getOfferingClient().listServiceOfferings(), 0).getId();
|
||||||
|
long templateId = Iterables.get(client.getTemplateClient().listTemplates(), 0).getId();
|
||||||
|
long zoneId = Iterables.get(client.getZoneClient().listZones(), 0).getId();
|
||||||
|
long networkId = Iterables.get(client.getNetworkClient().listNetworks(), 0).getId();
|
||||||
|
System.out.printf("serviceOfferingId %d, templateId %d, zoneId %d, networkId %d%n", serviceOfferingId, templateId, zoneId, networkId);
|
||||||
|
AsyncCreateResponse job = client.getVirtualMachineClient().deployVirtualMachine(serviceOfferingId, templateId, zoneId, DeployVirtualMachineOptions.Builder.networkId(networkId));
|
||||||
|
System.out.println("job: " + job);
|
||||||
|
vm = client.getVirtualMachineClient().getVirtualMachine(job.getId());
|
||||||
|
System.out.println("vm: " + vm);
|
||||||
|
assertEquals(vm.getServiceOfferingId(), serviceOfferingId);
|
||||||
|
assertEquals(vm.getTemplateId(), templateId);
|
||||||
|
assertEquals(vm.getZoneId(), zoneId);
|
||||||
|
checkVm(vm);
|
||||||
|
} finally {
|
||||||
|
if (vm != null) {
|
||||||
|
Long job = client.getVirtualMachineClient().destroyVirtualMachine(vm.getId());
|
||||||
|
assert job != null;
|
||||||
|
assertEquals(client.getVirtualMachineClient().getVirtualMachine(vm.getId()), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void testListVirtualMachines() throws Exception {
|
public void testListVirtualMachines() throws Exception {
|
||||||
Set<VirtualMachine> response = client.getVirtualMachineClient().listVirtualMachines();
|
Set<VirtualMachine> response = client.getVirtualMachineClient().listVirtualMachines();
|
||||||
|
@ -48,41 +75,46 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
VirtualMachine newDetails = Iterables.getOnlyElement(client.getVirtualMachineClient().listVirtualMachines(
|
VirtualMachine newDetails = Iterables.getOnlyElement(client.getVirtualMachineClient().listVirtualMachines(
|
||||||
ListVirtualMachinesOptions.Builder.id(vm.getId())));
|
ListVirtualMachinesOptions.Builder.id(vm.getId())));
|
||||||
assertEquals(vm, newDetails);
|
assertEquals(vm, newDetails);
|
||||||
assertEquals(vm, client.getVirtualMachineClient().getVirtualMachine(vm.getId()));
|
checkVm(vm);
|
||||||
assert vm.getId() > 0 : vm;
|
|
||||||
assert vm.getName() != null : vm;
|
|
||||||
assert vm.getDisplayName() != null : vm;
|
|
||||||
assert vm.getAccount() != null : vm;
|
|
||||||
assert vm.getDomain() != null : vm;
|
|
||||||
assert vm.getDomainId() > 0 : vm;
|
|
||||||
assert vm.getCreated() != null : vm;
|
|
||||||
assert vm.getState() != null : vm;
|
|
||||||
assert vm.getZoneId() > 0 : vm;
|
|
||||||
assert vm.getZoneName() != null : vm;
|
|
||||||
assert vm.getTemplateId() > 0 : vm;
|
|
||||||
assert vm.getTemplateName() != null : vm;
|
|
||||||
assert vm.getTemplateDisplayText() != null : vm;
|
|
||||||
assert vm.getServiceOfferingId() > 0 : vm;
|
|
||||||
assert vm.getServiceOfferingName() != null : vm;
|
|
||||||
assert vm.getCpuCount() > 0 : vm;
|
|
||||||
assert vm.getCpuSpeed() > 0 : vm;
|
|
||||||
assert vm.getMemory() > 0 : vm;
|
|
||||||
assert vm.getGuestOSId() > 0 : vm;
|
|
||||||
assert vm.getRootDeviceId() >= 0 : vm;
|
|
||||||
assert vm.getRootDeviceType() != null : vm;
|
|
||||||
if (vm.getJobId() != null)
|
|
||||||
assert vm.getJobStatus() != null : vm;
|
|
||||||
assert vm.getNICs() != null && vm.getNICs().size() > 0 : vm;
|
|
||||||
for (NIC nic : vm.getNICs()) {
|
|
||||||
assert nic.getId() > 0 : vm;
|
|
||||||
assert nic.getNetworkId() > 0 : vm;
|
|
||||||
assert nic.getNetmask() != null : vm;
|
|
||||||
assert nic.getGateway() != null : vm;
|
|
||||||
assert nic.getIPAddress() != null : vm;
|
|
||||||
assert nic.getTrafficType() != null : vm;
|
|
||||||
assert nic.getGuestIPType() != null : vm;
|
|
||||||
}
|
|
||||||
assert vm.getHypervisor() != null : vm;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void checkVm(VirtualMachine vm) {
|
||||||
|
assertEquals(vm, client.getVirtualMachineClient().getVirtualMachine(vm.getId()));
|
||||||
|
assert vm.getId() > 0 : vm;
|
||||||
|
assert vm.getName() != null : vm;
|
||||||
|
assert vm.getDisplayName() != null : vm;
|
||||||
|
assert vm.getAccount() != null : vm;
|
||||||
|
assert vm.getDomain() != null : vm;
|
||||||
|
assert vm.getDomainId() > 0 : vm;
|
||||||
|
assert vm.getCreated() != null : vm;
|
||||||
|
assert vm.getState() != null : vm;
|
||||||
|
assert vm.getZoneId() > 0 : vm;
|
||||||
|
assert vm.getZoneName() != null : vm;
|
||||||
|
assert vm.getTemplateId() > 0 : vm;
|
||||||
|
assert vm.getTemplateName() != null : vm;
|
||||||
|
assert vm.getTemplateDisplayText() != null : vm;
|
||||||
|
assert vm.getServiceOfferingId() > 0 : vm;
|
||||||
|
assert vm.getServiceOfferingName() != null : vm;
|
||||||
|
assert vm.getCpuCount() > 0 : vm;
|
||||||
|
assert vm.getCpuSpeed() > 0 : vm;
|
||||||
|
assert vm.getMemory() > 0 : vm;
|
||||||
|
assert vm.getGuestOSId() > 0 : vm;
|
||||||
|
assert vm.getRootDeviceId() >= 0 : vm;
|
||||||
|
assert vm.getRootDeviceType() != null : vm;
|
||||||
|
if (vm.getJobId() != null)
|
||||||
|
assert vm.getJobStatus() != null : vm;
|
||||||
|
assert vm.getNICs() != null && vm.getNICs().size() > 0 : vm;
|
||||||
|
for (NIC nic : vm.getNICs()) {
|
||||||
|
assert nic.getId() > 0 : vm;
|
||||||
|
assert nic.getNetworkId() > 0 : vm;
|
||||||
|
assert nic.getNetmask() != null : vm;
|
||||||
|
assert nic.getGateway() != null : vm;
|
||||||
|
assert nic.getIPAddress() != null : vm;
|
||||||
|
assert nic.getTrafficType() != null : vm;
|
||||||
|
assert nic.getGuestIPType() != null : vm;
|
||||||
|
}
|
||||||
|
assert vm.getSecurityGroups() != null && vm.getSecurityGroups().size() >= 0 : vm;
|
||||||
|
assert vm.getHypervisor() != null : vm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.options;
|
||||||
|
|
||||||
|
import static org.jclouds.cloudstack.options.ListAsyncJobsOptions.Builder.accountInDomain;
|
||||||
|
import static org.jclouds.cloudstack.options.ListAsyncJobsOptions.Builder.domainId;
|
||||||
|
import static org.jclouds.cloudstack.options.ListAsyncJobsOptions.Builder.startDate;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code ListAsyncJobsOptions}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class ListAsyncJobsOptionsTest {
|
||||||
|
public void testAccountInDomainId() {
|
||||||
|
ListAsyncJobsOptions options = new ListAsyncJobsOptions().accountInDomain("adrian", 6);
|
||||||
|
assertEquals(ImmutableList.of("adrian"), options.buildQueryParameters().get("account"));
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAccountInDomainIdStatic() {
|
||||||
|
ListAsyncJobsOptions options = accountInDomain("adrian", 6);
|
||||||
|
assertEquals(ImmutableList.of("adrian"), options.buildQueryParameters().get("account"));
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testStartDate() {
|
||||||
|
ListAsyncJobsOptions options = new ListAsyncJobsOptions().startDate(new Date(100000));
|
||||||
|
assertEquals(ImmutableList.of("1970-01-01T00:01:40Z"), options.buildQueryParameters().get("startdate"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDomainId() {
|
||||||
|
ListAsyncJobsOptions options = new ListAsyncJobsOptions().domainId(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testStartDateStatic() {
|
||||||
|
ListAsyncJobsOptions options = startDate(new Date(100000));
|
||||||
|
assertEquals(ImmutableList.of("1970-01-01T00:01:40Z"), options.buildQueryParameters().get("startdate"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDomainIdStatic() {
|
||||||
|
ListAsyncJobsOptions options = domainId(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.options;
|
||||||
|
|
||||||
|
import static org.jclouds.cloudstack.options.ListSecurityGroupsOptions.Builder.account;
|
||||||
|
import static org.jclouds.cloudstack.options.ListSecurityGroupsOptions.Builder.domainId;
|
||||||
|
import static org.jclouds.cloudstack.options.ListSecurityGroupsOptions.Builder.id;
|
||||||
|
import static org.jclouds.cloudstack.options.ListSecurityGroupsOptions.Builder.securityGroupName;
|
||||||
|
import static org.jclouds.cloudstack.options.ListSecurityGroupsOptions.Builder.virtualMachineId;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code ListSecurityGroupsOptions}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class ListSecurityGroupsOptionsTest {
|
||||||
|
|
||||||
|
public void testId() {
|
||||||
|
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions().id(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIdStatic() {
|
||||||
|
ListSecurityGroupsOptions options = id(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAccount() {
|
||||||
|
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions().account("account");
|
||||||
|
assertEquals(ImmutableList.of("account"), options.buildQueryParameters().get("account"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAccountStatic() {
|
||||||
|
ListSecurityGroupsOptions options = account("account");
|
||||||
|
assertEquals(ImmutableList.of("account"), options.buildQueryParameters().get("account"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testName() {
|
||||||
|
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions().securityGroupName("securityGroupName");
|
||||||
|
assertEquals(ImmutableList.of("securityGroupName"), options.buildQueryParameters().get("securitygroupname"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNameStatic() {
|
||||||
|
ListSecurityGroupsOptions options = securityGroupName("securityGroupName");
|
||||||
|
assertEquals(ImmutableList.of("securityGroupName"), options.buildQueryParameters().get("securitygroupname"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDomainId() {
|
||||||
|
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions().domainId(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDomainIdStatic() {
|
||||||
|
ListSecurityGroupsOptions options = domainId(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVirtualMachineId() {
|
||||||
|
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions().virtualMachineId(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("virtualmachineid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVirtualMachineIdStatic() {
|
||||||
|
ListSecurityGroupsOptions options = virtualMachineId(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("virtualmachineid"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,14 +61,14 @@ public class ListTemplatesOptionsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAccountInDomainId() {
|
public void testAccountInDomainId() {
|
||||||
ListTemplatesOptions options = new ListTemplatesOptions().accountInDomain(5, 6);
|
ListTemplatesOptions options = new ListTemplatesOptions().accountInDomain("adrian", 6);
|
||||||
assertEquals(ImmutableList.of("5"), options.buildQueryParameters().get("account"));
|
assertEquals(ImmutableList.of("adrian"), options.buildQueryParameters().get("account"));
|
||||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAccountInDomainIdStatic() {
|
public void testAccountInDomainIdStatic() {
|
||||||
ListTemplatesOptions options = accountInDomain(5, 6);
|
ListTemplatesOptions options = accountInDomain("adrian", 6);
|
||||||
assertEquals(ImmutableList.of("5"), options.buildQueryParameters().get("account"));
|
assertEquals(ImmutableList.of("adrian"), options.buildQueryParameters().get("account"));
|
||||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,14 +84,14 @@ public class ListVirtualMachesOptionsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAccountInDomainId() {
|
public void testAccountInDomainId() {
|
||||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().accountInDomain(5, 6);
|
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().accountInDomain("adrian", 6);
|
||||||
assertEquals(ImmutableList.of("5"), options.buildQueryParameters().get("account"));
|
assertEquals(ImmutableList.of("adrian"), options.buildQueryParameters().get("account"));
|
||||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAccountInDomainIdStatic() {
|
public void testAccountInDomainIdStatic() {
|
||||||
ListVirtualMachinesOptions options = accountInDomain(5, 6);
|
ListVirtualMachinesOptions options = accountInDomain("adrian", 6);
|
||||||
assertEquals(ImmutableList.of("5"), options.buildQueryParameters().get("account"));
|
assertEquals(ImmutableList.of("adrian"), options.buildQueryParameters().get("account"));
|
||||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue