mirror of https://github.com/apache/jclouds.git
added cloudstack loadbalancer code
This commit is contained in:
parent
634a33fe5f
commit
51cacf03d6
|
@ -22,6 +22,7 @@ package org.jclouds.cloudstack;
|
|||
import org.jclouds.cloudstack.features.AddressAsyncClient;
|
||||
import org.jclouds.cloudstack.features.AsyncJobAsyncClient;
|
||||
import org.jclouds.cloudstack.features.FirewallAsyncClient;
|
||||
import org.jclouds.cloudstack.features.LoadBalancerAsyncClient;
|
||||
import org.jclouds.cloudstack.features.NATAsyncClient;
|
||||
import org.jclouds.cloudstack.features.NetworkAsyncClient;
|
||||
import org.jclouds.cloudstack.features.OfferingAsyncClient;
|
||||
|
@ -100,4 +101,10 @@ public interface CloudStackAsyncClient {
|
|||
*/
|
||||
@Delegate
|
||||
FirewallAsyncClient getFirewallClient();
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to LoadBalancer features.
|
||||
*/
|
||||
@Delegate
|
||||
LoadBalancerAsyncClient getLoadBalancerClient();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.jclouds.cloudstack.features.AddressClient;
|
||||
import org.jclouds.cloudstack.features.AsyncJobClient;
|
||||
import org.jclouds.cloudstack.features.FirewallClient;
|
||||
import org.jclouds.cloudstack.features.LoadBalancerClient;
|
||||
import org.jclouds.cloudstack.features.NATClient;
|
||||
import org.jclouds.cloudstack.features.NetworkClient;
|
||||
import org.jclouds.cloudstack.features.OfferingClient;
|
||||
|
@ -103,4 +104,10 @@ public interface CloudStackClient {
|
|||
*/
|
||||
@Delegate
|
||||
FirewallClient getFirewallClient();
|
||||
|
||||
/**
|
||||
* Provides synchronous access to LoadBalancer features.
|
||||
*/
|
||||
@Delegate
|
||||
LoadBalancerClient getLoadBalancerClient();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ import org.jclouds.cloudstack.features.AsyncJobAsyncClient;
|
|||
import org.jclouds.cloudstack.features.AsyncJobClient;
|
||||
import org.jclouds.cloudstack.features.FirewallAsyncClient;
|
||||
import org.jclouds.cloudstack.features.FirewallClient;
|
||||
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;
|
||||
|
@ -76,6 +78,7 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
|
|||
.put(AddressClient.class, AddressAsyncClient.class)//
|
||||
.put(NATClient.class, NATAsyncClient.class)//
|
||||
.put(FirewallClient.class, FirewallAsyncClient.class)//
|
||||
.put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)//
|
||||
.build();
|
||||
|
||||
public CloudStackRestClientModule() {
|
||||
|
|
|
@ -0,0 +1,345 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
|
||||
|
||||
public static enum Algorithm {
|
||||
SOURCE, ROUNDROBIN, LEASTCONN, UNRECOGNIZED;
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
public static Algorithm fromValue(String algorithm) {
|
||||
try {
|
||||
return Algorithm.valueOf(checkNotNull(algorithm, "algorithm").toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private long id;
|
||||
private String account;
|
||||
private Algorithm algorithm;
|
||||
private String description;
|
||||
private String domain;
|
||||
private long domainId;
|
||||
private String name;
|
||||
private int privatePort;
|
||||
private String publicIP;
|
||||
private long publicIPId;
|
||||
private int publicPort;
|
||||
private String state;
|
||||
|
||||
public Builder id(long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder algorithm(Algorithm algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder domainId(long domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder privatePort(int privatePort) {
|
||||
this.privatePort = privatePort;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder publicIP(String publicIP) {
|
||||
this.publicIP = publicIP;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder publicIPId(long publicIPId) {
|
||||
this.publicIPId = publicIPId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder publicPort(int publicPort) {
|
||||
this.publicPort = publicPort;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder state(String state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoadBalancerRule build() {
|
||||
return new LoadBalancerRule(id, account, algorithm, description, domain, domainId, name, privatePort,
|
||||
publicIP, publicIPId, publicPort, state);
|
||||
}
|
||||
}
|
||||
|
||||
private long id;
|
||||
private String account;
|
||||
private Algorithm algorithm;
|
||||
private String description;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private long domainId;
|
||||
private String name;
|
||||
@SerializedName("privateport")
|
||||
private int privatePort;
|
||||
@SerializedName("publicip")
|
||||
private String publicIP;
|
||||
@SerializedName("publicipid")
|
||||
private long publicIPId;
|
||||
@SerializedName("publicport")
|
||||
private int publicPort;
|
||||
private String state;
|
||||
|
||||
// for deserializer
|
||||
LoadBalancerRule() {
|
||||
|
||||
}
|
||||
|
||||
public LoadBalancerRule(long id, String account, Algorithm algorithm, String description, String domain,
|
||||
long domainId, String name, int privatePort, String publicIP, long publicIPId, int publicPort, String state) {
|
||||
this.id = id;
|
||||
this.account = account;
|
||||
this.algorithm = algorithm;
|
||||
this.description = description;
|
||||
this.domain = domain;
|
||||
this.domainId = domainId;
|
||||
this.name = name;
|
||||
this.privatePort = privatePort;
|
||||
this.publicIP = publicIP;
|
||||
this.publicIPId = publicIPId;
|
||||
this.publicPort = publicPort;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the load balancer rule ID
|
||||
*/
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the account of the load balancer rule
|
||||
*/
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the load balancer algorithm (source, roundrobin, leastconn)
|
||||
*/
|
||||
public Algorithm getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description of the load balancer
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain of the load balancer rule
|
||||
*/
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain ID of the load balancer rule
|
||||
*/
|
||||
public long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the load balancer
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the private port
|
||||
*/
|
||||
public int getPrivatePort() {
|
||||
return privatePort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the public ip address
|
||||
*/
|
||||
public String getPublicIP() {
|
||||
return publicIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the public ip address id
|
||||
*/
|
||||
public long getPublicIPId() {
|
||||
return publicIPId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the public port
|
||||
*/
|
||||
public int getPublicPort() {
|
||||
return publicPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state of the rule
|
||||
*/
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(LoadBalancerRule arg0) {
|
||||
return new Long(id).compareTo(arg0.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((account == null) ? 0 : account.hashCode());
|
||||
result = prime * result + ((algorithm == null) ? 0 : algorithm.hashCode());
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((domain == null) ? 0 : domain.hashCode());
|
||||
result = prime * result + (int) (domainId ^ (domainId >>> 32));
|
||||
result = prime * result + (int) (id ^ (id >>> 32));
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + privatePort;
|
||||
result = prime * result + ((publicIP == null) ? 0 : publicIP.hashCode());
|
||||
result = prime * result + (int) (publicIPId ^ (publicIPId >>> 32));
|
||||
result = prime * result + publicPort;
|
||||
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
LoadBalancerRule other = (LoadBalancerRule) obj;
|
||||
if (account == null) {
|
||||
if (other.account != null)
|
||||
return false;
|
||||
} else if (!account.equals(other.account))
|
||||
return false;
|
||||
if (algorithm == null) {
|
||||
if (other.algorithm != null)
|
||||
return false;
|
||||
} else if (!algorithm.equals(other.algorithm))
|
||||
return false;
|
||||
if (description == null) {
|
||||
if (other.description != null)
|
||||
return false;
|
||||
} else if (!description.equals(other.description))
|
||||
return false;
|
||||
if (domain == null) {
|
||||
if (other.domain != null)
|
||||
return false;
|
||||
} else if (!domain.equals(other.domain))
|
||||
return false;
|
||||
if (domainId != other.domainId)
|
||||
return false;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (privatePort != other.privatePort)
|
||||
return false;
|
||||
if (publicIP == null) {
|
||||
if (other.publicIP != null)
|
||||
return false;
|
||||
} else if (!publicIP.equals(other.publicIP))
|
||||
return false;
|
||||
if (publicIPId != other.publicIPId)
|
||||
return false;
|
||||
if (publicPort != other.publicPort)
|
||||
return false;
|
||||
if (state == null) {
|
||||
if (other.state != null)
|
||||
return false;
|
||||
} else if (!state.equals(other.state))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[account=" + account + ", algorithm=" + algorithm + ", description=" + description + ", domain=" + domain
|
||||
+ ", domainId=" + domainId + ", id=" + id + ", name=" + name + ", privatePort=" + privatePort
|
||||
+ ", publicIP=" + publicIP + ", publicIPId=" + publicIPId + ", publicPort=" + publicPort + ", state="
|
||||
+ state + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -42,7 +42,7 @@ public interface FirewallClient {
|
|||
*
|
||||
* @param options
|
||||
* if present, how to constrain the list.
|
||||
* @return PortForwardingRulees matching query, or empty set, if no PortForwardingRulees are
|
||||
* @return PortForwardingRules matching query, or empty set, if no PortForwardingRulees are
|
||||
* found
|
||||
*/
|
||||
Set<PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesOptions... options);
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule;
|
||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
|
||||
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||
import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.QueryParams;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.Unwrap;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to cloudstack via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see LoadBalancerClient
|
||||
* @see <a href="http://download.cloud.com/releases/2.2.0/api/TOC_User.html" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(QuerySigner.class)
|
||||
@QueryParams(keys = "response", values = "json")
|
||||
public interface LoadBalancerAsyncClient {
|
||||
|
||||
/**
|
||||
* @see LoadBalancerClient#listLoadBalancerRules
|
||||
*/
|
||||
@GET
|
||||
@QueryParams(keys = "command", values = "listLoadBalancerRules")
|
||||
@Unwrap(depth = 2)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<LoadBalancerRule>> listLoadBalancerRules(ListLoadBalancerRulesOptions... options);
|
||||
|
||||
/**
|
||||
* @see LoadBalancerClient#createLoadBalancerRuleForPublicIp
|
||||
*/
|
||||
@GET
|
||||
@QueryParams(keys = "command", values = "createLoadBalancerRule")
|
||||
@Unwrap(depth = 2)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<LoadBalancerRule> createLoadBalancerRuleForPublicIP(@QueryParam("publicipid") long publicIPId,
|
||||
@QueryParam("algorithm") Algorithm algorithm, @QueryParam("name") String name,
|
||||
@QueryParam("privateport") int privatePort, @QueryParam("publicport") int publicPort);
|
||||
|
||||
/**
|
||||
* @see LoadBalancerClient#deleteLoadBalancerRule
|
||||
*/
|
||||
@GET
|
||||
@QueryParams(keys = "command", values = "deleteLoadBalancerRule")
|
||||
@Unwrap(depth = 2)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<Long> deleteLoadBalancerRule(@QueryParam("id") long id);
|
||||
|
||||
/**
|
||||
* @see LoadBalancerClient#listVirtualMachinesAssignedToLoadBalancerRule
|
||||
*/
|
||||
@GET
|
||||
@QueryParams(keys = "command", values = "listLoadBalancerRuleInstances")
|
||||
@Unwrap(depth = 2)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<VirtualMachine>> listVirtualMachinesAssignedToLoadBalancerRule(@QueryParam("id") long id);
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule;
|
||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
|
||||
import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions;
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to CloudStack LoadBalancer features.
|
||||
* <p/>
|
||||
*
|
||||
* @see LoadBalancerAsyncClient
|
||||
* @see <a href="http://download.cloud.com/releases/2.2.0/api/TOC_User.html" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
||||
public interface LoadBalancerClient {
|
||||
/**
|
||||
* List the load balancer rules
|
||||
*
|
||||
* @param options
|
||||
* if present, how to constrain the list.
|
||||
* @return load balancer rules matching query, or empty set, if no load balancer rules are found
|
||||
*/
|
||||
Set<LoadBalancerRule> listLoadBalancerRules(ListLoadBalancerRulesOptions... options);
|
||||
|
||||
/**
|
||||
* Creates a load balancer rule.
|
||||
*
|
||||
* @param publicIPId
|
||||
* the public port from where the network traffic will be load balanced from
|
||||
* @param algorithm
|
||||
* load balancer algorithm (source, roundrobin, leastconn)
|
||||
* @param name
|
||||
* name of the load balancer rule
|
||||
* @param privatePort
|
||||
* the private port of the private ip address/virtual machine where the network traffic
|
||||
* will be load balanced to
|
||||
* @param publicPort
|
||||
* public ip address id from where the network traffic will be load balanced from
|
||||
* @return newly created rule
|
||||
*/
|
||||
LoadBalancerRule createLoadBalancerRuleForPublicIP(long publicIPId, Algorithm algorithm, String name,
|
||||
int privatePort, int publicPort);
|
||||
|
||||
/**
|
||||
*
|
||||
* deletes a loadbalancer rule
|
||||
*
|
||||
* @param id
|
||||
* id of the rule to delete
|
||||
* @return async job id of the job completing or null, if the load balancer rule was not found.
|
||||
*/
|
||||
Long deleteLoadBalancerRule(long id);
|
||||
|
||||
/**
|
||||
* List all virtual machine instances that are assigned to a load balancer rule.
|
||||
*
|
||||
* @param id
|
||||
* id of the rule
|
||||
* @return VirtualMachines matching query, or empty set, if no VirtualMachines are assigned
|
||||
*/
|
||||
Set<VirtualMachine> listVirtualMachinesAssignedToLoadBalancerRule(long id);
|
||||
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.options;
|
||||
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Options used to control what load balancer rules are returned
|
||||
*
|
||||
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listLoadBalancerRules.html" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ListLoadBalancerRulesOptions extends BaseHttpRequestOptions {
|
||||
|
||||
public static final ListLoadBalancerRulesOptions NONE = new ListLoadBalancerRulesOptions();
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* Lists rule with the specified ID.
|
||||
*/
|
||||
public ListLoadBalancerRulesOptions id(long id) {
|
||||
this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param domainId
|
||||
* Lists all rules for this id. If used with the account parameter, returns all rules
|
||||
* for an account in the specified domain ID.
|
||||
*/
|
||||
public ListLoadBalancerRulesOptions domainId(long domainId) {
|
||||
this.queryParameters.replaceValues("domainid", ImmutableSet.of(domainId + ""));
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param account
|
||||
* the account associated with the load balancing rule. Must be used with the domainId
|
||||
* parameter.
|
||||
*
|
||||
* @param domain
|
||||
* domain id
|
||||
*/
|
||||
public ListLoadBalancerRulesOptions accountInDomain(String account, long domain) {
|
||||
this.queryParameters.replaceValues("account", ImmutableSet.of(account));
|
||||
this.queryParameters.replaceValues("domainid", ImmutableSet.of(domain + ""));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name of the load balancer rule
|
||||
*/
|
||||
public ListLoadBalancerRulesOptions name(String name) {
|
||||
this.queryParameters.replaceValues("name", ImmutableSet.of(name));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param publicIPId
|
||||
* the public IP address id of the load balancer rule
|
||||
*/
|
||||
public ListLoadBalancerRulesOptions publicIPId(long publicIPId) {
|
||||
this.queryParameters.replaceValues("publicipid", ImmutableSet.of(publicIPId + ""));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param virtualMachineId
|
||||
* the ID of the virtual machine of the load balancer rule
|
||||
*/
|
||||
public ListLoadBalancerRulesOptions virtualMachineId(long virtualMachineId) {
|
||||
this.queryParameters.replaceValues("virtualmachineid", ImmutableSet.of(virtualMachineId + ""));
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
* @see ListLoadBalancerRulesOptions#accountInDomain
|
||||
*/
|
||||
public static ListLoadBalancerRulesOptions accountInDomain(String account, long domain) {
|
||||
ListLoadBalancerRulesOptions options = new ListLoadBalancerRulesOptions();
|
||||
return options.accountInDomain(account, domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListLoadBalancerRulesOptions#publicIPId
|
||||
*/
|
||||
public static ListLoadBalancerRulesOptions publicIPId(long publicIPId) {
|
||||
ListLoadBalancerRulesOptions options = new ListLoadBalancerRulesOptions();
|
||||
return options.publicIPId(publicIPId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListLoadBalancerRulesOptions#domainId
|
||||
*/
|
||||
public static ListLoadBalancerRulesOptions domainId(long id) {
|
||||
ListLoadBalancerRulesOptions options = new ListLoadBalancerRulesOptions();
|
||||
return options.domainId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListLoadBalancerRulesOptions#name
|
||||
*/
|
||||
public static ListLoadBalancerRulesOptions name(String name) {
|
||||
ListLoadBalancerRulesOptions options = new ListLoadBalancerRulesOptions();
|
||||
return options.name(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListLoadBalancerRulesOptions#id
|
||||
*/
|
||||
public static ListLoadBalancerRulesOptions id(long id) {
|
||||
ListLoadBalancerRulesOptions options = new ListLoadBalancerRulesOptions();
|
||||
return options.id(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListLoadBalancerRulesOptions#virtualMachineId
|
||||
*/
|
||||
public static ListLoadBalancerRulesOptions virtualMachineId(long virtualMachineId) {
|
||||
ListLoadBalancerRulesOptions options = new ListLoadBalancerRulesOptions();
|
||||
return options.virtualMachineId(virtualMachineId);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
|
||||
import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code LoadBalancerAsyncClient}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "LoadBalancerAsyncClientTest")
|
||||
public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<LoadBalancerAsyncClient> {
|
||||
public void testListLoadBalancerRules() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules",
|
||||
ListLoadBalancerRulesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRules HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
|
||||
}
|
||||
|
||||
public void testListLoadBalancerRulesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules",
|
||||
ListLoadBalancerRulesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListLoadBalancerRulesOptions.Builder.publicIPId(3));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRules&publicipid=3 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
|
||||
}
|
||||
|
||||
public void testCreateLoadBalancerRuleForPublicIP() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = LoadBalancerAsyncClient.class.getMethod("createLoadBalancerRuleForPublicIP", long.class,
|
||||
Algorithm.class, String.class, int.class, int.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 6, Algorithm.LEASTCONN, "tcp", 22, 22);
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=createLoadBalancerRule&publicipid=6&name=tcp&algorithm=leastconn&privateport=22&publicport=22 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
|
||||
}
|
||||
|
||||
public void testDeleteLoadBalancerRule() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = LoadBalancerAsyncClient.class.getMethod("deleteLoadBalancerRule", long.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteLoadBalancerRule&id=5 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
|
||||
}
|
||||
|
||||
public void testListVirtualMachinesAssignedToLoadBalancerRule() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = LoadBalancerAsyncClient.class.getMethod("listVirtualMachinesAssignedToLoadBalancerRule",
|
||||
long.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRuleInstances&id=5 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<LoadBalancerAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<LoadBalancerAsyncClient>>() {
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agred 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.
|
||||
* Se the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import static com.google.common.collect.Iterables.find;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule;
|
||||
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
|
||||
import org.testng.annotations.AfterGroups;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code LoadBalancerClientLiveTest}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", sequential = true, testName = "LoadBalancerClientLiveTest")
|
||||
public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||
private PublicIPAddress ip = null;
|
||||
private VirtualMachine vm;
|
||||
private LoadBalancerRule rule;
|
||||
|
||||
@BeforeGroups(groups = "live")
|
||||
public void setupClient() {
|
||||
super.setupClient();
|
||||
prefix += "rule";
|
||||
ip = AddressClientLiveTest.createPublicIPAddress(client, jobComplete);
|
||||
vm = VirtualMachineClientLiveTest.createVirtualMachine(client, jobComplete, virtualMachineRunning);
|
||||
}
|
||||
|
||||
public void testCreateLoadBalancerRule() throws Exception {
|
||||
rule = client.getLoadBalancerClient().createLoadBalancerRuleForPublicIP(ip.getId(), Algorithm.LEASTCONN, prefix,
|
||||
22, 22);
|
||||
assert (rule.getPublicIPId() == ip.getId()) : rule;
|
||||
assertEquals(rule.getPublicPort(), 22);
|
||||
assertEquals(rule.getPrivatePort(), 22);
|
||||
assertEquals(rule.getAlgorithm(), Algorithm.LEASTCONN);
|
||||
assertEquals(rule.getName(), prefix);
|
||||
assertEquals(client.getLoadBalancerClient().listVirtualMachinesAssignedToLoadBalancerRule(rule.getId()).size(), 0);
|
||||
checkRule(rule);
|
||||
// IPSocket socket = new IPSocket(ip.getIPAddress(), 22);
|
||||
// socketTester.apply(socket);
|
||||
// SshClient client = sshFactory.create(socket, new Credentials("root", "password"));
|
||||
// try {
|
||||
// client.connect();
|
||||
// ExecResponse exec = client.exec("echo hello");
|
||||
// assertEquals(exec.getOutput().trim(), "hello");
|
||||
// } finally {
|
||||
// if (client != null)
|
||||
// client.disconnect();
|
||||
// }
|
||||
}
|
||||
|
||||
@AfterGroups(groups = "live")
|
||||
protected void tearDown() {
|
||||
if (rule != null) {
|
||||
assert jobComplete.apply(client.getLoadBalancerClient().deleteLoadBalancerRule(rule.getId()));
|
||||
}
|
||||
if (ip != null) {
|
||||
client.getAddressClient().disassociateIPAddress(ip.getId());
|
||||
}
|
||||
if (vm != null) {
|
||||
assert jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vm.getId()));
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testListLoadBalancerRules() throws Exception {
|
||||
Set<LoadBalancerRule> response = client.getLoadBalancerClient().listLoadBalancerRules();
|
||||
assert null != response;
|
||||
assertTrue(response.size() >= 0);
|
||||
for (final LoadBalancerRule rule : response) {
|
||||
LoadBalancerRule newDetails = findRuleWithId(rule.getId());
|
||||
assertEquals(rule.getId(), newDetails.getId());
|
||||
checkRule(rule);
|
||||
}
|
||||
}
|
||||
|
||||
private LoadBalancerRule findRuleWithId(final long id) {
|
||||
return find(client.getLoadBalancerClient().listLoadBalancerRules(), new Predicate<LoadBalancerRule>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(LoadBalancerRule arg0) {
|
||||
return arg0.getId() == id;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
protected void checkRule(LoadBalancerRule rule) {
|
||||
assertEquals(rule.getId(), findRuleWithId(rule.getId()).getId());
|
||||
assert rule.getId() > 0 : rule;
|
||||
assert rule.getAccount() != null : rule;
|
||||
assert rule.getAlgorithm() != null : rule;
|
||||
assert rule.getPrivatePort() > 0 : rule;
|
||||
assert rule.getPublicPort() > 0 : rule;
|
||||
assert rule.getDomain() != null : rule;
|
||||
assert rule.getDomainId() > 0 : rule;
|
||||
assert rule.getState() != null : rule;
|
||||
assert rule.getName() != null : rule;
|
||||
assert rule.getPublicIP() != null : rule;
|
||||
assert rule.getPublicIPId() > 0 : rule;
|
||||
}
|
||||
}
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import static com.google.common.base.Predicates.equalTo;
|
||||
import static com.google.common.base.Predicates.or;
|
||||
import static com.google.common.collect.Iterables.find;
|
||||
import static com.google.common.collect.Iterables.get;
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
|
@ -45,7 +47,6 @@ import org.testng.annotations.AfterGroups;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import static com.google.common.base.Predicates.*;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.google.common.collect.Ordering;
|
||||
|
||||
|
@ -76,7 +77,7 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
@Override
|
||||
public boolean apply(Template arg0) {
|
||||
return arg0.getZoneId() == zone.getId() && arg0.isFeatured() && arg0.isReady()
|
||||
&& arg0.getOSType().equals("Ubuntu 10.04 (64-bit)");
|
||||
&& or(equalTo("Ubuntu 10.04 (64-bit)"), equalTo("CentOS 5.3 (32-bit)")).apply(arg0.getOSType());
|
||||
}
|
||||
|
||||
}).getId();
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.options;
|
||||
|
||||
import static org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions.Builder.accountInDomain;
|
||||
import static org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions.Builder.domainId;
|
||||
import static org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions.Builder.id;
|
||||
import static org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions.Builder.name;
|
||||
import static org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions.Builder.publicIPId;
|
||||
import static org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions.Builder.virtualMachineId;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ListLoadBalancerRulesOptions}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListLoadBalancerRulesOptionsTest {
|
||||
|
||||
public void testId() {
|
||||
ListLoadBalancerRulesOptions options = new ListLoadBalancerRulesOptions().id(6);
|
||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("id"));
|
||||
}
|
||||
|
||||
public void testIdStatic() {
|
||||
ListLoadBalancerRulesOptions options = id(6);
|
||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("id"));
|
||||
}
|
||||
|
||||
public void testAccount() {
|
||||
ListLoadBalancerRulesOptions options = new ListLoadBalancerRulesOptions().accountInDomain("account", 6);
|
||||
assertEquals(ImmutableList.of("account"), options.buildQueryParameters().get("account"));
|
||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||
}
|
||||
|
||||
public void testAccountStatic() {
|
||||
ListLoadBalancerRulesOptions options = accountInDomain("account", 6);
|
||||
assertEquals(ImmutableList.of("account"), options.buildQueryParameters().get("account"));
|
||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||
}
|
||||
|
||||
public void testName() {
|
||||
ListLoadBalancerRulesOptions options = new ListLoadBalancerRulesOptions().name("name");
|
||||
assertEquals(ImmutableList.of("name"), options.buildQueryParameters().get("name"));
|
||||
}
|
||||
|
||||
public void testNameStatic() {
|
||||
ListLoadBalancerRulesOptions options = name("name");
|
||||
assertEquals(ImmutableList.of("name"), options.buildQueryParameters().get("name"));
|
||||
}
|
||||
|
||||
public void testPublicIPId() {
|
||||
ListLoadBalancerRulesOptions options = new ListLoadBalancerRulesOptions().publicIPId(9);
|
||||
assertEquals(ImmutableList.of("9"), options.buildQueryParameters().get("publicipid"));
|
||||
}
|
||||
|
||||
public void testPublicIPIdStatic() {
|
||||
ListLoadBalancerRulesOptions options = publicIPId(9);
|
||||
assertEquals(ImmutableList.of("9"), options.buildQueryParameters().get("publicipid"));
|
||||
}
|
||||
|
||||
public void testDomainId() {
|
||||
ListLoadBalancerRulesOptions options = new ListLoadBalancerRulesOptions().domainId(6);
|
||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||
}
|
||||
|
||||
public void testDomainIdStatic() {
|
||||
ListLoadBalancerRulesOptions options = domainId(6);
|
||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||
}
|
||||
|
||||
public void testVirtualMachineId() {
|
||||
ListLoadBalancerRulesOptions options = new ListLoadBalancerRulesOptions().virtualMachineId(6);
|
||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("virtualmachineid"));
|
||||
}
|
||||
|
||||
public void testVirtualMachineIdStatic() {
|
||||
ListLoadBalancerRulesOptions options = virtualMachineId(6);
|
||||
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("virtualmachineid"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue