mirror of https://github.com/apache/jclouds.git
updated cloudstack to include virtualmachine commands
This commit is contained in:
parent
096b25509d
commit
5df7f7d148
|
@ -22,6 +22,7 @@ package org.jclouds.cloudstack;
|
|||
import org.jclouds.cloudstack.features.NetworkAsyncClient;
|
||||
import org.jclouds.cloudstack.features.OfferingAsyncClient;
|
||||
import org.jclouds.cloudstack.features.TemplateAsyncClient;
|
||||
import org.jclouds.cloudstack.features.VirtualMachineAsyncClient;
|
||||
import org.jclouds.cloudstack.features.ZoneAsyncClient;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
|
||||
|
@ -58,4 +59,10 @@ public interface CloudStackAsyncClient {
|
|||
*/
|
||||
@Delegate
|
||||
NetworkAsyncClient getNetworkClient();
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to VirtualMachine features.
|
||||
*/
|
||||
@Delegate
|
||||
VirtualMachineAsyncClient getVirtualMachineClient();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.jclouds.cloudstack.features.NetworkClient;
|
||||
import org.jclouds.cloudstack.features.OfferingClient;
|
||||
import org.jclouds.cloudstack.features.TemplateClient;
|
||||
import org.jclouds.cloudstack.features.VirtualMachineClient;
|
||||
import org.jclouds.cloudstack.features.ZoneClient;
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
|
@ -62,4 +63,9 @@ public interface CloudStackClient {
|
|||
@Delegate
|
||||
NetworkClient getNetworkClient();
|
||||
|
||||
/**
|
||||
* Provides synchronous access to VirtualMachine features.
|
||||
*/
|
||||
@Delegate
|
||||
VirtualMachineClient getVirtualMachineClient();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ import org.jclouds.cloudstack.features.OfferingAsyncClient;
|
|||
import org.jclouds.cloudstack.features.OfferingClient;
|
||||
import org.jclouds.cloudstack.features.TemplateAsyncClient;
|
||||
import org.jclouds.cloudstack.features.TemplateClient;
|
||||
import org.jclouds.cloudstack.features.VirtualMachineAsyncClient;
|
||||
import org.jclouds.cloudstack.features.VirtualMachineClient;
|
||||
import org.jclouds.cloudstack.features.ZoneAsyncClient;
|
||||
import org.jclouds.cloudstack.features.ZoneClient;
|
||||
import org.jclouds.cloudstack.handlers.CloudStackErrorHandler;
|
||||
|
@ -58,6 +60,7 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
|
|||
.put(TemplateClient.class, TemplateAsyncClient.class)//
|
||||
.put(OfferingClient.class, OfferingAsyncClient.class)//
|
||||
.put(NetworkClient.class, NetworkAsyncClient.class)//
|
||||
.put(VirtualMachineClient.class, VirtualMachineAsyncClient.class)//
|
||||
.build();
|
||||
|
||||
public CloudStackRestClientModule() {
|
||||
|
|
|
@ -0,0 +1,218 @@
|
|||
/**
|
||||
*
|
||||
* 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.net.URI;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class NIC {
|
||||
private String id;
|
||||
@SerializedName("broadcasturi")
|
||||
private URI broadcastURI;
|
||||
private String gateway;
|
||||
@SerializedName("ipaddress")
|
||||
private String IPAddress;
|
||||
@SerializedName("isdefault")
|
||||
private boolean isDefault;
|
||||
@SerializedName("isolationuri")
|
||||
private URI isolationURI;
|
||||
private String netmask;
|
||||
@SerializedName("networkid")
|
||||
private String networkId;
|
||||
@SerializedName("traffictype")
|
||||
private TrafficType trafficType;
|
||||
@SerializedName("type")
|
||||
private GuestIPType guestIPType;
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*
|
||||
*/
|
||||
NIC() {
|
||||
|
||||
}
|
||||
|
||||
public NIC(String id, URI broadcastURI, String gateway, String iPAddress, boolean isDefault, URI isolationURI,
|
||||
String netmask, String networkId, TrafficType trafficType, GuestIPType guestIPType) {
|
||||
this.id = id;
|
||||
this.broadcastURI = broadcastURI;
|
||||
this.gateway = gateway;
|
||||
this.IPAddress = iPAddress;
|
||||
this.isDefault = isDefault;
|
||||
this.isolationURI = isolationURI;
|
||||
this.netmask = netmask;
|
||||
this.networkId = networkId;
|
||||
this.trafficType = trafficType;
|
||||
this.guestIPType = guestIPType;
|
||||
}
|
||||
|
||||
/**
|
||||
* the ID of the nic
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* the broadcast uri of the nic
|
||||
*/
|
||||
public URI getBroadcastURI() {
|
||||
return broadcastURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* the gateway of the nic
|
||||
*/
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
/**
|
||||
* the ip address of the nic
|
||||
*/
|
||||
public String getIPAddress() {
|
||||
return IPAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* true if nic is default, false otherwise
|
||||
*/
|
||||
public boolean isDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* the isolation uri of the nic
|
||||
*/
|
||||
public URI getIsolationURI() {
|
||||
return isolationURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* the netmask of the nic
|
||||
*/
|
||||
public String getNetmask() {
|
||||
return netmask;
|
||||
}
|
||||
|
||||
/**
|
||||
* the ID of the corresponding network
|
||||
*/
|
||||
public String getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
/**
|
||||
* the traffic type of the nic
|
||||
*/
|
||||
public TrafficType getTrafficType() {
|
||||
return trafficType;
|
||||
}
|
||||
|
||||
/**
|
||||
* the type of the nic
|
||||
*/
|
||||
public GuestIPType getGuestIPType() {
|
||||
return guestIPType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((IPAddress == null) ? 0 : IPAddress.hashCode());
|
||||
result = prime * result + ((broadcastURI == null) ? 0 : broadcastURI.hashCode());
|
||||
result = prime * result + ((gateway == null) ? 0 : gateway.hashCode());
|
||||
result = prime * result + ((guestIPType == null) ? 0 : guestIPType.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result + (isDefault ? 1231 : 1237);
|
||||
result = prime * result + ((isolationURI == null) ? 0 : isolationURI.hashCode());
|
||||
result = prime * result + ((netmask == null) ? 0 : netmask.hashCode());
|
||||
result = prime * result + ((networkId == null) ? 0 : networkId.hashCode());
|
||||
result = prime * result + ((trafficType == null) ? 0 : trafficType.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;
|
||||
NIC other = (NIC) obj;
|
||||
if (IPAddress == null) {
|
||||
if (other.IPAddress != null)
|
||||
return false;
|
||||
} else if (!IPAddress.equals(other.IPAddress))
|
||||
return false;
|
||||
if (broadcastURI == null) {
|
||||
if (other.broadcastURI != null)
|
||||
return false;
|
||||
} else if (!broadcastURI.equals(other.broadcastURI))
|
||||
return false;
|
||||
if (gateway == null) {
|
||||
if (other.gateway != null)
|
||||
return false;
|
||||
} else if (!gateway.equals(other.gateway))
|
||||
return false;
|
||||
if (guestIPType != other.guestIPType)
|
||||
return false;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
if (isDefault != other.isDefault)
|
||||
return false;
|
||||
if (isolationURI == null) {
|
||||
if (other.isolationURI != null)
|
||||
return false;
|
||||
} else if (!isolationURI.equals(other.isolationURI))
|
||||
return false;
|
||||
if (netmask == null) {
|
||||
if (other.netmask != null)
|
||||
return false;
|
||||
} else if (!netmask.equals(other.netmask))
|
||||
return false;
|
||||
if (networkId == null) {
|
||||
if (other.networkId != null)
|
||||
return false;
|
||||
} else if (!networkId.equals(other.networkId))
|
||||
return false;
|
||||
if (trafficType != other.trafficType)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + ", broadcastURI=" + broadcastURI + ", gateway=" + gateway + ", IPAddress=" + IPAddress
|
||||
+ ", isDefault=" + isDefault + ", isolationURI=" + isolationURI + ", netmask=" + netmask + ", networkId="
|
||||
+ networkId + ", trafficType=" + trafficType + ", guestIPType=" + guestIPType + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,744 @@
|
|||
/**
|
||||
*
|
||||
* 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.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class VirtualMachine {
|
||||
public static enum State {
|
||||
STARTING, RUNNING, STOPPING, STOPPED, DESTROYED, EXPUNGING, MIGRATING, ERROR, UNKNOWN, SHUTDOWNED, UNRECOGNIZED;
|
||||
@Override
|
||||
public String toString() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||
}
|
||||
|
||||
public static State fromValue(String state) {
|
||||
try {
|
||||
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String account;
|
||||
@SerializedName("cpunumber")
|
||||
private long cpuCount;
|
||||
@SerializedName("cpuspeed")
|
||||
private long cpuSpeed;
|
||||
@SerializedName("cpuused")
|
||||
private String cpuUsed;
|
||||
@SerializedName("displayname")
|
||||
private String displayName;
|
||||
private Date created;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private String domainId;
|
||||
@SerializedName("forvirtualnetwork")
|
||||
private boolean usesVirtualNetwork;
|
||||
private String group;
|
||||
@SerializedName("groupid")
|
||||
private String groupId;
|
||||
@SerializedName("guestosid")
|
||||
private String guestOSId;
|
||||
@SerializedName("haenable")
|
||||
private boolean HAEnabled;
|
||||
@SerializedName("hostid")
|
||||
private String hostId;
|
||||
private String hostname;
|
||||
@SerializedName("ipaddress")
|
||||
private String IPAddress;
|
||||
@SerializedName("isodisplaytext")
|
||||
private String ISODisplayText;
|
||||
@SerializedName("isoid")
|
||||
private String ISOId;
|
||||
@SerializedName("isoname")
|
||||
private String ISOName;
|
||||
@SerializedName("jobid")
|
||||
@Nullable
|
||||
private String jobId;
|
||||
@SerializedName("jobstatus")
|
||||
@Nullable
|
||||
private String jobStatus;
|
||||
private long memory;
|
||||
private String name;
|
||||
@SerializedName("networkkbsread")
|
||||
private Long networkKbsRead;
|
||||
@SerializedName("networkkbswrite")
|
||||
private Long networkKbsWrite;
|
||||
@Nullable
|
||||
private String password;
|
||||
@SerializedName("passwordenabled")
|
||||
private boolean passwordEnabled;
|
||||
@SerializedName("rootdeviceid")
|
||||
private String rootDeviceId;
|
||||
@SerializedName("rootdevicetype")
|
||||
private String rootDeviceType;
|
||||
@SerializedName("securitygrouplist")
|
||||
private String securityGroupList;
|
||||
@SerializedName("serviceofferingid")
|
||||
private String serviceOfferingId;
|
||||
@SerializedName("serviceofferingname")
|
||||
private String serviceOfferingName;
|
||||
private State state;
|
||||
@SerializedName("templatedisplaytext")
|
||||
private String templateDisplayText;
|
||||
@SerializedName("templateid")
|
||||
private String templateId;
|
||||
@SerializedName("templatename")
|
||||
private String templateName;
|
||||
@SerializedName("zoneid")
|
||||
private String zoneId;
|
||||
@SerializedName("zonename")
|
||||
private String zoneName;
|
||||
@SerializedName("nic")
|
||||
private Set<? extends NIC> nics = ImmutableSet.<NIC> of();
|
||||
private String hypervisor;
|
||||
|
||||
public VirtualMachine(String id, String account, long cpuCount, long cpuSpeed, long cpuUsed, String displayName,
|
||||
Date created, String domain, String domainId, boolean usesVirtualNetwork, String group, String groupId,
|
||||
String guestOSId, boolean hAEnabled, String hostId, String hostname, String iPAddress, String iSODisplayText,
|
||||
String iSOId, String iSOName, String jobId, String jobStatus, long memory, String name, Long networkKbsRead,
|
||||
Long networkKbsWrite, String password, boolean passwordEnabled, String rootDeviceId, String rootDeviceType,
|
||||
Set<String> securityGroupList, String serviceOfferingId, String serviceOfferingName, State state,
|
||||
String templateDisplayText, String templateId, String templateName, String zoneId, String zoneName,
|
||||
Set<? extends NIC> nics, String hypervisor) {
|
||||
this.id = id;
|
||||
this.account = account;
|
||||
this.cpuCount = cpuCount;
|
||||
this.cpuSpeed = cpuSpeed;
|
||||
this.cpuUsed = cpuUsed + "";
|
||||
this.displayName = displayName;
|
||||
this.created = created;
|
||||
this.domain = domain;
|
||||
this.domainId = domainId;
|
||||
this.usesVirtualNetwork = usesVirtualNetwork;
|
||||
this.group = group;
|
||||
this.groupId = groupId;
|
||||
this.guestOSId = guestOSId;
|
||||
this.HAEnabled = hAEnabled;
|
||||
this.hostId = hostId;
|
||||
this.hostname = hostname;
|
||||
this.IPAddress = iPAddress;
|
||||
this.ISODisplayText = iSODisplayText;
|
||||
this.ISOId = iSOId;
|
||||
this.ISOName = iSOName;
|
||||
this.jobId = jobId;
|
||||
this.jobStatus = jobStatus;
|
||||
this.memory = memory;
|
||||
this.name = name;
|
||||
this.networkKbsRead = networkKbsRead;
|
||||
this.networkKbsWrite = networkKbsWrite;
|
||||
this.password = password;
|
||||
this.passwordEnabled = passwordEnabled;
|
||||
this.rootDeviceId = rootDeviceId;
|
||||
this.rootDeviceType = rootDeviceType;
|
||||
this.securityGroupList = Joiner.on(',').join(checkNotNull(securityGroupList, "securityGroupList"));
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
this.serviceOfferingName = serviceOfferingName;
|
||||
this.state = state;
|
||||
this.templateDisplayText = templateDisplayText;
|
||||
this.templateId = templateId;
|
||||
this.templateName = templateName;
|
||||
this.zoneId = zoneId;
|
||||
this.zoneName = zoneName;
|
||||
this.nics = nics;
|
||||
this.hypervisor = hypervisor;
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*
|
||||
*/
|
||||
VirtualMachine() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the virtual machine
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the account associated with the virtual machine
|
||||
*/
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of cpu this virtual machine is running with
|
||||
*/
|
||||
public long getCpuCount() {
|
||||
return cpuCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the speed of each cpu
|
||||
*/
|
||||
public long getCpuSpeed() {
|
||||
return cpuSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount of the vm's CPU currently used
|
||||
*/
|
||||
public float getCpuUsed() {
|
||||
return cpuUsed != null ? Float.parseFloat(cpuUsed.substring(9, cpuUsed.length() - 1)) : 0.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return user generated name. The name of the virtual machine is returned if no displayname
|
||||
* exists.
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the date when this virtual machine was created
|
||||
*/
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the domain in which the virtual machine exists
|
||||
*/
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the domain in which the virtual machine exists
|
||||
*/
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the virtual network for the service offering
|
||||
*/
|
||||
public boolean isUsesVirtualNetwork() {
|
||||
return usesVirtualNetwork;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the group name of the virtual machine
|
||||
*/
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the group ID of the virtual machine
|
||||
*/
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Os type ID of the virtual machine
|
||||
*/
|
||||
public String getGuestOSId() {
|
||||
return guestOSId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if high-availability is enabled, false otherwise
|
||||
*/
|
||||
public boolean isHAEnabled() {
|
||||
return HAEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the host for the virtual machine
|
||||
*/
|
||||
public String getHostId() {
|
||||
return hostId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the host for the virtual machine
|
||||
*/
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ip address of the virtual machine
|
||||
*/
|
||||
public String getIPAddress() {
|
||||
return IPAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an alternate display text of the ISO attached to the virtual machine
|
||||
*/
|
||||
public String getISODisplayText() {
|
||||
return ISODisplayText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the ISO attached to the virtual machine
|
||||
*/
|
||||
public String getISOId() {
|
||||
return ISOId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the ISO attached to the virtual machine
|
||||
*/
|
||||
public String getISOName() {
|
||||
return ISOName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return shows the current pending asynchronous job ID. This tag is not returned if no current
|
||||
* pending jobs are acting on the virtual machine
|
||||
*/
|
||||
@Nullable
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return shows the current pending asynchronous job status
|
||||
*/
|
||||
@Nullable
|
||||
public String getJobStatus() {
|
||||
return jobStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memory allocated for the virtual machine
|
||||
*/
|
||||
public long getMemory() {
|
||||
return memory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the virtual machine
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the incoming network traffic on the vm
|
||||
*/
|
||||
public Long getNetworkKbsRead() {
|
||||
return networkKbsRead;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the outgoing network traffic on the host
|
||||
*/
|
||||
public Long getNetworkKbsWrite() {
|
||||
return networkKbsWrite;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the password (if exists) of the virtual machine
|
||||
*/
|
||||
@Nullable
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the password rest feature is enabled, false otherwise
|
||||
*/
|
||||
public boolean isPasswordEnabled() {
|
||||
return passwordEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return device ID of the root volume
|
||||
*/
|
||||
public String getRootDeviceId() {
|
||||
return rootDeviceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return device type of the root volume
|
||||
*/
|
||||
public String getRootDeviceType() {
|
||||
return rootDeviceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of security groups associated with the virtual machine
|
||||
*/
|
||||
public Set<String> getSecurityGroupList() {
|
||||
return securityGroupList == null ? ImmutableSet.<String> of() : ImmutableSet.copyOf(Splitter.on(',').split(
|
||||
securityGroupList));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the service offering of the virtual machine
|
||||
*/
|
||||
public String getServiceOfferingId() {
|
||||
return serviceOfferingId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the service offering of the virtual machine
|
||||
*/
|
||||
public String getServiceOfferingName() {
|
||||
return serviceOfferingName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state of the virtual machine
|
||||
*/
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an alternate display text of the template for the virtual machine
|
||||
*/
|
||||
public String getTemplateDisplayText() {
|
||||
return templateDisplayText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the template for the virtual machine. A -1 is returned if the virtual
|
||||
* machine was created from an ISO file.
|
||||
*/
|
||||
public String getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the template for the virtual machine
|
||||
*/
|
||||
public String getTemplateName() {
|
||||
return templateName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the availablility zone for the virtual machine
|
||||
*/
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the availability zone for the virtual machine
|
||||
*/
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of nics associated with vm
|
||||
*/
|
||||
public Set<? extends NIC> getNICs() {
|
||||
return nics;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type of the hypervisor
|
||||
*/
|
||||
public String getHypervisor() {
|
||||
return hypervisor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (HAEnabled ? 1231 : 1237);
|
||||
result = prime * result + ((IPAddress == null) ? 0 : IPAddress.hashCode());
|
||||
result = prime * result + ((ISODisplayText == null) ? 0 : ISODisplayText.hashCode());
|
||||
result = prime * result + ((ISOId == null) ? 0 : ISOId.hashCode());
|
||||
result = prime * result + ((ISOName == null) ? 0 : ISOName.hashCode());
|
||||
result = prime * result + ((account == null) ? 0 : account.hashCode());
|
||||
result = prime * result + (int) (cpuCount ^ (cpuCount >>> 32));
|
||||
result = prime * result + (int) (cpuSpeed ^ (cpuSpeed >>> 32));
|
||||
result = prime * result + ((cpuUsed == null) ? 0 : cpuUsed.hashCode());
|
||||
result = prime * result + ((created == null) ? 0 : created.hashCode());
|
||||
result = prime * result + ((displayName == null) ? 0 : displayName.hashCode());
|
||||
result = prime * result + ((domain == null) ? 0 : domain.hashCode());
|
||||
result = prime * result + ((domainId == null) ? 0 : domainId.hashCode());
|
||||
result = prime * result + ((group == null) ? 0 : group.hashCode());
|
||||
result = prime * result + ((groupId == null) ? 0 : groupId.hashCode());
|
||||
result = prime * result + ((guestOSId == null) ? 0 : guestOSId.hashCode());
|
||||
result = prime * result + ((hostId == null) ? 0 : hostId.hashCode());
|
||||
result = prime * result + ((hostname == null) ? 0 : hostname.hashCode());
|
||||
result = prime * result + ((hypervisor == null) ? 0 : hypervisor.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result + ((jobId == null) ? 0 : jobId.hashCode());
|
||||
result = prime * result + ((jobStatus == null) ? 0 : jobStatus.hashCode());
|
||||
result = prime * result + (int) (memory ^ (memory >>> 32));
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((networkKbsRead == null) ? 0 : networkKbsRead.hashCode());
|
||||
result = prime * result + ((networkKbsWrite == null) ? 0 : networkKbsWrite.hashCode());
|
||||
result = prime * result + ((nics == null) ? 0 : nics.hashCode());
|
||||
result = prime * result + ((password == null) ? 0 : password.hashCode());
|
||||
result = prime * result + (passwordEnabled ? 1231 : 1237);
|
||||
result = prime * result + ((rootDeviceId == null) ? 0 : rootDeviceId.hashCode());
|
||||
result = prime * result + ((rootDeviceType == null) ? 0 : rootDeviceType.hashCode());
|
||||
result = prime * result + ((securityGroupList == null) ? 0 : securityGroupList.hashCode());
|
||||
result = prime * result + ((serviceOfferingId == null) ? 0 : serviceOfferingId.hashCode());
|
||||
result = prime * result + ((serviceOfferingName == null) ? 0 : serviceOfferingName.hashCode());
|
||||
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
||||
result = prime * result + ((templateDisplayText == null) ? 0 : templateDisplayText.hashCode());
|
||||
result = prime * result + ((templateId == null) ? 0 : templateId.hashCode());
|
||||
result = prime * result + ((templateName == null) ? 0 : templateName.hashCode());
|
||||
result = prime * result + (usesVirtualNetwork ? 1231 : 1237);
|
||||
result = prime * result + ((zoneId == null) ? 0 : zoneId.hashCode());
|
||||
result = prime * result + ((zoneName == null) ? 0 : zoneName.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;
|
||||
VirtualMachine other = (VirtualMachine) obj;
|
||||
if (HAEnabled != other.HAEnabled)
|
||||
return false;
|
||||
if (IPAddress == null) {
|
||||
if (other.IPAddress != null)
|
||||
return false;
|
||||
} else if (!IPAddress.equals(other.IPAddress))
|
||||
return false;
|
||||
if (ISODisplayText == null) {
|
||||
if (other.ISODisplayText != null)
|
||||
return false;
|
||||
} else if (!ISODisplayText.equals(other.ISODisplayText))
|
||||
return false;
|
||||
if (ISOId == null) {
|
||||
if (other.ISOId != null)
|
||||
return false;
|
||||
} else if (!ISOId.equals(other.ISOId))
|
||||
return false;
|
||||
if (ISOName == null) {
|
||||
if (other.ISOName != null)
|
||||
return false;
|
||||
} else if (!ISOName.equals(other.ISOName))
|
||||
return false;
|
||||
if (account == null) {
|
||||
if (other.account != null)
|
||||
return false;
|
||||
} else if (!account.equals(other.account))
|
||||
return false;
|
||||
if (cpuCount != other.cpuCount)
|
||||
return false;
|
||||
if (cpuSpeed != other.cpuSpeed)
|
||||
return false;
|
||||
if (cpuUsed == null) {
|
||||
if (other.cpuUsed != null)
|
||||
return false;
|
||||
} else if (!cpuUsed.equals(other.cpuUsed))
|
||||
return false;
|
||||
if (created == null) {
|
||||
if (other.created != null)
|
||||
return false;
|
||||
} else if (!created.equals(other.created))
|
||||
return false;
|
||||
if (displayName == null) {
|
||||
if (other.displayName != null)
|
||||
return false;
|
||||
} else if (!displayName.equals(other.displayName))
|
||||
return false;
|
||||
if (domain == null) {
|
||||
if (other.domain != null)
|
||||
return false;
|
||||
} else if (!domain.equals(other.domain))
|
||||
return false;
|
||||
if (domainId == null) {
|
||||
if (other.domainId != null)
|
||||
return false;
|
||||
} else if (!domainId.equals(other.domainId))
|
||||
return false;
|
||||
if (group == null) {
|
||||
if (other.group != null)
|
||||
return false;
|
||||
} else if (!group.equals(other.group))
|
||||
return false;
|
||||
if (groupId == null) {
|
||||
if (other.groupId != null)
|
||||
return false;
|
||||
} else if (!groupId.equals(other.groupId))
|
||||
return false;
|
||||
if (guestOSId == null) {
|
||||
if (other.guestOSId != null)
|
||||
return false;
|
||||
} else if (!guestOSId.equals(other.guestOSId))
|
||||
return false;
|
||||
if (hostId == null) {
|
||||
if (other.hostId != null)
|
||||
return false;
|
||||
} else if (!hostId.equals(other.hostId))
|
||||
return false;
|
||||
if (hostname == null) {
|
||||
if (other.hostname != null)
|
||||
return false;
|
||||
} else if (!hostname.equals(other.hostname))
|
||||
return false;
|
||||
if (hypervisor == null) {
|
||||
if (other.hypervisor != null)
|
||||
return false;
|
||||
} else if (!hypervisor.equals(other.hypervisor))
|
||||
return false;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
if (jobId == null) {
|
||||
if (other.jobId != null)
|
||||
return false;
|
||||
} else if (!jobId.equals(other.jobId))
|
||||
return false;
|
||||
if (jobStatus == null) {
|
||||
if (other.jobStatus != null)
|
||||
return false;
|
||||
} else if (!jobStatus.equals(other.jobStatus))
|
||||
return false;
|
||||
if (memory != other.memory)
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (networkKbsRead == null) {
|
||||
if (other.networkKbsRead != null)
|
||||
return false;
|
||||
} else if (!networkKbsRead.equals(other.networkKbsRead))
|
||||
return false;
|
||||
if (networkKbsWrite == null) {
|
||||
if (other.networkKbsWrite != null)
|
||||
return false;
|
||||
} else if (!networkKbsWrite.equals(other.networkKbsWrite))
|
||||
return false;
|
||||
if (nics == null) {
|
||||
if (other.nics != null)
|
||||
return false;
|
||||
} else if (!nics.equals(other.nics))
|
||||
return false;
|
||||
if (password == null) {
|
||||
if (other.password != null)
|
||||
return false;
|
||||
} else if (!password.equals(other.password))
|
||||
return false;
|
||||
if (passwordEnabled != other.passwordEnabled)
|
||||
return false;
|
||||
if (rootDeviceId == null) {
|
||||
if (other.rootDeviceId != null)
|
||||
return false;
|
||||
} else if (!rootDeviceId.equals(other.rootDeviceId))
|
||||
return false;
|
||||
if (rootDeviceType == null) {
|
||||
if (other.rootDeviceType != null)
|
||||
return false;
|
||||
} else if (!rootDeviceType.equals(other.rootDeviceType))
|
||||
return false;
|
||||
if (securityGroupList == null) {
|
||||
if (other.securityGroupList != null)
|
||||
return false;
|
||||
} else if (!securityGroupList.equals(other.securityGroupList))
|
||||
return false;
|
||||
if (serviceOfferingId == null) {
|
||||
if (other.serviceOfferingId != null)
|
||||
return false;
|
||||
} else if (!serviceOfferingId.equals(other.serviceOfferingId))
|
||||
return false;
|
||||
if (serviceOfferingName == null) {
|
||||
if (other.serviceOfferingName != null)
|
||||
return false;
|
||||
} else if (!serviceOfferingName.equals(other.serviceOfferingName))
|
||||
return false;
|
||||
if (state != other.state)
|
||||
return false;
|
||||
if (templateDisplayText == null) {
|
||||
if (other.templateDisplayText != null)
|
||||
return false;
|
||||
} else if (!templateDisplayText.equals(other.templateDisplayText))
|
||||
return false;
|
||||
if (templateId == null) {
|
||||
if (other.templateId != null)
|
||||
return false;
|
||||
} else if (!templateId.equals(other.templateId))
|
||||
return false;
|
||||
if (templateName == null) {
|
||||
if (other.templateName != null)
|
||||
return false;
|
||||
} else if (!templateName.equals(other.templateName))
|
||||
return false;
|
||||
if (usesVirtualNetwork != other.usesVirtualNetwork)
|
||||
return false;
|
||||
if (zoneId == null) {
|
||||
if (other.zoneId != null)
|
||||
return false;
|
||||
} else if (!zoneId.equals(other.zoneId))
|
||||
return false;
|
||||
if (zoneName == null) {
|
||||
if (other.zoneName != null)
|
||||
return false;
|
||||
} else if (!zoneName.equals(other.zoneName))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + ", account=" + account + ", cpuCount=" + cpuCount + ", cpuSpeed=" + cpuSpeed + ", cpuUsed="
|
||||
+ cpuUsed + ", displayName=" + displayName + ", created=" + created + ", domain=" + domain + ", domainId="
|
||||
+ domainId + ", usesVirtualNetwork=" + usesVirtualNetwork + ", group=" + group + ", groupId=" + groupId
|
||||
+ ", guestOSId=" + guestOSId + ", HAEnabled=" + HAEnabled + ", hostId=" + hostId + ", hostname=" + hostname
|
||||
+ ", IPAddress=" + IPAddress + ", ISODisplayText=" + ISODisplayText + ", ISOId=" + ISOId + ", ISOName="
|
||||
+ ISOName + ", jobId=" + jobId + ", jobStatus=" + jobStatus + ", memory=" + memory + ", name=" + name
|
||||
+ ", networkKbsRead=" + networkKbsRead + ", networkKbsWrite=" + networkKbsWrite + ", password=" + password
|
||||
+ ", passwordEnabled=" + passwordEnabled + ", rootDeviceId=" + rootDeviceId + ", rootDeviceType="
|
||||
+ rootDeviceType + ", securityGroupList=" + securityGroupList + ", serviceOfferingId=" + serviceOfferingId
|
||||
+ ", serviceOfferingName=" + serviceOfferingName + ", state=" + state + ", templateDisplayText="
|
||||
+ templateDisplayText + ", templateId=" + templateId + ", templateName=" + templateName + ", zoneId="
|
||||
+ zoneId + ", zoneName=" + zoneName + ", nics=" + nics + ", hypervisor=" + hypervisor + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -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 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.VirtualMachine;
|
||||
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
||||
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 com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to cloudstack via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see VirtualMachineClient
|
||||
* @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 VirtualMachineAsyncClient {
|
||||
|
||||
/**
|
||||
* @see VirtualMachineClient#listVirtualMachines
|
||||
*/
|
||||
@GET
|
||||
@QueryParams(keys = "command", values = "listVirtualMachines")
|
||||
@Unwrap(depth = 2)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<VirtualMachine>> listVirtualMachines(ListVirtualMachinesOptions... options);
|
||||
|
||||
/**
|
||||
* @see VirtualMachineClient#getVirtualMachine
|
||||
*/
|
||||
@GET
|
||||
@QueryParams(keys = "command", values = "listVirtualMachines")
|
||||
@Unwrap(depth = 3, edgeCollection = Set.class)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<VirtualMachine> getVirtualMachine(@QueryParam("id") String id);
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
*
|
||||
* 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.VirtualMachine;
|
||||
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to CloudStack VirtualMachine features.
|
||||
* <p/>
|
||||
*
|
||||
* @see VirtualMachineAsyncClient
|
||||
* @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 VirtualMachineClient {
|
||||
/**
|
||||
* Lists VirtualMachines
|
||||
*
|
||||
* @param options
|
||||
* if present, how to constrain the list.
|
||||
* @return VirtualMachines matching query, or empty set, if no VirtualMachines are found
|
||||
*/
|
||||
Set<VirtualMachine> listVirtualMachines(ListVirtualMachinesOptions... options);
|
||||
|
||||
/**
|
||||
* get a specific VirtualMachine by id
|
||||
*
|
||||
* @param id
|
||||
* VirtualMachine to get
|
||||
* @return VirtualMachine or null if not found
|
||||
*/
|
||||
VirtualMachine getVirtualMachine(String id);
|
||||
}
|
|
@ -0,0 +1,235 @@
|
|||
/**
|
||||
*
|
||||
* 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 virtual machines information is returned
|
||||
*
|
||||
* @see <a href="http://download.cloud.com/releases/2.2/api/user/listVirtualMachines.html" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ListVirtualMachinesOptions extends BaseHttpRequestOptions {
|
||||
|
||||
public static final ListVirtualMachinesOptions NONE = new ListVirtualMachinesOptions();
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the ID of the virtual machine
|
||||
*/
|
||||
public ListVirtualMachinesOptions id(String id) {
|
||||
this.queryParameters.replaceValues("id", ImmutableSet.of(id));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the virtual machine name
|
||||
*/
|
||||
public ListVirtualMachinesOptions name(String name) {
|
||||
this.queryParameters.replaceValues("name", ImmutableSet.of(name));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* state of the virtual machine
|
||||
*/
|
||||
public ListVirtualMachinesOptions state(String state) {
|
||||
this.queryParameters.replaceValues("state", ImmutableSet.of(state));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param domainId
|
||||
* the ID of the domain associated with the virtual machine
|
||||
*/
|
||||
public ListVirtualMachinesOptions domainId(String domainId) {
|
||||
this.queryParameters.replaceValues("domainid", ImmutableSet.of(domainId));
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param account
|
||||
* account id
|
||||
* @param domain
|
||||
* domain id
|
||||
*/
|
||||
public ListVirtualMachinesOptions accountInDomain(String account, String domain) {
|
||||
this.queryParameters.replaceValues("account", ImmutableSet.of(account));
|
||||
return domainId(domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param groupId
|
||||
* list virtual machines by groupId.
|
||||
*/
|
||||
public ListVirtualMachinesOptions groupId(String groupId) {
|
||||
this.queryParameters.replaceValues("groupid", ImmutableSet.of(groupId));
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hostId
|
||||
* list virtual machines by hostId.
|
||||
*/
|
||||
public ListVirtualMachinesOptions hostId(String hostId) {
|
||||
this.queryParameters.replaceValues("hostid", ImmutableSet.of(hostId));
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param networkId
|
||||
* list virtual machines by networkId.
|
||||
*/
|
||||
public ListVirtualMachinesOptions networkId(String networkId) {
|
||||
this.queryParameters.replaceValues("networkid", ImmutableSet.of(networkId));
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param podId
|
||||
* list virtual machines by podId.
|
||||
*/
|
||||
public ListVirtualMachinesOptions podId(String podId) {
|
||||
this.queryParameters.replaceValues("podid", ImmutableSet.of(podId));
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param zoneId
|
||||
* list virtual machines by zoneId.
|
||||
*/
|
||||
public ListVirtualMachinesOptions zoneId(String zoneId) {
|
||||
this.queryParameters.replaceValues("zoneid", ImmutableSet.of(zoneId));
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param usesVirtualNetwork
|
||||
* list by network type; true if need to list vms using Virtual Network, false
|
||||
* otherwise
|
||||
*/
|
||||
public ListVirtualMachinesOptions usesVirtualNetwork(boolean usesVirtualNetwork) {
|
||||
this.queryParameters.replaceValues("forvirtualnetwork", ImmutableSet.of(usesVirtualNetwork + ""));
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
* @see ListVirtualMachinesOptions#accountInDomain
|
||||
*/
|
||||
public static ListVirtualMachinesOptions accountInDomain(String account, String domain) {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
||||
return options.accountInDomain(account, domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListVirtualMachinesOptions#domainId
|
||||
*/
|
||||
public static ListVirtualMachinesOptions domainId(String id) {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
||||
return options.domainId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListVirtualMachinesOptions#id
|
||||
*/
|
||||
public static ListVirtualMachinesOptions id(String id) {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
||||
return options.id(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListVirtualMachinesOptions#name
|
||||
*/
|
||||
public static ListVirtualMachinesOptions name(String name) {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
||||
return options.name(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListVirtualMachinesOptions#state
|
||||
*/
|
||||
public static ListVirtualMachinesOptions state(String state) {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
||||
return options.state(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListVirtualMachinesOptions#groupId
|
||||
*/
|
||||
public static ListVirtualMachinesOptions groupId(String id) {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
||||
return options.groupId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListVirtualMachinesOptions#hostId
|
||||
*/
|
||||
public static ListVirtualMachinesOptions hostId(String id) {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
||||
return options.hostId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListVirtualMachinesOptions#networkId
|
||||
*/
|
||||
public static ListVirtualMachinesOptions networkId(String id) {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
||||
return options.networkId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListVirtualMachinesOptions#podId
|
||||
*/
|
||||
public static ListVirtualMachinesOptions podId(String id) {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
||||
return options.podId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListVirtualMachinesOptions#zoneId
|
||||
*/
|
||||
public static ListVirtualMachinesOptions zoneId(String id) {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
||||
return options.zoneId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListVirtualMachinesOptions#usesVirtualNetwork
|
||||
*/
|
||||
public static ListVirtualMachinesOptions usesVirtualNetwork(boolean usesVirtualNetwork) {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions();
|
||||
return options.usesVirtualNetwork(usesVirtualNetwork);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -41,8 +41,8 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
public void testListTemplates() throws Exception {
|
||||
Set<Template> response = client.getTemplateClient().listTemplates();
|
||||
assert null != response;
|
||||
long zoneCount = response.size();
|
||||
assertTrue(zoneCount >= 0);
|
||||
long templateCount = response.size();
|
||||
assertTrue(templateCount >= 0);
|
||||
for (Template template : response) {
|
||||
Template newDetails = Iterables.getOnlyElement(client.getTemplateClient().listTemplates(
|
||||
ListTemplatesOptions.Builder.id(template.getId())));
|
||||
|
@ -58,7 +58,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
assert template.getAccount() != null : template;
|
||||
assert template.getZone() != null : template;
|
||||
assert template.getZoneId() != null : template;
|
||||
assert template.getStatus() != null : template;
|
||||
assert template.getStatus() == null : template;
|
||||
assert template.getType() != null && template.getType() != Template.Type.UNRECOGNIZED : template;
|
||||
assert template.getHypervisor() != null : template;
|
||||
assert template.getDomain() != null : template;
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
/**
|
||||
*
|
||||
* 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.ListVirtualMachinesOptions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VirtualMachineAsyncClient}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "VirtualMachineAsyncClientTest")
|
||||
public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest<VirtualMachineAsyncClient> {
|
||||
public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("listVirtualMachines",
|
||||
ListVirtualMachinesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines 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 testListVirtualMachinesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("listVirtualMachines",
|
||||
ListVirtualMachinesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method,
|
||||
ListVirtualMachinesOptions.Builder.accountInDomain("accountId", "domainId").usesVirtualNetwork(true));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&account=accountId&domainid=domainId&forvirtualnetwork=true 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 testGetVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("getVirtualMachine", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "id");
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&id=id 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);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<VirtualMachineAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<VirtualMachineAsyncClient>>() {
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
*
|
||||
* 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.NIC;
|
||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VirtualMachineClientLiveTest}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", sequential = true, testName = "VirtualMachineClientLiveTest")
|
||||
public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||
|
||||
public void testListVirtualMachines() throws Exception {
|
||||
Set<VirtualMachine> response = client.getVirtualMachineClient().listVirtualMachines();
|
||||
System.out.println(response);
|
||||
assert null != response;
|
||||
assertTrue(response.size() >= 0);
|
||||
for (VirtualMachine vm : response) {
|
||||
VirtualMachine newDetails = Iterables.getOnlyElement(client.getVirtualMachineClient().listVirtualMachines(
|
||||
ListVirtualMachinesOptions.Builder.id(vm.getId())));
|
||||
assertEquals(vm, newDetails);
|
||||
assertEquals(vm, client.getVirtualMachineClient().getVirtualMachine(vm.getId()));
|
||||
assert vm.getId() != null : vm;
|
||||
assert vm.getName() != null : vm;
|
||||
assert vm.getDisplayName() != null : vm;
|
||||
assert vm.getAccount() != null : vm;
|
||||
assert vm.getDomain() != null : vm;
|
||||
assert vm.getDomainId() != null : vm;
|
||||
assert vm.getCreated() != null : vm;
|
||||
assert vm.getState() != null : vm;
|
||||
assert vm.getZoneId() != null : vm;
|
||||
assert vm.getZoneName() != null : vm;
|
||||
assert vm.getTemplateId() != null : vm;
|
||||
assert vm.getTemplateName() != null : vm;
|
||||
assert vm.getTemplateDisplayText() != null : vm;
|
||||
assert vm.getServiceOfferingId() != null : vm;
|
||||
assert vm.getServiceOfferingName() != null : vm;
|
||||
assert vm.getCpuCount() > 0 : vm;
|
||||
assert vm.getCpuSpeed() > 0 : vm;
|
||||
assert vm.getMemory() > 0 : vm;
|
||||
assert vm.getGuestOSId() != null : vm;
|
||||
assert vm.getRootDeviceId() != null : 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() != null : vm;
|
||||
assert nic.getNetworkId() != null : 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -51,18 +51,19 @@ public class ZoneClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
assertEquals(zone, client.getZoneClient().getZone(zone.getId()));
|
||||
assert zone.getId() != null : zone;
|
||||
assert zone.getName() != null : zone;
|
||||
assert zone.getDNS().size() != 0 : zone;
|
||||
assert zone.getInternalDNS().size() != 0 : zone;
|
||||
assert zone.getNetworkType() != null && zone.getNetworkType() != NetworkType.UNRECOGNIZED : zone;
|
||||
switch (zone.getNetworkType()) {
|
||||
case ADVANCED:
|
||||
assert zone.getVLAN() != null : zone;
|
||||
assert zone.getDomain() == null : zone;
|
||||
assert zone.getDomainId() == null : zone;
|
||||
assert zone.getGuestCIDRAddress() != null : zone;
|
||||
//TODO
|
||||
// assert zone.getVLAN() != null : zone;
|
||||
// assert zone.getDomain() == null : zone;
|
||||
// assert zone.getDomainId() == null : zone;
|
||||
// assert zone.getGuestCIDRAddress() != null : zone;
|
||||
break;
|
||||
case BASIC:
|
||||
assert zone.getVLAN() == null : zone;
|
||||
assert zone.getDNS().size() != 0 : zone;
|
||||
assert zone.getInternalDNS().size() != 0 : zone;
|
||||
assert zone.getDomain() != null : zone;
|
||||
assert zone.getDomainId() != null : zone;
|
||||
assert zone.getGuestCIDRAddress() == null : zone;
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
/**
|
||||
*
|
||||
* 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.ListVirtualMachinesOptions.Builder.accountInDomain;
|
||||
import static org.jclouds.cloudstack.options.ListVirtualMachinesOptions.Builder.domainId;
|
||||
import static org.jclouds.cloudstack.options.ListVirtualMachinesOptions.Builder.groupId;
|
||||
import static org.jclouds.cloudstack.options.ListVirtualMachinesOptions.Builder.hostId;
|
||||
import static org.jclouds.cloudstack.options.ListVirtualMachinesOptions.Builder.id;
|
||||
import static org.jclouds.cloudstack.options.ListVirtualMachinesOptions.Builder.networkId;
|
||||
import static org.jclouds.cloudstack.options.ListVirtualMachinesOptions.Builder.podId;
|
||||
import static org.jclouds.cloudstack.options.ListVirtualMachinesOptions.Builder.state;
|
||||
import static org.jclouds.cloudstack.options.ListVirtualMachinesOptions.Builder.usesVirtualNetwork;
|
||||
import static org.jclouds.cloudstack.options.ListVirtualMachinesOptions.Builder.zoneId;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ListVirtualMachinesOptions}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListVirtualMachesOptionsTest {
|
||||
|
||||
public void testHostId() {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().hostId("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("hostid"));
|
||||
}
|
||||
|
||||
public void testHostIdStatic() {
|
||||
ListVirtualMachinesOptions options = hostId("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("hostid"));
|
||||
}
|
||||
|
||||
public void testPodId() {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().podId("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("podid"));
|
||||
}
|
||||
|
||||
public void testPodIdStatic() {
|
||||
ListVirtualMachinesOptions options = podId("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("podid"));
|
||||
}
|
||||
|
||||
public void testNetworkId() {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().networkId("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("networkid"));
|
||||
}
|
||||
|
||||
public void testNetworkIdStatic() {
|
||||
ListVirtualMachinesOptions options = networkId("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("networkid"));
|
||||
}
|
||||
|
||||
public void testGroupId() {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().groupId("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("groupid"));
|
||||
}
|
||||
|
||||
public void testGroupIdStatic() {
|
||||
ListVirtualMachinesOptions options = groupId("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("groupid"));
|
||||
}
|
||||
|
||||
public void testAccountInDomainId() {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().accountInDomain("moo", "goo");
|
||||
assertEquals(ImmutableList.of("moo"), options.buildQueryParameters().get("account"));
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("domainid"));
|
||||
}
|
||||
|
||||
public void testAccountInDomainIdStatic() {
|
||||
ListVirtualMachinesOptions options = accountInDomain("moo", "goo");
|
||||
assertEquals(ImmutableList.of("moo"), options.buildQueryParameters().get("account"));
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("domainid"));
|
||||
}
|
||||
|
||||
public void testName() {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().id("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("id"));
|
||||
}
|
||||
|
||||
public void testNameStatic() {
|
||||
ListVirtualMachinesOptions options = id("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("id"));
|
||||
}
|
||||
|
||||
public void testZoneId() {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().zoneId("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("zoneid"));
|
||||
}
|
||||
|
||||
public void testZoneIdStatic() {
|
||||
ListVirtualMachinesOptions options = zoneId("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("zoneid"));
|
||||
}
|
||||
|
||||
public void testState() {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().state("state");
|
||||
assertEquals(ImmutableList.of("state"), options.buildQueryParameters().get("state"));
|
||||
}
|
||||
|
||||
public void testStateStatic() {
|
||||
ListVirtualMachinesOptions options = state("state");
|
||||
assertEquals(ImmutableList.of("state"), options.buildQueryParameters().get("state"));
|
||||
}
|
||||
|
||||
public void testUsingVirtualNetwork() {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().usesVirtualNetwork(true);
|
||||
assertEquals(ImmutableList.of("true"), options.buildQueryParameters().get("forvirtualnetwork"));
|
||||
}
|
||||
|
||||
public void testUsingVirtualNetworkStatic() {
|
||||
ListVirtualMachinesOptions options = usesVirtualNetwork(true);
|
||||
assertEquals(ImmutableList.of("true"), options.buildQueryParameters().get("forvirtualnetwork"));
|
||||
}
|
||||
|
||||
public void testId() {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().id("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("id"));
|
||||
}
|
||||
|
||||
public void testDomainId() {
|
||||
ListVirtualMachinesOptions options = new ListVirtualMachinesOptions().domainId("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("domainid"));
|
||||
}
|
||||
|
||||
public void testIdStatic() {
|
||||
ListVirtualMachinesOptions options = id("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("id"));
|
||||
}
|
||||
|
||||
public void testDomainIdStatic() {
|
||||
ListVirtualMachinesOptions options = domainId("goo");
|
||||
assertEquals(ImmutableList.of("goo"), options.buildQueryParameters().get("domainid"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue