mirror of https://github.com/apache/jclouds.git
refactored cloudstack tests
This commit is contained in:
parent
15e74945da
commit
3a690186f4
|
@ -0,0 +1,140 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.config;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.Account.State;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Configures the cloudstack parsers.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CloudStackParserModule extends AbstractModule {
|
||||
|
||||
@Singleton
|
||||
public static class BreakGenericSetAdapter implements JsonSerializer<Account>, JsonDeserializer<Account> {
|
||||
|
||||
public JsonElement serialize(Account src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return context.serialize(src);
|
||||
}
|
||||
|
||||
public Account deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||
throws JsonParseException {
|
||||
return apply(context.<AccountInternal> deserialize(json, AccountInternal.class));
|
||||
}
|
||||
|
||||
public Account apply(AccountInternal in) {
|
||||
return Account.builder().id(in.id).type(in.type).domain(in.domain).domainId(in.domainId)
|
||||
.IPsAvailable(nullIfUnlimited(in.IPsAvailable)).IPLimit(nullIfUnlimited(in.IPLimit)).IPs(in.IPs)
|
||||
.cleanupRequired(in.cleanupRequired).name(in.name).receivedBytes(in.receivedBytes)
|
||||
.sentBytes(in.sentBytes).snapshotsAvailable(nullIfUnlimited(in.snapshotsAvailable))
|
||||
.snapshotLimit(nullIfUnlimited(in.snapshotLimit)).snapshots(in.snapshots).state(in.state)
|
||||
.templatesAvailable(nullIfUnlimited(in.templatesAvailable))
|
||||
.templateLimit(nullIfUnlimited(in.templateLimit)).templates(in.templates)
|
||||
.VMsAvailable(nullIfUnlimited(in.VMsAvailable)).VMLimit(nullIfUnlimited(in.VMLimit))
|
||||
.VMsRunning(in.VMsRunning).VMsStopped(in.VMsStopped).VMs(in.VMs)
|
||||
.volumesAvailable(nullIfUnlimited(in.volumesAvailable)).volumeLimit(nullIfUnlimited(in.volumeLimit))
|
||||
.volumes(in.volumes).users(in.users).build();
|
||||
}
|
||||
|
||||
static final class AccountInternal {
|
||||
private long id;
|
||||
@SerializedName("accounttype")
|
||||
private Account.Type type;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private long domainId;
|
||||
@SerializedName("ipavailable")
|
||||
private String IPsAvailable;
|
||||
@SerializedName("iplimit")
|
||||
private String IPLimit;
|
||||
@SerializedName("iptotal")
|
||||
private long IPs;
|
||||
@SerializedName("iscleanuprequired")
|
||||
private boolean cleanupRequired;
|
||||
private String name;
|
||||
@SerializedName("receivedbytes")
|
||||
private long receivedBytes;
|
||||
@SerializedName("sentBytes")
|
||||
private long sentBytes;
|
||||
@SerializedName("snapshotavailable")
|
||||
private String snapshotsAvailable;
|
||||
@SerializedName("snapshotlimit")
|
||||
private String snapshotLimit;
|
||||
@SerializedName("snapshottotal")
|
||||
private long snapshots;
|
||||
@SerializedName("state")
|
||||
private State state;
|
||||
@SerializedName("templateavailable")
|
||||
private String templatesAvailable;
|
||||
@SerializedName("templatelimit")
|
||||
private String templateLimit;
|
||||
@SerializedName("templatetotal")
|
||||
private long templates;
|
||||
@SerializedName("vmavailable")
|
||||
private String VMsAvailable;
|
||||
@SerializedName("vmlimit")
|
||||
private String VMLimit;
|
||||
@SerializedName("vmrunning")
|
||||
private long VMsRunning;
|
||||
@SerializedName("vmstopped")
|
||||
private long VMsStopped;
|
||||
@SerializedName("vmtotal")
|
||||
private long VMs;
|
||||
@SerializedName("volumeavailable")
|
||||
private String volumesAvailable;
|
||||
@SerializedName("volumelimit")
|
||||
private String volumeLimit;
|
||||
@SerializedName("volumetotal")
|
||||
private long volumes;
|
||||
@SerializedName("user")
|
||||
private Set<User> users;
|
||||
}
|
||||
|
||||
private static Long nullIfUnlimited(String in) {
|
||||
return in == null || "Unlimited".equals(in) ? null : new Long(in);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(new TypeLiteral<Map<Type, Object>>() {
|
||||
}).toInstance(ImmutableMap.<Type, Object> of(Account.class, new BreakGenericSetAdapter()));
|
||||
}
|
||||
|
||||
}
|
|
@ -18,17 +18,10 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.config;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.cloudstack.CloudStackAsyncClient;
|
||||
import org.jclouds.cloudstack.CloudStackClient;
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.cloudstack.domain.Account.State;
|
||||
import org.jclouds.cloudstack.features.AccountAsyncClient;
|
||||
import org.jclouds.cloudstack.features.AccountClient;
|
||||
import org.jclouds.cloudstack.features.AddressAsyncClient;
|
||||
|
@ -73,14 +66,6 @@ import org.jclouds.rest.ConfiguresRestClient;
|
|||
import org.jclouds.rest.config.RestClientModule;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Configures the cloudstack connection.
|
||||
|
@ -113,91 +98,6 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
|
|||
super(CloudStackClient.class, CloudStackAsyncClient.class, DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class BreakGenericSetAdapter implements JsonSerializer<Account>, JsonDeserializer<Account> {
|
||||
|
||||
public JsonElement serialize(Account src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return context.serialize(src);
|
||||
}
|
||||
|
||||
public Account deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||
throws JsonParseException {
|
||||
return apply(context.<AccountInternal> deserialize(json, AccountInternal.class));
|
||||
}
|
||||
|
||||
public Account apply(AccountInternal in) {
|
||||
return Account.builder().id(in.id).type(in.type).domain(in.domain).domainId(in.domainId).IPsAvailable(
|
||||
nullIfUnlimited(in.IPsAvailable)).IPLimit(nullIfUnlimited(in.IPLimit)).IPs(in.IPs).cleanupRequired(
|
||||
in.cleanupRequired).name(in.name).receivedBytes(in.receivedBytes).sentBytes(in.sentBytes)
|
||||
.snapshotsAvailable(nullIfUnlimited(in.snapshotsAvailable)).snapshotLimit(
|
||||
nullIfUnlimited(in.snapshotLimit)).snapshots(in.snapshots).state(in.state)
|
||||
.templatesAvailable(nullIfUnlimited(in.templatesAvailable)).templateLimit(
|
||||
nullIfUnlimited(in.templateLimit)).templates(in.templates).VMsAvailable(
|
||||
nullIfUnlimited(in.VMsAvailable)).VMLimit(nullIfUnlimited(in.VMLimit)).VMsRunning(
|
||||
in.VMsRunning).VMsStopped(in.VMsStopped).VMs(in.VMs).volumesAvailable(
|
||||
nullIfUnlimited(in.volumesAvailable)).volumeLimit(nullIfUnlimited(in.volumeLimit)).volumes(
|
||||
in.volumes).users(in.users).build();
|
||||
}
|
||||
|
||||
static final class AccountInternal {
|
||||
private long id;
|
||||
@SerializedName("accounttype")
|
||||
private Account.Type type;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private long domainId;
|
||||
@SerializedName("ipavailable")
|
||||
private String IPsAvailable;
|
||||
@SerializedName("iplimit")
|
||||
private String IPLimit;
|
||||
@SerializedName("iptotal")
|
||||
private long IPs;
|
||||
@SerializedName("iscleanuprequired")
|
||||
private boolean cleanupRequired;
|
||||
private String name;
|
||||
@SerializedName("receivedbytes")
|
||||
private long receivedBytes;
|
||||
@SerializedName("sentBytes")
|
||||
private long sentBytes;
|
||||
@SerializedName("snapshotavailable")
|
||||
private String snapshotsAvailable;
|
||||
@SerializedName("snapshotlimit")
|
||||
private String snapshotLimit;
|
||||
@SerializedName("snapshottotal")
|
||||
private long snapshots;
|
||||
@SerializedName("state")
|
||||
private State state;
|
||||
@SerializedName("templateavailable")
|
||||
private String templatesAvailable;
|
||||
@SerializedName("templatelimit")
|
||||
private String templateLimit;
|
||||
@SerializedName("templatetotal")
|
||||
private long templates;
|
||||
@SerializedName("vmavailable")
|
||||
private String VMsAvailable;
|
||||
@SerializedName("vmlimit")
|
||||
private String VMLimit;
|
||||
@SerializedName("vmrunning")
|
||||
private long VMsRunning;
|
||||
@SerializedName("vmstopped")
|
||||
private long VMsStopped;
|
||||
@SerializedName("vmtotal")
|
||||
private long VMs;
|
||||
@SerializedName("volumeavailable")
|
||||
private String volumesAvailable;
|
||||
@SerializedName("volumelimit")
|
||||
private String volumeLimit;
|
||||
@SerializedName("volumetotal")
|
||||
private long volumes;
|
||||
@SerializedName("user")
|
||||
private Set<User> users;
|
||||
}
|
||||
|
||||
private static Long nullIfUnlimited(String in) {
|
||||
return in == null || "Unlimited".equals(in) ? null : new Long(in);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
|
@ -209,8 +109,7 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
|
|||
}
|
||||
|
||||
});
|
||||
bind(new TypeLiteral<Map<Type, Object>>() {
|
||||
}).toInstance(ImmutableMap.<Type, Object> of(Account.class, new BreakGenericSetAdapter()));
|
||||
install(new CloudStackParserModule());
|
||||
super.configure();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
|
@ -267,7 +269,8 @@ public class Network implements Comparable<Network> {
|
|||
@SerializedName("zoneid")
|
||||
private long zoneId;
|
||||
@SerializedName("service")
|
||||
private Set<? extends NetworkService> services = ImmutableSet.<NetworkService> of();
|
||||
// so tests and serialization comes out expected
|
||||
private SortedSet<? extends NetworkService> services = ImmutableSortedSet.<NetworkService> of();
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
|
@ -311,7 +314,7 @@ public class Network implements Comparable<Network> {
|
|||
this.VLAN = vLAN;
|
||||
this.trafficType = trafficType;
|
||||
this.zoneId = zoneId;
|
||||
this.services = ImmutableSet.copyOf(checkNotNull(services, "services"));
|
||||
this.services = ImmutableSortedSet.copyOf(checkNotNull(services, "services"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,20 +22,21 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class NetworkService {
|
||||
public class NetworkService implements Comparable<NetworkService> {
|
||||
// internal only to match json type
|
||||
private static class Capability {
|
||||
private static class Capability implements Comparable<Capability> {
|
||||
|
||||
private String name;
|
||||
private String value;
|
||||
|
@ -85,11 +86,17 @@ public class NetworkService {
|
|||
return "[name=" + name + ", value=" + value + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Capability o) {
|
||||
return name.compareTo(o.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String name;
|
||||
@SerializedName("capability")
|
||||
private Set<? extends NetworkService.Capability> capabilities = ImmutableSet.of();
|
||||
// so tests and serialization comes out expected
|
||||
private SortedSet<? extends NetworkService.Capability> capabilities = ImmutableSortedSet.of();
|
||||
|
||||
NetworkService() {
|
||||
|
||||
|
@ -101,7 +108,7 @@ public class NetworkService {
|
|||
|
||||
public NetworkService(String name, Map<String, String> capabilities) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
ImmutableSet.Builder<Capability> internal = ImmutableSet.<Capability> builder();
|
||||
ImmutableSortedSet.Builder<Capability> internal = ImmutableSortedSet.<Capability> naturalOrder();
|
||||
for (Entry<String, String> capabililty : checkNotNull(capabilities, "capabilities").entrySet())
|
||||
internal.add(new Capability(capabililty.getKey(), capabililty.getValue()));
|
||||
this.capabilities = internal.build();
|
||||
|
@ -112,7 +119,8 @@ public class NetworkService {
|
|||
}
|
||||
|
||||
public Map<String, String> getCapabilities() {
|
||||
Builder<String, String> returnVal = ImmutableMap.<String, String> builder();
|
||||
// so tests and serialization comes out expected
|
||||
Builder<String, String> returnVal = ImmutableSortedMap.<String, String> naturalOrder();
|
||||
for (Capability capability : capabilities) {
|
||||
returnVal.put(capability.name, capability.value);
|
||||
}
|
||||
|
@ -154,4 +162,9 @@ public class NetworkService {
|
|||
public String toString() {
|
||||
return "[name=" + name + ", capabilities=" + capabilities + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(NetworkService o) {
|
||||
return name.compareTo(o.getName());
|
||||
}
|
||||
}
|
|
@ -21,8 +21,10 @@ package org.jclouds.cloudstack.domain;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
|
@ -91,7 +93,8 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
|
|||
@SerializedName("domainid")
|
||||
private long domainId;
|
||||
@SerializedName("ingressrule")
|
||||
private Set<IngressRule> ingressRules = ImmutableSet.of();
|
||||
// so that tests and serialization come out expected
|
||||
private SortedSet<IngressRule> ingressRules = ImmutableSortedSet.<IngressRule> of();
|
||||
|
||||
public SecurityGroup(long id, String account, String name, String description, String domain, long domainId,
|
||||
Set<IngressRule> ingressRules) {
|
||||
|
@ -101,7 +104,7 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
|
|||
this.description = description;
|
||||
this.domain = domain;
|
||||
this.domainId = domainId;
|
||||
this.ingressRules = ImmutableSet.copyOf(checkNotNull(ingressRules, "ingressRules"));
|
||||
this.ingressRules = ImmutableSortedSet.copyOf(checkNotNull(ingressRules, "ingressRules"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.jclouds.http.HttpResponse;
|
|||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ public class ParseIdToNameFromHttpResponse implements Function<HttpResponse, Map
|
|||
checkNotNull(response, "response");
|
||||
Set<IdName> toParse = parser.apply(response);
|
||||
checkNotNull(toParse, "parsed result from %s", response);
|
||||
Builder<Long, String> builder = ImmutableMap.<Long, String> builder();
|
||||
Builder<Long, String> builder = ImmutableSortedMap.<Long, String> naturalOrder();
|
||||
for (IdName entry : toParse)
|
||||
builder.put(entry.id, entry.name);
|
||||
return builder.build();
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.functions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Capabilities;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListCapabilitiesResponseTest {
|
||||
public void test() {
|
||||
|
||||
UnwrapOnlyNestedJsonValue<Capabilities> parser = Guice.createInjector(new GsonModule()).getInstance(
|
||||
Key.get(new TypeLiteral<UnwrapOnlyNestedJsonValue<Capabilities>>() {
|
||||
}));
|
||||
Capabilities response = parser
|
||||
.apply(new HttpResponse(
|
||||
200,
|
||||
"ok",
|
||||
Payloads
|
||||
.newStringPayload("{ \"listcapabilitiesresponse\" : { \"capability\" : {\"securitygroupsenabled\":true,\"cloudstackversion\":\"2.2\",\"userpublictemplateenabled\":true} } }")));
|
||||
|
||||
assertEquals(Capabilities.builder().securityGroupsEnabled(true).sharedTemplatesEnabled(true).cloudStackVersion(
|
||||
"2.2").build(), response);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.functions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.NetworkOffering;
|
||||
import org.jclouds.cloudstack.domain.TrafficType;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListNetworkOfferingsResponseTest {
|
||||
|
||||
Injector i = Guice.createInjector(new GsonModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
super.configure();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/listnetworkofferingsresponse.json");
|
||||
|
||||
Set<NetworkOffering> expects = ImmutableSortedSet.<NetworkOffering> of(
|
||||
NetworkOffering.builder().id(6).name("DefaultVirtualizedNetworkOffering").displayText("Virtual Vlan")
|
||||
.trafficType(TrafficType.GUEST).isDefault(true).supportsVLAN(false).availability("Required")
|
||||
.networkRate(200).build(), NetworkOffering.builder().id(7).name("DefaultDirectNetworkOffering")
|
||||
.displayText("Direct").trafficType(TrafficType.PUBLIC).isDefault(true).supportsVLAN(false)
|
||||
.availability("Required").networkRate(200).build());
|
||||
|
||||
UnwrapOnlyNestedJsonValue<Set<NetworkOffering>> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyNestedJsonValue<Set<NetworkOffering>>>() {
|
||||
}));
|
||||
Set<NetworkOffering> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(Sets.newTreeSet(response), expects);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.functions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.PortForwardingRule;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListPortForwardingRuleResponseTest {
|
||||
|
||||
Injector i = Guice.createInjector(new GsonModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
super.configure();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/listportforwardingrulesresponse.json");
|
||||
|
||||
Set<PortForwardingRule> expects = ImmutableSortedSet.<PortForwardingRule> of(PortForwardingRule.builder().id(15)
|
||||
.privatePort(22).protocol("tcp").publicPort(2022).virtualMachineId(3).virtualMachineName("i-3-3-VM")
|
||||
.IPAddressId(3).IPAddress("72.52.126.32").state("Active").build(), PortForwardingRule.builder().id(18)
|
||||
.privatePort(22).protocol("tcp").publicPort(22).virtualMachineId(89).virtualMachineName("i-3-89-VM")
|
||||
.IPAddressId(34).IPAddress("72.52.126.63").state("Active").build());
|
||||
|
||||
UnwrapOnlyNestedJsonValue<Set<PortForwardingRule>> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyNestedJsonValue<Set<PortForwardingRule>>>() {
|
||||
}));
|
||||
Set<PortForwardingRule> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(Sets.newTreeSet(response), expects);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.functions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListPublicIPAddressesResponseTest {
|
||||
|
||||
Injector i = Guice.createInjector(new GsonModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
super.configure();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/listpublicipaddressesresponse.json");
|
||||
|
||||
PublicIPAddress expects = PublicIPAddress.builder().id(30).IPAddress("72.52.126.59").allocated(
|
||||
new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-02-19T21:15:01-0800")).zoneId(1)
|
||||
.zoneName("San Jose 1").isSourceNAT(false).account("adrian").domainId(1).domain("ROOT")
|
||||
.usesVirtualNetwork(true).isStaticNAT(false).associatedNetworkId(204).networkId(200).state(
|
||||
PublicIPAddress.State.ALLOCATED).build();
|
||||
|
||||
UnwrapOnlyNestedJsonValue<Set<PublicIPAddress>> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyNestedJsonValue<Set<PublicIPAddress>>>() {
|
||||
}));
|
||||
Set<PublicIPAddress> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(Iterables.getOnlyElement(response), expects);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.functions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.IngressRule;
|
||||
import org.jclouds.cloudstack.domain.SecurityGroup;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListSecurityGroupsResponseTest {
|
||||
|
||||
Injector i = Guice.createInjector(new GsonModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
super.configure();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/listsecuritygroupsresponse.json");
|
||||
|
||||
Set<SecurityGroup> expects = ImmutableSortedSet.<SecurityGroup> naturalOrder().add(
|
||||
|
||||
SecurityGroup.builder().id(12).name("adriancole").account("adrian").domainId(1).domain("ROOT").build()).add(
|
||||
SecurityGroup.builder().id(13).name("default").description("description").account("adrian").domainId(1)
|
||||
.domain("ROOT").ingressRules(
|
||||
ImmutableSet.of(
|
||||
|
||||
IngressRule.builder().id(5).protocol("tcp").startPort(22).endPort(22)
|
||||
.securityGroupName("adriancole").account("adrian").build(),
|
||||
|
||||
IngressRule.builder().id(6).protocol("udp").startPort(11).endPort(11).CIDR(
|
||||
"1.1.1.1/24").build())).build()).add(
|
||||
SecurityGroup.builder().id(14).name("1").description("description").account("adrian").domainId(1)
|
||||
.domain("ROOT").ingressRules(
|
||||
ImmutableSet.of(
|
||||
|
||||
IngressRule.builder().id(7).protocol("tcp").startPort(10).endPort(10).CIDR(
|
||||
"1.1.1.1/24").build(),
|
||||
|
||||
IngressRule.builder().id(8).protocol("tcp").startPort(10).endPort(10).CIDR(
|
||||
"2.2.2.2/16").build())).build()).add(
|
||||
SecurityGroup.builder().id(15).name("2").description("description").account("adrian").domainId(1)
|
||||
.domain("ROOT").build(),
|
||||
SecurityGroup.builder().id(16).name("with1and2").description("description").account("adrian")
|
||||
.domainId(1).domain("ROOT").ingressRules(
|
||||
ImmutableSet.of(
|
||||
|
||||
IngressRule.builder().id(9).protocol("icmp").ICMPType(-1).ICMPCode(-1)
|
||||
.securityGroupName("1").account("adrian").build(),
|
||||
|
||||
IngressRule.builder().id(10).protocol("tcp").startPort(22).endPort(22)
|
||||
.securityGroupName("1").account("adrian").build(),
|
||||
|
||||
IngressRule.builder().id(11).protocol("tcp").startPort(22).endPort(22)
|
||||
.securityGroupName("2").account("adrian").build())).build()).build();
|
||||
|
||||
UnwrapOnlyNestedJsonValue<Set<SecurityGroup>> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyNestedJsonValue<Set<SecurityGroup>>>() {
|
||||
}));
|
||||
Set<SecurityGroup> response = ImmutableSortedSet.copyOf(parser.apply(new HttpResponse(200, "ok", Payloads
|
||||
.newInputStreamPayload(is))));
|
||||
|
||||
assertEquals(response, expects);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public abstract class BaseItemParserTest<T> extends BaseParserTest<T, T> {
|
||||
|
||||
}
|
|
@ -16,32 +16,29 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.functions;
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.NetworkType;
|
||||
import org.jclouds.cloudstack.domain.Zone;
|
||||
import org.jclouds.cloudstack.config.CloudStackParserModule;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.util.Types;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListZonesResponseTest {
|
||||
public abstract class BaseParserTest<T, G> {
|
||||
|
||||
Injector i = Guice.createInjector(new GsonModule() {
|
||||
|
||||
|
@ -51,22 +48,32 @@ public class ListZonesResponseTest {
|
|||
super.configure();
|
||||
}
|
||||
|
||||
});
|
||||
}, new CloudStackParserModule());
|
||||
|
||||
public void testAdvanced() {
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
Zone expects = Zone.builder().id(1).name("San Jose 1").networkType(NetworkType.ADVANCED).build();
|
||||
T expects = expected();
|
||||
|
||||
UnwrapOnlyNestedJsonValue<Set<Zone>> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyNestedJsonValue<Set<Zone>>>() {
|
||||
}));
|
||||
Set<Zone> response = parser
|
||||
.apply(new HttpResponse(
|
||||
200,
|
||||
"ok",
|
||||
Payloads
|
||||
.newStringPayload("{ \"listzonesresponse\" : { \"zone\" : [ {\"id\":1,\"name\":\"San Jose 1\",\"networktype\":\"Advanced\"} ] } }")));
|
||||
|
||||
assertEquals(Iterables.getOnlyElement(response), expects);
|
||||
Function<HttpResponse, T> parser = getParser();
|
||||
T response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(getClass()
|
||||
.getResourceAsStream(resource()))));
|
||||
compare(expects, response);
|
||||
}
|
||||
|
||||
public void compare(T expects, T response) {
|
||||
assertEquals(response.toString(), expects.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Function<HttpResponse, T> getParser(){
|
||||
return (Function<HttpResponse, T>) i.getInstance(Key.get(TypeLiteral.get(
|
||||
Types.newParameterizedType(UnwrapOnlyNestedJsonValue.class, type())).getType()));
|
||||
}
|
||||
|
||||
public abstract Class<G> type();
|
||||
|
||||
public abstract String resource();
|
||||
|
||||
public abstract T expected();
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.util.Types;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public abstract class BaseSetParserTest<T> extends BaseParserTest<Set<T>, T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// crazy stuff due to type erasure
|
||||
protected Function<HttpResponse, Set<T>> getParser() {
|
||||
return (Function<HttpResponse, Set<T>>) i.getInstance(Key.get(TypeLiteral.get(
|
||||
Types.newParameterizedType(UnwrapOnlyNestedJsonValue.class, Types.newParameterizedType(Set.class, type())))
|
||||
.getType()));
|
||||
}
|
||||
|
||||
public void compare(Set<T> expects, Set<T> response) {
|
||||
assertEquals(ImmutableSortedSet.copyOf(response).toString(), ImmutableSortedSet.copyOf(expects).toString());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.Account.State;
|
||||
import org.jclouds.cloudstack.domain.Account.Type;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListAccountsResponseTest extends BaseSetParserTest<Account> {
|
||||
|
||||
@Override
|
||||
public Class<Account> type() {
|
||||
return Account.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listaccountsresponse.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Account> expected() {
|
||||
return ImmutableSet.<Account> of(Account
|
||||
.builder()
|
||||
.id(36)
|
||||
.name("adrian")
|
||||
.type(Type.USER)
|
||||
.domainId(1)
|
||||
.domain("ROOT")
|
||||
.receivedBytes(0)
|
||||
.sentBytes(0)
|
||||
.VMLimit(500l)
|
||||
.VMs(-3)
|
||||
.VMsAvailable(503l)
|
||||
.IPLimit(null)
|
||||
.IPs(0)
|
||||
.IPsAvailable(null)
|
||||
.volumeLimit(null)
|
||||
.volumes(0)
|
||||
.volumesAvailable(null)
|
||||
.snapshotLimit(null)
|
||||
.snapshots(0)
|
||||
.snapshotsAvailable(null)
|
||||
.templateLimit(null)
|
||||
.templates(0)
|
||||
.templatesAvailable(null)
|
||||
.VMsStopped(0)
|
||||
.VMsRunning(0)
|
||||
.state(State.ENABLED)
|
||||
.users(
|
||||
ImmutableSet.of(User.builder().id(46).name("adrian").firstName("Adrian").lastName("test")
|
||||
.email("adrian@jcloud.com")
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-03-26T23:10:49-0700"))
|
||||
.state("enabled").account("adrian").accountType(Type.USER).domainId(1).domain("ROOT")
|
||||
.apiKey("APIKEY").secretKey("SECRETKEY").build())).build());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Capabilities;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListCapabilitiesResponseTest extends BaseItemParserTest<Capabilities> {
|
||||
|
||||
@Override
|
||||
public Class<Capabilities> type() {
|
||||
return Capabilities.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listcapabilitiesresponse.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Capabilities expected() {
|
||||
return Capabilities.builder().securityGroupsEnabled(true).sharedTemplatesEnabled(true).cloudStackVersion("2.2")
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -16,49 +16,36 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.functions;
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.DiskOffering;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListDiskOfferingsResponseTest {
|
||||
|
||||
Injector i = Guice.createInjector(new GsonModule() {
|
||||
public class ListDiskOfferingsResponseTest extends BaseSetParserTest<DiskOffering> {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
super.configure();
|
||||
public Class<DiskOffering> type() {
|
||||
return DiskOffering.class;
|
||||
}
|
||||
|
||||
});
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listdiskofferingsresponse.json";
|
||||
}
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/listdiskofferingsresponse.json");
|
||||
|
||||
Set<DiskOffering> expects = ImmutableSet.<DiskOffering> of(
|
||||
@Override
|
||||
public Set<DiskOffering> expected() {
|
||||
return ImmutableSet.<DiskOffering> of(
|
||||
DiskOffering.builder().id(3).domainId(1).domain("ROOT").name("Small").displayText("Small Disk, 5 GB")
|
||||
.diskSize(5)
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-02-11T15:22:32-0800"))
|
||||
|
@ -71,13 +58,5 @@ public class ListDiskOfferingsResponseTest {
|
|||
.diskSize(100)
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-02-11T15:22:32-0800"))
|
||||
.customized(false).build());
|
||||
|
||||
UnwrapOnlyNestedJsonValue<Set<DiskOffering>> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyNestedJsonValue<Set<DiskOffering>>>() {
|
||||
}));
|
||||
Set<DiskOffering> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(Sets.newHashSet(response), expects);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.functions.ParseNamesFromHttpResponse;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListHypervisorsResponseTest extends BaseSetParserTest<String> {
|
||||
|
||||
@Override
|
||||
public Class<String> type() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listhypervisorsresponse.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> expected() {
|
||||
return ImmutableSet.<String> of("XenServer", "KVM", "VMware");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<HttpResponse, Set<String>> getParser() {
|
||||
return i.getInstance(ParseNamesFromHttpResponse.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.NetworkOffering;
|
||||
import org.jclouds.cloudstack.domain.TrafficType;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListNetworkOfferingsResponseTest extends BaseSetParserTest<NetworkOffering> {
|
||||
|
||||
@Override
|
||||
public Class<NetworkOffering> type() {
|
||||
return NetworkOffering.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listnetworkofferingsresponse.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<NetworkOffering> expected() {
|
||||
return ImmutableSet.<NetworkOffering> of(
|
||||
NetworkOffering.builder().id(7).name("DefaultDirectNetworkOffering").displayText("Direct")
|
||||
.trafficType(TrafficType.PUBLIC).isDefault(true).supportsVLAN(false).availability("Required")
|
||||
.networkRate(200).build(), NetworkOffering.builder().id(6).name("DefaultVirtualizedNetworkOffering")
|
||||
.displayText("Virtual Vlan").trafficType(TrafficType.GUEST).isDefault(true).supportsVLAN(false)
|
||||
.availability("Required").networkRate(200).build());
|
||||
}
|
||||
|
||||
}
|
|
@ -16,11 +16,8 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.functions;
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -28,42 +25,34 @@ import org.jclouds.cloudstack.domain.GuestIPType;
|
|||
import org.jclouds.cloudstack.domain.Network;
|
||||
import org.jclouds.cloudstack.domain.NetworkService;
|
||||
import org.jclouds.cloudstack.domain.TrafficType;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListNetworksResponseTest {
|
||||
|
||||
Injector i = Guice.createInjector(new GsonModule() {
|
||||
public class ListNetworksResponseTest extends BaseSetParserTest<Network> {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
super.configure();
|
||||
public Class<Network> type() {
|
||||
return Network.class;
|
||||
}
|
||||
|
||||
});
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listnetworksresponse.json";
|
||||
}
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/listnetworksresponse.json");
|
||||
|
||||
Set<Network> expects = ImmutableSet
|
||||
@Override
|
||||
public Set<Network> expected() {
|
||||
return ImmutableSet
|
||||
.<Network> of(Network
|
||||
.builder()
|
||||
.id(204)
|
||||
|
@ -89,12 +78,12 @@ public class ListNetworksResponseTest {
|
|||
.domain("ROOT")
|
||||
.isDefault(true)
|
||||
.services(
|
||||
ImmutableSet.of(
|
||||
ImmutableSortedSet.of(
|
||||
new NetworkService("Vpn", ImmutableMap.of("SupportedVpnTypes", "pptp,l2tp,ipsec")),
|
||||
new NetworkService("Gateway"),
|
||||
new NetworkService("UserData"),
|
||||
new NetworkService("Dhcp"),
|
||||
new NetworkService("Firewall", ImmutableMap.<String, String> builder()
|
||||
new NetworkService("Firewall", ImmutableSortedMap.<String, String> naturalOrder()
|
||||
.put("SupportedSourceNatTypes", "per account").put("StaticNat", "true")
|
||||
.put("TrafficStatistics", "per public ip").put("PortForwarding", "true")
|
||||
.put("MultipleIps", "true").put("SupportedProtocols", "tcp,udp").build()),
|
||||
|
@ -102,12 +91,5 @@ public class ListNetworksResponseTest {
|
|||
new NetworkService("Lb", ImmutableMap.of("SupportedLbAlgorithms",
|
||||
"roundrobin,leastconn,source", "SupportedProtocols", "tcp, udp"))))
|
||||
.networkDomain("cs3cloud.internal").build());
|
||||
|
||||
UnwrapOnlyNestedJsonValue<Set<Network>> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyNestedJsonValue<Set<Network>>>() {
|
||||
}));
|
||||
Set<Network> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(Sets.newHashSet(response), expects);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.cloudstack.functions.ParseIdToNameFromHttpResponse;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListOSCategoriesResponseTest extends BaseItemParserTest<Map<Long, String>> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listoscategoriesresponse.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, String> expected() {
|
||||
return ImmutableMap.<Long, String> builder().put(1l, "CentOS").put(2l, "Debian").put(3l, "Oracle")
|
||||
.put(4l, "RedHat").put(5l, "SUSE").put(6l, "Windows").put(7l, "Other").put(8l, "Novel").put(9l, "Unix")
|
||||
.put(10l, "Ubuntu").build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<HttpResponse, Map<Long, String>> getParser() {
|
||||
return i.getInstance(ParseIdToNameFromHttpResponse.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public Class<Map<Long, String>> type() {
|
||||
return (Class) Map.class;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.PortForwardingRule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListPortForwardingRulesResponseTest extends BaseSetParserTest<PortForwardingRule> {
|
||||
|
||||
@Override
|
||||
public Class<PortForwardingRule> type() {
|
||||
return PortForwardingRule.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listportforwardingrulesresponse.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<PortForwardingRule> expected() {
|
||||
return ImmutableSet.<PortForwardingRule> of(
|
||||
PortForwardingRule.builder().id(15).privatePort(22).protocol("tcp").publicPort(2022).virtualMachineId(3)
|
||||
.virtualMachineName("i-3-3-VM").IPAddressId(3).IPAddress("72.52.126.32").state("Active").build(),
|
||||
PortForwardingRule.builder().id(18).privatePort(22).protocol("tcp").publicPort(22).virtualMachineId(89)
|
||||
.virtualMachineName("i-3-89-VM").IPAddressId(34).IPAddress("72.52.126.63").state("Active").build());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListPublicIPAddressesResponseTest extends BaseSetParserTest<PublicIPAddress> {
|
||||
|
||||
@Override
|
||||
public Class<PublicIPAddress> type() {
|
||||
return PublicIPAddress.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listpublicipaddressesresponse.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<PublicIPAddress> expected() {
|
||||
return ImmutableSet.of(PublicIPAddress.builder().id(30).IPAddress("72.52.126.59")
|
||||
.allocated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-02-19T21:15:01-0800")).zoneId(1)
|
||||
.zoneName("San Jose 1").isSourceNAT(false).account("adrian").domainId(1).domain("ROOT")
|
||||
.usesVirtualNetwork(true).isStaticNAT(false).associatedNetworkId(204).networkId(200)
|
||||
.state(PublicIPAddress.State.ALLOCATED).build());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.IngressRule;
|
||||
import org.jclouds.cloudstack.domain.SecurityGroup;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListSecurityGroupsResponseTest extends BaseSetParserTest<SecurityGroup> {
|
||||
|
||||
@Override
|
||||
public Class<SecurityGroup> type() {
|
||||
return SecurityGroup.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listsecuritygroupsresponse.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SecurityGroup> expected() {
|
||||
return ImmutableSet
|
||||
.<SecurityGroup> builder()
|
||||
.add(SecurityGroup
|
||||
.builder()
|
||||
.id(13)
|
||||
.name("default")
|
||||
.description("description")
|
||||
.account("adrian")
|
||||
.domainId(1)
|
||||
.domain("ROOT")
|
||||
.ingressRules(
|
||||
ImmutableSet.of(
|
||||
|
||||
IngressRule.builder().id(5).protocol("tcp").startPort(22).endPort(22)
|
||||
.securityGroupName("adriancole").account("adrian").build(),
|
||||
|
||||
IngressRule.builder().id(6).protocol("udp").startPort(11).endPort(11).CIDR("1.1.1.1/24")
|
||||
.build())).build())
|
||||
.add(SecurityGroup.builder().id(12).name("adriancole").account("adrian").domainId(1).domain("ROOT").build())
|
||||
.add(SecurityGroup.builder().id(15).name("2").description("description").account("adrian").domainId(1)
|
||||
.domain("ROOT").build())
|
||||
|
||||
.add(SecurityGroup.builder().id(14).name("1").description("description").account("adrian").domainId(1)
|
||||
.domain("ROOT").ingressRules(ImmutableSet.of(
|
||||
|
||||
IngressRule.builder().id(7).protocol("tcp").startPort(10).endPort(10).CIDR("1.1.1.1/24").build(),
|
||||
|
||||
IngressRule.builder().id(8).protocol("tcp").startPort(10).endPort(10).CIDR("2.2.2.2/16").build()))
|
||||
.build())
|
||||
.add(SecurityGroup
|
||||
.builder()
|
||||
.id(16)
|
||||
.name("with1and2")
|
||||
.description("description")
|
||||
.account("adrian")
|
||||
.domainId(1)
|
||||
.domain("ROOT")
|
||||
.ingressRules(
|
||||
ImmutableSet.of(IngressRule.builder().id(9).protocol("icmp").ICMPType(-1).ICMPCode(-1)
|
||||
.securityGroupName("1").account("adrian").build(),
|
||||
|
||||
IngressRule.builder().id(10).protocol("tcp").startPort(22).endPort(22).securityGroupName("1")
|
||||
.account("adrian").build(),
|
||||
|
||||
IngressRule.builder().id(11).protocol("tcp").startPort(22).endPort(22).securityGroupName("2")
|
||||
.account("adrian").build())).build()).build();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -16,50 +16,37 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.functions;
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.ServiceOffering;
|
||||
import org.jclouds.cloudstack.domain.StorageType;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListServiceOfferingsResponseTest {
|
||||
|
||||
Injector i = Guice.createInjector(new GsonModule() {
|
||||
public class ListServiceOfferingsResponseTest extends BaseSetParserTest<ServiceOffering> {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
super.configure();
|
||||
public Class<ServiceOffering> type() {
|
||||
return ServiceOffering.class;
|
||||
}
|
||||
|
||||
});
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listserviceofferingsresponse.json";
|
||||
}
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/listserviceofferingsresponse.json");
|
||||
|
||||
Set<ServiceOffering> expects = ImmutableSortedSet.<ServiceOffering> of(
|
||||
@Override
|
||||
public Set<ServiceOffering> expected() {
|
||||
return ImmutableSet.<ServiceOffering> of(
|
||||
ServiceOffering.builder().id(1).name("Small Instance")
|
||||
.displayText("Small Instance - 500 MhZ CPU, 512 MB RAM - $0.05 per hour").cpuNumber(1).cpuSpeed(500)
|
||||
.memory(512)
|
||||
|
@ -70,13 +57,6 @@ public class ListServiceOfferingsResponseTest {
|
|||
.memory(1024)
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-02-11T15:22:32-0800"))
|
||||
.storageType(StorageType.SHARED).haSupport(false).build());
|
||||
|
||||
UnwrapOnlyNestedJsonValue<Set<ServiceOffering>> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyNestedJsonValue<Set<ServiceOffering>>>() {
|
||||
}));
|
||||
Set<ServiceOffering> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(Sets.newTreeSet(response), expects);
|
||||
}
|
||||
|
||||
}
|
|
@ -16,78 +16,70 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.functions;
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Template;
|
||||
import org.jclouds.cloudstack.domain.Template.Format;
|
||||
import org.jclouds.cloudstack.domain.Template.Type;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListTemplatesResponseTest {
|
||||
|
||||
Injector i = Guice.createInjector(new GsonModule() {
|
||||
public class ListTemplatesResponseTest extends BaseSetParserTest<Template> {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
super.configure();
|
||||
public Class<Template> type() {
|
||||
return Template.class;
|
||||
}
|
||||
|
||||
});
|
||||
@Override
|
||||
public String resource() {
|
||||
// grep listtemplatesresponse ./target/test-data/jclouds-wire.log|tail
|
||||
// -1|sed -e 's/.*<< "//g' -e 's/"$//g'
|
||||
return "/listtemplatesresponse.json";
|
||||
}
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/listtemplatesresponse.json");
|
||||
|
||||
Set<Template> expects = ImmutableSortedSet.<Template> of(
|
||||
@Override
|
||||
public Set<Template> expected() {
|
||||
return ImmutableSet.of(
|
||||
Template.builder().id(2).name("CentOS 5.3(64-bit) no GUI (XenServer)")
|
||||
.displayText("CentOS 5.3(64-bit) no GUI (XenServer)").isPublic(true)
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-02-11T18:45:54-0800"))
|
||||
.ready(true).passwordEnabled(false).format(Format.VHD).featured(true).crossZones(true).OSTypeId(11)
|
||||
.OSType("CentOS 5.3 (32-bit)").account("system").zoneId(1).zone("San Jose 1").size(8589934592l)
|
||||
.type(Template.Type.BUILTIN).hypervisor("XenServer").domain("ROOT").domainId(1).extractable(true)
|
||||
.build(),
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-03-20T19:17:48-0700"))
|
||||
.ready(false).passwordEnabled(false).format(Format.VHD).featured(true).crossZones(true).OSTypeId(11)
|
||||
.OSType("CentOS 5.3 (32-bit)").account("system").zoneId(2).zone("Chicago").type(Type.BUILTIN)
|
||||
.hypervisor("XenServer").domain("ROOT").domainId(1).extractable(true).build(),
|
||||
Template.builder().id(4).name("CentOS 5.5(64-bit) no GUI (KVM)")
|
||||
.displayText("CentOS 5.5(64-bit) no GUI (KVM)").isPublic(true)
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-02-11T18:45:54-0800"))
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-03-20T19:17:48-0700"))
|
||||
.ready(true).passwordEnabled(false).format(Format.QCOW2).featured(true).crossZones(true)
|
||||
.OSTypeId(112).OSType("CentOS 5.5 (64-bit)").account("system").zoneId(1).zone("San Jose 1")
|
||||
.OSTypeId(112).OSType("CentOS 5.5 (64-bit)").account("system").zoneId(2).zone("Chicago")
|
||||
.size(8589934592l).type(Type.BUILTIN).hypervisor("KVM").domain("ROOT").domainId(1).extractable(true)
|
||||
.build(),
|
||||
Template.builder().id(203).name("Windows 7 KVM").displayText("Windows 7 KVM").isPublic(true)
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-03-20T22:02:18-0700"))
|
||||
.ready(true).passwordEnabled(false).format(Format.QCOW2).featured(true).crossZones(false)
|
||||
.OSTypeId(48).OSType("Windows 7 (32-bit)").account("admin").zoneId(2).zone("Chicago")
|
||||
.size(17179869184l).type(Type.USER).hypervisor("KVM").domain("ROOT").domainId(1).extractable(false)
|
||||
.build(),
|
||||
Template.builder().id(7).name("CentOS 5.3(64-bit) no GUI (vSphere)")
|
||||
.displayText("CentOS 5.3(64-bit) no GUI (vSphere)").isPublic(true)
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-02-11T18:45:54-0800"))
|
||||
.ready(true).passwordEnabled(false).format(Format.OVA).featured(true).crossZones(true).OSTypeId(12)
|
||||
.OSType("CentOS 5.3 (64-bit)").account("system").zoneId(1).zone("San Jose 1").size(459320832l)
|
||||
.type(Type.BUILTIN).hypervisor("VMware").domain("ROOT").domainId(1).extractable(true).build());
|
||||
|
||||
UnwrapOnlyNestedJsonValue<Set<Template>> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyNestedJsonValue<Set<Template>>>() {
|
||||
}));
|
||||
Set<Template> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(Sets.newTreeSet(response), expects);
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-03-20T19:17:48-0700"))
|
||||
.ready(false).passwordEnabled(false).format(Format.OVA).featured(true).crossZones(true).OSTypeId(12)
|
||||
.OSType("CentOS 5.3 (64-bit)").account("system").zoneId(2).zone("Chicago").type(Type.BUILTIN)
|
||||
.hypervisor("VMware").domain("ROOT").domainId(1).extractable(true).build(),
|
||||
Template.builder().id(241).name("kvmdev4").displayText("v5.6.28_Dev4").isPublic(true)
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-04-21T09:43:25-0700"))
|
||||
.ready(true).passwordEnabled(false).format(Format.QCOW2).featured(false).crossZones(false)
|
||||
.OSTypeId(14).OSType("CentOS 5.4 (64-bit)").account("rs3").zoneId(2).zone("Chicago")
|
||||
.size(10737418240l).type(Type.USER).hypervisor("KVM").domain("ROOT").domainId(1).extractable(false)
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
|
@ -16,11 +16,8 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.functions;
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.GuestIPType;
|
||||
|
@ -28,40 +25,30 @@ import org.jclouds.cloudstack.domain.NIC;
|
|||
import org.jclouds.cloudstack.domain.TrafficType;
|
||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListVirtualMachinesResponseTest {
|
||||
|
||||
Injector i = Guice.createInjector(new GsonModule() {
|
||||
public class ListVirtualMachinesResponseTest extends BaseSetParserTest<VirtualMachine> {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
super.configure();
|
||||
public Class<VirtualMachine> type() {
|
||||
return VirtualMachine.class;
|
||||
}
|
||||
|
||||
});
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listvirtualmachinesresponse.json";
|
||||
}
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/listvirtualmachinesresponse.json");
|
||||
|
||||
VirtualMachine expects = VirtualMachine
|
||||
@Override
|
||||
public Set<VirtualMachine> expected() {
|
||||
return ImmutableSet.of(VirtualMachine
|
||||
.builder()
|
||||
.id(54)
|
||||
.name("i-3-54-VM")
|
||||
|
@ -90,14 +77,7 @@ public class ListVirtualMachinesResponseTest {
|
|||
.jobStatus(0)
|
||||
.nics(ImmutableSet.of(NIC.builder().id(72).networkId(204).netmask("255.255.255.0").gateway("10.1.1.1")
|
||||
.IPAddress("10.1.1.18").trafficType(TrafficType.GUEST).guestIPType(GuestIPType.VIRTUAL)
|
||||
.isDefault(true).build())).hypervisor("XenServer").build();
|
||||
|
||||
UnwrapOnlyNestedJsonValue<Set<VirtualMachine>> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyNestedJsonValue<Set<VirtualMachine>>>() {
|
||||
}));
|
||||
Set<VirtualMachine> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(Iterables.getOnlyElement(response), expects);
|
||||
.isDefault(true).build())).hypervisor("XenServer").build());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.cloudstack.parse;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.NetworkType;
|
||||
import org.jclouds.cloudstack.domain.Zone;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ListZonesResponseTest extends BaseSetParserTest<Zone> {
|
||||
|
||||
@Override
|
||||
public Class<Zone> type() {
|
||||
return Zone.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/listzonesresponse.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Zone> expected() {
|
||||
return ImmutableSet.of(Zone.builder().id(1).name("San Jose 1").networkType(NetworkType.ADVANCED)
|
||||
.securityGroupsEnabled(false).build(),
|
||||
Zone.builder().id(2).name("Chicago").networkType(NetworkType.ADVANCED).securityGroupsEnabled(true).build());
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{ "listaccountsresponse" : { "account" : [ {"id":36,"name":"adrian","accounttype":0,"domainid":1,"domain":"ROOT","receivedbytes":0,"sentbytes":0,"vmlimit":"500","vmtotal":-3,"vmavailable":"503","iplimit":"Unlimited","iptotal":0,"ipavailable":"Unlimited","volumelimit":"Unlimited","volumetotal":0,"volumeavailable":"Unlimited","snapshotlimit":"Unlimited","snapshottotal":0,"snapshotavailable":"Unlimited","templatelimit":"Unlimited","templatetotal":0,"templateavailable":"Unlimited","vmstopped":0,"vmrunning":0,"state":"enabled","user":[{"id":46,"username":"adrian","firstname":"Adrian","lastname":"test","email":"adrian@jcloud.com","created":"2011-03-26T23:10:49-0700","state":"enabled","account":"adrian","accounttype":0,"domainid":1,"domain":"ROOT","apikey":"APIKEY","secretkey":"SECRETKEY"}]} ] } }
|
|
@ -0,0 +1 @@
|
|||
{ "listcapabilitiesresponse" : { "capability" : {"securitygroupsenabled":true,"cloudstackversion":"2.2","userpublictemplateenabled":true} } }
|
|
@ -0,0 +1 @@
|
|||
{ "listhypervisorsresponse" : { "hypervisor" : [ {"name":"KVM"}, {"name":"VMware"}, {"name":"XenServer"} ] } }
|
|
@ -0,0 +1 @@
|
|||
{ "listoscategoriesresponse" : { "oscategory" : [ {"id":1,"name":"CentOS"}, {"id":2,"name":"Debian"}, {"id":3,"name":"Oracle"}, {"id":4,"name":"RedHat"}, {"id":5,"name":"SUSE"}, {"id":6,"name":"Windows"}, {"id":7,"name":"Other"}, {"id":8,"name":"Novel"}, {"id":9,"name":"Unix"}, {"id":10,"name":"Ubuntu"} ] } }
|
|
@ -1 +1 @@
|
|||
{ "listtemplatesresponse" : { "template" : [ {"id":2,"name":"CentOS 5.3(64-bit) no GUI (XenServer)","displaytext":"CentOS 5.3(64-bit) no GUI (XenServer)","ispublic":true,"created":"2011-02-11T18:45:54-0800","isready":true,"passwordenabled":false,"format":"VHD","isfeatured":true,"crossZones":true,"ostypeid":11,"ostypename":"CentOS 5.3 (32-bit)","account":"system","zoneid":1,"zonename":"San Jose 1","size":8589934592,"templatetype":"BUILTIN","hypervisor":"XenServer","domain":"ROOT","domainid":1,"isextractable":true}, {"id":4,"name":"CentOS 5.5(64-bit) no GUI (KVM)","displaytext":"CentOS 5.5(64-bit) no GUI (KVM)","ispublic":true,"created":"2011-02-11T18:45:54-0800","isready":true,"passwordenabled":false,"format":"QCOW2","isfeatured":true,"crossZones":true,"ostypeid":112,"ostypename":"CentOS 5.5 (64-bit)","account":"system","zoneid":1,"zonename":"San Jose 1","size":8589934592,"templatetype":"BUILTIN","hypervisor":"KVM","domain":"ROOT","domainid":1,"isextractable":true}, {"id":7,"name":"CentOS 5.3(64-bit) no GUI (vSphere)","displaytext":"CentOS 5.3(64-bit) no GUI (vSphere)","ispublic":true,"created":"2011-02-11T18:45:54-0800","isready":true,"passwordenabled":false,"format":"OVA","isfeatured":true,"crossZones":true,"ostypeid":12,"ostypename":"CentOS 5.3 (64-bit)","account":"system","zoneid":1,"zonename":"San Jose 1","size":459320832,"templatetype":"BUILTIN","hypervisor":"VMware","domain":"ROOT","domainid":1,"isextractable":true} ] } }
|
||||
{ "listtemplatesresponse" : { "template" : [ {"id":2,"name":"CentOS 5.3(64-bit) no GUI (XenServer)","displaytext":"CentOS 5.3(64-bit) no GUI (XenServer)","ispublic":true,"created":"2011-03-20T19:17:48-0700","isready":false,"passwordenabled":false,"format":"VHD","isfeatured":true,"crossZones":true,"ostypeid":11,"ostypename":"CentOS 5.3 (32-bit)","account":"system","zoneid":2,"zonename":"Chicago","templatetype":"BUILTIN","hypervisor":"XenServer","domain":"ROOT","domainid":1,"isextractable":true}, {"id":4,"name":"CentOS 5.5(64-bit) no GUI (KVM)","displaytext":"CentOS 5.5(64-bit) no GUI (KVM)","ispublic":true,"created":"2011-03-20T19:17:48-0700","isready":true,"passwordenabled":false,"format":"QCOW2","isfeatured":true,"crossZones":true,"ostypeid":112,"ostypename":"CentOS 5.5 (64-bit)","account":"system","zoneid":2,"zonename":"Chicago","size":8589934592,"templatetype":"BUILTIN","hypervisor":"KVM","domain":"ROOT","domainid":1,"isextractable":true}, {"id":203,"name":"Windows 7 KVM","displaytext":"Windows 7 KVM","ispublic":true,"created":"2011-03-20T22:02:18-0700","isready":true,"passwordenabled":false,"format":"QCOW2","isfeatured":true,"crossZones":false,"ostypeid":48,"ostypename":"Windows 7 (32-bit)","account":"admin","zoneid":2,"zonename":"Chicago","size":17179869184,"templatetype":"USER","hypervisor":"KVM","domain":"ROOT","domainid":1,"isextractable":false}, {"id":7,"name":"CentOS 5.3(64-bit) no GUI (vSphere)","displaytext":"CentOS 5.3(64-bit) no GUI (vSphere)","ispublic":true,"created":"2011-03-20T19:17:48-0700","isready":false,"passwordenabled":false,"format":"OVA","isfeatured":true,"crossZones":true,"ostypeid":12,"ostypename":"CentOS 5.3 (64-bit)","account":"system","zoneid":2,"zonename":"Chicago","templatetype":"BUILTIN","hypervisor":"VMware","domain":"ROOT","domainid":1,"isextractable":true}, {"id":241,"name":"kvmdev4","displaytext":"v5.6.28_Dev4","ispublic":true,"created":"2011-04-21T09:43:25-0700","isready":true,"passwordenabled":false,"format":"QCOW2","isfeatured":false,"crossZones":false,"ostypeid":14,"ostypename":"CentOS 5.4 (64-bit)","account":"rs3","zoneid":2,"zonename":"Chicago","size":10737418240,"templatetype":"USER","hypervisor":"KVM","domain":"ROOT","domainid":1,"isextractable":false} ] } }
|
|
@ -0,0 +1 @@
|
|||
{ "listzonesresponse" : { "zone" : [ {"id":1,"name":"San Jose 1","networktype":"Advanced","securitygroupsenabled":false}, {"id":2,"name":"Chicago","networktype":"Advanced","securitygroupsenabled":true} ] } }
|
Loading…
Reference in New Issue