SSHKeyPair API implementation

- Updated tests with correct domain model object.
- Unit tests for ListSSHKeyPairs
This commit is contained in:
vijaykiran 2011-10-29 16:57:54 +02:00
parent 6d4ce41d15
commit 1151cbc241
77 changed files with 796 additions and 578 deletions

View File

@ -18,7 +18,22 @@
*/ */
package org.jclouds.cloudstack; package org.jclouds.cloudstack;
import org.jclouds.cloudstack.features.*; import org.jclouds.cloudstack.features.AccountAsyncClient;
import org.jclouds.cloudstack.features.AddressAsyncClient;
import org.jclouds.cloudstack.features.AsyncJobAsyncClient;
import org.jclouds.cloudstack.features.ConfigurationAsyncClient;
import org.jclouds.cloudstack.features.FirewallAsyncClient;
import org.jclouds.cloudstack.features.GuestOSAsyncClient;
import org.jclouds.cloudstack.features.HypervisorAsyncClient;
import org.jclouds.cloudstack.features.LoadBalancerAsyncClient;
import org.jclouds.cloudstack.features.NATAsyncClient;
import org.jclouds.cloudstack.features.NetworkAsyncClient;
import org.jclouds.cloudstack.features.OfferingAsyncClient;
import org.jclouds.cloudstack.features.SSHKeyPairAsyncClient;
import org.jclouds.cloudstack.features.SecurityGroupAsyncClient;
import org.jclouds.cloudstack.features.TemplateAsyncClient;
import org.jclouds.cloudstack.features.VirtualMachineAsyncClient;
import org.jclouds.cloudstack.features.ZoneAsyncClient;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
/** /**
@ -44,7 +59,8 @@ public interface CloudStackAsyncClient {
TemplateAsyncClient getTemplateClient(); TemplateAsyncClient getTemplateClient();
/** /**
* Provides asynchronous access to Service, Disk, and Network Offering features. * Provides asynchronous access to Service, Disk, and Network Offering
* features.
*/ */
@Delegate @Delegate
OfferingAsyncClient getOfferingClient(); OfferingAsyncClient getOfferingClient();

View File

@ -18,12 +18,27 @@
*/ */
package org.jclouds.cloudstack; package org.jclouds.cloudstack;
import org.jclouds.cloudstack.features.*; import java.util.concurrent.TimeUnit;
import org.jclouds.cloudstack.features.AccountClient;
import org.jclouds.cloudstack.features.AddressClient;
import org.jclouds.cloudstack.features.AsyncJobClient;
import org.jclouds.cloudstack.features.ConfigurationClient;
import org.jclouds.cloudstack.features.FirewallClient;
import org.jclouds.cloudstack.features.GuestOSClient;
import org.jclouds.cloudstack.features.HypervisorClient;
import org.jclouds.cloudstack.features.LoadBalancerClient;
import org.jclouds.cloudstack.features.NATClient;
import org.jclouds.cloudstack.features.NetworkClient;
import org.jclouds.cloudstack.features.OfferingClient;
import org.jclouds.cloudstack.features.SSHKeyPairClient;
import org.jclouds.cloudstack.features.SecurityGroupClient;
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.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import java.util.concurrent.TimeUnit;
/** /**
* Provides synchronous access to CloudStack. * Provides synchronous access to CloudStack.
* <p/> * <p/>
@ -47,7 +62,8 @@ public interface CloudStackClient {
TemplateClient getTemplateClient(); TemplateClient getTemplateClient();
/** /**
* Provides synchronous access to Service, Disk, and Network Offering features. * Provides synchronous access to Service, Disk, and Network Offering
* features.
*/ */
@Delegate @Delegate
OfferingClient getOfferingClient(); OfferingClient getOfferingClient();

View File

@ -30,8 +30,7 @@ import com.google.inject.Module;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CloudStackContextBuilder extends public class CloudStackContextBuilder extends RestContextBuilder<CloudStackClient, CloudStackAsyncClient> {
RestContextBuilder<CloudStackClient, CloudStackAsyncClient> {
public CloudStackContextBuilder(Properties props) { public CloudStackContextBuilder(Properties props) {
super(CloudStackClient.class, CloudStackAsyncClient.class, props); super(CloudStackClient.class, CloudStackAsyncClient.class, props);

View File

@ -33,8 +33,8 @@ import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.rest.Binder; import org.jclouds.rest.Binder;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableMultimap.Builder; import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.common.collect.Multimap;
/** /**
* *

View File

@ -18,10 +18,42 @@
*/ */
package org.jclouds.cloudstack.config; package org.jclouds.cloudstack.config;
import com.google.common.collect.ImmutableMap; 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.*; import org.jclouds.cloudstack.features.AccountAsyncClient;
import org.jclouds.cloudstack.features.AccountClient;
import org.jclouds.cloudstack.features.AddressAsyncClient;
import org.jclouds.cloudstack.features.AddressClient;
import org.jclouds.cloudstack.features.AsyncJobAsyncClient;
import org.jclouds.cloudstack.features.AsyncJobClient;
import org.jclouds.cloudstack.features.ConfigurationAsyncClient;
import org.jclouds.cloudstack.features.ConfigurationClient;
import org.jclouds.cloudstack.features.FirewallAsyncClient;
import org.jclouds.cloudstack.features.FirewallClient;
import org.jclouds.cloudstack.features.GuestOSAsyncClient;
import org.jclouds.cloudstack.features.GuestOSClient;
import org.jclouds.cloudstack.features.HypervisorAsyncClient;
import org.jclouds.cloudstack.features.HypervisorClient;
import org.jclouds.cloudstack.features.LoadBalancerAsyncClient;
import org.jclouds.cloudstack.features.LoadBalancerClient;
import org.jclouds.cloudstack.features.NATAsyncClient;
import org.jclouds.cloudstack.features.NATClient;
import org.jclouds.cloudstack.features.NetworkAsyncClient;
import org.jclouds.cloudstack.features.NetworkClient;
import org.jclouds.cloudstack.features.OfferingAsyncClient;
import org.jclouds.cloudstack.features.OfferingClient;
import org.jclouds.cloudstack.features.SSHKeyPairAsyncClient;
import org.jclouds.cloudstack.features.SSHKeyPairClient;
import org.jclouds.cloudstack.features.SecurityGroupAsyncClient;
import org.jclouds.cloudstack.features.SecurityGroupClient;
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; import org.jclouds.cloudstack.handlers.CloudStackErrorHandler;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
@ -35,7 +67,7 @@ import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.config.RestClientModule;
import java.util.Map; import com.google.common.collect.ImmutableMap;
/** /**
* Configures the cloudstack connection. * Configures the cloudstack connection.

View File

@ -118,9 +118,9 @@ public class AsyncJob<T> {
} }
public static <T> Builder<T> fromAsyncJobUntyped(AsyncJob<T> in) { public static <T> Builder<T> fromAsyncJobUntyped(AsyncJob<T> in) {
return new Builder<T>().accountId(in.accountId).cmd(in.cmd).created(in.created).id(in.id).instanceId( return new Builder<T>().accountId(in.accountId).cmd(in.cmd).created(in.created).id(in.id)
in.instanceId).instanceType(in.instanceType).progress(in.progress).result(in.result).resultCode( .instanceId(in.instanceId).instanceType(in.instanceType).progress(in.progress).result(in.result)
in.resultCode).resultType(in.resultType).status(in.status).userId(in.userId).error(in.error); .resultCode(in.resultCode).resultType(in.resultType).status(in.status).userId(in.userId).error(in.error);
} }
} }
@ -260,7 +260,8 @@ public class AsyncJob<T> {
/** /**
* *
* *
* @return the error related to this command, or null if no error or error not yet encountered. * @return the error related to this command, or null if no error or error
* not yet encountered.
*/ */
public AsyncJobError getError() { public AsyncJobError getError() {
return error; return error;
@ -346,8 +347,8 @@ public class AsyncJob<T> {
public String toString() { public String toString() {
return "[accountId=" + accountId + ", cmd=" + cmd + ", created=" + created + ", id=" + id + ", instanceId=" return "[accountId=" + accountId + ", cmd=" + cmd + ", created=" + created + ", id=" + id + ", instanceId="
+ instanceId + ", instanceType=" + instanceType + ", error=" + error + ", progress=" + progress + instanceId + ", instanceType=" + instanceType + ", error=" + error + ", progress=" + progress
+ ", result=" + result + ", resultCode=" + resultCode + ", resultType=" + resultType + ", status=" + ", result=" + result + ", resultCode=" + resultCode + ", resultType=" + resultType + ", status=" + status
+ status + ", userId=" + userId + "]"; + ", userId=" + userId + "]";
} }
} }

View File

@ -94,7 +94,8 @@ public class Capabilities {
/** /**
* *
* @return true if user and domain admins can set templates to be shared, false otherwise * @return true if user and domain admins can set templates to be shared,
* false otherwise
*/ */
public boolean isSharedTemplatesEnabled() { public boolean isSharedTemplatesEnabled() {
return canShareTemplates; return canShareTemplates;

View File

@ -30,13 +30,13 @@ import com.google.common.base.CaseFormat;
public enum GuestIPType { public enum GuestIPType {
/** /**
* guest IP address will be issued by Dhcp server in the guest virtual network. Dhcp role is * guest IP address will be issued by Dhcp server in the guest virtual
* played by domain router. * network. Dhcp role is played by domain router.
*/ */
VIRTUAL, VIRTUAL,
/** /**
* traffic directly to the network and VMs created here are assigned an IP directly from the * traffic directly to the network and VMs created here are assigned an IP
* network as configured * directly from the network as configured
*/ */
DIRECT, DIRECT,

View File

@ -286,9 +286,9 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
@Override @Override
public String toString() { public String toString() {
return "[IPAddress=" + IPAddress + ", IPAddressId=" + IPAddressId + ", id=" + id + ", startPort=" + startPort return "[IPAddress=" + IPAddress + ", IPAddressId=" + IPAddressId + ", id=" + id + ", startPort=" + startPort
+ ", protocol=" + protocol + ", endPort=" + endPort + ", state=" + state + ", protocol=" + protocol + ", endPort=" + endPort + ", state=" + state + ", virtualMachineDisplayName="
+ ", virtualMachineDisplayName=" + virtualMachineDisplayName + ", virtualMachineId=" + virtualMachineId + virtualMachineDisplayName + ", virtualMachineId=" + virtualMachineId + ", virtualMachineName="
+ ", virtualMachineName=" + virtualMachineName + "]"; + virtualMachineName + "]";
} }
} }

View File

@ -18,21 +18,21 @@
*/ */
package org.jclouds.cloudstack.domain; package org.jclouds.cloudstack.domain;
import com.google.common.collect.ImmutableList; import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.gson.annotations.SerializedName;
import javax.annotation.Nullable;
import java.net.URI; import java.net.URI;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import static com.google.common.base.Preconditions.checkNotNull; import javax.annotation.Nullable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.gson.annotations.SerializedName;
/** /**
*
* @author Adrian Cole * @author Adrian Cole
*/ */
public class Network implements Comparable<Network> { public class Network implements Comparable<Network> {
@ -244,7 +244,8 @@ public class Network implements Comparable<Network> {
@SerializedName("issystem") @SerializedName("issystem")
private boolean isSystem; private boolean isSystem;
private String netmask; private String netmask;
@SerializedName("domain") @Nullable
@SerializedName("networkdomain")
private String networkDomain; private String networkDomain;
@SerializedName("networkofferingavailability") @SerializedName("networkofferingavailability")
private String networkOfferingAvailability; private String networkOfferingAvailability;
@ -273,7 +274,6 @@ public class Network implements Comparable<Network> {
/** /**
* present only for serializer * present only for serializer
*
*/ */
Network() { Network() {
@ -317,7 +317,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return network id * @return network id
*/ */
public long getId() { public long getId() {
@ -325,7 +324,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the name of the account to which the template beLongs * @return the name of the account to which the template beLongs
*/ */
public String getAccount() { public String getAccount() {
@ -333,7 +331,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return Broadcast domain type of the network * @return Broadcast domain type of the network
*/ */
public String getBroadcastDomainType() { public String getBroadcastDomainType() {
@ -341,7 +338,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return broadcast uri of the network * @return broadcast uri of the network
*/ */
public URI getBroadcastURI() { public URI getBroadcastURI() {
@ -349,7 +345,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the display text of the zone * @return the display text of the zone
*/ */
public String getDisplayText() { public String getDisplayText() {
@ -357,7 +352,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the external DNS for the network * @return the external DNS for the network
*/ */
public List<String> getDNS() { public List<String> getDNS() {
@ -370,7 +364,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return Domain name for the Vms in the zone * @return Domain name for the Vms in the zone
*/ */
public String getDomain() { public String getDomain() {
@ -378,7 +371,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the ID of the containing domain, null for public zones * @return the ID of the containing domain, null for public zones
*/ */
@Nullable @Nullable
@ -387,7 +379,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the end ip of the network * @return the end ip of the network
*/ */
public String getEndIP() { public String getEndIP() {
@ -395,7 +386,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the network's gateway * @return the network's gateway
*/ */
public String getGateway() { public String getGateway() {
@ -403,7 +393,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return true if network offering is default, false otherwise * @return true if network offering is default, false otherwise
*/ */
public boolean isDefault() { public boolean isDefault() {
@ -411,7 +400,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return true if network offering is shared, false otherwise * @return true if network offering is shared, false otherwise
*/ */
public boolean isShared() { public boolean isShared() {
@ -419,7 +407,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return true if network offering is system, false otherwise * @return true if network offering is system, false otherwise
*/ */
public boolean isSystem() { public boolean isSystem() {
@ -427,7 +414,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return network name * @return network name
*/ */
public String getName() { public String getName() {
@ -435,7 +421,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the GuestIPType of the network * @return the GuestIPType of the network
*/ */
public GuestIPType getGuestIPType() { public GuestIPType getGuestIPType() {
@ -443,7 +428,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return state of the network * @return state of the network
*/ */
public String getState() { public String getState() {
@ -451,7 +435,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the vlan range of the zone * @return the vlan range of the zone
*/ */
public String getVLAN() { public String getVLAN() {
@ -459,7 +442,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the traffic type for this network offering * @return the traffic type for this network offering
*/ */
public TrafficType getTrafficType() { public TrafficType getTrafficType() {
@ -467,7 +449,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the network's netmask * @return the network's netmask
*/ */
public String getNetmask() { public String getNetmask() {
@ -475,7 +456,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the network domain * @return the network domain
*/ */
public String getNetworkDomain() { public String getNetworkDomain() {
@ -483,7 +463,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return availability of the network offering the network is created from * @return availability of the network offering the network is created from
*/ */
public String getNetworkOfferingAvailability() { public String getNetworkOfferingAvailability() {
@ -491,7 +470,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return display text of the network offering the network is created from * @return display text of the network offering the network is created from
*/ */
public String getNetworkOfferingDisplayText() { public String getNetworkOfferingDisplayText() {
@ -499,7 +477,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return network offering id the network is created from * @return network offering id the network is created from
*/ */
public long getNetworkOfferingId() { public long getNetworkOfferingId() {
@ -507,7 +484,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return name of the network offering the network is created from * @return name of the network offering the network is created from
*/ */
public String getNetworkOfferingName() { public String getNetworkOfferingName() {
@ -515,7 +491,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return related to what other network configuration * @return related to what other network configuration
*/ */
public long getRelated() { public long getRelated() {
@ -523,7 +498,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the start ip of the network * @return the start ip of the network
*/ */
public String getStartIP() { public String getStartIP() {
@ -531,7 +505,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return zone id of the network * @return zone id of the network
*/ */
public long getZoneId() { public long getZoneId() {
@ -539,7 +512,6 @@ public class Network implements Comparable<Network> {
} }
/** /**
*
* @return the list of services * @return the list of services
*/ */
public Set<? extends NetworkService> getServices() { public Set<? extends NetworkService> getServices() {
@ -716,7 +688,7 @@ public class Network implements Comparable<Network> {
+ account + ", startIP=" + startIP + ", endIP=" + endIP + ", netmask=" + netmask + ", gateway=" + gateway + account + ", startIP=" + startIP + ", endIP=" + endIP + ", netmask=" + netmask + ", gateway=" + gateway
+ ", broadcastDomainType=" + broadcastDomainType + ", broadcastURI=" + broadcastURI + ", services=" + ", broadcastDomainType=" + broadcastDomainType + ", broadcastURI=" + broadcastURI + ", services="
+ services + ", domain=" + domain + ", domainId=" + domainId + ", isDefault=" + isDefault + ", isShared=" + services + ", domain=" + domain + ", domainId=" + domainId + ", isDefault=" + isDefault + ", isShared="
+ isShared + ", isSystem=" + isSystem + ", related=" + related + ", zoneId=" + zoneId + ", networkDomain=" + isShared + ", isSystem=" + isSystem + ", related=" + related + ", zoneId=" + zoneId + ", domain="
+ networkDomain + ", networkOfferingAvailability=" + networkOfferingAvailability + networkDomain + ", networkOfferingAvailability=" + networkOfferingAvailability
+ ", networkOfferingDisplayText=" + networkOfferingDisplayText + ", networkOfferingId=" + networkOfferingId + ", networkOfferingDisplayText=" + networkOfferingDisplayText + ", networkOfferingId=" + networkOfferingId
+ ", networkOfferingName=" + networkOfferingName + "]"; + ", networkOfferingName=" + networkOfferingName + "]";

View File

@ -128,7 +128,7 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
this.IPAddressId = iPAddressId; this.IPAddressId = iPAddressId;
this.privatePort = privatePort; this.privatePort = privatePort;
this.protocol = protocol; this.protocol = protocol;
this.publicPort = publicPort+""; this.publicPort = publicPort + "";
this.state = state; this.state = state;
this.virtualMachineDisplayName = virtualMachineDisplayName; this.virtualMachineDisplayName = virtualMachineDisplayName;
this.virtualMachineId = virtualMachineId; this.virtualMachineId = virtualMachineId;

View File

@ -333,7 +333,8 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
/** /**
* *
* @return State of the ip address. Can be: Allocating, Allocated and Releasing * @return State of the ip address. Can be: Allocating, Allocated and
* Releasing
*/ */
public State getState() { public State getState() {
return state; return state;
@ -341,8 +342,8 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
/** /**
* *
* @return virtual machine display name the ip address is assigned to (not null only for static * @return virtual machine display name the ip address is assigned to (not
* nat Ip) * null only for static nat Ip)
*/ */
public String getVirtualMachineDisplayName() { public String getVirtualMachineDisplayName() {
return virtualMachineDisplayName; return virtualMachineDisplayName;
@ -350,7 +351,8 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
/** /**
* *
* @return virtual machine id the ip address is assigned to (not null only for static nat Ip) * @return virtual machine id the ip address is assigned to (not null only
* for static nat Ip)
*/ */
public long getVirtualMachineId() { public long getVirtualMachineId() {
return virtualMachineId; return virtualMachineId;
@ -358,7 +360,8 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
/** /**
* *
* @return virtual machine name the ip address is assigned to (not null only for static nat Ip) * @return virtual machine name the ip address is assigned to (not null only
* for static nat Ip)
*/ */
public String getVirtualMachineName() { public String getVirtualMachineName() {
return virtualMachineName; return virtualMachineName;

View File

@ -29,7 +29,6 @@ public class SSHKeyPair implements Comparable<SSHKeyPair> {
return this; return this;
} }
public SSHKeyPair build() { public SSHKeyPair build() {
return new SSHKeyPair(fingerprint, name, privateKey); return new SSHKeyPair(fingerprint, name, privateKey);
} }
@ -112,5 +111,4 @@ public class SSHKeyPair implements Comparable<SSHKeyPair> {
return fingerprint.compareTo(arg0.getFingerprint()); return fingerprint.compareTo(arg0.getFingerprint());
} }
} }

View File

@ -523,8 +523,8 @@ public class Template implements Comparable<Template> {
/** /**
* *
* @return shows the current pending asynchronous job ID, or null if current pending jobs are * @return shows the current pending asynchronous job ID, or null if current
* acting on the template * pending jobs are acting on the template
*/ */
@Nullable @Nullable
public Long getJobId() { public Long getJobId() {

View File

@ -37,7 +37,8 @@ public enum TemplateFilter {
*/ */
SELF, SELF,
/** /**
* templates that have been registered/created by the owner that can be used to deploy a new VM * templates that have been registered/created by the owner that can be used
* to deploy a new VM
*/ */
SELF_EXECUTABLE, SELF_EXECUTABLE,
/** /**

View File

@ -38,15 +38,18 @@ public enum TrafficType {
*/ */
GUEST, GUEST,
/** /**
* System network that only Admin can view, and only when isSystem is specified. * System network that only Admin can view, and only when isSystem is
* specified.
*/ */
STORAGE, STORAGE,
/** /**
* System network that only Admin can view, and only when isSystem is specified. * System network that only Admin can view, and only when isSystem is
* specified.
*/ */
MANAGEMENT, MANAGEMENT,
/** /**
* System network that only Admin can view, and only when isSystem is specified. * System network that only Admin can view, and only when isSystem is
* specified.
*/ */
CONTROL, CONTROL,

View File

@ -329,8 +329,8 @@ public class User implements Comparable<User> {
return String return String
.format( .format(
"[id=%s, name=%s, state=%s, created=%s, account=%s, accountType=%s, domain=%s, domainId=%s, email=%s, firstName=%s, lastName=%s, apiKey=%s, secretKey=%s, timeZone=%s]", "[id=%s, name=%s, state=%s, created=%s, account=%s, accountType=%s, domain=%s, domainId=%s, email=%s, firstName=%s, lastName=%s, apiKey=%s, secretKey=%s, timeZone=%s]",
id, name, state, created, account, accountType, domain, domainId, email, firstName, lastName, id, name, state, created, account, accountType, domain, domainId, email, firstName, lastName, apiKey,
apiKey, secretKey, timeZone); secretKey, timeZone);
} }
} }

View File

@ -289,11 +289,10 @@ public class VirtualMachine implements Comparable<VirtualMachine> {
public VirtualMachine build() { public VirtualMachine build() {
return new VirtualMachine(id, account, cpuCount, cpuSpeed, cpuUsed, displayName, created, domain, domainId, return new VirtualMachine(id, account, cpuCount, cpuSpeed, cpuUsed, displayName, created, domain, domainId,
usesVirtualNetwork, group, groupId, guestOSId, HAEnabled, hostId, hostname, IPAddress, usesVirtualNetwork, group, groupId, guestOSId, HAEnabled, hostId, hostname, IPAddress, ISODisplayText,
ISODisplayText, ISOId, ISOName, jobId, jobStatus, memory, name, networkKbsRead, networkKbsWrite, ISOId, ISOName, jobId, jobStatus, memory, name, networkKbsRead, networkKbsWrite, password,
password, passwordEnabled, rootDeviceId, rootDeviceType, securityGroups, serviceOfferingId, passwordEnabled, rootDeviceId, rootDeviceType, securityGroups, serviceOfferingId, serviceOfferingName,
serviceOfferingName, state, templateDisplayText, templateId, templateName, zoneId, zoneName, nics, state, templateDisplayText, templateId, templateName, zoneId, zoneName, nics, hypervisor);
hypervisor);
} }
} }
@ -395,8 +394,8 @@ public class VirtualMachine implements Comparable<VirtualMachine> {
long iSOId, String iSOName, Long jobId, Integer jobStatus, long memory, String name, Long networkKbsRead, long iSOId, String iSOName, Long jobId, Integer 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<SecurityGroup> securityGroups, 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<NIC> nics,
Set<NIC> nics, String hypervisor) { String hypervisor) {
this.id = id; this.id = id;
this.account = account; this.account = account;
this.cpuCount = cpuCount; this.cpuCount = cpuCount;
@ -483,8 +482,8 @@ public class VirtualMachine implements Comparable<VirtualMachine> {
} }
/** /**
* @return user generated name. The name of the virtual machine is returned if no displayname * @return user generated name. The name of the virtual machine is returned
* exists. * if no displayname exists.
*/ */
public String getDisplayName() { public String getDisplayName() {
return displayName; return displayName;
@ -574,7 +573,8 @@ public class VirtualMachine implements Comparable<VirtualMachine> {
} }
/** /**
* @return an alternate display text of the ISO attached to the virtual machine * @return an alternate display text of the ISO attached to the virtual
* machine
*/ */
public String getISODisplayText() { public String getISODisplayText() {
return ISODisplayText; return ISODisplayText;
@ -595,8 +595,9 @@ public class VirtualMachine implements Comparable<VirtualMachine> {
} }
/** /**
* @return shows the current pending asynchronous job ID. This tag is not returned if no current * @return shows the current pending asynchronous job ID. This tag is not
* pending jobs are acting on the virtual machine * returned if no current pending jobs are acting on the virtual
* machine
*/ */
@Nullable @Nullable
public Long getJobId() { public Long getJobId() {
@ -704,8 +705,8 @@ public class VirtualMachine implements Comparable<VirtualMachine> {
} }
/** /**
* @return the ID of the template for the virtual machine. A -1 is returned if the virtual * @return the ID of the template for the virtual machine. A -1 is returned
* machine was created from an ISO file. * if the virtual machine was created from an ISO file.
*/ */
public long getTemplateId() { public long getTemplateId() {
return templateId; return templateId;
@ -955,18 +956,17 @@ public class VirtualMachine implements Comparable<VirtualMachine> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", account=" + account + ", cpuCount=" + cpuCount + ", cpuSpeed=" + cpuSpeed + ", cpuUsed=" return "[id=" + id + ", account=" + account + ", cpuCount=" + cpuCount + ", cpuSpeed=" + cpuSpeed + ", cpuUsed="
+ cpuUsed + ", displayName=" + displayName + ", created=" + created + ", domain=" + domain + cpuUsed + ", displayName=" + displayName + ", created=" + created + ", domain=" + domain + ", domainId="
+ ", domainId=" + domainId + ", usesVirtualNetwork=" + usesVirtualNetwork + ", group=" + group + domainId + ", usesVirtualNetwork=" + usesVirtualNetwork + ", group=" + group + ", groupId=" + groupId
+ ", groupId=" + groupId + ", guestOSId=" + guestOSId + ", HAEnabled=" + HAEnabled + ", hostId=" + ", guestOSId=" + guestOSId + ", HAEnabled=" + HAEnabled + ", hostId=" + hostId + ", hostname=" + hostname
+ hostId + ", hostname=" + hostname + ", IPAddress=" + IPAddress + ", ISODisplayText=" + ISODisplayText + ", IPAddress=" + IPAddress + ", ISODisplayText=" + ISODisplayText + ", ISOId=" + ISOId + ", ISOName="
+ ", ISOId=" + ISOId + ", ISOName=" + ISOName + ", jobId=" + jobId + ", jobStatus=" + jobStatus + ISOName + ", jobId=" + jobId + ", jobStatus=" + jobStatus + ", memory=" + memory + ", name=" + name
+ ", memory=" + memory + ", name=" + name + ", networkKbsRead=" + networkKbsRead + ", networkKbsWrite=" + ", networkKbsRead=" + networkKbsRead + ", networkKbsWrite=" + networkKbsWrite + ", password=" + password
+ networkKbsWrite + ", password=" + password + ", passwordEnabled=" + passwordEnabled + ", passwordEnabled=" + passwordEnabled + ", rootDeviceId=" + rootDeviceId + ", rootDeviceType="
+ ", rootDeviceId=" + rootDeviceId + ", rootDeviceType=" + rootDeviceType + ", serviceOfferingId=" + rootDeviceType + ", serviceOfferingId=" + serviceOfferingId + ", serviceOfferingName="
+ serviceOfferingId + ", serviceOfferingName=" + serviceOfferingName + ", state=" + state + serviceOfferingName + ", state=" + state + ", templateDisplayText=" + templateDisplayText
+ ", templateDisplayText=" + templateDisplayText + ", templateId=" + templateId + ", templateName=" + ", templateId=" + templateId + ", templateName=" + templateName + ", zoneId=" + zoneId + ", zoneName="
+ templateName + ", zoneId=" + zoneId + ", zoneName=" + zoneName + ", nics=" + nics + ", hypervisor=" + zoneName + ", nics=" + nics + ", hypervisor=" + hypervisor + ", securityGroups=" + securityGroups + "]";
+ hypervisor + ", securityGroups=" + securityGroups + "]";
} }
@Override @Override

View File

@ -42,7 +42,8 @@ public interface AddressClient {
* *
* @param options * @param options
* if present, how to constrain the list. * if present, how to constrain the list.
* @return IPAddresses matching query, or empty set, if no IPAddresses are found * @return IPAddresses matching query, or empty set, if no IPAddresses are
* found
*/ */
Set<PublicIPAddress> listPublicIPAddresses(ListPublicIPAddressesOptions... options); Set<PublicIPAddress> listPublicIPAddresses(ListPublicIPAddressesOptions... options);
@ -59,7 +60,8 @@ public interface AddressClient {
* Acquires and associates a public IP to an account. * Acquires and associates a public IP to an account.
* *
* @param zoneId * @param zoneId
* the ID of the availability zone you want to acquire an public IP address from * the ID of the availability zone you want to acquire an public IP
* address from
* @return IPAddress * @return IPAddress
*/ */
AsyncCreateResponse associateIPAddressInZone(long zoneId, AssociateIPAddressOptions... options); AsyncCreateResponse associateIPAddressInZone(long zoneId, AssociateIPAddressOptions... options);

View File

@ -41,8 +41,8 @@ public interface FirewallClient {
* *
* @param options * @param options
* if present, how to constrain the list. * if present, how to constrain the list.
* @return PortForwardingRules matching query, or empty set, if no PortForwardingRulees are * @return PortForwardingRules matching query, or empty set, if no
* found * PortForwardingRulees are found
*/ */
Set<PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesOptions... options); Set<PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesOptions... options);
@ -52,8 +52,8 @@ public interface FirewallClient {
* @param virtualMachineId * @param virtualMachineId
* the ID of the virtual machine for the port forwarding rule * the ID of the virtual machine for the port forwarding rule
* @param IPAddressId * @param IPAddressId
* the public IP address id of the forwarding rule, already associated via * the public IP address id of the forwarding rule, already
* associatePort * associated via associatePort
* @param protocol * @param protocol
* the protocol for the rule. Valid values are TCP or UDP. * the protocol for the rule. Valid values are TCP or UDP.
* @param privatePort * @param privatePort

View File

@ -57,7 +57,8 @@ public interface GuestOSClient {
/** /**
* Lists all supported OS categories for this cloud. * Lists all supported OS categories for this cloud.
* *
* @return os categories matching query, or empty set, if no categories are found * @return os categories matching query, or empty set, if no categories are
* found
*/ */
Map<Long, String> listOSCategories(); Map<Long, String> listOSCategories();

View File

@ -26,8 +26,8 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.filters.QuerySigner; import org.jclouds.cloudstack.filters.QuerySigner;
import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions; import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions;
import org.jclouds.functions.JoinOnComma; import org.jclouds.functions.JoinOnComma;

View File

@ -22,8 +22,8 @@ import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions; import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
@ -42,7 +42,8 @@ public interface LoadBalancerClient {
* *
* @param options * @param options
* if present, how to constrain the list. * if present, how to constrain the list.
* @return load balancer rules matching query, or empty set, if no load balancer rules are found * @return load balancer rules matching query, or empty set, if no load
* balancer rules are found
*/ */
Set<LoadBalancerRule> listLoadBalancerRules(ListLoadBalancerRulesOptions... options); Set<LoadBalancerRule> listLoadBalancerRules(ListLoadBalancerRulesOptions... options);
@ -59,16 +60,18 @@ public interface LoadBalancerClient {
* Creates a load balancer rule. * Creates a load balancer rule.
* *
* @param publicIPId * @param publicIPId
* the public port from where the network traffic will be load balanced from * the public port from where the network traffic will be load
* balanced from
* @param algorithm * @param algorithm
* load balancer algorithm (source, roundrobin, leastconn) * load balancer algorithm (source, roundrobin, leastconn)
* @param name * @param name
* name of the load balancer rule * name of the load balancer rule
* @param privatePort * @param privatePort
* the private port of the private ip address/virtual machine where the network traffic * the private port of the private ip address/virtual machine where
* will be load balanced to * the network traffic will be load balanced to
* @param publicPort * @param publicPort
* public ip address id from where the network traffic will be load balanced from * public ip address id from where the network traffic will be load
* balanced from
* @return newly created rule * @return newly created rule
*/ */
LoadBalancerRule createLoadBalancerRuleForPublicIP(long publicIPId, Algorithm algorithm, String name, LoadBalancerRule createLoadBalancerRuleForPublicIP(long publicIPId, Algorithm algorithm, String name,
@ -80,63 +83,70 @@ public interface LoadBalancerClient {
* *
* @param id * @param id
* id of the rule to delete * id of the rule to delete
* @return async job id of the job completing or null, if the load balancer rule was not found. * @return async job id of the job completing or null, if the load balancer
* rule was not found.
*/ */
Long deleteLoadBalancerRule(long id); Long deleteLoadBalancerRule(long id);
/** /**
* List all virtual machine instances that are assigned to a load balancer rule. * List all virtual machine instances that are assigned to a load balancer
* rule.
* *
* @param id * @param id
* id of the rule * id of the rule
* @return VirtualMachines matching query, or empty set, if no VirtualMachines are assigned * @return VirtualMachines matching query, or empty set, if no
* VirtualMachines are assigned
*/ */
Set<VirtualMachine> listVirtualMachinesAssignedToLoadBalancerRule(long id); Set<VirtualMachine> listVirtualMachinesAssignedToLoadBalancerRule(long id);
/** /**
* Assigns virtual machine or a list of virtual machines to a load balancer rule. * Assigns virtual machine or a list of virtual machines to a load balancer
* rule.
* *
* @param id * @param id
* the ID of the load balancer rule * the ID of the load balancer rule
* @param virtualMachineIds * @param virtualMachineIds
* the list of IDs of the virtual machine that are being assigned to the load balancer * the list of IDs of the virtual machine that are being assigned
* rule * to the load balancer rule
* @return job id related to the operation * @return job id related to the operation
*/ */
long assignVirtualMachinesToLoadBalancerRule(long id, Iterable<Long> virtualMachineIds); long assignVirtualMachinesToLoadBalancerRule(long id, Iterable<Long> virtualMachineIds);
/** /**
* Assigns virtual machine or a list of virtual machines to a load balancer rule. * Assigns virtual machine or a list of virtual machines to a load balancer
* rule.
* *
* @param id * @param id
* the ID of the load balancer rule * the ID of the load balancer rule
* @param virtualMachineIds * @param virtualMachineIds
* the list of IDs of the virtual machine that are being assigned to the load balancer * the list of IDs of the virtual machine that are being assigned
* rule * to the load balancer rule
* @return job id related to the operation * @return job id related to the operation
*/ */
long assignVirtualMachinesToLoadBalancerRule(long id, long... virtualMachineIds); long assignVirtualMachinesToLoadBalancerRule(long id, long... virtualMachineIds);
/** /**
* Removes a virtual machine or a list of virtual machines from a load balancer rule. * Removes a virtual machine or a list of virtual machines from a load
* balancer rule.
* *
* @param id * @param id
* the ID of the load balancer rule * the ID of the load balancer rule
* @param virtualMachineIds * @param virtualMachineIds
* the list of IDs of the virtual machine that are being removed from the load balancer * the list of IDs of the virtual machine that are being removed
* rule * from the load balancer rule
* @return job id related to the operation * @return job id related to the operation
*/ */
long removeVirtualMachinesFromLoadBalancerRule(long id, Iterable<Long> virtualMachineIds); long removeVirtualMachinesFromLoadBalancerRule(long id, Iterable<Long> virtualMachineIds);
/** /**
* Removes a virtual machine or a list of virtual machines from a load balancer rule. * Removes a virtual machine or a list of virtual machines from a load
* balancer rule.
* *
* @param id * @param id
* the ID of the load balancer rule * the ID of the load balancer rule
* @param virtualMachineIds * @param virtualMachineIds
* the list of IDs of the virtual machine that are being removed from the load balancer * the list of IDs of the virtual machine that are being removed
* rule * from the load balancer rule
* @return job id related to the operation * @return job id related to the operation
*/ */
long removeVirtualMachinesFromLoadBalancerRule(long id, long... virtualMachineIds); long removeVirtualMachinesFromLoadBalancerRule(long id, long... virtualMachineIds);

View File

@ -42,7 +42,8 @@ public interface NATClient {
* *
* @param options * @param options
* if present, how to constrain the list. * if present, how to constrain the list.
* @return IPForwardingRulees matching query, or empty set, if no IPForwardingRulees are found * @return IPForwardingRulees matching query, or empty set, if no
* IPForwardingRulees are found
*/ */
Set<IPForwardingRule> listIPForwardingRules(ListIPForwardingRulesOptions... options); Set<IPForwardingRule> listIPForwardingRules(ListIPForwardingRulesOptions... options);
@ -59,7 +60,8 @@ public interface NATClient {
* Creates an ip forwarding rule * Creates an ip forwarding rule
* *
* @param IPAddressId * @param IPAddressId
* the public IP address id of the forwarding rule, already associated via associateIp * the public IP address id of the forwarding rule, already
* associated via associateIp
* @param protocol * @param protocol
* the protocol for the rule. Valid values are TCP or UDP. * the protocol for the rule. Valid values are TCP or UDP.
* @param startPort * @param startPort

View File

@ -77,8 +77,8 @@ public interface NetworkClient {
* *
* @param id * @param id
* the ID of the network * the ID of the network
* @return job id related to destroying the network, or null if resource was not * @return job id related to destroying the network, or null if resource was
* found * not found
*/ */
Long deleteNetwork(long id); Long deleteNetwork(long id);
} }

View File

@ -44,7 +44,8 @@ public interface OfferingClient {
* *
* @param options * @param options
* if present, how to constrain the list. * if present, how to constrain the list.
* @return service offerings matching query, or empty set, if no service offerings are found * @return service offerings matching query, or empty set, if no service
* offerings are found
*/ */
Set<ServiceOffering> listServiceOfferings(ListServiceOfferingsOptions... options); Set<ServiceOffering> listServiceOfferings(ListServiceOfferingsOptions... options);
@ -62,7 +63,8 @@ public interface OfferingClient {
* *
* @param options * @param options
* if present, how to constrain the list. * if present, how to constrain the list.
* @return disk offerings matching query, or empty set, if no disk offerings are found * @return disk offerings matching query, or empty set, if no disk offerings
* are found
*/ */
Set<DiskOffering> listDiskOfferings(ListDiskOfferingsOptions... options); Set<DiskOffering> listDiskOfferings(ListDiskOfferingsOptions... options);
@ -80,7 +82,8 @@ public interface OfferingClient {
* *
* @param options * @param options
* if present, how to constrain the list. * if present, how to constrain the list.
* @return service offerings matching query, or empty set, if no service offerings are found * @return service offerings matching query, or empty set, if no service
* offerings are found
*/ */
Set<NetworkOffering> listNetworkOfferings(ListNetworkOfferingsOptions... options); Set<NetworkOffering> listNetworkOfferings(ListNetworkOfferingsOptions... options);

View File

@ -18,30 +18,51 @@
*/ */
package org.jclouds.cloudstack.features; package org.jclouds.cloudstack.features;
import com.google.common.util.concurrent.ListenableFuture; import java.util.Set;
import org.jclouds.cloudstack.filters.QuerySigner;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.jclouds.cloudstack.domain.SSHKeyPair;
import org.jclouds.cloudstack.filters.QuerySigner;
import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import com.google.common.util.concurrent.ListenableFuture;
@RequestFilters(QuerySigner.class) @RequestFilters(QuerySigner.class)
@QueryParams(keys = "response", values = "json") @QueryParams(keys = "response", values = "json")
public interface SSHKeyPairAsyncClient { public interface SSHKeyPairAsyncClient {
/** /**
* @see AccountClient#listAccounts * @see org.jclouds.cloudstack.features.SSHKeyPairClient#listSSHKeyPairs
*/ */
@GET @GET
@QueryParams(keys = "command", values = "listSSHKeyPairs") @QueryParams(keys = "command", values = "listSSHKeyPairs")
// @SelectJson("") @SelectJson("keypair")
// @Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
// @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
// ListenableFuture<Set<SSHKeyPair>> listSSHKeyPairs(); ListenableFuture<Set<SSHKeyPair>> listSSHKeyPairs(ListSSHKeyPairsOptions... options);
ListenableFuture<String> listSSHKeyPairs();
@GET @GET
@QueryParams(keys = "command", values="createSSHKeyPair") @QueryParams(keys = "command", values = "createSSHKeyPair")
ListenableFuture<String> createSSHKeyPair(@QueryParam("name") String name); @SelectJson("keypair")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<SSHKeyPair> createSSHKeyPair(@QueryParam("name") String name);
@GET
@QueryParams(keys = "command", values = "listSSHKeyPairs")
@SelectJson("keypair")
@OnlyElement()
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<SSHKeyPair> getSSHKeyPair(@QueryParam("name") String name);
} }

View File

@ -1,22 +1,27 @@
package org.jclouds.cloudstack.features; package org.jclouds.cloudstack.features;
import org.jclouds.concurrent.Timeout; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.cloudstack.domain.SSHKeyPair;
import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions;
import org.jclouds.concurrent.Timeout;
/** /**
* Provides synchronous access to CloudStack SSHKeyPair features. * Provides synchronous access to CloudStack SSHKeyPair features.
* <p/> * <p/>
* *
* @author Adrian Cole * @author Adrian Cole
* @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.8/user/listSSHKeyPairs.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api_2.2.8/user/listSSHKeyPairs.html"
* />
*/ */
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
public interface SSHKeyPairClient { public interface SSHKeyPairClient {
String listSSHKeyPairs(); Set<SSHKeyPair> listSSHKeyPairs(ListSSHKeyPairsOptions... options);
String createSSHKeyPair(String name); SSHKeyPair createSSHKeyPair(String name);
SSHKeyPair getSSHKeyPair(String name);
} }

View File

@ -107,10 +107,8 @@ public interface SecurityGroupAsyncClient {
@QueryParams(keys = "command", values = "authorizeSecurityGroupIngress") @QueryParams(keys = "command", values = "authorizeSecurityGroupIngress")
@Unwrap(depth = 2) @Unwrap(depth = 2)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Long> authorizeIngressPortsToSecurityGroups( ListenableFuture<Long> authorizeIngressPortsToSecurityGroups(@QueryParam("securitygroupid") long securityGroupId,
@QueryParam("securitygroupid") long securityGroupId, @QueryParam("protocol") String protocol, @QueryParam("startport") int startPort,
@QueryParam("protocol") String protocol,
@QueryParam("startport") int startPort,
@QueryParam("endport") int endPort, @QueryParam("endport") int endPort,
@BinderParam(BindAccountSecurityGroupPairsToIndexedQueryParams.class) Multimap<String, String> accountToGroup, @BinderParam(BindAccountSecurityGroupPairsToIndexedQueryParams.class) Multimap<String, String> accountToGroup,
AccountInDomainOptions... options); AccountInDomainOptions... options);
@ -134,10 +132,8 @@ public interface SecurityGroupAsyncClient {
@QueryParams(keys = { "command", "protocol" }, values = { "authorizeSecurityGroupIngress", "ICMP" }) @QueryParams(keys = { "command", "protocol" }, values = { "authorizeSecurityGroupIngress", "ICMP" })
@Unwrap(depth = 2) @Unwrap(depth = 2)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Long> authorizeIngressICMPToSecurityGroups( ListenableFuture<Long> authorizeIngressICMPToSecurityGroups(@QueryParam("securitygroupid") long securityGroupId,
@QueryParam("securitygroupid") long securityGroupId, @QueryParam("icmpcode") int ICMPCode, @QueryParam("icmptype") int ICMPType,
@QueryParam("icmpcode") int ICMPCode,
@QueryParam("icmptype") int ICMPType,
@BinderParam(BindAccountSecurityGroupPairsToIndexedQueryParams.class) Multimap<String, String> accountToGroup, @BinderParam(BindAccountSecurityGroupPairsToIndexedQueryParams.class) Multimap<String, String> accountToGroup,
AccountInDomainOptions... options); AccountInDomainOptions... options);

View File

@ -43,7 +43,8 @@ public interface SecurityGroupClient {
* *
* @param options * @param options
* if present, how to constrain the list. * if present, how to constrain the list.
* @return security groups matching query, or empty set, if no security groups are found * @return security groups matching query, or empty set, if no security
* groups are found
*/ */
Set<SecurityGroup> listSecurityGroups(ListSecurityGroupsOptions... options); Set<SecurityGroup> listSecurityGroups(ListSecurityGroupsOptions... options);
@ -77,11 +78,12 @@ public interface SecurityGroupClient {
* @param endPort * @param endPort
* end port for this ingress rule * end port for this ingress rule
* @param accountToGroup * @param accountToGroup
* mapping of account names to security groups you wish to authorize * mapping of account names to security groups you wish to
* authorize
* @return response relating to the creation of this ingress rule * @return response relating to the creation of this ingress rule
*/ */
long authorizeIngressPortsToSecurityGroups(long securityGroupId, String protocol, int startPort, long authorizeIngressPortsToSecurityGroups(long securityGroupId, String protocol, int startPort, int endPort,
int endPort, Multimap<String, String> accountToGroup, AccountInDomainOptions... options); Multimap<String, String> accountToGroup, AccountInDomainOptions... options);
/** /**
* Authorizes a particular ICMP ingress rule for this security group * Authorizes a particular ICMP ingress rule for this security group
@ -96,8 +98,8 @@ public interface SecurityGroupClient {
* the cidr list associated * the cidr list associated
* @return response relating to the creation of this ingress rule * @return response relating to the creation of this ingress rule
*/ */
long authorizeIngressICMPToCIDRs(long securityGroupId, int ICMPCode, int ICMPType, long authorizeIngressICMPToCIDRs(long securityGroupId, int ICMPCode, int ICMPType, Iterable<String> cidrList,
Iterable<String> cidrList, AccountInDomainOptions... options); AccountInDomainOptions... options);
/** /**
* Authorizes a particular ICMP ingress rule for this security group * Authorizes a particular ICMP ingress rule for this security group
@ -109,7 +111,8 @@ public interface SecurityGroupClient {
* @param ICMPType * @param ICMPType
* error code for this icmp message * error code for this icmp message
* @param accountToGroup * @param accountToGroup
* mapping of account names to security groups you wish to authorize * mapping of account names to security groups you wish to
* authorize
* @return response relating to the creation of this ingress rule * @return response relating to the creation of this ingress rule
*/ */
long authorizeIngressICMPToSecurityGroups(long securityGroupId, int ICMPCode, int ICMPType, long authorizeIngressICMPToSecurityGroups(long securityGroupId, int ICMPCode, int ICMPType,
@ -118,8 +121,10 @@ public interface SecurityGroupClient {
/** /**
* Deletes a particular ingress rule from this security group * Deletes a particular ingress rule from this security group
* *
* @param id The ID of the ingress rule * @param id
* @param options scope of the rule. * The ID of the ingress rule
* @param options
* scope of the rule.
*/ */
long revokeIngressRule(long id, AccountInDomainOptions... options);; long revokeIngressRule(long id, AccountInDomainOptions... options);;

View File

@ -47,7 +47,8 @@ public interface TemplateClient {
* List all public, private, and privileged templates. * List all public, private, and privileged templates.
* *
* @param options * @param options
* if present, how to constrain the list, defaults to all executable templates * if present, how to constrain the list, defaults to all
* executable templates
* @return templates matching query, or empty set, if no templates are found * @return templates matching query, or empty set, if no templates are found
* @see TemplateFilter * @see TemplateFilter
*/ */

View File

@ -81,8 +81,8 @@ public interface VirtualMachineAsyncClient {
@QueryParams(keys = "command", values = "deployVirtualMachine") @QueryParams(keys = "command", values = "deployVirtualMachine")
@Unwrap @Unwrap
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<AsyncCreateResponse> deployVirtualMachineInZone( @QueryParam("zoneid") long zoneId, @QueryParam("serviceofferingid") long serviceOfferingId, ListenableFuture<AsyncCreateResponse> deployVirtualMachineInZone(@QueryParam("zoneid") long zoneId,
@QueryParam("templateid") long templateId, @QueryParam("serviceofferingid") long serviceOfferingId, @QueryParam("templateid") long templateId,
DeployVirtualMachineOptions... options); DeployVirtualMachineOptions... options);
/** /**

View File

@ -42,7 +42,8 @@ public interface VirtualMachineClient {
* *
* @param options * @param options
* if present, how to constrain the list. * if present, how to constrain the list.
* @return VirtualMachines matching query, or empty set, if no VirtualMachines are found * @return VirtualMachines matching query, or empty set, if no
* VirtualMachines are found
*/ */
Set<VirtualMachine> listVirtualMachines(ListVirtualMachinesOptions... options); Set<VirtualMachine> listVirtualMachines(ListVirtualMachinesOptions... options);
@ -56,8 +57,8 @@ public interface VirtualMachineClient {
VirtualMachine getVirtualMachine(long id); VirtualMachine getVirtualMachine(long id);
/** /**
* Creates and automatically starts a virtual machine based on a service offering, disk offering, * Creates and automatically starts a virtual machine based on a service
* and template. * offering, disk offering, and template.
* *
* @param zoneId * @param zoneId
* availability zone for the virtual machine * availability zone for the virtual machine
@ -99,8 +100,9 @@ public interface VirtualMachineClient {
Long stopVirtualMachine(long id); Long stopVirtualMachine(long id);
/** /**
* Resets the password for virtual machine. The virtual machine must be in a "Stopped" state and * Resets the password for virtual machine. The virtual machine must be in a
* the template must already support this feature for this command to take effect. * "Stopped" state and the template must already support this feature for
* this command to take effect.
* *
* @param id * @param id
* The ID of the virtual machine * The ID of the virtual machine
@ -109,8 +111,8 @@ public interface VirtualMachineClient {
Long resetPasswordForVirtualMachine(long id); Long resetPasswordForVirtualMachine(long id);
/** /**
* Changes the service offering for a virtual machine. The virtual machine must be in a "Stopped" * Changes the service offering for a virtual machine. The virtual machine
* state for this command to take effect. * must be in a "Stopped" state for this command to take effect.
* *
* @param id * @param id
* The ID of the virtual machine * The ID of the virtual machine
@ -128,11 +130,13 @@ public interface VirtualMachineClient {
Long updateVirtualMachine(long id); Long updateVirtualMachine(long id);
/** /**
* Destroys a virtual machine. Once destroyed, only the administrator can recover it. * Destroys a virtual machine. Once destroyed, only the administrator can
* recover it.
* *
* @param id * @param id
* vm to destroy * vm to destroy
* @return job id related to destroying the VM, or null if resource was not found * @return job id related to destroying the VM, or null if resource was not
* found
*/ */
Long destroyVirtualMachine(long id); Long destroyVirtualMachine(long id);
} }

View File

@ -42,7 +42,8 @@ public class ParseAsyncJobFromHttpResponse implements Function<HttpResponse, Asy
private final ParseTypedAsyncJob parseTyped; private final ParseTypedAsyncJob parseTyped;
@Inject @Inject
public ParseAsyncJobFromHttpResponse(ParseTypedAsyncJob parseTyped, UnwrapOnlyJsonValue<AsyncJob<Map<String, JsonBall>>> parser) { public ParseAsyncJobFromHttpResponse(ParseTypedAsyncJob parseTyped,
UnwrapOnlyJsonValue<AsyncJob<Map<String, JsonBall>>> parser) {
this.parseTyped = checkNotNull(parseTyped, "parseTyped"); this.parseTyped = checkNotNull(parseTyped, "parseTyped");
this.parser = checkNotNull(parser, "parser"); this.parser = checkNotNull(parser, "parser");
} }

View File

@ -74,8 +74,9 @@ public class ParseNamesFromHttpResponse implements Function<HttpResponse, Set<St
@Inject @Inject
public ParseNamesFromHttpResponse(GsonWrapper gsonWrapper) { public ParseNamesFromHttpResponse(GsonWrapper gsonWrapper) {
this.parser = new ParseFirstJsonValueNamed<Set<Name>>(checkNotNull(gsonWrapper, "gsonWrapper"), new TypeLiteral<Set<Name>>(){}, this.parser = new ParseFirstJsonValueNamed<Set<Name>>(checkNotNull(gsonWrapper, "gsonWrapper"),
"hypervisor"); new TypeLiteral<Set<Name>>() {
}, "hypervisor");
} }
public Set<String> apply(HttpResponse response) { public Set<String> apply(HttpResponse response) {

View File

@ -28,6 +28,7 @@ import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.cloudstack.domain.AsyncJob; import org.jclouds.cloudstack.domain.AsyncJob;
import org.jclouds.cloudstack.domain.AsyncJob.Builder;
import org.jclouds.cloudstack.domain.AsyncJobError; import org.jclouds.cloudstack.domain.AsyncJobError;
import org.jclouds.cloudstack.domain.IPForwardingRule; import org.jclouds.cloudstack.domain.IPForwardingRule;
import org.jclouds.cloudstack.domain.Network; import org.jclouds.cloudstack.domain.Network;
@ -36,7 +37,6 @@ import org.jclouds.cloudstack.domain.PublicIPAddress;
import org.jclouds.cloudstack.domain.SecurityGroup; import org.jclouds.cloudstack.domain.SecurityGroup;
import org.jclouds.cloudstack.domain.Template; import org.jclouds.cloudstack.domain.Template;
import org.jclouds.cloudstack.domain.VirtualMachine; import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.domain.AsyncJob.Builder;
import org.jclouds.domain.JsonBall; import org.jclouds.domain.JsonBall;
import org.jclouds.json.Json; import org.jclouds.json.Json;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
@ -60,8 +60,8 @@ public class ParseTypedAsyncJob implements Function<AsyncJob<Map<String, JsonBal
@VisibleForTesting @VisibleForTesting
@Named("jclouds.cloudstack.jobresult-type-map") @Named("jclouds.cloudstack.jobresult-type-map")
Map<String, Class<?>> typeMap = ImmutableMap.<String, Class<?>> builder().put("securitygroup", SecurityGroup.class) Map<String, Class<?>> typeMap = ImmutableMap.<String, Class<?>> builder().put("securitygroup", SecurityGroup.class)
.put("portforwardingrule", PortForwardingRule.class).put("ipforwardingrule", IPForwardingRule.class).put( .put("portforwardingrule", PortForwardingRule.class).put("ipforwardingrule", IPForwardingRule.class)
"template", Template.class).put("network", Network.class).put("ipaddress", PublicIPAddress.class) .put("template", Template.class).put("network", Network.class).put("ipaddress", PublicIPAddress.class)
.put("virtualmachine", VirtualMachine.class).build(); .put("virtualmachine", VirtualMachine.class).build();
private final Json json; private final Json json;
@ -74,7 +74,7 @@ public class ParseTypedAsyncJob implements Function<AsyncJob<Map<String, JsonBal
AsyncJob<?> result = toParse; AsyncJob<?> result = toParse;
if (toParse.getResult() != null) { if (toParse.getResult() != null) {
if (toParse.getResult().size() == 1) { if (toParse.getResult().size() == 1) {
@SuppressWarnings( { "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
Builder<Object> builder = AsyncJob.Builder.fromAsyncJobUntyped((AsyncJob) toParse); Builder<Object> builder = AsyncJob.Builder.fromAsyncJobUntyped((AsyncJob) toParse);
if (toParse.getResult().containsKey("success")) { if (toParse.getResult().containsKey("success")) {
builder.result(null); builder.result(null);
@ -83,8 +83,7 @@ public class ParseTypedAsyncJob implements Function<AsyncJob<Map<String, JsonBal
if (typeMap.containsKey(entry.getKey())) { if (typeMap.containsKey(entry.getKey())) {
builder.result(json.fromJson(entry.getValue().toString(), typeMap.get(entry.getKey()))); builder.result(json.fromJson(entry.getValue().toString(), typeMap.get(entry.getKey())));
} else { } else {
logger logger.warn(
.warn(
"type key %s not configured. please override default for Map<String, Class<?>> bound to name jclouds.cloudstack.jobresult-type-map", "type key %s not configured. please override default for Map<String, Class<?>> bound to name jclouds.cloudstack.jobresult-type-map",
entry.getKey()); entry.getKey());
builder.result(entry.getValue().toString()); builder.result(entry.getValue().toString());
@ -92,16 +91,16 @@ public class ParseTypedAsyncJob implements Function<AsyncJob<Map<String, JsonBal
} }
result = builder.build(); result = builder.build();
} else if (toParse.getResult().containsKey("errorcode")) { } else if (toParse.getResult().containsKey("errorcode")) {
@SuppressWarnings( { "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
Builder<Object> builder = AsyncJob.Builder.fromAsyncJobUntyped((AsyncJob) toParse); Builder<Object> builder = AsyncJob.Builder.fromAsyncJobUntyped((AsyncJob) toParse);
builder.result(null);// avoid classcastexceptions builder.result(null);// avoid classcastexceptions
builder.error(new AsyncJobError(Integer.parseInt(toParse.getResult().get("errorcode").toString()), toParse builder.error(new AsyncJobError(Integer.parseInt(toParse.getResult().get("errorcode").toString()), toParse
.getResult().containsKey("errortext") ? toParse.getResult().get("errortext").toString().replace( .getResult().containsKey("errortext") ? toParse.getResult().get("errortext").toString()
"\"", "") : null)); .replace("\"", "") : null));
result = builder.build(); result = builder.build();
} else if (toParse.getResult().size() > 1) { } else if (toParse.getResult().size() > 1) {
logger.warn("unexpected size of async job result; expecting a map with a single element", toParse logger.warn("unexpected size of async job result; expecting a map with a single element",
.getResult()); toParse.getResult());
} }
} }
return result; return result;

View File

@ -29,9 +29,9 @@ import org.jclouds.util.Throwables2;
import com.google.common.base.Function; import com.google.common.base.Function;
/** /**
* CloudStack is currently sending 431 errors with the text "Unable to find account owner for ip ". * CloudStack is currently sending 431 errors with the text
* In this case, we have to ignore as there's no means for us to avoid the problem, or action to * "Unable to find account owner for ip ". In this case, we have to ignore as
* take. * there's no means for us to avoid the problem, or action to take.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */

View File

@ -58,14 +58,14 @@ public class ReuseOrAssociateNewPublicIPAddress implements Function<Network, Pub
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
@Inject @Inject
public public ReuseOrAssociateNewPublicIPAddress(CloudStackClient client, Predicate<Long> jobComplete) {
ReuseOrAssociateNewPublicIPAddress(CloudStackClient client, Predicate<Long> jobComplete) {
this.client = checkNotNull(client, "client"); this.client = checkNotNull(client, "client");
this.jobComplete = checkNotNull(jobComplete, "jobComplete"); this.jobComplete = checkNotNull(jobComplete, "jobComplete");
} }
/** /**
* Finds existing addresses who are ready for use and not assigned to a machine. * Finds existing addresses who are ready for use and not assigned to a
* machine.
* *
* @param networkId * @param networkId
* network id to search * network id to search
@ -76,8 +76,8 @@ public class ReuseOrAssociateNewPublicIPAddress implements Function<Network, Pub
* if there's no existing ip address that is free for use * if there's no existing ip address that is free for use
*/ */
public static PublicIPAddress findAvailableAndAssociatedWithNetwork(long networkId, AddressClient client) { public static PublicIPAddress findAvailableAndAssociatedWithNetwork(long networkId, AddressClient client) {
return find(client.listPublicIPAddresses(allocatedOnly(true).networkId(networkId)), and( return find(client.listPublicIPAddresses(allocatedOnly(true).networkId(networkId)),
associatedWithNetwork(networkId), available())); and(associatedWithNetwork(networkId), available()));
} }
public static PublicIPAddress associateIPAddressInNetwork(Network network, CloudStackClient client, public static PublicIPAddress associateIPAddressInNetwork(Network network, CloudStackClient client,

View File

@ -23,7 +23,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to acquire and associate a public IP to an account. * Options used to acquire and associate a public IP to an account.
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/associateIpAddress.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api/user/associateIpAddress.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class AssociateIPAddressOptions extends AccountInDomainOptions { public class AssociateIPAddressOptions extends AccountInDomainOptions {

View File

@ -25,7 +25,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to create an ip forwarding rule * Options used to create an ip forwarding rule
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/createIpForwardingRule.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api/user/createIpForwardingRule.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CreateIPForwardingRuleOptions extends BaseHttpRequestOptions { public class CreateIPForwardingRuleOptions extends BaseHttpRequestOptions {

View File

@ -23,7 +23,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what networks information is returned * Options used to control what networks information is returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listNetworks.html" /> * @see <a
* href="http://download.cloud.com/releases/2.2.0/api/user/listNetworks.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CreateNetworkOptions extends AccountInDomainOptions { public class CreateNetworkOptions extends AccountInDomainOptions {

View File

@ -29,7 +29,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what disk offerings are returned * Options used to control what disk offerings are returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/deployVirtualMachine.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api/user/deployVirtualMachine.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class DeployVirtualMachineOptions extends AccountInDomainOptions { public class DeployVirtualMachineOptions extends AccountInDomainOptions {
@ -37,11 +39,13 @@ public class DeployVirtualMachineOptions extends AccountInDomainOptions {
public static final DeployVirtualMachineOptions NONE = new DeployVirtualMachineOptions(); public static final DeployVirtualMachineOptions NONE = new DeployVirtualMachineOptions();
/** /**
* the ID of the disk offering for the virtual machine. If the template is of ISO format, the * the ID of the disk offering for the virtual machine. If the template is of
* diskOfferingId is for the root disk volume. Otherwise this parameter is used to dinidcate the * ISO format, the diskOfferingId is for the root disk volume. Otherwise this
* offering for the data disk volume. If the templateId parameter passed is from a Template * parameter is used to dinidcate the offering for the data disk volume. If
* object, the diskOfferingId refers to a DATA Disk Volume created. If the templateId parameter * the templateId parameter passed is from a Template object, the
* passed is from an ISO object, the diskOfferingId refers to a ROOT Disk Volume created. * 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 * @param id
* the ID of the disk offering * the ID of the disk offering
@ -117,8 +121,8 @@ public class DeployVirtualMachineOptions extends AccountInDomainOptions {
/** /**
* @param securityGroupId * @param securityGroupId
* security group applied to the virtual machine. Should be passed only when vm is * security group applied to the virtual machine. Should be passed
* created from a zone with Basic Network support * only when vm is created from a zone with Basic Network support
*/ */
public DeployVirtualMachineOptions securityGroupId(long securityGroupId) { public DeployVirtualMachineOptions securityGroupId(long securityGroupId) {
this.queryParameters.replaceValues("securitygroupids", ImmutableSet.of(securityGroupId + "")); this.queryParameters.replaceValues("securitygroupids", ImmutableSet.of(securityGroupId + ""));
@ -127,8 +131,8 @@ public class DeployVirtualMachineOptions extends AccountInDomainOptions {
/** /**
* @param securityGroupIds * @param securityGroupIds
* security groups applied to the virtual machine. Should be passed only when vm is * security groups applied to the virtual machine. Should be passed
* created from a zone with Basic Network support * only when vm is created from a zone with Basic Network support
*/ */
public DeployVirtualMachineOptions securityGroupIds(Iterable<Long> securityGroupIds) { public DeployVirtualMachineOptions securityGroupIds(Iterable<Long> securityGroupIds) {
this.queryParameters.replaceValues("securitygroupids", ImmutableSet.of(Joiner.on(',').join(securityGroupIds))); this.queryParameters.replaceValues("securitygroupids", ImmutableSet.of(Joiner.on(',').join(securityGroupIds)));
@ -137,7 +141,8 @@ public class DeployVirtualMachineOptions extends AccountInDomainOptions {
/** /**
* @param dataDiskSize * @param dataDiskSize
* the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId * the arbitrary size for the DATADISK volume. Mutually exclusive
* with diskOfferingId
*/ */
public DeployVirtualMachineOptions dataDiskSize(long dataDiskSize) { public DeployVirtualMachineOptions dataDiskSize(long dataDiskSize) {
checkArgument(!queryParameters.containsKey("diskofferingid"), "Mutually exclusive with diskOfferingId"); checkArgument(!queryParameters.containsKey("diskofferingid"), "Mutually exclusive with diskOfferingId");
@ -147,10 +152,11 @@ public class DeployVirtualMachineOptions extends AccountInDomainOptions {
/** /**
* @param unencodedData * @param unencodedData
* an optional binary data that can be sent to the virtual machine upon a successful * an optional binary data that can be sent to the virtual machine
* deployment. This binary data must be base64 encoded before adding it to the request. * upon a successful deployment. This binary data must be base64
* Currently only HTTP GET is supported. Using HTTP GET (via querystring), you can send * encoded before adding it to the request. Currently only HTTP GET
* up to 2KB of data after base64 encoding. * is supported. Using HTTP GET (via querystring), you can send up
* to 2KB of data after base64 encoding.
*/ */
public DeployVirtualMachineOptions userData(byte[] unencodedData) { public DeployVirtualMachineOptions userData(byte[] unencodedData) {
int length = checkNotNull(unencodedData, "unencodedData").length; int length = checkNotNull(unencodedData, "unencodedData").length;

View File

@ -23,7 +23,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what account information is returned * Options used to control what account information is returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listAccounts.html" /> * @see <a
* href="http://download.cloud.com/releases/2.2.0/api/user/listAccounts.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListAccountsOptions extends AccountInDomainOptions { public class ListAccountsOptions extends AccountInDomainOptions {
@ -50,7 +52,8 @@ public class ListAccountsOptions extends AccountInDomainOptions {
/** /**
* @param state * @param state
* list accounts by state. Valid states are enabled, disabled, and locked. * list accounts by state. Valid states are enabled, disabled, and
* locked.
*/ */
public ListAccountsOptions state(String state) { public ListAccountsOptions state(String state) {
this.queryParameters.replaceValues("state", ImmutableSet.of(state)); this.queryParameters.replaceValues("state", ImmutableSet.of(state));
@ -68,8 +71,8 @@ public class ListAccountsOptions extends AccountInDomainOptions {
/** /**
* @param recursive * @param recursive
* defaults to false, but if true, lists all accounts from the parent specified by the * defaults to false, but if true, lists all accounts from the
* domain id till leaves. * parent specified by the domain id till leaves.
*/ */
public ListAccountsOptions recursive(boolean recursive) { public ListAccountsOptions recursive(boolean recursive) {
this.queryParameters.replaceValues("isrecursive", ImmutableSet.of(recursive + "")); this.queryParameters.replaceValues("isrecursive", ImmutableSet.of(recursive + ""));

View File

@ -30,7 +30,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what asyncJobs information is returned * Options used to control what asyncJobs information is returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listAsyncJobs.html" /> * @see <a
* href="http://download.cloud.com/releases/2.2.0/api/user/listAsyncJobs.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListAsyncJobsOptions extends AccountInDomainOptions { public class ListAsyncJobsOptions extends AccountInDomainOptions {
@ -43,8 +45,8 @@ public class ListAsyncJobsOptions extends AccountInDomainOptions {
* the start date of the async job * the start date of the async job
*/ */
public ListAsyncJobsOptions startDate(Date startDate) { public ListAsyncJobsOptions startDate(Date startDate) {
this.queryParameters.replaceValues("startdate", ImmutableSet.of(dateService this.queryParameters.replaceValues("startdate",
.iso8601SecondsDateFormat(checkNotNull(startDate, "startDate")))); ImmutableSet.of(dateService.iso8601SecondsDateFormat(checkNotNull(startDate, "startDate"))));
return this; return this;
} }

View File

@ -25,7 +25,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what disk offerings are returned * Options used to control what disk offerings are returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listDiskOfferings.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api/user/listDiskOfferings.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListDiskOfferingsOptions extends BaseHttpRequestOptions { public class ListDiskOfferingsOptions extends BaseHttpRequestOptions {

View File

@ -23,7 +23,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what ip forwarding rules are returned * Options used to control what ip forwarding rules are returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listIpForwardingRules.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api/user/listIpForwardingRules.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListIPForwardingRulesOptions extends AccountInDomainOptions { public class ListIPForwardingRulesOptions extends AccountInDomainOptions {

View File

@ -23,7 +23,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what load balancer rules are returned * Options used to control what load balancer rules are returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listLoadBalancerRules.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api/user/listLoadBalancerRules.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListLoadBalancerRulesOptions extends AccountInDomainOptions { public class ListLoadBalancerRulesOptions extends AccountInDomainOptions {

View File

@ -26,7 +26,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what network offerings are returned * Options used to control what network offerings are returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listNetworkOfferings.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api/user/listNetworkOfferings.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListNetworkOfferingsOptions extends BaseHttpRequestOptions { public class ListNetworkOfferingsOptions extends BaseHttpRequestOptions {
@ -38,7 +40,7 @@ public class ListNetworkOfferingsOptions extends BaseHttpRequestOptions {
* the ID of the network offering * the ID of the network offering
*/ */
public ListNetworkOfferingsOptions id(long id) { public ListNetworkOfferingsOptions id(long id) {
this.queryParameters.replaceValues("id", ImmutableSet.of(id+"")); this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));
return this; return this;
} }
@ -89,8 +91,8 @@ public class ListNetworkOfferingsOptions extends BaseHttpRequestOptions {
/** /**
* @param specifyVLAN * @param specifyVLAN
* True if we allow the network supports vlan, false otherwise. If you create network * True if we allow the network supports vlan, false otherwise. If
* using this offering, you must specify vlan. * you create network using this offering, you must specify vlan.
*/ */
public ListNetworkOfferingsOptions specifyVLAN(boolean specifyVLAN) { public ListNetworkOfferingsOptions specifyVLAN(boolean specifyVLAN) {
this.queryParameters.replaceValues("specifyvlan", ImmutableSet.of(specifyVLAN + "")); this.queryParameters.replaceValues("specifyvlan", ImmutableSet.of(specifyVLAN + ""));

View File

@ -27,7 +27,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what networks information is returned * Options used to control what networks information is returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listNetworks.html" /> * @see <a
* href="http://download.cloud.com/releases/2.2.0/api/user/listNetworks.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListNetworksOptions extends BaseHttpRequestOptions { public class ListNetworksOptions extends BaseHttpRequestOptions {
@ -82,8 +84,8 @@ public class ListNetworksOptions extends BaseHttpRequestOptions {
/** /**
* *
* @param account * @param account
* account who will own the VLAN. If VLAN is Zone wide, this parameter should be * account who will own the VLAN. If VLAN is Zone wide, this
* ommited * parameter should be ommited
*/ */
public ListNetworksOptions account(String account) { public ListNetworksOptions account(String account) {
this.queryParameters.replaceValues("account", ImmutableSet.of(account)); this.queryParameters.replaceValues("account", ImmutableSet.of(account));

View File

@ -25,19 +25,24 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what OSType information is returned * Options used to control what OSType information is returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listOsTypes.html" /> * @see <a
* href="http://download.cloud.com/releases/2.2.0/api/user/listOsTypes.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListOSTypesOptions extends BaseHttpRequestOptions { public class ListOSTypesOptions extends BaseHttpRequestOptions {
public static final ListOSTypesOptions NONE = new ListOSTypesOptions(); public static final ListOSTypesOptions NONE = new ListOSTypesOptions();
/** /**
* @param id list by Os type Id * @param id
* list by Os type Id
*/ */
public ListOSTypesOptions id(long id) { public ListOSTypesOptions id(long id) {
this.queryParameters.replaceValues("id", ImmutableSet.of(id + "")); this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));
return this; return this;
} }
/** /**
* @param OSCategoryId * @param OSCategoryId
* list by Os Category id * list by Os Category id
@ -47,7 +52,6 @@ public class ListOSTypesOptions extends BaseHttpRequestOptions {
return this; return this;
} }
public static class Builder { public static class Builder {
/** /**
* @see ListOSTypesOptions#id * @see ListOSTypesOptions#id
@ -57,7 +61,6 @@ public class ListOSTypesOptions extends BaseHttpRequestOptions {
return options.id(id); return options.id(id);
} }
/** /**
* @see ListOSTypesOptions#OSCategoryId * @see ListOSTypesOptions#OSCategoryId
*/ */

View File

@ -23,7 +23,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what port forwarding rules are returned * Options used to control what port forwarding rules are returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listIpForwardingRules.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api/user/listIpForwardingRules.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListPortForwardingRulesOptions extends AccountInDomainOptions { public class ListPortForwardingRulesOptions extends AccountInDomainOptions {

View File

@ -23,7 +23,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what ip addresss information is returned * Options used to control what ip addresss information is returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listIPAddresses.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api/user/listIPAddresses.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListPublicIPAddressesOptions extends AccountInDomainOptions { public class ListPublicIPAddressesOptions extends AccountInDomainOptions {

View File

@ -18,15 +18,17 @@
*/ */
package org.jclouds.cloudstack.options; package org.jclouds.cloudstack.options;
import com.google.common.collect.ImmutableSet;
import org.jclouds.http.options.BaseHttpRequestOptions; import org.jclouds.http.options.BaseHttpRequestOptions;
import com.google.common.collect.ImmutableSet;
public class ListSSHKeyPairsOptions extends BaseHttpRequestOptions { public class ListSSHKeyPairsOptions extends BaseHttpRequestOptions {
public static final ListSSHKeyPairsOptions NONE = new ListSSHKeyPairsOptions(); public static final ListSSHKeyPairsOptions NONE = new ListSSHKeyPairsOptions();
/** /**
* @param name the SSHKeyPair name * @param name
* the SSHKeyPair name
*/ */
public ListSSHKeyPairsOptions name(String name) { public ListSSHKeyPairsOptions name(String name) {
this.queryParameters.replaceValues("name", ImmutableSet.of(name)); this.queryParameters.replaceValues("name", ImmutableSet.of(name));

View File

@ -23,7 +23,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what security groups are returned * Options used to control what security groups are returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listSecurityGroups.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api/user/listSecurityGroups.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListSecurityGroupsOptions extends AssociateIPAddressOptions { public class ListSecurityGroupsOptions extends AssociateIPAddressOptions {
@ -50,8 +52,9 @@ public class ListSecurityGroupsOptions extends AssociateIPAddressOptions {
/** /**
* @param virtualMachineId * @param virtualMachineId
* the ID of the virtual machine. Pass this in if you want to see the available service * the ID of the virtual machine. Pass this in if you want to see
* offering that a virtual machine can be changed to. * the available service offering that a virtual machine can be
* changed to.
*/ */
public ListSecurityGroupsOptions virtualMachineId(long virtualMachineId) { public ListSecurityGroupsOptions virtualMachineId(long virtualMachineId) {
this.queryParameters.replaceValues("virtualmachineid", ImmutableSet.of(virtualMachineId + "")); this.queryParameters.replaceValues("virtualmachineid", ImmutableSet.of(virtualMachineId + ""));

View File

@ -25,7 +25,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what service offerings are returned * Options used to control what service offerings are returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listServiceOfferings.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api/user/listServiceOfferings.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListServiceOfferingsOptions extends BaseHttpRequestOptions { public class ListServiceOfferingsOptions extends BaseHttpRequestOptions {
@ -62,8 +64,9 @@ public class ListServiceOfferingsOptions extends BaseHttpRequestOptions {
/** /**
* @param virtualMachineId * @param virtualMachineId
* the ID of the virtual machine. Pass this in if you want to see the available service * the ID of the virtual machine. Pass this in if you want to see
* offering that a virtual machine can be changed to. * the available service offering that a virtual machine can be
* changed to.
*/ */
public ListServiceOfferingsOptions virtualMachineId(long virtualMachineId) { public ListServiceOfferingsOptions virtualMachineId(long virtualMachineId) {
this.queryParameters.replaceValues("virtualmachineid", ImmutableSet.of(virtualMachineId + "")); this.queryParameters.replaceValues("virtualmachineid", ImmutableSet.of(virtualMachineId + ""));

View File

@ -25,7 +25,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what templates information is returned * Options used to control what templates information is returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listTemplates.html" /> * @see <a
* href="http://download.cloud.com/releases/2.2.0/api/user/listTemplates.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListTemplatesOptions extends AccountInDomainOptions { public class ListTemplatesOptions extends AccountInDomainOptions {

View File

@ -23,7 +23,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what virtual machines information is returned * Options used to control what virtual machines information is returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listVirtualMachines.html" /> * @see <a href=
* "http://download.cloud.com/releases/2.2.0/api/user/listVirtualMachines.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListVirtualMachinesOptions extends AccountInDomainOptions { public class ListVirtualMachinesOptions extends AccountInDomainOptions {
@ -109,8 +111,8 @@ public class ListVirtualMachinesOptions extends AccountInDomainOptions {
/** /**
* @param usesVirtualNetwork * @param usesVirtualNetwork
* list by network type; true if need to list vms using Virtual Network, false * list by network type; true if need to list vms using Virtual
* otherwise * Network, false otherwise
*/ */
public ListVirtualMachinesOptions usesVirtualNetwork(boolean usesVirtualNetwork) { public ListVirtualMachinesOptions usesVirtualNetwork(boolean usesVirtualNetwork) {
this.queryParameters.replaceValues("forvirtualnetwork", ImmutableSet.of(usesVirtualNetwork + "")); this.queryParameters.replaceValues("forvirtualnetwork", ImmutableSet.of(usesVirtualNetwork + ""));

View File

@ -25,7 +25,9 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Options used to control what zones information is returned * Options used to control what zones information is returned
* *
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listZones.html" /> * @see <a
* href="http://download.cloud.com/releases/2.2.0/api/user/listZones.html"
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListZonesOptions extends BaseHttpRequestOptions { public class ListZonesOptions extends BaseHttpRequestOptions {
@ -37,7 +39,7 @@ public class ListZonesOptions extends BaseHttpRequestOptions {
* the ID of the zone * the ID of the zone
*/ */
public ListZonesOptions id(long id) { public ListZonesOptions id(long id) {
this.queryParameters.replaceValues("id", ImmutableSet.of(id+"")); this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));
return this; return this;
} }
@ -46,15 +48,16 @@ public class ListZonesOptions extends BaseHttpRequestOptions {
* the ID of the domain associated with the zone * the ID of the domain associated with the zone
*/ */
public ListZonesOptions domainId(long domainId) { public ListZonesOptions domainId(long domainId) {
this.queryParameters.replaceValues("domainid", ImmutableSet.of(domainId+"")); this.queryParameters.replaceValues("domainid", ImmutableSet.of(domainId + ""));
return this; return this;
} }
/** /**
* @param available * @param available
* true if you want to retrieve all available Zones. False if you only want to return * true if you want to retrieve all available Zones. False if you
* the Zones from which you have at least one VM. Default is false. * only want to return the Zones from which you have at least one
* VM. Default is false.
*/ */
public ListZonesOptions available(boolean available) { public ListZonesOptions available(boolean available) {
this.queryParameters.replaceValues("available", ImmutableSet.of(available + "")); this.queryParameters.replaceValues("available", ImmutableSet.of(available + ""));

View File

@ -39,8 +39,8 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableMap.Builder;
/** /**
* Templates can be present in a zone, and available, but not valid for launch as their hypervisor * Templates can be present in a zone, and available, but not valid for launch
* isn't installed. * as their hypervisor isn't installed.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */

View File

@ -49,8 +49,8 @@ public class OSCategoryIn implements Function<Set<String>, Predicate<Template>>
@Inject @Inject
public OSCategoryIn(CloudStackClient client) { public OSCategoryIn(CloudStackClient client) {
this(Suppliers.ofInstance(checkNotNull(client, "client").getGuestOSClient().listOSCategories()), Suppliers.ofInstance(client this(Suppliers.ofInstance(checkNotNull(client, "client").getGuestOSClient().listOSCategories()), Suppliers
.getGuestOSClient().listOSTypes())); .ofInstance(client.getGuestOSClient().listOSTypes()));
} }
public OSCategoryIn(Supplier<Map<Long, String>> categoriesSupplier, Supplier<Set<OSType>> osTypesSupplier) { public OSCategoryIn(Supplier<Map<Long, String>> categoriesSupplier, Supplier<Set<OSType>> osTypesSupplier) {

View File

@ -74,7 +74,8 @@ public class PublicIPAddressPredicates {
/** /**
* *
* @return true, if the public ip address is associated with the specified network * @return true, if the public ip address is associated with the specified
* network
*/ */
public static Predicate<PublicIPAddress> associatedWithNetwork(final long networkId) { public static Predicate<PublicIPAddress> associatedWithNetwork(final long networkId) {
return new AssociatedWithNetwork(networkId); return new AssociatedWithNetwork(networkId);

View File

@ -109,7 +109,8 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
assert network.getAccount() != null : network; assert network.getAccount() != null : network;
assert network.getBroadcastDomainType() != null : network; assert network.getBroadcastDomainType() != null : network;
assert network.getDisplayText() != null : network; assert network.getDisplayText() != null : network;
assert network.getNetworkDomain() != null : network; // Network domain can be null sometimes
// assert network.getNetworkDomain() != null : network;
assert network.getNetworkOfferingAvailability() != null : network; assert network.getNetworkOfferingAvailability() != null : network;
assert network.getNetworkOfferingDisplayText() != null : network; assert network.getNetworkOfferingDisplayText() != null : network;
assert network.getNetworkOfferingId() > 0 : network; assert network.getNetworkOfferingId() > 0 : network;

View File

@ -65,7 +65,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSH
HttpRequest httpRequest = processor.createRequest(method, ListSSHKeyPairsOptions.Builder.name("jclouds")); HttpRequest httpRequest = processor.createRequest(method, ListSSHKeyPairsOptions.Builder.name("jclouds"));
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&SSHKeyPair=jclouds&domainid=123 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&name=jclouds 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);
@ -78,11 +78,11 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSH
} }
public void testGetSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException { public void testGetSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
Method method = SSHKeyPairAsyncClient.class.getMethod("getSSHKeyPair", long.class); Method method = SSHKeyPairAsyncClient.class.getMethod("getSSHKeyPair", String.class);
HttpRequest httpRequest = processor.createRequest(method, 3l); HttpRequest httpRequest = processor.createRequest(method, "jclouds-keypair");
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&id=3 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&name=jclouds-keypair 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);

View File

@ -18,6 +18,10 @@
*/ */
package org.jclouds.cloudstack.features; package org.jclouds.cloudstack.features;
import static org.testng.Assert.assertEquals;
import java.util.Set;
import org.jclouds.cloudstack.domain.SSHKeyPair; import org.jclouds.cloudstack.domain.SSHKeyPair;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -30,18 +34,20 @@ import org.testng.annotations.Test;
public class SSHKeyPairClientLiveTest extends BaseCloudStackClientLiveTest { public class SSHKeyPairClientLiveTest extends BaseCloudStackClientLiveTest {
public void testListSSHKeyPairs() { public void testListSSHKeyPairs() {
System.out.println(client.getSSHKeyPairClient().listSSHKeyPairs()); final Set<SSHKeyPair> sshKeyPairs = client.getSSHKeyPairClient().listSSHKeyPairs();
for (SSHKeyPair sshKeyPair : sshKeyPairs) {
checkSSHKeyPair(sshKeyPair);
}
} }
public void testCreateSSHKeyPair() { public void testCreateSSHKeyPair() {
final String sshKeyPair = client.getSSHKeyPairClient().createSSHKeyPair("vijay-test"); final SSHKeyPair sshKeyPair = client.getSSHKeyPairClient().createSSHKeyPair("jclouds-keypair");
System.out.println(sshKeyPair); System.out.println(sshKeyPair);
} }
protected void checkSSHKeyPair(SSHKeyPair pair) { protected void checkSSHKeyPair(SSHKeyPair pair) {
assert pair.getName() != null : pair; assert pair.getName() != null : pair;
// assertEquals(pair.toString(), assertEquals(pair.toString(), client.getSSHKeyPairClient().getSSHKeyPair(pair.getName()).toString());
// client.getSSHKeyPairClient().getSSHKeyPair(pair.getName()).toString());
} }
} }

View File

@ -0,0 +1,66 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.cloudstack.parse;
import java.util.Set;
import org.jclouds.cloudstack.config.CloudStackParserModule;
import org.jclouds.cloudstack.domain.SSHKeyPair;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.json.config.GsonModule;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Guice;
import com.google.inject.Injector;
/**
* @author Adrian Cole
*/
@Test(groups = "unit")
public class ListSSHKeyPairsResponseTest extends BaseSetParserTest<SSHKeyPair> {
@Override
protected Injector injector() {
return Guice.createInjector(new CloudStackParserModule(), new GsonModule() {
@Override
protected void configure() {
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
super.configure();
}
});
}
@Override
public String resource() {
return "/listsshkeypairsresponse.json";
}
@Override
@SelectJson("keypair")
public Set<SSHKeyPair> expected() {
return ImmutableSet.<SSHKeyPair> of(SSHKeyPair.builder().name("jclouds-keypair")
.fingerprint("43:6a:bd:46:e0:3d:3a:8d:ab:69:25:bb:b9:ca:9d:17").build());
}
}

View File

@ -0,0 +1 @@
{ "createkeypairresponse" : { "keypair" : {"name":"vijay2-test","fingerprint":"80:61:58:5b:92:4c:1f:5a:4f:fc:1d:39:ea:28:06:c7","privatekey":"-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQDTMxvFfEC+SAq4JD1sYx/EAtvzdKt1XY3yBFZ4iRRDCM30fK76\nQ5um9H+PhxzeGj5PVKPF409nq17BiNjM64qnmoHFVn2J+NFaiyo/oo2wohDDWUyn\noh7ifGd+AUfhaISnuAmEfhlgHxBhrTXsKmGe/x7lgwiyg25t84XYR38QiQIDAQAB\nAoGAGk5cYC3I1qqcgzEoYW67TyvX/6wBiz3a51E5AAx69JqNJK2/EbcIFTSRCuyW\nYOe96R2uxIA6rLwAsnR8JJIWE+5DdlSjp+Vrgp3p10YXU6FHdmX0Uwq+Gi9Ofg2E\nX1qGBJTVmV0BRCJCZcufNk+XPSUp7QQpstqd0Nxnc6dcEnECQQDzZ7PnP+7EKmk4\nNT0kN2V56dartYOookA20V6YMa2mcOmDw0Mhh3B3GlOjwkfVLtGfdxdz4gtcGtzz\nEpwjrRA1AkEA3iDKxmSyWQSl80KfVQQK2QZ52jHIJbuT5UlvCSvgb2XXxJ+gxjSh\n/V805IIZ+WMzWNkRQ1g786dhI1BUCv2xhQJBAKngB3vub8pyuwqihXCARQ9H9y3R\nufh4fI6FoxpfGY2fIip2naSJ7SECu7r/vbh4O46qxDB5Y2o9yVTP+S8g+r0CQDKA\nWhnJAxNiDyjDWN5HUQAOjN2iu9J4VyOmEmyPYTNygB/f+vmVNc8ZOjlJqwYcG6xz\njY02HktDHr6coL7u9tECQE8hJ04UbS2O4ruafhDUHNJ9/4ERzFyn1GWhcipK6ACE\nF4MrwQImqtsUvGjtA3X0s+lEj3+iLJfJr02pfYpCyf8=\n-----END RSA PRIVATE KEY-----\n"} } }

View File

@ -0,0 +1 @@
{ "listsshkeypairsresponse" : { "count":1 ,"keypair" : [ {"name":"jclouds-keypair","fingerprint":"43:6a:bd:46:e0:3d:3a:8d:ab:69:25:bb:b9:ca:9d:17"} ] } }