From e7b350a6ff07a4eb9d7ed2603c861119504ad39c Mon Sep 17 00:00:00 2001 From: Kedar Dave Date: Wed, 9 Feb 2011 10:13:38 -0600 Subject: [PATCH 01/10] added vdc,vapp,network handling for savvis --- .../org/jclouds/vcloud/xml/VDCHandler.java | 8 +- .../savvis/SymphonyVPDCAsyncClient.java | 75 +++++++ .../config/SymphonyVPDCRestClientModule.java | 13 +- .../domain/network/SymphonyVPDCNetwork.java | 84 +++++++ .../internal/SymphonyVPDCNetworkImpl.java | 205 ++++++++++++++++++ .../xml/SymphonyVPDCNetworkHandler.java | 154 +++++++++++++ .../savvis/xml/SymphonyVPDCVAppHandler.java | 147 +++++++++++++ .../savvis/SymphonyVPDCClientLiveTest.java | 11 +- 8 files changed, 689 insertions(+), 8 deletions(-) create mode 100644 sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/domain/network/SymphonyVPDCNetwork.java create mode 100644 sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/domain/network/internal/SymphonyVPDCNetworkImpl.java create mode 100644 sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCNetworkHandler.java create mode 100644 sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCVAppHandler.java diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java index b226070bab..c0270a84ef 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java @@ -98,16 +98,16 @@ public class VDCHandler extends ParseSax.HandlerWithResult { @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { Map attributes = cleanseAttributes(attrs); - if (qName.equals("Vdc")) { + if (qName.endsWith("Vdc")) { vDC = newReferenceType(attributes); String status = attributes.get("status"); if (status != null) this.status = VDCStatus.fromValue(Integer.parseInt(status)); - } else if (qName.equals("Network")) { + } else if (qName.endsWith("Network")) { putReferenceType(availableNetworks, attributes); - } else if (qName.equals("ResourceEntity")) { + } else if (qName.endsWith("ResourceEntity")) { putReferenceType(resourceEntities, attributes); - } else if (qName.equals("Link") && "up".equals(attributes.get("rel"))) { + } else if (qName.endsWith("Link") && "up".equals(attributes.get("rel"))) { org = newReferenceType(attributes); } else { taskHandler.startElement(uri, localName, qName, attrs); diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java b/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java index 9273d42ec5..867f000d1f 100644 --- a/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java +++ b/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java @@ -29,11 +29,21 @@ import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.vcloud.CommonVCloudClient; +import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudExpressAsyncClient; import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.VCloudExpressVApp; +import org.jclouds.vcloud.domain.VDC; +import org.jclouds.vcloud.domain.network.OrgNetwork; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameToEndpoint; +import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; +import org.jclouds.vcloud.savvis.xml.SymphonyVPDCNetworkHandler; +import org.jclouds.vcloud.savvis.xml.SymphonyVPDCVAppHandler; import org.jclouds.vcloud.xml.OrgHandler; +import org.jclouds.vcloud.xml.VDCHandler; import com.google.common.util.concurrent.ListenableFuture; @@ -67,4 +77,69 @@ public interface SymphonyVPDCAsyncClient extends VCloudExpressAsyncClient { @XMLResponseParser(OrgHandler.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture getOrg(@EndpointParam URI orgId); + + /** + * @see CommonVCloudClient#getVDC(URI) + */ + @GET + @XMLResponseParser(VDCHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVDC(@EndpointParam URI vdc); + + /** + * @see CommonVCloudClient#findVDCInOrgNamed(String, String) + */ + @GET + @XMLResponseParser(VDCHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture findVDCInOrgNamed( + @Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName); + + /** + * @see CommonVCloudClient#findNetworkInOrgVDCNamed + *//* + @GET + @XMLResponseParser(TerremarkOrgNetworkFromTerremarkVCloudExpressNetworkHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture findNetworkInOrgVDCNamed( + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName, + @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName); + + *//** + * @see CommonVCloudClient#getNetwork + *//* + @GET + @XMLResponseParser(TerremarkOrgNetworkFromTerremarkVCloudExpressNetworkHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetwork(@EndpointParam URI network);*/ + + /** + * @see CommonVCloudClient#findNetworkInOrgVDCNamed + */ + @GET + @XMLResponseParser(SymphonyVPDCNetworkHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture findNetworkInOrgVDCNamed( + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName, + @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName); + + /** + * @see CommonVCloudClient#getNetwork + */ + @GET + @XMLResponseParser(SymphonyVPDCNetworkHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetwork(@EndpointParam URI network); + + /** + * @see VCloudClient#getVApp + */ + @GET + @XMLResponseParser(SymphonyVPDCVAppHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVApp(@EndpointParam URI vApp); + } diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/config/SymphonyVPDCRestClientModule.java b/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/config/SymphonyVPDCRestClientModule.java index d65fac14b2..69427500dd 100644 --- a/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/config/SymphonyVPDCRestClientModule.java +++ b/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/config/SymphonyVPDCRestClientModule.java @@ -19,6 +19,8 @@ package org.jclouds.savvis.config; +import java.net.URI; + import javax.inject.Singleton; import org.jclouds.http.HttpErrorHandler; @@ -31,6 +33,7 @@ import org.jclouds.savvis.handlers.SymphonyVPDCErrorHandler; import org.jclouds.vcloud.VCloudExpressAsyncClient; import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.config.BaseVCloudExpressRestClientModule; +import org.jclouds.vcloud.domain.Org; import com.google.inject.Provides; @@ -52,7 +55,15 @@ public class SymphonyVPDCRestClientModule extends protected VCloudExpressClient provideVCloudClient(SymphonyVPDCClient in) { return in; } - + + @Override + protected URI provideDefaultTasksList(Org org) { + if(org.getTasksList() != null){ + return org.getTasksList().getHref(); + }else{ + return URI.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/tasksList"); + } + } @Override diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/domain/network/SymphonyVPDCNetwork.java b/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/domain/network/SymphonyVPDCNetwork.java new file mode 100644 index 0000000000..bddf4bc766 --- /dev/null +++ b/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/domain/network/SymphonyVPDCNetwork.java @@ -0,0 +1,84 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.vcloud.domain.network; + +import java.util.Set; + +import javax.annotation.Nullable; + +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.network.firewall.FirewallRule; +import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule; + +/** + * + * A network that is available in a vDC. + * + * @author Kedar Dave + */ +public interface SymphonyVPDCNetwork extends ReferenceType { + /** + * + * @return Description of the network + */ + String getDescription(); + + /** + * @return IP addresses of the network’s DNS servers. + */ + Set getDnsServers(); + + /** + * + * + * @return The IP address of the network’s primary gateway + */ + String getGateway(); + + /** + * * + * + * @return the network’s subnet mask + */ + String getNetmask(); + + /** + * return the network’s fence modes. + */ + Set getFenceModes(); + + /** + * return True if the network provides DHCP services + */ + @Nullable + Boolean isDhcp(); + + /** + * + * @return Network Address Translation rules for the network + */ + Set getNatRules(); + + /** + * @return Firewall rules for the network + */ + Set getFirewallRules(); + +} \ No newline at end of file diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/domain/network/internal/SymphonyVPDCNetworkImpl.java b/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/domain/network/internal/SymphonyVPDCNetworkImpl.java new file mode 100644 index 0000000000..9cdc3a236b --- /dev/null +++ b/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/domain/network/internal/SymphonyVPDCNetworkImpl.java @@ -0,0 +1,205 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.vcloud.domain.network.internal; + +import java.net.URI; +import java.util.Set; + +import javax.annotation.Nullable; + +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; +import org.jclouds.vcloud.domain.network.FenceMode; +import org.jclouds.vcloud.domain.network.SymphonyVPDCNetwork; +import org.jclouds.vcloud.domain.network.firewall.FirewallRule; +import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule; + +import com.google.common.collect.Sets; + +/** + * Locations of resources in vCloud + * + * @author Kedar Dave + * + */ +public class SymphonyVPDCNetworkImpl extends ReferenceTypeImpl implements SymphonyVPDCNetwork { + + /** The serialVersionUID */ + private static final long serialVersionUID = 8464716396538298809L; + protected final String description; + protected final Set dnsServers = Sets.newHashSet(); + protected final String gateway; + protected final String netmask; + protected final Set fenceModes = Sets.newHashSet(); + @Nullable + protected final Boolean dhcp; + protected final Set natRules = Sets.newHashSet(); + protected final Set firewallRules = Sets.newHashSet(); + + public SymphonyVPDCNetworkImpl(String name, String type, URI id, String description, Set dnsServers, + String gateway, String netmask, Set fenceModes, Boolean dhcp, Set natRules, + Set firewallRules) { + super(name, type, id); + this.description = description; + this.dnsServers.addAll(dnsServers); + this.gateway = gateway; + this.netmask = netmask; + this.fenceModes.addAll(fenceModes); + this.dhcp = dhcp; + this.natRules.addAll(natRules); + this.firewallRules.addAll(firewallRules); + } + + /** + * {@inheritDoc} + */ + public String getDescription() { + return description; + } + + /** + * {@inheritDoc} + */ + public Set getDnsServers() { + return dnsServers; + } + + /** + * {@inheritDoc} + */ + public String getGateway() { + return gateway; + } + + /** + * {@inheritDoc} + */ + public String getNetmask() { + return netmask; + } + + /** + * {@inheritDoc} + */ + public Set getFenceModes() { + return fenceModes; + } + + /** + * {@inheritDoc} + */ + public Boolean isDhcp() { + return dhcp; + } + + /** + * {@inheritDoc} + */ + public Set getNatRules() { + return natRules; + } + + /** + * {@inheritDoc} + */ + public Set getFirewallRules() { + return firewallRules; + } + + @Override + public int compareTo(ReferenceType o) { + return (this == o) ? 0 : getHref().compareTo(o.getHref()); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((dhcp == null) ? 0 : dhcp.hashCode()); + result = prime * result + ((dnsServers == null) ? 0 : dnsServers.hashCode()); + result = prime * result + ((fenceModes == null) ? 0 : fenceModes.hashCode()); + result = prime * result + ((firewallRules == null) ? 0 : firewallRules.hashCode()); + result = prime * result + ((gateway == null) ? 0 : gateway.hashCode()); + result = prime * result + ((natRules == null) ? 0 : natRules.hashCode()); + result = prime * result + ((netmask == null) ? 0 : netmask.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + VCloudExpressNetworkImpl other = (VCloudExpressNetworkImpl) obj; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (dhcp == null) { + if (other.dhcp != null) + return false; + } else if (!dhcp.equals(other.dhcp)) + return false; + if (dnsServers == null) { + if (other.dnsServers != null) + return false; + } else if (!dnsServers.equals(other.dnsServers)) + return false; + if (fenceModes == null) { + if (other.fenceModes != null) + return false; + } else if (!fenceModes.equals(other.fenceModes)) + return false; + if (firewallRules == null) { + if (other.firewallRules != null) + return false; + } else if (!firewallRules.equals(other.firewallRules)) + return false; + if (gateway == null) { + if (other.gateway != null) + return false; + } else if (!gateway.equals(other.gateway)) + return false; + if (natRules == null) { + if (other.natRules != null) + return false; + } else if (!natRules.equals(other.natRules)) + return false; + if (netmask == null) { + if (other.netmask != null) + return false; + } else if (!netmask.equals(other.netmask)) + return false; + return true; + } + + @Override + public String toString() { + return "[id=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", description=" + description + + ", dhcp=" + dhcp + ", dnsServers=" + dnsServers + ", fenceModes=" + fenceModes + ", firewallRules=" + + firewallRules + ", gateway=" + gateway + ", natRules=" + natRules + ", netmask=" + netmask + "]"; + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCNetworkHandler.java b/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCNetworkHandler.java new file mode 100644 index 0000000000..1c698dc3e8 --- /dev/null +++ b/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCNetworkHandler.java @@ -0,0 +1,154 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.vcloud.savvis.xml; + +import static org.jclouds.vcloud.util.Utils.cleanseAttributes; +import static org.jclouds.vcloud.util.Utils.newReferenceType; + +import java.util.Map; +import java.util.Set; + +import javax.annotation.Resource; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.logging.Logger; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.network.FenceMode; +import org.jclouds.vcloud.domain.network.SymphonyVPDCNetwork; +import org.jclouds.vcloud.domain.network.firewall.FirewallPolicy; +import org.jclouds.vcloud.domain.network.firewall.FirewallRule; +import org.jclouds.vcloud.domain.network.internal.SymphonyVPDCNetworkImpl; +import org.jclouds.vcloud.domain.network.nat.NatProtocol; +import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import com.google.common.collect.Sets; + +/** + * @author Kedar Dave + */ +public class SymphonyVPDCNetworkHandler extends ParseSax.HandlerWithResult{ + + @Resource + protected Logger logger = Logger.NULL; + + private ReferenceType ips; + private ReferenceType extension; + + protected StringBuilder currentText = new StringBuilder(); + + protected ReferenceType network; + + protected String description; + + protected Set dnsServers = Sets.newLinkedHashSet(); + protected String gateway; + protected String netmask; + protected Set fenceModes = Sets.newLinkedHashSet(); + protected Boolean dhcp; + protected Set natRules = Sets.newLinkedHashSet(); + protected Set firewallRules = Sets.newLinkedHashSet(); + + protected String externalIP; + protected Integer externalPort; + protected String internalIP; + protected Integer internalPort; + + protected FirewallPolicy policy; + protected String sourceIP; + protected int sourcePort; + + public SymphonyVPDCNetwork getResult() { + return new SymphonyVPDCNetworkImpl(network.getName(), network.getType(), network.getHref(), description, + dnsServers, gateway, netmask, fenceModes, dhcp, natRules, firewallRules); + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { + Map attributes = cleanseAttributes(attrs); + if (qName.endsWith("Network")) { + network = newReferenceType(attributes); + } else if (qName.endsWith("Link")) { + if ("IP Addresses".equals(attributes.get("name"))) { + ips = newReferenceType(attributes); + } else if ("down".equals(attributes.get("rel"))) { + extension = newReferenceType(attributes); + } + } + } + + public void endElement(String uri, String name, String qName) { + if (qName.equals("Description")) { + description = currentOrNull(); + } else if (qName.equals("Dns")) { + dnsServers.add(currentOrNull()); + } else if (qName.equals("Gateway")) { + gateway = currentOrNull(); + } else if (qName.equals("Netmask")) { + netmask = currentOrNull(); + } else if (qName.equals("FenceMode")) { + try { + fenceModes.add(FenceMode.fromValue(currentOrNull())); + } catch (IllegalArgumentException e) { + fenceModes.add(FenceMode.BRIDGED); + } + } else if (qName.equals("Dhcp")) { + dhcp = new Boolean(currentOrNull()); + } else if (qName.equals("NatRule")) { + natRules.add(new PortForwardingRule(externalIP, externalPort, internalIP, internalPort, NatProtocol.TCP_UDP)); + externalIP = null; + externalPort = null; + internalIP = null; + internalPort = null; + } else if (qName.equals("ExternalIP")) { + externalIP = currentOrNull(); + } else if (qName.equals("ExternalPort")) { + externalPort = Integer.parseInt(currentOrNull()); + } else if (qName.equals("InternalIP")) { + internalIP = currentOrNull(); + } else if (qName.equals("InternalPort")) { + internalPort = Integer.parseInt(currentOrNull()); + } else if (qName.equals("FirewallRule")) { + firewallRules.add(new FirewallRule(true, null, policy, null, sourcePort, sourceIP)); + policy = null; + sourceIP = null; + sourcePort = -1; + } else if (qName.equals("Policy")) { + policy = FirewallPolicy.fromValue(currentOrNull()); + } else if (qName.equals("SourceIp")) { + sourceIP = currentOrNull(); + } else if (qName.equals("SourcePort")) { + sourcePort = Integer.parseInt(currentOrNull()); + } + + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } + + protected String currentOrNull() { + String returnVal = currentText.toString().trim(); + return returnVal.equals("") ? null : returnVal; + } + +} diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCVAppHandler.java b/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCVAppHandler.java new file mode 100644 index 0000000000..630c9f7a3c --- /dev/null +++ b/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCVAppHandler.java @@ -0,0 +1,147 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.vcloud.savvis.xml; + +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.vcloud.util.Utils.cleanseAttributes; +import static org.jclouds.vcloud.util.Utils.newReferenceType; + +import java.net.URI; +import java.util.Map; +import java.util.Set; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.logging.Logger; +import org.jclouds.vcloud.VCloudExpressMediaType; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.Status; +import org.jclouds.vcloud.domain.VCloudExpressVApp; +import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl; +import org.jclouds.vcloud.domain.ovf.ResourceAllocation; +import org.jclouds.vcloud.domain.ovf.System; +import org.jclouds.vcloud.xml.ovf.ResourceAllocationHandler; +import org.jclouds.vcloud.xml.ovf.SystemHandler; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Sets; + +/** + * @author Kedar Dave + */ +public class SymphonyVPDCVAppHandler extends ParseSax.HandlerWithResult { + private final String apiVersion; + private final SystemHandler systemHandler; + private final ResourceAllocationHandler allocationHandler; + @Resource + protected Logger logger = Logger.NULL; + + @Inject + public SymphonyVPDCVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, SystemHandler systemHandler, + ResourceAllocationHandler allocationHandler) { + this.apiVersion = apiVersion; + this.systemHandler = systemHandler; + this.allocationHandler = allocationHandler; + } + + protected System system; + protected Set allocations = Sets.newLinkedHashSet(); + protected Status status; + protected final ListMultimap networkToAddresses = ArrayListMultimap.create(); + protected StringBuilder currentText = new StringBuilder(); + protected String operatingSystemDescription; + protected boolean inOs; + protected String networkName; + protected String name; + protected Integer osType; + protected URI location; + protected Long size; + protected ReferenceType vDC; + + public VCloudExpressVApp getResult() { + return new VCloudExpressVAppImpl(name, location, status, size, vDC, networkToAddresses, osType, + operatingSystemDescription, system, allocations); + } + + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { + Map attributes = cleanseAttributes(attrs); + if (qName.endsWith("VApp")) { + ReferenceType resource = newReferenceType(attributes); + name = resource.getName(); + location = resource.getHref(); + String statusString = attributes.get("status"); + if (apiVersion.indexOf("0.8") != -1 && "2".equals(statusString)) + status = Status.OFF; + else + status = Status.fromValue(statusString); + if (attributes.containsKey("size")) + size = new Long(attributes.get("size")); + } else if (qName.equals("Link")) { // type should never be missing + if (attributes.containsKey("type") && attributes.get("type").equals(VCloudExpressMediaType.VDC_XML)) { + vDC = newReferenceType(attributes); + } + } else if (qName.endsWith("OperatingSystemSection")) { + inOs = true; + if (attributes.containsKey("id")) + osType = Integer.parseInt(attributes.get("id")); + } else if (qName.endsWith("NetworkConnection")) { + networkName = attributes.get("Network"); + } else { + systemHandler.startElement(uri, localName, qName, attrs); + allocationHandler.startElement(uri, localName, qName, attrs); + } + + } + + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { + if (qName.endsWith("OperatingSystemSection")) { + inOs = false; + } else if (inOs && qName.endsWith("Description")) { + operatingSystemDescription = currentText.toString().trim(); + } else if (qName.endsWith("IpAddress")) { + networkToAddresses.put(networkName, currentText.toString().trim()); + } else if (qName.equals("System")) { + systemHandler.endElement(uri, localName, qName); + system = systemHandler.getResult(); + } else if (qName.equals("Item")) { + allocationHandler.endElement(uri, localName, qName); + allocations.add(allocationHandler.getResult()); + } else { + systemHandler.endElement(uri, localName, qName); + allocationHandler.endElement(uri, localName, qName); + } + currentText = new StringBuilder(); + } + + @Override + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + systemHandler.characters(ch, start, length); + allocationHandler.characters(ch, start, length); + } + +} diff --git a/sandbox-providers/savvis/src/test/java/org/jclouds/savvis/SymphonyVPDCClientLiveTest.java b/sandbox-providers/savvis/src/test/java/org/jclouds/savvis/SymphonyVPDCClientLiveTest.java index 4b5525957c..09ad7499ce 100644 --- a/sandbox-providers/savvis/src/test/java/org/jclouds/savvis/SymphonyVPDCClientLiveTest.java +++ b/sandbox-providers/savvis/src/test/java/org/jclouds/savvis/SymphonyVPDCClientLiveTest.java @@ -50,9 +50,14 @@ public class SymphonyVPDCClientLiveTest extends VCloudExpressClientLiveTest { context = new ComputeServiceContextFactory(restProperties).createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); - System.out.println(context); - connection = context.getApi(); - System.out.println(connection); + + System.out.println(context); + /*System.out.println(connection); + Org org = connection.getOrg(URI.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/607968.0")); + System.out.println(connection.getVDC(URI.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/607968.0/vdc/2826")).getAvailableNetworks()); + System.out.println(org.getVDCs().get(0)); + System.out.println(org.getTasksList()); + System.out.println(org.getTasks());*/ } } \ No newline at end of file From c5d43b88b141992a4b56d91e000b44cdc8047bf6 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 1 Mar 2011 16:45:02 -0500 Subject: [PATCH 02/10] updated version for ninefold --- sandbox-providers/ninefold-storage/pom.xml | 2 +- .../ninefold/storage/NinefoldStoragePropertiesBuilder.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sandbox-providers/ninefold-storage/pom.xml b/sandbox-providers/ninefold-storage/pom.xml index 90b9979a95..be157c21b3 100644 --- a/sandbox-providers/ninefold-storage/pom.xml +++ b/sandbox-providers/ninefold-storage/pom.xml @@ -37,7 +37,7 @@ org.jclouds.ninefold.storage.blobstore.integration.NinefoldStorageTestInitializer http://onlinestorage.ninefold.com - 1.2.7c + 1.4.0 FIXME_IDENTITY FIXME_CREDENTIAL diff --git a/sandbox-providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStoragePropertiesBuilder.java b/sandbox-providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStoragePropertiesBuilder.java index 6729925f9e..820a62baf3 100644 --- a/sandbox-providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStoragePropertiesBuilder.java +++ b/sandbox-providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStoragePropertiesBuilder.java @@ -39,7 +39,7 @@ public class NinefoldStoragePropertiesBuilder extends PropertiesBuilder { Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_ENDPOINT, "http://onlinestorage.ninefold.com"); properties.setProperty(PROPERTY_ISO3166_CODES, "AU-NSW"); - properties.setProperty(PROPERTY_API_VERSION, "1.2.7C"); + properties.setProperty(PROPERTY_API_VERSION, "1.4.0"); return properties; } From b40c8ccb1be4ef3c4ab2b9acf181bcd641ce3173 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 1 Mar 2011 16:46:30 -0500 Subject: [PATCH 03/10] expose statement being executed in runscript --- .../java/org/jclouds/compute/callables/RunScriptOnNode.java | 5 +++++ .../callables/RunScriptOnNodeAsInitScriptUsingSsh.java | 5 +++++ .../jclouds/compute/callables/RunScriptOnNodeUsingSsh.java | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNode.java b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNode.java index ebeb405b15..ab0d63c12d 100644 --- a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNode.java +++ b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNode.java @@ -50,6 +50,11 @@ public interface RunScriptOnNode extends Callable { @Override ExecResponse call(); + /** + * @return statement that will be executed + */ + Statement getStatement(); + /** * verifies that the command can execute on the node. For example, if this is ssh, it may attempt * to find a reachable socket. If this is using an API, it may attempt to validate that diff --git a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java index eca269255a..c20fbdc422 100644 --- a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java +++ b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java @@ -156,4 +156,9 @@ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode { return Objects.toStringHelper(this).add("node", node).add("name", name).add("runAsRoot", runAsRoot).toString(); } + @Override + public Statement getStatement() { + return init; + } + } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeUsingSsh.java b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeUsingSsh.java index 321b2dc792..71fc4ab7b9 100644 --- a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeUsingSsh.java +++ b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeUsingSsh.java @@ -124,4 +124,9 @@ public class RunScriptOnNodeUsingSsh implements RunScriptOnNode { .toString(); } + @Override + public Statement getStatement() { + return statement; + } + } \ No newline at end of file From 739bcc4c68735e77925b10dbfd5e19361b3cd8eb Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 3 Mar 2011 09:44:53 -0500 Subject: [PATCH 04/10] Issue 491:support new ap-northeast-1 region in aws --- .../ec2/compute/functions/EC2ImageParser.java | 2 +- .../strategy/EC2GetNodeMetadataStrategy.java | 8 +- .../jclouds/ec2/domain/AvailabilityZone.java | 49 ---------- .../ec2/options/DescribeRegionsOptions.java | 3 +- .../java/org/jclouds/ec2/util/EC2Utils.java | 83 ----------------- .../ec2/xml/CreateVolumeResponseHandler.java | 33 ++++--- .../EC2RunNodesAndAddToSetStrategyTest.java | 12 +-- ...ilabilityZoneAndRegionAsyncClientTest.java | 30 +++--- .../ec2/services/BaseEC2AsyncClientTest.java | 3 +- .../ElasticBlockStoreAsyncClientTest.java | 7 +- .../ElasticBlockStoreClientLiveTest.java | 20 ++-- .../ec2/services/InstanceAsyncClientTest.java | 4 +- .../org/jclouds/ec2/utils/EC2UtilsTest.java | 52 ----------- .../jclouds/ec2/xml/BaseEC2HandlerTest.java | 3 +- .../xml/CreateVolumeResponseHandlerTest.java | 3 +- ...eAvailabilityZonesResponseHandlerTest.java | 10 +- .../DescribeInstancesResponseHandlerTest.java | 9 +- .../DescribeVolumesResponseHandlerTest.java | 9 +- .../xml/RunInstancesResponseHandlerTest.java | 7 +- .../org/jclouds/s3/S3AsyncClientTest.java | 8 +- .../java/org/jclouds/aws/domain/Region.java | 41 +++++++- .../java/org/jclouds/aws/util/AWSUtils.java | 7 +- core/src/main/resources/rest.properties | 5 +- .../aws/ec2/AWSEC2PropertiesBuilder.java | 22 +---- .../AWSEC2TemplateBuilderLiveTest.java | 2 +- .../aws}/ec2/services/AMIClientLiveTest.java | 15 ++- .../ec2/services/AWSAMIClientLiveTest.java | 28 +++--- .../services/AWSInstanceAsyncClientTest.java | 12 +-- .../services/AWSInstanceClientLiveTest.java | 5 +- .../services/BaseAWSEC2AsyncClientTest.java | 3 +- .../PlacementGroupClientLiveTest.java | 29 +++--- ...SDescribeInstancesResponseHandlerTest.java | 9 +- .../xml/RunInstancesResponseHandlerTest.java | 7 +- .../aws/s3/AWSS3PropertiesBuilder.java | 31 ++----- .../AWSS3ServiceIntegrationLiveTest.java | 2 +- sandbox-apis/cloudwatch/pom.xml | 6 ++ .../CloudWatchPropertiesBuilder.java | 21 ++--- .../cloudwatch/CloudWatchClientLiveTest.java | 19 ++-- .../org/jclouds/elb/ELBAsyncClientTest.java | 14 ++- .../elb/ProvidersInPropertiesTest.java | 41 -------- .../org/jclouds/sqs/SQSPropertiesBuilder.java | 15 --- .../org/jclouds/sqs/SQSAsyncClientTest.java | 24 +++-- .../org/jclouds/sqs/SQSClientLiveTest.java | 87 +++++++++-------- .../sqs/config/SQSRestClientModuleTest.java | 93 ------------------- sandbox-providers/aws-elb/pom.xml | 6 ++ .../aws/elb/AWSELBPropertiesBuilder.java | 19 ++-- .../jclouds/aws/elb/AWSELBClientLiveTest.java | 7 +- .../jclouds/aws/elb/ELBAsyncClientTest.java | 12 ++- ...java => AWSSimpleDBPropertiesBuilder.java} | 26 +++--- ...t.java => AWSSimpleDBAsyncClientTest.java} | 21 +++-- .../simpledb/AWSSimpleDBClientLiveTest.java | 8 +- 51 files changed, 339 insertions(+), 653 deletions(-) delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/domain/AvailabilityZone.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/util/EC2Utils.java delete mode 100644 apis/ec2/src/test/java/org/jclouds/ec2/utils/EC2UtilsTest.java rename {apis/ec2/src/test/java/org/jclouds => providers/aws-ec2/src/test/java/org/jclouds/aws}/ec2/services/AMIClientLiveTest.java (96%) delete mode 100644 sandbox-apis/elb/src/test/java/org/jclouds/elb/ProvidersInPropertiesTest.java delete mode 100644 sandbox-apis/sqs/src/test/java/org/jclouds/sqs/config/SQSRestClientModuleTest.java rename sandbox-providers/aws-simpledb/src/main/java/org/jclouds/aws/simpledb/{SimpleDBPropertiesBuilder.java => AWSSimpleDBPropertiesBuilder.java} (66%) rename sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/{SimpleDBAsyncClientTest.java => AWSSimpleDBAsyncClientTest.java} (70%) diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java index 17670dc8bd..793283405c 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java @@ -115,7 +115,7 @@ public class EC2ImageParser implements Function getAllRunningInstancesInRegion(InstanceClient client, String region, + String id) { + return Iterables.concat(client.describeInstancesInRegion(region, id)); + } + } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/AvailabilityZone.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/AvailabilityZone.java deleted file mode 100644 index cf7245e446..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/AvailabilityZone.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * 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.ec2.domain; - -import java.util.Set; - -import com.google.common.collect.ImmutableSet; - -/** - * - * Availability zones used for all ec2 instance commands. - * - * @author Adrian Cole - */ -public class AvailabilityZone { - - public static final String EU_WEST_1A = "eu-west-1a"; - public static final String EU_WEST_1B = "eu-west-1b"; - public static final String US_EAST_1A = "us-east-1a"; - public static final String US_EAST_1B = "us-east-1b"; - public static final String US_EAST_1C = "us-east-1c"; - public static final String US_EAST_1D = "us-east-1d"; - public static final String US_WEST_1A = "us-west-1a"; - public static final String US_WEST_1B = "us-west-1b"; - public static final String AP_SOUTHEAST_1A = "ap-southeast-1a"; - public static final String AP_SOUTHEAST_1B = "ap-southeast-1b"; - - public static final Set zones = ImmutableSet.of(EU_WEST_1A, EU_WEST_1B, - US_EAST_1A, US_EAST_1B, US_EAST_1C, US_EAST_1D, - US_WEST_1A, US_WEST_1B, AP_SOUTHEAST_1A, AP_SOUTHEAST_1B); - -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java index 27aefe9ad1..cd5ff1ea9b 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java @@ -22,7 +22,6 @@ package org.jclouds.ec2.options; import java.util.Arrays; import java.util.Set; -import org.jclouds.aws.domain.Region; import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; /** @@ -61,7 +60,7 @@ public class DescribeRegionsOptions extends BaseEC2RequestOptions { public static class Builder { /** - * @see DescribeRegionsOptions#regions(Region[] ) + * @see DescribeRegionsOptions#regions(String[] ) */ public static DescribeRegionsOptions regions(String... regions) { DescribeRegionsOptions options = new DescribeRegionsOptions(); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/util/EC2Utils.java b/apis/ec2/src/main/java/org/jclouds/ec2/util/EC2Utils.java deleted file mode 100644 index 7e5c6e6117..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/util/EC2Utils.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * 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.ec2.util; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - - -import org.jclouds.aws.util.AWSUtils; -import org.jclouds.ec2.domain.AvailabilityZone; -import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.ec2.services.InstanceClient; -import org.jclouds.rest.internal.GeneratedHttpRequest; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -public class EC2Utils { - public static String[] getAvailabilityZonesForRegion(String region) { - Set availabilityZones = new HashSet(); - for (String az : AvailabilityZone.zones) { - if (az.startsWith(region)) - availabilityZones.add(az); - } - - return (String[]) availabilityZones.toArray(new String[availabilityZones.size()]); - } - - public static Iterable getAllRunningInstancesInRegion(InstanceClient client, String region, - String id) { - return Iterables.concat(client.describeInstancesInRegion(region, id)); - } - - public static String findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest gRequest) { - for (Object arg : gRequest.getArgs()) { - if (arg instanceof String) { - String zone = (String) arg; - if (AvailabilityZone.zones.contains(zone)) - return zone; - } - } - return null; - } - - private static final Pattern ELB_PATTERN = Pattern.compile("([^.]+)-[^.]+\\.([^.]+)\\.elb\\.amazonaws\\.com"); - - public static Map getLoadBalancerNameAndRegionFromDnsName(String dnsName) { - Matcher matcher = ELB_PATTERN.matcher(checkNotNull(dnsName, "dnsName")); - checkArgument(matcher.find(), "dnsName syntax is " + ELB_PATTERN + " didn't match: " + dnsName); - String loadBalancerName = matcher.group(1); - String regionName = matcher.group(2); - checkArgument((AWSUtils.isRegion(regionName)), - String.format("Region (%s) parsed from (%s) is not a valid region", regionName, dnsName)); - return ImmutableMap. of(regionName, loadBalancerName); - } -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java b/apis/ec2/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java index 30594e0ad8..ab50e5e88c 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java @@ -28,16 +28,16 @@ import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.Volume; -import org.jclouds.ec2.util.EC2Utils; import org.jclouds.aws.util.AWSUtils; import org.jclouds.date.DateService; +import org.jclouds.ec2.domain.Attachment; +import org.jclouds.ec2.domain.Volume; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.location.Region; import org.jclouds.location.Zone; import org.jclouds.logging.Logger; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.xml.sax.Attributes; import com.google.common.collect.Sets; @@ -46,8 +46,7 @@ import com.google.common.collect.Sets; * * @author Adrian Cole */ -public class CreateVolumeResponseHandler extends - ParseSax.HandlerForGeneratedRequestWithResult { +public class CreateVolumeResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult { private StringBuilder currentText = new StringBuilder(); @Resource @@ -128,8 +127,7 @@ public class CreateVolumeResponseHandler extends attachTime = dateService.iso8601DateParse(currentText.toString().trim()); } else if (qName.equals("item")) { if (inAttachmentSet) { - attachments.add(new Attachment(region, volumeId, instanceId, device, attachmentStatus, - attachTime)); + attachments.add(new Attachment(region, volumeId, instanceId, device, attachmentStatus, attachTime)); volumeId = null; instanceId = null; device = null; @@ -142,8 +140,7 @@ public class CreateVolumeResponseHandler extends } private Volume newVolume() { - Volume volume = new Volume(region, id, size, snapshotId, availabilityZone, volumeStatus, - createTime, attachments); + Volume volume = new Volume(region, id, size, snapshotId, availabilityZone, volumeStatus, createTime, attachments); id = null; size = 0; snapshotId = null; @@ -163,14 +160,26 @@ public class CreateVolumeResponseHandler extends super.setContext(request); region = AWSUtils.findRegionInArgsOrNull(getRequest()); if (region == null) { - String zone = EC2Utils.findAvailabilityZoneInArgsOrNull(getRequest()); + String zone = findAvailabilityZoneInArgsOrNull(getRequest(), availabilityZoneToRegion.keySet()); if (zone != null) { - region = checkNotNull(availabilityZoneToRegion.get(zone), String.format( - "zone %s not in %s", zone, availabilityZoneToRegion)); + region = checkNotNull(availabilityZoneToRegion.get(zone), + String.format("zone %s not in %s", zone, availabilityZoneToRegion)); } else { region = defaultRegion; } } return this; } + + public static String findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest gRequest, Set zones) { + for (Object arg : gRequest.getArgs()) { + if (arg instanceof String) { + String zone = (String) arg; + if (zones.contains(zone)) + return zone; + } + } + return null; + } + } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategyTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategyTest.java index 605a6660fe..568a2b4978 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategyTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategyTest.java @@ -30,7 +30,6 @@ import java.util.Map; import java.util.Set; import org.easymock.IArgumentMatcher; -import org.jclouds.aws.domain.Region; import org.jclouds.compute.config.CustomizationResponse; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; @@ -44,7 +43,6 @@ import org.jclouds.domain.LocationScope; import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata; import org.jclouds.ec2.compute.options.EC2TemplateOptions; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.options.RunInstancesOptions; @@ -65,12 +63,12 @@ public class EC2RunNodesAndAddToSetStrategyTest { @Test public void testZoneAsALocation() { - assertRegionAndZoneForLocation(ZONE_AP_SOUTHEAST_1A, Region.AP_SOUTHEAST_1, AvailabilityZone.AP_SOUTHEAST_1A); + assertRegionAndZoneForLocation(ZONE_AP_SOUTHEAST_1A, "ap-southeast-1", "ap-southeast-1a"); } @Test public void testRegionAsALocation() { - assertRegionAndZoneForLocation(REGION_AP_SOUTHEAST_1, Region.AP_SOUTHEAST_1, null); + assertRegionAndZoneForLocation(REGION_AP_SOUTHEAST_1, "ap-southeast-1", null); } // // fixtures @@ -155,10 +153,10 @@ public class EC2RunNodesAndAddToSetStrategyTest { } private static final Location REGION_AP_SOUTHEAST_1 = new LocationBuilder().scope(LocationScope.REGION).id( - Region.AP_SOUTHEAST_1).description(Region.AP_SOUTHEAST_1).parent( - new LocationBuilder().scope(LocationScope.PROVIDER).id("ec2").description("ec2").build()).build(); + "ap-southeast-1").description("ap-southeast-1").parent( + new LocationBuilder().scope(LocationScope.PROVIDER).id("aws-ec2").description("aws-ec2").build()).build(); private static final Location ZONE_AP_SOUTHEAST_1A = new LocationBuilder().scope(LocationScope.ZONE).id( - AvailabilityZone.AP_SOUTHEAST_1A).description(AvailabilityZone.AP_SOUTHEAST_1A).parent( + "ap-southeast-1a").description("ap-southeast-1a").parent( REGION_AP_SOUTHEAST_1).build(); // ///////////////////////////////////////////////////////////////////// diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java index f6f3326fb6..b09dc655d9 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java @@ -27,7 +27,6 @@ import java.lang.reflect.Array; import java.lang.reflect.Method; import org.jclouds.aws.domain.Region; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions; import org.jclouds.ec2.options.DescribeRegionsOptions; import org.jclouds.ec2.xml.DescribeAvailabilityZonesResponseHandler; @@ -48,17 +47,17 @@ import com.google.inject.TypeLiteral; // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "AvailabilityZoneAndRegionAsyncClientTest") public class AvailabilityZoneAndRegionAsyncClientTest extends - BaseEC2AsyncClientTest { + BaseEC2AsyncClientTest { public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException, IOException { Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion", - String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass()); + String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass()); HttpRequest request = processor.createRequest(method, Region.US_WEST_1); assertRequestLineEquals(request, "POST https://ec2.us-west-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-west-1.amazonaws.com\n"); assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeAvailabilityZones", - "application/x-www-form-urlencoded", false); + "application/x-www-form-urlencoded", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, DescribeAvailabilityZonesResponseHandler.class); @@ -69,15 +68,14 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends public void testDescribeAvailabilityZonesOptions() throws SecurityException, NoSuchMethodException, IOException { Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion", - String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass()); - HttpRequest request = processor.createRequest(method, Region.US_EAST_1, availabilityZones( - AvailabilityZone.US_EAST_1A, AvailabilityZone.US_EAST_1B)); + String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass()); + HttpRequest request = processor.createRequest(method, "us-east-1", availabilityZones("us-east-1a", "us-east-1b")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); assertPayloadEquals(request, - "Version=2010-06-15&Action=DescribeAvailabilityZones&ZoneName.1=us-east-1a&ZoneName.2=us-east-1b", - "application/x-www-form-urlencoded", false); + "Version=2010-06-15&Action=DescribeAvailabilityZones&ZoneName.1=us-east-1a&ZoneName.2=us-east-1b", + "application/x-www-form-urlencoded", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, DescribeAvailabilityZonesResponseHandler.class); @@ -87,14 +85,14 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends } public void testDescribeRegions() throws SecurityException, NoSuchMethodException, IOException { - Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", Array.newInstance( - DescribeRegionsOptions.class, 0).getClass()); + Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", + Array.newInstance(DescribeRegionsOptions.class, 0).getClass()); HttpRequest request = processor.createRequest(method); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeRegions", "application/x-www-form-urlencoded", - false); + false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, DescribeRegionsResponseHandler.class); @@ -104,15 +102,15 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends } public void testDescribeRegionsOptions() throws SecurityException, NoSuchMethodException, IOException { - Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", Array.newInstance( - DescribeRegionsOptions.class, 0).getClass()); + Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", + Array.newInstance(DescribeRegionsOptions.class, 0).getClass()); HttpRequest request = processor.createRequest(method, regions(Region.US_EAST_1, Region.US_WEST_1)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); assertPayloadEquals(request, - "Version=2010-06-15&Action=DescribeRegions&RegionName.1=us-east-1&RegionName.2=us-west-1", - "application/x-www-form-urlencoded", false); + "Version=2010-06-15&Action=DescribeRegions&RegionName.1=us-east-1&RegionName.2=us-west-1", + "application/x-www-form-urlencoded", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, DescribeRegionsResponseHandler.class); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java index 76fce4f473..d7ed36b608 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java @@ -34,7 +34,6 @@ import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.EC2ContextBuilder; import org.jclouds.ec2.EC2PropertiesBuilder; import org.jclouds.ec2.config.EC2RestClientModule; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; @@ -85,7 +84,7 @@ public abstract class BaseEC2AsyncClientTest extends RestClientTest { static class Zones implements javax.inject.Provider> { @Override public Map get() { - return ImmutableMap. of(AvailabilityZone.US_EAST_1A, Region.US_EAST_1); + return ImmutableMap. of("us-east-1a", "us-east-1"); } } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java index 739ac43055..cce049ae77 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.lang.reflect.Array; import java.lang.reflect.Method; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.ec2.functions.ReturnVoidOnVolumeAvailable; import org.jclouds.ec2.options.CreateSnapshotOptions; import org.jclouds.ec2.options.DescribeSnapshotsOptions; @@ -59,7 +58,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest allResults = Sets.newTreeSet(client.describeVolumesInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { @@ -120,10 +118,10 @@ public class ElasticBlockStoreClientLiveTest { @Test void testCreateVolumeInAvailabilityZone() { - Volume expected = client.createVolumeInAvailabilityZone(AvailabilityZone.US_EAST_1B, 1); + Volume expected = client.createVolumeInAvailabilityZone(getDefaultAvailabilityZone(), 1); assertNotNull(expected); System.out.println(expected); - assertEquals(expected.getAvailabilityZone(), AvailabilityZone.US_EAST_1B); + assertEquals(expected.getAvailabilityZone(), getDefaultAvailabilityZone()); this.volumeId = expected.getId(); @@ -148,9 +146,13 @@ public class ElasticBlockStoreClientLiveTest { this.snapshot = result; } + protected String getDefaultAvailabilityZone(){ + return "us-east-1a"; + } + @Test(dependsOnMethods = "testCreateSnapshotInRegion") void testCreateVolumeFromSnapshotInAvailabilityZone() { - Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone.US_EAST_1A, snapshot.getId()); + Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(getDefaultAvailabilityZone(), snapshot.getId()); assertNotNull(volume); Predicate availabile = new RetryablePredicate(new VolumeAvailable(client), 600, 10, @@ -160,7 +162,7 @@ public class ElasticBlockStoreClientLiveTest { Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId())); assertEquals(volume.getId(), result.getId()); assertEquals(volume.getSnapshotId(), snapshot.getId()); - assertEquals(volume.getAvailabilityZone(), AvailabilityZone.US_EAST_1A); + assertEquals(volume.getAvailabilityZone(), getDefaultAvailabilityZone()); assertEquals(result.getStatus(), Volume.Status.AVAILABLE); client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId()); @@ -168,7 +170,7 @@ public class ElasticBlockStoreClientLiveTest { @Test(dependsOnMethods = "testCreateSnapshotInRegion") void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() { - Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(AvailabilityZone.US_EAST_1B, 2, + Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(getDefaultAvailabilityZone(), 2, snapshot.getId()); assertNotNull(volume); @@ -179,7 +181,7 @@ public class ElasticBlockStoreClientLiveTest { Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId())); assertEquals(volume.getId(), result.getId()); assertEquals(volume.getSnapshotId(), snapshot.getId()); - assertEquals(volume.getAvailabilityZone(), AvailabilityZone.US_EAST_1B); + assertEquals(volume.getAvailabilityZone(), getDefaultAvailabilityZone()); assertEquals(volume.getSize(), 2); assertEquals(result.getStatus(), Volume.Status.AVAILABLE); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java index 3088a7ffd7..67d3c7b4a2 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java @@ -24,8 +24,6 @@ import java.lang.reflect.Array; import java.lang.reflect.Method; import java.util.Map; -import org.jclouds.aws.domain.Region; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior; @@ -131,7 +129,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest - * - * ==================================================================== - * 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.ec2.utils; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.ec2.util.EC2Utils; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit") -public class EC2UtilsTest { - - public void testGetLoadBalancerNameAndRegionFromDnsName() { - assertEquals( - ImmutableMap. of("us-east-1", "my-load-balancer"), - EC2Utils - .getLoadBalancerNameAndRegionFromDnsName("my-load-balancer-1277832914.us-east-1.elb.amazonaws.com")); - assertEquals( - ImmutableMap. of("us-east-1", "ec2lb"), - EC2Utils - .getLoadBalancerNameAndRegionFromDnsName("ec2lb-915583419.us-east-1.elb.amazonaws.com")); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetLoadBalancerNameAndRegionFromDnsNameFail() { - EC2Utils - .getLoadBalancerNameAndRegionFromDnsName("my-load-balancer-1277832914.us-east-1.microsoft.com"); - } - -} diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java index 18d9c95bba..2b1c7d0f7e 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java @@ -24,7 +24,6 @@ import java.util.Map; import javax.inject.Singleton; import org.jclouds.aws.domain.Region; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; @@ -68,7 +67,7 @@ public abstract class BaseEC2HandlerTest extends BaseHandlerTest { @Provides @Zone Map provideAvailabilityZoneRegionMap() { - return ImmutableMap. of(AvailabilityZone.US_EAST_1A, Region.US_EAST_1); + return ImmutableMap. of("us-east-1a", "us-east-1"); } }); factory = injector.getInstance(ParseSax.Factory.class); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java index 633ddb1071..a27064c496 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java @@ -29,7 +29,6 @@ import java.io.InputStream; import org.jclouds.aws.domain.Region; import org.jclouds.date.DateService; import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.ec2.domain.Volume; import org.jclouds.http.functions.ParseSax; import org.jclouds.rest.internal.GeneratedHttpRequest; @@ -52,7 +51,7 @@ public class CreateVolumeResponseHandlerTest extends BaseEC2HandlerTest { InputStream is = getClass().getResourceAsStream("/created_volume.xml"); Volume expected = new Volume(Region.US_EAST_1, "vol-2a21e543", 1, null, - AvailabilityZone.US_EAST_1A, Volume.Status.CREATING, dateService + "us-east-1a", Volume.Status.CREATING, dateService .iso8601DateParse("2009-12-28T05:42:53.000Z"), Sets . newLinkedHashSet()); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java index 40e2ce34bb..3223c0aab2 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java @@ -24,8 +24,6 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.util.Set; -import org.jclouds.aws.domain.Region; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.ec2.domain.AvailabilityZoneInfo; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; @@ -66,14 +64,14 @@ public class DescribeAvailabilityZonesResponseHandlerTest extends BaseHandlerTes Set expected = ImmutableSet. of( - new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1A, "available", Region.US_EAST_1, ImmutableSet. of()), - new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1B, "available", Region.US_EAST_1, ImmutableSet + new AvailabilityZoneInfo("us-east-1a", "available", "us-east-1", ImmutableSet. of()), + new AvailabilityZoneInfo("us-east-1b", "available", "us-east-1", ImmutableSet . of()), - new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1C, "available", Region.US_EAST_1, ImmutableSet + new AvailabilityZoneInfo("us-east-1c", "available", "us-east-1", ImmutableSet . of("our service is awesome")), - new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1D, "downlikeaclown", Region.US_EAST_1, ImmutableSet + new AvailabilityZoneInfo("us-east-1d", "downlikeaclown", "us-east-1", ImmutableSet . of())); Set result = factory.create( injector.getInstance(DescribeAvailabilityZonesResponseHandler.class)).parse(is); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java index cba5d6dd23..a8c15847a4 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java @@ -27,7 +27,6 @@ import java.util.Set; import org.jclouds.date.DateService; import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceType; @@ -74,7 +73,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest { "174.129.81.68").kernelId("aki-a71cf9ce").keyName("adriancole.ec21").launchTime( dateService.iso8601DateParse("2009-11-09T03:00:34.000Z")) // MonitoringState.DISABLED, - .availabilityZone(AvailabilityZone.US_EAST_1C).virtualizationType("paravirtual") + .availabilityZone("us-east-1c").virtualizationType("paravirtual") .privateDnsName("ip-10-243-42-70.ec2.internal").privateIpAddress("10.243.42.70").ramdiskId( "ari-a51cf9cc").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()), "993194456877", null, "r-a3c508cb")); @@ -92,7 +91,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest { InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name").launchTime( dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")) // MonitoringState.DISABLED, - .availabilityZone(AvailabilityZone.US_EAST_1B).virtualizationType("paravirtual") + .availabilityZone("us-east-1b").virtualizationType("paravirtual") .privateDnsName("10-251-50-132.ec2.internal")// product codes // ImmutableSet.of("774F4FF8") .ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build(), @@ -102,7 +101,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest { InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name") .launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")) // MonitoringState.DISABLED, - .availabilityZone(AvailabilityZone.US_EAST_1B).virtualizationType("paravirtual") + .availabilityZone("us-east-1b").virtualizationType("paravirtual") .privateDnsName("10-251-50-134.ec2.internal")// product codes // ImmutableSet.of("774F4FF8") .ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()), @@ -124,7 +123,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest { .keyName("adriancole.ec2ebs1") .launchTime(dateService.iso8601DateParse("2009-12-30T04:06:23.000Z")) // MonitoringState.DISABLED - .availabilityZone(AvailabilityZone.US_EAST_1B) + .availabilityZone("us-east-1b") // "placement" .virtualizationType("hvm").privateDnsName("domU-12-31-39-09-CE-53.compute-1.internal") .privateIpAddress("10.210.209.157").ramdiskId("ari-a51cf9cc") diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java index 9d0cfc0963..02bec1b7b4 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java @@ -27,10 +27,9 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.util.Set; -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.AvailabilityZone; -import org.jclouds.ec2.domain.Volume; import org.jclouds.date.DateService; +import org.jclouds.ec2.domain.Attachment; +import org.jclouds.ec2.domain.Volume; import org.jclouds.http.functions.ParseSax; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; @@ -52,11 +51,11 @@ public class DescribeVolumesResponseHandlerTest extends BaseEC2HandlerTest { InputStream is = getClass().getResourceAsStream("/describe_volumes.xml"); Set expected = Sets.newLinkedHashSet(); - expected.add(new Volume(defaultRegion, "vol-2a21e543", 1, null, AvailabilityZone.US_EAST_1A, + expected.add(new Volume(defaultRegion, "vol-2a21e543", 1, null, "us-east-1a", Volume.Status.AVAILABLE, dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"), Sets. newLinkedHashSet())); expected.add(new Volume(defaultRegion, "vol-4282672b", 800, "snap-536d1b3a", - AvailabilityZone.US_EAST_1A, Volume.Status.IN_USE, dateService + "us-east-1a", Volume.Status.IN_USE, dateService .iso8601DateParse("2008-05-07T11:51:50.000Z"), Sets . newHashSet(new Attachment(defaultRegion, "vol-4282672b", "i-6058a509", "/dev/sdh", Attachment.Status.ATTACHED, dateService diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java index a35063aaf5..3e86390ef3 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java @@ -27,7 +27,6 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.Reservation; @@ -70,19 +69,19 @@ public class RunInstancesResponseHandlerTest extends BaseEC2HandlerTest { .imageId("ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).instanceType( InstanceType.M1_SMALL).keyName("example-key-name").launchTime( dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED, - .availabilityZone(AvailabilityZone.US_EAST_1B).build(), + .availabilityZone("us-east-1b").build(), new RunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1") .imageId("ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType( InstanceType.M1_SMALL).keyName("example-key-name").launchTime( dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED, - .availabilityZone(AvailabilityZone.US_EAST_1B).build(), + .availabilityZone("us-east-1b").build(), new RunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2") .imageId("ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType( InstanceType.M1_SMALL).keyName("example-key-name").launchTime( dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED, - .availabilityZone(AvailabilityZone.US_EAST_1B).build()) + .availabilityZone("us-east-1b").build()) , "AIDADH4IGTRXXKCD", null, "r-47a5402e"); diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java index 7a1d0b15d4..38cd214bc6 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java @@ -44,13 +44,13 @@ import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.s3.config.S3RestClientModule; import org.jclouds.s3.domain.AccessControlList; +import org.jclouds.s3.domain.AccessControlList.EmailAddressGrantee; +import org.jclouds.s3.domain.AccessControlList.Grant; +import org.jclouds.s3.domain.AccessControlList.Permission; import org.jclouds.s3.domain.BucketLogging; import org.jclouds.s3.domain.CannedAccessPolicy; import org.jclouds.s3.domain.Payer; import org.jclouds.s3.domain.S3Object; -import org.jclouds.s3.domain.AccessControlList.EmailAddressGrantee; -import org.jclouds.s3.domain.AccessControlList.Grant; -import org.jclouds.s3.domain.AccessControlList.Permission; import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent; import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders; import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState; @@ -87,7 +87,7 @@ public abstract class S3AsyncClientTest extends BaseS3A public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException { Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, Array.newInstance( PutBucketOptions.class, 0).getClass()); - for (String region : Region.ALL_S3) { + for (String region : Region.DEFAULT_S3) { processor.createRequest(method, region, "bucket-name"); } } diff --git a/common/aws/src/main/java/org/jclouds/aws/domain/Region.java b/common/aws/src/main/java/org/jclouds/aws/domain/Region.java index d28b2d57f3..d0a390fd10 100644 --- a/common/aws/src/main/java/org/jclouds/aws/domain/Region.java +++ b/common/aws/src/main/java/org/jclouds/aws/domain/Region.java @@ -19,8 +19,15 @@ package org.jclouds.aws.domain; +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; +import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + +import java.util.Properties; import java.util.Set; +import com.google.common.base.Joiner; import com.google.common.collect.ImmutableSet; /** @@ -84,6 +91,36 @@ public class Region { */ public static final String AP_SOUTHEAST_1 = "ap-southeast-1"; - public static Set ALL_S3 = ImmutableSet.of(EU, US_STANDARD, US_WEST_1, AP_SOUTHEAST_1); - public static Set ALL_SQS = ImmutableSet.of(EU_WEST_1, US_STANDARD, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1); + /** + * Region in Tokyo, launched March 2, 2011. This region improves latency for Asia-based users + */ + public static final String AP_NORTHEAST_1 = "ap-northeast-1"; + + public static Set DEFAULT_S3 = ImmutableSet.of(EU, US_STANDARD, US_WEST_1, AP_SOUTHEAST_1, AP_NORTHEAST_1); + + public static Set DEFAULT_REGIONS = ImmutableSet.of(US_EAST_1, US_WEST_1, EU_WEST_1, AP_SOUTHEAST_1, + AP_NORTHEAST_1); + + public static Properties regionPropertiesS3() { + + Properties properties = regionProperties(); + properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_S3)); + // note that due to US_STANDARD the codes include US instead of US-VA + properties.setProperty(PROPERTY_ISO3166_CODES, "US,US-CA,IE,SG,JP-13"); + properties.setProperty(PROPERTY_REGION + "." + US_STANDARD + "." + ISO3166_CODES, "US"); + properties.setProperty(PROPERTY_REGION + "." + EU + "." + ISO3166_CODES, "IE"); + return properties; + } + + public static Properties regionProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS)); + properties.setProperty(PROPERTY_ISO3166_CODES, "US-VA,US-CA,IE,SG,JP-13"); + properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + "." + ISO3166_CODES, "US-VA"); + properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ISO3166_CODES, "US-CA"); + properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + "." + ISO3166_CODES, "IE"); + properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + "." + ISO3166_CODES, "SG"); + properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + "." + ISO3166_CODES, "JP-13"); + return properties; + } } \ No newline at end of file diff --git a/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java b/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java index 0ce230422e..f356bfb914 100644 --- a/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java +++ b/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java @@ -117,10 +117,9 @@ public class AWSUtils { return forms.size() == 0 ? request : ModifyRequest.putFormParams(request, forms); } + // TODO: make this more dynamic public static boolean isRegion(String regionName) { - return Region.EU_WEST_1.equals(regionName) || Region.US_WEST_1.equals(regionName) - || Region.US_EAST_1.equals(regionName) || Region.US_STANDARD.equals(regionName) - || Region.AP_SOUTHEAST_1.equals(regionName); + return Region.DEFAULT_REGIONS.contains(regionName); } public static R indexIterableToFormValuesWithPrefix(R request, String prefix, Object input) { @@ -162,7 +161,7 @@ public class AWSUtils { for (Object arg : gRequest.getArgs()) { if (arg instanceof String) { String regionName = (String) arg; - //TODO regions may not be amazon regions! + // TODO regions may not be amazon regions! // take from a configured value if (isRegion(regionName)) return regionName; diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties index eeeb84c7d6..519bd5c804 100644 --- a/core/src/main/resources/rest.properties +++ b/core/src/main/resources/rest.properties @@ -36,7 +36,10 @@ sdn.contextbuilder=org.jclouds.nirvanix.sdn.SDNContextBuilder sdn.propertiesbuilder=org.jclouds.nirvanix.sdn.SDNPropertiesBuilder aws-simpledb.contextbuilder=org.jclouds.simpledb.SimpleDBContextBuilder -aws-simpledb.propertiesbuilder=org.jclouds.aws.simpledb.SimpleDBPropertiesBuilder +aws-simpledb.propertiesbuilder=org.jclouds.aws.simpledb.AWSSimpleDBPropertiesBuilder + +aws-sqs.contextbuilder=org.jclouds.sqs.SQSContextBuilder +aws-sqs.propertiesbuilder=org.jclouds.aws.sqs.AWSSQSPropertiesBuilder aws-elb.contextbuilder=org.jclouds.elb.ELBContextBuilder aws-elb.propertiesbuilder=org.jclouds.aws.elb.AWSELBPropertiesBuilder diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilder.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilder.java index 720f854437..b4eda29b12 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilder.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilder.java @@ -20,23 +20,13 @@ package org.jclouds.aws.ec2; import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; -import static org.jclouds.aws.domain.Region.EU_WEST_1; -import static org.jclouds.aws.domain.Region.US_EAST_1; -import static org.jclouds.aws.domain.Region.US_WEST_1; import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMIs; import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_SUSPENDED; import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; -import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; -import java.util.Set; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableSet; +import org.jclouds.aws.domain.Region; /** * Builds properties used in EC2 Clients @@ -44,17 +34,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilder { - public static Set DEFAULT_REGIONS = ImmutableSet.of(US_EAST_1, US_WEST_1, EU_WEST_1, AP_SOUTHEAST_1); - @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-VA,US-CA,IE,SG"); - properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + "." + ISO3166_CODES, "US-VA"); - properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ISO3166_CODES, "US-CA"); - properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + "." + ISO3166_CODES, "IE"); - properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + "." + ISO3166_CODES, "SG"); - // sometimes, like in ec2, stop takes a very long time, perhaps // due to volume management. one example spent 2 minutes moving // from stopping->stopped state on an ec2 micro @@ -65,7 +47,7 @@ public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilde properties.setProperty("jclouds.ssh.retryable_messages", "Auth fail,invalid data,End of IO Stream Read,Connection reset,socket is not established,connection is closed by foreign host,socket is not established"); properties.setProperty(PROPERTY_ENDPOINT, "https://ec2.us-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS)); + properties.putAll(Region.regionProperties()); // amazon, alestic, canonical, and rightscale properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "137112412989,063491364108,099720109477,411009282317"); // amis that work with the cluster instances diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index a67ffedbb5..1aebbc681b 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -209,7 +209,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { @Override protected Set getIso3166Codes() { - return ImmutableSet. of("US-VA", "US-CA", "IE", "SG"); + return ImmutableSet. of("US-VA", "US-CA", "IE", "SG", "JP-13"); } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java similarity index 96% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/AMIClientLiveTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java index 7e6a7208a8..c6081b6cad 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.ec2.services; +package org.jclouds.aws.ec2.services; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.imageIds; @@ -31,14 +31,13 @@ import java.util.Properties; import java.util.Set; import org.jclouds.Constants; -import org.jclouds.aws.AWSResponseException; -import org.jclouds.aws.domain.Region; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.domain.RootDeviceType; import org.jclouds.ec2.domain.Image.ImageType; +import org.jclouds.ec2.domain.RootDeviceType; +import org.jclouds.ec2.services.AMIClient; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; import org.testng.annotations.AfterTest; @@ -49,7 +48,6 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.inject.Module; @@ -69,7 +67,7 @@ public class AMIClientLiveTest { private Set imagesToDeregister = Sets.newHashSet(); - protected String provider = "ec2"; + protected String provider = "aws-ec2"; protected String identity; protected String credential; protected String endpoint; @@ -110,14 +108,13 @@ public class AMIClientLiveTest { assertEquals(client.describeImagesInRegion(null, imageIds("ami-cdf819a3")).size(), 0); } - @Test(expectedExceptions = AWSResponseException.class) + @Test(expectedExceptions = IllegalArgumentException.class) public void testDescribeImageBadId() { client.describeImagesInRegion(null, imageIds("asdaasdsa")); } public void testDescribeImages() { - for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, - Region.AP_SOUTHEAST_1)) { + for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { Set allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region)); assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java index 93670a523a..7f384fddc6 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java @@ -31,13 +31,12 @@ import java.util.Properties; import java.util.Set; import org.jclouds.Constants; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.AWSEC2AsyncClient; import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.domain.RootDeviceType; import org.jclouds.ec2.domain.Image.ImageType; +import org.jclouds.ec2.domain.RootDeviceType; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.RestContext; @@ -49,7 +48,6 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.inject.Module; @@ -102,7 +100,7 @@ public class AWSAMIClientLiveTest { setupCredentials(); Properties overrides = setupProperties(); context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); + ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); client = context.getApi().getAMIServices(); } @@ -116,8 +114,7 @@ public class AWSAMIClientLiveTest { } public void testDescribeImages() { - for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, - Region.AP_SOUTHEAST_1)) { + for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { Set allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region)); assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); @@ -138,7 +135,7 @@ public class AWSAMIClientLiveTest { String imageRegisteredId = client.registerImageFromManifestInRegion(null, "jcloudstest1", DEFAULT_MANIFEST); imagesToDeregister.add(imageRegisteredId); Image imageRegisteredFromManifest = Iterables.getOnlyElement(client.describeImagesInRegion(null, - imageIds(imageRegisteredId))); + imageIds(imageRegisteredId))); assertEquals(imageRegisteredFromManifest.getName(), "jcloudstest1"); assertEquals(imageRegisteredFromManifest.getImageLocation(), DEFAULT_MANIFEST); assertEquals(imageRegisteredFromManifest.getImageType(), ImageType.MACHINE); @@ -149,10 +146,10 @@ public class AWSAMIClientLiveTest { @Test(enabled = false) public void testRegisterImageFromManifestOptions() { String imageRegisteredWithOptionsId = client.registerImageFromManifestInRegion(null, "jcloudstest2", - DEFAULT_MANIFEST, withDescription("adrian")); + DEFAULT_MANIFEST, withDescription("adrian")); imagesToDeregister.add(imageRegisteredWithOptionsId); Image imageRegisteredFromManifestWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null, - imageIds(imageRegisteredWithOptionsId))); + imageIds(imageRegisteredWithOptionsId))); assertEquals(imageRegisteredFromManifestWithOptions.getName(), "jcloudstest2"); assertEquals(imageRegisteredFromManifestWithOptions.getImageLocation(), DEFAULT_MANIFEST); assertEquals(imageRegisteredFromManifestWithOptions.getImageType(), ImageType.MACHINE); @@ -167,7 +164,7 @@ public class AWSAMIClientLiveTest { String imageRegisteredId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest1", DEFAULT_MANIFEST); imagesToDeregister.add(imageRegisteredId); Image imageRegistered = Iterables - .getOnlyElement(client.describeImagesInRegion(null, imageIds(imageRegisteredId))); + .getOnlyElement(client.describeImagesInRegion(null, imageIds(imageRegisteredId))); assertEquals(imageRegistered.getName(), "jcloudstest1"); assertEquals(imageRegistered.getImageType(), ImageType.MACHINE); assertEquals(imageRegistered.getRootDeviceType(), RootDeviceType.EBS); @@ -178,18 +175,19 @@ public class AWSAMIClientLiveTest { // awaiting EBS functionality to be added to jclouds public void testRegisterImageBackedByEBSOptions() { String imageRegisteredWithOptionsId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest2", - DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian")); + DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian")); imagesToDeregister.add(imageRegisteredWithOptionsId); Image imageRegisteredWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null, - imageIds(imageRegisteredWithOptionsId))); + imageIds(imageRegisteredWithOptionsId))); assertEquals(imageRegisteredWithOptions.getName(), "jcloudstest2"); assertEquals(imageRegisteredWithOptions.getImageType(), ImageType.MACHINE); assertEquals(imageRegisteredWithOptions.getRootDeviceType(), RootDeviceType.EBS); assertEquals(imageRegisteredWithOptions.getRootDeviceName(), "/dev/sda1"); assertEquals(imageRegisteredWithOptions.getDescription(), "adrian"); - assertEquals(imageRegisteredWithOptions.getEbsBlockDevices().entrySet(), ImmutableMap.of("/dev/sda1", - new Image.EbsBlockDevice("/dev/sda1", 30, true), "/dev/sda2", - new Image.EbsBlockDevice("/dev/sda2", 1, true)).entrySet()); + assertEquals( + imageRegisteredWithOptions.getEbsBlockDevices().entrySet(), + ImmutableMap.of("/dev/sda1", new Image.EbsBlockDevice("/dev/sda1", 30, true), "/dev/sda2", + new Image.EbsBlockDevice("/dev/sda2", 1, true)).entrySet()); } @Test(enabled = false) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java index 6ba5b680a7..fcc2141ded 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java @@ -24,11 +24,9 @@ import java.lang.reflect.Array; import java.lang.reflect.Method; import java.util.Map; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.options.AWSRunInstancesOptions; import org.jclouds.aws.ec2.xml.AWSDescribeInstancesResponseHandler; import org.jclouds.aws.ec2.xml.AWSRunInstancesResponseHandler; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior; @@ -132,22 +130,22 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest> allResults = client.describeInstancesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 0 : allResults.size(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java index d661123576..731c5c32f5 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java @@ -11,7 +11,6 @@ import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.config.AWSEC2RestClientModule; import org.jclouds.aws.filters.FormSigner; import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; @@ -59,7 +58,7 @@ public abstract class BaseAWSEC2AsyncClientTest extends RestClientTest { static class Zones implements javax.inject.Provider> { @Override public Map get() { - return ImmutableMap. of(AvailabilityZone.US_EAST_1A, Region.US_EAST_1); + return ImmutableMap. of("us-east-1a", "us-east-1"); } } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java index c735d8750f..077e0e2fd6 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java @@ -112,14 +112,14 @@ public class PlacementGroupClientLiveTest { public void setupClient() throws FileNotFoundException, IOException { setupCredentials(); Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new JschSshClientModule()), overrides); + context = new ComputeServiceContextFactory().createContext(provider, + ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides); keyPair = setupKeyPair(); client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()); availableTester = new RetryablePredicate(new PlacementGroupAvailable(client), 60, 1, - TimeUnit.SECONDS); + TimeUnit.SECONDS); deletedTester = new RetryablePredicate(new PlacementGroupDeleted(client), 60, 1, TimeUnit.SECONDS); } @@ -128,24 +128,25 @@ public class PlacementGroupClientLiveTest { void testDescribe() { for (String region : newArrayList(Region.US_EAST_1)) { SortedSet allResults = newTreeSet(client.getPlacementGroupServices() - .describePlacementGroupsInRegion(region)); + .describePlacementGroupsInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { PlacementGroup group = allResults.last(); SortedSet result = newTreeSet(client.getPlacementGroupServices() - .describePlacementGroupsInRegion(region, group.getName())); + .describePlacementGroupsInRegion(region, group.getName())); assertNotNull(result); PlacementGroup compare = result.last(); assertEquals(compare, group); } } - for (String region : newArrayList(Region.EU_WEST_1, Region.US_WEST_1, Region.AP_SOUTHEAST_1)) { - try { - client.getPlacementGroupServices().describePlacementGroupsInRegion(region); - assert false : "should be unsupported"; - } catch (UnsupportedOperationException e) { - } + for (String region : client.getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + if (!region.equals(Region.US_EAST_1)) + try { + client.getPlacementGroupServices().describePlacementGroupsInRegion(region); + assert false : "should be unsupported"; + } catch (UnsupportedOperationException e) { + } } } @@ -161,7 +162,7 @@ public class PlacementGroupClientLiveTest { private void verifyPlacementGroup(String groupName) { assert availableTester.apply(new PlacementGroup(Region.US_EAST_1, groupName, "cluster", State.PENDING)) : group; Set oneResult = client.getPlacementGroupServices().describePlacementGroupsInRegion(null, - groupName); + groupName); assertNotNull(oneResult); assertEquals(oneResult.size(), 1); group = oneResult.iterator().next(); @@ -197,7 +198,7 @@ public class PlacementGroupClientLiveTest { assertEquals(template.getImage().getId(), "us-east-1/ami-7ea24a17"); template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public")) - .runScript(buildScript(template.getImage().getOperatingSystem())); + .runScript(buildScript(template.getImage().getOperatingSystem())); String group = PREFIX + "cccluster"; context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); @@ -209,7 +210,7 @@ public class PlacementGroupClientLiveTest { NodeMetadata node = getOnlyElement(nodes); getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(null, - node.getProviderId()))); + node.getProviderId()))); } catch (RunNodesException e) { System.err.println(e.getNodeErrors().keySet()); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java index ff2099e669..80cf0d64ce 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java @@ -29,7 +29,6 @@ import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.MonitoringState; import org.jclouds.date.DateService; import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceType; @@ -77,7 +76,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest .instanceType(InstanceType.M1_SMALL).ipAddress("174.129.81.68").kernelId( "aki-a71cf9ce").keyName("adriancole.ec21").launchTime( dateService.iso8601DateParse("2009-11-09T03:00:34.000Z")).monitoringState( - MonitoringState.DISABLED).availabilityZone(AvailabilityZone.US_EAST_1C) + MonitoringState.DISABLED).availabilityZone("us-east-1c") .virtualizationType("paravirtual").privateDnsName("ip-10-243-42-70.ec2.internal") .privateIpAddress("10.243.42.70").ramdiskId("ari-a51cf9cc").rootDeviceType( RootDeviceType.INSTANCE_STORE).build()), "993194456877", null, "r-a3c508cb")); @@ -95,7 +94,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest .instanceState(InstanceState.RUNNING).instanceType(InstanceType.M1_LARGE).kernelId( "aki-ba3adfd3").keyName("example-key-name").launchTime( dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")).monitoringState( - MonitoringState.DISABLED).availabilityZone(AvailabilityZone.US_EAST_1B) + MonitoringState.DISABLED).availabilityZone("us-east-1b") .virtualizationType("paravirtual").privateDnsName("10-251-50-132.ec2.internal").productCode( "774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE) .build(), new AWSRunningInstance.Builder().region(defaultRegion).groupId("default") @@ -103,7 +102,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest .instanceId("i-28a64435").instanceState(InstanceState.RUNNING).instanceType( InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name") .launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")).monitoringState( - MonitoringState.DISABLED).availabilityZone(AvailabilityZone.US_EAST_1B) + MonitoringState.DISABLED).availabilityZone("us-east-1b") .virtualizationType("paravirtual").privateDnsName("10-251-50-134.ec2.internal").productCode( "774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE) .build()), "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", null, "r-44a5402d")); @@ -123,7 +122,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest .instanceType(InstanceType.M1_SMALL).ipAddress("75.101.203.146").kernelId( "aki-a71cf9ce").keyName("adriancole.ec2ebs1").launchTime( dateService.iso8601DateParse("2009-12-30T04:06:23.000Z")).monitoringState( - MonitoringState.DISABLED).availabilityZone(AvailabilityZone.US_EAST_1B) + MonitoringState.DISABLED).availabilityZone("us-east-1b") .placementGroup("placement").virtualizationType("hvm").privateDnsName( "domU-12-31-39-09-CE-53.compute-1.internal").privateIpAddress( "10.210.209.157").ramdiskId("ari-a51cf9cc") diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/RunInstancesResponseHandlerTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/RunInstancesResponseHandlerTest.java index 77cee3c388..c2e18320de 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/RunInstancesResponseHandlerTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/RunInstancesResponseHandlerTest.java @@ -29,7 +29,6 @@ import java.io.InputStream; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.MonitoringState; import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.AvailabilityZone; import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.Reservation; @@ -86,19 +85,19 @@ public class RunInstancesResponseHandlerTest extends BaseEC2HandlerTest { "ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).instanceType( InstanceType.M1_SMALL).keyName("example-key-name").launchTime( dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState( - MonitoringState.ENABLED).availabilityZone(AvailabilityZone.US_EAST_1B).build(), + MonitoringState.ENABLED).availabilityZone("us-east-1b").build(), new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1").imageId( "ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType( InstanceType.M1_SMALL).keyName("example-key-name").launchTime( dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState( - MonitoringState.ENABLED).availabilityZone(AvailabilityZone.US_EAST_1B).build(), + MonitoringState.ENABLED).availabilityZone("us-east-1b").build(), new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2").imageId( "ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType( InstanceType.M1_SMALL).keyName("example-key-name").launchTime( dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState( - MonitoringState.ENABLED).availabilityZone(AvailabilityZone.US_EAST_1B).build()) + MonitoringState.ENABLED).availabilityZone("us-east-1b").build()) , "AIDADH4IGTRXXKCD", null, "r-47a5402e"); diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3PropertiesBuilder.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3PropertiesBuilder.java index 92a6232cc8..65818f3dad 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3PropertiesBuilder.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3PropertiesBuilder.java @@ -20,49 +20,36 @@ package org.jclouds.aws.s3; import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; +import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1; import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; -import static org.jclouds.aws.domain.Region.EU_WEST_1; -import static org.jclouds.aws.domain.Region.US_EAST_1; +import static org.jclouds.aws.domain.Region.US_STANDARD; import static org.jclouds.aws.domain.Region.US_WEST_1; import static org.jclouds.location.reference.LocationConstants.ENDPOINT; -import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; -import java.util.Set; import org.jclouds.aws.domain.Region; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableSet; - /** * Builds properties used in S3 Clients * * @author Adrian Cole */ public class AWSS3PropertiesBuilder extends org.jclouds.s3.S3PropertiesBuilder { - public static Set DEFAULT_REGIONS = ImmutableSet.of(EU_WEST_1, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1); @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US,US-CA,IE,SG"); - properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_STANDARD, Region.US_WEST_1, "EU", - Region.AP_SOUTHEAST_1)); + properties.putAll(Region.regionPropertiesS3()); properties.setProperty(PROPERTY_ENDPOINT, "https://s3.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_STANDARD + "." + ENDPOINT, "https://s3.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_STANDARD + "." + ISO3166_CODES, "US"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + "." + ENDPOINT, - "https://s3-us-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + "." + ISO3166_CODES, "US-CA"); + properties.setProperty(PROPERTY_REGION + "." + US_STANDARD + "." + ENDPOINT, "https://s3.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ENDPOINT, "https://s3-us-west-1.amazonaws.com"); properties.setProperty(PROPERTY_REGION + "." + "EU" + "." + ENDPOINT, "https://s3-eu-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + "EU" + "." + ISO3166_CODES, "IE"); - properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + "." + ENDPOINT, - "https://s3-ap-southeast-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + "." + ISO3166_CODES, "SG"); + properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + "." + ENDPOINT, + "https://s3-ap-southeast-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + "." + ENDPOINT, + "https://s3-ap-northeast-1.amazonaws.com"); return properties; } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ServiceIntegrationLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ServiceIntegrationLiveTest.java index 465a46f522..0fa100c1c9 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ServiceIntegrationLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ServiceIntegrationLiveTest.java @@ -33,7 +33,7 @@ import com.google.common.collect.ImmutableSet; public class AWSS3ServiceIntegrationLiveTest extends S3ServiceIntegrationLiveTest { @Override protected Set getIso3166Codes() { - return ImmutableSet. of("US", "US-CA", "IE", "SG"); + return ImmutableSet. of("US", "US-CA", "IE", "SG", "JP-13"); } } diff --git a/sandbox-apis/cloudwatch/pom.xml b/sandbox-apis/cloudwatch/pom.xml index bc3511180e..68c47d5f40 100644 --- a/sandbox-apis/cloudwatch/pom.xml +++ b/sandbox-apis/cloudwatch/pom.xml @@ -61,6 +61,12 @@ ${project.version} test + + log4j + log4j + 1.2.16 + test + diff --git a/sandbox-apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchPropertiesBuilder.java b/sandbox-apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchPropertiesBuilder.java index d6003d2b1d..5f56f9e95a 100644 --- a/sandbox-apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchPropertiesBuilder.java +++ b/sandbox-apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchPropertiesBuilder.java @@ -18,44 +18,43 @@ */ package org.jclouds.cloudwatch; + import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; import org.jclouds.PropertiesBuilder; import org.jclouds.aws.domain.Region; -import com.google.common.base.Joiner; - /** * Builds properties used in Cloud Watch Clients * * @author Adrian Cole */ public class CloudWatchPropertiesBuilder extends PropertiesBuilder { + @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_HEADER_TAG, "amz"); properties.setProperty(PROPERTY_API_VERSION, CloudWatchAsyncClient.VERSION); - properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_EAST_1, - Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1)); - properties.setProperty(PROPERTY_ENDPOINT, - "https://monitoring.us-east-1.amazonaws.com"); + properties.putAll(Region.regionProperties()); + properties.setProperty(PROPERTY_ENDPOINT, "https://monitoring.us-east-1.amazonaws.com"); properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint", - "https://monitoring.us-east-1.amazonaws.com"); + "https://monitoring.us-east-1.amazonaws.com"); properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint", - "https://monitoring.us-west-1.amazonaws.com"); + "https://monitoring.us-west-1.amazonaws.com"); properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint", - "https://monitoring.eu-west-1.amazonaws.com"); + "https://monitoring.eu-west-1.amazonaws.com"); properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint", - "https://monitoring.ap-southeast-1.amazonaws.com"); + "https://monitoring.ap-southeast-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + Region.AP_NORTHEAST_1 + ".endpoint", + "https://monitoring.ap-northeast-1.amazonaws.com"); return properties; } diff --git a/sandbox-apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java b/sandbox-apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java index fac341ae11..dabb587ef8 100644 --- a/sandbox-apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java +++ b/sandbox-apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java @@ -35,7 +35,6 @@ import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; import com.google.inject.Module; /** @@ -57,10 +56,9 @@ public class CloudWatchClientLiveTest { protected void setupCredentials() { identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider - + ".credential"); - endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint"); - apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider - + ".apiversion"); + + ".credential"); + endpoint = System.getProperty("test." + provider + ".endpoint", null); + apiversion = System.getProperty("test." + provider + ".apiversion", null); } protected Properties setupProperties() { @@ -69,8 +67,10 @@ public class CloudWatchClientLiveTest { overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); overrides.setProperty(provider + ".identity", identity); overrides.setProperty(provider + ".credential", credential); - overrides.setProperty(provider + ".endpoint", endpoint); - overrides.setProperty(provider + ".apiversion", apiversion); + if (endpoint != null) + overrides.setProperty(provider + ".endpoint", endpoint); + if (apiversion != null) + overrides.setProperty(provider + ".apiversion", apiversion); return overrides; } @@ -79,7 +79,7 @@ public class CloudWatchClientLiveTest { setupCredentials(); Properties overrides = setupProperties(); context = new RestContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), - overrides); + overrides); client = context.getApi(); } @@ -87,8 +87,7 @@ public class CloudWatchClientLiveTest { void testGetMetricStatisticsInRegion() { Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, -1); - for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, - Region.AP_SOUTHEAST_1)) { + for (String region : Region.DEFAULT_REGIONS) { assert client.getMetricStatisticsInRegion(region, "CPUUtilization", cal.getTime(), new Date(), 60, "Average") != null; } } diff --git a/sandbox-apis/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java b/sandbox-apis/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java index 20a2b8bdf2..56f8234a0a 100644 --- a/sandbox-apis/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java +++ b/sandbox-apis/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java @@ -68,7 +68,7 @@ public class ELBAsyncClientTest extends RestClientTest { assertNonPayloadHeadersEqual(request, "Host: elasticloadbalancing.us-east-1.amazonaws.com\n"); assertPayloadEquals( request, - "Version=2010-07-01&Action=CreateLoadBalancer&Listeners.member.1.Protocol=http&LoadBalancerName=name&Listeners.member.1.InstancePort=80&Listeners.member.1.LoadBalancerPort=80", + "Version=2010-07-01&Action=CreateLoadBalancer&Listeners.member.1.Protocol=http&LoadBalancerName=name&Listeners.member.1.LoadBalancerPort=80&Listeners.member.1.InstancePort=80", "application/x-www-form-urlencoded", false); assertResponseParserClassEquals(method, request, ParseSax.class); @@ -180,9 +180,19 @@ public class ELBAsyncClientTest extends RestClientTest { protected String provider = "elb"; + @Override + protected Properties getProperties() { + Properties overrides = new Properties(); + overrides.setProperty(provider + ".endpoint", "https://elasticloadbalancing.us-east-1.amazonaws.com"); + overrides.setProperty(provider + ".propertiesbuilder", ELBPropertiesBuilder.class.getName()); + overrides.setProperty(provider + ".contextbuilder", ELBContextBuilder.class.getName()); + return overrides; + } + @Override public RestContextSpec createContextSpec() { - return new RestContextFactory().createContextSpec(provider, "identity", "credential", new Properties()); + return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential", + new Properties()); } @Override diff --git a/sandbox-apis/elb/src/test/java/org/jclouds/elb/ProvidersInPropertiesTest.java b/sandbox-apis/elb/src/test/java/org/jclouds/elb/ProvidersInPropertiesTest.java deleted file mode 100644 index ae54198ecb..0000000000 --- a/sandbox-apis/elb/src/test/java/org/jclouds/elb/ProvidersInPropertiesTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * 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.elb; - -import org.jclouds.rest.Providers; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - * - */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "elb") : providers; - } - -} diff --git a/sandbox-apis/sqs/src/main/java/org/jclouds/sqs/SQSPropertiesBuilder.java b/sandbox-apis/sqs/src/main/java/org/jclouds/sqs/SQSPropertiesBuilder.java index dba702da45..471060ca58 100644 --- a/sandbox-apis/sqs/src/main/java/org/jclouds/sqs/SQSPropertiesBuilder.java +++ b/sandbox-apis/sqs/src/main/java/org/jclouds/sqs/SQSPropertiesBuilder.java @@ -23,15 +23,10 @@ import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; import org.jclouds.PropertiesBuilder; -import org.jclouds.aws.domain.Region; - -import com.google.common.base.Joiner; /** * Builds properties used in SQS Clients @@ -45,17 +40,7 @@ public class SQSPropertiesBuilder extends PropertiesBuilder { properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_HEADER_TAG, "amz"); properties.setProperty(PROPERTY_API_VERSION, SQSAsyncClient.VERSION); - properties.setProperty(PROPERTY_REGIONS, - Joiner.on(',').join(Region.US_EAST_1, Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1)); properties.setProperty(PROPERTY_ENDPOINT, "https://sqs.us-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint", - "https://sqs.us-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint", - "https://sqs.us-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint", - "https://sqs.eu-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint", - "https://sqs.ap-southeast-1.amazonaws.com"); return properties; } diff --git a/sandbox-apis/sqs/src/test/java/org/jclouds/sqs/SQSAsyncClientTest.java b/sandbox-apis/sqs/src/test/java/org/jclouds/sqs/SQSAsyncClientTest.java index 8e2cff6049..3ff143a9de 100644 --- a/sandbox-apis/sqs/src/test/java/org/jclouds/sqs/SQSAsyncClientTest.java +++ b/sandbox-apis/sqs/src/test/java/org/jclouds/sqs/SQSAsyncClientTest.java @@ -19,8 +19,6 @@ package org.jclouds.sqs; -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Predicates.not; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -31,7 +29,6 @@ import java.util.Properties; import javax.inject.Named; import org.jclouds.Constants; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.filters.FormSigner; import org.jclouds.date.DateService; import org.jclouds.http.HttpRequest; @@ -48,7 +45,6 @@ import org.jclouds.sqs.xml.RegexListQueuesResponseHandler; import org.jclouds.sqs.xml.RegexQueueHandler; import org.testng.annotations.Test; -import com.google.common.collect.Iterables; import com.google.inject.Module; import com.google.inject.TypeLiteral; @@ -145,14 +141,6 @@ public class SQSAsyncClientTest extends RestClientTest { checkFilters(request); } - public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException { - Method method = SQSAsyncClient.class.getMethod("createQueueInRegion", String.class, String.class, Array - .newInstance(CreateQueueOptions.class, 0).getClass()); - for (String region : Iterables.filter(Region.ALL_SQS, not(equalTo("us-standard")))) { - processor.createRequest(method, region, "queueName"); - } - } - @Override protected void checkFilters(HttpRequest request) { assertEquals(request.getFilters().size(), 1); @@ -172,9 +160,19 @@ public class SQSAsyncClientTest extends RestClientTest { protected String provider = "sqs"; + @Override + protected Properties getProperties() { + Properties overrides = new Properties(); + overrides.setProperty(provider + ".endpoint", "https://sqs.us-east-1.amazonaws.com"); + overrides.setProperty(provider + ".propertiesbuilder", SQSPropertiesBuilder.class.getName()); + overrides.setProperty(provider + ".contextbuilder", SQSContextBuilder.class.getName()); + return overrides; + } + @Override public RestContextSpec createContextSpec() { - return new RestContextFactory().createContextSpec(provider, "identity", "credential", new Properties()); + return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential", + new Properties()); } } diff --git a/sandbox-apis/sqs/src/test/java/org/jclouds/sqs/SQSClientLiveTest.java b/sandbox-apis/sqs/src/test/java/org/jclouds/sqs/SQSClientLiveTest.java index ec6fd38373..b949f3d6a4 100644 --- a/sandbox-apis/sqs/src/test/java/org/jclouds/sqs/SQSClientLiveTest.java +++ b/sandbox-apis/sqs/src/test/java/org/jclouds/sqs/SQSClientLiveTest.java @@ -31,7 +31,6 @@ import java.util.SortedSet; import org.jclouds.Constants; import org.jclouds.aws.AWSResponseException; -import org.jclouds.aws.domain.Region; import org.jclouds.crypto.CryptoStreams; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; @@ -42,7 +41,6 @@ import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.inject.Module; @@ -97,60 +95,61 @@ public class SQSClientLiveTest { } @Test - void testListQueuesInRegion() throws InterruptedException { - for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, - Region.AP_SOUTHEAST_1)) { - SortedSet allResults = Sets.newTreeSet(client.listQueuesInRegion(region)); - assertNotNull(allResults); - if (allResults.size() >= 1) { - Queue queue = allResults.last(); - assertQueueInList(region, queue); - } + protected void testListQueues() throws InterruptedException { + listQueuesInRegion(null); + } + + protected void listQueuesInRegion(String region) throws InterruptedException { + SortedSet allResults = Sets.newTreeSet(client.listQueuesInRegion(region)); + assertNotNull(allResults); + if (allResults.size() >= 1) { + Queue queue = allResults.last(); + assertQueueInList(region, queue); } } public static final String PREFIX = System.getProperty("user.name") + "-sqs"; @Test - void testCreateQueue() throws InterruptedException { - String queueName = PREFIX + "1"; + protected void testCreateQueue() throws InterruptedException { + createQueueInRegion(null, PREFIX + "1"); + } - for (final String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, - Region.AP_SOUTHEAST_1)) { - try { - SortedSet result = Sets.newTreeSet(client.listQueuesInRegion(region, queuePrefix(queueName))); - if (result.size() >= 1) { - client.deleteQueue(result.last()); - queueName += 1;// cannot recreate a queue within 60 seconds - } - } catch (Exception e) { + public String createQueueInRegion(final String region, String queueName) throws InterruptedException { + try { + SortedSet result = Sets.newTreeSet(client.listQueuesInRegion(region, queuePrefix(queueName))); + if (result.size() >= 1) { + client.deleteQueue(result.last()); + queueName += 1;// cannot recreate a queue within 60 seconds + } + } catch (Exception e) { - } - Queue queue = null; - int tries = 0; - while (queue == null && tries < 5) { - try { - tries++; - queue = client.createQueueInRegion(region, queueName); - } catch (AWSResponseException e) { - queueName += "1"; - if (e.getError().getCode().equals("AWS.SimpleQueueService.QueueDeletedRecently"))// TODO - // retry - // handler - continue; - throw e; - } - } - if (region != null) - assertEquals(queue.getRegion(), region); - assertEquals(queue.getName(), queueName); - assertQueueInList(region, queue); - queues.add(queue); } + Queue queue = null; + int tries = 0; + while (queue == null && tries < 5) { + try { + tries++; + queue = client.createQueueInRegion(region, queueName); + } catch (AWSResponseException e) { + queueName += "1"; + if (e.getError().getCode().equals("AWS.SimpleQueueService.QueueDeletedRecently"))// TODO + // retry + // handler + continue; + throw e; + } + } + if (region != null) + assertEquals(queue.getRegion(), region); + assertEquals(queue.getName(), queueName); + assertQueueInList(region, queue); + queues.add(queue); + return queueName; } @Test(dependsOnMethods = "testCreateQueue") - void testSendMessage() throws InterruptedException, IOException { + protected void testSendMessage() throws InterruptedException, IOException { String message = "hardyharhar"; byte[] md5 = CryptoStreams.md5(message.getBytes()); for (Queue queue : queues) { diff --git a/sandbox-apis/sqs/src/test/java/org/jclouds/sqs/config/SQSRestClientModuleTest.java b/sandbox-apis/sqs/src/test/java/org/jclouds/sqs/config/SQSRestClientModuleTest.java deleted file mode 100644 index 7874a12f37..0000000000 --- a/sandbox-apis/sqs/src/test/java/org/jclouds/sqs/config/SQSRestClientModuleTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * 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.sqs.config; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; -import java.util.Map; - -import org.jclouds.aws.domain.Region; -import org.jclouds.aws.handlers.AWSClientErrorRetryHandler; -import org.jclouds.aws.handlers.AWSRedirectionRetryHandler; -import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent; -import org.jclouds.http.handlers.DelegatingErrorHandler; -import org.jclouds.http.handlers.DelegatingRetryHandler; -import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.BaseRestClientTest.MockModule; -import org.jclouds.rest.RestContextFactory; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.Module; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit") -public class SQSRestClientModuleTest { - - Injector createInjector() { - return new RestContextFactory().createContextBuilder("sqs", "uid", "key", - ImmutableSet. of(new MockModule(), new NullLoggingModule())).buildInjector(); - } - - @Test - void testServerErrorHandler() { - DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class); - assertEquals(handler.getServerErrorHandler().getClass(), ParseAWSErrorFromXmlContent.class); - } - - @Test - void testRegions() { - Map regionMap = createInjector().getInstance( - new Key>(org.jclouds.location.Region.class) { - }); - assertEquals(regionMap, ImmutableMap. of(Region.US_EAST_1, URI - .create("https://sqs.us-east-1.amazonaws.com"), Region.US_WEST_1, URI - .create("https://sqs.us-west-1.amazonaws.com"), Region.EU_WEST_1, URI - .create("https://sqs.eu-west-1.amazonaws.com"), Region.AP_SOUTHEAST_1, URI - .create("https://sqs.ap-southeast-1.amazonaws.com"))); - } - - @Test - void testClientErrorHandler() { - DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class); - assertEquals(handler.getClientErrorHandler().getClass(), ParseAWSErrorFromXmlContent.class); - } - - @Test - void testClientRetryHandler() { - DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class); - assertEquals(handler.getClientErrorRetryHandler().getClass(), - AWSClientErrorRetryHandler.class); - } - - @Test - void testRedirectionRetryHandler() { - DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class); - assertEquals(handler.getRedirectionRetryHandler().getClass(), - AWSRedirectionRetryHandler.class); - } - -} diff --git a/sandbox-providers/aws-elb/pom.xml b/sandbox-providers/aws-elb/pom.xml index 8c3b4d6318..38209a0ded 100644 --- a/sandbox-providers/aws-elb/pom.xml +++ b/sandbox-providers/aws-elb/pom.xml @@ -74,6 +74,12 @@ test-jar test + + org.jclouds.provider + aws-ec2 + ${project.version} + test + org.jclouds.driver jclouds-log4j diff --git a/sandbox-providers/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java b/sandbox-providers/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java index 8a2c2c0c88..1ce6d255fe 100644 --- a/sandbox-providers/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java +++ b/sandbox-providers/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java @@ -21,6 +21,7 @@ package org.jclouds.aws.elb; import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1; import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; import static org.jclouds.aws.domain.Region.EU_WEST_1; import static org.jclouds.aws.domain.Region.US_EAST_1; @@ -28,41 +29,37 @@ import static org.jclouds.aws.domain.Region.US_WEST_1; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_ZONECLIENT_ENDPOINT; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; -import java.util.Set; import org.jclouds.aws.domain.Region; import org.jclouds.elb.ELBAsyncClient; import org.jclouds.elb.ELBPropertiesBuilder; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableSet; - /** * Builds properties used in ELB Clients * * @author Adrian Cole */ public class AWSELBPropertiesBuilder extends ELBPropertiesBuilder { - public static Set DEFAULT_REGIONS = ImmutableSet.of(EU_WEST_1, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1); @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); - properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS)); + properties.putAll(Region.regionProperties()); properties.setProperty(PROPERTY_API_VERSION, ELBAsyncClient.VERSION); properties.setProperty(PROPERTY_ENDPOINT, "https://elasticloadbalancing.us-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint", + properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + ".endpoint", "https://elasticloadbalancing.us-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint", + properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + ".endpoint", "https://elasticloadbalancing.us-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint", + properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + ".endpoint", "https://elasticloadbalancing.eu-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint", + properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + ".endpoint", "https://elasticloadbalancing.ap-southeast-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + ".endpoint", + "https://elasticloadbalancing.ap-northeast-1.amazonaws.com"); properties.setProperty(PROPERTY_ZONECLIENT_ENDPOINT, "https://ec2.us-east-1.amazonaws.com"); return properties; } diff --git a/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java b/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java index 1fd4ffebd8..183bc242a7 100644 --- a/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java +++ b/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java @@ -19,6 +19,7 @@ package org.jclouds.aws.elb; +import org.jclouds.aws.domain.Region; import org.jclouds.elb.ELBClientLiveTest; import org.testng.annotations.Test; @@ -35,21 +36,21 @@ public class AWSELBClientLiveTest extends ELBClientLiveTest { @Test public void testCreateLoadBalancer() { - for (String region : AWSELBPropertiesBuilder.DEFAULT_REGIONS) { + for (String region : Region.DEFAULT_REGIONS) { createLoadBalancerInRegionZone(region, region + "a", name); } } @Test(dependsOnMethods = "testCreateLoadBalancer") public void testDescribeLoadBalancers() { - for (String region : AWSELBPropertiesBuilder.DEFAULT_REGIONS) { + for (String region : Region.DEFAULT_REGIONS) { describeLoadBalancerInRegion(region); } } @Test public void testDeleteLoadBalancer() { - for (String region : AWSELBPropertiesBuilder.DEFAULT_REGIONS) { + for (String region : Region.DEFAULT_REGIONS) { deleteLoadBalancerInRegion(region); } } diff --git a/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/ELBAsyncClientTest.java b/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/ELBAsyncClientTest.java index f2732b4857..1ef7e419c0 100644 --- a/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/ELBAsyncClientTest.java +++ b/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/ELBAsyncClientTest.java @@ -19,12 +19,13 @@ package org.jclouds.aws.elb; -import static org.jclouds.aws.elb.AWSELBPropertiesBuilder.DEFAULT_REGIONS; - import java.io.IOException; import java.lang.reflect.Method; +import java.util.Properties; +import org.jclouds.aws.domain.Region; import org.jclouds.elb.ELBAsyncClient; +import org.jclouds.rest.RestContextFactory; import org.testng.annotations.Test; /** @@ -40,9 +41,14 @@ public class ELBAsyncClientTest extends org.jclouds.elb.ELBAsyncClientTest { this.provider = "aws-elb"; } + @Override + protected Properties getProperties() { + return RestContextFactory.getPropertiesFromResource("/rest.properties"); + } + public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException { Method method = ELBAsyncClient.class.getMethod("describeLoadBalancersInRegion", String.class, String[].class); - for (String region : DEFAULT_REGIONS) { + for (String region : Region.DEFAULT_REGIONS) { processor.createRequest(method, region); } } diff --git a/sandbox-providers/aws-simpledb/src/main/java/org/jclouds/aws/simpledb/SimpleDBPropertiesBuilder.java b/sandbox-providers/aws-simpledb/src/main/java/org/jclouds/aws/simpledb/AWSSimpleDBPropertiesBuilder.java similarity index 66% rename from sandbox-providers/aws-simpledb/src/main/java/org/jclouds/aws/simpledb/SimpleDBPropertiesBuilder.java rename to sandbox-providers/aws-simpledb/src/main/java/org/jclouds/aws/simpledb/AWSSimpleDBPropertiesBuilder.java index d483c004b1..9cf5c8fe99 100644 --- a/sandbox-providers/aws-simpledb/src/main/java/org/jclouds/aws/simpledb/SimpleDBPropertiesBuilder.java +++ b/sandbox-providers/aws-simpledb/src/main/java/org/jclouds/aws/simpledb/AWSSimpleDBPropertiesBuilder.java @@ -20,51 +20,49 @@ package org.jclouds.aws.simpledb; import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1; import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; import static org.jclouds.aws.domain.Region.EU_WEST_1; import static org.jclouds.aws.domain.Region.US_EAST_1; import static org.jclouds.aws.domain.Region.US_WEST_1; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; -import java.util.Set; import org.jclouds.aws.domain.Region; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableSet; - /** * Builds properties used in SimpleDB Clients * * @author Adrian Cole */ -public class SimpleDBPropertiesBuilder extends org.jclouds.simpledb.SimpleDBPropertiesBuilder { - public static Set DEFAULT_REGIONS = ImmutableSet.of(EU_WEST_1, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1); +public class AWSSimpleDBPropertiesBuilder extends org.jclouds.simpledb.SimpleDBPropertiesBuilder { @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); - properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS)); + properties.putAll(Region.regionProperties()); + properties.setProperty(PROPERTY_ENDPOINT, "https://sdb.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint", "https://sdb.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint", + properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + ".endpoint", "https://sdb.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + ".endpoint", "https://sdb.us-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint", + properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + ".endpoint", "https://sdb.eu-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint", + properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + ".endpoint", "https://sdb.ap-southeast-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + ".endpoint", + "https://sdb.ap-northeast-1.amazonaws.com"); return properties; } - public SimpleDBPropertiesBuilder() { + public AWSSimpleDBPropertiesBuilder() { super(); } - public SimpleDBPropertiesBuilder(Properties properties) { + public AWSSimpleDBPropertiesBuilder(Properties properties) { super(properties); } diff --git a/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/SimpleDBAsyncClientTest.java b/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/AWSSimpleDBAsyncClientTest.java similarity index 70% rename from sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/SimpleDBAsyncClientTest.java rename to sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/AWSSimpleDBAsyncClientTest.java index d466a26e77..b4a511df6f 100644 --- a/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/SimpleDBAsyncClientTest.java +++ b/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/AWSSimpleDBAsyncClientTest.java @@ -19,12 +19,14 @@ package org.jclouds.aws.simpledb; -import static org.jclouds.aws.simpledb.SimpleDBPropertiesBuilder.DEFAULT_REGIONS; - import java.io.IOException; import java.lang.reflect.Method; +import java.util.Properties; +import org.jclouds.aws.domain.Region; +import org.jclouds.rest.RestContextFactory; import org.jclouds.simpledb.SimpleDBAsyncClient; +import org.jclouds.simpledb.SimpleDBAsyncClientTest; import org.testng.annotations.Test; /** @@ -34,17 +36,20 @@ import org.testng.annotations.Test; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "aws.SimpleDBAsyncClientTest") -public class SimpleDBAsyncClientTest extends org.jclouds.simpledb.SimpleDBAsyncClientTest { +public class AWSSimpleDBAsyncClientTest extends SimpleDBAsyncClientTest { - public SimpleDBAsyncClientTest() { + public AWSSimpleDBAsyncClientTest() { this.provider = "aws-simpledb"; } - // TODO fix this test as it has the wrong arg count - @Test(enabled = false) + @Override + protected Properties getProperties() { + return RestContextFactory.getPropertiesFromResource("/rest.properties"); + } + public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException { - Method method = SimpleDBAsyncClient.class.getMethod("putAttributes", String.class, String.class); - for (String region : DEFAULT_REGIONS) { + Method method = SimpleDBAsyncClient.class.getMethod("createDomainInRegion", String.class, String.class); + for (String region : Region.DEFAULT_REGIONS) { processor.createRequest(method, region, "domainName"); } } diff --git a/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/AWSSimpleDBClientLiveTest.java b/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/AWSSimpleDBClientLiveTest.java index 93eba468ed..333c228b9e 100644 --- a/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/AWSSimpleDBClientLiveTest.java +++ b/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/AWSSimpleDBClientLiveTest.java @@ -19,8 +19,7 @@ package org.jclouds.aws.simpledb; -import static org.jclouds.aws.simpledb.SimpleDBPropertiesBuilder.DEFAULT_REGIONS; - +import org.jclouds.aws.domain.Region; import org.jclouds.simpledb.SimpleDBClientLiveTest; import org.testng.annotations.Test; @@ -36,7 +35,7 @@ public class AWSSimpleDBClientLiveTest extends SimpleDBClientLiveTest { } @Test void testListDomainsInRegion() throws InterruptedException { - for (String region : DEFAULT_REGIONS) { + for (String region : Region.DEFAULT_REGIONS) { listDomainInRegion(region); } } @@ -44,8 +43,7 @@ public class AWSSimpleDBClientLiveTest extends SimpleDBClientLiveTest { @Test void testCreateDomainInRegions() throws InterruptedException { String domainName = PREFIX + "1"; - - for (String region : DEFAULT_REGIONS) { + for (String region : Region.DEFAULT_REGIONS) { domainName = createDomainInRegion(region, domainName); } } From 19eea56052f573924f9580a99b968b3e9fee72aa Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 4 Mar 2011 14:57:35 -0500 Subject: [PATCH 05/10] added example for reassigning server ip in cloudsigma --- .../jclouds/vcloud/VCloudClientLiveTest.java | 2 +- .../vcloud/CommonVCloudClientLiveTest.java | 7 +++- .../org/jclouds/cloudsigma/util/Servers.java | 15 ++++++++ .../cloudsigma/CloudSigmaClientLiveTest.java | 29 ++++++++++++--- .../cloudstack/CloudStackAsyncClient.java | 7 ++++ .../jclouds/cloudstack/CloudStackClient.java | 7 ++++ .../config/CloudStackRestClientModule.java | 37 +++++++++++++------ 7 files changed, 84 insertions(+), 20 deletions(-) diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java index 0c29bcad55..be3ca05dd4 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java @@ -141,7 +141,7 @@ public class VCloudClientLiveTest extends CommonVCloudClientLiveTest { public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// - .put(ZoneClient.class, ZoneAsyncClient.class)// - .put(TemplateClient.class, TemplateAsyncClient.class)// - .put(OfferingClient.class, OfferingAsyncClient.class)// - .put(NetworkClient.class, NetworkAsyncClient.class)// - .put(VirtualMachineClient.class, VirtualMachineAsyncClient.class)// - .put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)// - .put(AsyncJobClient.class, AsyncJobAsyncClient.class)// - .put(AddressClient.class, AddressAsyncClient.class)// - .put(NATClient.class, NATAsyncClient.class)// - .put(FirewallClient.class, FirewallAsyncClient.class)// - .put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)// - .build(); + .put(ZoneClient.class, ZoneAsyncClient.class)// + .put(TemplateClient.class, TemplateAsyncClient.class)// + .put(OfferingClient.class, OfferingAsyncClient.class)// + .put(NetworkClient.class, NetworkAsyncClient.class)// + .put(VirtualMachineClient.class, VirtualMachineAsyncClient.class)// + .put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)// + .put(AsyncJobClient.class, AsyncJobAsyncClient.class)// + .put(AddressClient.class, AddressAsyncClient.class)// + .put(NATClient.class, NATAsyncClient.class)// + .put(FirewallClient.class, FirewallAsyncClient.class)// + .put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)// + .put(GuestOSClient.class, GuestOSAsyncClient.class)// + .build(); public CloudStackRestClientModule() { super(CloudStackClient.class, CloudStackAsyncClient.class, DELEGATE_MAP); @@ -88,6 +93,14 @@ public class CloudStackRestClientModule extends RestClientModule Date: Fri, 4 Mar 2011 14:26:26 -0600 Subject: [PATCH 06/10] added compute service live test for savvis --- .../SymphonyVPDCComputeServiceLiveTest.java | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 sandbox-providers/savvis/src/test/java/org/jclouds/vcloud/savvis/compute/SymphonyVPDCComputeServiceLiveTest.java diff --git a/sandbox-providers/savvis/src/test/java/org/jclouds/vcloud/savvis/compute/SymphonyVPDCComputeServiceLiveTest.java b/sandbox-providers/savvis/src/test/java/org/jclouds/vcloud/savvis/compute/SymphonyVPDCComputeServiceLiveTest.java new file mode 100644 index 0000000000..9361e7d327 --- /dev/null +++ b/sandbox-providers/savvis/src/test/java/org/jclouds/vcloud/savvis/compute/SymphonyVPDCComputeServiceLiveTest.java @@ -0,0 +1,128 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.vcloud.savvis.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; + +import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.domain.ComputeMetadata; +import org.jclouds.compute.domain.ComputeType; +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.rest.RestContext; +import org.jclouds.savvis.SymphonyVPDCAsyncClient; +import org.jclouds.savvis.SymphonyVPDCClient; +import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.vcloud.domain.VCloudExpressVApp; +import org.testng.annotations.Test; + +/** + * + * + * @author Kedar Dave + */ +@Test(groups = "live", enabled = true, sequential = true) +public class SymphonyVPDCComputeServiceLiveTest extends BaseComputeServiceLiveTest { + public SymphonyVPDCComputeServiceLiveTest() { + provider = "savvis-symphony-vpdc"; + } + + @Override + public void setServiceDefaults() { + group = "savvis.jclouds"; + } + + @Test + public void testTemplateBuilder() { + Template defaultTemplate = client.templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5.5"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS); + assert defaultTemplate.getLocation().getDescription() != null;// different per org + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + + public void testAssignability() throws Exception { + @SuppressWarnings("unused") + RestContext tmContext = new ComputeServiceContextFactory() + .createContext(provider, identity, credential).getProviderSpecificContext(); + } + + @Override + protected Template buildTemplate(TemplateBuilder templateBuilder) { + Template template = super.buildTemplate(templateBuilder); + Image image = template.getImage(); + assert image.getDefaultCredentials() != null && image.getDefaultCredentials().identity != null : image; + assert image.getDefaultCredentials() != null && image.getDefaultCredentials().credential != null : image; + return template; + } + + // currently, the wrong CIM OSType data is coming back. + @Override + protected void checkOsMatchesTemplate(NodeMetadata node) { + if (node.getOperatingSystem() != null) + assertEquals(node.getOperatingSystem().getFamily(), null); + } + + @Override + public void testListImages() throws Exception { + for (Image image : client.listImages()) { + assert image.getProviderId() != null : image; + // image.getLocationId() can be null, if it is a location-free image + assertEquals(image.getType(), ComputeType.IMAGE); + if (image.getOperatingSystem().getFamily() != OsFamily.WINDOWS + && image.getOperatingSystem().getFamily() != OsFamily.SOLARIS) { + assert image.getDefaultCredentials() != null && image.getDefaultCredentials().identity != null : image; + assert image.getDefaultCredentials().credential != null : image; + } + } + } + + @Override + public void testListNodes() throws Exception { + for (ComputeMetadata node : client.listNodes()) { + assert node.getProviderId() != null; + assert node.getLocation() != null; + assertEquals(node.getType(), ComputeType.NODE); + NodeMetadata allData = client.getNodeMetadata(node.getId()); + System.out.println(allData.getHardware()); + RestContext tmContext = new ComputeServiceContextFactory() + .createContext(provider, identity, credential).getProviderSpecificContext(); + VCloudExpressVApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(null, null, allData.getName()); + assertEquals(vApp.getName(), allData.getName()); + } + } + + @Override + public void testDestroyNodes() { + super.testDestroyNodes(); + } + + @Override + protected JschSshClientModule getSshModule() { + return new JschSshClientModule(); + } + +} \ No newline at end of file From c1637ba7409737d6d949fbb5ce5da334ed38e992 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 4 Mar 2011 15:45:59 -0500 Subject: [PATCH 07/10] added guest os to cloudstack --- .../org/jclouds/cloudstack/domain/OSType.java | 137 ++++++++++++++++++ .../features/GuestOSAsyncClient.java | 72 +++++++++ .../cloudstack/features/GuestOSClient.java | 56 +++++++ .../options/ListOSTypesOptions.java | 71 +++++++++ .../features/GuestOSAsyncClientTest.java | 101 +++++++++++++ .../features/GuestOSClientLiveTest.java | 60 ++++++++ .../options/ListOSTypesOptionsTest.java | 57 ++++++++ 7 files changed, 554 insertions(+) create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/OSType.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GuestOSAsyncClient.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GuestOSClient.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListOSTypesOptions.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSAsyncClientTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSClientLiveTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListOSTypesOptionsTest.java diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/OSType.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/OSType.java new file mode 100644 index 0000000000..ea41c7c670 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/OSType.java @@ -0,0 +1,137 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cloudstack.domain; + +import com.google.gson.annotations.SerializedName; + +/** + * + * @author Adrian Cole + */ +public class OSType implements Comparable { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private long id; + private long OSCategoryId; + private String description; + + public Builder id(long id) { + this.id = id; + return this; + } + + public Builder OSCategoryId(long OSCategoryId) { + this.OSCategoryId = OSCategoryId; + return this; + } + + public Builder description(String description) { + this.description = description; + return this; + } + + public OSType build() { + return new OSType(id, OSCategoryId, description); + } + } + + // for deserialization + OSType() { + + } + + private long id; + @SerializedName("oscategoryid") + private long OSCategoryId; + private String description; + + public OSType(long id, long OSCategoryId, String description) { + this.id = id; + this.OSCategoryId = OSCategoryId; + this.description = description; + } + + /** + * @return the ID of the OS type + */ + public long getId() { + return id; + } + + /** + * @return the ID of the OS category + */ + public long getOSCategoryId() { + return OSCategoryId; + } + + /** + * @return the name/description of the OS type + */ + public String getDescription() { + return description; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (OSCategoryId ^ (OSCategoryId >>> 32)); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + (int) (id ^ (id >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + OSType other = (OSType) obj; + if (OSCategoryId != other.OSCategoryId) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (id != other.id) + return false; + return true; + } + + @Override + public String toString() { + return "[id=" + id + ", OSCategoryId=" + OSCategoryId + ", description=" + description + "]"; + } + + @Override + public int compareTo(OSType arg0) { + return new Long(id).compareTo(arg0.getId()); + } + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GuestOSAsyncClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GuestOSAsyncClient.java new file mode 100644 index 0000000000..40a9ec84f8 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GuestOSAsyncClient.java @@ -0,0 +1,72 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cloudstack.features; + +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.cloudstack.domain.OSType; +import org.jclouds.cloudstack.filters.QuerySigner; +import org.jclouds.cloudstack.options.ListOSTypesOptions; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Unwrap; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides asynchronous access to cloudstack via their REST API. + *

+ * + * @see AsyncJobClient + * @see + * @author Adrian Cole + */ +@RequestFilters(QuerySigner.class) +@QueryParams(keys = "response", values = "json") +public interface GuestOSAsyncClient { + + /** + * @see GuestOSClient#listOSTypes + */ + @GET + @QueryParams(keys = "command", values = "listOsTypes") + @Unwrap(depth = 2) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listOSTypes(ListOSTypesOptions... options); + + /** + * @see OSTypeClient#getOSType + */ + @GET + @QueryParams(keys = "command", values = "listOsTypes") + @Unwrap(depth = 3, edgeCollection = Set.class) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getOSType(@QueryParam("id") long id); +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GuestOSClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GuestOSClient.java new file mode 100644 index 0000000000..80c4d76a3e --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GuestOSClient.java @@ -0,0 +1,56 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cloudstack.features; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.cloudstack.domain.OSType; +import org.jclouds.cloudstack.options.ListOSTypesOptions; +import org.jclouds.concurrent.Timeout; + +/** + * Provides synchronous access to CloudStack Operating System features. + *

+ * + * @see GuestOSAsyncClient + * @see + * @author Adrian Cole + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface GuestOSClient { + /** + * Lists all supported OS types for this cloud. + * + * @param options + * if present, how to constrain the list + * @return os types matching query, or empty set, if no types are found + */ + Set listOSTypes(ListOSTypesOptions... options); + + /** + * get a specific os type by id + * + * @param id + * os type to get + * @return os type or null if not found + */ + OSType getOSType(long id); +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListOSTypesOptions.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListOSTypesOptions.java new file mode 100644 index 0000000000..a7138b2a66 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListOSTypesOptions.java @@ -0,0 +1,71 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cloudstack.options; + +import org.jclouds.http.options.BaseHttpRequestOptions; + +import com.google.common.collect.ImmutableSet; + +/** + * Options used to control what OSType information is returned + * + * @see + * @author Adrian Cole + */ +public class ListOSTypesOptions extends BaseHttpRequestOptions { + + public static final ListOSTypesOptions NONE = new ListOSTypesOptions(); + /** + * @param id list by Os type Id + */ + public ListOSTypesOptions id(long id) { + this.queryParameters.replaceValues("id", ImmutableSet.of(id + "")); + return this; + } + /** + * @param OSCategoryId + * list by Os Category id + */ + public ListOSTypesOptions OSCategoryId(long OSCategoryId) { + this.queryParameters.replaceValues("oscategoryid", ImmutableSet.of(OSCategoryId + "")); + return this; + } + + + public static class Builder { + /** + * @see ListOSTypesOptions#id + */ + public static ListOSTypesOptions id(long id) { + ListOSTypesOptions options = new ListOSTypesOptions(); + return options.id(id); + } + + + /** + * @see ListOSTypesOptions#OSCategoryId + */ + public static ListOSTypesOptions OSCategoryId(long id) { + ListOSTypesOptions options = new ListOSTypesOptions(); + return options.OSCategoryId(id); + } + + } +} diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSAsyncClientTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSAsyncClientTest.java new file mode 100644 index 0000000000..bfd1fbb96c --- /dev/null +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSAsyncClientTest.java @@ -0,0 +1,101 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cloudstack.features; + +import java.io.IOException; +import java.lang.reflect.Method; + +import org.jclouds.cloudstack.options.ListOSTypesOptions; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue; +import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code GuestOSAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "GuestOSAsyncClientTest") +public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest { + + public void testGetOSType() throws SecurityException, NoSuchMethodException, IOException { + Method method = GuestOSAsyncClient.class.getMethod("getOSType", long.class); + HttpRequest httpRequest = processor.createRequest(method, 11l); + + assertRequestLineEquals(httpRequest, + "GET http://localhost:8080/client/api?response=json&command=listOsTypes&id=11 HTTP/1.1"); + assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); + assertPayloadEquals(httpRequest, null, null, false); + + assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValueInSet.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(httpRequest); + + } + + public void testListOSTypes() throws SecurityException, NoSuchMethodException, IOException { + Method method = GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class); + HttpRequest httpRequest = processor.createRequest(method); + + assertRequestLineEquals(httpRequest, + "GET http://localhost:8080/client/api?response=json&command=listOsTypes HTTP/1.1"); + assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); + assertPayloadEquals(httpRequest, null, null, false); + + assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + + checkFilters(httpRequest); + + } + + public void testListOSTypesOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class); + HttpRequest httpRequest = processor.createRequest(method, ListOSTypesOptions.Builder.OSCategoryId(11)); + + assertRequestLineEquals(httpRequest, + "GET http://localhost:8080/client/api?response=json&command=listOsTypes&oscategoryid=11 HTTP/1.1"); + assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); + assertPayloadEquals(httpRequest, null, null, false); + + assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + + checkFilters(httpRequest); + + } + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } +} diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSClientLiveTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSClientLiveTest.java new file mode 100644 index 0000000000..4e20f8678f --- /dev/null +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSClientLiveTest.java @@ -0,0 +1,60 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cloudstack.features; + +import static com.google.common.collect.Iterables.getOnlyElement; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.util.Set; + +import org.jclouds.cloudstack.domain.OSType; +import org.jclouds.cloudstack.options.ListOSTypesOptions; +import org.testng.annotations.Test; + +/** + * Tests behavior of {@code GuestOSClientLiveTest} + * + * @author Adrian Cole + */ +@Test(groups = "live", sequential = true, testName = "GuestOSClientLiveTest") +public class GuestOSClientLiveTest extends BaseCloudStackClientLiveTest { + + public void testListOSTypes() throws Exception { + Set response = client.getGuestOSClient().listOSTypes(); + assert null != response; + assertTrue(response.size() >= 0); + for (OSType type : response) { + OSType newDetails = getOnlyElement(client.getGuestOSClient().listOSTypes( + ListOSTypesOptions.Builder.id(type.getId()))); + assertEquals(type.getId(), newDetails.getId()); + checkIP(type); + } + } + + protected void checkIP(OSType type) { + assertEquals(type.getId(), client.getGuestOSClient().getOSType(type.getId()).getId()); + assert type.getId() > 0 : type; + assert type.getOSCategoryId() > 0 : type; + assert type.getDescription() != null : type; + + } + +} diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListOSTypesOptionsTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListOSTypesOptionsTest.java new file mode 100644 index 0000000000..e87b835584 --- /dev/null +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListOSTypesOptionsTest.java @@ -0,0 +1,57 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.ListOSTypesOptions.Builder.OSCategoryId; +import static org.jclouds.cloudstack.options.ListOSTypesOptions.Builder.id; +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; + +/** + * Tests behavior of {@code ListOSTypesOptions} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class ListOSTypesOptionsTest { + + public void testId() { + ListOSTypesOptions options = new ListOSTypesOptions().id(6); + assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("id")); + } + + public void testIdStatic() { + ListOSTypesOptions options = id(6); + assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("id")); + } + + public void testOSCategoryId() { + ListOSTypesOptions options = new ListOSTypesOptions().OSCategoryId(6); + assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("oscategoryid")); + } + + public void testOSCategoryIdStatic() { + ListOSTypesOptions options = OSCategoryId(6); + assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("oscategoryid")); + } +} From 6543f3af7a3317f466edc01cbce95588ea04d2db Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 4 Mar 2011 15:47:31 -0500 Subject: [PATCH 08/10] Issue 493:bad http syntax deleting cloudsigma resources --- .../cloudsigma/CloudSigmaAsyncClient.java | 8 +++---- .../cloudsigma/CloudSigmaAsyncClientTest.java | 8 +++---- .../cloudsigma/CloudSigmaClientLiveTest.java | 24 ++++--------------- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java index c271e0ce7b..d886ecf841 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java @@ -203,7 +203,7 @@ public interface CloudSigmaAsyncClient { /** * @see CloudSigmaClient#destroyServer */ - @POST + @GET @Path("/servers/{uuid}/destroy") @ExceptionParser(ReturnVoidOnNotFoundOr404.class) ListenableFuture destroyServer(@PathParam("uuid") String uuid); @@ -247,7 +247,7 @@ public interface CloudSigmaAsyncClient { /** * @see CloudSigmaClient#destroyDrive */ - @POST + @GET @Path("/drives/{uuid}/destroy") @ExceptionParser(ReturnVoidOnNotFoundOr404.class) ListenableFuture destroyDrive(@PathParam("uuid") String uuid); @@ -301,7 +301,7 @@ public interface CloudSigmaAsyncClient { /** * @see CloudSigmaClient#destroyVLAN */ - @POST + @GET @Path("/resources/vlan/{uuid}/destroy") @ExceptionParser(ReturnVoidOnNotFoundOr404.class) ListenableFuture destroyVLAN(@PathParam("uuid") String uuid); @@ -343,7 +343,7 @@ public interface CloudSigmaAsyncClient { /** * @see CloudSigmaClient#destroyStaticIP */ - @POST + @GET @Path("/resources/ip/{uuid}/destroy") @ExceptionParser(ReturnVoidOnNotFoundOr404.class) ListenableFuture destroyStaticIP(@PathParam("uuid") String uuid); diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java index 6772a832d9..51df12ab58 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java @@ -323,7 +323,7 @@ public class CloudSigmaAsyncClientTest extends RestClientTest Date: Fri, 4 Mar 2011 16:14:06 -0500 Subject: [PATCH 09/10] updated savvis to the correct naming convention and maven dependencies --- .../{savvis => savvis-symphony-vpdc}/pom.xml | 17 ++++++++++++----- .../jclouds/savvis/SymphonyVPDCAsyncClient.java | 1 - .../org/jclouds/savvis/SymphonyVPDCClient.java | 0 .../savvis/SymphonyVPDCContextBuilder.java | 0 .../savvis/SymphonyVPDCPropertiesBuilder.java | 0 ...SymphonyVPDCComputeServiceContextModule.java | 0 .../config/SymphonyVPDCRestClientModule.java | 0 .../handlers/SymphonyVPDCErrorHandler.java | 0 .../domain/network/SymphonyVPDCNetwork.java | 0 .../internal/SymphonyVPDCNetworkImpl.java | 0 .../savvis/xml/SymphonyVPDCNetworkHandler.java | 0 .../savvis/xml/SymphonyVPDCVAppHandler.java | 0 .../savvis/SymphonyVPDCAsyncClientTest.java | 9 ++++----- .../savvis/SymphonyVPDCClientLiveTest.java | 0 .../handlers/SymphonyVPDCErrorHandlerTest.java | 0 .../SymphonyVPDCComputeServiceLiveTest.java | 0 16 files changed, 16 insertions(+), 11 deletions(-) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/pom.xml (94%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java (99%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/main/java/org/jclouds/savvis/SymphonyVPDCClient.java (100%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/main/java/org/jclouds/savvis/SymphonyVPDCContextBuilder.java (100%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/main/java/org/jclouds/savvis/SymphonyVPDCPropertiesBuilder.java (100%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/main/java/org/jclouds/savvis/compute/config/SymphonyVPDCComputeServiceContextModule.java (100%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/main/java/org/jclouds/savvis/config/SymphonyVPDCRestClientModule.java (100%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/main/java/org/jclouds/savvis/handlers/SymphonyVPDCErrorHandler.java (100%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/main/java/org/jclouds/vcloud/domain/network/SymphonyVPDCNetwork.java (100%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/main/java/org/jclouds/vcloud/domain/network/internal/SymphonyVPDCNetworkImpl.java (100%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCNetworkHandler.java (100%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCVAppHandler.java (100%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/test/java/org/jclouds/savvis/SymphonyVPDCAsyncClientTest.java (99%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/test/java/org/jclouds/savvis/SymphonyVPDCClientLiveTest.java (100%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/test/java/org/jclouds/savvis/handlers/SymphonyVPDCErrorHandlerTest.java (100%) rename sandbox-providers/{savvis => savvis-symphony-vpdc}/src/test/java/org/jclouds/vcloud/savvis/compute/SymphonyVPDCComputeServiceLiveTest.java (100%) diff --git a/sandbox-providers/savvis/pom.xml b/sandbox-providers/savvis-symphony-vpdc/pom.xml similarity index 94% rename from sandbox-providers/savvis/pom.xml rename to sandbox-providers/savvis-symphony-vpdc/pom.xml index 9b739298d0..d9c357c863 100644 --- a/sandbox-providers/savvis/pom.xml +++ b/sandbox-providers/savvis-symphony-vpdc/pom.xml @@ -31,7 +31,7 @@ ../../project/pom.xml org.jclouds.provider - savvis + savvis-symphony-vpdc jclouds savvis core jclouds components to access savvis @@ -59,13 +59,13 @@ - org.jclouds - jclouds-vcloud + org.jclouds.api + vcloudexpress ${project.version} - org.jclouds - jclouds-core + org.jclouds.api + vcloudexpress ${project.version} test-jar test @@ -84,6 +84,13 @@ test-jar test + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + org.jclouds.driver jclouds-jsch diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java similarity index 99% rename from sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java index 867f000d1f..09d81b1942 100644 --- a/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java @@ -30,7 +30,6 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.vcloud.CommonVCloudClient; -import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudExpressAsyncClient; import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.VCloudExpressVApp; diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCClient.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCClient.java similarity index 100% rename from sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCClient.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCClient.java diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCContextBuilder.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCContextBuilder.java similarity index 100% rename from sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCContextBuilder.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCContextBuilder.java diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCPropertiesBuilder.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCPropertiesBuilder.java similarity index 100% rename from sandbox-providers/savvis/src/main/java/org/jclouds/savvis/SymphonyVPDCPropertiesBuilder.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCPropertiesBuilder.java diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/compute/config/SymphonyVPDCComputeServiceContextModule.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/compute/config/SymphonyVPDCComputeServiceContextModule.java similarity index 100% rename from sandbox-providers/savvis/src/main/java/org/jclouds/savvis/compute/config/SymphonyVPDCComputeServiceContextModule.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/compute/config/SymphonyVPDCComputeServiceContextModule.java diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/config/SymphonyVPDCRestClientModule.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/config/SymphonyVPDCRestClientModule.java similarity index 100% rename from sandbox-providers/savvis/src/main/java/org/jclouds/savvis/config/SymphonyVPDCRestClientModule.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/config/SymphonyVPDCRestClientModule.java diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/savvis/handlers/SymphonyVPDCErrorHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/handlers/SymphonyVPDCErrorHandler.java similarity index 100% rename from sandbox-providers/savvis/src/main/java/org/jclouds/savvis/handlers/SymphonyVPDCErrorHandler.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/handlers/SymphonyVPDCErrorHandler.java diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/domain/network/SymphonyVPDCNetwork.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/domain/network/SymphonyVPDCNetwork.java similarity index 100% rename from sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/domain/network/SymphonyVPDCNetwork.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/domain/network/SymphonyVPDCNetwork.java diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/domain/network/internal/SymphonyVPDCNetworkImpl.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/domain/network/internal/SymphonyVPDCNetworkImpl.java similarity index 100% rename from sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/domain/network/internal/SymphonyVPDCNetworkImpl.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/domain/network/internal/SymphonyVPDCNetworkImpl.java diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCNetworkHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCNetworkHandler.java similarity index 100% rename from sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCNetworkHandler.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCNetworkHandler.java diff --git a/sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCVAppHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCVAppHandler.java similarity index 100% rename from sandbox-providers/savvis/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCVAppHandler.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCVAppHandler.java diff --git a/sandbox-providers/savvis/src/test/java/org/jclouds/savvis/SymphonyVPDCAsyncClientTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/SymphonyVPDCAsyncClientTest.java similarity index 99% rename from sandbox-providers/savvis/src/test/java/org/jclouds/savvis/SymphonyVPDCAsyncClientTest.java rename to sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/SymphonyVPDCAsyncClientTest.java index 3855497930..6941b70844 100644 --- a/sandbox-providers/savvis/src/test/java/org/jclouds/savvis/SymphonyVPDCAsyncClientTest.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/SymphonyVPDCAsyncClientTest.java @@ -50,8 +50,10 @@ import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.savvis.config.SymphonyVPDCRestClientModule; import org.jclouds.util.Strings2; import org.jclouds.vcloud.CommonVCloudClient; -import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.VCloudExpressAsyncClient; +import org.jclouds.vcloud.VCloudExpressLoginAsyncClient; import org.jclouds.vcloud.VCloudExpressMediaType; +import org.jclouds.vcloud.VCloudVersionsAsyncClient; import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; @@ -85,9 +87,6 @@ import com.google.inject.Injector; import com.google.inject.Module; import com.google.inject.TypeLiteral; -import domain.VCloudExpressLoginAsyncClient; -import domain.VCloudVersionsAsyncClient; - /** * Tests annotation parsing of {@code SymphonyVPDCAsyncClient} * @@ -453,7 +452,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest Date: Fri, 4 Mar 2011 16:49:36 -0500 Subject: [PATCH 10/10] repackaged savvis and got tests passing --- .../{ => vpdc}/SymphonyVPDCAsyncClient.java | 6 +- .../savvis/{ => vpdc}/SymphonyVPDCClient.java | 2 +- .../SymphonyVPDCContextBuilder.java | 6 +- .../SymphonyVPDCPropertiesBuilder.java | 2 +- ...mphonyVPDCComputeServiceContextModule.java | 2 +- .../config/SymphonyVPDCRestClientModule.java | 8 +- .../vpdc/domain}/SymphonyVPDCNetwork.java | 3 +- .../internal/SymphonyVPDCNetworkImpl.java | 6 +- .../handlers/SymphonyVPDCErrorHandler.java | 2 +- .../vpdc}/xml/SymphonyVPDCNetworkHandler.java | 6 +- .../vpdc}/xml/SymphonyVPDCVAppHandler.java | 2 +- .../SymphonyVPDCAsyncClientTest.java | 35 +++-- .../SymphonyVPDCClientLiveTest.java | 15 +- .../SymphonyVPDCComputeServiceLiveTest.java | 57 ++++++++ .../SymphonyVPDCTemplateBuilderLiveTest.java | 77 +++++++++++ .../SymphonyVPDCErrorHandlerTest.java | 2 +- .../SymphonyVPDCComputeServiceLiveTest.java | 128 ------------------ 17 files changed, 178 insertions(+), 181 deletions(-) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/{ => vpdc}/SymphonyVPDCAsyncClient.java (97%) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/{ => vpdc}/SymphonyVPDCClient.java (97%) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/{ => vpdc}/SymphonyVPDCContextBuilder.java (88%) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/{ => vpdc}/SymphonyVPDCPropertiesBuilder.java (97%) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/{ => vpdc}/compute/config/SymphonyVPDCComputeServiceContextModule.java (95%) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/{ => vpdc}/config/SymphonyVPDCRestClientModule.java (92%) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/{vcloud/domain/network => savvis/vpdc/domain}/SymphonyVPDCNetwork.java (95%) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/{vcloud/domain/network => savvis/vpdc/domain}/internal/SymphonyVPDCNetworkImpl.java (97%) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/{ => vpdc}/handlers/SymphonyVPDCErrorHandler.java (98%) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/{vcloud/savvis => savvis/vpdc}/xml/SymphonyVPDCNetworkHandler.java (96%) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/{vcloud/savvis => savvis/vpdc}/xml/SymphonyVPDCVAppHandler.java (99%) rename sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/{ => vpdc}/SymphonyVPDCAsyncClientTest.java (97%) rename sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/{ => vpdc}/SymphonyVPDCClientLiveTest.java (72%) create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCComputeServiceLiveTest.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCTemplateBuilderLiveTest.java rename sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/{ => vpdc}/handlers/SymphonyVPDCErrorHandlerTest.java (98%) delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/vcloud/savvis/compute/SymphonyVPDCComputeServiceLiveTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClient.java similarity index 97% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClient.java index 09d81b1942..a0ebf6572c 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCAsyncClient.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClient.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.savvis; +package org.jclouds.savvis.vpdc; import java.net.URI; @@ -29,6 +29,8 @@ import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.savvis.vpdc.xml.SymphonyVPDCNetworkHandler; +import org.jclouds.savvis.vpdc.xml.SymphonyVPDCVAppHandler; import org.jclouds.vcloud.CommonVCloudClient; import org.jclouds.vcloud.VCloudExpressAsyncClient; import org.jclouds.vcloud.domain.Org; @@ -39,8 +41,6 @@ import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; -import org.jclouds.vcloud.savvis.xml.SymphonyVPDCNetworkHandler; -import org.jclouds.vcloud.savvis.xml.SymphonyVPDCVAppHandler; import org.jclouds.vcloud.xml.OrgHandler; import org.jclouds.vcloud.xml.VDCHandler; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCClient.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCClient.java similarity index 97% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCClient.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCClient.java index e6f1f1bf4d..04a012f2ad 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCClient.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCClient.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.savvis; +package org.jclouds.savvis.vpdc; import java.util.concurrent.TimeUnit; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCContextBuilder.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCContextBuilder.java similarity index 88% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCContextBuilder.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCContextBuilder.java index 2b60e557ed..aa06ef4c39 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCContextBuilder.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCContextBuilder.java @@ -17,14 +17,14 @@ * ==================================================================== */ -package org.jclouds.savvis; +package org.jclouds.savvis.vpdc; import java.util.List; import java.util.Properties; import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.savvis.compute.config.SymphonyVPDCComputeServiceContextModule; -import org.jclouds.savvis.config.SymphonyVPDCRestClientModule; +import org.jclouds.savvis.vpdc.compute.config.SymphonyVPDCComputeServiceContextModule; +import org.jclouds.savvis.vpdc.config.SymphonyVPDCRestClientModule; import com.google.inject.Module; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCPropertiesBuilder.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCPropertiesBuilder.java similarity index 97% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCPropertiesBuilder.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCPropertiesBuilder.java index c0307f28ab..4240562f46 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/SymphonyVPDCPropertiesBuilder.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCPropertiesBuilder.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.savvis; +package org.jclouds.savvis.vpdc; import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_ENDPOINT; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/compute/config/SymphonyVPDCComputeServiceContextModule.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/SymphonyVPDCComputeServiceContextModule.java similarity index 95% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/compute/config/SymphonyVPDCComputeServiceContextModule.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/SymphonyVPDCComputeServiceContextModule.java index 932143c28b..ce962be795 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/compute/config/SymphonyVPDCComputeServiceContextModule.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/SymphonyVPDCComputeServiceContextModule.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.savvis.compute.config; +package org.jclouds.savvis.vpdc.compute.config; import org.jclouds.vcloud.compute.config.VCloudExpressComputeServiceContextModule; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/config/SymphonyVPDCRestClientModule.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/SymphonyVPDCRestClientModule.java similarity index 92% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/config/SymphonyVPDCRestClientModule.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/SymphonyVPDCRestClientModule.java index 69427500dd..24d40457b7 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/config/SymphonyVPDCRestClientModule.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/SymphonyVPDCRestClientModule.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.savvis.config; +package org.jclouds.savvis.vpdc.config; import java.net.URI; @@ -27,9 +27,9 @@ import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; -import org.jclouds.savvis.SymphonyVPDCAsyncClient; -import org.jclouds.savvis.SymphonyVPDCClient; -import org.jclouds.savvis.handlers.SymphonyVPDCErrorHandler; +import org.jclouds.savvis.vpdc.SymphonyVPDCAsyncClient; +import org.jclouds.savvis.vpdc.SymphonyVPDCClient; +import org.jclouds.savvis.vpdc.handlers.SymphonyVPDCErrorHandler; import org.jclouds.vcloud.VCloudExpressAsyncClient; import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.config.BaseVCloudExpressRestClientModule; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/domain/network/SymphonyVPDCNetwork.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/SymphonyVPDCNetwork.java similarity index 95% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/domain/network/SymphonyVPDCNetwork.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/SymphonyVPDCNetwork.java index bddf4bc766..818ac64e9a 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/domain/network/SymphonyVPDCNetwork.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/SymphonyVPDCNetwork.java @@ -17,13 +17,14 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain.network; +package org.jclouds.savvis.vpdc.domain; import java.util.Set; import javax.annotation.Nullable; import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.network.FenceMode; import org.jclouds.vcloud.domain.network.firewall.FirewallRule; import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/domain/network/internal/SymphonyVPDCNetworkImpl.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/SymphonyVPDCNetworkImpl.java similarity index 97% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/domain/network/internal/SymphonyVPDCNetworkImpl.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/SymphonyVPDCNetworkImpl.java index 9cdc3a236b..19510622fd 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/domain/network/internal/SymphonyVPDCNetworkImpl.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/SymphonyVPDCNetworkImpl.java @@ -17,17 +17,17 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain.network.internal; +package org.jclouds.savvis.vpdc.domain.internal; import java.net.URI; import java.util.Set; import javax.annotation.Nullable; +import org.jclouds.savvis.vpdc.domain.SymphonyVPDCNetwork; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.SymphonyVPDCNetwork; import org.jclouds.vcloud.domain.network.firewall.FirewallRule; import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule; @@ -151,7 +151,7 @@ public class SymphonyVPDCNetworkImpl extends ReferenceTypeImpl implements Sympho return false; if (getClass() != obj.getClass()) return false; - VCloudExpressNetworkImpl other = (VCloudExpressNetworkImpl) obj; + SymphonyVPDCNetworkImpl other = (SymphonyVPDCNetworkImpl) obj; if (description == null) { if (other.description != null) return false; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/handlers/SymphonyVPDCErrorHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/SymphonyVPDCErrorHandler.java similarity index 98% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/handlers/SymphonyVPDCErrorHandler.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/SymphonyVPDCErrorHandler.java index 74b72ed5d2..6a667705cb 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/handlers/SymphonyVPDCErrorHandler.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/SymphonyVPDCErrorHandler.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.savvis.handlers; +package org.jclouds.savvis.vpdc.handlers; import java.io.IOException; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCNetworkHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCNetworkHandler.java similarity index 96% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCNetworkHandler.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCNetworkHandler.java index 1c698dc3e8..ce31f2f95f 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCNetworkHandler.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCNetworkHandler.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.vcloud.savvis.xml; +package org.jclouds.savvis.vpdc.xml; import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; @@ -29,12 +29,12 @@ import javax.annotation.Resource; import org.jclouds.http.functions.ParseSax; import org.jclouds.logging.Logger; +import org.jclouds.savvis.vpdc.domain.SymphonyVPDCNetwork; +import org.jclouds.savvis.vpdc.domain.internal.SymphonyVPDCNetworkImpl; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.SymphonyVPDCNetwork; import org.jclouds.vcloud.domain.network.firewall.FirewallPolicy; import org.jclouds.vcloud.domain.network.firewall.FirewallRule; -import org.jclouds.vcloud.domain.network.internal.SymphonyVPDCNetworkImpl; import org.jclouds.vcloud.domain.network.nat.NatProtocol; import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule; import org.xml.sax.Attributes; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCVAppHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVAppHandler.java similarity index 99% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCVAppHandler.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVAppHandler.java index 630c9f7a3c..5e56a0ccc5 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/vcloud/savvis/xml/SymphonyVPDCVAppHandler.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVAppHandler.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.vcloud.savvis.xml; +package org.jclouds.savvis.vpdc.xml; import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.vcloud.util.Utils.cleanseAttributes; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/SymphonyVPDCAsyncClientTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClientTest.java similarity index 97% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/SymphonyVPDCAsyncClientTest.java rename to sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClientTest.java index 6941b70844..79c6e9c0f8 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/SymphonyVPDCAsyncClientTest.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClientTest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.savvis; +package org.jclouds.savvis.vpdc; import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_IDENTITY; @@ -47,7 +47,9 @@ import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; -import org.jclouds.savvis.config.SymphonyVPDCRestClientModule; +import org.jclouds.savvis.vpdc.config.SymphonyVPDCRestClientModule; +import org.jclouds.savvis.vpdc.xml.SymphonyVPDCNetworkHandler; +import org.jclouds.savvis.vpdc.xml.SymphonyVPDCVAppHandler; import org.jclouds.util.Strings2; import org.jclouds.vcloud.CommonVCloudClient; import org.jclouds.vcloud.VCloudExpressAsyncClient; @@ -71,7 +73,6 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.xml.CatalogHandler; import org.jclouds.vcloud.xml.CatalogItemHandler; import org.jclouds.vcloud.xml.OrgHandler; -import org.jclouds.vcloud.xml.OrgNetworkFromVCloudExpressNetworkHandler; import org.jclouds.vcloud.xml.TaskHandler; import org.jclouds.vcloud.xml.TasksListHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; @@ -136,10 +137,9 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest createContextSpec() { Properties restProperties = new Properties(); - restProperties - .setProperty("savvis-symphony-vpdc.contextbuilder", "org.jclouds.savvis.SymphonyVPDCContextBuilder"); + restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName()); restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder", - "org.jclouds.savvis.SymphonyVPDCPropertiesBuilder"); + SymphonyVPDCPropertiesBuilder.class.getName()); Properties overrides = new Properties(); overrides.setProperty("savvis-symphony-vpdc.endpoint", diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/SymphonyVPDCClientLiveTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCClientLiveTest.java similarity index 72% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/SymphonyVPDCClientLiveTest.java rename to sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCClientLiveTest.java index 09ad7499ce..fc5c96e998 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/SymphonyVPDCClientLiveTest.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCClientLiveTest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.savvis; +package org.jclouds.savvis.vpdc; import java.util.Properties; @@ -42,22 +42,13 @@ public class SymphonyVPDCClientLiveTest extends VCloudExpressClientLiveTest { // TODO remove these lines when this is registered under jclouds-core/rest.properties Properties restProperties = new Properties(); - restProperties - .setProperty("savvis-symphony-vpdc.contextbuilder", "org.jclouds.savvis.SymphonyVPDCContextBuilder"); + restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName()); restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder", - "org.jclouds.savvis.SymphonyVPDCPropertiesBuilder"); + SymphonyVPDCPropertiesBuilder.class.getName()); context = new ComputeServiceContextFactory(restProperties).createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); connection = context.getApi(); - - System.out.println(context); - /*System.out.println(connection); - Org org = connection.getOrg(URI.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/607968.0")); - System.out.println(connection.getVDC(URI.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/607968.0/vdc/2826")).getAvailableNetworks()); - System.out.println(org.getVDCs().get(0)); - System.out.println(org.getTasksList()); - System.out.println(org.getTasks());*/ } } \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCComputeServiceLiveTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCComputeServiceLiveTest.java new file mode 100644 index 0000000000..34fa9efc0b --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCComputeServiceLiveTest.java @@ -0,0 +1,57 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.savvis.vpdc.compute; + +import java.util.Properties; + +import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.savvis.vpdc.SymphonyVPDCContextBuilder; +import org.jclouds.savvis.vpdc.SymphonyVPDCPropertiesBuilder; +import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.testng.annotations.Test; + +/** + * + * + * @author Kedar Dave + */ +@Test(groups = "live", enabled = true, sequential = true) +public class SymphonyVPDCComputeServiceLiveTest extends BaseComputeServiceLiveTest { + public SymphonyVPDCComputeServiceLiveTest() { + provider = "savvis-symphony-vpdc"; + group = "savvis.jclouds"; + } + + @Override + protected Properties getRestProperties() { + // TODO remove these lines when this is registered under jclouds-core/rest.properties + Properties restProperties = new Properties(); + restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName()); + restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder", + SymphonyVPDCPropertiesBuilder.class.getName()); + return restProperties; + } + + @Override + protected JschSshClientModule getSshModule() { + return new JschSshClientModule(); + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCTemplateBuilderLiveTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCTemplateBuilderLiveTest.java new file mode 100644 index 0000000000..21082ea684 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCTemplateBuilderLiveTest.java @@ -0,0 +1,77 @@ +package org.jclouds.savvis.vpdc.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; +import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.savvis.vpdc.SymphonyVPDCContextBuilder; +import org.jclouds.savvis.vpdc.SymphonyVPDCPropertiesBuilder; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live") +public class SymphonyVPDCTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + + public SymphonyVPDCTemplateBuilderLiveTest() { + provider = "savvis-symphony-vpdc"; + } + + @Override + @BeforeClass + public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException { + setupCredentials(); + // TODO remove these lines when this is registered under jclouds-core/rest.properties + Properties restProperties = new Properties(); + restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName()); + restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder", + SymphonyVPDCPropertiesBuilder.class.getName()); + + context = new ComputeServiceContextFactory(restProperties).createContext(provider, + ImmutableSet. of(new Log4JLoggingModule()), setupProperties()); + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return new Predicate() { + + @Override + public boolean apply(OsFamilyVersion64Bit input) { + // TODO it seems there are no base vApp Templates available in Savvis + return true; + } + }; + } + + @Test + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = context.getComputeService().templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5.5"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("US-FL", "NL-NH"); + } +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/handlers/SymphonyVPDCErrorHandlerTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/SymphonyVPDCErrorHandlerTest.java similarity index 98% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/handlers/SymphonyVPDCErrorHandlerTest.java rename to sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/SymphonyVPDCErrorHandlerTest.java index d2bccacf28..7faefe658a 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/handlers/SymphonyVPDCErrorHandlerTest.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/SymphonyVPDCErrorHandlerTest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.savvis.handlers; +package org.jclouds.savvis.vpdc.handlers; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.reportMatcher; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/vcloud/savvis/compute/SymphonyVPDCComputeServiceLiveTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/vcloud/savvis/compute/SymphonyVPDCComputeServiceLiveTest.java deleted file mode 100644 index 9361e7d327..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/vcloud/savvis/compute/SymphonyVPDCComputeServiceLiveTest.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * 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.vcloud.savvis.compute; - -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.compute.domain.ComputeMetadata; -import org.jclouds.compute.domain.ComputeType; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.rest.RestContext; -import org.jclouds.savvis.SymphonyVPDCAsyncClient; -import org.jclouds.savvis.SymphonyVPDCClient; -import org.jclouds.ssh.jsch.config.JschSshClientModule; -import org.jclouds.vcloud.domain.VCloudExpressVApp; -import org.testng.annotations.Test; - -/** - * - * - * @author Kedar Dave - */ -@Test(groups = "live", enabled = true, sequential = true) -public class SymphonyVPDCComputeServiceLiveTest extends BaseComputeServiceLiveTest { - public SymphonyVPDCComputeServiceLiveTest() { - provider = "savvis-symphony-vpdc"; - } - - @Override - public void setServiceDefaults() { - group = "savvis.jclouds"; - } - - @Test - public void testTemplateBuilder() { - Template defaultTemplate = client.templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5.5"); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS); - assert defaultTemplate.getLocation().getDescription() != null;// different per org - assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); - } - - public void testAssignability() throws Exception { - @SuppressWarnings("unused") - RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); - } - - @Override - protected Template buildTemplate(TemplateBuilder templateBuilder) { - Template template = super.buildTemplate(templateBuilder); - Image image = template.getImage(); - assert image.getDefaultCredentials() != null && image.getDefaultCredentials().identity != null : image; - assert image.getDefaultCredentials() != null && image.getDefaultCredentials().credential != null : image; - return template; - } - - // currently, the wrong CIM OSType data is coming back. - @Override - protected void checkOsMatchesTemplate(NodeMetadata node) { - if (node.getOperatingSystem() != null) - assertEquals(node.getOperatingSystem().getFamily(), null); - } - - @Override - public void testListImages() throws Exception { - for (Image image : client.listImages()) { - assert image.getProviderId() != null : image; - // image.getLocationId() can be null, if it is a location-free image - assertEquals(image.getType(), ComputeType.IMAGE); - if (image.getOperatingSystem().getFamily() != OsFamily.WINDOWS - && image.getOperatingSystem().getFamily() != OsFamily.SOLARIS) { - assert image.getDefaultCredentials() != null && image.getDefaultCredentials().identity != null : image; - assert image.getDefaultCredentials().credential != null : image; - } - } - } - - @Override - public void testListNodes() throws Exception { - for (ComputeMetadata node : client.listNodes()) { - assert node.getProviderId() != null; - assert node.getLocation() != null; - assertEquals(node.getType(), ComputeType.NODE); - NodeMetadata allData = client.getNodeMetadata(node.getId()); - System.out.println(allData.getHardware()); - RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); - VCloudExpressVApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(null, null, allData.getName()); - assertEquals(vApp.getName(), allData.getName()); - } - } - - @Override - public void testDestroyNodes() { - super.testDestroyNodes(); - } - - @Override - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); - } - -} \ No newline at end of file