mirror of https://github.com/apache/jclouds.git
updated tests in cloudstack and added network create/destroy
This commit is contained in:
parent
6548fe1212
commit
de463ffb8e
|
@ -73,13 +73,13 @@ public interface AddressAsyncClient {
|
||||||
ListenableFuture<PublicIPAddress> getPublicIPAddress(@QueryParam("id") long id);
|
ListenableFuture<PublicIPAddress> getPublicIPAddress(@QueryParam("id") long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AddressClient#associateIPAddress
|
* @see AddressClient#associateIPAddressInZone
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@QueryParams(keys = "command", values = "associateIpAddress")
|
@QueryParams(keys = "command", values = "associateIpAddress")
|
||||||
@Unwrap
|
@Unwrap
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
ListenableFuture<AsyncCreateResponse> associateIPAddress(@QueryParam("zoneid") long zoneId,
|
ListenableFuture<AsyncCreateResponse> associateIPAddressInZone(@QueryParam("zoneid") long zoneId,
|
||||||
AssociateIPAddressOptions... options);
|
AssociateIPAddressOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,7 +62,7 @@ public interface AddressClient {
|
||||||
* the ID of the availability zone you want to acquire an public IP address from
|
* the ID of the availability zone you want to acquire an public IP address from
|
||||||
* @return IPAddress
|
* @return IPAddress
|
||||||
*/
|
*/
|
||||||
AsyncCreateResponse associateIPAddress(long zoneId, AssociateIPAddressOptions... options);
|
AsyncCreateResponse associateIPAddressInZone(long zoneId, AssociateIPAddressOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disassociates an ip address from the account.
|
* Disassociates an ip address from the account.
|
||||||
|
|
|
@ -25,8 +25,10 @@ import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||||
import org.jclouds.cloudstack.domain.Network;
|
import org.jclouds.cloudstack.domain.Network;
|
||||||
import org.jclouds.cloudstack.filters.QuerySigner;
|
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||||
|
import org.jclouds.cloudstack.options.CreateNetworkOptions;
|
||||||
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.QueryParams;
|
import org.jclouds.rest.annotations.QueryParams;
|
||||||
|
@ -34,6 +36,7 @@ import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.Unwrap;
|
import org.jclouds.rest.annotations.Unwrap;
|
||||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
@ -69,4 +72,22 @@ public interface NetworkAsyncClient {
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<Network> getNetwork(@QueryParam("id") long id);
|
ListenableFuture<Network> getNetwork(@QueryParam("id") long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see NetworkClient#createNetworkInZone
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "createNetwork")
|
||||||
|
@Unwrap
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
ListenableFuture<AsyncCreateResponse> createNetworkInZone(@QueryParam("zoneid") long zoneId,
|
||||||
|
@QueryParam("networkofferingid") long networkOfferingId, @QueryParam("name") String name,
|
||||||
|
@QueryParam("displaytext") String displayText, CreateNetworkOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see NetworkClient#deleteNetwork
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "deleteNetwork")
|
||||||
|
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Void> deleteNetwork(@QueryParam("id") long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,9 @@ package org.jclouds.cloudstack.features;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||||
import org.jclouds.cloudstack.domain.Network;
|
import org.jclouds.cloudstack.domain.Network;
|
||||||
|
import org.jclouds.cloudstack.options.CreateNetworkOptions;
|
||||||
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
|
@ -53,4 +55,30 @@ public interface NetworkClient {
|
||||||
*/
|
*/
|
||||||
Network getNetwork(long id);
|
Network getNetwork(long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a network
|
||||||
|
*
|
||||||
|
* @param zoneId
|
||||||
|
* the Zone ID for the Vlan ip range
|
||||||
|
* @param networkOfferingId
|
||||||
|
* the network offering id
|
||||||
|
* @param name
|
||||||
|
* the name of the network
|
||||||
|
* @param displayText
|
||||||
|
* the display text of the network
|
||||||
|
* @param options
|
||||||
|
* optional parameters
|
||||||
|
* @return task in progress
|
||||||
|
*/
|
||||||
|
AsyncCreateResponse createNetworkInZone(long zoneId, long networkOfferingId, String name, String displayText,
|
||||||
|
CreateNetworkOptions... options);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a network
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* the ID of the network
|
||||||
|
*/
|
||||||
|
void deleteNetwork(long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,14 +72,14 @@ public interface VirtualMachineAsyncClient {
|
||||||
ListenableFuture<VirtualMachine> getVirtualMachine(@QueryParam("id") long id);
|
ListenableFuture<VirtualMachine> getVirtualMachine(@QueryParam("id") long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VirtualMachineClient#deployVirtualMachine
|
* @see VirtualMachineClient#deployVirtualMachineInZone
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@QueryParams(keys = "command", values = "deployVirtualMachine")
|
@QueryParams(keys = "command", values = "deployVirtualMachine")
|
||||||
@Unwrap
|
@Unwrap
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
ListenableFuture<AsyncCreateResponse> deployVirtualMachine(@QueryParam("serviceofferingid") long serviceOfferingId,
|
ListenableFuture<AsyncCreateResponse> deployVirtualMachineInZone( @QueryParam("zoneid") long zoneId, @QueryParam("serviceofferingid") long serviceOfferingId,
|
||||||
@QueryParam("templateid") long templateId, @QueryParam("zoneid") long zoneId,
|
@QueryParam("templateid") long templateId,
|
||||||
DeployVirtualMachineOptions... options);
|
DeployVirtualMachineOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -59,15 +59,16 @@ public interface VirtualMachineClient {
|
||||||
* Creates and automatically starts a virtual machine based on a service offering, disk offering,
|
* Creates and automatically starts a virtual machine based on a service offering, disk offering,
|
||||||
* and template.
|
* and template.
|
||||||
*
|
*
|
||||||
|
* @param zoneId
|
||||||
|
* availability zone for the virtual machine
|
||||||
* @param serviceOfferingId
|
* @param serviceOfferingId
|
||||||
* the ID of the service offering for the virtual machine
|
* the ID of the service offering for the virtual machine
|
||||||
* @param templateId
|
* @param templateId
|
||||||
* the ID of the template for the virtual machine
|
* the ID of the template for the virtual machine
|
||||||
* @param zoneId
|
*
|
||||||
* availability zone for the virtual machine
|
|
||||||
* @return virtual machine
|
* @return virtual machine
|
||||||
*/
|
*/
|
||||||
AsyncCreateResponse deployVirtualMachine(long serviceOfferingId, long templateId, long zoneId,
|
AsyncCreateResponse deployVirtualMachineInZone(long zoneId, long serviceOfferingId, long templateId,
|
||||||
DeployVirtualMachineOptions... options);
|
DeployVirtualMachineOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class ReuseOrAssociateNewPublicIPAddress implements Function<Network, Pub
|
||||||
|
|
||||||
public static PublicIPAddress associateIPAddressInNetwork(Network network, CloudStackClient client,
|
public static PublicIPAddress associateIPAddressInNetwork(Network network, CloudStackClient client,
|
||||||
Predicate<Long> jobComplete) {
|
Predicate<Long> jobComplete) {
|
||||||
AsyncCreateResponse job = client.getAddressClient().associateIPAddress(network.getZoneId(),
|
AsyncCreateResponse job = client.getAddressClient().associateIPAddressInZone(network.getZoneId(),
|
||||||
networkId(network.getId()));
|
networkId(network.getId()));
|
||||||
checkState(jobComplete.apply(job.getJobId()), "job %d failed to complete", job.getJobId());
|
checkState(jobComplete.apply(job.getJobId()), "job %d failed to complete", job.getJobId());
|
||||||
PublicIPAddress ip = client.getAsyncJobClient().<PublicIPAddress> getAsyncJob(job.getJobId()).getResult();
|
PublicIPAddress ip = client.getAsyncJobClient().<PublicIPAddress> getAsyncJob(job.getJobId()).getResult();
|
||||||
|
|
|
@ -0,0 +1,202 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.options;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options used to control what networks information is returned
|
||||||
|
*
|
||||||
|
* @see <a href="http://download.cloud.com/releases/2.2.0/api/user/listNetworks.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class CreateNetworkOptions extends AccountInDomainOptions {
|
||||||
|
|
||||||
|
public static final CreateNetworkOptions NONE = new CreateNetworkOptions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isDefault
|
||||||
|
* true if network is default, false otherwise
|
||||||
|
*/
|
||||||
|
public CreateNetworkOptions isDefault(boolean isDefault) {
|
||||||
|
this.queryParameters.replaceValues("isdefault", ImmutableSet.of(isDefault + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isShared
|
||||||
|
* true if network is shared, false otherwise
|
||||||
|
*/
|
||||||
|
public CreateNetworkOptions isShared(boolean isShared) {
|
||||||
|
this.queryParameters.replaceValues("isshared", ImmutableSet.of(isShared + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param startIP
|
||||||
|
* the beginning IP address in the VLAN IP range
|
||||||
|
*/
|
||||||
|
public CreateNetworkOptions startIP(String startIP) {
|
||||||
|
this.queryParameters.replaceValues("startip", ImmutableSet.of(startIP));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param endIP
|
||||||
|
* the ending IP address in the VLAN IP range
|
||||||
|
*/
|
||||||
|
public CreateNetworkOptions endIP(String endIP) {
|
||||||
|
this.queryParameters.replaceValues("endip", ImmutableSet.of(endIP));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gateway
|
||||||
|
* the gateway of the VLAN IP range
|
||||||
|
*/
|
||||||
|
public CreateNetworkOptions gateway(String gateway) {
|
||||||
|
this.queryParameters.replaceValues("gateway", ImmutableSet.of(gateway));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param netmask
|
||||||
|
* the netmask of the VLAN IP range
|
||||||
|
*/
|
||||||
|
public CreateNetworkOptions netmask(String netmask) {
|
||||||
|
this.queryParameters.replaceValues("netmask", ImmutableSet.of(netmask));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param networkDomain
|
||||||
|
* network domain
|
||||||
|
*/
|
||||||
|
public CreateNetworkOptions networkDomain(String networkDomain) {
|
||||||
|
this.queryParameters.replaceValues("networkdomain", ImmutableSet.of(networkDomain));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param vlan
|
||||||
|
* the ID or VID of the VLAN. Default is an "untagged" VLAN.
|
||||||
|
*/
|
||||||
|
public CreateNetworkOptions vlan(String vlan) {
|
||||||
|
this.queryParameters.replaceValues("vlan", ImmutableSet.of(vlan));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
/**
|
||||||
|
* @see CreateNetworkOptions#isDefault
|
||||||
|
*/
|
||||||
|
public static CreateNetworkOptions isDefault(boolean isDefault) {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions();
|
||||||
|
return options.isDefault(isDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CreateNetworkOptions#isShared
|
||||||
|
*/
|
||||||
|
public static CreateNetworkOptions isShared(boolean isShared) {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions();
|
||||||
|
return options.isShared(isShared);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CreateNetworkOptions#startIP(String)
|
||||||
|
*/
|
||||||
|
public static CreateNetworkOptions startIP(String startIP) {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions();
|
||||||
|
return options.startIP(startIP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CreateNetworkOptions#endIP(String)
|
||||||
|
*/
|
||||||
|
public static CreateNetworkOptions endIP(String endIP) {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions();
|
||||||
|
return options.endIP(endIP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CreateNetworkOptions#gateway(String)
|
||||||
|
*/
|
||||||
|
public static CreateNetworkOptions gateway(String gateway) {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions();
|
||||||
|
return options.gateway(gateway);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CreateNetworkOptions#netmask(String)
|
||||||
|
*/
|
||||||
|
public static CreateNetworkOptions netmask(String netmask) {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions();
|
||||||
|
return options.netmask(netmask);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CreateNetworkOptions#networkDomain(String)
|
||||||
|
*/
|
||||||
|
public static CreateNetworkOptions networkDomain(String networkDomain) {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions();
|
||||||
|
return options.networkDomain(networkDomain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CreateNetworkOptions#vlan(String)
|
||||||
|
*/
|
||||||
|
public static CreateNetworkOptions vlan(String vlan) {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions();
|
||||||
|
return options.vlan(vlan);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CreateNetworkOptions#accountInDomain
|
||||||
|
*/
|
||||||
|
public static CreateNetworkOptions accountInDomain(String account, long domain) {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions();
|
||||||
|
return options.accountInDomain(account, domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CreateNetworkOptions#domainId
|
||||||
|
*/
|
||||||
|
public static CreateNetworkOptions domainId(long domainId) {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions();
|
||||||
|
return options.domainId(domainId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CreateNetworkOptions accountInDomain(String account, long domain) {
|
||||||
|
return CreateNetworkOptions.class.cast(super.accountInDomain(account, domain));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CreateNetworkOptions domainId(long domainId) {
|
||||||
|
return CreateNetworkOptions.class.cast(super.domainId(domainId));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.predicates;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.NetworkType;
|
||||||
|
import org.jclouds.cloudstack.domain.Zone;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class ZonePredicates {
|
||||||
|
|
||||||
|
public static class SupportsNetworkType implements Predicate<Zone> {
|
||||||
|
private final org.jclouds.cloudstack.domain.NetworkType type;
|
||||||
|
|
||||||
|
public SupportsNetworkType(org.jclouds.cloudstack.domain.NetworkType type) {
|
||||||
|
this.type = checkNotNull(type, "type");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Zone input) {
|
||||||
|
return type.equals(checkNotNull(input, "zone").getNetworkType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "supportsNetworkType(" + type + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Predicate<Zone> supportsAdvancedNetworks = new SupportsNetworkType(
|
||||||
|
org.jclouds.cloudstack.domain.NetworkType.ADVANCED);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true, if the zone supports {@link NetworkType.ADVANCED}
|
||||||
|
*/
|
||||||
|
public static Predicate<Zone> supportsAdvancedNetworks() {
|
||||||
|
return supportsAdvancedNetworks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return always returns true.
|
||||||
|
*/
|
||||||
|
public static Predicate<Zone> any() {
|
||||||
|
return Predicates.alwaysTrue();
|
||||||
|
}
|
||||||
|
}
|
|
@ -100,8 +100,8 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAssociateIPAddress() throws SecurityException, NoSuchMethodException, IOException {
|
public void testAssociateIPAddressInZone() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = AddressAsyncClient.class.getMethod("associateIPAddress",
|
Method method = AddressAsyncClient.class.getMethod("associateIPAddressInZone",
|
||||||
long.class, AssociateIPAddressOptions[].class);
|
long.class, AssociateIPAddressOptions[].class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, 6);
|
HttpRequest httpRequest = processor.createRequest(method, 6);
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class AddressClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
public void testAssociateDisassociatePublicIPAddress() throws Exception {
|
public void testAssociateDisassociatePublicIPAddress() throws Exception {
|
||||||
if (!networksEnabled)
|
if (!networksEnabled)
|
||||||
return;
|
return;
|
||||||
AsyncCreateResponse job = client.getAddressClient().associateIPAddress(
|
AsyncCreateResponse job = client.getAddressClient().associateIPAddressInZone(
|
||||||
Iterables.get(client.getNetworkClient().listNetworks(), 0).getZoneId());
|
Iterables.get(client.getNetworkClient().listNetworks(), 0).getZoneId());
|
||||||
checkState(jobComplete.apply(job.getJobId()), "job %d failed to complete", job.getJobId());
|
checkState(jobComplete.apply(job.getJobId()), "job %d failed to complete", job.getJobId());
|
||||||
ip = client.getAsyncJobClient().<PublicIPAddress> getAsyncJob(job.getJobId()).getResult();
|
ip = client.getAsyncJobClient().<PublicIPAddress> getAsyncJob(job.getJobId()).getResult();
|
||||||
|
|
|
@ -22,12 +22,17 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.NetworkType;
|
import org.jclouds.cloudstack.domain.NetworkType;
|
||||||
|
import org.jclouds.cloudstack.options.CreateNetworkOptions;
|
||||||
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
|
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
|
||||||
|
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -93,6 +98,61 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCreateNetworkInZone() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = NetworkAsyncClient.class.getMethod("createNetworkInZone", long.class, long.class, String.class,
|
||||||
|
String.class, CreateNetworkOptions[].class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, 1, 2, "named", "lovely");
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=createNetwork&zoneid=1&name=named&networkofferingid=2&displaytext=lovely HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCreateNetworkInZoneOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = NetworkAsyncClient.class.getMethod("createNetworkInZone", long.class, long.class, String.class,
|
||||||
|
String.class, CreateNetworkOptions[].class);
|
||||||
|
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, 1, 2, "named", "lovely", CreateNetworkOptions.Builder
|
||||||
|
.netmask("255.255.255.0").domainId(6));
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=createNetwork&zoneid=1&name=named&networkofferingid=2&displaytext=lovely&netmask=255.255.255.0&domainid=6 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDeleteNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = NetworkAsyncClient.class.getMethod("deleteNetwork", long.class);
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpRequest,
|
||||||
|
"GET http://localhost:8080/client/api?response=json&command=deleteNetwork&id=5 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||||
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeLiteral<RestAnnotationProcessor<NetworkAsyncClient>> createTypeLiteral() {
|
protected TypeLiteral<RestAnnotationProcessor<NetworkAsyncClient>> createTypeLiteral() {
|
||||||
return new TypeLiteral<RestAnnotationProcessor<NetworkAsyncClient>>() {
|
return new TypeLiteral<RestAnnotationProcessor<NetworkAsyncClient>>() {
|
||||||
|
|
|
@ -18,16 +18,25 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudstack.features;
|
package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
|
import static com.google.common.collect.Iterables.find;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||||
import org.jclouds.cloudstack.domain.GuestIPType;
|
import org.jclouds.cloudstack.domain.GuestIPType;
|
||||||
import org.jclouds.cloudstack.domain.Network;
|
import org.jclouds.cloudstack.domain.Network;
|
||||||
|
import org.jclouds.cloudstack.domain.NetworkOffering;
|
||||||
|
import org.jclouds.cloudstack.domain.Zone;
|
||||||
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
||||||
|
import org.jclouds.cloudstack.predicates.ZonePredicates;
|
||||||
|
import org.testng.annotations.AfterGroups;
|
||||||
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +47,53 @@ import com.google.common.collect.Iterables;
|
||||||
@Test(groups = "live", singleThreaded = true, testName = "NetworkClientLiveTest")
|
@Test(groups = "live", singleThreaded = true, testName = "NetworkClientLiveTest")
|
||||||
public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
|
public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
|
private boolean networksSupported;
|
||||||
|
|
||||||
|
private Zone zone;
|
||||||
|
private NetworkOffering offering;
|
||||||
|
|
||||||
|
private Network network;
|
||||||
|
|
||||||
|
@BeforeGroups(groups = "live")
|
||||||
|
public void setupClient() {
|
||||||
|
super.setupClient();
|
||||||
|
|
||||||
|
try {
|
||||||
|
zone = find(client.getZoneClient().listZones(), ZonePredicates.supportsAdvancedNetworks());
|
||||||
|
offering = Iterables.find(client.getOfferingClient().listNetworkOfferings(),new Predicate<NetworkOffering>(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(NetworkOffering arg0) {
|
||||||
|
return "Optional".equals(arg0.getAvailability());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
networksSupported = true;
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCreateNetworks() throws Exception {
|
||||||
|
if (!networksSupported)
|
||||||
|
return;
|
||||||
|
AsyncCreateResponse job = client.getNetworkClient().createNetworkInZone(zone.getId(), offering.getId(), prefix,
|
||||||
|
prefix);
|
||||||
|
assert jobComplete.apply(job.getJobId()) : job;
|
||||||
|
network = client.getNetworkClient().getNetwork(job.getId());
|
||||||
|
checkNetwork(network);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterGroups(groups = "live")
|
||||||
|
protected void tearDown() {
|
||||||
|
if (network != null) {
|
||||||
|
client.getNetworkClient().deleteNetwork(network.getId());
|
||||||
|
}
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
public void testListNetworks() throws Exception {
|
public void testListNetworks() throws Exception {
|
||||||
|
if (!networksSupported)
|
||||||
|
return;
|
||||||
Set<Network> response = client.getNetworkClient().listNetworks();
|
Set<Network> response = client.getNetworkClient().listNetworks();
|
||||||
assert null != response;
|
assert null != response;
|
||||||
long networkCount = response.size();
|
long networkCount = response.size();
|
||||||
|
@ -48,6 +103,12 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
ListNetworksOptions.Builder.id(network.getId())));
|
ListNetworksOptions.Builder.id(network.getId())));
|
||||||
assertEquals(network, newDetails);
|
assertEquals(network, newDetails);
|
||||||
assertEquals(network, client.getNetworkClient().getNetwork(network.getId()));
|
assertEquals(network, client.getNetworkClient().getNetwork(network.getId()));
|
||||||
|
checkNetwork(network);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkNetwork(Network network) {
|
||||||
assert network.getId() > 0 : network;
|
assert network.getId() > 0 : network;
|
||||||
assert network.getName() != null : network;
|
assert network.getName() != null : network;
|
||||||
assert network.getDNS().size() != 0 : network;
|
assert network.getDNS().size() != 0 : network;
|
||||||
|
@ -84,7 +145,5 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
assert network.getEndIP() != null : network;
|
assert network.getEndIP() != null : network;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||||
import org.jclouds.cloudstack.domain.Zone;
|
import org.jclouds.cloudstack.domain.Zone;
|
||||||
import org.jclouds.cloudstack.options.AccountInDomainOptions;
|
import org.jclouds.cloudstack.options.AccountInDomainOptions;
|
||||||
import org.jclouds.cloudstack.options.ListSecurityGroupsOptions;
|
import org.jclouds.cloudstack.options.ListSecurityGroupsOptions;
|
||||||
import org.jclouds.cloudstack.options.ListVirtualMachinesOptions;
|
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.testng.annotations.AfterGroups;
|
import org.testng.annotations.AfterGroups;
|
||||||
|
@ -170,9 +169,6 @@ public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
public void testCreateVMInSecurityGroup() throws Exception {
|
public void testCreateVMInSecurityGroup() throws Exception {
|
||||||
if (!securityGroupsSupported)
|
if (!securityGroupsSupported)
|
||||||
return;
|
return;
|
||||||
for (VirtualMachine vm : client.getVirtualMachineClient().listVirtualMachines(
|
|
||||||
ListVirtualMachinesOptions.Builder.zoneId(zone.getId()))) {
|
|
||||||
}
|
|
||||||
vm = VirtualMachineClientLiveTest.createVirtualMachineWithSecurityGroupInZone(zone.getId(), group.getId(),
|
vm = VirtualMachineClientLiveTest.createVirtualMachineWithSecurityGroupInZone(zone.getId(), group.getId(),
|
||||||
client, jobComplete, virtualMachineRunning);
|
client, jobComplete, virtualMachineRunning);
|
||||||
if (vm.getPassword() != null)
|
if (vm.getPassword() != null)
|
||||||
|
|
|
@ -98,14 +98,14 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeployVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeployVirtualMachineInZone() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VirtualMachineAsyncClient.class.getMethod("deployVirtualMachine", long.class, long.class,
|
Method method = VirtualMachineAsyncClient.class.getMethod("deployVirtualMachineInZone", long.class, long.class,
|
||||||
long.class, DeployVirtualMachineOptions[].class);
|
long.class, DeployVirtualMachineOptions[].class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, 4, 5, 6);
|
HttpRequest httpRequest = processor.createRequest(method, 6, 4, 5);
|
||||||
|
|
||||||
assertRequestLineEquals(
|
assertRequestLineEquals(
|
||||||
httpRequest,
|
httpRequest,
|
||||||
"GET http://localhost:8080/client/api?response=json&command=deployVirtualMachine&serviceofferingid=4&zoneid=6&templateid=5 HTTP/1.1");
|
"GET http://localhost:8080/client/api?response=json&command=deployVirtualMachine&zoneid=6&templateid=5&serviceofferingid=4 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
System.out.printf("serviceOfferingId %d, templateId %d, zoneId %d, options %s%n", serviceOfferingId, templateId,
|
System.out.printf("serviceOfferingId %d, templateId %d, zoneId %d, options %s%n", serviceOfferingId, templateId,
|
||||||
zoneId, options);
|
zoneId, options);
|
||||||
AsyncCreateResponse job = client.getVirtualMachineClient().deployVirtualMachine(serviceOfferingId, templateId,
|
AsyncCreateResponse job = client.getVirtualMachineClient().deployVirtualMachineInZone(serviceOfferingId, templateId,
|
||||||
zoneId, options);
|
zoneId, options);
|
||||||
assert jobComplete.apply(job.getJobId());
|
assert jobComplete.apply(job.getJobId());
|
||||||
AsyncJob<VirtualMachine> jobWithResult = client.getAsyncJobClient().<VirtualMachine> getAsyncJob(job.getJobId());
|
AsyncJob<VirtualMachine> jobWithResult = client.getAsyncJobClient().<VirtualMachine> getAsyncJob(job.getJobId());
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class ReuseOrAssociateNewPublicIPAddressTest {
|
||||||
|
|
||||||
AsyncCreateResponse job = new AsyncCreateResponse(1, 2);
|
AsyncCreateResponse job = new AsyncCreateResponse(1, 2);
|
||||||
// make sure we created the job relating to a new ip
|
// make sure we created the job relating to a new ip
|
||||||
expect(addressClient.associateIPAddress(zoneId, networkId(networkId))).andReturn(job);
|
expect(addressClient.associateIPAddressInZone(zoneId, networkId(networkId))).andReturn(job);
|
||||||
|
|
||||||
AsyncJobClient jobClient = createMock(AsyncJobClient.class);
|
AsyncJobClient jobClient = createMock(AsyncJobClient.class);
|
||||||
expect(client.getAsyncJobClient()).andReturn(jobClient).atLeastOnce();
|
expect(client.getAsyncJobClient()).andReturn(jobClient).atLeastOnce();
|
||||||
|
@ -132,7 +132,7 @@ public class ReuseOrAssociateNewPublicIPAddressTest {
|
||||||
|
|
||||||
AsyncCreateResponse job = new AsyncCreateResponse(1, 2);
|
AsyncCreateResponse job = new AsyncCreateResponse(1, 2);
|
||||||
// make sure we created the job relating to a new ip
|
// make sure we created the job relating to a new ip
|
||||||
expect(addressClient.associateIPAddress(zoneId, networkId(networkId))).andReturn(job);
|
expect(addressClient.associateIPAddressInZone(zoneId, networkId(networkId))).andReturn(job);
|
||||||
|
|
||||||
// the alwaysfalse predicate above should blow up with IllegalStateException
|
// the alwaysfalse predicate above should blow up with IllegalStateException
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,136 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.options;
|
||||||
|
|
||||||
|
import static org.jclouds.cloudstack.options.CreateNetworkOptions.Builder.accountInDomain;
|
||||||
|
import static org.jclouds.cloudstack.options.CreateNetworkOptions.Builder.endIP;
|
||||||
|
import static org.jclouds.cloudstack.options.CreateNetworkOptions.Builder.gateway;
|
||||||
|
import static org.jclouds.cloudstack.options.CreateNetworkOptions.Builder.isDefault;
|
||||||
|
import static org.jclouds.cloudstack.options.CreateNetworkOptions.Builder.isShared;
|
||||||
|
import static org.jclouds.cloudstack.options.CreateNetworkOptions.Builder.netmask;
|
||||||
|
import static org.jclouds.cloudstack.options.CreateNetworkOptions.Builder.networkDomain;
|
||||||
|
import static org.jclouds.cloudstack.options.CreateNetworkOptions.Builder.startIP;
|
||||||
|
import static org.jclouds.cloudstack.options.CreateNetworkOptions.Builder.vlan;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code CreateNetworkOptions}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class CreateNetworkOptionsTest {
|
||||||
|
|
||||||
|
public void testAccountInDomainId() {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions().accountInDomain("adrian", 6);
|
||||||
|
assertEquals(ImmutableList.of("adrian"), options.buildQueryParameters().get("account"));
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAccountInDomainIdStatic() {
|
||||||
|
CreateNetworkOptions options = accountInDomain("adrian", 6);
|
||||||
|
assertEquals(ImmutableList.of("adrian"), options.buildQueryParameters().get("account"));
|
||||||
|
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIsDefault() {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions().isDefault(true);
|
||||||
|
assertEquals(ImmutableList.of("true"), options.buildQueryParameters().get("isdefault"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIsDefaultStatic() {
|
||||||
|
CreateNetworkOptions options = isDefault(true);
|
||||||
|
assertEquals(ImmutableList.of("true"), options.buildQueryParameters().get("isdefault"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIsShared() {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions().isShared(true);
|
||||||
|
assertEquals(ImmutableList.of("true"), options.buildQueryParameters().get("isshared"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIsSharedStatic() {
|
||||||
|
CreateNetworkOptions options = isShared(true);
|
||||||
|
assertEquals(ImmutableList.of("true"), options.buildQueryParameters().get("isshared"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testStartIP() {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions().startIP("1.1.1.1");
|
||||||
|
assertEquals(ImmutableList.of("1.1.1.1"), options.buildQueryParameters().get("startip"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testStartIPStatic() {
|
||||||
|
CreateNetworkOptions options = startIP("1.1.1.1");
|
||||||
|
assertEquals(ImmutableList.of("1.1.1.1"), options.buildQueryParameters().get("startip"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testEndIP() {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions().endIP("1.1.1.1");
|
||||||
|
assertEquals(ImmutableList.of("1.1.1.1"), options.buildQueryParameters().get("endip"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testEndIPStatic() {
|
||||||
|
CreateNetworkOptions options = endIP("1.1.1.1");
|
||||||
|
assertEquals(ImmutableList.of("1.1.1.1"), options.buildQueryParameters().get("endip"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGateway() {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions().gateway("1.1.1.1");
|
||||||
|
assertEquals(ImmutableList.of("1.1.1.1"), options.buildQueryParameters().get("gateway"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGatewayStatic() {
|
||||||
|
CreateNetworkOptions options = gateway("1.1.1.1");
|
||||||
|
assertEquals(ImmutableList.of("1.1.1.1"), options.buildQueryParameters().get("gateway"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNetmask() {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions().netmask("1.1.1.1");
|
||||||
|
assertEquals(ImmutableList.of("1.1.1.1"), options.buildQueryParameters().get("netmask"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNetmaskStatic() {
|
||||||
|
CreateNetworkOptions options = netmask("1.1.1.1");
|
||||||
|
assertEquals(ImmutableList.of("1.1.1.1"), options.buildQueryParameters().get("netmask"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNetworkDomain() {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions().networkDomain("network.com");
|
||||||
|
assertEquals(ImmutableList.of("network.com"), options.buildQueryParameters().get("networkdomain"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNetworkDomainStatic() {
|
||||||
|
CreateNetworkOptions options = networkDomain("network.com");
|
||||||
|
assertEquals(ImmutableList.of("network.com"), options.buildQueryParameters().get("networkdomain"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVlan() {
|
||||||
|
CreateNetworkOptions options = new CreateNetworkOptions().vlan("tag");
|
||||||
|
assertEquals(ImmutableList.of("tag"), options.buildQueryParameters().get("vlan"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVlanStatic() {
|
||||||
|
CreateNetworkOptions options = vlan("tag");
|
||||||
|
assertEquals(ImmutableList.of("tag"), options.buildQueryParameters().get("vlan"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,28 +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.parse;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public abstract class BaseItemParserTest<T> extends BaseParserTest<T, T> {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,79 +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.parse;
|
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
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.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
|
|
||||||
*/
|
|
||||||
public abstract class BaseParserTest<T, G> {
|
|
||||||
|
|
||||||
Injector i = Guice.createInjector(new GsonModule() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
|
||||||
super.configure();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, new CloudStackParserModule());
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
|
|
||||||
T expects = expected();
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
|
@ -1,52 +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.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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -20,14 +20,19 @@ package org.jclouds.cloudstack.parse;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.config.CloudStackParserModule;
|
||||||
import org.jclouds.cloudstack.domain.Account;
|
import org.jclouds.cloudstack.domain.Account;
|
||||||
|
import org.jclouds.cloudstack.domain.User;
|
||||||
import org.jclouds.cloudstack.domain.Account.State;
|
import org.jclouds.cloudstack.domain.Account.State;
|
||||||
import org.jclouds.cloudstack.domain.Account.Type;
|
import org.jclouds.cloudstack.domain.Account.Type;
|
||||||
import org.jclouds.cloudstack.domain.User;
|
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -35,6 +40,19 @@ import com.google.common.collect.ImmutableSet;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit")
|
||||||
public class ListAccountsResponseTest extends BaseSetParserTest<Account> {
|
public class ListAccountsResponseTest extends BaseSetParserTest<Account> {
|
||||||
|
@Override
|
||||||
|
protected Injector getInjector() {
|
||||||
|
return Guice.createInjector(new CloudStackParserModule(), new GsonModule() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||||
|
super.configure();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<Account> type() {
|
public Class<Account> type() {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.cloudstack.parse;
|
package org.jclouds.cloudstack.parse;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.Capabilities;
|
import org.jclouds.cloudstack.domain.Capabilities;
|
||||||
|
import org.jclouds.json.BaseItemParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.DiskOffering;
|
import org.jclouds.cloudstack.domain.DiskOffering;
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
|
@ -22,10 +22,12 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.functions.ParseNamesFromHttpResponse;
|
import org.jclouds.cloudstack.functions.ParseNamesFromHttpResponse;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -50,7 +52,7 @@ public class ListHypervisorsResponseTest extends BaseSetParserTest<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<HttpResponse, Set<String>> getParser() {
|
protected Function<HttpResponse, Set<String>> getParser(Injector injector) {
|
||||||
return i.getInstance(ParseNamesFromHttpResponse.class);
|
return injector.getInstance(ParseNamesFromHttpResponse.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.NetworkOffering;
|
import org.jclouds.cloudstack.domain.NetworkOffering;
|
||||||
import org.jclouds.cloudstack.domain.TrafficType;
|
import org.jclouds.cloudstack.domain.TrafficType;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.jclouds.cloudstack.domain.GuestIPType;
|
||||||
import org.jclouds.cloudstack.domain.Network;
|
import org.jclouds.cloudstack.domain.Network;
|
||||||
import org.jclouds.cloudstack.domain.NetworkService;
|
import org.jclouds.cloudstack.domain.NetworkService;
|
||||||
import org.jclouds.cloudstack.domain.TrafficType;
|
import org.jclouds.cloudstack.domain.TrafficType;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
|
@ -22,10 +22,12 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.functions.ParseIdToNameFromHttpResponse;
|
import org.jclouds.cloudstack.functions.ParseIdToNameFromHttpResponse;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.json.BaseItemParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -41,17 +43,17 @@ public class ListOSCategoriesResponseTest extends BaseItemParserTest<Map<Long, S
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Long, String> expected() {
|
public Map<Long, String> expected() {
|
||||||
return ImmutableMap.<Long, String> builder().put(1l, "CentOS").put(2l, "Debian").put(3l, "Oracle")
|
return ImmutableMap.<Long, String> builder().put(1l, "CentOS").put(2l, "Debian").put(3l, "Oracle").put(4l,
|
||||||
.put(4l, "RedHat").put(5l, "SUSE").put(6l, "Windows").put(7l, "Other").put(8l, "Novel").put(9l, "Unix")
|
"RedHat").put(5l, "SUSE").put(6l, "Windows").put(7l, "Other").put(8l, "Novel").put(9l, "Unix").put(10l,
|
||||||
.put(10l, "Ubuntu").build();
|
"Ubuntu").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<HttpResponse, Map<Long, String>> getParser() {
|
protected Function<HttpResponse, Map<Long, String>> getParser(Injector injector) {
|
||||||
return i.getInstance(ParseIdToNameFromHttpResponse.class);
|
return injector.getInstance(ParseIdToNameFromHttpResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings( { "unchecked", "rawtypes" })
|
||||||
@Override
|
@Override
|
||||||
public Class<Map<Long, String>> type() {
|
public Class<Map<Long, String>> type() {
|
||||||
return (Class) Map.class;
|
return (Class) Map.class;
|
||||||
|
|
|
@ -0,0 +1,230 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.OSType;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class ListOSTypesResponseTest extends BaseSetParserTest<OSType> {
|
||||||
|
@Override
|
||||||
|
public Class<OSType> type() {
|
||||||
|
return OSType.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String resource() {
|
||||||
|
return "/listostypesresponse.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<OSType> expected() {
|
||||||
|
return ImmutableSet.<OSType> builder().add(
|
||||||
|
OSType.builder().id(69).OSCategoryId(7).description("Asianux 3(32-bit)").build()).add(
|
||||||
|
OSType.builder().id(70).OSCategoryId(7).description("Asianux 3(64-bit)").build()).add(
|
||||||
|
OSType.builder().id(1).OSCategoryId(1).description("CentOS 4.5 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(2).OSCategoryId(1).description("CentOS 4.6 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(3).OSCategoryId(1).description("CentOS 4.7 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(4).OSCategoryId(1).description("CentOS 4.8 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(5).OSCategoryId(1).description("CentOS 5.0 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(6).OSCategoryId(1).description("CentOS 5.0 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(7).OSCategoryId(1).description("CentOS 5.1 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(8).OSCategoryId(1).description("CentOS 5.1 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(9).OSCategoryId(1).description("CentOS 5.2 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(10).OSCategoryId(1).description("CentOS 5.2 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(11).OSCategoryId(1).description("CentOS 5.3 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(12).OSCategoryId(1).description("CentOS 5.3 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(13).OSCategoryId(1).description("CentOS 5.4 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(14).OSCategoryId(1).description("CentOS 5.4 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(111).OSCategoryId(1).description("CentOS 5.5 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(112).OSCategoryId(1).description("CentOS 5.5 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(73).OSCategoryId(2).description("Debian GNU/Linux 4(32-bit)").build()).add(
|
||||||
|
OSType.builder().id(74).OSCategoryId(2).description("Debian GNU/Linux 4(64-bit)").build()).add(
|
||||||
|
OSType.builder().id(72).OSCategoryId(2).description("Debian GNU/Linux 5(64-bit)").build()).add(
|
||||||
|
OSType.builder().id(15).OSCategoryId(2).description("Debian GNU/Linux 5.0 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(132).OSCategoryId(2).description("Debian GNU/Linux 6(32-bit)").build()).add(
|
||||||
|
OSType.builder().id(133).OSCategoryId(2).description("Debian GNU/Linux 6(64-bit)").build()).add(
|
||||||
|
OSType.builder().id(102).OSCategoryId(6).description("DOS").build()).add(
|
||||||
|
OSType.builder().id(118).OSCategoryId(4).description("Fedora 10").build()).add(
|
||||||
|
OSType.builder().id(117).OSCategoryId(4).description("Fedora 11").build()).add(
|
||||||
|
OSType.builder().id(116).OSCategoryId(4).description("Fedora 12").build()).add(
|
||||||
|
OSType.builder().id(115).OSCategoryId(4).description("Fedora 13").build()).add(
|
||||||
|
OSType.builder().id(120).OSCategoryId(4).description("Fedora 8").build()).add(
|
||||||
|
OSType.builder().id(119).OSCategoryId(4).description("Fedora 9").build()).add(
|
||||||
|
OSType.builder().id(83).OSCategoryId(9).description("FreeBSD (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(84).OSCategoryId(9).description("FreeBSD (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(92).OSCategoryId(6).description("Microsoft Small Bussiness Server 2003").build())
|
||||||
|
.add(OSType.builder().id(78).OSCategoryId(8).description("Novell Netware 5.1").build()).add(
|
||||||
|
OSType.builder().id(77).OSCategoryId(8).description("Novell Netware 6.x").build()).add(
|
||||||
|
OSType.builder().id(68).OSCategoryId(7).description("Open Enterprise Server").build()).add(
|
||||||
|
OSType.builder().id(16).OSCategoryId(3).description("Oracle Enterprise Linux 5.0 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(17).OSCategoryId(3).description("Oracle Enterprise Linux 5.0 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(18).OSCategoryId(3).description("Oracle Enterprise Linux 5.1 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(19).OSCategoryId(3).description("Oracle Enterprise Linux 5.1 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(20).OSCategoryId(3).description("Oracle Enterprise Linux 5.2 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(21).OSCategoryId(3).description("Oracle Enterprise Linux 5.2 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(22).OSCategoryId(3).description("Oracle Enterprise Linux 5.3 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(23).OSCategoryId(3).description("Oracle Enterprise Linux 5.3 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(24).OSCategoryId(3).description("Oracle Enterprise Linux 5.4 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(25).OSCategoryId(3).description("Oracle Enterprise Linux 5.4 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(134).OSCategoryId(3).description("Oracle Enterprise Linux 5.5 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(135).OSCategoryId(3).description("Oracle Enterprise Linux 5.5 (64-bit)")
|
||||||
|
.build()).add(OSType.builder().id(104).OSCategoryId(7).description("OS/2").build())
|
||||||
|
.add(OSType.builder().id(60).OSCategoryId(7).description("Other (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(103).OSCategoryId(7).description("Other (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(75).OSCategoryId(7).description("Other 2.6x Linux (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(76).OSCategoryId(7).description("Other 2.6x Linux (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(98).OSCategoryId(7).description("Other Linux (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(99).OSCategoryId(7).description("Other Linux (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(59).OSCategoryId(10).description("Other Ubuntu (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(100).OSCategoryId(10).description("Other Ubuntu (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(131).OSCategoryId(10).description("Red Hat Enterprise Linux 2").build())
|
||||||
|
.add(OSType.builder().id(66).OSCategoryId(4).description("Red Hat Enterprise Linux 3(32-bit)").build())
|
||||||
|
.add(OSType.builder().id(67).OSCategoryId(4).description("Red Hat Enterprise Linux 3(64-bit)").build())
|
||||||
|
.add(OSType.builder().id(106).OSCategoryId(4).description("Red Hat Enterprise Linux 4(64-bit)").build())
|
||||||
|
.add(
|
||||||
|
OSType.builder().id(26).OSCategoryId(4).description("Red Hat Enterprise Linux 4.5 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(27).OSCategoryId(4).description("Red Hat Enterprise Linux 4.6 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(28).OSCategoryId(4).description("Red Hat Enterprise Linux 4.7 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(29).OSCategoryId(4).description("Red Hat Enterprise Linux 4.8 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(30).OSCategoryId(4).description("Red Hat Enterprise Linux 5.0 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(31).OSCategoryId(4).description("Red Hat Enterprise Linux 5.0 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(32).OSCategoryId(4).description("Red Hat Enterprise Linux 5.1 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(33).OSCategoryId(4).description("Red Hat Enterprise Linux 5.1 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(34).OSCategoryId(4).description("Red Hat Enterprise Linux 5.2 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(35).OSCategoryId(4).description("Red Hat Enterprise Linux 5.2 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(36).OSCategoryId(4).description("Red Hat Enterprise Linux 5.3 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(37).OSCategoryId(4).description("Red Hat Enterprise Linux 5.3 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(38).OSCategoryId(4).description("Red Hat Enterprise Linux 5.4 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(39).OSCategoryId(4).description("Red Hat Enterprise Linux 5.4 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(113).OSCategoryId(4).description("Red Hat Enterprise Linux 5.5 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(114).OSCategoryId(4).description("Red Hat Enterprise Linux 5.5 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(136).OSCategoryId(4).description("Red Hat Enterprise Linux 6.0 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(137).OSCategoryId(4).description("Red Hat Enterprise Linux 6.0 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(85).OSCategoryId(9).description("SCO OpenServer 5").build()).add(
|
||||||
|
OSType.builder().id(86).OSCategoryId(9).description("SCO UnixWare 7").build()).add(
|
||||||
|
OSType.builder().id(79).OSCategoryId(9).description("Sun Solaris 10(32-bit)").build()).add(
|
||||||
|
OSType.builder().id(80).OSCategoryId(9).description("Sun Solaris 10(64-bit)").build()).add(
|
||||||
|
OSType.builder().id(82).OSCategoryId(9).description("Sun Solaris 8(Experimental)").build())
|
||||||
|
.add(OSType.builder().id(81).OSCategoryId(9).description("Sun Solaris 9(Experimental)").build()).add(
|
||||||
|
OSType.builder().id(109).OSCategoryId(5).description("SUSE Linux Enterprise 10(32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(110).OSCategoryId(5).description("SUSE Linux Enterprise 10(64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(96).OSCategoryId(5).description("SUSE Linux Enterprise 8(32-bit)").build())
|
||||||
|
.add(OSType.builder().id(97).OSCategoryId(5).description("SUSE Linux Enterprise 8(64-bit)").build())
|
||||||
|
.add(OSType.builder().id(107).OSCategoryId(5).description("SUSE Linux Enterprise 9(32-bit)").build())
|
||||||
|
.add(OSType.builder().id(108).OSCategoryId(5).description("SUSE Linux Enterprise 9(64-bit)").build())
|
||||||
|
.add(
|
||||||
|
OSType.builder().id(41).OSCategoryId(5).description(
|
||||||
|
"SUSE Linux Enterprise Server 10 SP1 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(42).OSCategoryId(5).description(
|
||||||
|
"SUSE Linux Enterprise Server 10 SP1 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(43).OSCategoryId(5).description(
|
||||||
|
"SUSE Linux Enterprise Server 10 SP2 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(44).OSCategoryId(5).description(
|
||||||
|
"SUSE Linux Enterprise Server 10 SP2 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(45).OSCategoryId(5).description(
|
||||||
|
"SUSE Linux Enterprise Server 10 SP3 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(46).OSCategoryId(5).description("SUSE Linux Enterprise Server 11 (32-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(47).OSCategoryId(5).description("SUSE Linux Enterprise Server 11 (64-bit)")
|
||||||
|
.build()).add(
|
||||||
|
OSType.builder().id(40).OSCategoryId(5).description(
|
||||||
|
"SUSE Linux Enterprise Server 9 SP4 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(121).OSCategoryId(10).description("Ubuntu 10.04 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(126).OSCategoryId(10).description("Ubuntu 10.04 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(125).OSCategoryId(10).description("Ubuntu 8.04 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(130).OSCategoryId(10).description("Ubuntu 8.04 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(124).OSCategoryId(10).description("Ubuntu 8.10 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(129).OSCategoryId(10).description("Ubuntu 8.10 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(123).OSCategoryId(10).description("Ubuntu 9.04 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(128).OSCategoryId(10).description("Ubuntu 9.04 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(122).OSCategoryId(10).description("Ubuntu 9.10 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(127).OSCategoryId(10).description("Ubuntu 9.10 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(95).OSCategoryId(6).description("Windows 2000 Advanced Server").build())
|
||||||
|
.add(OSType.builder().id(105).OSCategoryId(6).description("Windows 2000 Professional").build()).add(
|
||||||
|
OSType.builder().id(61).OSCategoryId(6).description("Windows 2000 Server").build())
|
||||||
|
.add(OSType.builder().id(55).OSCategoryId(6).description("Windows 2000 Server SP4 (32-bit)").build())
|
||||||
|
.add(OSType.builder().id(65).OSCategoryId(6).description("Windows 3.1").build()).add(
|
||||||
|
OSType.builder().id(48).OSCategoryId(6).description("Windows 7 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(49).OSCategoryId(6).description("Windows 7 (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(63).OSCategoryId(6).description("Windows 95").build()).add(
|
||||||
|
OSType.builder().id(62).OSCategoryId(6).description("Windows 98").build()).add(
|
||||||
|
OSType.builder().id(64).OSCategoryId(6).description("Windows NT 4").build()).add(
|
||||||
|
OSType.builder().id(87).OSCategoryId(6).description(
|
||||||
|
"Windows Server 2003 DataCenter Edition(32-bit)").build()).add(
|
||||||
|
OSType.builder().id(88).OSCategoryId(6).description(
|
||||||
|
"Windows Server 2003 DataCenter Edition(64-bit)").build()).add(
|
||||||
|
OSType.builder().id(50).OSCategoryId(6).description(
|
||||||
|
"Windows Server 2003 Enterprise Edition(32-bit)").build()).add(
|
||||||
|
OSType.builder().id(51).OSCategoryId(6).description(
|
||||||
|
"Windows Server 2003 Enterprise Edition(64-bit)").build()).add(
|
||||||
|
OSType.builder().id(89).OSCategoryId(6).description(
|
||||||
|
"Windows Server 2003 Standard Edition(32-bit)").build()).add(
|
||||||
|
OSType.builder().id(90).OSCategoryId(6).description(
|
||||||
|
"Windows Server 2003 Standard Edition(64-bit)").build()).add(
|
||||||
|
OSType.builder().id(91).OSCategoryId(6).description("Windows Server 2003 Web Edition").build())
|
||||||
|
.add(OSType.builder().id(52).OSCategoryId(6).description("Windows Server 2008 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(53).OSCategoryId(6).description("Windows Server 2008 (64-bit)").build())
|
||||||
|
.add(OSType.builder().id(54).OSCategoryId(6).description("Windows Server 2008 R2 (64-bit)").build())
|
||||||
|
.add(OSType.builder().id(56).OSCategoryId(6).description("Windows Vista (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(101).OSCategoryId(6).description("Windows Vista (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(93).OSCategoryId(6).description("Windows XP (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(94).OSCategoryId(6).description("Windows XP (64-bit)").build()).add(
|
||||||
|
OSType.builder().id(57).OSCategoryId(6).description("Windows XP SP2 (32-bit)").build()).add(
|
||||||
|
OSType.builder().id(58).OSCategoryId(6).description("Windows XP SP3 (32-bit)").build()).build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ package org.jclouds.cloudstack.parse;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.PortForwardingRule;
|
import org.jclouds.cloudstack.domain.PortForwardingRule;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.IngressRule;
|
import org.jclouds.cloudstack.domain.IngressRule;
|
||||||
import org.jclouds.cloudstack.domain.SecurityGroup;
|
import org.jclouds.cloudstack.domain.SecurityGroup;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Set;
|
||||||
import org.jclouds.cloudstack.domain.ServiceOffering;
|
import org.jclouds.cloudstack.domain.ServiceOffering;
|
||||||
import org.jclouds.cloudstack.domain.StorageType;
|
import org.jclouds.cloudstack.domain.StorageType;
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.jclouds.cloudstack.domain.Template;
|
||||||
import org.jclouds.cloudstack.domain.Template.Format;
|
import org.jclouds.cloudstack.domain.Template.Format;
|
||||||
import org.jclouds.cloudstack.domain.Template.Type;
|
import org.jclouds.cloudstack.domain.Template.Type;
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.jclouds.cloudstack.domain.NIC;
|
||||||
import org.jclouds.cloudstack.domain.TrafficType;
|
import org.jclouds.cloudstack.domain.TrafficType;
|
||||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Set;
|
||||||
|
|
||||||
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.json.BaseSetParserTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue