mirror of https://github.com/apache/jclouds.git
Merge pull request #325 from richardcloudsoft/cs-pod
CloudStack "Pod" API (global administrator)
This commit is contained in:
commit
3863247372
|
@ -26,6 +26,7 @@ import org.jclouds.cloudstack.features.GlobalConfigurationClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalDomainAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalDomainAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalHostAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalHostAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient;
|
||||||
|
import org.jclouds.cloudstack.features.GlobalPodAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalStoragePoolAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalStoragePoolAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalUsageAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalUsageAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalUserAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalUserAsyncClient;
|
||||||
|
@ -115,4 +116,10 @@ public interface CloudStackGlobalAsyncClient extends CloudStackDomainAsyncClient
|
||||||
@Delegate
|
@Delegate
|
||||||
@Override
|
@Override
|
||||||
GlobalZoneAsyncClient getZoneClient();
|
GlobalZoneAsyncClient getZoneClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to Pod
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
GlobalPodAsyncClient getPodClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.jclouds.cloudstack.features.GlobalConfigurationClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalDomainClient;
|
import org.jclouds.cloudstack.features.GlobalDomainClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalHostClient;
|
import org.jclouds.cloudstack.features.GlobalHostClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalOfferingClient;
|
import org.jclouds.cloudstack.features.GlobalOfferingClient;
|
||||||
|
import org.jclouds.cloudstack.features.GlobalPodClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalStoragePoolClient;
|
import org.jclouds.cloudstack.features.GlobalStoragePoolClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalUsageClient;
|
import org.jclouds.cloudstack.features.GlobalUsageClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalUserClient;
|
import org.jclouds.cloudstack.features.GlobalUserClient;
|
||||||
|
@ -118,4 +119,10 @@ public interface CloudStackGlobalClient extends CloudStackDomainClient {
|
||||||
@Delegate
|
@Delegate
|
||||||
@Override
|
@Override
|
||||||
GlobalZoneClient getZoneClient();
|
GlobalZoneClient getZoneClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to Pod
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
GlobalPodClient getPodClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,8 @@ import org.jclouds.cloudstack.features.GlobalHostAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalHostClient;
|
import org.jclouds.cloudstack.features.GlobalHostClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalOfferingClient;
|
import org.jclouds.cloudstack.features.GlobalOfferingClient;
|
||||||
|
import org.jclouds.cloudstack.features.GlobalPodAsyncClient;
|
||||||
|
import org.jclouds.cloudstack.features.GlobalPodClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalStoragePoolAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalStoragePoolAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalStoragePoolClient;
|
import org.jclouds.cloudstack.features.GlobalStoragePoolClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalUsageAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalUsageAsyncClient;
|
||||||
|
@ -169,6 +171,7 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
|
||||||
.put(GlobalHostClient.class, GlobalHostAsyncClient.class)//
|
.put(GlobalHostClient.class, GlobalHostAsyncClient.class)//
|
||||||
.put(GlobalStoragePoolClient.class, GlobalStoragePoolAsyncClient.class)//
|
.put(GlobalStoragePoolClient.class, GlobalStoragePoolAsyncClient.class)//
|
||||||
.put(GlobalUsageClient.class, GlobalUsageAsyncClient.class)//
|
.put(GlobalUsageClient.class, GlobalUsageAsyncClient.class)//
|
||||||
|
.put(GlobalPodClient.class, GlobalPodAsyncClient.class)//
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.cloudstack.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
|
||||||
|
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the allocationstate field used in several CloudStack domain objects.
|
||||||
|
*/
|
||||||
|
public enum AllocationState {
|
||||||
|
DISABLED,
|
||||||
|
ENABLED,
|
||||||
|
UNKNOWN;
|
||||||
|
|
||||||
|
public static AllocationState fromValue(String value) {
|
||||||
|
try{
|
||||||
|
return valueOf(value.toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return UPPER_UNDERSCORE.to(UPPER_CAMEL, name());
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,7 +57,7 @@ public class Cluster implements Comparable<Cluster> {
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private long id;
|
private long id;
|
||||||
private Host.AllocationState allocationState;
|
private AllocationState allocationState;
|
||||||
private Host.ClusterType clusterType;
|
private Host.ClusterType clusterType;
|
||||||
private String hypervisor;
|
private String hypervisor;
|
||||||
private ManagedState managedState;
|
private ManagedState managedState;
|
||||||
|
@ -72,7 +72,7 @@ public class Cluster implements Comparable<Cluster> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder allocationState(Host.AllocationState allocationState) {
|
public Builder allocationState(AllocationState allocationState) {
|
||||||
this.allocationState = allocationState;
|
this.allocationState = allocationState;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public class Cluster implements Comparable<Cluster> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
@SerializedName("allocationstate") private Host.AllocationState allocationState;
|
@SerializedName("allocationstate") private AllocationState allocationState;
|
||||||
@SerializedName("clustertype") private Host.ClusterType clusterType;
|
@SerializedName("clustertype") private Host.ClusterType clusterType;
|
||||||
@SerializedName("hypervisortype") private String hypervisor;
|
@SerializedName("hypervisortype") private String hypervisor;
|
||||||
@SerializedName("managedstate") private ManagedState managedState;
|
@SerializedName("managedstate") private ManagedState managedState;
|
||||||
|
@ -136,7 +136,7 @@ public class Cluster implements Comparable<Cluster> {
|
||||||
// Just for the serializer
|
// Just for the serializer
|
||||||
Cluster() {}
|
Cluster() {}
|
||||||
|
|
||||||
public Cluster(long id, Host.AllocationState allocationState, Host.ClusterType clusterType, String hypervisor, ManagedState managedState, String name, long podId, String podName, long zoneId, String zoneName) {
|
public Cluster(long id, AllocationState allocationState, Host.ClusterType clusterType, String hypervisor, ManagedState managedState, String name, long podId, String podName, long zoneId, String zoneName) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.allocationState = allocationState;
|
this.allocationState = allocationState;
|
||||||
this.clusterType = clusterType;
|
this.clusterType = clusterType;
|
||||||
|
@ -153,7 +153,7 @@ public class Cluster implements Comparable<Cluster> {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Host.AllocationState getAllocationState() {
|
public AllocationState getAllocationState() {
|
||||||
return allocationState;
|
return allocationState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,25 +32,6 @@ import com.google.gson.annotations.SerializedName;
|
||||||
*/
|
*/
|
||||||
public class Host implements Comparable<Host> {
|
public class Host implements Comparable<Host> {
|
||||||
|
|
||||||
public static enum AllocationState {
|
|
||||||
DISABLED,
|
|
||||||
ENABLED,
|
|
||||||
UNKNOWN;
|
|
||||||
|
|
||||||
public static AllocationState fromValue(String value) {
|
|
||||||
try{
|
|
||||||
return valueOf(value.toUpperCase());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return UPPER_UNDERSCORE.to(UPPER_CAMEL, name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum ClusterType {
|
public static enum ClusterType {
|
||||||
CLOUD_MANAGED,
|
CLOUD_MANAGED,
|
||||||
EXTERNAL_MANAGED,
|
EXTERNAL_MANAGED,
|
||||||
|
|
|
@ -0,0 +1,270 @@
|
||||||
|
/**
|
||||||
|
* 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.domain;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a Pod in CloudStack.
|
||||||
|
*
|
||||||
|
* @author Richard Downer
|
||||||
|
*/
|
||||||
|
public class Pod implements Comparable<Pod> {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String name;
|
||||||
|
private long zoneId;
|
||||||
|
private String zoneName;
|
||||||
|
private String gateway;
|
||||||
|
private String netmask;
|
||||||
|
private String startIp;
|
||||||
|
private String endIp;
|
||||||
|
private AllocationState allocationState;
|
||||||
|
|
||||||
|
private Builder() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id the ID of the Pod
|
||||||
|
*/
|
||||||
|
public Builder id(long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name the name of the Pod
|
||||||
|
*/
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param zoneId the Zone ID of the Pod
|
||||||
|
*/
|
||||||
|
public Builder zoneId(long zoneId) {
|
||||||
|
this.zoneId = zoneId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param zoneName the Zone name of the Pod
|
||||||
|
*/
|
||||||
|
public Builder zoneName(String zoneName) {
|
||||||
|
this.zoneName = zoneName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gateway the gateway of the Pod
|
||||||
|
*/
|
||||||
|
public Builder gateway(String gateway) {
|
||||||
|
this.gateway = gateway;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param netmask the netmask of the Pod
|
||||||
|
*/
|
||||||
|
public Builder netmask(String netmask) {
|
||||||
|
this.netmask = netmask;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param startIp the starting IP for the Pod
|
||||||
|
*/
|
||||||
|
public Builder startIp(String startIp) {
|
||||||
|
this.startIp = startIp;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param endIp the ending IP for the Pod
|
||||||
|
*/
|
||||||
|
public Builder endIp(String endIp) {
|
||||||
|
this.endIp = endIp;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param allocationState the allocation state of the cluster
|
||||||
|
*/
|
||||||
|
public Builder allocationState(AllocationState allocationState) {
|
||||||
|
this.allocationState = allocationState;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the Pod object
|
||||||
|
* @return the Pod object
|
||||||
|
*/
|
||||||
|
public Pod build() {
|
||||||
|
return new Pod(id, name, zoneId, zoneName, gateway, netmask, startIp, endIp, allocationState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String name;
|
||||||
|
@SerializedName("zoneid") private long zoneId;
|
||||||
|
@SerializedName("zonename") private String zoneName;
|
||||||
|
private String gateway;
|
||||||
|
private String netmask;
|
||||||
|
@SerializedName("startip") private String startIp;
|
||||||
|
@SerializedName("endip") private String endIp;
|
||||||
|
@SerializedName("allocationstate") private AllocationState allocationState;
|
||||||
|
|
||||||
|
/* Just for the serializer */
|
||||||
|
Pod() {}
|
||||||
|
|
||||||
|
public Pod(long id, String name, long zoneId, String zoneName, String gateway, String netmask, String startIp, String endIp, AllocationState allocationState) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.zoneId = zoneId;
|
||||||
|
this.zoneName = zoneName;
|
||||||
|
this.gateway = gateway;
|
||||||
|
this.netmask = netmask;
|
||||||
|
this.startIp = startIp;
|
||||||
|
this.endIp = endIp;
|
||||||
|
this.allocationState = allocationState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return id the ID of the Pod
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return name the name of the Pod
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return zoneId the Zone ID of the Pod
|
||||||
|
*/
|
||||||
|
public long getZoneId() {
|
||||||
|
return zoneId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return zoneName the Zone name of the Pod
|
||||||
|
*/
|
||||||
|
public String getZoneName() {
|
||||||
|
return zoneName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return gateway the gateway of the Pod
|
||||||
|
*/
|
||||||
|
public String getGateway() {
|
||||||
|
return gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return netmask the netmask of the Pod
|
||||||
|
*/
|
||||||
|
public String getNetmask() {
|
||||||
|
return netmask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return startIp the starting IP for the Pod
|
||||||
|
*/
|
||||||
|
public String getStartIp() {
|
||||||
|
return startIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return endIp the ending IP for the Pod
|
||||||
|
*/
|
||||||
|
public String getEndIp() {
|
||||||
|
return endIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param allocationState the allocation state of the cluster
|
||||||
|
*/
|
||||||
|
public AllocationState getAllocationState() {
|
||||||
|
return allocationState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
Pod pod = (Pod) o;
|
||||||
|
|
||||||
|
if (id != pod.id) return false;
|
||||||
|
if (zoneId != pod.zoneId) return false;
|
||||||
|
if (allocationState != pod.allocationState) return false;
|
||||||
|
if (endIp != null ? !endIp.equals(pod.endIp) : pod.endIp != null) return false;
|
||||||
|
if (gateway != null ? !gateway.equals(pod.gateway) : pod.gateway != null) return false;
|
||||||
|
if (name != null ? !name.equals(pod.name) : pod.name != null) return false;
|
||||||
|
if (netmask != null ? !netmask.equals(pod.netmask) : pod.netmask != null) return false;
|
||||||
|
if (startIp != null ? !startIp.equals(pod.startIp) : pod.startIp != null) return false;
|
||||||
|
if (zoneName != null ? !zoneName.equals(pod.zoneName) : pod.zoneName != null) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = (int) (id ^ (id >>> 32));
|
||||||
|
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||||
|
result = 31 * result + (int) (zoneId ^ (zoneId >>> 32));
|
||||||
|
result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0);
|
||||||
|
result = 31 * result + (gateway != null ? gateway.hashCode() : 0);
|
||||||
|
result = 31 * result + (netmask != null ? netmask.hashCode() : 0);
|
||||||
|
result = 31 * result + (startIp != null ? startIp.hashCode() : 0);
|
||||||
|
result = 31 * result + (endIp != null ? endIp.hashCode() : 0);
|
||||||
|
result = 31 * result + (allocationState != null ? allocationState.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Pod{" +
|
||||||
|
"id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", zoneId=" + zoneId +
|
||||||
|
", zoneName='" + zoneName + '\'' +
|
||||||
|
", gateway='" + gateway + '\'' +
|
||||||
|
", netmask='" + netmask + '\'' +
|
||||||
|
", startIp='" + startIp + '\'' +
|
||||||
|
", endIp='" + endIp + '\'' +
|
||||||
|
", allocationState=" + allocationState +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Pod other) {
|
||||||
|
return Long.valueOf(this.id).compareTo(other.id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,8 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudstack.domain;
|
package org.jclouds.cloudstack.domain;
|
||||||
|
|
||||||
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
|
|
||||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -33,25 +31,6 @@ import com.google.gson.annotations.SerializedName;
|
||||||
*/
|
*/
|
||||||
public class Zone implements Comparable<Zone> {
|
public class Zone implements Comparable<Zone> {
|
||||||
|
|
||||||
public static enum AllocationState {
|
|
||||||
DISABLED,
|
|
||||||
ENABLED,
|
|
||||||
UNKNOWN;
|
|
||||||
|
|
||||||
public static AllocationState fromValue(String value) {
|
|
||||||
try{
|
|
||||||
return valueOf(value.toUpperCase());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return UPPER_UNDERSCORE.to(UPPER_CAMEL, name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,136 @@
|
||||||
|
/**
|
||||||
|
* 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.features;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import org.jclouds.cloudstack.domain.Pod;
|
||||||
|
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||||
|
import org.jclouds.cloudstack.options.CreatePodOptions;
|
||||||
|
import org.jclouds.cloudstack.options.ListPodsOptions;
|
||||||
|
import org.jclouds.cloudstack.options.UpdatePodOptions;
|
||||||
|
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 org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to CloudStack Pod features available to Global
|
||||||
|
* Admin users.
|
||||||
|
*
|
||||||
|
* @author Richard Downer
|
||||||
|
* @see <a href=
|
||||||
|
* "http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_Global_Admin.html"
|
||||||
|
* />
|
||||||
|
*/
|
||||||
|
@RequestFilters(QuerySigner.class)
|
||||||
|
@QueryParams(keys = "response", values = "json")
|
||||||
|
public interface GlobalPodAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see PodClient#listPods
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "listPods")
|
||||||
|
@SelectJson("pod")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Set<Pod>> listPods(ListPodsOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see PodClient#getPod
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "listPods")
|
||||||
|
@SelectJson("pod")
|
||||||
|
@OnlyElement
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Pod> getPod(@QueryParam("id") long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Pod.
|
||||||
|
*
|
||||||
|
* @param name the name of the Pod
|
||||||
|
* @param zoneId the Zone ID in which the Pod will be created
|
||||||
|
* @param startIp the starting IP address for the Pod
|
||||||
|
* @param endIp the ending IP address for the Pod
|
||||||
|
* @param gateway the gateway for the Pod
|
||||||
|
* @param netmask the netmask for the Pod
|
||||||
|
* @param createPodOptions optional arguments
|
||||||
|
* @return the new Pod
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "createPod")
|
||||||
|
@SelectJson("pod")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Pod> createPod(@QueryParam("name") String name, @QueryParam("zoneid") long zoneId, @QueryParam("startip") String startIp, @QueryParam("endip") String endIp, @QueryParam("gateway") String gateway, @QueryParam("netmask") String netmask, CreatePodOptions... createPodOptions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Pod.
|
||||||
|
*
|
||||||
|
* @param name the name of the Pod
|
||||||
|
* @param zoneId the Zone ID in which the Pod will be created
|
||||||
|
* @param startIp the starting IP address for the Pod
|
||||||
|
* @param gateway the gateway for the Pod
|
||||||
|
* @param netmask the netmask for the Pod
|
||||||
|
* @param createPodOptions optional arguments
|
||||||
|
* @return the new Pod
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "createPod")
|
||||||
|
@SelectJson("pod")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Pod> createPod(@QueryParam("name") String name, @QueryParam("zoneid") long zoneId, @QueryParam("startip") String startIp, @QueryParam("gateway") String gateway, @QueryParam("netmask") String netmask, CreatePodOptions... createPodOptions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a Pod.
|
||||||
|
* @param id the ID of the Pod
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "deletePod")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Void> deletePod(@QueryParam("id") long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a Pod.
|
||||||
|
* @param id the ID of the Pod
|
||||||
|
* @param updatePodOptions optional arguments
|
||||||
|
* @return the updated pod
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "updatePod")
|
||||||
|
@SelectJson("pod")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Pod> updatePod(@QueryParam("id") long id, UpdatePodOptions... updatePodOptions);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
/**
|
||||||
|
* 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.features;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.Pod;
|
||||||
|
import org.jclouds.cloudstack.options.CreatePodOptions;
|
||||||
|
import org.jclouds.cloudstack.options.ListPodsOptions;
|
||||||
|
import org.jclouds.cloudstack.options.UpdatePodOptions;
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to CloudStack Pod features available to Global
|
||||||
|
* Admin users.
|
||||||
|
*
|
||||||
|
* @author Richard Downer
|
||||||
|
* @see <a href=
|
||||||
|
* "http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_Global_Admin.html"
|
||||||
|
* />
|
||||||
|
*/
|
||||||
|
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface GlobalPodClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists pods
|
||||||
|
*
|
||||||
|
* @param options
|
||||||
|
* if present, how to constrain the list.
|
||||||
|
* @return pods matching query, or empty set, if no pods are found
|
||||||
|
*/
|
||||||
|
Set<Pod> listPods(ListPodsOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get a specific pod by id
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* pod to get
|
||||||
|
* @return pod or null if not found
|
||||||
|
*/
|
||||||
|
Pod getPod(long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Pod.
|
||||||
|
*
|
||||||
|
* @param name the name of the Pod
|
||||||
|
* @param zoneId the Zone ID in which the Pod will be created
|
||||||
|
* @param startIp the starting IP address for the Pod
|
||||||
|
* @param endIp the ending IP address for the Pod
|
||||||
|
* @param gateway the gateway for the Pod
|
||||||
|
* @param netmask the netmask for the Pod
|
||||||
|
* @param createPodOptions optional arguments
|
||||||
|
* @return the new Pod
|
||||||
|
*/
|
||||||
|
Pod createPod(String name, long zoneId, String startIp, String endIp, String gateway, String netmask, CreatePodOptions... createPodOptions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Pod.
|
||||||
|
*
|
||||||
|
* @param name the name of the Pod
|
||||||
|
* @param zoneId the Zone ID in which the Pod will be created
|
||||||
|
* @param startIp the starting IP address for the Pod
|
||||||
|
* @param gateway the gateway for the Pod
|
||||||
|
* @param netmask the netmask for the Pod
|
||||||
|
* @param createPodOptions optional arguments
|
||||||
|
* @return the new Pod
|
||||||
|
*/
|
||||||
|
Pod createPod(String name, long zoneId, String startIp, String gateway, String netmask, CreatePodOptions... createPodOptions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a Pod.
|
||||||
|
* @param id the ID of the Pod
|
||||||
|
*/
|
||||||
|
void deletePod(long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a Pod.
|
||||||
|
* @param id the ID of the Pod
|
||||||
|
* @param updatePodOptions optional arguments
|
||||||
|
* @return the updated pod
|
||||||
|
*/
|
||||||
|
Pod updatePod(long id, UpdatePodOptions... updatePodOptions);
|
||||||
|
|
||||||
|
}
|
|
@ -19,12 +19,9 @@
|
||||||
package org.jclouds.cloudstack.options;
|
package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.functions.JoinOnComma;
|
|
||||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options to the GlobalHostClient.addHost() API call
|
* Options to the GlobalHostClient.addHost() API call
|
||||||
*
|
*
|
||||||
|
@ -37,7 +34,7 @@ public class AddClusterOptions extends BaseHttpRequestOptions {
|
||||||
/**
|
/**
|
||||||
* @param allocationState Allocation state of this Host for allocation of new resources
|
* @param allocationState Allocation state of this Host for allocation of new resources
|
||||||
*/
|
*/
|
||||||
public AddClusterOptions allocationState(Host.AllocationState allocationState) {
|
public AddClusterOptions allocationState(AllocationState allocationState) {
|
||||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +76,7 @@ public class AddClusterOptions extends BaseHttpRequestOptions {
|
||||||
/**
|
/**
|
||||||
* @param allocationState Allocation state of this Host for allocation of new resources
|
* @param allocationState Allocation state of this Host for allocation of new resources
|
||||||
*/
|
*/
|
||||||
public static AddClusterOptions allocationState(Host.AllocationState allocationState) {
|
public static AddClusterOptions allocationState(AllocationState allocationState) {
|
||||||
return new AddClusterOptions().allocationState(allocationState);
|
return new AddClusterOptions().allocationState(allocationState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -37,7 +37,7 @@ public class AddHostOptions extends BaseHttpRequestOptions {
|
||||||
/**
|
/**
|
||||||
* @param allocationState Allocation state of this Host for allocation of new resources
|
* @param allocationState Allocation state of this Host for allocation of new resources
|
||||||
*/
|
*/
|
||||||
public AddHostOptions allocationState(Host.AllocationState allocationState) {
|
public AddHostOptions allocationState(AllocationState allocationState) {
|
||||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public class AddHostOptions extends BaseHttpRequestOptions {
|
||||||
/**
|
/**
|
||||||
* @param allocationState Allocation state of this Host for allocation of new resources
|
* @param allocationState Allocation state of this Host for allocation of new resources
|
||||||
*/
|
*/
|
||||||
public static AddHostOptions allocationState(Host.AllocationState allocationState) {
|
public static AddHostOptions allocationState(AllocationState allocationState) {
|
||||||
return new AddHostOptions().allocationState(allocationState);
|
return new AddHostOptions().allocationState(allocationState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
/**
|
||||||
|
* 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.options;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options to the GlobalPodClient.createPod API call.
|
||||||
|
*
|
||||||
|
* @author Richard Downer
|
||||||
|
*/
|
||||||
|
public class CreatePodOptions extends BaseHttpRequestOptions {
|
||||||
|
|
||||||
|
public static final CreatePodOptions NONE = new CreatePodOptions();
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
public static CreatePodOptions allocationState(AllocationState allocationState) {
|
||||||
|
return new CreatePodOptions().allocationState(allocationState);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreatePodOptions allocationState(AllocationState allocationState) {
|
||||||
|
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.cloudstack.options;
|
package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.jclouds.cloudstack.domain.Zone;
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class CreateZoneOptions extends BaseHttpRequestOptions {
|
||||||
* @param allocationState
|
* @param allocationState
|
||||||
* allocation state of this Zone for allocation of new resources
|
* allocation state of this Zone for allocation of new resources
|
||||||
*/
|
*/
|
||||||
public CreateZoneOptions allocationState(Zone.AllocationState allocationState) {
|
public CreateZoneOptions allocationState(AllocationState allocationState) {
|
||||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ public class CreateZoneOptions extends BaseHttpRequestOptions {
|
||||||
/**
|
/**
|
||||||
* @see CreateZoneOptions#allocationState
|
* @see CreateZoneOptions#allocationState
|
||||||
*/
|
*/
|
||||||
public static CreateZoneOptions allocationState(Zone.AllocationState allocationState) {
|
public static CreateZoneOptions allocationState(AllocationState allocationState) {
|
||||||
CreateZoneOptions options = new CreateZoneOptions();
|
CreateZoneOptions options = new CreateZoneOptions();
|
||||||
return options.allocationState(allocationState);
|
return options.allocationState(allocationState);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.cloudstack.options;
|
package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.cloudstack.domain.Cluster;
|
import org.jclouds.cloudstack.domain.Cluster;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.Host;
|
||||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
@ -35,7 +36,7 @@ public class ListClustersOptions extends BaseHttpRequestOptions {
|
||||||
|
|
||||||
public static final ListHostsOptions NONE = new ListHostsOptions();
|
public static final ListHostsOptions NONE = new ListHostsOptions();
|
||||||
|
|
||||||
public ListClustersOptions allocationState(Host.AllocationState allocationState) {
|
public ListClustersOptions allocationState(AllocationState allocationState) {
|
||||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +83,7 @@ public class ListClustersOptions extends BaseHttpRequestOptions {
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
public static ListClustersOptions allocationState(Host.AllocationState allocationState) {
|
public static ListClustersOptions allocationState(AllocationState allocationState) {
|
||||||
return new ListClustersOptions().allocationState(allocationState);
|
return new ListClustersOptions().allocationState(allocationState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudstack.options;
|
package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.Host;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -45,7 +46,7 @@ public class ListHostsOptions extends AccountInDomainOptions {
|
||||||
/**
|
/**
|
||||||
* @param allocationState list hosts by allocation state
|
* @param allocationState list hosts by allocation state
|
||||||
*/
|
*/
|
||||||
public ListHostsOptions allocationState(Host.AllocationState allocationState) {
|
public ListHostsOptions allocationState(AllocationState allocationState) {
|
||||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +160,7 @@ public class ListHostsOptions extends AccountInDomainOptions {
|
||||||
/**
|
/**
|
||||||
* @see ListHostsOptions#allocationState
|
* @see ListHostsOptions#allocationState
|
||||||
*/
|
*/
|
||||||
public static ListHostsOptions allocationState(Host.AllocationState allocationState) {
|
public static ListHostsOptions allocationState(AllocationState allocationState) {
|
||||||
ListHostsOptions options = new ListHostsOptions();
|
ListHostsOptions options = new ListHostsOptions();
|
||||||
return options.allocationState(allocationState);
|
return options.allocationState(allocationState);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/**
|
||||||
|
* 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.options;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options to the GlobalPodClient.listPods API call.
|
||||||
|
*
|
||||||
|
* @author Richard Downer
|
||||||
|
*/
|
||||||
|
public class ListPodsOptions extends BaseHttpRequestOptions {
|
||||||
|
|
||||||
|
public static final ListPodsOptions NONE = new ListPodsOptions();
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
public static ListPodsOptions allocationState(AllocationState allocationState) {
|
||||||
|
return new ListPodsOptions().allocationState(allocationState);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ListPodsOptions id(long id) {
|
||||||
|
return new ListPodsOptions().id(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ListPodsOptions keyword(String keyword) {
|
||||||
|
return new ListPodsOptions().keyword(keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ListPodsOptions name(String name) {
|
||||||
|
return new ListPodsOptions().name(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ListPodsOptions zoneId(long zoneId) {
|
||||||
|
return new ListPodsOptions().zoneId(zoneId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListPodsOptions allocationState(AllocationState allocationState) {
|
||||||
|
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListPodsOptions id(long id) {
|
||||||
|
this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListPodsOptions keyword(String keyword) {
|
||||||
|
this.queryParameters.replaceValues("keyword", ImmutableSet.of(keyword));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListPodsOptions name(String name) {
|
||||||
|
this.queryParameters.replaceValues("name", ImmutableSet.of(name));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListPodsOptions zoneId(long zoneId) {
|
||||||
|
this.queryParameters.replaceValues("zoneid", ImmutableSet.of(zoneId + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.cloudstack.options;
|
package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.cloudstack.domain.Cluster;
|
import org.jclouds.cloudstack.domain.Cluster;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.Host;
|
||||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
@ -35,7 +36,7 @@ public class UpdateClusterOptions extends BaseHttpRequestOptions {
|
||||||
/**
|
/**
|
||||||
* @param allocationState Allocation state of this cluster for allocation of new resources
|
* @param allocationState Allocation state of this cluster for allocation of new resources
|
||||||
*/
|
*/
|
||||||
public UpdateClusterOptions allocationState(Host.AllocationState allocationState) {
|
public UpdateClusterOptions allocationState(AllocationState allocationState) {
|
||||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.<String>of(allocationState.toString()));
|
this.queryParameters.replaceValues("allocationstate", ImmutableSet.<String>of(allocationState.toString()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +78,7 @@ public class UpdateClusterOptions extends BaseHttpRequestOptions {
|
||||||
/**
|
/**
|
||||||
* @param allocationState Allocation state of this cluster for allocation of new resources
|
* @param allocationState Allocation state of this cluster for allocation of new resources
|
||||||
*/
|
*/
|
||||||
public static UpdateClusterOptions allocationState(Host.AllocationState allocationState) {
|
public static UpdateClusterOptions allocationState(AllocationState allocationState) {
|
||||||
return new UpdateClusterOptions().allocationState(allocationState);
|
return new UpdateClusterOptions().allocationState(allocationState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,7 @@ package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.functions.JoinOnComma;
|
|
||||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -39,7 +38,7 @@ public class UpdateHostOptions extends BaseHttpRequestOptions {
|
||||||
/**
|
/**
|
||||||
* @param allocationState Allocation state of this Host for allocation of new resources
|
* @param allocationState Allocation state of this Host for allocation of new resources
|
||||||
*/
|
*/
|
||||||
public UpdateHostOptions allocationState(Host.AllocationState allocationState) {
|
public UpdateHostOptions allocationState(AllocationState allocationState) {
|
||||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +64,7 @@ public class UpdateHostOptions extends BaseHttpRequestOptions {
|
||||||
/**
|
/**
|
||||||
* @param allocationState Allocation state of this Host for allocation of new resources
|
* @param allocationState Allocation state of this Host for allocation of new resources
|
||||||
*/
|
*/
|
||||||
public static UpdateHostOptions allocationState(Host.AllocationState allocationState) {
|
public static UpdateHostOptions allocationState(AllocationState allocationState) {
|
||||||
return new UpdateHostOptions().allocationState(allocationState);
|
return new UpdateHostOptions().allocationState(allocationState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
/**
|
||||||
|
* 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.options;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options to the GlobalPodClient.updatePod API call.
|
||||||
|
*
|
||||||
|
* @author Richard Downer
|
||||||
|
*/
|
||||||
|
public class UpdatePodOptions extends BaseHttpRequestOptions {
|
||||||
|
|
||||||
|
public static final UpdatePodOptions NONE = new UpdatePodOptions();
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
public static UpdatePodOptions name(String name) {
|
||||||
|
return new UpdatePodOptions().name(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UpdatePodOptions startIp(String startIp) {
|
||||||
|
return new UpdatePodOptions().startIp(startIp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UpdatePodOptions endIp(String endIp) {
|
||||||
|
return new UpdatePodOptions().endIp(endIp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UpdatePodOptions gateway(String gateway) {
|
||||||
|
return new UpdatePodOptions().gateway(gateway);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UpdatePodOptions netmask(String netmask) {
|
||||||
|
return new UpdatePodOptions().netmask(netmask);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UpdatePodOptions allocationState(AllocationState allocationState) {
|
||||||
|
return new UpdatePodOptions().allocationState(allocationState);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdatePodOptions name(String name) {
|
||||||
|
this.queryParameters.replaceValues("name", ImmutableSet.<String>of(name));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdatePodOptions startIp(String startIp) {
|
||||||
|
this.queryParameters.replaceValues("startip", ImmutableSet.<String>of(startIp));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdatePodOptions endIp(String endIp) {
|
||||||
|
this.queryParameters.replaceValues("endip", ImmutableSet.<String>of(endIp));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdatePodOptions gateway(String gateway) {
|
||||||
|
this.queryParameters.replaceValues("gateway", ImmutableSet.<String>of(gateway));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdatePodOptions netmask(String netmask) {
|
||||||
|
this.queryParameters.replaceValues("netmask", ImmutableSet.<String>of(netmask));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdatePodOptions allocationState(AllocationState allocationState) {
|
||||||
|
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.cloudstack.options;
|
package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.jclouds.cloudstack.domain.Zone;
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -42,7 +42,7 @@ public class UpdateZoneOptions extends BaseHttpRequestOptions {
|
||||||
* @param allocationState
|
* @param allocationState
|
||||||
* allocation state of this Zone for allocation of new resources
|
* allocation state of this Zone for allocation of new resources
|
||||||
*/
|
*/
|
||||||
public UpdateZoneOptions allocationState(Zone.AllocationState allocationState) {
|
public UpdateZoneOptions allocationState(AllocationState allocationState) {
|
||||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ public class UpdateZoneOptions extends BaseHttpRequestOptions {
|
||||||
/**
|
/**
|
||||||
* @see UpdateZoneOptions#allocationState
|
* @see UpdateZoneOptions#allocationState
|
||||||
*/
|
*/
|
||||||
public static UpdateZoneOptions allocationState(Zone.AllocationState allocationState) {
|
public static UpdateZoneOptions allocationState(AllocationState allocationState) {
|
||||||
UpdateZoneOptions options = new UpdateZoneOptions();
|
UpdateZoneOptions options = new UpdateZoneOptions();
|
||||||
return options.allocationState(allocationState);
|
return options.allocationState(allocationState);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudstack.features;
|
package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.jclouds.cloudstack.CloudStackContext;
|
import org.jclouds.cloudstack.CloudStackContext;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.cloudstack.domain.Cluster;
|
import org.jclouds.cloudstack.domain.Cluster;
|
||||||
import org.jclouds.cloudstack.domain.ConfigurationEntry;
|
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.Host;
|
||||||
import org.jclouds.cloudstack.options.AddClusterOptions;
|
import org.jclouds.cloudstack.options.AddClusterOptions;
|
||||||
import org.jclouds.cloudstack.options.AddHostOptions;
|
import org.jclouds.cloudstack.options.AddHostOptions;
|
||||||
|
@ -68,20 +67,20 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
|
|
||||||
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
||||||
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "UTC");
|
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "UTC");
|
||||||
Host host1 = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
Host host1 = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
||||||
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "UTC");
|
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "UTC");
|
||||||
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
||||||
Host host2 = Host.builder().id(2).name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId(1).zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
Host host2 = Host.builder().id(2).name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId(1).zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
||||||
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 35, 51, "UTC");
|
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 35, 51, "UTC");
|
||||||
Host host3 = Host.builder().id(3).name("s-1-VM").state(Host.State.UP).type(Host.Type.SECONDARY_STORAGE_VM).ipAddress("10.26.26.81").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId(223098941760041L).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
Host host3 = Host.builder().id(3).name("s-1-VM").state(Host.State.UP).type(Host.Type.SECONDARY_STORAGE_VM).ipAddress("10.26.26.81").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId(223098941760041L).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
||||||
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 36, 46, "UTC");
|
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 36, 46, "UTC");
|
||||||
Host host4 = Host.builder().id(4).name("v-2-VM").state(Host.State.UP).type(Host.Type.CONSOLE_PROXY).ipAddress("10.26.26.96").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId(223098941760041L).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
Host host4 = Host.builder().id(4).name("v-2-VM").state(Host.State.UP).type(Host.Type.CONSOLE_PROXY).ipAddress("10.26.26.96").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId(223098941760041L).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
Set<Host> expected = ImmutableSet.of(host1, host2, host3, host4);
|
Set<Host> expected = ImmutableSet.of(host1, host2, host3, host4);
|
||||||
|
|
||||||
|
@ -114,10 +113,10 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
|
|
||||||
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
||||||
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "UTC");
|
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "UTC");
|
||||||
Host expected = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
Host expected = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
Host actual = requestSendsResponse(request, response).addHost(1, "http://example.com", "XenServer", "fred", "sekrit",
|
Host actual = requestSendsResponse(request, response).addHost(1, "http://example.com", "XenServer", "fred", "sekrit",
|
||||||
AddHostOptions.Builder.hostTags(Collections.<String>emptySet()).allocationState(Host.AllocationState.ENABLED).clusterId(1).clusterName("Xen Clust 1").podId(1));
|
AddHostOptions.Builder.hostTags(Collections.<String>emptySet()).allocationState(AllocationState.ENABLED).clusterId(1).clusterName("Xen Clust 1").podId(1));
|
||||||
|
|
||||||
assertEquals(actual, expected);
|
assertEquals(actual, expected);
|
||||||
}
|
}
|
||||||
|
@ -135,9 +134,9 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
|
|
||||||
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
||||||
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "UTC");
|
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "UTC");
|
||||||
Host expected = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
Host expected = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
Host actual = requestSendsResponse(request, response).updateHost(1, UpdateHostOptions.Builder.allocationState(Host.AllocationState.ENABLED).hostTags(Collections.<String>emptySet()).osCategoryId(5));
|
Host actual = requestSendsResponse(request, response).updateHost(1, UpdateHostOptions.Builder.allocationState(AllocationState.ENABLED).hostTags(Collections.<String>emptySet()).osCategoryId(5));
|
||||||
|
|
||||||
assertEquals(actual, expected);
|
assertEquals(actual, expected);
|
||||||
}
|
}
|
||||||
|
@ -227,7 +226,7 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
||||||
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "UTC");
|
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "UTC");
|
||||||
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
||||||
Host expected = Host.builder().id(2).name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId(1).zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
Host expected = Host.builder().id(2).name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId(1).zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||||
|
|
||||||
Host actual = requestSendsResponse(request, response).addSecondaryStorage("nfs://10.26.26.165/mnt/nfs/cs_sec", AddSecondaryStorageOptions.Builder.zoneId(1));
|
Host actual = requestSendsResponse(request, response).addSecondaryStorage("nfs://10.26.26.165/mnt/nfs/cs_sec", AddSecondaryStorageOptions.Builder.zoneId(1));
|
||||||
|
|
||||||
|
@ -247,8 +246,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
|
|
||||||
Set<Cluster> actual = requestSendsResponse(request, response).listClusters();
|
Set<Cluster> actual = requestSendsResponse(request, response).listClusters();
|
||||||
|
|
||||||
Cluster cluster1 = Cluster.builder().id(1).name("Xen Clust 1").podId(1).podName("Dev Pod 1").zoneId(1).zoneName("Dev Zone 1").hypervisor("XenServer").clusterType(Host.ClusterType.CLOUD_MANAGED).allocationState(Host.AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build();
|
Cluster cluster1 = Cluster.builder().id(1).name("Xen Clust 1").podId(1).podName("Dev Pod 1").zoneId(1).zoneName("Dev Zone 1").hypervisor("XenServer").clusterType(Host.ClusterType.CLOUD_MANAGED).allocationState(AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build();
|
||||||
Cluster cluster2 = Cluster.builder().id(2).name("Xen Clust 1").podId(2).podName("Dev Pod 2").zoneId(2).zoneName("Dev Zone 2").hypervisor("XenServer").clusterType(Host.ClusterType.CLOUD_MANAGED).allocationState(Host.AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build();
|
Cluster cluster2 = Cluster.builder().id(2).name("Xen Clust 1").podId(2).podName("Dev Pod 2").zoneId(2).zoneName("Dev Zone 2").hypervisor("XenServer").clusterType(Host.ClusterType.CLOUD_MANAGED).allocationState(AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build();
|
||||||
ImmutableSet<Cluster> expected = ImmutableSet.of(cluster1, cluster2);
|
ImmutableSet<Cluster> expected = ImmutableSet.of(cluster1, cluster2);
|
||||||
|
|
||||||
assertEquals(actual, expected);
|
assertEquals(actual, expected);
|
||||||
|
@ -278,9 +277,9 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.payload(payloadFromResource("/addclusterresponse.json"))
|
.payload(payloadFromResource("/addclusterresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
|
||||||
Cluster expected = Cluster.builder().id(1).name("Xen Clust 1").podId(1).podName("Dev Pod 1").zoneId(1).zoneName("Dev Zone 1").hypervisor("XenServer").clusterType(Host.ClusterType.CLOUD_MANAGED).allocationState(Host.AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build();
|
Cluster expected = Cluster.builder().id(1).name("Xen Clust 1").podId(1).podName("Dev Pod 1").zoneId(1).zoneName("Dev Zone 1").hypervisor("XenServer").clusterType(Host.ClusterType.CLOUD_MANAGED).allocationState(AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build();
|
||||||
|
|
||||||
Cluster actual = requestSendsResponse(request, response).addCluster(1, "Xen Clust 1", Host.ClusterType.CLOUD_MANAGED, "XenServer", AddClusterOptions.Builder.allocationState(Host.AllocationState.ENABLED).podId(1).url("http://example.com/cluster").username("fred").password("sekrit"));
|
Cluster actual = requestSendsResponse(request, response).addCluster(1, "Xen Clust 1", Host.ClusterType.CLOUD_MANAGED, "XenServer", AddClusterOptions.Builder.allocationState(AllocationState.ENABLED).podId(1).url("http://example.com/cluster").username("fred").password("sekrit"));
|
||||||
|
|
||||||
assertEquals(actual, expected);
|
assertEquals(actual, expected);
|
||||||
}
|
}
|
||||||
|
@ -296,9 +295,9 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.payload(payloadFromResource("/updateclusterresponse.json"))
|
.payload(payloadFromResource("/updateclusterresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
|
||||||
Cluster expected = Cluster.builder().id(1).name("Xen Clust 1").podId(1).podName("Dev Pod 1").zoneId(1).zoneName("Dev Zone 1").hypervisor("XenServer").clusterType(Host.ClusterType.CLOUD_MANAGED).allocationState(Host.AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build();
|
Cluster expected = Cluster.builder().id(1).name("Xen Clust 1").podId(1).podName("Dev Pod 1").zoneId(1).zoneName("Dev Zone 1").hypervisor("XenServer").clusterType(Host.ClusterType.CLOUD_MANAGED).allocationState(AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build();
|
||||||
|
|
||||||
Cluster actual = requestSendsResponse(request, response).updateCluster(1, UpdateClusterOptions.Builder.allocationState(Host.AllocationState.ENABLED).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).hypervisor("XenServer").managedState(Cluster.ManagedState.MANAGED));
|
Cluster actual = requestSendsResponse(request, response).updateCluster(1, UpdateClusterOptions.Builder.allocationState(AllocationState.ENABLED).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).hypervisor("XenServer").managedState(Cluster.ManagedState.MANAGED));
|
||||||
|
|
||||||
assertEquals(actual, expected);
|
assertEquals(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import static org.testng.Assert.assertTrue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.cloudstack.domain.Cluster;
|
import org.jclouds.cloudstack.domain.Cluster;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.Host;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -79,7 +80,7 @@ public class GlobalHostClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
private void checkCluster(Cluster cluster) {
|
private void checkCluster(Cluster cluster) {
|
||||||
assertTrue(cluster.getId() > 0);
|
assertTrue(cluster.getId() > 0);
|
||||||
assertFalse(Strings.isNullOrEmpty(cluster.getName()));
|
assertFalse(Strings.isNullOrEmpty(cluster.getName()));
|
||||||
assertTrue(cluster.getAllocationState() != Host.AllocationState.UNKNOWN);
|
assertTrue(cluster.getAllocationState() != AllocationState.UNKNOWN);
|
||||||
assertTrue(cluster.getClusterType() != Host.ClusterType.UNKNOWN);
|
assertTrue(cluster.getClusterType() != Host.ClusterType.UNKNOWN);
|
||||||
assertFalse(Strings.isNullOrEmpty(cluster.getHypervisor()));
|
assertFalse(Strings.isNullOrEmpty(cluster.getHypervisor()));
|
||||||
assertTrue(cluster.getManagedState() != Cluster.ManagedState.UNRECOGNIZED);
|
assertTrue(cluster.getManagedState() != Cluster.ManagedState.UNRECOGNIZED);
|
||||||
|
|
|
@ -0,0 +1,202 @@
|
||||||
|
/**
|
||||||
|
* 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.features;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.jclouds.cloudstack.CloudStackContext;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
|
import org.jclouds.cloudstack.domain.Pod;
|
||||||
|
import org.jclouds.cloudstack.options.CreatePodOptions;
|
||||||
|
import org.jclouds.cloudstack.options.UpdatePodOptions;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the CloudStack PodClient
|
||||||
|
*
|
||||||
|
* @author Richard Downer
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "GlobalPodClientExpectTest")
|
||||||
|
public class GlobalPodClientExpectTest extends BaseCloudStackRestClientExpectTest<GlobalPodClient> {
|
||||||
|
|
||||||
|
public void testListPodsWhenResponseIs2xx() {
|
||||||
|
GlobalPodClient client = requestSendsResponse(
|
||||||
|
HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(
|
||||||
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
|
"command=listPods&apiKey=identity&signature=asx1px2NQkW4R44%2FDgdozuu9wQg%3D"))
|
||||||
|
.headers(
|
||||||
|
ImmutableMultimap.<String, String>builder()
|
||||||
|
.put("Accept", "application/json")
|
||||||
|
.build())
|
||||||
|
.build(),
|
||||||
|
HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResource("/listpodsresponse.json"))
|
||||||
|
.build());
|
||||||
|
|
||||||
|
Pod pod1 = Pod.builder()
|
||||||
|
.id(1)
|
||||||
|
.name("Dev Pod 1")
|
||||||
|
.zoneId(1)
|
||||||
|
.zoneName("Dev Zone 1")
|
||||||
|
.gateway("10.26.26.254")
|
||||||
|
.netmask("255.255.255.0")
|
||||||
|
.startIp("10.26.26.50")
|
||||||
|
.endIp("10.26.26.100")
|
||||||
|
.allocationState(AllocationState.ENABLED)
|
||||||
|
.build();
|
||||||
|
Pod pod2 = Pod.builder()
|
||||||
|
.id(2)
|
||||||
|
.name("Dev Pod 2")
|
||||||
|
.zoneId(2)
|
||||||
|
.zoneName("Dev Zone 2")
|
||||||
|
.gateway("10.22.22.254")
|
||||||
|
.netmask("255.255.255.0")
|
||||||
|
.startIp("10.22.22.25")
|
||||||
|
.endIp("10.22.22.50")
|
||||||
|
.allocationState(AllocationState.ENABLED)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.listPods(), ImmutableSet.of(pod1, pod2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListPodsWhenResponseIs404() {
|
||||||
|
GlobalPodClient client = requestSendsResponse(
|
||||||
|
HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(
|
||||||
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
|
"command=listPods&apiKey=identity&signature=asx1px2NQkW4R44%2FDgdozuu9wQg%3D"))
|
||||||
|
.headers(
|
||||||
|
ImmutableMultimap.<String, String>builder()
|
||||||
|
.put("Accept", "application/json")
|
||||||
|
.build())
|
||||||
|
.build(),
|
||||||
|
HttpResponse.builder()
|
||||||
|
.statusCode(404)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
assertEquals(client.listPods(), ImmutableSet.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCreatePodWhenResponseIs2xx() {
|
||||||
|
GlobalPodClient client = requestSendsResponse(
|
||||||
|
HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(
|
||||||
|
URI.create("http://localhost:8080/client/api?response=json&command=createPod&netmask=255.255.255.0&name=richard-pod&startip=172.20.0.1&zoneid=10&endip=172.20.0.250&gateway=172.20.0.254&allocationstate=Enabled&apiKey=identity&signature=fwsoQ77BmNQWfuqv4nVlPcKvKbU%3D"))
|
||||||
|
.headers(
|
||||||
|
ImmutableMultimap.<String, String>builder()
|
||||||
|
.put("Accept", "application/json")
|
||||||
|
.build())
|
||||||
|
.build(),
|
||||||
|
HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResource("/createpodresponse.json"))
|
||||||
|
.build());
|
||||||
|
|
||||||
|
Pod expected = Pod.builder()
|
||||||
|
.id(6)
|
||||||
|
.name("richard-pod")
|
||||||
|
.zoneId(10)
|
||||||
|
.zoneName("richard-zone")
|
||||||
|
.gateway("172.20.0.254")
|
||||||
|
.netmask("255.255.255.0")
|
||||||
|
.startIp("172.20.0.1")
|
||||||
|
.endIp("172.20.0.250")
|
||||||
|
.allocationState(AllocationState.ENABLED)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Pod actual = client.createPod("richard-pod", 10, "172.20.0.1", "172.20.0.250", "172.20.0.254", "255.255.255.0",
|
||||||
|
CreatePodOptions.Builder.allocationState(AllocationState.ENABLED));
|
||||||
|
|
||||||
|
assertEquals(actual, expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testUpdatePodWhenResponseIs2xx() {
|
||||||
|
GlobalPodClient client = requestSendsResponse(
|
||||||
|
HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(
|
||||||
|
URI.create("http://localhost:8080/client/api?response=json&command=updatePod&id=7&netmask=255.255.255.128&name=richard-updatepod&startip=172.21.0.129&endip=172.21.0.250&gateway=172.21.0.254&allocationstate=Disabled&apiKey=identity&signature=QpdbRyyF%2FxJ78ioJWhPKXEWhthY%3D"))
|
||||||
|
.headers(
|
||||||
|
ImmutableMultimap.<String, String>builder()
|
||||||
|
.put("Accept", "application/json")
|
||||||
|
.build())
|
||||||
|
.build(),
|
||||||
|
HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResource("/updatepodresponse.json"))
|
||||||
|
.build());
|
||||||
|
|
||||||
|
Pod expected = Pod.builder()
|
||||||
|
.id(7)
|
||||||
|
.name("richard-updatedpod")
|
||||||
|
.zoneId(11)
|
||||||
|
.zoneName("richard-zone")
|
||||||
|
.gateway("172.21.0.254")
|
||||||
|
.netmask("255.255.255.128")
|
||||||
|
.startIp("172.21.0.129")
|
||||||
|
.endIp("172.21.0.250")
|
||||||
|
.allocationState(AllocationState.DISABLED)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Pod actual = client.updatePod(7, UpdatePodOptions.Builder
|
||||||
|
.netmask("255.255.255.128")
|
||||||
|
.name("richard-updatepod")
|
||||||
|
.startIp("172.21.0.129")
|
||||||
|
.endIp("172.21.0.250")
|
||||||
|
.gateway("172.21.0.254")
|
||||||
|
.allocationState(AllocationState.DISABLED)
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(actual, expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDeletePodWhenResponseIs2xx() {
|
||||||
|
GlobalPodClient client = requestSendsResponse(
|
||||||
|
HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(
|
||||||
|
URI.create("http://localhost:8080/client/api?response=json&command=deletePod&id=3&apiKey=identity&signature=rm4ItuAL1Ztnj%2BHFFvBFzvHAIog%3D"))
|
||||||
|
.headers(
|
||||||
|
ImmutableMultimap.<String, String>builder()
|
||||||
|
.put("Accept", "application/json")
|
||||||
|
.build())
|
||||||
|
.build(),
|
||||||
|
HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
client.deletePod(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected GlobalPodClient clientFrom(CloudStackContext context) {
|
||||||
|
return context.getGlobalContext().getApi().getPodClient();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
/**
|
||||||
|
* 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.features;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
|
import org.jclouds.cloudstack.domain.NetworkType;
|
||||||
|
import org.jclouds.cloudstack.domain.Pod;
|
||||||
|
import org.jclouds.cloudstack.domain.Zone;
|
||||||
|
import org.jclouds.cloudstack.options.CreatePodOptions;
|
||||||
|
import org.jclouds.cloudstack.options.ListPodsOptions;
|
||||||
|
import org.jclouds.cloudstack.options.UpdatePodOptions;
|
||||||
|
import org.testng.annotations.AfterClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.jclouds.cloudstack.options.UpdateZoneOptions.Builder.name;
|
||||||
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code GlobalPodClient}
|
||||||
|
*
|
||||||
|
* @author Richard Downer
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", singleThreaded = true, testName = "GlobalPodClientLiveTest")
|
||||||
|
public class GlobalPodClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
|
private Zone zone;
|
||||||
|
private Pod pod;
|
||||||
|
|
||||||
|
public void testListPods() throws Exception {
|
||||||
|
Set<Pod> response = globalAdminClient.getPodClient().listPods();
|
||||||
|
assert null != response;
|
||||||
|
long podCount = response.size();
|
||||||
|
assertTrue(podCount >= 0);
|
||||||
|
for (Pod pod : response) {
|
||||||
|
Pod newDetails = Iterables.getOnlyElement(globalAdminClient.getPodClient().listPods(
|
||||||
|
ListPodsOptions.Builder.id(pod.getId())));
|
||||||
|
assertEquals(pod, newDetails);
|
||||||
|
assertEquals(pod, globalAdminClient.getPodClient().getPod(pod.getId()));
|
||||||
|
assertFalse(pod.getId() <= 0);
|
||||||
|
assertFalse(Strings.isNullOrEmpty(pod.getName()));
|
||||||
|
assertFalse(pod.getZoneId() <= 0);
|
||||||
|
assertFalse(Strings.isNullOrEmpty(pod.getZoneName()));
|
||||||
|
assertFalse(Strings.isNullOrEmpty(pod.getGateway()));
|
||||||
|
assertFalse(Strings.isNullOrEmpty(pod.getNetmask()));
|
||||||
|
assertFalse(Strings.isNullOrEmpty(pod.getStartIp()));
|
||||||
|
assertFalse(Strings.isNullOrEmpty(pod.getEndIp()));
|
||||||
|
assertNotEquals(pod.getAllocationState(), AllocationState.UNKNOWN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreatePod() {
|
||||||
|
assertTrue(globalAdminEnabled, "Global admin credentials must be given");
|
||||||
|
|
||||||
|
zone = globalAdminClient.getZoneClient().createZone(prefix + "-zone", NetworkType.BASIC, "8.8.8.8", "10.10.10.10");
|
||||||
|
pod = globalAdminClient.getPodClient().createPod(prefix + "-pod", zone.getId(), "172.20.0.1", "172.20.0.250", "172.20.0.254", "255.255.255.0",
|
||||||
|
CreatePodOptions.Builder.allocationState(AllocationState.ENABLED));
|
||||||
|
|
||||||
|
assertNotNull(pod);
|
||||||
|
assertEquals(pod.getName(), prefix + "-pod");
|
||||||
|
assertEquals(pod.getZoneId(), zone.getId());
|
||||||
|
assertEquals(pod.getZoneName(), prefix + "-zone");
|
||||||
|
assertEquals(pod.getStartIp(), "172.20.0.1");
|
||||||
|
assertEquals(pod.getEndIp(), "172.20.0.250");
|
||||||
|
assertEquals(pod.getGateway(), "172.20.0.254");
|
||||||
|
assertEquals(pod.getNetmask(), "255.255.255.0");
|
||||||
|
assertEquals(pod.getAllocationState(), AllocationState.ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dependsOnMethods = "testCreatePod")
|
||||||
|
public void testUpdatePod() {
|
||||||
|
Pod updated = globalAdminClient.getPodClient().updatePod(pod.getId(), UpdatePodOptions.Builder
|
||||||
|
.name(prefix + "-updatedpod")
|
||||||
|
.startIp("172.21.0.129")
|
||||||
|
.endIp("172.21.0.250")
|
||||||
|
.gateway("172.21.0.254")
|
||||||
|
.netmask("255.255.255.128")
|
||||||
|
.allocationState(AllocationState.DISABLED)
|
||||||
|
);
|
||||||
|
|
||||||
|
assertNotNull(updated);
|
||||||
|
assertEquals(updated.getName(), prefix + "-updatedpod");
|
||||||
|
assertEquals(updated.getZoneId(), zone.getId());
|
||||||
|
assertEquals(updated.getZoneName(), prefix + "-zone");
|
||||||
|
assertEquals(updated.getStartIp(), "172.21.0.129");
|
||||||
|
assertEquals(updated.getEndIp(), "172.21.0.250");
|
||||||
|
assertEquals(updated.getGateway(), "172.21.0.254");
|
||||||
|
assertEquals(updated.getNetmask(), "255.255.255.128");
|
||||||
|
assertEquals(updated.getAllocationState(), AllocationState.DISABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public void testFixtureTearDown() {
|
||||||
|
if (pod != null) {
|
||||||
|
globalAdminClient.getPodClient().deletePod(pod.getId());
|
||||||
|
pod = null;
|
||||||
|
}
|
||||||
|
if (zone != null) {
|
||||||
|
globalAdminClient.getZoneClient().deleteZone(zone.getId());
|
||||||
|
zone = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ package org.jclouds.cloudstack.features;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import org.jclouds.cloudstack.CloudStackContext;
|
import org.jclouds.cloudstack.CloudStackContext;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.cloudstack.domain.NetworkType;
|
import org.jclouds.cloudstack.domain.NetworkType;
|
||||||
import org.jclouds.cloudstack.domain.Zone;
|
import org.jclouds.cloudstack.domain.Zone;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
@ -68,7 +69,7 @@ public class GlobalZoneClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.internalDNS(ImmutableList.of("10.10.10.10"))
|
.internalDNS(ImmutableList.of("10.10.10.10"))
|
||||||
.networkType(NetworkType.BASIC)
|
.networkType(NetworkType.BASIC)
|
||||||
.securityGroupsEnabled(true)
|
.securityGroupsEnabled(true)
|
||||||
.allocationState(Zone.AllocationState.ENABLED)
|
.allocationState(AllocationState.ENABLED)
|
||||||
.zoneToken("7b6e27df-30a6-3024-9d8b-7971a3127f64")
|
.zoneToken("7b6e27df-30a6-3024-9d8b-7971a3127f64")
|
||||||
.dhcpProvider("DhcpServer").build());
|
.dhcpProvider("DhcpServer").build());
|
||||||
|
|
||||||
|
@ -102,7 +103,7 @@ public class GlobalZoneClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.internalDNS(ImmutableList.of("10.10.10.10"))
|
.internalDNS(ImmutableList.of("10.10.10.10"))
|
||||||
.networkType(NetworkType.BASIC)
|
.networkType(NetworkType.BASIC)
|
||||||
.securityGroupsEnabled(true)
|
.securityGroupsEnabled(true)
|
||||||
.allocationState(Zone.AllocationState.ENABLED)
|
.allocationState(AllocationState.ENABLED)
|
||||||
.zoneToken("7b6e27df-30a6-3024-9d8b-7971a3127f64")
|
.zoneToken("7b6e27df-30a6-3024-9d8b-7971a3127f64")
|
||||||
.dhcpProvider("DhcpServer").build());
|
.dhcpProvider("DhcpServer").build());
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.cloudstack.options;
|
package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import static org.jclouds.cloudstack.options.AddClusterOptions.Builder.*;
|
import static org.jclouds.cloudstack.options.AddClusterOptions.Builder.*;
|
||||||
|
@ -34,12 +34,12 @@ import static org.testng.Assert.assertEquals;
|
||||||
public class AddClusterOptionsTest {
|
public class AddClusterOptionsTest {
|
||||||
|
|
||||||
public void testAllocationState() {
|
public void testAllocationState() {
|
||||||
AddClusterOptions options = new AddClusterOptions().allocationState(Host.AllocationState.ENABLED);
|
AddClusterOptions options = new AddClusterOptions().allocationState(AllocationState.ENABLED);
|
||||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllocationStateStatic() {
|
public void testAllocationStateStatic() {
|
||||||
AddClusterOptions options = allocationState(Host.AllocationState.ENABLED);
|
AddClusterOptions options = allocationState(AllocationState.ENABLED);
|
||||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import static org.jclouds.cloudstack.options.AddHostOptions.Builder.*;
|
import static org.jclouds.cloudstack.options.AddHostOptions.Builder.*;
|
||||||
|
@ -35,12 +35,12 @@ import static org.testng.Assert.assertEquals;
|
||||||
public class AddHostOptionsTest {
|
public class AddHostOptionsTest {
|
||||||
|
|
||||||
public void testAllocationState() {
|
public void testAllocationState() {
|
||||||
AddHostOptions options = new AddHostOptions().allocationState(Host.AllocationState.ENABLED);
|
AddHostOptions options = new AddHostOptions().allocationState(AllocationState.ENABLED);
|
||||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllocationStateStatic() {
|
public void testAllocationStateStatic() {
|
||||||
AddHostOptions options = allocationState(Host.AllocationState.ENABLED);
|
AddHostOptions options = allocationState(AllocationState.ENABLED);
|
||||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
* 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.options;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import static org.jclouds.cloudstack.options.CreatePodOptions.Builder.*;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code CreatePodOptions}
|
||||||
|
*
|
||||||
|
* @author Richard Downer
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class CreatePodOptionsTest {
|
||||||
|
|
||||||
|
public void testAllocationState() {
|
||||||
|
CreatePodOptions options = new CreatePodOptions().allocationState(AllocationState.ENABLED);
|
||||||
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllocationStateStatic() {
|
||||||
|
CreatePodOptions options = allocationState(AllocationState.ENABLED);
|
||||||
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.cloudstack.options;
|
package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.cloudstack.domain.Cluster;
|
import org.jclouds.cloudstack.domain.Cluster;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.Host;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -35,12 +36,12 @@ import static org.testng.Assert.assertEquals;
|
||||||
public class ListClustersOptionsTest {
|
public class ListClustersOptionsTest {
|
||||||
|
|
||||||
public void testAllocationState() {
|
public void testAllocationState() {
|
||||||
ListClustersOptions options = new ListClustersOptions().allocationState(Host.AllocationState.ENABLED);
|
ListClustersOptions options = new ListClustersOptions().allocationState(AllocationState.ENABLED);
|
||||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllocationStateStatic() {
|
public void testAllocationStateStatic() {
|
||||||
ListClustersOptions options = allocationState(Host.AllocationState.ENABLED);
|
ListClustersOptions options = allocationState(AllocationState.ENABLED);
|
||||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.cloudstack.options;
|
package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.Host;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -55,12 +56,12 @@ public class ListHostsOptionsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllocationState() {
|
public void testAllocationState() {
|
||||||
ListHostsOptions options = new ListHostsOptions().allocationState(Host.AllocationState.ENABLED);
|
ListHostsOptions options = new ListHostsOptions().allocationState(AllocationState.ENABLED);
|
||||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllocationStateStatic() {
|
public void testAllocationStateStatic() {
|
||||||
ListHostsOptions options = allocationState(Host.AllocationState.ENABLED);
|
ListHostsOptions options = allocationState(AllocationState.ENABLED);
|
||||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
/**
|
||||||
|
* 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.options;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import static org.jclouds.cloudstack.options.ListPodsOptions.Builder.*;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code ListPodsOptions}
|
||||||
|
*
|
||||||
|
* @author Richard Downer
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class ListPodsOptionsTest {
|
||||||
|
|
||||||
|
public void testId() {
|
||||||
|
ListPodsOptions options = new ListPodsOptions().id(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIdStatic() {
|
||||||
|
ListPodsOptions options = id(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllocationState() {
|
||||||
|
ListPodsOptions options = new ListPodsOptions().allocationState(AllocationState.ENABLED);
|
||||||
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllocationStateStatic() {
|
||||||
|
ListPodsOptions options = allocationState(AllocationState.ENABLED);
|
||||||
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testKeyword() {
|
||||||
|
ListPodsOptions options = new ListPodsOptions().keyword("fred");
|
||||||
|
assertEquals(ImmutableList.of("fred"), options.buildQueryParameters().get("keyword"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testKeywordStatic() {
|
||||||
|
ListPodsOptions options = keyword("fred");
|
||||||
|
assertEquals(ImmutableList.of("fred"), options.buildQueryParameters().get("keyword"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testName() {
|
||||||
|
ListPodsOptions options = new ListPodsOptions().name("bob");
|
||||||
|
assertEquals(ImmutableList.of("bob"), options.buildQueryParameters().get("name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNameStatic() {
|
||||||
|
ListPodsOptions options = name("bob");
|
||||||
|
assertEquals(ImmutableList.of("bob"), options.buildQueryParameters().get("name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testZoneId() {
|
||||||
|
ListPodsOptions options = new ListPodsOptions().zoneId(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("zoneid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testZoneIdStatic() {
|
||||||
|
ListPodsOptions options = zoneId(6);
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("zoneid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.cloudstack.options;
|
package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.cloudstack.domain.Cluster;
|
import org.jclouds.cloudstack.domain.Cluster;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.Host;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -35,12 +36,12 @@ import static org.testng.Assert.assertEquals;
|
||||||
public class UpdateClusterOptionsTest {
|
public class UpdateClusterOptionsTest {
|
||||||
|
|
||||||
public void testAllocationState() {
|
public void testAllocationState() {
|
||||||
UpdateClusterOptions options = new UpdateClusterOptions().allocationState(Host.AllocationState.ENABLED);
|
UpdateClusterOptions options = new UpdateClusterOptions().allocationState(AllocationState.ENABLED);
|
||||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllocationStateStatic() {
|
public void testAllocationStateStatic() {
|
||||||
UpdateClusterOptions options = allocationState(Host.AllocationState.ENABLED);
|
UpdateClusterOptions options = allocationState(AllocationState.ENABLED);
|
||||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import static org.jclouds.cloudstack.options.UpdateHostOptions.Builder.*;
|
import static org.jclouds.cloudstack.options.UpdateHostOptions.Builder.*;
|
||||||
|
@ -35,12 +35,12 @@ import static org.testng.Assert.assertEquals;
|
||||||
public class UpdateHostOptionsTest {
|
public class UpdateHostOptionsTest {
|
||||||
|
|
||||||
public void testAllocationState() {
|
public void testAllocationState() {
|
||||||
UpdateHostOptions options = new UpdateHostOptions().allocationState(Host.AllocationState.ENABLED);
|
UpdateHostOptions options = new UpdateHostOptions().allocationState(AllocationState.ENABLED);
|
||||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllocationStateStatic() {
|
public void testAllocationStateStatic() {
|
||||||
UpdateHostOptions options = allocationState(Host.AllocationState.ENABLED);
|
UpdateHostOptions options = allocationState(AllocationState.ENABLED);
|
||||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
/**
|
||||||
|
* 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.options;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import static org.jclouds.cloudstack.options.UpdatePodOptions.Builder.*;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code UpdatePodOptions}
|
||||||
|
*
|
||||||
|
* @author Richard Downer
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class UpdatePodOptionsTest {
|
||||||
|
|
||||||
|
public void testName() {
|
||||||
|
UpdatePodOptions options = new UpdatePodOptions().name("fred");
|
||||||
|
assertEquals(ImmutableList.of("fred"), options.buildQueryParameters().get("name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNameStatic() {
|
||||||
|
UpdatePodOptions options = name("fred");
|
||||||
|
assertEquals(ImmutableList.of("fred"), options.buildQueryParameters().get("name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testStartIp() {
|
||||||
|
UpdatePodOptions options = new UpdatePodOptions().startIp("192.168.42.42");
|
||||||
|
assertEquals(ImmutableList.of("192.168.42.42"), options.buildQueryParameters().get("startip"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testStartIpStatic() {
|
||||||
|
UpdatePodOptions options = startIp("192.168.42.42");
|
||||||
|
assertEquals(ImmutableList.of("192.168.42.42"), options.buildQueryParameters().get("startip"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testEndIp() {
|
||||||
|
UpdatePodOptions options = new UpdatePodOptions().endIp("192.168.42.52");
|
||||||
|
assertEquals(ImmutableList.of("192.168.42.52"), options.buildQueryParameters().get("endip"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testEndIpStatic() {
|
||||||
|
UpdatePodOptions options = endIp("192.168.42.52");
|
||||||
|
assertEquals(ImmutableList.of("192.168.42.52"), options.buildQueryParameters().get("endip"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGateway() {
|
||||||
|
UpdatePodOptions options = new UpdatePodOptions().gateway("192.168.42.62");
|
||||||
|
assertEquals(ImmutableList.of("192.168.42.62"), options.buildQueryParameters().get("gateway"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGatewayStatic() {
|
||||||
|
UpdatePodOptions options = gateway("192.168.42.62");
|
||||||
|
assertEquals(ImmutableList.of("192.168.42.62"), options.buildQueryParameters().get("gateway"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNetmask() {
|
||||||
|
UpdatePodOptions options = new UpdatePodOptions().netmask("255.255.240.0");
|
||||||
|
assertEquals(ImmutableList.of("255.255.240.0"), options.buildQueryParameters().get("netmask"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNetmaskStatic() {
|
||||||
|
UpdatePodOptions options = netmask("255.255.240.0");
|
||||||
|
assertEquals(ImmutableList.of("255.255.240.0"), options.buildQueryParameters().get("netmask"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllocationState() {
|
||||||
|
UpdatePodOptions options = new UpdatePodOptions().allocationState(AllocationState.ENABLED);
|
||||||
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllocationStateStatic() {
|
||||||
|
UpdatePodOptions options = allocationState(AllocationState.ENABLED);
|
||||||
|
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,14 +19,10 @@
|
||||||
package org.jclouds.cloudstack.parse;
|
package org.jclouds.cloudstack.parse;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Guice;
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import com.google.inject.Injector;
|
|
||||||
import org.jclouds.cloudstack.config.CloudStackParserModule;
|
|
||||||
import org.jclouds.cloudstack.domain.Cluster;
|
import org.jclouds.cloudstack.domain.Cluster;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.Host;
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
|
||||||
import org.jclouds.json.BaseSetParserTest;
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.jclouds.json.config.GsonModule;
|
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -53,7 +49,7 @@ public class ListClustersResponseTest extends BaseSetParserTest<Cluster> {
|
||||||
.zoneId(1).zoneName("Dev Zone 1")
|
.zoneId(1).zoneName("Dev Zone 1")
|
||||||
.hypervisor("XenServer")
|
.hypervisor("XenServer")
|
||||||
.clusterType(Host.ClusterType.CLOUD_MANAGED)
|
.clusterType(Host.ClusterType.CLOUD_MANAGED)
|
||||||
.allocationState(Host.AllocationState.ENABLED)
|
.allocationState(AllocationState.ENABLED)
|
||||||
.managedState(Cluster.ManagedState.MANAGED)
|
.managedState(Cluster.ManagedState.MANAGED)
|
||||||
.build();
|
.build();
|
||||||
Cluster cluster2 = Cluster.builder()
|
Cluster cluster2 = Cluster.builder()
|
||||||
|
@ -63,7 +59,7 @@ public class ListClustersResponseTest extends BaseSetParserTest<Cluster> {
|
||||||
.zoneId(2).zoneName("Dev Zone 2")
|
.zoneId(2).zoneName("Dev Zone 2")
|
||||||
.hypervisor("XenServer")
|
.hypervisor("XenServer")
|
||||||
.clusterType(Host.ClusterType.CLOUD_MANAGED)
|
.clusterType(Host.ClusterType.CLOUD_MANAGED)
|
||||||
.allocationState(Host.AllocationState.ENABLED)
|
.allocationState(AllocationState.ENABLED)
|
||||||
.managedState(Cluster.ManagedState.MANAGED)
|
.managedState(Cluster.ManagedState.MANAGED)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import org.jclouds.cloudstack.config.CloudStackParserModule;
|
import org.jclouds.cloudstack.config.CloudStackParserModule;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
import org.jclouds.cloudstack.domain.Host;
|
import org.jclouds.cloudstack.domain.Host;
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
import org.jclouds.json.BaseSetParserTest;
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
|
@ -95,7 +96,7 @@ public class ListHostsResponseTest extends BaseSetParserTest<Host> {
|
||||||
"AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping")
|
"AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping")
|
||||||
.hostTags("")
|
.hostTags("")
|
||||||
.hasEnoughCapacity(false)
|
.hasEnoughCapacity(false)
|
||||||
.allocationState(Host.AllocationState.ENABLED).build(),
|
.allocationState(AllocationState.ENABLED).build(),
|
||||||
|
|
||||||
Host.builder()
|
Host.builder()
|
||||||
.id(2)
|
.id(2)
|
||||||
|
@ -113,7 +114,7 @@ public class ListHostsResponseTest extends BaseSetParserTest<Host> {
|
||||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-11-26T23:33:38+0200"))
|
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-11-26T23:33:38+0200"))
|
||||||
.events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping")
|
.events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping")
|
||||||
.hasEnoughCapacity(false)
|
.hasEnoughCapacity(false)
|
||||||
.allocationState(Host.AllocationState.ENABLED).build(),
|
.allocationState(AllocationState.ENABLED).build(),
|
||||||
|
|
||||||
Host.builder()
|
Host.builder()
|
||||||
.id(3)
|
.id(3)
|
||||||
|
@ -133,7 +134,7 @@ public class ListHostsResponseTest extends BaseSetParserTest<Host> {
|
||||||
.events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; " +
|
.events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; " +
|
||||||
"AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping")
|
"AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping")
|
||||||
.hasEnoughCapacity(false)
|
.hasEnoughCapacity(false)
|
||||||
.allocationState(Host.AllocationState.ENABLED).build(),
|
.allocationState(AllocationState.ENABLED).build(),
|
||||||
|
|
||||||
Host.builder()
|
Host.builder()
|
||||||
.id(4)
|
.id(4)
|
||||||
|
@ -153,7 +154,7 @@ public class ListHostsResponseTest extends BaseSetParserTest<Host> {
|
||||||
.events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; " +
|
.events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; " +
|
||||||
"AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping")
|
"AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping")
|
||||||
.hasEnoughCapacity(false)
|
.hasEnoughCapacity(false)
|
||||||
.allocationState(Host.AllocationState.ENABLED).build()
|
.allocationState(AllocationState.ENABLED).build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
/**
|
||||||
|
* 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 com.google.common.collect.ImmutableSet;
|
||||||
|
import org.jclouds.cloudstack.domain.AllocationState;
|
||||||
|
import org.jclouds.cloudstack.domain.Host;
|
||||||
|
import org.jclouds.cloudstack.domain.NetworkType;
|
||||||
|
import org.jclouds.cloudstack.domain.Pod;
|
||||||
|
import org.jclouds.cloudstack.domain.Zone;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Richard Downer
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class ListPodsResponseTest extends BaseSetParserTest<Pod> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String resource() {
|
||||||
|
return "/listpodsresponse.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SelectJson("pod")
|
||||||
|
public Set<Pod> expected() {
|
||||||
|
Pod pod1 = Pod.builder()
|
||||||
|
.id(1)
|
||||||
|
.name("Dev Pod 1")
|
||||||
|
.zoneId(1)
|
||||||
|
.zoneName("Dev Zone 1")
|
||||||
|
.gateway("10.26.26.254")
|
||||||
|
.netmask("255.255.255.0")
|
||||||
|
.startIp("10.26.26.50")
|
||||||
|
.endIp("10.26.26.100")
|
||||||
|
.allocationState(AllocationState.ENABLED)
|
||||||
|
.build();
|
||||||
|
Pod pod2 = Pod.builder()
|
||||||
|
.id(2)
|
||||||
|
.name("Dev Pod 2")
|
||||||
|
.zoneId(2)
|
||||||
|
.zoneName("Dev Zone 2")
|
||||||
|
.gateway("10.22.22.254")
|
||||||
|
.netmask("255.255.255.0")
|
||||||
|
.startIp("10.22.22.25")
|
||||||
|
.endIp("10.22.22.50")
|
||||||
|
.allocationState(AllocationState.ENABLED)
|
||||||
|
.build();
|
||||||
|
return ImmutableSet.of(pod1, pod2);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
{ "createpodresponse" : { "pod" : {"id":6,"name":"richard-pod","zoneid":10,"zonename":"richard-zone","gateway":"172.20.0.254","netmask":"255.255.255.0","startip":"172.20.0.1","endip":"172.20.0.250","allocationstate":"Enabled"} } }
|
|
@ -0,0 +1 @@
|
||||||
|
{ "listpodsresponse" : { "count":2 ,"pod" : [ {"id":1,"name":"Dev Pod 1","zoneid":1,"zonename":"Dev Zone 1","gateway":"10.26.26.254","netmask":"255.255.255.0","startip":"10.26.26.50","endip":"10.26.26.100","allocationstate":"Enabled"}, {"id":2,"name":"Dev Pod 2","zoneid":2,"zonename":"Dev Zone 2","gateway":"10.22.22.254","netmask":"255.255.255.0","startip":"10.22.22.25","endip":"10.22.22.50","allocationstate":"Enabled"} ] } }
|
|
@ -0,0 +1 @@
|
||||||
|
{ "updatepodresponse" : { "pod" : {"id":7,"name":"richard-updatedpod","zoneid":11,"zonename":"richard-zone","gateway":"172.21.0.254","netmask":"255.255.255.128","startip":"172.21.0.129","endip":"172.21.0.250","allocationstate":"Disabled"} } }
|
Loading…
Reference in New Issue