You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/08/20 11:35:47 UTC
[01/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Repository: stratos
Updated Branches:
refs/heads/master d1a5ce4ae -> b45ae00e3
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vapp-pool.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vapp-pool.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vapp-pool.xml
new file mode 100644
index 0000000..1ac8ff3
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vapp-pool.xml
@@ -0,0 +1,227 @@
+<VApp xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" deployed="true" status="4" name="my-appExample" type="application/vnd.vmware.vcloud.vApp+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_VirtualSystemSettingData.xsd http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd http://www.vmware.com/vcloud/v1 http://1.1.1.1/api/v1.0/sch
ema/master.xsd">
+ <Link rel="power:powerOff" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/power/action/powerOff"/>
+ <Link rel="power:reboot" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/power/action/reboot"/>
+ <Link rel="power:reset" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/power/action/reset"/>
+ <Link rel="power:shutdown" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/power/action/shutdown"/>
+ <Link rel="power:suspend" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/power/action/suspend"/>
+ <Link rel="deploy" type="application/vnd.vmware.vcloud.deployVAppParams+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/action/deploy"/>
+ <Link rel="undeploy" type="application/vnd.vmware.vcloud.undeployVAppParams+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/action/undeploy"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.controlAccess+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/controlAccess/"/>
+ <Link rel="controlAccess" type="application/vnd.vmware.vcloud.controlAccess+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/action/controlAccess"/>
+ <Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml" href="https://1.1.1.1/api/v1.0/vdc/1"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.vApp+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1"/>
+ <Description>Example FTP Server vApp</Description>
+ <LeaseSettingsSection type="application/vnd.vmware.vcloud.leaseSettingsSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/leaseSettingsSection/" ovf:required="false">
+ <ovf:Info>Lease settings section</ovf:Info>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.leaseSettingsSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/leaseSettingsSection/"/>
+ <DeploymentLeaseInSeconds>0</DeploymentLeaseInSeconds>
+ <StorageLeaseInSeconds>0</StorageLeaseInSeconds>
+ </LeaseSettingsSection>
+ <ovf:StartupSection xmlns:vcloud="http://www.vmware.com/vcloud/v1" vcloud:href="https://1.1.1.1/api/v1.0/vApp/vapp-1/startupSection/" vcloud:type="application/vnd.vmware.vcloud.startupSection+xml">
+ <ovf:Info>VApp startup section</ovf:Info>
+ <ovf:Item ovf:stopDelay="0" ovf:stopAction="powerOff" ovf:startDelay="0" ovf:startAction="powerOn" ovf:order="0" ovf:id="my-app"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.startupSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/startupSection/"/>
+ </ovf:StartupSection>
+ <ovf:NetworkSection xmlns:vcloud="http://www.vmware.com/vcloud/v1" vcloud:href="https://1.1.1.1/api/v1.0/vApp/vapp-1/networkSection/" vcloud:type="application/vnd.vmware.vcloud.networkSection+xml">
+ <ovf:Info>The list of logical networks</ovf:Info>
+ <ovf:Network ovf:name="Direct">
+ <ovf:Description/>
+ </ovf:Network>
+ </ovf:NetworkSection>
+ <NetworkConfigSection type="application/vnd.vmware.vcloud.networkConfigSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/networkConfigSection/" ovf:required="false">
+ <ovf:Info>The configuration parameters for logical networks</ovf:Info>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.networkConfigSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/networkConfigSection/"/>
+ <NetworkConfig networkName="Direct">
+ <Description/>
+ <Configuration>
+ <IpScope>
+ <IsInherited>true</IsInherited>
+ <Gateway>172.16.7.1</Gateway>
+ <Netmask>255.255.255.0</Netmask>
+ <Dns1>1.1.1.2</Dns1>
+ <Dns2>1.1.1.3</Dns2>
+ <IpRanges>
+ <IpRange>
+ <StartAddress>172.16.7.230</StartAddress>
+ <EndAddress>172.16.7.239</EndAddress>
+ </IpRange>
+ </IpRanges>
+ </IpScope>
+ <ParentNetwork type="application/vnd.vmware.vcloud.network+xml" name="Direct" href="https://1.1.1.1/api/v1.0/network/282371363"/>
+ <FenceMode>bridged</FenceMode>
+ <Features>
+ <DhcpService>
+ <IsEnabled>false</IsEnabled>
+ <DefaultLeaseTime>3600</DefaultLeaseTime>
+ <MaxLeaseTime>7200</MaxLeaseTime>
+ <IpRange>
+ <StartAddress>172.16.7.2</StartAddress>
+ <EndAddress>172.16.7.229</EndAddress>
+ </IpRange>
+ </DhcpService>
+ <FirewallService>
+ <IsEnabled>true</IsEnabled>
+ </FirewallService>
+ <NatService>
+ <IsEnabled>true</IsEnabled>
+ <NatType>ipTranslation</NatType>
+ <Policy>allowTraffic</Policy>
+ <NatRule>
+ <OneToOneVmRule>
+ <MappingMode>automatic</MappingMode>
+ <VAppScopedVmId>100c208b-4f43-40bb-98d6-a046f6e48c3a</VAppScopedVmId>
+ <VmNicId>0</VmNicId>
+ </OneToOneVmRule>
+ </NatRule>
+ </NatService>
+ </Features>
+ </Configuration>
+ <IsDeployed>true</IsDeployed>
+ </NetworkConfig>
+ </NetworkConfigSection>
+ <Children>
+ <Vm deployed="true" status="4" name="my-app" type="application/vnd.vmware.vcloud.vm+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1">
+ <Link rel="power:powerOff" href="https://1.1.1.1/api/v1.0/vApp/vm-1/power/action/powerOff"/>
+ <Link rel="power:reboot" href="https://1.1.1.1/api/v1.0/vApp/vm-1/power/action/reboot"/>
+ <Link rel="power:reset" href="https://1.1.1.1/api/v1.0/vApp/vm-1/power/action/reset"/>
+ <Link rel="power:shutdown" href="https://1.1.1.1/api/v1.0/vApp/vm-1/power/action/shutdown"/>
+ <Link rel="power:suspend" href="https://1.1.1.1/api/v1.0/vApp/vm-1/power/action/suspend"/>
+ <Link rel="undeploy" type="application/vnd.vmware.vcloud.undeployVAppParams+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/action/undeploy"/>
+ <Link rel="up" type="application/vnd.vmware.vcloud.vApp+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.vm+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1"/>
+ <Link rel="screen:thumbnail" href="https://1.1.1.1/api/v1.0/vApp/vm-1/screen"/>
+ <Link rel="screen:acquireTicket" href="https://1.1.1.1/api/v1.0/vApp/vm-1/screen/action/acquireTicket"/>
+ <Link rel="media:insertMedia" type="application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/media/action/insertMedia"/>
+ <Link rel="media:ejectMedia" type="application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/media/action/ejectMedia"/>
+ <Description/>
+ <ovf:VirtualHardwareSection xmlns:vcloud="http://www.vmware.com/vcloud/v1" vcloud:href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/" vcloud:type="application/vnd.vmware.vcloud.virtualHardwareSection+xml">
+ <ovf:Info>Virtual hardware requirements</ovf:Info>
+ <ovf:System>
+ <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
+ <vssd:InstanceID>0</vssd:InstanceID>
+ <vssd:VirtualSystemIdentifier>my-app</vssd:VirtualSystemIdentifier>
+ <vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>
+ </ovf:System>
+ <ovf:Item>
+ <rasd:Address>00:50:56:01:02:33</rasd:Address>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
+ <rasd:Connection vcloud:ipAddress="172.16.7.230" vcloud:primaryNetworkConnection="true" vcloud:ipAddressingMode="POOL">Direct</rasd:Connection>
+ <rasd:Description>PCNet32 ethernet adapter</rasd:Description>
+ <rasd:ElementName>Network adapter 0</rasd:ElementName>
+ <rasd:InstanceID>1</rasd:InstanceID>
+ <rasd:ResourceSubType>PCNet32</rasd:ResourceSubType>
+ <rasd:ResourceType>10</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>SCSI Controller</rasd:Description>
+ <rasd:ElementName>SCSI Controller 0</rasd:ElementName>
+ <rasd:InstanceID>2</rasd:InstanceID>
+ <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
+ <rasd:ResourceType>6</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:Description>Hard disk</rasd:Description>
+ <rasd:ElementName>Hard disk 1</rasd:ElementName>
+ <rasd:HostResource vcloud:capacity="15360" vcloud:busType="6" vcloud:busSubType="lsilogic"/>
+ <rasd:InstanceID>2000</rasd:InstanceID>
+ <rasd:Parent>2</rasd:Parent>
+ <rasd:ResourceType>17</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>IDE Controller</rasd:Description>
+ <rasd:ElementName>IDE Controller 0</rasd:ElementName>
+ <rasd:InstanceID>3</rasd:InstanceID>
+ <rasd:ResourceType>5</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:Description>CD/DVD Drive</rasd:Description>
+ <rasd:ElementName>CD/DVD Drive 1</rasd:ElementName>
+ <rasd:HostResource/>
+ <rasd:InstanceID>3002</rasd:InstanceID>
+ <rasd:Parent>3</rasd:Parent>
+ <rasd:ResourceType>15</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:Description>Floppy Drive</rasd:Description>
+ <rasd:ElementName>Floppy Drive 1</rasd:ElementName>
+ <rasd:HostResource/>
+ <rasd:InstanceID>8000</rasd:InstanceID>
+ <rasd:ResourceType>14</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item vcloud:href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/cpu" vcloud:type="application/vnd.vmware.vcloud.rasdItem+xml">
+ <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
+ <rasd:Description>Number of Virtual CPUs</rasd:Description>
+ <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
+ <rasd:InstanceID>4</rasd:InstanceID>
+ <rasd:Reservation>0</rasd:Reservation>
+ <rasd:ResourceType>3</rasd:ResourceType>
+ <rasd:VirtualQuantity>1</rasd:VirtualQuantity>
+ <rasd:Weight>0</rasd:Weight>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/cpu"/>
+ </ovf:Item>
+ <ovf:Item vcloud:href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/memory" vcloud:type="application/vnd.vmware.vcloud.rasdItem+xml">
+ <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
+ <rasd:Description>Memory Size</rasd:Description>
+ <rasd:ElementName>2048 MB of memory</rasd:ElementName>
+ <rasd:InstanceID>5</rasd:InstanceID>
+ <rasd:Reservation>0</rasd:Reservation>
+ <rasd:ResourceType>4</rasd:ResourceType>
+ <rasd:VirtualQuantity>2048</rasd:VirtualQuantity>
+ <rasd:Weight>0</rasd:Weight>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/memory"/>
+ </ovf:Item>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.virtualHardwareSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/cpu"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/cpu"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/memory"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/memory"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.rasdItemsList+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/disks"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItemsList+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/disks"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.rasdItemsList+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/media"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.rasdItemsList+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/networkCards"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItemsList+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/networkCards"/>
+ </ovf:VirtualHardwareSection>
+ <ovf:OperatingSystemSection xmlns:vcloud="http://www.vmware.com/vcloud/v1" xmlns:vmw="http://www.vmware.com/schema/ovf" ovf:id="80" vcloud:href="https://1.1.1.1/api/v1.0/vApp/vm-1/operatingSystemSection/" vcloud:type="application/vnd.vmware.vcloud.operatingSystemSection+xml" vmw:osType="rhel5_64Guest">
+ <ovf:Info>Specifies the operating system installed</ovf:Info>
+ <ovf:Description>Red Hat Enterprise Linux 5 (64-bit)</ovf:Description>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.operatingSystemSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/operatingSystemSection/"/>
+ </ovf:OperatingSystemSection>
+ <NetworkConnectionSection type="application/vnd.vmware.vcloud.networkConnectionSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/networkConnectionSection/" ovf:required="false">
+ <ovf:Info>Specifies the available VM network connections</ovf:Info>
+ <PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
+ <NetworkConnection network="Direct">
+ <NetworkConnectionIndex>0</NetworkConnectionIndex>
+ <IpAddress>172.16.7.230</IpAddress>
+ <IsConnected>true</IsConnected>
+ <MACAddress>00:50:56:01:02:33</MACAddress>
+ <IpAddressAllocationMode>POOL</IpAddressAllocationMode>
+ </NetworkConnection>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.networkConnectionSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/networkConnectionSection/"/>
+ </NetworkConnectionSection>
+ <GuestCustomizationSection type="application/vnd.vmware.vcloud.guestCustomizationSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/guestCustomizationSection/" ovf:required="false">
+ <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
+ <Enabled>true</Enabled>
+ <ChangeSid>false</ChangeSid>
+ <VirtualMachineId>1</VirtualMachineId>
+ <JoinDomainEnabled>false</JoinDomainEnabled>
+ <UseOrgSettings>false</UseOrgSettings>
+ <AdminPasswordEnabled>true</AdminPasswordEnabled>
+ <AdminPasswordAuto>true</AdminPasswordAuto>
+ <AdminPassword>Favor</AdminPassword>
+ <ResetPasswordRequired>false</ResetPasswordRequired>
+ <CustomizationScript/>
+ <ComputerName>my-app</ComputerName>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.guestCustomizationSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/guestCustomizationSection/"/>
+ </GuestCustomizationSection>
+ <VAppScopedLocalId>100c208b-4f43-40bb-98d6-a046f6e48c3a</VAppScopedLocalId>
+ </Vm>
+ </Children>
+</VApp>
[30/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIP.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIP.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIP.java
new file mode 100644
index 0000000..ae62625
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIP.java
@@ -0,0 +1,492 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * A Neutron LBaaS v1 VIP.
+ */
+public class VIP {
+
+ // Mandatory attributes when creating
+ @Named("tenant_id")
+ private String tenantId;
+ @Named("subnet_id")
+ private String subnetId;
+ private Protocol protocol;
+ @Named("protocol_port")
+ private Integer protocolPort;
+ // Mandatory attributes that can be updated
+ @Named("pool_id")
+ private String poolId;
+ // Optional attributes when creating
+ private String address;
+ // Optional attributes that can be updated
+ private String name;
+ private String description;
+ @Named("session_persistence")
+ private SessionPersistence sessionPersistence;
+ @Named("connection_limit")
+ private Integer connectionLimit;
+ @Named("admin_state_up")
+ private Boolean adminStateUp;
+ // Read-only attributes
+ private String id;
+ @Named("port_id")
+ private String portId;
+ private LBaaSStatus status;
+ @Named("status_description")
+ private String statusDescription;
+
+ /**
+ * Deserialization constructor.
+ */
+ @ConstructorProperties({ "id", "tenant_id", "name", "description", "subnet_id", "address", "port_id", "protocol",
+ "protocol_port", "pool_id", "session_persistence", "connection_limit", "admin_state_up", "status",
+ "status_description" })
+ private VIP(String id, String tenantId, String name, String description, String subnetId, String address,
+ String portId, Protocol protocol, Integer protocolPort, String poolId, SessionPersistence sessionPersistence,
+ Integer connectionLimit, Boolean adminStateUp, LBaaSStatus status, String statusDescription) {
+ this.id = id;
+ this.tenantId = tenantId;
+ this.name = name;
+ this.description = description;
+ this.subnetId = subnetId;
+ this.address = address;
+ this.portId = portId;
+ this.protocol = protocol;
+ this.protocolPort = protocolPort;
+ this.poolId = poolId;
+ this.sessionPersistence = sessionPersistence;
+ this.connectionLimit = connectionLimit;
+ this.adminStateUp = adminStateUp;
+ this.status = status;
+ this.statusDescription = statusDescription;
+ }
+
+ /**
+ * Default constructor.
+ */
+ private VIP() {
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param VIP the VIP to copy from.
+ */
+ private VIP(VIP vip) {
+ this(vip.id, vip.tenantId, vip.name, vip.description, vip.subnetId, vip.address, vip.portId, vip.protocol,
+ vip.protocolPort, vip.poolId, vip.sessionPersistence, vip.connectionLimit, vip.adminStateUp, vip.status,
+ vip.statusDescription);
+ }
+
+ /**
+ * @return the id of the VIP.
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the tenant id of the VIP.
+ */
+ @Nullable
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return the name of the VIP.
+ */
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the description of the VIP.
+ */
+ @Nullable
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @return the subnet id for this VIP.
+ */
+ @Nullable
+ public String getSubnetId() {
+ return subnetId;
+ }
+
+ /**
+ * @return the address for this VIP.
+ */
+ @Nullable
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * @return the port id for this VIP.
+ */
+ @Nullable
+ public String getPortId() {
+ return portId;
+ }
+
+ /**
+ * @return the protocol for this VIP.
+ */
+ @Nullable
+ public Protocol getProtocol() {
+ return protocol;
+ }
+
+ /**
+ * @return the protocol port for this VIP.
+ */
+ @Nullable
+ public Integer getProtocolPort() {
+ return protocolPort;
+ }
+
+ /**
+ * @return the pool id for this VIP.
+ */
+ @Nullable
+ public String getPoolId() {
+ return poolId;
+ }
+
+ /**
+ * @return the session persistence for this VIP.
+ */
+ @Nullable
+ public SessionPersistence getSessionPersistence() {
+ return sessionPersistence;
+ }
+
+ /**
+ * @return the connection limit for this VIP.
+ */
+ @Nullable
+ public Integer getConnectionLimit() {
+ return connectionLimit;
+ }
+
+ /**
+ * @return the administrative state for this VIP.
+ */
+ @Nullable
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the status for this VIP.
+ */
+ @Nullable
+ public LBaaSStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @return the status description for this VIP.
+ */
+ @Nullable
+ public String getStatusDescription() {
+ return statusDescription;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ VIP that = (VIP) o;
+
+ return Objects.equal(this.id, that.id) && Objects.equal(this.tenantId, that.tenantId)
+ && Objects.equal(this.name, that.name) && Objects.equal(this.description, that.description)
+ && Objects.equal(this.subnetId, that.subnetId) && Objects.equal(this.address, that.address)
+ && Objects.equal(this.portId, that.portId) && Objects.equal(this.protocol, that.protocol)
+ && Objects.equal(this.protocolPort, that.protocolPort) && Objects.equal(this.poolId, that.poolId)
+ && Objects.equal(this.sessionPersistence, that.sessionPersistence)
+ && Objects.equal(this.connectionLimit, that.connectionLimit)
+ && Objects.equal(this.adminStateUp, that.adminStateUp) && Objects.equal(this.status, that.status)
+ && Objects.equal(this.statusDescription, that.statusDescription);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, tenantId, name, description, subnetId, address, portId, protocol, protocolPort,
+ poolId, sessionPersistence, connectionLimit, adminStateUp, status, statusDescription);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this).add("id", id).add("tenantId", tenantId).add("name", name)
+ .add("description", description).add("subnetId", subnetId).add("address", address).add("portId", portId)
+ .add("protocol", protocol).add("protocolPort", protocolPort).add("poolId", poolId)
+ .add("sessionPersistence", sessionPersistence).add("connectionLimit", connectionLimit)
+ .add("adminStateUp", adminStateUp).add("status", status).add("statusDescription", statusDescription)
+ .toString();
+ }
+
+ /*
+ * Methods to get the Create and Update builders follow.
+ */
+
+ /**
+ * @return the Builder for creating a new VIP.
+ */
+ public static CreateBuilder createBuilder(String subnetId, Protocol protocol, Integer port, String poolId) {
+ return new CreateBuilder(subnetId, protocol, port, poolId);
+ }
+
+ /**
+ * @return the Builder for updating a VIP.
+ */
+ public static UpdateBuilder updateBuilder() {
+ return new UpdateBuilder();
+ }
+
+ private abstract static class Builder<ParameterizedBuilderType> {
+ protected VIP vip;
+
+ /**
+ * Default constructor.
+ */
+ private Builder() {
+ vip = new VIP();
+ }
+
+ protected abstract ParameterizedBuilderType self();
+
+ /**
+ * Provides the name for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getName()
+ */
+ public ParameterizedBuilderType name(String name) {
+ vip.name = name;
+ return self();
+ }
+
+ /**
+ * Provides the description for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getDescription()
+ */
+ public ParameterizedBuilderType description(String description) {
+ vip.description = description;
+ return self();
+ }
+
+ /**
+ * Provides the pool id for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getPoolId()
+ */
+ public ParameterizedBuilderType poolId(String poolId) {
+ vip.poolId = poolId;
+ return self();
+ }
+
+ /**
+ * Provides the session persistence for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getSessionPersistence()
+ */
+ public ParameterizedBuilderType sessionPersistence(SessionPersistence sessionPersistence) {
+ vip.sessionPersistence = sessionPersistence;
+ return self();
+ }
+
+ /**
+ * Provides the connection limit for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getConnectionLimit()
+ */
+ public ParameterizedBuilderType connectionLimit(Integer connectionLimit) {
+ vip.connectionLimit = connectionLimit;
+ return self();
+ }
+
+ /**
+ * Provides the administrative state for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getAdminStateUp()
+ */
+ public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) {
+ vip.adminStateUp = adminStateUp;
+ return self();
+ }
+ }
+
+ /**
+ * Create builder (inheriting from Builder).
+ */
+ public static class CreateBuilder extends Builder<CreateBuilder> {
+ /**
+ * Supply required properties for creating a VIP's CreateBuilder
+ */
+ private CreateBuilder(String subnetId, Protocol protocol, Integer port, String poolId) {
+ subnetId(subnetId).protocol(protocol).protocolPort(port).poolId(poolId);
+ }
+
+ /**
+ * Provides the tenantId for this VIP's Builder. Admin-only.
+ * When keystone is enabled, it is not mandatory to specify tenant_id for resources in create requests, as the
+ * tenant identifier will be derived from the Authentication token. Please note that the default authorization
+ * settings only allow administrative users to create resources on behalf of a different tenant.
+ *
+ * @return the Builder.
+ * @see VIP#getTenantId()
+ */
+ public CreateBuilder tenantId(String tenantId) {
+ vip.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * Provides the subnet id for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getSubnetId()
+ */
+ public CreateBuilder subnetId(String subnetId) {
+ vip.subnetId = subnetId;
+ return self();
+ }
+
+ /**
+ * Provides the address for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getAddress()
+ */
+ public CreateBuilder address(String address) {
+ vip.address = address;
+ return self();
+ }
+
+ /**
+ * Provides the protocol for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getProtocol()
+ */
+ public CreateBuilder protocol(Protocol protocol) {
+ vip.protocol = protocol;
+ return self();
+ }
+
+ /**
+ * Provides the protocol port for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getProtocolPort()
+ */
+ public CreateBuilder protocolPort(Integer protocolPort) {
+ vip.protocolPort = protocolPort;
+ return self();
+ }
+
+ /**
+ * @return a CreateVIP constructed with this Builder.
+ */
+ public CreateVIP build() {
+ return new CreateVIP(vip);
+ }
+
+ @Override
+ protected CreateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Update builder (inheriting from Builder).
+ */
+ public static class UpdateBuilder extends Builder<UpdateBuilder> {
+ /**
+ * Supply required properties for creating a VIP's UpdateBuilder.
+ */
+ private UpdateBuilder() {
+ }
+
+ /**
+ * @return a UpdateVIP constructed with this Builder.
+ */
+ public UpdateVIP build() {
+ return new UpdateVIP(vip);
+ }
+
+ @Override
+ protected UpdateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Create options - extend the domain class, passed to API create calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class CreateVIP extends VIP {
+ /**
+ * Copy constructor.
+ *
+ * @param vip the VIP to copy from.
+ */
+ private CreateVIP(VIP vip) {
+ super(vip);
+ }
+ }
+
+ /**
+ * Update options - extend the domain class, passed to API update calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class UpdateVIP extends VIP {
+ /**
+ * Copy constructor.
+ *
+ * @param vip the VIP to copy from.
+ */
+ private UpdateVIP(VIP vip) {
+ super(vip);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIPs.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIPs.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIPs.java
new file mode 100644
index 0000000..f53223d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIPs.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A collection of of Neutron LBaaS v1 VIPs.
+ */
+public class VIPs extends PaginatedCollection<VIP> {
+ public static final VIPs EMPTY = new VIPs(ImmutableSet.<VIP> of(), ImmutableSet.<Link> of());
+
+ @ConstructorProperties({ "vips", "vips_links" })
+ protected VIPs(Iterable<VIP> vips, Iterable<Link> vipsLinks) {
+ super(vips, vipsLinks);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java
new file mode 100644
index 0000000..60d23a3
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.extensions;
+
+/**
+ * Extension Namespaces for OpenStack Networking (Neutron).
+ */
+public final class ExtensionNamespaces {
+ /**
+ * Neutron Layer-3 Router Extension
+ */
+ public static final String L3_ROUTER = "http://docs.openstack.org/ext/neutron/router/api/v1.0";
+ /**
+ * Neutron Security Groups Extension
+ */
+ public static final String SECURITY_GROUPS = "http://docs.openstack.org/ext/securitygroups/api/v2.0";
+ /**
+ * LBaaS Extension.
+ */
+ public static final String LBAAS = "http://wiki.openstack.org/neutron/LBaaS/API_1.0";
+
+ private ExtensionNamespaces() {
+ throw new AssertionError("intentionally unimplemented");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApi.java
new file mode 100644
index 0000000..9a65543
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApi.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.neutron.v2.domain.FloatingIP;
+import org.jclouds.openstack.neutron.v2.domain.FloatingIPs;
+import org.jclouds.openstack.neutron.v2.fallbacks.EmptyFloatingIPsFallback;
+import org.jclouds.openstack.neutron.v2.functions.FloatingIPsToPagedIterable;
+import org.jclouds.openstack.neutron.v2.functions.ParseFloatingIPs;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.annotations.WrapWith;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Provides access to Floating IP operations for the OpenStack Networking (Neutron) v2 API.
+ * <p/>
+ * A floating IP is an IP address on an external network, which is associated with a specific port, and optionally a
+ * specific IP address, on a private OpenStack Networking network. Therefore a floating IP allows access to an
+ * instance on a private network from an external network. Floating IPs can only be defined on networks for which the
+ * attribute floatingip:external (by the external network extension) has been set to True.
+ */
+@Beta
+@Path("/floatingips")
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface FloatingIPApi {
+
+ /**
+ * Returns a list of floating IPs to which the tenant has access. Default policy settings return only
+ * those floating IPs that are owned by the tenant who submits the request, unless the request is submitted by an
+ * user with administrative rights.
+ *
+ * @return the list of all floatingIP references configured for the tenant.
+ */
+ @Named("floatingip:list")
+ @GET
+ @Transform(FloatingIPsToPagedIterable.class)
+ @ResponseParser(ParseFloatingIPs.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<FloatingIP> list();
+
+ /**
+ * @return the list of all floatingIP references configured for the tenant.
+ */
+ @Named("floatingip:list")
+ @GET
+ @ResponseParser(ParseFloatingIPs.class)
+ @Fallback(EmptyFloatingIPsFallback.class)
+ FloatingIPs list(PaginationOptions options);
+
+ /**
+ * Returns the details for a specific floating IP.
+ *
+ * @param id the id of the floatingIP to return
+ * @return FloatingIPs collection or empty if not found
+ */
+ @Named("floatingip:get")
+ @GET
+ @Path("/{id}")
+ @SelectJson("floatingip")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ FloatingIP get(@PathParam("id") String id);
+
+ /**
+ * Creates a floating IP.
+ *
+ * @param createFloatingIP Options for creating a Floating IP
+ * @return the newly created Floating IP
+ */
+ @Named("floatingip:create")
+ @POST
+ @SelectJson("floatingip")
+ FloatingIP create(@WrapWith("floatingip") FloatingIP.CreateFloatingIP createFloatingIP);
+
+ /**
+ * Update a Floating IP
+ *
+ * @param id the id of the Floating IP to update
+ * @param updateFloatingIP Contains only the attributes to update
+ * @return The modified Floating IP
+ */
+ @Named("floatingip:update")
+ @PUT
+ @Path("/{id}")
+ @SelectJson("floatingip")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ FloatingIP update(@PathParam("id") String id, @WrapWith("floatingip") FloatingIP.UpdateFloatingIP updateFloatingIP);
+
+ /**
+ * Deletes the specified floatingIP
+ *
+ * @param id the id of the floatingIP to delete
+ * @return true if delete successful, false if not
+ */
+ @Named("floatingip:delete")
+ @DELETE
+ @Path("/{id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean delete(@PathParam("id") String id);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/RouterApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/RouterApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/RouterApi.java
new file mode 100644
index 0000000..e259d69
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/RouterApi.java
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.neutron.v2.domain.Router;
+import org.jclouds.openstack.neutron.v2.domain.RouterInterface;
+import org.jclouds.openstack.neutron.v2.domain.Routers;
+import org.jclouds.openstack.neutron.v2.fallbacks.EmptyRoutersFallback;
+import org.jclouds.openstack.neutron.v2.functions.ParseRouters;
+import org.jclouds.openstack.neutron.v2.functions.RouterToPagedIterable;
+import org.jclouds.openstack.neutron.v2.options.EmptyOptions;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.annotations.WrapWith;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Provides access to Router operations for the OpenStack Networking (Neutron) v2 API.
+ * <p/>
+ * A logical entity for forwarding packets across internal subnets and NATting them on external
+ * networks through an appropriate external gateway.
+ *
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-network/2.0/content/router_ext.html">api doc</a>
+ */
+@Beta
+@Path("/routers")
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface RouterApi {
+
+ /**
+ * Returns the list of all routers currently defined in Neutron for the current tenant. The list provides the unique
+ * identifier of each router configured for the tenant
+ *
+ * @return the list of all router references configured for the tenant.
+ */
+ @Named("router:list")
+ @GET
+ @Transform(RouterToPagedIterable.class)
+ @ResponseParser(ParseRouters.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Router> list();
+
+ /**
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a>
+ */
+ @Named("router:list")
+ @GET
+ @ResponseParser(ParseRouters.class)
+ @Fallback(EmptyRoutersFallback.class)
+ Routers list(PaginationOptions options);
+
+ /**
+ * Returns a Routers collection that should contain a single router with the id requested.
+ *
+ * @param id the id of the router to return
+ * @return Routers collection or empty if not found
+ */
+ @Named("router:get")
+ @GET
+ @Path("/{id}")
+ @SelectJson("router")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Router get(@PathParam("id") String id);
+
+ /**
+ * Create a new router
+ *
+ * @param router Options for creating a router
+ * @return the newly created router
+ */
+ @Named("router:create")
+ @POST
+ @SelectJson("router")
+ Router create(@WrapWith("router") Router.CreateRouter router);
+
+ /**
+ * Update a router
+ *
+ * @param id the id of the router to update
+ * @param router Contains only the attributes to update
+ * @return The modified router
+ */
+ @Named("router:update")
+ @PUT
+ @Path("/{id}")
+ @SelectJson("router")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Router update(@PathParam("id") String id, @WrapWith("router") Router.UpdateRouter router);
+
+ /**
+ * Deletes the specified router
+ *
+ * @param id the id of the router to delete
+ * @return true if delete successful, false if not
+ */
+ @Named("router:delete")
+ @DELETE
+ @Path("/{id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean delete(@PathParam("id") String id);
+
+ /**
+ * Add a interface to a router to connect to the specified subnet
+ *
+ * @param routerId the id of the router to create the interface at
+ * @param subnetId the id of the subnet to connect with the interface
+ * @return the newly-created router interface
+ */
+ @Named("router:addInterfaceForSubnet")
+ @PUT
+ @Path("/{id}/add_router_interface")
+ @MapBinder(EmptyOptions.class)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ RouterInterface addInterfaceForSubnet(@PathParam("id") String routerId, @PayloadParam("subnet_id") String subnetId);
+
+ /**
+ * Add a interface to a router to connect to the specified port
+ *
+ * @param routerId the id of the router to create the interface at
+ * @param portId the id of the port to connect with the interface
+ * @return the newly-created router interface
+ */
+ @Named("router:addInterfaceForPort")
+ @PUT
+ @Path("/{id}/add_router_interface")
+ @MapBinder(EmptyOptions.class)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ RouterInterface addInterfaceForPort(@PathParam("id") String routerId, @PayloadParam("port_id") String portId);
+
+ /**
+ * Remove the interface where the specified subnet is connected to
+ *
+ * @param routerId the id of the router to remove the interface from
+ * @param subnetId the id of the subnet to disconnect from the interface
+ */
+ @Named("router:removeInterfaceForSubnet")
+ @PUT
+ @Path("/{id}/remove_router_interface")
+ @MapBinder(EmptyOptions.class)
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean removeInterfaceForSubnet(@PathParam("id") String routerId, @PayloadParam("subnet_id") String subnetId);
+
+ /**
+ * Remove the interface where the specified port is connected to
+ *
+ * @param routerId the id of the router to remove the interface from
+ * @param portId the id of the port to disconnect from the interface
+ */
+ @Named("router:removeInterfaceForPort")
+ @PUT
+ @Path("/{id}/remove_router_interface")
+ @MapBinder(EmptyOptions.class)
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean removeInterfaceForPort(@PathParam("id") String routerId, @PayloadParam("port_id") String portId);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/SecurityGroupApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/SecurityGroupApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/SecurityGroupApi.java
new file mode 100644
index 0000000..0832d4c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/SecurityGroupApi.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.neutron.v2.domain.Rule;
+import org.jclouds.openstack.neutron.v2.domain.Rules;
+import org.jclouds.openstack.neutron.v2.domain.SecurityGroup;
+import org.jclouds.openstack.neutron.v2.domain.SecurityGroups;
+import org.jclouds.openstack.neutron.v2.fallbacks.EmptyRulesFallback;
+import org.jclouds.openstack.neutron.v2.fallbacks.EmptySecurityGroupsFallback;
+import org.jclouds.openstack.neutron.v2.functions.ParseRules;
+import org.jclouds.openstack.neutron.v2.functions.ParseSecurityGroups;
+import org.jclouds.openstack.neutron.v2.functions.RulesToPagedIterable;
+import org.jclouds.openstack.neutron.v2.functions.SecurityGroupsToPagedIterable;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.annotations.WrapWith;
+import com.google.common.annotations.Beta;
+
+/**
+ * Provides access to Security Group extension operations for the OpenStack Networking (Neutron) v2 API.
+ * <p/>
+ * Security groups and security group rules allows administrators and tenants the ability to specify the type of
+ * traffic and direction (ingress/egress) that is allowed to pass through a port. A security group is a container for
+ * security group rules.
+ */
+@Beta
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+@Produces(MediaType.APPLICATION_JSON)
+public interface SecurityGroupApi {
+ /**
+ * Groups
+ */
+
+ /**
+ * @return all security groups currently defined in Neutron for the current tenant.
+ */
+ @Path("/security-groups")
+ @Named("security-group:list")
+ @GET
+ @ResponseParser(ParseSecurityGroups.class)
+ @Transform(SecurityGroupsToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<SecurityGroup> listSecurityGroups();
+
+ /**
+ * @return all security groups currently defined in Neutron for the current tenant.
+ */
+ @Path("/security-groups")
+ @Named("security-group:list")
+ @GET
+ @ResponseParser(ParseSecurityGroups.class)
+ @Fallback(EmptySecurityGroupsFallback.class)
+ SecurityGroups listSecurityGroups(PaginationOptions options);
+
+ /**
+ * @param id the id of the security group to return
+ * @return SecurityGroup or null if not found.
+ */
+ @Path("/security-groups/{id}")
+ @Named("security-group:get")
+ @GET
+ @SelectJson("security_group")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Nullable
+ SecurityGroup getSecurityGroup(@PathParam("id") String id);
+
+ /**
+ * Creates a new SecurityGroup.
+ *
+ * @param securityGroup Describes the security group to be created.
+ * @return a reference of the newly-created security group
+ */
+ @Path("/security-groups")
+ @Named("secuity-group:create")
+ @POST
+ @SelectJson("security_group")
+ SecurityGroup create(@WrapWith("security_group") SecurityGroup.CreateSecurityGroup securityGroup);
+
+ /**
+ * Deletes the specified Security Group.
+ *
+ * @param id the id of the security group to delete
+ * @return true if delete was successful, false if not
+ */
+ @Path("/security-groups/{id}")
+ @Named("security-group:delete")
+ @DELETE
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean deleteSecurityGroup(@PathParam("id") String id);
+
+ /**
+ * Rules
+ */
+
+ /**
+ * @return all security groups rules currently defined in Neutron for the current tenant.
+ */
+ @Path("/security-group-rules")
+ @Named("security-group-rule:list")
+ @GET
+ @ResponseParser(ParseRules.class)
+ @Transform(RulesToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Rule> listRules();
+
+ /**
+ * @return all security groups rules currently defined in Neutron for the current tenant.
+ */
+ @Path("/security-group-rules")
+ @Named("security-group-rule:list")
+ @GET
+ @ResponseParser(ParseRules.class)
+ @Fallback(EmptyRulesFallback.class)
+ Rules listRules(PaginationOptions options);
+
+ /**
+ * @param id the id of the security group rule to return.
+ * @return SecurityGroupRule or null if not found.
+ */
+ @Path("/security-group-rules/{id}")
+ @Named("security-group-rule:get")
+ @GET
+ @SelectJson("security_group_rule")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Nullable
+ Rule get(@PathParam("id") String id);
+
+ /**
+ * Creates a new Security Group Rule.
+ *
+ * @param securityGroupRule Describes the security group rule to be created.
+ * @return a reference of the newly-created security group rule.
+ */
+ @Path("/security-group-rules")
+ @Named("security-group-rule:create")
+ @POST
+ @SelectJson("security_group_rule")
+ Rule create(@WrapWith("security_group_rule") Rule.CreateRule securityGroupRule);
+
+ /**
+ * Deletes the specified Security Group Rule.
+ *
+ * @param id the id of the security group rule to delete.
+ * @return true if delete was successful, false if not.
+ */
+ @Path("/security-group-rules/{id}")
+ @Named("security-group-rule:delete")
+ @DELETE
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean deleteRule(@PathParam("id") String id);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApi.java
new file mode 100644
index 0000000..dad80d8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApi.java
@@ -0,0 +1,426 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.extensions.lbaas.v1;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitor;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Member;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pool;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIP;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs;
+import org.jclouds.openstack.neutron.v2.extensions.ExtensionNamespaces;
+import org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1.EmptyHealthMonitorsFallback;
+import org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1.EmptyMembersFallback;
+import org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1.EmptyPoolsFallback;
+import org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1.EmptyVIPsFallback;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.HealthMonitorsToPagedIterable;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.MembersToPagedIterable;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.ParseHealthMonitors;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.ParseMembers;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.ParsePools;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.ParseVIPs;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.PoolsToPagedIterable;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.VIPsToPagedIterable;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.annotations.WrapWith;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Provides access to load-balancing operations for the OpenStack Networking (Neutron) v2 API.
+ * <p/>
+ * LBaaS v1 is an extension to load-balance the traffic between instances and external networks.
+ */
+@Beta
+@Extension(of = ServiceType.NETWORK, namespace = ExtensionNamespaces.LBAAS)
+@Path("/lb")
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface LBaaSApi {
+
+ /**
+ * Returns a list of VIPs to which the tenant has access. Default policy settings return only
+ * those VIPs that are owned by the tenant who submits the request, unless the request is submitted by an
+ * user with administrative rights.
+ *
+ * @return the list of all VIP references configured for the tenant.
+ */
+ @Named("vip:list")
+ @GET
+ @Path("/vips")
+ @Transform(VIPsToPagedIterable.class)
+ @ResponseParser(ParseVIPs.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<VIP> listVIPs();
+
+ /**
+ * @return the list of all VIP references configured for the tenant.
+ */
+ @Named("vip:list")
+ @GET
+ @Path("/vips")
+ @ResponseParser(ParseVIPs.class)
+ @Fallback(EmptyVIPsFallback.class)
+ VIPs listVIPs(PaginationOptions options);
+
+ /**
+ * Returns the details for a specific VIP.
+ *
+ * @param id the id of the VIP to return.
+ * @return VIP or null if not found.
+ */
+ @Named("vip:get")
+ @GET
+ @Path("/vips/{id}")
+ @SelectJson("vip")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ VIP getVIP(@PathParam("id") String id);
+
+ /**
+ * Creates a new VIP.
+ *
+ * @param vip describes the VIP to be created.
+ * @return a reference of the newly-created VIP.
+ */
+ @Named("vip:create")
+ @POST
+ @Path("/vips")
+ @SelectJson("vip")
+ VIP createVIP(@WrapWith("vip") VIP.CreateVIP vip);
+
+ /**
+ * Update a VIP.
+ *
+ * @param id the id of the VIP to update.
+ * @param vip the VIP's attributes to update.
+ * @return a reference of the updated VIP.
+ */
+ @Named("vip:update")
+ @PUT
+ @Path("/vips/{id}")
+ @SelectJson("vip")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ VIP updateVIP(@PathParam("id") String id, @WrapWith("vip") VIP.UpdateVIP vip);
+
+ /**
+ * Deletes the specified VIP.
+ *
+ * @param id the id of the VIP to delete.
+ * @return true if delete successful, false if not.
+ */
+ @Named("vip:delete")
+ @DELETE
+ @Path("/vips/{id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean deleteVIP(@PathParam("id") String id);
+
+ /**
+ * Returns a list of Pools to which the tenant has access. Default policy settings return only
+ * those Pools that are owned by the tenant who submits the request, unless the request is submitted by an
+ * user with administrative rights.
+ *
+ * @return the list of all Pool references configured for the tenant.
+ */
+ @Named("pool:list")
+ @GET
+ @Path("/pools")
+ @Transform(PoolsToPagedIterable.class)
+ @ResponseParser(ParsePools.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Pool> listPools();
+
+ /**
+ * @return the list of all Pool references configured for the tenant.
+ */
+ @Named("pool:list")
+ @GET
+ @Path("/pools")
+ @ResponseParser(ParsePools.class)
+ @Fallback(EmptyPoolsFallback.class)
+ Pools listPools(PaginationOptions options);
+
+ /**
+ * Returns the details for a specific Pool.
+ *
+ * @param id the id of the Pool to return.
+ * @return Pool or null if not found.
+ */
+ @Named("pool:get")
+ @GET
+ @Path("/pools/{id}")
+ @SelectJson("pool")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Pool getPool(@PathParam("id") String id);
+
+ /**
+ * Creates a new Pool.
+ *
+ * @param pool describes the Pool to be created.
+ * @return a reference of the newly-created Pool.
+ */
+ @Named("pool:create")
+ @POST
+ @Path("/pools")
+ @SelectJson("pool")
+ Pool createPool(@WrapWith("pool") Pool.CreatePool pool);
+
+ /**
+ * Update a Pool.
+ *
+ * @param id the id of the Pool to update.
+ * @param pool the Pool's attributes to update.
+ * @return a reference of the updated Pool.
+ */
+ @Named("pool:update")
+ @PUT
+ @Path("/pools/{id}")
+ @SelectJson("pool")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Pool updatePool(@PathParam("id") String id, @WrapWith("pool") Pool.UpdatePool pool);
+
+ /**
+ * Deletes the specified Pool.
+ *
+ * @param id the id of the Pool to delete.
+ * @return true if delete successful, false if not.
+ */
+ @Named("pool:delete")
+ @DELETE
+ @Path("/pools/{id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean deletePool(@PathParam("id") String id);
+
+ /**
+ * Returns a list of Members to which the tenant has access. Default policy settings return only
+ * those Members that are owned by the tenant who submits the request, unless the request is submitted by an
+ * user with administrative rights.
+ *
+ * @return the list of all Member references configured for the tenant.
+ */
+ @Named("member:list")
+ @GET
+ @Path("/members")
+ @Transform(MembersToPagedIterable.class)
+ @ResponseParser(ParseMembers.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Member> listMembers();
+
+ /**
+ * @return the list of all Member references configured for the tenant.
+ */
+ @Named("member:list")
+ @GET
+ @Path("/members")
+ @ResponseParser(ParseMembers.class)
+ @Fallback(EmptyMembersFallback.class)
+ Members listMembers(PaginationOptions options);
+
+ /**
+ * Returns the details for a specific Member.
+ *
+ * @param id the id of the Member to return.
+ * @return Member or null if not found.
+ */
+ @Named("member:get")
+ @GET
+ @Path("/members/{id}")
+ @SelectJson("member")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Member getMember(@PathParam("id") String id);
+
+ /**
+ * Creates a new Member.
+ *
+ * @param member describes the Member to be created.
+ * @return a reference of the newly-created Member.
+ */
+ @Named("member:create")
+ @POST
+ @Path("/members")
+ @SelectJson("member")
+ Member createMember(@WrapWith("member") Member.CreateMember member);
+
+ /**
+ * Update a Member.
+ *
+ * @param id the id of the Member to update.
+ * @param member the Member's attributes to update.
+ * @return a reference of the updated Member.
+ */
+ @Named("member:update")
+ @PUT
+ @Path("/members/{id}")
+ @SelectJson("member")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Member updateMember(@PathParam("id") String id, @WrapWith("member") Member.UpdateMember member);
+
+ /**
+ * Deletes the specified Member.
+ *
+ * @param id the id of the Member to delete.
+ * @return true if delete successful, false if not.
+ */
+ @Named("member:delete")
+ @DELETE
+ @Path("/members/{id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean deleteMember(@PathParam("id") String id);
+
+ /**
+ * Returns a list of HealthMonitors to which the tenant has access. Default policy settings return only
+ * those HealthMonitors that are owned by the tenant who submits the request, unless the request is submitted by an
+ * user with administrative rights.
+ *
+ * @return the list of all HealthMonitor references configured for the tenant.
+ */
+ @Named("health_monitor:list")
+ @GET
+ @Path("/health_monitors")
+ @Transform(HealthMonitorsToPagedIterable.class)
+ @ResponseParser(ParseHealthMonitors.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<HealthMonitor> listHealthMonitors();
+
+ /**
+ * @return the list of all HealthMonitor references configured for the tenant.
+ */
+ @Named("health_monitor:list")
+ @GET
+ @Path("/health_monitors")
+ @ResponseParser(ParseHealthMonitors.class)
+ @Fallback(EmptyHealthMonitorsFallback.class)
+ HealthMonitors listHealthMonitors(PaginationOptions options);
+
+ /**
+ * Returns the details for a specific HealthMonitor.
+ *
+ * @param id the id of the HealthMonitor to return.
+ * @return Health Monitor or null if not found.
+ */
+ @Named("health_monitor:get")
+ @GET
+ @Path("/health_monitors/{id}")
+ @SelectJson("health_monitor")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ HealthMonitor getHealthMonitor(@PathParam("id") String id);
+
+ /**
+ * Creates a new HealthMonitor.
+ *
+ * @param healthMonitor describes the HealthMonitor to be created.
+ * @return a reference of the newly-created HealthMonitor.
+ */
+ @Named("health_monitor:create")
+ @POST
+ @Path("/health_monitors")
+ @SelectJson("health_monitor")
+ HealthMonitor createHealthMonitor(@WrapWith("health_monitor") HealthMonitor.CreateHealthMonitor healthMonitor);
+
+ /**
+ * Update a HealthMonitor.
+ *
+ * @param id the id of the HealthMonitor to update.
+ * @param healthMonitor the HealthMonitor's attributes to update.
+ * @return a reference of the updated HealthMonitor.
+ */
+ @Named("health_monitor:update")
+ @PUT
+ @Path("/health_monitors/{id}")
+ @SelectJson("health_monitor")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ HealthMonitor updateHealthMonitor(@PathParam("id") String id,
+ @WrapWith("health_monitor") HealthMonitor.UpdateHealthMonitor healthMonitor);
+
+ /**
+ * Deletes the specified Health Monitor.
+ *
+ * @param id the id of the Health Monitor to delete.
+ * @return true if delete successful, false if not.
+ */
+ @Named("health_monitor:delete")
+ @DELETE
+ @Path("/health_monitors/{id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean deleteHealthMonitor(@PathParam("id") String id);
+
+ /**
+ * Associate a HealthMonitor to a Pool.
+ *
+ * @param poolId the id of the Pool to associate.
+ * @param healthMonitorId the id of the HealthMonitor to associate.
+ * @return the newly associated HealthMonitor.
+ */
+ @Named("pool:associate_health_monitor")
+ @POST
+ @Path("/pools/{pool-id}/health_monitors")
+ @SelectJson("health_monitor")
+ @Payload("%7B\"health_monitor\":%7B\"id\":\"{healthMonitorId}\"%7D%7D")
+ @Produces(MediaType.APPLICATION_JSON)
+ HealthMonitor associateHealthMonitor(@PathParam("pool-id") String poolId,
+ @PayloadParam("healthMonitorId") String healthMonitorId);
+
+ /**
+ * Disassociate a HealthMonitor from a Pool.
+ *
+ * @param poolId the id of the Pool to disassociate.
+ * @param healthMonitorId the id of the HealthMonitor to disassociate.
+ * @return true if disassociate successful, false if not.
+ */
+ @Named("pool:disassociate_health_monitor")
+ @DELETE
+ @Path("/pools/{pool-id}/health_monitors/{health-monitor-id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean disassociateHealthMonitor(@PathParam("pool-id") String poolId,
+ @PathParam("health-monitor-id") String healthMonitorId);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyFloatingIPsFallback.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyFloatingIPsFallback.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyFloatingIPsFallback.java
new file mode 100644
index 0000000..ede9046
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyFloatingIPsFallback.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.fallbacks;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.FloatingIPs;
+import org.jclouds.rest.ResourceNotFoundException;
+
+public class EmptyFloatingIPsFallback implements Fallback<FloatingIPs> {
+ @Override
+ public FloatingIPs createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return FloatingIPs.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyNetworksFallback.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyNetworksFallback.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyNetworksFallback.java
new file mode 100644
index 0000000..8410afb
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyNetworksFallback.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.fallbacks;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.Networks;
+import org.jclouds.rest.ResourceNotFoundException;
+
+public class EmptyNetworksFallback implements Fallback<Networks> {
+ @Override
+ public Networks createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return Networks.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyPortsFallback.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyPortsFallback.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyPortsFallback.java
new file mode 100644
index 0000000..ac2e0db
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyPortsFallback.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.fallbacks;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.Ports;
+import org.jclouds.rest.ResourceNotFoundException;
+
+public class EmptyPortsFallback implements Fallback<Ports> {
+ @Override
+ public Ports createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return Ports.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyRoutersFallback.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyRoutersFallback.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyRoutersFallback.java
new file mode 100644
index 0000000..8b74be2
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyRoutersFallback.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.fallbacks;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.Routers;
+import org.jclouds.rest.ResourceNotFoundException;
+
+public class EmptyRoutersFallback implements Fallback<Routers> {
+ @Override
+ public Routers createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return Routers.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyRulesFallback.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyRulesFallback.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyRulesFallback.java
new file mode 100644
index 0000000..4556f74
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptyRulesFallback.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.fallbacks;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.Rules;
+import org.jclouds.rest.ResourceNotFoundException;
+
+public class EmptyRulesFallback implements Fallback<Rules> {
+ @Override
+ public Rules createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return Rules.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptySecurityGroupsFallback.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptySecurityGroupsFallback.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptySecurityGroupsFallback.java
new file mode 100644
index 0000000..70a3e37
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptySecurityGroupsFallback.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.fallbacks;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.SecurityGroups;
+import org.jclouds.rest.ResourceNotFoundException;
+
+public class EmptySecurityGroupsFallback implements Fallback<SecurityGroups> {
+ @Override
+ public SecurityGroups createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return SecurityGroups.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptySubnetsFallback.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptySubnetsFallback.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptySubnetsFallback.java
new file mode 100644
index 0000000..8f7a94a
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/EmptySubnetsFallback.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.fallbacks;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.Subnets;
+import org.jclouds.rest.ResourceNotFoundException;
+
+public class EmptySubnetsFallback implements Fallback<Subnets> {
+ @Override
+ public Subnets createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return Subnets.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyHealthMonitorsFallback.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyHealthMonitorsFallback.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyHealthMonitorsFallback.java
new file mode 100644
index 0000000..8364fba
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyHealthMonitorsFallback.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors;
+import org.jclouds.rest.ResourceNotFoundException;
+
+public class EmptyHealthMonitorsFallback implements Fallback<HealthMonitors> {
+ @Override
+ public HealthMonitors createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return HealthMonitors.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyMembersFallback.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyMembersFallback.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyMembersFallback.java
new file mode 100644
index 0000000..9cb8084
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyMembersFallback.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members;
+import org.jclouds.rest.ResourceNotFoundException;
+
+public class EmptyMembersFallback implements Fallback<Members> {
+ @Override
+ public Members createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return Members.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyPoolsFallback.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyPoolsFallback.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyPoolsFallback.java
new file mode 100644
index 0000000..0c2ce99
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyPoolsFallback.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools;
+import org.jclouds.rest.ResourceNotFoundException;
+
+public class EmptyPoolsFallback implements Fallback<Pools> {
+ @Override
+ public Pools createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return Pools.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyVIPsFallback.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyVIPsFallback.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyVIPsFallback.java
new file mode 100644
index 0000000..4dfae2d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyVIPsFallback.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs;
+import org.jclouds.rest.ResourceNotFoundException;
+
+public class EmptyVIPsFallback implements Fallback<VIPs> {
+ @Override
+ public VIPs createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return VIPs.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
[19/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_request.json
new file mode 100644
index 0000000..2772b5a
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_request.json
@@ -0,0 +1,5 @@
+{
+ "floatingip": {
+ "port_id": "fc861431-0e6c-4842-a0ed-e2363f9bc3a8"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_response.json
new file mode 100644
index 0000000..59c8a68
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_response.json
@@ -0,0 +1,11 @@
+{
+ "floatingip": {
+ "router_id": "d23abc8d-2991-4a55-ba98-2aaea84cc72f",
+ "tenant_id": "4969c491a3c74ee4af974e6d800c62de",
+ "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",
+ "fixed_ip_address": "10.0.0.4",
+ "floating_ip_address": "172.24.4.228",
+ "port_id": "fc861431-0e6c-4842-a0ed-e2363f9bc3a8",
+ "id": "2f245a7b-796b-4f26-9cf9-9e82d248fda7"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_create_request.json
new file mode 100644
index 0000000..7d3b6a4
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_create_request.json
@@ -0,0 +1,8 @@
+{
+ "health_monitor": {
+ "delay": 1,
+ "max_retries": 1,
+ "type": "HTTP",
+ "timeout": 1
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_create_response.json
new file mode 100644
index 0000000..1a0dbce
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_create_response.json
@@ -0,0 +1,16 @@
+{
+ "health_monitor": {
+ "status": "PENDING_CREATE",
+ "admin_state_up": true,
+ "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
+ "delay": 1,
+ "expected_codes": "200",
+ "max_retries": 1,
+ "http_method": "GET",
+ "timeout": 1,
+ "pools": [],
+ "url_path": "/",
+ "type": "HTTP",
+ "id": "b624decf-d5d3-4c66-9a3d-f047e7786181"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_get_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_get_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_get_response.json
new file mode 100644
index 0000000..fc162dc
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_get_response.json
@@ -0,0 +1,16 @@
+{
+ "health_monitor": {
+ "status": "ACTIVE",
+ "admin_state_up": true,
+ "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
+ "delay": 5,
+ "expected_codes": "200",
+ "max_retries": 2,
+ "http_method": "GET",
+ "timeout": 2,
+ "url_path": "/",
+ "type": "HTTP",
+ "pools": [],
+ "id": "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_list_response_paged1.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_list_response_paged1.json
new file mode 100644
index 0000000..3856187
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_list_response_paged1.json
@@ -0,0 +1,20 @@
+{
+ "health_monitors": [
+ {
+ "status": "ACTIVE",
+ "admin_state_up": true,
+ "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
+ "delay": 10,
+ "max_retries": 1,
+ "timeout": 1,
+ "type": "PING",
+ "id": "466c8345-28d8-4f84-a246-e04380b0461d"
+ }
+ ],
+ "health_monitors_links": [
+ {
+ "href": "/v2.0/lb/health_monitors.json?marker=396f12f8-521e-4b91-8e21-2e003500433a",
+ "rel": "next"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_list_response_paged2.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_list_response_paged2.json
new file mode 100644
index 0000000..703b123
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_list_response_paged2.json
@@ -0,0 +1,23 @@
+{
+ "health_monitors": [
+ {
+ "status": "ACTIVE",
+ "admin_state_up": true,
+ "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
+ "delay": 5,
+ "expected_codes": "200",
+ "max_retries": 2,
+ "http_method": "GET",
+ "timeout": 2,
+ "url_path": "/",
+ "type": "HTTP",
+ "id": "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ }
+ ],
+ "health_monitors_links": [
+ {
+ "href": "/v2.0/lb/health_monitors.json?marker=396f12f8-521e-4b91-8e21-2e003500433a",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_update_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_update_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_update_request.json
new file mode 100644
index 0000000..cfb9c2e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_update_request.json
@@ -0,0 +1,11 @@
+{
+ "health_monitor": {
+ "delay": 1,
+ "max_retries": 1,
+ "timeout": 1,
+ "http_method": "HEAD",
+ "url_path": "/index.html",
+ "expected_codes": "201",
+ "admin_state_up": false
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_update_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_update_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_update_response.json
new file mode 100644
index 0000000..95bdf43
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/health_monitor_update_response.json
@@ -0,0 +1,16 @@
+{
+ "health_monitor": {
+ "status": "ACTIVE",
+ "admin_state_up": false,
+ "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
+ "delay": 1,
+ "expected_codes": "201",
+ "max_retries": 1,
+ "http_method": "HEAD",
+ "timeout": 1,
+ "pools": [],
+ "url_path": "/index.html",
+ "type": "HTTP",
+ "id": "466c8345-28d8-4f84-a246-e04380b0461d"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_create_request.json
new file mode 100644
index 0000000..20645b8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_create_request.json
@@ -0,0 +1,6 @@
+{
+ "member": {
+ "protocol_port": 80,
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_create_response.json
new file mode 100644
index 0000000..cb74c42
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_create_response.json
@@ -0,0 +1,12 @@
+{
+ "member": {
+ "status": "PENDING_CREATE",
+ "protocol_port": 80,
+ "weight": 1,
+ "admin_state_up": true,
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "address": "10.0.0.5",
+ "id":"48a471ea-64f1-4eb6-9be7-dae6bbe40a0f"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_get_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_get_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_get_response.json
new file mode 100644
index 0000000..a7302b3
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_get_response.json
@@ -0,0 +1,12 @@
+{
+ "member": {
+ "status": "ACTIVE",
+ "protocol_port": 80,
+ "weight": 1,
+ "admin_state_up": true,
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "address": "10.0.0.5",
+ "id":"48a471ea-64f1-4eb6-9be7-dae6bbe40a0f"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_list_response_paged1.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_list_response_paged1.json
new file mode 100644
index 0000000..b793ad4
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_list_response_paged1.json
@@ -0,0 +1,20 @@
+{
+ "members": [
+ {
+ "status": "ACTIVE",
+ "protocol_port": 80,
+ "weight": 1,
+ "admin_state_up": true,
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "address": "10.0.0.5",
+ "id":"48a471ea-64f1-4eb6-9be7-dae6bbe40a0f"
+ }
+ ],
+ "members_links": [
+ {
+ "href": "/v2.0/lb/members.json?marker=396f12f8-521e-4b91-8e21-2e003500433a",
+ "rel": "next"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_list_response_paged2.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_list_response_paged2.json
new file mode 100644
index 0000000..c707ae4
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_list_response_paged2.json
@@ -0,0 +1,20 @@
+{
+ "members": [
+ {
+ "status": "ACTIVE",
+ "protocol_port": 80,
+ "weight": 1,
+ "admin_state_up": true,
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "address": "10.0.0.5",
+ "id":"701b531b-111a-4f21-ad85-4795b7b12af6"
+ }
+ ],
+ "members_links": [
+ {
+ "href": "/v2.0/lb/members.json?marker=86ae12f8-521e-4b91-8e21-2e0035005fdc",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_update_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_update_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_update_request.json
new file mode 100644
index 0000000..4d7ac67
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_update_request.json
@@ -0,0 +1,7 @@
+{
+ "member": {
+ "weight": 2,
+ "admin_state_up": false,
+ "pool_id": "new_pool_id"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_update_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_update_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_update_response.json
new file mode 100644
index 0000000..1d14b9e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/member_update_response.json
@@ -0,0 +1,12 @@
+{
+ "member": {
+ "status": "ACTIVE",
+ "protocol_port": 80,
+ "weight": 2,
+ "admin_state_up": false,
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "pool_id": "new_pool_id",
+ "address": "10.0.0.5",
+ "id":"48a471ea-64f1-4eb6-9be7-dae6bbe40a0f"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_associate_health_monitor_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_associate_health_monitor_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_associate_health_monitor_request.json
new file mode 100644
index 0000000..c3b2dd4
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_associate_health_monitor_request.json
@@ -0,0 +1,5 @@
+{
+ "health_monitor": {
+ "id":"5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_associate_health_monitor_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_associate_health_monitor_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_associate_health_monitor_response.json
new file mode 100644
index 0000000..3e0459d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_associate_health_monitor_response.json
@@ -0,0 +1,4 @@
+{
+ "health_monitor": {
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_create_request.json
new file mode 100644
index 0000000..077a14b
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_create_request.json
@@ -0,0 +1,8 @@
+{
+ "pool": {
+ "subnet_id":"8032909d-47a1-4715-90af-5153ffe39861",
+ "lb_method":"ROUND_ROBIN",
+ "protocol":"TCP",
+ "name":"NewPool"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_create_response.json
new file mode 100644
index 0000000..3cc5cf7
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_create_response.json
@@ -0,0 +1,18 @@
+{
+ "pool": {
+ "status": "PENDING_CREATE",
+ "lb_method": "ROUND_ROBIN",
+ "protocol": "TCP",
+ "provider": "HAPROXY",
+ "description": "",
+ "health_monitors": [],
+ "health_monitors_status": [],
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "admin_state_up": true,
+ "name": "NewPool",
+ "members": [],
+ "id": "a224402b-794b-4c0c-9d08-d95640a6f5a1",
+ "vip_id": null
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_get_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_get_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_get_response.json
new file mode 100644
index 0000000..00ecef5
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_get_response.json
@@ -0,0 +1,35 @@
+{
+ "pool": {
+ "status": "ACTIVE",
+ "lb_method": "ROUND_ROBIN",
+ "protocol": "HTTP",
+ "provider": "HAPROXY",
+ "description": "",
+ "health_monitors": [
+ "466c8345-28d8-4f84-a246-e04380b0461d",
+ "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ ],
+ "health_monitors_status": [
+ {
+ "status": "ACTIVE",
+ "monitor_id": "466c8345-28d8-4f84-a246-e04380b0461d",
+ "status_dezcription": null
+ },
+ {
+ "status": "ACTIVE",
+ "monitor_id": "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
+ "status_dezcription": null
+ }
+ ],
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "admin_state_up": true,
+ "name": "app_pool",
+ "members": [
+ "701b531b-111a-4f21-ad85-4795b7b12af6",
+ "beb53b4d-230b-4abd-8118-575b8fa006ef"
+ ],
+ "id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "vip_id": "4ec89087-d057-4e2c-911f-60a3b47ee304"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_list_response_paged1.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_list_response_paged1.json
new file mode 100644
index 0000000..b10ce38
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_list_response_paged1.json
@@ -0,0 +1,46 @@
+{
+ "pools": [
+ {
+ "status": "ACTIVE",
+ "lb_method": "ROUND_ROBIN",
+ "protocol": "HTTP",
+ "description": "",
+ "health_monitors": [
+ "466c8345-28d8-4f84-a246-e04380b0461d",
+ "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ ],
+ "health_monitors_status": [
+ {
+ "status": "ACTIVE",
+ "monitor_id": "466c8345-28d8-4f84-a246-e04380b0461d",
+ "status_dezcription": null
+ },
+ {
+ "status": "ACTIVE",
+ "monitor_id": "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
+ "status_dezcription": null
+ }
+ ],
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "admin_state_up": true,
+ "name": "app_pool",
+ "members": [
+ "701b531b-111a-4f21-ad85-4795b7b12af6",
+ "beb53b4d-230b-4abd-8118-575b8fa006ef"
+ ],
+ "id":"72741b06-df4d-4715-b142-276b6bce75ab",
+ "vip_id":"4ec89087-d057-4e2c-911f-60a3b47ee304"
+ }
+ ],
+ "pools_links": [
+ {
+ "href": "/v2.0/lb/pools.json?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718",
+ "rel": "next"
+ },
+ {
+ "href": "/v2.0/lb/pools.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_list_response_paged2.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_list_response_paged2.json
new file mode 100644
index 0000000..dbe902e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_list_response_paged2.json
@@ -0,0 +1,42 @@
+{
+ "pools": [
+ {
+ "status": "ACTIVE",
+ "lb_method": "ROUND_ROBIN",
+ "protocol": "TCP",
+ "description": "",
+ "health_monitors": [
+ "466c8345-28d8-4f84-a246-e04380b0461d",
+ "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ ],
+ "health_monitors_status": [
+ {
+ "status": "ACTIVE",
+ "monitor_id": "466c8345-28d8-4f84-a246-e04380b0461d",
+ "status_dezcription": null
+ },
+ {
+ "status": "ACTIVE",
+ "monitor_id": "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
+ "status_dezcription": null
+ }
+ ],
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "admin_state_up": true,
+ "name": "app_pool2",
+ "members": [
+ "701b531b-111a-4f21-ad85-4795b7b12af6",
+ "beb53b4d-230b-4abd-8118-575b8fa006ef"
+ ],
+ "id":"72741b06-df4d-4715-b142-276b6bce75ab_2",
+ "vip_id":"4ec89087-d057-4e2c-911f-60a3b47ee304"
+ }
+ ],
+ "pools_links": [
+ {
+ "href": "/v2.0/lb/pools.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_update_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_update_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_update_request.json
new file mode 100644
index 0000000..a54b680
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_update_request.json
@@ -0,0 +1,11 @@
+{
+ "pool": {
+ "name": "new_name",
+ "description": "new description",
+ "lb_method": "NEW_LB_METHOD",
+ "health_monitors": [
+ "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ ],
+ "admin_state_up": false
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_update_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_update_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_update_response.json
new file mode 100644
index 0000000..9159529
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/pool_update_response.json
@@ -0,0 +1,29 @@
+{
+ "pool": {
+ "status": "ACTIVE",
+ "lb_method":"NEW_LB_METHOD",
+ "protocol": "HTTP",
+ "provider": "HAPROXY",
+ "description": "new description",
+ "health_monitors": [
+ "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ ],
+ "health_monitors_status": [
+ {
+ "status": "ACTIVE",
+ "monitor_id": "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
+ "status_dezcription": null
+ }
+ ],
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "admin_state_up": false,
+ "name": "new_name",
+ "members": [
+ "701b531b-111a-4f21-ad85-4795b7b12af6",
+ "beb53b4d-230b-4abd-8118-575b8fa006ef"
+ ],
+ "id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "vip_id": "4ec89087-d057-4e2c-911f-60a3b47ee304"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_create_request.json
new file mode 100644
index 0000000..6d159e1
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_create_request.json
@@ -0,0 +1,9 @@
+{
+ "vip": {
+ "protocol": "HTTP",
+ "name": "NewVip",
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "pool_id": "61b1f87a-7a21-4ad3-9dda-7f81d249944f",
+ "protocol_port":80
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_create_response.json
new file mode 100644
index 0000000..7dc958c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_create_response.json
@@ -0,0 +1,17 @@
+{
+ "vip": {
+ "status": "PENDING_CREATE",
+ "protocol": "HTTP",
+ "description": "",
+ "admin_state_up": true,
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "connection_limit": -1,
+ "pool_id": "61b1f87a-7a21-4ad3-9dda-7f81d249944f",
+ "address": "10.0.0.11",
+ "protocol_port": 80,
+ "port_id": "f7e6fe6a-b8b5-43a8-8215-73456b32e0f5",
+ "id": "c987d2be-9a3c-4ac9-a046-e8716b1350e2",
+ "name": "NewVip"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_get_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_get_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_get_response.json
new file mode 100644
index 0000000..c237b39
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_get_response.json
@@ -0,0 +1,21 @@
+{
+ "vip": {
+ "status": "ACTIVE",
+ "protocol": "HTTP",
+ "description": "",
+ "admin_state_up": true,
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "connection_limit": 1000,
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "session_persistence": {
+ "cookie_name": "MyAppCookie",
+ "type": "APP_COOKIE"
+ },
+ "address": "10.0.0.10",
+ "protocol_port": 80,
+ "port_id": "b5a743d6-056b-468b-862d-fb13a9aa694e",
+ "id": "4ec89087-d057-4e2c-911f-60a3b47ee304",
+ "name": "my-vip"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_list_response_paged1.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_list_response_paged1.json
new file mode 100644
index 0000000..eaabe2c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_list_response_paged1.json
@@ -0,0 +1,29 @@
+{
+ "vips": [
+ {
+ "status": "ACTIVE",
+ "protocol": "HTTP",
+ "description": "",
+ "admin_state_up": true,
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "connection_limit": 1000,
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "session_persistence": {
+ "cookie_name": "MyAppCookie",
+ "type": "APP_COOKIE"
+ },
+ "address": "10.0.0.10",
+ "protocol_port": 80,
+ "port_id": "b5a743d6-056b-468b-862d-fb13a9aa694e",
+ "id": "4ec89087-d057-4e2c-911f-60a3b47ee304",
+ "name": "my-vip1"
+ }
+ ],
+ "vips_links": [
+ {
+ "href": "/v2.0/lb/vips.json?marker=396f12f8-521e-4b91-8e21-2e003500433a",
+ "rel": "next"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_list_response_paged2.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_list_response_paged2.json
new file mode 100644
index 0000000..74c46a9
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_list_response_paged2.json
@@ -0,0 +1,29 @@
+{
+ "vips": [
+ {
+ "status": "ACTIVE",
+ "protocol": "HTTPS",
+ "description": "",
+ "admin_state_up": true,
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "connection_limit": 100,
+ "pool_id": "61b1f87a-7a21-4ad3-9dda-7f81d249944f",
+ "session_persistence": {
+ "cookie_name": null,
+ "type": "HTTP_COOKIE"
+ },
+ "address": "10.0.0.11",
+ "protocol_port": 80,
+ "port_id": "f7e6fe6a-b8b5-43a8-8215-73456b32e0f5",
+ "id": "c987d2be-9a3c-4ac9-a046-e8716b1350e2",
+ "name": "my-vip2"
+ }
+ ],
+ "vips_links": [
+ {
+ "href": "/v2.0/lb/vips.json?marker=ABCDEFf8-521e-4b91-8e21-2e003500433a",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_update_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_update_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_update_request.json
new file mode 100644
index 0000000..8d185a3
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_update_request.json
@@ -0,0 +1,13 @@
+{
+ "vip": {
+ "name": "new-name",
+ "description": "new description",
+ "pool_id": "61b1f87a-7a21-4ad3-9dda-7f81d249944f",
+ "session_persistence": {
+ "cookie_name": "MyNewAppCookie",
+ "type": "APP_COOKIE"
+ },
+ "connection_limit": 50,
+ "admin_state_up": false
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_update_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_update_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_update_response.json
new file mode 100644
index 0000000..1502be2
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/lbaas/v1/vip_update_response.json
@@ -0,0 +1,21 @@
+{
+ "vip": {
+ "status": "PENDING_UPDATE",
+ "protocol": "HTTP",
+ "description": "new description",
+ "admin_state_up": false,
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "connection_limit": 50,
+ "pool_id": "61b1f87a-7a21-4ad3-9dda-7f81d249944f",
+ "session_persistence": {
+ "cookie_name": "MyNewAppCookie",
+ "type": "APP_COOKIE"
+ },
+ "address": "10.0.0.11",
+ "protocol_port": 80,
+ "port_id": "f7e6fe6a-b8b5-43a8-8215-73456b32e0f5",
+ "id": "c987d2be-9a3c-4ac9-a046-e8716b1350e2",
+ "name": "new-name"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_networks.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_networks.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_networks.json
new file mode 100644
index 0000000..17b9e9f
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_networks.json
@@ -0,0 +1,62 @@
+{"networks": [
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "16dba3bc-f3fa-4775-afdc-237e12c72f6a"
+ },
+ {
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "31083ae2-420d-48b2-ac98-9f7a4fd8dbdc"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "49c6d6fa-ff2a-459d-b975-75a8d31c9a89"
+ },
+ {
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "5d51d012-3491-4db7-b1b5-6f254015015d"
+ },
+ {
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5f9cf7dc-22ca-4097-8e49-1cc8b23faf17"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6319ecad-6bff-48b2-9b53-02ede8cb7588"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6ba4c788-661f-49ab-9bf8-5f10cbbb2f57"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "74ed170b-5069-4353-ab38-9719766dc57e"
+ },
+ {
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "b71fcac1-e864-4031-8c5b-edbecd9ece36"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "c7681895-d84d-4650-9ca0-82c72036b855"
+ }
+]}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_ports.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_ports.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_ports.json
new file mode 100644
index 0000000..29c3a2b
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_ports.json
@@ -0,0 +1,86 @@
+{"ports": [
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "16dba3bc-f3fa-4775-afdc-237e12c72f6a"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "31083ae2-420d-48b2-ac98-9f7a4fd8dbdc"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "49c6d6fa-ff2a-459d-b975-75a8d31c9a89"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "5d51d012-3491-4db7-b1b5-6f254015015d"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5f9cf7dc-22ca-4097-8e49-1cc8b23faf17"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6319ecad-6bff-48b2-9b53-02ede8cb7588"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6ba4c788-661f-49ab-9bf8-5f10cbbb2f57"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "74ed170b-5069-4353-ab38-9719766dc57e"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "b71fcac1-e864-4031-8c5b-edbecd9ece36"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "c7681895-d84d-4650-9ca0-82c72036b855"
+ }
+]}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_routers.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_routers.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_routers.json
new file mode 100644
index 0000000..14dcfae
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_routers.json
@@ -0,0 +1,74 @@
+{"routers": [
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "16dba3bc-f3fa-4775-afdc-237e12c72f6a"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "31083ae2-420d-48b2-ac98-9f7a4fd8dbdc"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "49c6d6fa-ff2a-459d-b975-75a8d31c9a89"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "5d51d012-3491-4db7-b1b5-6f254015015d"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5f9cf7dc-22ca-4097-8e49-1cc8b23faf17"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6319ecad-6bff-48b2-9b53-02ede8cb7588"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6ba4c788-661f-49ab-9bf8-5f10cbbb2f57"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "74ed170b-5069-4353-ab38-9719766dc57e"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "b71fcac1-e864-4031-8c5b-edbecd9ece36"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "c7681895-d84d-4650-9ca0-82c72036b855"
+ }
+]}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_subnets.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_subnets.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_subnets.json
new file mode 100644
index 0000000..b0061e9
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/list_subnets.json
@@ -0,0 +1,98 @@
+{"subnets": [
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "16dba3bc-f3fa-4775-afdc-237e12c72f6a"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "31083ae2-420d-48b2-ac98-9f7a4fd8dbdc"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "49c6d6fa-ff2a-459d-b975-75a8d31c9a89"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "5d51d012-3491-4db7-b1b5-6f254015015d"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5f9cf7dc-22ca-4097-8e49-1cc8b23faf17"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6319ecad-6bff-48b2-9b53-02ede8cb7588"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6ba4c788-661f-49ab-9bf8-5f10cbbb2f57"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "74ed170b-5069-4353-ab38-9719766dc57e"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "b71fcac1-e864-4031-8c5b-edbecd9ece36"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "c7681895-d84d-4650-9ca0-82c72036b855"
+ }
+]}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/logback.xml b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/logback.xml
new file mode 100644
index 0000000..6559c23
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/logback.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<configuration scan="false">
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>target/test-data/jclouds.log</file>
+
+ <encoder>
+ <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+ </encoder>
+ </appender>
+
+ <appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
+ <file>target/test-data/jclouds-wire.log</file>
+
+ <encoder>
+ <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+ </encoder>
+ </appender>
+
+ <appender name="BLOBSTOREFILE" class="ch.qos.logback.core.FileAppender">
+ <file>target/test-data/jclouds-blobstore.log</file>
+
+ <encoder>
+ <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root>
+ <level value="warn" />
+ </root>
+
+ <logger name="org.jclouds">
+ <level value="DEBUG" />
+ <appender-ref ref="FILE" />
+ </logger>
+
+ <logger name="jclouds.wire">
+ <level value="DEBUG" />
+ <appender-ref ref="WIREFILE" />
+ </logger>
+
+ <logger name="jclouds.headers">
+ <level value="DEBUG" />
+ <appender-ref ref="WIREFILE" />
+ </logger>
+
+ <logger name="jclouds.blobstore">
+ <level value="DEBUG" />
+ <appender-ref ref="BLOBSTOREFILE" />
+ </logger>
+
+</configuration>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network.json
new file mode 100644
index 0000000..06d5d07
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network.json
@@ -0,0 +1,7 @@
+{"network": {
+ "provider:network_type": "local",
+ "status": "ACTIVE",
+ "name": "jclouds-wibble",
+ "tenant_id": "1234567890",
+ "id": "624312ff-d14b-4ba3-9834-1c78d23d574d"
+}}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_bulk_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_bulk_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_bulk_create_request.json
new file mode 100644
index 0000000..e732dde
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_bulk_create_request.json
@@ -0,0 +1,12 @@
+{
+ "networks": [
+ {
+ "provider:network_type": "local",
+ "name": "jclouds-wibble"
+ },
+ {
+ "provider:network_type": "local",
+ "name": "jclouds-wibble2"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_bulk_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_bulk_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_bulk_create_response.json
new file mode 100644
index 0000000..ebde974
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_bulk_create_response.json
@@ -0,0 +1,18 @@
+{
+ "networks": [
+ {
+ "provider:network_type": "local",
+ "status": "ACTIVE",
+ "name": "jclouds-wibble",
+ "tenant_id": "1234567890",
+ "id": "624312ff-d14b-4ba3-9834-1c78d23d574d"
+ },
+ {
+ "provider:network_type": "local",
+ "status": "ACTIVE",
+ "name": "jclouds-wibble2",
+ "tenant_id": "1234567890",
+ "id": "624312ff-d14b-4ba3-9834-1c78d23d574e"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_create_request.json
new file mode 100644
index 0000000..f6bcfad
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_create_request.json
@@ -0,0 +1,4 @@
+{"network": {
+ "provider:network_type": "local",
+ "name": "jclouds-wibble"
+}}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_create_response.json
new file mode 100644
index 0000000..06d5d07
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_create_response.json
@@ -0,0 +1,7 @@
+{"network": {
+ "provider:network_type": "local",
+ "status": "ACTIVE",
+ "name": "jclouds-wibble",
+ "tenant_id": "1234567890",
+ "id": "624312ff-d14b-4ba3-9834-1c78d23d574d"
+}}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_get_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_get_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_get_response.json
new file mode 100644
index 0000000..06d5d07
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_get_response.json
@@ -0,0 +1,7 @@
+{"network": {
+ "provider:network_type": "local",
+ "status": "ACTIVE",
+ "name": "jclouds-wibble",
+ "tenant_id": "1234567890",
+ "id": "624312ff-d14b-4ba3-9834-1c78d23d574d"
+}}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_list_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_list_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_list_response.json
new file mode 100644
index 0000000..17b9e9f
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_list_response.json
@@ -0,0 +1,62 @@
+{"networks": [
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "16dba3bc-f3fa-4775-afdc-237e12c72f6a"
+ },
+ {
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "31083ae2-420d-48b2-ac98-9f7a4fd8dbdc"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "49c6d6fa-ff2a-459d-b975-75a8d31c9a89"
+ },
+ {
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "5d51d012-3491-4db7-b1b5-6f254015015d"
+ },
+ {
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5f9cf7dc-22ca-4097-8e49-1cc8b23faf17"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6319ecad-6bff-48b2-9b53-02ede8cb7588"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6ba4c788-661f-49ab-9bf8-5f10cbbb2f57"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "74ed170b-5069-4353-ab38-9719766dc57e"
+ },
+ {
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "b71fcac1-e864-4031-8c5b-edbecd9ece36"
+ },
+ {
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "c7681895-d84d-4650-9ca0-82c72036b855"
+ }
+]}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_list_response_paged1.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_list_response_paged1.json
new file mode 100644
index 0000000..9fe7e54
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_list_response_paged1.json
@@ -0,0 +1,40 @@
+{
+ "networks": [
+ {
+ "admin_state_up": true,
+ "id": "396f12f8-521e-4b91-8e21-2e003500433a",
+ "name": "net3",
+ "provider:network_type": "vlan",
+ "provider:physical_network": "physnet1",
+ "provider:segmentation_id": 1002,
+ "router:external": false,
+ "shared": false,
+ "status": "ACTIVE",
+ "subnets": [],
+ "tenant_id": "20bd52ff3e1b40039c312395b04683cf"
+ },
+ {
+ "admin_state_up": true,
+ "id": "71c1e68c-171a-4aa2-aca5-50ea153a3718",
+ "name": "net2",
+ "provider:network_type": "vlan",
+ "provider:physical_network": "physnet1",
+ "provider:segmentation_id": 1001,
+ "router:external": false,
+ "shared": false,
+ "status": "ACTIVE",
+ "subnets": [],
+ "tenant_id": "20bd52ff3e1b40039c312395b04683cf"
+ }
+ ],
+ "networks_links": [
+ {
+ "href": "/v2.0/networks.json?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718",
+ "rel": "next"
+ },
+ {
+ "href": "/v2.0/networks.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_list_response_paged2.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_list_response_paged2.json
new file mode 100644
index 0000000..b03714f
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_list_response_paged2.json
@@ -0,0 +1,36 @@
+{
+ "networks": [
+ {
+ "admin_state_up": true,
+ "id": "396f12f8-521e-4b91-8e21-2e003500433a_2",
+ "name": "net3",
+ "provider:network_type": "vlan",
+ "provider:physical_network": "physnet1",
+ "provider:segmentation_id": 1002,
+ "router:external": false,
+ "shared": false,
+ "status": "ACTIVE",
+ "subnets": [],
+ "tenant_id": "20bd52ff3e1b40039c312395b04683cf"
+ },
+ {
+ "admin_state_up": true,
+ "id": "71c1e68c-171a-4aa2-aca5-50ea153a3718_2",
+ "name": "net2",
+ "provider:network_type": "vlan",
+ "provider:physical_network": "physnet1",
+ "provider:segmentation_id": 1001,
+ "router:external": false,
+ "shared": false,
+ "status": "ACTIVE",
+ "subnets": [],
+ "tenant_id": "20bd52ff3e1b40039c312395b04683cf"
+ }
+ ],
+ "networks_links": [
+ {
+ "href": "/v2.0/networks.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_update_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_update_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_update_request.json
new file mode 100644
index 0000000..a9f0aee
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_update_request.json
@@ -0,0 +1,4 @@
+{"network": {
+ "provider:network_type": "local",
+ "name": "jclouds-wibble-updated"
+}}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_update_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_update_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_update_response.json
new file mode 100644
index 0000000..140b648
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/network_update_response.json
@@ -0,0 +1,11 @@
+{
+ "network": {
+ "status": "ACTIVE",
+ "subnets": [],
+ "name": "updated_name",
+ "admin_state_up": false,
+ "shared": false,
+ "tenant_id": "c1210485b2424d48804aad5d39c61b8f",
+ "id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port.json
new file mode 100644
index 0000000..15629a6
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port.json
@@ -0,0 +1,7 @@
+{"port": {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-wibble",
+ "tenant_id": "1234567890",
+ "id": "624312ff-d14b-4ba3-9834-1c78d23d574d"
+}}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_bulk_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_bulk_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_bulk_request.json
new file mode 100644
index 0000000..c0567c6
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_bulk_request.json
@@ -0,0 +1,22 @@
+{
+ "ports": [
+ {
+ "admin_state_up": true,
+ "device_id": "24df1d04-d5cb-41e1-8de5-61ed77c558df",
+ "name": "port1",
+ "network_id": "64239a54-dcc4-4b39-920b-b37c2144effa",
+ "security_groups": [
+ "dbc107f4-afcd-4d5a-9352-f68f82241d5b"
+ ]
+ },
+ {
+ "admin_state_up": false,
+ "name": "port2",
+ "network_id": "e6031bc2-901a-4c66-82da-f4c32ed89406",
+ "security_groups": [
+ "8bf3f7cc-8471-40b1-815f-9da47e79775b",
+ "dbc107f4-afcd-4d5a-9352-f68f82241d5b"
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_bulk_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_bulk_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_bulk_response.json
new file mode 100644
index 0000000..3ecfb52
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_bulk_response.json
@@ -0,0 +1,47 @@
+{
+ "ports": [
+ {
+ "admin_state_up": true,
+ "allowed_address_pairs": [],
+ "device_id": "24df1d04-d5cb-41e1-8de5-61ed77c558df",
+ "device_owner": "",
+ "fixed_ips": [
+ {
+ "ip_address": "10.56.4.2",
+ "subnet_id": "b0e7435c-1512-45fb-aa9e-9a7c5932fb30"
+ }
+ ],
+ "id": "4fa2a5b2-d758-449d-80d6-dff31df9e91e",
+ "mac_address": "fa:16:3e:63:b0:82",
+ "name": "port1",
+ "network_id": "64239a54-dcc4-4b39-920b-b37c2144effa",
+ "security_groups": [
+ "dbc107f4-afcd-4d5a-9352-f68f82241d5b"
+ ],
+ "status": "DOWN",
+ "tenant_id": "d19231fc08ec4bc4829b668040d34512"
+ },
+ {
+ "admin_state_up": false,
+ "allowed_address_pairs": [],
+ "device_id": "",
+ "device_owner": "",
+ "fixed_ips": [
+ {
+ "ip_address": "192.168.199.2",
+ "subnet_id": "0468a7a7-290d-4127-aedd-6c9449775a24"
+ }
+ ],
+ "id": "d3c059b8-40fd-489a-8d17-97bde9370987",
+ "mac_address": "fa:16:3e:86:09:06",
+ "name": "port2",
+ "network_id": "e6031bc2-901a-4c66-82da-f4c32ed89406",
+ "security_groups": [
+ "8bf3f7cc-8471-40b1-815f-9da47e79775b",
+ "dbc107f4-afcd-4d5a-9352-f68f82241d5b"
+ ],
+ "status": "DOWN",
+ "tenant_id": "d19231fc08ec4bc4829b668040d34512"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_request.json
new file mode 100644
index 0000000..d9e8d33
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_request.json
@@ -0,0 +1,14 @@
+{
+ "port": {
+ "admin_state_up": true,
+ "device_id": "d6b4d3a5-c700-476f-b609-1493dd9dadc0",
+ "name": "port1",
+ "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12",
+ "allowed_address_pairs": [
+ {
+ "ip_address": "111.222.333.444",
+ "mac_address": "12"
+ }
+ ]
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_response.json
new file mode 100644
index 0000000..696ac44
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_create_response.json
@@ -0,0 +1,29 @@
+{
+ "port": {
+ "admin_state_up": true,
+ "device_id": "d6b4d3a5-c700-476f-b609-1493dd9dadc0",
+ "device_owner": "",
+ "allowed_address_pairs": [
+ {
+ "ip_address": "192.168.1.1",
+ "mac_address": "12:12"
+ },
+ {
+ "mac_address": "12:13",
+ "ip_address": "192.168.1.2"
+ }
+ ],
+ "fixed_ips": [
+ {
+ "ip_address": "192.168.111.4",
+ "subnet_id": "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27"
+ }
+ ],
+ "id": "ebe69f1e-bc26-4db5-bed0-c0afb4afe3db",
+ "mac_address": "fa:16:3e:a6:50:c1",
+ "name": "port1",
+ "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12",
+ "status": "ACTIVE",
+ "tenant_id": "cf1a5775e766426cb1968766d0191908"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_get_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_get_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_get_response.json
new file mode 100644
index 0000000..d9c154d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_get_response.json
@@ -0,0 +1,10 @@
+{"port": {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-wibble",
+ "tenant_id": "1234567890",
+ "id": "624312ff-d14b-4ba3-9834-1c78d23d574d",
+ "binding:vnic_type": "normal",
+ "binding:vif_type": "hyperv",
+ "binding:vif_details": {"name1": "value1", "name2": {"mapname2": 3}}
+}}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_list_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_list_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_list_response.json
new file mode 100644
index 0000000..29c3a2b
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_list_response.json
@@ -0,0 +1,86 @@
+{"ports": [
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "16dba3bc-f3fa-4775-afdc-237e12c72f6a"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "31083ae2-420d-48b2-ac98-9f7a4fd8dbdc"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "49c6d6fa-ff2a-459d-b975-75a8d31c9a89"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "5d51d012-3491-4db7-b1b5-6f254015015d"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5f9cf7dc-22ca-4097-8e49-1cc8b23faf17"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6319ecad-6bff-48b2-9b53-02ede8cb7588"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6ba4c788-661f-49ab-9bf8-5f10cbbb2f57"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "74ed170b-5069-4353-ab38-9719766dc57e"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "b71fcac1-e864-4031-8c5b-edbecd9ece36"
+ },
+ {
+ "status": "ACTIVE",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "c7681895-d84d-4650-9ca0-82c72036b855"
+ }
+]}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_list_response_paged1.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_list_response_paged1.json
new file mode 100644
index 0000000..f3bd818
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_list_response_paged1.json
@@ -0,0 +1,48 @@
+{
+ "ports": [
+ {
+ "admin_state_up": true,
+ "device_id": "257614cc-e178-4c92-9c61-3b28d40eca44",
+ "device_owner": "",
+ "fixed_ips": [
+ {
+ "ip_address": "192.168.111.3",
+ "subnet_id": "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27"
+ }
+ ],
+ "id": "24e6637e-c521-45fc-8b8b-d7331aa3c99f",
+ "mac_address": "fa:16:3e:0f:3f:b5",
+ "name": "",
+ "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12",
+ "status": "ACTIVE",
+ "tenant_id": "cf1a5775e766426cb1968766d0191908"
+ },
+ {
+ "admin_state_up": true,
+ "device_id": "d266f9de-fe2c-4705-93b3-9da71168c93b",
+ "device_owner": "",
+ "fixed_ips": [
+ {
+ "ip_address": "192.168.111.2",
+ "subnet_id": "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27"
+ }
+ ],
+ "id": "e54dfd9b-ce6e-47f7-af47-1609cfd1cdb0",
+ "mac_address": "fa:16:3e:f5:41:7f",
+ "name": "",
+ "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12",
+ "status": "ACTIVE",
+ "tenant_id": "cf1a5775e766426cb1968766d0191908"
+ }
+ ],
+ "ports_links": [
+ {
+ "href": "/v2.0/ports.json?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718",
+ "rel": "next"
+ },
+ {
+ "href": "/v2.0/ports.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_list_response_paged2.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_list_response_paged2.json
new file mode 100644
index 0000000..ccd4c93
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_list_response_paged2.json
@@ -0,0 +1,44 @@
+{
+ "ports": [
+ {
+ "admin_state_up": true,
+ "device_id": "257614cc-e178-4c92-9c61-3b28d40eca44_3",
+ "device_owner": "",
+ "fixed_ips": [
+ {
+ "ip_address": "192.168.111.3",
+ "subnet_id": "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27"
+ }
+ ],
+ "id": "24e6637e-c521-45fc-8b8b-d7331aa3c99f-2_3",
+ "mac_address": "fa:16:3e:0f:3f:b5",
+ "name": "3",
+ "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12",
+ "status": "ACTIVE",
+ "tenant_id": "cf1a5775e766426cb1968766d0191908"
+ },
+ {
+ "admin_state_up": true,
+ "device_id": "d266f9de-fe2c-4705-93b3-9da71168c93b",
+ "device_owner": "",
+ "fixed_ips": [
+ {
+ "ip_address": "192.168.111.2",
+ "subnet_id": "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27"
+ }
+ ],
+ "id": "e54dfd9b-ce6e-47f7-af47-1609cfd1cdb0_4",
+ "mac_address": "fa:16:3e:f5:41:7f",
+ "name": "4",
+ "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12",
+ "status": "ACTIVE",
+ "tenant_id": "cf1a5775e766426cb1968766d0191908"
+ }
+ ],
+ "ports_links": [
+ {
+ "href": "/v2.0/ports.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_update_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_update_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_update_request.json
new file mode 100644
index 0000000..f5af476
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_update_request.json
@@ -0,0 +1,8 @@
+{
+ "port": {
+ "security_groups": [
+ "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "c5ab5c29-2c99-44cb-a4b8-e70a88b77799"
+ ]
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_update_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_update_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_update_response.json
new file mode 100644
index 0000000..b88db25
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/port_update_response.json
@@ -0,0 +1,23 @@
+{
+ "port": {
+ "admin_state_up": true,
+ "device_id": "24df1d04-d5cb-41e1-8de5-61ed77c558df",
+ "device_owner": "compute:None",
+ "fixed_ips": [
+ {
+ "ip_address": "10.0.0.3",
+ "subnet_id": "3b498f11-0a20-43ed-b992-0e4202d5f930"
+ }
+ ],
+ "id": "1d8591f4-7b62-428e-857d-e82a15e5a7f1",
+ "mac_address": "fa:16:3e:b6:da:54",
+ "name": "",
+ "network_id": "abaf2e70-4305-4e8d-ac70-3e4cc5f66a07",
+ "security_groups": [
+ "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "c5ab5c29-2c99-44cb-a4b8-e70a88b77799"
+ ],
+ "status": "ACTIVE",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router.json
new file mode 100644
index 0000000..b39e3c8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router.json
@@ -0,0 +1,9 @@
+{"router": {
+ "status": "ACTIVE",
+ "external_gateway_info": {
+ "network_id": "624312ff-d14b-4ba3-9834-1c78d23d574d"
+ },
+ "name": "jclouds-wibble",
+ "tenant_id": "1234567890",
+ "id": "16dba3bc-f3fa-4775-afdc-237e12c72f6a"
+}}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_add_interface_port_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_add_interface_port_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_add_interface_port_request.json
new file mode 100644
index 0000000..bae800a
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_add_interface_port_request.json
@@ -0,0 +1,3 @@
+{
+ "port_id": "portid"
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_add_interface_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_add_interface_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_add_interface_request.json
new file mode 100644
index 0000000..107e6e4
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_add_interface_request.json
@@ -0,0 +1,3 @@
+{
+ "subnet_id": "a2f1f29d-571b-4533-907f-5803ab96ead1"
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_add_interface_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_add_interface_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_add_interface_response.json
new file mode 100644
index 0000000..d28007c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_add_interface_response.json
@@ -0,0 +1,4 @@
+{
+ "subnet_id": "a2f1f29d-571b-4533-907f-5803ab96ead1",
+ "port_id": "3a44f4e5-1694-493a-a1fb-393881c673a4"
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_create_request.json
new file mode 100644
index 0000000..106e5d4
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_create_request.json
@@ -0,0 +1,9 @@
+{
+ "router": {
+ "name": "another_router",
+ "external_gateway_info": {
+ "network_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b"
+ },
+ "admin_state_up": true
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_create_response.json
new file mode 100644
index 0000000..d851d76
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_create_response.json
@@ -0,0 +1,12 @@
+{
+ "router": {
+ "status": "ACTIVE",
+ "external_gateway_info": {
+ "network_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b"
+ },
+ "name": "another_router",
+ "admin_state_up": true,
+ "tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
+ "id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_get_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_get_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_get_response.json
new file mode 100644
index 0000000..77bdebf
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_get_response.json
@@ -0,0 +1,12 @@
+{
+ "router": {
+ "status": "ACTIVE",
+ "external_gateway_info": {
+ "network_id": "3c5bcddd-6af9-4e6b-9c3e-c153e521cab8"
+ },
+ "name": "router1",
+ "admin_state_up": true,
+ "tenant_id": "33a40233088643acb66ff6eb0ebea679",
+ "id": "a9254bdb-2613-4a13-ac4c-adc581fba50d"
+ }
+}
[33/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadata.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadata.java
new file mode 100644
index 0000000..043bed8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadata.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2;
+
+import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
+import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule;
+import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule;
+import org.jclouds.openstack.neutron.v2.config.NeutronHttpApiModule;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+
+/**
+ * Implementation of {@link org.jclouds.apis.ApiMetadata} for Neutron 2.0 API
+ *
+ */
+public class NeutronApiMetadata extends BaseHttpApiMetadata<NeutronApi> {
+
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
+ }
+
+ public NeutronApiMetadata() {
+ this(new Builder());
+ }
+
+ protected NeutronApiMetadata(Builder builder) {
+ super(builder);
+ }
+
+ public static Properties defaultProperties() {
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
+ properties.setProperty(SERVICE_TYPE, ServiceType.NETWORK);
+ properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS);
+ return properties;
+ }
+
+ public static class Builder extends BaseHttpApiMetadata.Builder<NeutronApi, Builder> {
+
+ protected Builder() {
+ super(NeutronApi.class);
+ id("openstack-neutron")
+ .name("OpenStack Neutron API")
+ .identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant")
+ .credentialName("${password}")
+ .endpointName("Neutron base url ending in /v2.0/")
+ .documentation(URI.create("http://docs.openstack.org/api/openstack-network/2.0/content/"))
+ .version("v2.0")
+ .defaultEndpoint("http://localhost:5000/v2.0/")
+ .defaultProperties(NeutronApiMetadata.defaultProperties())
+ .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
+ .add(AuthenticationApiModule.class)
+ .add(KeystoneAuthenticationModule.class)
+ .add(RegionModule.class)
+ .add(NeutronHttpApiModule.class).build());
+ }
+
+ @Override
+ public NeutronApiMetadata build() {
+ return new NeutronApiMetadata(this);
+ }
+
+ @Override
+ public Builder fromApiMetadata(ApiMetadata in) {
+ super.fromApiMetadata(in);
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java
new file mode 100644
index 0000000..90c59f2
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.config;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.Multimap;
+import com.google.inject.Provides;
+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.json.config.GsonModule.DateAdapter;
+import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.handlers.NeutronErrorHandler;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.openstack.v2_0.functions.PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet;
+import org.jclouds.openstack.neutron.v2.extensions.ExtensionNamespaces;
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.jclouds.rest.config.HttpApiModule;
+import org.jclouds.rest.functions.ImplicitOptionalConverter;
+
+import javax.inject.Provider;
+import javax.inject.Singleton;
+import java.net.URI;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Configures the Neutron connection.
+ *
+ */
+@ConfiguresHttpApi
+public class NeutronHttpApiModule extends HttpApiModule<NeutronApi> {
+
+ @Override
+ protected void configure() {
+ bind(DateAdapter.class).to(Iso8601DateAdapter.class);
+ bind(ImplicitOptionalConverter.class).to(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class);
+ super.configure();
+ }
+
+ @Provides
+ @Singleton
+ public Multimap<URI, URI> aliases() {
+ return ImmutableMultimap.<URI, URI>builder()
+ .put(URI.create(ExtensionNamespaces.L3_ROUTER),
+ URI.create("http://docs.openstack.org/ext/neutron/router/api/v1.0"))
+ .put(URI.create(ExtensionNamespaces.SECURITY_GROUPS),
+ URI.create("http://docs.openstack.org/ext/securitygroups/api/v2.0"))
+ .put(URI.create(ExtensionNamespaces.LBAAS),
+ URI.create("http://docs.openstack.org/networking/ext/lbaas/api/v1.0"))
+ .build();
+ }
+
+ @Provides
+ @Singleton
+ public LoadingCache<String, Set<? extends Extension>> provideExtensionsByRegion(final Provider<NeutronApi> neutronApi) {
+ return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
+ .build(new CacheLoader<String, Set<? extends Extension>>() {
+ @Override
+ public Set<? extends Extension> load(String key) throws Exception {
+ return neutronApi.get().getExtensionApi(key).list();
+ }
+ });
+ }
+
+ @Override
+ protected void bindErrorHandlers() {
+ bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(NeutronErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(NeutronErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(NeutronErrorHandler.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AddressPair.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AddressPair.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AddressPair.java
new file mode 100644
index 0000000..e2d888c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AddressPair.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * Contains a mapping between a MAC address and an IP address.
+ */
+public class AddressPair {
+
+ @Named("mac_address")
+ private String macAddress;
+ @Named("ip_address")
+ private String ipAddress;
+
+ @ConstructorProperties({"mac_address", "ip_address"})
+ protected AddressPair(String macAddress, String ipAddress) {
+ checkNotNull(macAddress, "mac address should not be null");
+ checkNotNull(ipAddress, "ip should not be null");
+ this.macAddress = macAddress;
+ this.ipAddress = ipAddress;
+ }
+
+ /**
+ * Copy constructor
+ * @param addressPair
+ */
+ private AddressPair(AddressPair addressPair) {
+ this(addressPair.getMacAddress(), addressPair.getIpAddress());
+ }
+
+ /**
+ * Default constructor
+ */
+ private AddressPair() {}
+
+ /**
+ * @return the macAddress of the AddressPair
+ */
+ @Nullable
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ /**
+ * @return the ipAddress of the AddressPair
+ */
+ @Nullable
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(macAddress, ipAddress);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ AddressPair that = AddressPair.class.cast(obj);
+ return Objects.equal(this.macAddress, that.macAddress) && Objects.equal(this.ipAddress, that.ipAddress);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this).add("macAddress", macAddress).add("ipAddress", ipAddress);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ /**
+ * Returns a builder, but requires the user to specify any parameters required when creating a resource.
+ * In this case, both parameters are required.
+ * @return the Builder for AddressPair
+ */
+ public static Builder builder(String macAddress, String ipAddress) {
+ return new Builder(macAddress, ipAddress);
+ }
+
+ /**
+ * Gets a Builder configured as this object.
+ */
+ public Builder toBuilder() {
+ return new Builder().fromAddressPair(this);
+ }
+
+ public static class Builder {
+ // Keep track of the builder's state.
+ private AddressPair addressPair;
+
+ /**
+ * No-parameters constructor used when updating.
+ * */
+ private Builder() {
+ addressPair = new AddressPair();
+ }
+
+ /**
+ * Required parameters constructor used when creating.
+ * @param macAddress
+ * @param ipAddress
+ */
+ private Builder(String macAddress, String ipAddress) {
+ addressPair = new AddressPair();
+ addressPair.macAddress = macAddress;
+ addressPair.ipAddress = ipAddress;
+ }
+
+ /**
+ * Provide the macAddress to the AddressPair's Builder.
+ *
+ * @return the Builder.
+ * @see AddressPair#getMacAddress()
+ */
+ public Builder macAddress(String macAddress) {
+ addressPair.macAddress = macAddress;
+ return this;
+ }
+
+ /**
+ * Provide the ipAddress to the AddressPair's Builder.
+ *
+ * @return the Builder.
+ * @see AddressPair#getIpAddress()
+ */
+ public Builder ipAddress(String ipAddress) {
+ addressPair.ipAddress = ipAddress;
+ return this;
+ }
+
+ /**
+ * @return a AddressPair constructed with this Builder.
+ */
+ public AddressPair build() {
+ // Use the copy constructor to copy the builder's state (config) object and pass back to the user.
+ // Immutability is preserved, and fields are defined only once.
+ return new AddressPair(addressPair);
+ }
+
+ /**
+ * @return a Builder from another AddressPair.
+ */
+ public Builder fromAddressPair(AddressPair in) {
+ return this.macAddress(in.getMacAddress()).ipAddress(in.getIpAddress());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AllocationPool.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AllocationPool.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AllocationPool.java
new file mode 100644
index 0000000..6d20999
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/AllocationPool.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * A Neutron Subnet Allocation Pool
+ * Contains a start and an end IP address describing the pool.
+ *
+ * @see <a
+ * href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api
+ * doc</a>
+ */
+public class AllocationPool {
+
+ protected final String start;
+ protected final String end;
+
+ @ConstructorProperties({"start", "end"})
+ protected AllocationPool(String start, String end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ /**
+ * @return the start of the AllocationPool
+ */
+ @Nullable
+ public String getStart() {
+ return start;
+ }
+
+ /**
+ * @return the end of the AllocationPool
+ */
+ @Nullable
+ public String getEnd() {
+ return end;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(start, end);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ AllocationPool that = AllocationPool.class.cast(obj);
+ return Objects.equal(this.start, that.start) && Objects.equal(this.end, that.end);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this).add("start", start).add("end", end);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ /**
+ * @return the Builder for AllocationPool
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Gets a Builder configured as this object.
+ */
+ public Builder toBuilder() {
+ return new Builder().fromAllocationPool(this);
+ }
+
+ public static class Builder {
+ protected String start;
+ protected String end;
+
+ /**
+ * Provide the start to the AllocationPool's Builder.
+ *
+ * @return the Builder.
+ * @see AllocationPool#getStart()
+ */
+ public Builder start(String start) {
+ this.start = start;
+ return this;
+ }
+
+ /**
+ * Provide the end to the AllocationPool's Builder.
+ *
+ * @return the Builder.
+ * @see AllocationPool#getEnd()
+ */
+ public Builder end(String end) {
+ this.end = end;
+ return this;
+ }
+
+ /**
+ * @return a AllocationPool constructed with this Builder.
+ */
+ public AllocationPool build() {
+ return new AllocationPool(start, end);
+ }
+
+ /**
+ * @return a Builder from another AllocationPool.
+ */
+ public Builder fromAllocationPool(AllocationPool in) {
+ return this.start(in.getStart()).end(in.getEnd());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExternalGatewayInfo.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExternalGatewayInfo.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExternalGatewayInfo.java
new file mode 100644
index 0000000..4dd6505
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExternalGatewayInfo.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import com.google.common.base.Objects;
+import org.jclouds.javax.annotation.Nullable;
+
+import javax.inject.Named;
+import java.beans.ConstructorProperties;
+
+/**
+ * Information on the external gateway for the router
+ */
+public class ExternalGatewayInfo {
+
+ @Named("network_id")
+ protected final String networkId;
+ @Named("enable_snat")
+ protected final Boolean enableSnat;
+
+ @ConstructorProperties({"network_id", "enable_snat"})
+ protected ExternalGatewayInfo(String networkId, Boolean enableSnat) {
+ this.networkId = networkId;
+ this.enableSnat = enableSnat;
+ }
+
+ /**
+ * @return the networkId of the ExternalGatewayInfo
+ */
+ @Nullable
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ /**
+ * @return the enableSnat status of the ExternalGatewayInfo
+ */
+ @Nullable
+ public Boolean getEnableSnat() {
+ return enableSnat;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(networkId, enableSnat);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ ExternalGatewayInfo that = (ExternalGatewayInfo) o;
+
+ return Objects.equal(this.networkId, that.networkId) &&
+ Objects.equal(this.enableSnat, that.enableSnat);
+ }
+
+ /**
+ * @return the Builder for ExternalGatewayInfo
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Gets a Builder configured as this object.
+ */
+ public Builder toBuilder() {
+ return new Builder().fromExternalGatewayInfo(this);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this)
+ .add("networkId", networkId)
+ .add("enableSnat", enableSnat)
+ .toString();
+ }
+
+ public static class Builder {
+ protected String networkId;
+ protected Boolean enableSnat;
+
+ /**
+ * Provide the networkId to the ExternalGatewayInfo's Builder.
+ *
+ * @return the Builder.
+ * @see ExternalGatewayInfo#getNetworkId()
+ */
+ public Builder networkId(String networkId) {
+ this.networkId = networkId;
+ return this;
+ }
+
+ /**
+ * Provide the enableSnat status to the ExternalGatewayInfo's Builder.
+ *
+ * @return the Builder.
+ * @see ExternalGatewayInfo#getEnableSnat()
+ */
+ public Builder enableSnat(Boolean enableSnat) {
+ this.enableSnat = enableSnat;
+ return this;
+ }
+
+ /**
+ * @return a ExternalGatewayInfo constructed with this Builder.
+ */
+ public ExternalGatewayInfo build() {
+ return new ExternalGatewayInfo(networkId, enableSnat);
+ }
+
+ /**
+ * @return a Builder from another ExternalGatewayInfo.
+ */
+ public Builder fromExternalGatewayInfo(ExternalGatewayInfo in) {
+ return this.networkId(in.getNetworkId()).enableSnat(in.getEnableSnat());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExtraDhcpOption.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExtraDhcpOption.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExtraDhcpOption.java
new file mode 100644
index 0000000..89060f7
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/ExtraDhcpOption.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import com.google.common.base.Objects;
+import org.jclouds.javax.annotation.Nullable;
+
+import javax.inject.Named;
+import java.beans.ConstructorProperties;
+
+/**
+ * This is used to provide additional DHCP-related options to Subnet. This is
+ * based on a neutron extension.
+ * For example PXE boot options to DHCP clients can be specified (e.g. tftp-server,
+ * server-ip-address, bootfile-name)
+ *
+ * @see <a
+ * href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api
+ * doc</a>
+ */
+public class ExtraDhcpOption {
+
+ protected final String id;
+ @Named("opt_name")
+ protected final String optionName;
+ @Named("opt_value")
+ protected final String optionValue;
+
+ @ConstructorProperties({"id", "opt_name", "opt_value"})
+ protected ExtraDhcpOption(String id, String optionName, String optionValue) {
+ this.id = id;
+ this.optionName = optionName;
+ this.optionValue = optionValue;
+ }
+
+ /**
+ * @return the id of the ExtraDhcpOption
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the optionName of the ExtraDhcpOption
+ */
+ @Nullable
+ public String getOptionName() {
+ return optionName;
+ }
+
+ /**
+ * @return the optionValue of the ExtraDhcpOption
+ */
+ @Nullable
+ public String getOptionValue() {
+ return optionValue;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, optionName, optionValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ ExtraDhcpOption that = ExtraDhcpOption.class.cast(obj);
+ return Objects.equal(this.id, that.id) && Objects.equal(this.optionName, that.optionName)
+ && Objects.equal(this.optionValue, that.optionValue);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this).add("id", id).add("optionName", optionName).add("optionValue", optionValue);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ /**
+ * @return the Builder for ExtraDhcpOption
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Gets a Builder configured as this object.
+ */
+ public Builder toBuilder() {
+ return new Builder().fromExtraDhcpOption(this);
+ }
+
+ public static class Builder {
+ protected String id;
+ protected String optionName;
+ protected String optionValue;
+
+ /**
+ * Provide the id to the ExtraDhcpOption's Builder.
+ *
+ * @return the Builder.
+ * @see ExtraDhcpOption#getId()
+ */
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * Provide the optionName to the ExtraDhcpOption's Builder.
+ *
+ * @return the Builder.
+ * @see ExtraDhcpOption#getOptionName()
+ */
+ public Builder optionName(String optionName) {
+ this.optionName = optionName;
+ return this;
+ }
+
+ /**
+ * Provide the optionValue to the ExtraDhcpOption's Builder.
+ *
+ * @return the Builder.
+ * @see ExtraDhcpOption#getOptionValue()
+ */
+ public Builder optionValue(String optionValue) {
+ this.optionValue = optionValue;
+ return this;
+ }
+
+ /**
+ * @return a ExtraDhcpOption constructed with this Builder.
+ */
+ public ExtraDhcpOption build() {
+ return new ExtraDhcpOption(id, optionName, optionValue);
+ }
+
+ /**
+ * @return a Builder from another ExtraDhcpOption.
+ */
+ public Builder fromExtraDhcpOption(ExtraDhcpOption in) {
+ return this.id(in.getId()).optionName(in.getOptionName()).optionValue(in.getOptionValue());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIP.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIP.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIP.java
new file mode 100644
index 0000000..fa5a8b5
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIP.java
@@ -0,0 +1,315 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import java.beans.ConstructorProperties;
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+import com.google.common.base.Objects;
+
+/**
+ * A Neutron Floating IP
+ *
+ */
+public class FloatingIP {
+
+ private String id;
+ @Named("router_id")
+ private String routerId;
+ @Named("tenant_id")
+ private String tenantId;
+ // Only mandatory attribute when creating
+ @Named("floating_network_id")
+ private String floatingNetworkId;
+ @Named("fixed_ip_address")
+ private String fixedIpAddress;
+ @Named("floating_ip_address")
+ private String floatingIpAddress;
+ @Named("port_id")
+ private String portId;
+
+ /**
+ * Deserialization constructor
+ */
+ @ConstructorProperties({"id", "router_id", "tenant_id", "floating_network_id", "fixed_ip_address",
+ "floating_ip_address", "port_id"})
+ private FloatingIP(String id, String routerId, String tenantId, String floatingNetworkId, String fixedIpAddress,
+ String floatingIpAddress, String portId) {
+ this.id = id;
+ this.routerId = routerId;
+ this.tenantId = tenantId;
+ this.floatingNetworkId = floatingNetworkId;
+ this.fixedIpAddress = fixedIpAddress;
+ this.floatingIpAddress = floatingIpAddress;
+ this.portId = portId;
+ }
+
+ private FloatingIP() {}
+
+ /**
+ * @param floatingIP The floating IP to copy from
+ */
+ private FloatingIP(FloatingIP floatingIP) {
+ this(floatingIP.id, floatingIP.routerId, floatingIP.tenantId, floatingIP.floatingNetworkId,
+ floatingIP.fixedIpAddress, floatingIP.floatingIpAddress, floatingIP.portId);
+ }
+
+ /**
+ * @return the id of the floating IP
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the router id of this floating IP
+ */
+ @Nullable
+ public String getRouterId() {
+ return routerId;
+ }
+
+ /**
+ * @return the tenant id of the Floating IP
+ */
+ @Nullable
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return the floating network id for this floating IP
+ */
+ @Nullable
+ public String getFloatingNetworkId() {
+ return floatingNetworkId;
+ }
+
+ /**
+ * @return the fixed IP address for this floating IP
+ */
+ @Nullable
+ public String getFixedIpAddress() {
+ return fixedIpAddress;
+ }
+
+ /**
+ * @return the floating IP address for this floating IP
+ */
+ @Nullable
+ public String getFloatingIpAddress() {
+ return floatingIpAddress;
+ }
+
+ /**
+ * @return the port id for this floating IP
+ */
+ @Nullable
+ public String getPortId() {
+ return portId;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ FloatingIP that = (FloatingIP) o;
+
+ return Objects.equal(this.id, that.id) &&
+ Objects.equal(this.routerId, that.routerId) &&
+ Objects.equal(this.tenantId, that.tenantId) &&
+ Objects.equal(this.floatingNetworkId, that.floatingNetworkId) &&
+ Objects.equal(this.fixedIpAddress, that.fixedIpAddress) &&
+ Objects.equal(this.floatingIpAddress, that.floatingIpAddress) &&
+ Objects.equal(this.portId, that.portId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, routerId, tenantId, floatingNetworkId, fixedIpAddress, floatingIpAddress,
+ portId);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this)
+ .add("id", id)
+ .add("routerId", routerId)
+ .add("tenantId", tenantId)
+ .add("floatingNetworkId", floatingNetworkId)
+ .add("fixedIpAddress", fixedIpAddress)
+ .add("floatingIpAddress", floatingIpAddress)
+ .add("portId", portId)
+ .toString();
+ }
+
+ /**
+ * @return the Builder for creating a new floating IP
+ */
+ public static CreateBuilder createBuilder(String floatingNetworkId) {
+ return new CreateBuilder(floatingNetworkId);
+ }
+
+ /**
+ * @return the Builder for updating a floating IP
+ */
+ public static UpdateBuilder updateBuilder() {
+ return new UpdateBuilder();
+ }
+
+ private abstract static class Builder<ParameterizedBuilderType> {
+ protected FloatingIP floatingIP;
+
+ /**
+ * No-parameters constructor.
+ * */
+ private Builder() {
+ floatingIP = new FloatingIP();
+ }
+
+ protected abstract ParameterizedBuilderType self();
+
+ /**
+ * Provide the tenantId for this Floating IP. Admin-only.
+ * When keystone is enabled, it is not mandatory to specify tenant_id for resources in create requests, as the
+ * tenant identifier will be derived from the Authentication token. Please note that the default authorization
+ * settings only allow administrative users to create resources on behalf of a different tenant.
+ *
+ * @return the Builder.
+ * @see FloatingIP#getTenantId()
+ */
+ public ParameterizedBuilderType tenantId(String tenantId) {
+ floatingIP.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * Provides the floating network id for this Floating IP.
+ * Mandatory when creating a floating IP.
+ * Floating IPs can only be created on external networks. If the network specified by floating_network_id is not
+ * external (for example, router:external=false), a 400 error is returned.
+ *
+ * @return the Builder.
+ * @see FloatingIP#getFloatingNetworkId() ()
+ */
+ public ParameterizedBuilderType floatingNetworkId(String floatingNetworkId) {
+ floatingIP.floatingNetworkId = floatingNetworkId;
+ return self();
+ }
+
+ /**
+ * Provides the fixed ip address for this Floating IP.
+ * As an OpenStack Networking port might be associated with multiple IP addresses, the particular IP address to
+ * associate with the floating IP can be specified using the fixed_ip_address request body parameter. The default
+ * logic of this operation is to associate the floating IP with a single IP address configured on a port; hence,
+ * if a port has multiple IP addresses, it is mandatory to specify the fixed_ip_address attribute. If an invalid
+ * IP address is specified in fixed_ip_address a 400 error will be returned.
+ *
+ * @return the Builder.
+ * @see FloatingIP#getFixedIpAddress()
+ */
+ public ParameterizedBuilderType fixedIpAddress(String fixedIpAddress) {
+ floatingIP.fixedIpAddress = fixedIpAddress;
+ return self();
+ }
+
+ /**
+ * Provides the port id for this Floating IP.
+ * Users can associate the floating IP with an internal port using the port_id attribute in the request body.
+ * If an invalid port identifier is specified, a 404 error will be returned. The internal OpenStack Networking
+ * port associated with the Floating IP must have at least an IP address configured, otherwise a 400 error will
+ * be returned.
+ *
+ * @return the Builder.
+ * @see FloatingIP#getPortId()
+ */
+ public ParameterizedBuilderType portId(String portId) {
+ floatingIP.portId = portId;
+ return self();
+ }
+ }
+
+ public static class CreateBuilder extends Builder<CreateBuilder> {
+ /**
+ * Supply required properties for creating a Builder
+ */
+ private CreateBuilder(String floatingNetworkId) {
+ floatingIP.floatingNetworkId = floatingNetworkId;
+ }
+
+ /**
+ * @return a CreateFloatingIP constructed with this Builder.
+ */
+ public CreateFloatingIP build() {
+ return new CreateFloatingIP(floatingIP);
+ }
+
+ protected CreateBuilder self() {
+ return this;
+ }
+ }
+
+ public static class UpdateBuilder extends Builder<UpdateBuilder> {
+ /**
+ * Supply required properties for updating a Builder
+ */
+ private UpdateBuilder() {
+ }
+
+ /**
+ * Provide the floating ip address for this Floating IP.
+ * An address for the floating ip will be automatically allocated, unless the floating_ip_address attribute is
+ * specified in the request body. If the requested floating IP address does not fall in the external network's
+ * subnet range, a 400 error will be returned. If the requested floating IP address is already in use, a 409
+ * error code will be returned.
+ *
+ * @return the Builder.
+ * @see FloatingIP#getFloatingIpAddress()
+ */
+ public UpdateBuilder floatingIpAddress(String floatingIpAddress) {
+ floatingIP.floatingIpAddress = floatingIpAddress;
+ return this;
+ }
+
+ /**
+ * @return a UpdateFloatingIP constructed with this Builder.
+ */
+ public UpdateFloatingIP build() {
+ return new UpdateFloatingIP(floatingIP);
+ }
+
+ protected UpdateBuilder self() {
+ return this;
+ }
+ }
+
+ public static class CreateFloatingIP extends FloatingIP {
+ private CreateFloatingIP(FloatingIP floatingIP) {
+ super(floatingIP);
+ }
+ }
+ public static class UpdateFloatingIP extends FloatingIP {
+ private UpdateFloatingIP(FloatingIP floatingIP) {
+ super(floatingIP);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIPs.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIPs.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIPs.java
new file mode 100644
index 0000000..8befa3e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/FloatingIPs.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A collection of Floating IPs
+ */
+public class FloatingIPs extends PaginatedCollection<FloatingIP> {
+ public static final FloatingIPs EMPTY = new FloatingIPs(ImmutableSet.<FloatingIP> of(), ImmutableSet.<Link> of());
+
+ @ConstructorProperties({"floatingips", "floatingips_links"})
+ protected FloatingIPs(Iterable<FloatingIP> floatingIPs, Iterable<Link> floatingIPsLinks) {
+ super(floatingIPs, floatingIPsLinks);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/HostRoute.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/HostRoute.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/HostRoute.java
new file mode 100644
index 0000000..6ff0ddc
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/HostRoute.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * A Neutron Subnet Host Route
+ *
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api doc</a>
+ */
+public class HostRoute {
+
+ @Named("destination")
+ private final String destinationCidr;
+ @Named("nexthop")
+ private final String nextHop;
+
+ @ConstructorProperties({"destination", "nexthop"})
+ protected HostRoute(String destinationCidr, String nextHop) {
+ this.destinationCidr = destinationCidr;
+ this.nextHop = nextHop;
+ }
+
+ /**
+ * @return the destination CIDR for this route.
+ */
+ @Nullable
+ public String getDestinationCidr() {
+ return destinationCidr;
+ }
+
+ /**
+ * @return the IP of the next hop to forward traffic to.
+ */
+ @Nullable
+ public String getNextHop() {
+ return nextHop;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(destinationCidr, nextHop);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ HostRoute that = HostRoute.class.cast(obj);
+ return Objects.equal(this.destinationCidr, that.destinationCidr) && Objects.equal(this.nextHop, that.nextHop);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("destinationCidr", destinationCidr).add("nextHop", nextHop);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromHostRoute(this);
+ }
+
+ public static class Builder {
+ protected String destinationCidr;
+ protected String nextHop;
+
+ /**
+ * This should be a valid CIDR.
+ * @see HostRoute#getDestinationCidr()
+ */
+ public Builder destinationCidr(String destinationCidr) {
+ this.destinationCidr = destinationCidr;
+ return this;
+ }
+
+ /**
+ * This should be a valid IP address.
+ * @see HostRoute#getNextHop()
+ */
+ public Builder nextHop(String nextHop) {
+ this.nextHop = nextHop;
+ return this;
+ }
+
+ public HostRoute build() {
+ return new HostRoute(destinationCidr, nextHop);
+ }
+
+ public Builder fromHostRoute(HostRoute in) {
+ return this.destinationCidr(in.getDestinationCidr()).nextHop(in.getNextHop());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IP.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IP.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IP.java
new file mode 100644
index 0000000..9c64604
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IP.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import com.google.common.base.Objects;
+import org.jclouds.javax.annotation.Nullable;
+
+import javax.inject.Named;
+import java.beans.ConstructorProperties;
+
+/**
+ * Describes an IP address
+ */
+public class IP {
+
+ @Named("ip_address")
+ protected final String ipAddress;
+ @Named("subnet_id")
+ protected final String subnetId;
+
+ @ConstructorProperties({"ip_address", "subnet_id"})
+ protected IP(String ipAddress, String subnetId) {
+ this.ipAddress = ipAddress;
+ this.subnetId = subnetId;
+ }
+
+ /**
+ * @return the ipAddress of the IP
+ */
+ @Nullable
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ /**
+ * @return the subnetId of the IP
+ */
+ @Nullable
+ public String getSubnetId() {
+ return subnetId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(ipAddress, subnetId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ IP that = IP.class.cast(obj);
+ return Objects.equal(this.ipAddress, that.ipAddress) && Objects.equal(this.subnetId, that.subnetId);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this).add("ipAddress", ipAddress).add("subnetId", subnetId);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ /**
+ * @return the Builder for IP
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Gets a Builder configured as this object.
+ */
+ public Builder toBuilder() {
+ return new Builder().fromIP(this);
+ }
+
+ public static class Builder {
+ protected String ipAddress;
+ protected String subnetId;
+
+ /**
+ * Provide the ipAddress to the IP's Builder.
+ *
+ * @return the Builder.
+ * @see IP#getIpAddress()
+ */
+ public Builder ipAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ return this;
+ }
+
+ /**
+ * Provide the subnetId to the IP's Builder.
+ *
+ * @return the Builder.
+ * @see IP#getSubnetId()
+ */
+ public Builder subnetId(String subnetId) {
+ this.subnetId = subnetId;
+ return this;
+ }
+
+ /**
+ * @return a IP constructed with this Builder.
+ */
+ public IP build() {
+ return new IP(ipAddress, subnetId);
+ }
+
+ /**
+ * @return a Builder from another IP.
+ */
+ public Builder fromIP(IP in) {
+ return this.ipAddress(in.getIpAddress()).subnetId(in.getSubnetId());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IPv6DHCPMode.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IPv6DHCPMode.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IPv6DHCPMode.java
new file mode 100644
index 0000000..654e053
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/IPv6DHCPMode.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.domain;
+
+/**
+ * Enumerates DHCP modes for UPv6
+ */
+public enum IPv6DHCPMode {
+ OFF("off"),
+ SLAAC("slaac"),
+ DHCPV6_STATEFUL("dhcpv6-stateful"),
+ DHCPV6_STATELESS("dhcpv6-stateless"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private String name;
+
+ private IPv6DHCPMode(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * */
+ public static IPv6DHCPMode fromValue(String name){
+ if (name != null) {
+ for (IPv6DHCPMode value : IPv6DHCPMode.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Network.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Network.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Network.java
new file mode 100644
index 0000000..ac40019
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Network.java
@@ -0,0 +1,646 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A Neutron network
+ *
+ * @see <a
+ * href="http://docs.openstack.org/api/openstack-network/2.0/content/Networks.html">api
+ * doc</a>
+ */
+public class Network {
+
+ private String id;
+ private NetworkStatus status;
+ private ImmutableSet<String> subnets;
+
+ private String name;
+ @Named("admin_state_up")
+ private Boolean adminStateUp;
+ private Boolean shared;
+ @Named("tenant_id")
+ private String tenantId;
+
+ // providernet.py: Provider Networks Extension
+ @Named("provider:network_type")
+ private NetworkType networkType;
+ @Named("provider:physical_network")
+ private String physicalNetworkName;
+ @Named("provider:segmentation_id")
+ private Integer segmentationId;
+
+ // external_net.py: Configurable external gateway modes extension
+ @Named("router:external")
+ private Boolean external;
+
+ // portsecurity.py: VMWare port security
+ @Named("port_security_enabled")
+ private Boolean portSecurity;
+
+ // n1kv.py: Cisco plugin extension; admin rights might be needed
+ @Named("n1kv:profile_id")
+ // UUID
+ private String profileId;
+ @Named("n1kv:multicast_ip")
+ private String multicastIp;
+ @Named("n1kv:segment_add")
+ private String segmentAdd;
+ @Named("n1kv:segment_del")
+ private String segmentDel;
+ @Named("n1kv:member_segments")
+ private String memberSegments;
+
+ // multiprovidernet.py: Multiprovider net extension; Segments and provider
+ // values cannot both be set.
+ private ImmutableSet<NetworkSegment> segments;
+
+ // flavor.py: Flavor support for network and router
+ @Named("flavor:network")
+ private String networkFlavor;
+
+ @ConstructorProperties({"id", "status", "subnets", "name", "admin_state_up", "shared", "tenant_id",
+ "provider:network_type", "provider:physical_network", "provider:segmentation_id", "router:external",
+ "port_security_enabled", "n1kv:profile_id", "n1kv:multicast_ip", "n1kv:segment_add", "n1kv:segment_del",
+ "n1kv:member_segments", "segments", "flavor:network"})
+ private Network(String id, NetworkStatus status, ImmutableSet<String> subnets, String name, Boolean adminStateUp,
+ Boolean shared, String tenantId, NetworkType networkType, String physicalNetworkName, Integer segmentationId,
+ Boolean external, Boolean portSecurity, String profileId, String multicastIp, String segmentAdd,
+ String segmentDel, String memberSegments, ImmutableSet<NetworkSegment> segments, String networkFlavor) {
+ // No checkNotNulls. With Neutron, any of these properties can be left null when used in an update.
+ this.id = id;
+ this.status = status;
+ this.subnets = subnets;
+ this.name = name;
+ this.adminStateUp = adminStateUp;
+ this.shared = shared;
+ this.tenantId = tenantId;
+ this.networkType = networkType;
+ this.physicalNetworkName = physicalNetworkName;
+ this.segmentationId = segmentationId;
+ this.external = external;
+ this.portSecurity = portSecurity;
+ this.profileId = profileId;
+ this.multicastIp = multicastIp;
+ this.segmentAdd = segmentAdd;
+ this.segmentDel = segmentDel;
+ this.memberSegments = memberSegments;
+ this.segments = segments;
+ this.networkFlavor = networkFlavor;
+ }
+
+ /**
+ * Default constructor.
+ */
+ private Network() {}
+
+ /**
+ * Copy constructor
+ * @param network
+ */
+ private Network(Network network) {
+ this(network.id,
+ network.status,
+ network.subnets,
+ network.name,
+ network.adminStateUp,
+ network.shared,
+ network.tenantId,
+ network.networkType,
+ network.physicalNetworkName,
+ network.segmentationId,
+ network.external,
+ network.portSecurity,
+ network.profileId,
+ network.multicastIp,
+ network.segmentAdd,
+ network.segmentDel,
+ network.memberSegments,
+ network.segments,
+ network.networkFlavor);
+ }
+
+ /**
+ * @return the id of the Network
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the status of the Network
+ */
+ @Nullable
+ public NetworkStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @return the subnets of the Network
+ */
+ @Nullable
+ public ImmutableSet<String> getSubnets() {
+ return subnets;
+ }
+
+ /**
+ * @return the name of the Network
+ */
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the adminStateUp of the Network
+ */
+ @Nullable
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * The shared attribute can be used to create a public network, i.e.: a network which is shared with all other tenants.
+ * Control of the shared attribute could be reserved to particular users only, such as administrators.
+ * In this case, regular users trying to create a shared network will receive a 403 - Forbidden error.
+ * @return true if the network resource can be accessed by any tenant or not, false if not
+ */
+ @Nullable
+ public Boolean getShared() {
+ return shared;
+ }
+
+ /**
+ * @return the tenantId of the Network
+ */
+ @Nullable
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return the networkType of the Network
+ */
+ @Nullable
+ public NetworkType getNetworkType() {
+ return networkType;
+ }
+
+ /**
+ * @return the physicalNetworkName of the Network
+ */
+ @Nullable
+ public String getPhysicalNetworkName() {
+ return physicalNetworkName;
+ }
+
+ /**
+ * @return the segmentationId of the Network
+ */
+ @Nullable
+ public Integer getSegmentationId() {
+ return segmentationId;
+ }
+
+ /**
+ * Adds external network attribute to network resource.
+ * @return the external of the Network
+ */
+ @Nullable
+ public Boolean getExternal() {
+ return external;
+ }
+
+ /**
+ * @return the portSecurity of the Network
+ */
+ @Nullable
+ public Boolean getPortSecurity() {
+ return portSecurity;
+ }
+
+ /**
+ * @return the profileId of the Network
+ */
+ @Nullable
+ public String getProfileId() {
+ return profileId;
+ }
+
+ /**
+ * @return the multicastIp of the Network
+ */
+ @Nullable
+ public String getMulticastIp() {
+ return multicastIp;
+ }
+
+ /**
+ * @return the segmentAdd of the Network
+ */
+ @Nullable
+ public String getSegmentAdd() {
+ return segmentAdd;
+ }
+
+ /**
+ * @return the segmentDel of the Network
+ */
+ @Nullable
+ public String getSegmentDel() {
+ return segmentDel;
+ }
+
+ /**
+ * @return the memberSegments of the Network
+ */
+ @Nullable
+ public String getMemberSegments() {
+ return memberSegments;
+ }
+
+ /**
+ * @return the segments of the Network
+ */
+ @Nullable
+ public ImmutableSet<NetworkSegment> getSegments() {
+ return segments;
+ }
+
+ /**
+ * @return the networkFlavor of the Network
+ */
+ @Nullable
+ public String getNetworkFlavor() {
+ return networkFlavor;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, status, subnets, name, adminStateUp, shared, tenantId, networkType,
+ physicalNetworkName, segmentationId, external, portSecurity, profileId, multicastIp, segmentAdd, segmentDel,
+ memberSegments, segments, networkFlavor);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ Network that = Network.class.cast(obj);
+ return Objects.equal(this.id, that.id)
+ && Objects.equal(this.status, that.status)
+ && Objects.equal(this.subnets, that.subnets)
+ && Objects.equal(this.name, that.name)
+ && Objects.equal(this.adminStateUp, that.adminStateUp)
+ && Objects.equal(this.shared, that.shared)
+ && Objects.equal(this.tenantId, that.tenantId)
+ && Objects.equal(this.networkType, that.networkType)
+ && Objects.equal(this.physicalNetworkName, that.physicalNetworkName)
+ && Objects.equal(this.segmentationId, that.segmentationId)
+ && Objects.equal(this.external, that.external)
+ && Objects.equal(this.portSecurity, that.portSecurity)
+ && Objects.equal(this.profileId, that.profileId)
+ && Objects.equal(this.multicastIp, that.multicastIp)
+ && Objects.equal(this.segmentAdd, that.segmentAdd)
+ && Objects.equal(this.segmentDel, that.segmentDel)
+ && Objects.equal(this.memberSegments, that.memberSegments)
+ && Objects.equal(this.segments, that.segments)
+ && Objects.equal(this.networkFlavor, that.networkFlavor);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this)
+ .add("id", id)
+ .add("status", status)
+ .add("subnets", subnets)
+ .add("name", name)
+ .add("adminStateUp", adminStateUp)
+ .add("shared", shared)
+ .add("tenantId", tenantId)
+ .add("networkType", networkType)
+ .add("physicalNetworkName", physicalNetworkName)
+ .add("segmentationId", segmentationId)
+ .add("external", external)
+ .add("portSecurity", portSecurity)
+ .add("profileId", profileId)
+ .add("multicastIp", multicastIp)
+ .add("segmentAdd", segmentAdd)
+ .add("segmentDel", segmentDel)
+ .add("memberSegments", memberSegments)
+ .add("segments", segments)
+ .add("networkFlavor", networkFlavor)
+ .toString();
+ }
+
+ /*
+ * Methods to get the Create and Update builders follow
+ */
+
+ /**
+ * @return the Builder for creating a new Router
+ */
+ public static CreateBuilder createBuilder(String name) {
+ return new CreateBuilder(name);
+ }
+
+ /**
+ * @return the Builder for updating a Router
+ */
+ public static UpdateBuilder updateBuilder() {
+ return new UpdateBuilder();
+ }
+
+ private abstract static class Builder<ParameterizedBuilderType> {
+ protected Network network;
+
+ /**
+ * No-parameters constructor used when updating.
+ * */
+ private Builder() {
+ network = new Network();
+ }
+
+ protected abstract ParameterizedBuilderType self();
+
+ /**
+ * Provide the name to the Network's Builder.
+ *
+ * @return the Builder.
+ * @see Network#getName()
+ */
+ public ParameterizedBuilderType name(String name) {
+ network.name = name;
+ return self();
+ }
+
+ /**
+ * Provide the adminStateUp to the Network's Builder.
+ *
+ * @return the Builder.
+ * @see Network#isAdminStateUp()
+ */
+ public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) {
+ network.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ /**
+ * Provide the shared to the Network's Builder.
+ *
+ * @return the Builder.
+ * @see Network#isShared()
+ */
+ public ParameterizedBuilderType shared(Boolean shared) {
+ network.shared = shared;
+ return self();
+ }
+
+ /**
+ * Provide the tenantId to the Network's Builder.
+ *
+ * @return the Builder.
+ * @see Network#getTenantId()
+ */
+ public ParameterizedBuilderType tenantId(String tenantId) {
+ network.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * Provide the networkType to the Network's Builder.
+ *
+ * @return the Builder.
+ * @see Network#getNetworkType()
+ */
+ public ParameterizedBuilderType networkType(NetworkType networkType) {
+ network.networkType = networkType;
+ return self();
+ }
+
+ /**
+ * Provide the physicalNetworkName to the Network's Builder.
+ *
+ * @return the Builder.
+ * @see Network#getPhysicalNetworkName()
+ */
+ public ParameterizedBuilderType physicalNetworkName(String physicalNetworkName) {
+ network.physicalNetworkName = physicalNetworkName;
+ return self();
+ }
+
+ /**
+ * Provide the segmentationId to the Network's Builder.
+ *
+ * @return the Builder.
+ * @see Network#getSegmentationId()
+ */
+ public ParameterizedBuilderType segmentationId(Integer segmentationId) {
+ network.segmentationId = segmentationId;
+ return self();
+ }
+
+ /**
+ * Adds external network attribute to network resource.
+ *
+ * @return the Builder.
+ * @see Network#isExternal()
+ */
+ public ParameterizedBuilderType external(Boolean external) {
+ network.external = external;
+ return self();
+ }
+
+ /**
+ * Provide the portSecurity to the Network's Builder.
+ *
+ * @return the Builder.
+ * @see Network#isPortSecurity()
+ */
+ public ParameterizedBuilderType portSecurity(Boolean portSecurity) {
+ network.portSecurity = portSecurity;
+ return self();
+ }
+
+ /**
+ * Provide the profileId to the Network's Builder.
+ *
+ * @return the Builder.
+ * @see Network#getProfileId()
+ */
+ public ParameterizedBuilderType profileId(String profileId) {
+ network.profileId = profileId;
+ return self();
+ }
+
+ /**
+ * Provide the multicastIp to the Network's Builder.
+ *
+ * @return the Builder.
+ * @see Network#getMulticastIp()
+ */
+ public ParameterizedBuilderType multicastIp(String multicastIp) {
+ network.multicastIp = multicastIp;
+ return self();
+ }
+
+ /**
+ * Provide the segmentAdd to the Network's Builder.
+ * Cisco plugin extension; admin right might be needed to use this.
+ *
+ * @return the Builder.
+ * @see Network#getSegmentAdd()
+ */
+ public ParameterizedBuilderType segmentAdd(String segmentAdd) {
+ network.segmentAdd = segmentAdd;
+ return self();
+ }
+
+ /**
+ * Provide the segmentDel to the Network's Builder.
+ * Cisco plugin extension; admin right might be needed to use this.
+ *
+ * @return the Builder.
+ * @see Network#getSegmentDel()
+ */
+ public ParameterizedBuilderType segmentDel(String segmentDel) {
+ network.segmentDel = segmentDel;
+ return self();
+ }
+
+ /**
+ * Provide the memberSegments to the Network's Builder.
+ * Cisco plugin extension; admin right might be needed to use this.
+ *
+ * @return the Builder.
+ * @see Network#getMemberSegments()
+ */
+ public ParameterizedBuilderType memberSegments(String memberSegments) {
+ network.memberSegments = memberSegments;
+ return self();
+ }
+
+ /**
+ * Provide the segments to the Network's Builder.
+ * Multiprovider extension.
+ *
+ * @return the Builder.
+ * @see Network#getSegments()
+ */
+ public ParameterizedBuilderType segments(ImmutableSet<NetworkSegment> segments) {
+ network.segments = segments;
+ return self();
+ }
+
+ /**
+ * Provide the networkFlavor to the Network's Builder.
+ *
+ * @return the Builder.
+ * @see Network#getNetworkFlavor()
+ */
+ public ParameterizedBuilderType networkFlavor(String networkFlavor) {
+ network.networkFlavor = networkFlavor;
+ return self();
+ }
+ }
+
+ /**
+ * Create and Update builders (inheriting from Builder)
+ */
+ public static class CreateBuilder extends Builder<CreateBuilder> {
+ /**
+ * Supply required properties for creating a Builder
+ */
+ private CreateBuilder(String name) {
+ network.name = name;
+ }
+
+ /**
+ * @return a CreateNetwork constructed with this Builder.
+ */
+ public CreateNetwork build() {
+ return new CreateNetwork(network);
+ }
+
+ protected CreateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Create and Update builders (inheriting from Builder)
+ */
+ public static class UpdateBuilder extends Builder<UpdateBuilder> {
+ /**
+ * Supply required properties for updating a Builder
+ */
+ private UpdateBuilder() {
+ }
+
+ /**
+ * @return a UpdateNetwork constructed with this Builder.
+ */
+ public UpdateNetwork build() {
+ return new UpdateNetwork(network);
+ }
+
+ protected UpdateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Create and Update options - extend the domain class, passed to API update and create calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class CreateNetwork extends Network {
+ /**
+ * Copy constructor
+ */
+ private CreateNetwork(Network network) {
+ super(network);
+ checkNotNull(network.name, "name should not be null");
+ }
+ }
+
+ /**
+ * Create and Update options - extend the domain class, passed to API update and create calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class UpdateNetwork extends Network {
+ /**
+ * Copy constructor
+ */
+ private UpdateNetwork(Network network) {
+ super(network);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkSegment.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkSegment.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkSegment.java
new file mode 100644
index 0000000..aacd5c1
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkSegment.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import com.google.common.base.Objects;
+import org.jclouds.javax.annotation.Nullable;
+
+import javax.inject.Named;
+import java.beans.ConstructorProperties;
+
+/**
+ * A Neutron Network Segment
+ * Segments and provider values cannot both be set.
+ *
+ * @see <a
+ * href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api
+ * doc</a>
+ */
+public class NetworkSegment {
+
+ @Named("provider:network_type")
+ protected final NetworkType networkType;
+ @Named("provider:physical_network")
+ protected final String physicalNetwork;
+ @Named("provider:segmentation_id")
+ protected final Integer segmentationId;
+
+ @ConstructorProperties({"provider:network_type", "provider:physical_network", "provider:segmentation_id"})
+ protected NetworkSegment(NetworkType networkType, String physicalNetwork, Integer segmentationId) {
+ this.networkType = networkType;
+ this.physicalNetwork = physicalNetwork;
+ this.segmentationId = segmentationId;
+ }
+
+ /**
+ * @return the networkType of the NetworkSegment
+ */
+ @Nullable
+ public NetworkType getNetworkType() {
+ return networkType;
+ }
+
+ /**
+ * @return the physicalNetwork of the NetworkSegment
+ */
+ @Nullable
+ public String getPhysicalNetwork() {
+ return physicalNetwork;
+ }
+
+ /**
+ * @return the segmentationId of the NetworkSegment
+ */
+ @Nullable
+ public Integer getSegmentationId() {
+ return segmentationId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(networkType, physicalNetwork, segmentationId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ NetworkSegment that = NetworkSegment.class.cast(obj);
+ return Objects.equal(this.networkType, that.networkType)
+ && Objects.equal(this.physicalNetwork, that.physicalNetwork)
+ && Objects.equal(this.segmentationId, that.segmentationId);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this).add("networkType", networkType).add("physicalNetwork", physicalNetwork)
+ .add("segmentationId", segmentationId);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ /**
+ * @return the Builder for NetworkSegment
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Gets a Builder configured as this object.
+ */
+ public Builder toBuilder() {
+ return new Builder().fromNetworkSegment(this);
+ }
+
+ public static class Builder {
+ protected NetworkType networkType;
+ protected String physicalNetwork;
+ protected Integer segmentationId;
+
+ /**
+ * Provide the networkType to the NetworkSegment's Builder.
+ *
+ * @return the Builder.
+ * @see NetworkSegment#getNetworkType()
+ */
+ public Builder networkType(NetworkType networkType) {
+ this.networkType = networkType;
+ return this;
+ }
+
+ /**
+ * Provide the physicalNetwork to the NetworkSegment's Builder.
+ *
+ * @return the Builder.
+ * @see NetworkSegment#getPhysicalNetwork()
+ */
+ public Builder physicalNetwork(String physicalNetwork) {
+ this.physicalNetwork = physicalNetwork;
+ return this;
+ }
+
+ /**
+ * Provide the segmentationId to the NetworkSegment's Builder.
+ *
+ * @return the Builder.
+ * @see NetworkSegment#getSegmentationId()
+ */
+ public Builder segmentationId(int segmentationId) {
+ this.segmentationId = segmentationId;
+ return this;
+ }
+
+ /**
+ * @return a NetworkSegment constructed with this Builder.
+ */
+ public NetworkSegment build() {
+ return new NetworkSegment(networkType, physicalNetwork, segmentationId);
+ }
+
+ /**
+ * @return a Builder from another NetworkSegment.
+ */
+ public Builder fromNetworkSegment(NetworkSegment in) {
+ return this.networkType(in.getNetworkType()).physicalNetwork(in.getPhysicalNetwork())
+ .segmentationId(in.getSegmentationId());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkStatus.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkStatus.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkStatus.java
new file mode 100644
index 0000000..04334d0
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkStatus.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.domain;
+
+/**
+ * Enumerates Network Status.
+ */
+public enum NetworkStatus {
+ ACTIVE("active"),
+ DOWN("down"),
+ BUILD("build"),
+ ERROR("error"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private final String name;
+
+ private NetworkStatus(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name();
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * @param name The string representation of this enum value.
+ * @return The corresponding enum value.
+ */
+ public static NetworkStatus fromValue(String name) {
+ if (name != null) {
+ for (NetworkStatus value : NetworkStatus.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkType.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkType.java
new file mode 100644
index 0000000..89c3e9a
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/NetworkType.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.domain;
+
+/**
+ * Enumerates supported Network types.
+ */
+public enum NetworkType {
+ /**
+ * Used to describe a local network.
+ */
+ LOCAL("local"),
+ /**
+ * Used to describe a flat network.
+ */
+ FLAT("flat"),
+ /**
+ * Used to describe a VLAN network. NetworkSegment might have to be set.
+ */
+ VLAN("vlan"),
+ /**
+ * Used to describe a Virtual Extensible LAN (VXLAN) network.
+ * It uses a VLAN-like encapsulation technique to encapsulate MAC-based
+ * OSI layer 2 Ethernet frames within layer 4 UDP packets.
+ */
+ VXLAN("vxlan"),
+ /**
+ * Used to describe a GRE tunnel network. A virtual network realized as
+ * packets encapsulated using Generic Routing Encapsulation. GRE tunnel
+ * packets are routed by the compute node hosts, so GRE tunnels are not
+ * associated by the openvswitch plugin with specific physical networks.
+ */
+ GRE("gre"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private String name;
+
+ private NetworkType(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * @param name The string representation of this enum value.
+ * @return The corresponding enum value.
+ */
+ public static NetworkType fromValue(String name) {
+ if (name != null) {
+ for (NetworkType value : NetworkType.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Networks.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Networks.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Networks.java
new file mode 100644
index 0000000..9b3bf10
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Networks.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A collection of Networks
+ */
+public class Networks extends PaginatedCollection<Network> {
+ public static final Networks EMPTY = new Networks(ImmutableSet.<Network> of(), ImmutableSet.<Link> of());
+
+ @ConstructorProperties({"networks", "networks_links"})
+ protected Networks(Iterable<Network> networks, Iterable<Link> networksLinks) {
+ super(networks, networksLinks);
+ }
+}
[29/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/NetworkApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/NetworkApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/NetworkApi.java
new file mode 100644
index 0000000..08e5586
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/NetworkApi.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.features;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.neutron.v2.domain.Network;
+import org.jclouds.openstack.neutron.v2.domain.Networks;
+import org.jclouds.openstack.neutron.v2.fallbacks.EmptyNetworksFallback;
+import org.jclouds.openstack.neutron.v2.functions.NetworksToPagedIterable;
+import org.jclouds.openstack.neutron.v2.functions.ParseNetworks;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.annotations.WrapWith;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Provides access to Network operations for the OpenStack Networking (Neutron) v2 API.
+ * <p/>
+ * Each tenant can define one or more networks. A network is a virtual isolated layer-2 broadcast domain reserved to the
+ * tenant. A tenant can create several ports for a network, and plug virtual interfaces into these ports.
+ *
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-network/2.0/content/Networks.html">api doc</a>
+ */
+@Beta
+@Path("/networks")
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+@Produces(MediaType.APPLICATION_JSON)
+public interface NetworkApi {
+
+ /**
+ * Returns all networks currently defined in Neutron for the current tenant.
+ *
+ * @return the list of all networks configured for the tenant
+ */
+ @Named("network:list")
+ @GET
+ @ResponseParser(ParseNetworks.class)
+ @Transform(NetworksToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Network> list();
+
+ /**
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a>
+ */
+ @Named("network:list")
+ @GET
+ @ResponseParser(ParseNetworks.class)
+ @Fallback(EmptyNetworksFallback.class)
+ Networks list(PaginationOptions options);
+
+ /**
+ * Return a specific network
+ *
+ * @param id the id of the network to return
+ * @return Network or null if not found
+ */
+ @Named("network:get")
+ @GET
+ @Path("/{id}")
+ @SelectJson("network")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Nullable
+ Network get(@PathParam("id") String id);
+
+ /**
+ * Create a new network with the specified type
+ *
+ * @param network Describes the network to be created.
+ * @return a reference of the newly-created network
+ */
+ @Named("network:create")
+ @POST
+ @SelectJson("network")
+ Network create(@WrapWith("network") Network.CreateNetwork network);
+
+ /**
+ * Create multiple networks
+ *
+ * @param networks the bulk of networks to create
+ * @return list of references of the newly-created networks
+ */
+ @Named("network:createBulk")
+ @POST
+ @SelectJson("networks")
+ FluentIterable<Network> createBulk(@WrapWith("networks") ImmutableList<Network.CreateNetwork> networks);
+
+ /**
+ * Update a network
+ *
+ * @param id the id of the network to update
+ * @param network the network to update
+ * @return true if update successful, false if not
+ */
+ @Named("network:update")
+ @PUT
+ @Path("/{id}")
+ @SelectJson("network")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Nullable
+ Network update(@PathParam("id") String id, @WrapWith("network") Network.UpdateNetwork network);
+
+ /**
+ * Deletes the specified network
+ *
+ * @param id the id of the network to delete
+ * @return true if delete was successful, false if not
+ */
+ @Named("network:delete")
+ @DELETE
+ @Path("/{id}")
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean delete(@PathParam("id") String id);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/PortApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/PortApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/PortApi.java
new file mode 100644
index 0000000..6466a90
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/PortApi.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.features;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import org.jclouds.Fallbacks;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.neutron.v2.domain.Port;
+import org.jclouds.openstack.neutron.v2.domain.Ports;
+import org.jclouds.openstack.neutron.v2.fallbacks.EmptyPortsFallback;
+import org.jclouds.openstack.neutron.v2.functions.ParsePorts;
+import org.jclouds.openstack.neutron.v2.functions.PortsToPagedIterable;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.annotations.WrapWith;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+
+/**
+ * Provides access to Port operations for the OpenStack Networking (Neutron) v2 API.
+ * <p/>
+ * A port represents a virtual switch port on a logical network switch where all the interfaces attached to a given network are connected.
+ * <p/>
+ * A port has an administrative state which is either 'DOWN' or 'ACTIVE'. Ports which are administratively down will not be able to receive/send traffic.
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-network/2.0/content/Ports.html">api doc</a>
+ */
+@Beta
+@Path("/ports")
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface PortApi {
+
+ /**
+ * Returns the list of all ports currently defined in Neutron for the current tenant. The list provides the unique
+ * identifier of each network configured for the tenant.
+ *
+ * @return the list of all port references configured for the tenant
+ */
+ @Named("port:list")
+ @GET
+ @Transform(PortsToPagedIterable.class)
+ @ResponseParser(ParsePorts.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Port> list();
+
+ /**
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a>
+ */
+ @Named("port:list")
+ @GET
+ @ResponseParser(ParsePorts.class)
+ @Fallback(EmptyPortsFallback.class)
+ Ports list(PaginationOptions options);
+
+ /**
+ * Returns the specific port
+ *
+ * @param id the id of the port to return
+ * @return Port or null if not found
+ */
+ @Named("port:get")
+ @GET
+ @Path("/{id}")
+ @SelectJson("port")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Nullable
+ Port get(@PathParam("id") String id);
+
+ /**
+ * Create a new port in the specified network
+ *
+ * @param port the port details
+ * @return a reference of the newly-created port
+ */
+ @Named("port:create")
+ @POST
+ @SelectJson("port")
+ Port create(@WrapWith("port") Port.CreatePort port);
+
+ /**
+ * Create multiple ports
+ *
+ * @param ports the bulk of ports to create
+ * @return list of references of the newly-created ports
+ */
+ @Named("port:createBulk")
+ @POST
+ @SelectJson("ports")
+ FluentIterable<Port> createBulk(@WrapWith("ports") List<Port.CreatePort> ports);
+
+ /**
+ * Update a port
+ *
+ * @param id the id of the port to update
+ * @param port CreatePort with just the attributes to update
+ * @return true if update successful, false if not
+ */
+ @Named("port:update")
+ @PUT
+ @Path("/{id}")
+ @SelectJson("port")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Port update(@PathParam("id") String id, @WrapWith("port") Port.UpdatePort port);
+
+ /**
+ * Delete a port
+ *
+ * @param id the id of the port to delete
+ * @return true if delete successful, false if not
+ */
+ @Named("port:delete")
+ @DELETE
+ @Path("/{id}")
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean delete(@PathParam("id") String id);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/SubnetApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/SubnetApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/SubnetApi.java
new file mode 100644
index 0000000..7b6f54e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/SubnetApi.java
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.features;
+
+import com.google.common.collect.FluentIterable;
+import org.jclouds.Fallbacks;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.neutron.v2.domain.Subnet;
+import org.jclouds.openstack.neutron.v2.domain.Subnets;
+import org.jclouds.openstack.neutron.v2.fallbacks.EmptySubnetsFallback;
+import org.jclouds.openstack.neutron.v2.functions.ParseSubnets;
+import org.jclouds.openstack.neutron.v2.functions.SubnetsToPagedIterable;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.annotations.WrapWith;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+
+/**
+ * Provides access to Subnet operations for the OpenStack Networking (Neutron) v2 API.
+ *
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api doc</a>
+ */
+@Path("/subnets")
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+@Produces(MediaType.APPLICATION_JSON)
+public interface SubnetApi {
+
+ /**
+ * Returns the list of all subnets currently defined in Neutron for the current tenant. The list provides the unique
+ * identifier of each subnet configured for the tenant.
+ *
+ * @return the list of all subnet references configured for the tenant
+ */
+ @Named("subnet:list")
+ @GET
+ @ResponseParser(ParseSubnets.class)
+ @Transform(SubnetsToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Subnet> list();
+
+ /**
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a>
+ */
+ @Named("subnet:list")
+ @GET
+ @ResponseParser(ParseSubnets.class)
+ @Fallback(EmptySubnetsFallback.class)
+ Subnets list(PaginationOptions options);
+
+ /**
+ * Returns the specific Subnet.
+ *
+ * @param id the id of the subnet to return
+ * @return Subnet or null if not found
+ */
+ @Named("subnet:get")
+ @GET
+ @Path("/{id}")
+ @SelectJson("subnet")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Nullable
+ Subnet get(@PathParam("id") String id);
+
+ /**
+ * Create a subnet within a specified network
+ *
+ * @param subnet the subnet to be created
+ * @return a reference of the newly-created subnet
+ */
+ @Named("subnet:create")
+ @POST
+ @SelectJson("subnet")
+ Subnet create(@WrapWith("subnet") Subnet.CreateSubnet subnet);
+
+ /**
+ * Create multiple subnets
+ *
+ * @param subnets the bulk of subnets to create
+ * @return list of references of the newly-created subnets
+ */
+ @Named("subnet:createBulk")
+ @POST
+ @SelectJson("subnets")
+ FluentIterable<Subnet> createBulk(@WrapWith("subnets") List<Subnet.CreateSubnet> subnets);
+
+ /**
+ * Update a subnet
+ *
+ * @param id the id of the subnet to update
+ * @return true if update was successful, false if not
+ */
+ @Named("subnet:update")
+ @PUT
+ @Path("/{id}")
+ @SelectJson("subnet")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Subnet update(@PathParam("id") String id, @WrapWith("subnet") Subnet.UpdateSubnet subnet);
+
+ /**
+ * Delete a subnet
+ *
+ * @param id the id of the subnet to delete
+ * @return true if delete successful, false if not
+ */
+ @Named("subnet:delete")
+ @DELETE
+ @Path("/{id}")
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean delete(@PathParam("id") String id);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/FloatingIPsToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/FloatingIPsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/FloatingIPsToPagedIterable.java
new file mode 100644
index 0000000..4d54d1f
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/FloatingIPsToPagedIterable.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.FloatingIP;
+import org.jclouds.openstack.neutron.v2.extensions.FloatingIPApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import javax.inject.Inject;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Ensures Floating IPs works as PagedIterable.
+ */
+public class FloatingIPsToPagedIterable extends Arg0ToPagedIterable.FromCaller<FloatingIP, FloatingIPsToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected FloatingIPsToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<FloatingIP>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final FloatingIPApi floatingIPApi = api.getFloatingIPApi(region).get();
+ return new Function<Object, IterableWithMarker<FloatingIP>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<FloatingIP> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(floatingIPApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listfloatingIPs()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/NetworksToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/NetworksToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/NetworksToPagedIterable.java
new file mode 100644
index 0000000..c898381
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/NetworksToPagedIterable.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.Network;
+import org.jclouds.openstack.neutron.v2.features.NetworkApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import javax.inject.Inject;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Makes Networks work as a PagedIterable.
+ */
+public class NetworksToPagedIterable extends Arg0ToPagedIterable.FromCaller<Network, NetworksToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected NetworksToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Network>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final NetworkApi networkApi = api.getNetworkApi(region);
+ return new Function<Object, IterableWithMarker<Network>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Network> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(networkApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listNetworks()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFloatingIPs.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFloatingIPs.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFloatingIPs.java
new file mode 100644
index 0000000..6529627
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFloatingIPs.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import com.google.inject.TypeLiteral;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.FloatingIPs;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParseFloatingIPs extends ParseJson<FloatingIPs> {
+
+ @Inject
+ public ParseFloatingIPs(Json json) {
+ super(json, TypeLiteral.get(FloatingIPs.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseNetworks.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseNetworks.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseNetworks.java
new file mode 100644
index 0000000..0f9b8aa
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseNetworks.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+
+import com.google.inject.TypeLiteral;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.Networks;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParseNetworks extends ParseJson<Networks> {
+
+ @Inject
+ public ParseNetworks(Json json) {
+ super(json, TypeLiteral.get(Networks.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParsePorts.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParsePorts.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParsePorts.java
new file mode 100644
index 0000000..ab169dd
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParsePorts.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import com.google.inject.TypeLiteral;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.Ports;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParsePorts extends ParseJson<Ports> {
+
+ @Inject
+ public ParsePorts(Json json) {
+ super(json, TypeLiteral.get(Ports.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRouters.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRouters.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRouters.java
new file mode 100644
index 0000000..f0acde7
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRouters.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import com.google.inject.TypeLiteral;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.Routers;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParseRouters extends ParseJson<Routers> {
+
+ @Inject
+ public ParseRouters(Json json) {
+ super(json, TypeLiteral.get(Routers.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRules.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRules.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRules.java
new file mode 100644
index 0000000..954180b
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRules.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.Rules;
+
+import com.google.inject.TypeLiteral;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParseRules extends ParseJson<Rules> {
+
+ @Inject
+ public ParseRules(Json json) {
+ super(json, TypeLiteral.get(Rules.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSecurityGroups.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSecurityGroups.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSecurityGroups.java
new file mode 100644
index 0000000..3864781
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSecurityGroups.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.SecurityGroups;
+
+import com.google.inject.TypeLiteral;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParseSecurityGroups extends ParseJson<SecurityGroups> {
+
+ @Inject
+ public ParseSecurityGroups(Json json) {
+ super(json, TypeLiteral.get(SecurityGroups.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSubnets.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSubnets.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSubnets.java
new file mode 100644
index 0000000..0c985ee
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSubnets.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import com.google.inject.TypeLiteral;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.Subnets;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParseSubnets extends ParseJson<Subnets> {
+
+ @Inject
+ public ParseSubnets(Json json) {
+ super(json, TypeLiteral.get(Subnets.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/PortsToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/PortsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/PortsToPagedIterable.java
new file mode 100644
index 0000000..cad5517
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/PortsToPagedIterable.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.Port;
+import org.jclouds.openstack.neutron.v2.features.PortApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import javax.inject.Inject;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Ensures Ports works as a paged iterable.
+ */
+public class PortsToPagedIterable extends Arg0ToPagedIterable.FromCaller<Port, PortsToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected PortsToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Port>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final PortApi portApi = api.getPortApi(region);
+ return new Function<Object, IterableWithMarker<Port>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Port> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(portApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listPortsInDetail()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RouterToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RouterToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RouterToPagedIterable.java
new file mode 100644
index 0000000..5ce4def
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RouterToPagedIterable.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.Router;
+import org.jclouds.openstack.neutron.v2.extensions.RouterApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+/**
+ * Ensures Routers works as PagedIterable.
+ */
+public class RouterToPagedIterable extends Arg0ToPagedIterable.FromCaller<Router, RouterToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected RouterToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Router>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final RouterApi routerApi = api.getRouterApi(region).get();
+ return new Function<Object, IterableWithMarker<Router>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Router> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(routerApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listRouters()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RulesToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RulesToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RulesToPagedIterable.java
new file mode 100644
index 0000000..d664cd6
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RulesToPagedIterable.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.Rule;
+import org.jclouds.openstack.neutron.v2.extensions.SecurityGroupApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+/**
+ * Ensures Routers works as PagedIterable.
+ */
+public class RulesToPagedIterable extends
+ Arg0ToPagedIterable.FromCaller<Rule, RulesToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected RulesToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Rule>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final SecurityGroupApi securityGroupApi = api.getSecurityGroupApi(region).get();
+ return new Function<Object, IterableWithMarker<Rule>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Rule> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(securityGroupApi.listRules(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listRules()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SecurityGroupsToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SecurityGroupsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SecurityGroupsToPagedIterable.java
new file mode 100644
index 0000000..15c7c14
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SecurityGroupsToPagedIterable.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.SecurityGroup;
+import org.jclouds.openstack.neutron.v2.extensions.SecurityGroupApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+/**
+ * Ensures Routers works as PagedIterable.
+ */
+public class SecurityGroupsToPagedIterable extends
+ Arg0ToPagedIterable.FromCaller<SecurityGroup, SecurityGroupsToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected SecurityGroupsToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<SecurityGroup>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final SecurityGroupApi securityGroupApi = api.getSecurityGroupApi(region).get();
+ return new Function<Object, IterableWithMarker<SecurityGroup>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<SecurityGroup> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(securityGroupApi.listSecurityGroups(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listSecurityGroups()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SubnetsToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SubnetsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SubnetsToPagedIterable.java
new file mode 100644
index 0000000..a5e6abe
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SubnetsToPagedIterable.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.Subnet;
+import org.jclouds.openstack.neutron.v2.features.SubnetApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import javax.inject.Inject;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Ensures Subnets works as a PagedIterable.
+ */
+public class SubnetsToPagedIterable extends Arg0ToPagedIterable.FromCaller<Subnet, SubnetsToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected SubnetsToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Subnet>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final SubnetApi subnetApi = api.getSubnetApi(region);
+ return new Function<Object, IterableWithMarker<Subnet>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Subnet> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(subnetApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listSubnets()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/HealthMonitorsToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/HealthMonitorsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/HealthMonitorsToPagedIterable.java
new file mode 100644
index 0000000..e925b81
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/HealthMonitorsToPagedIterable.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitor;
+import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+/**
+ * Makes HealthMonitors work as a PagedIterable.
+ */
+public class HealthMonitorsToPagedIterable extends
+ Arg0ToPagedIterable.FromCaller<HealthMonitor, HealthMonitorsToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected HealthMonitorsToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<HealthMonitor>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final LBaaSApi lbaasApi = api.getLBaaSApi(region).get();
+ return new Function<Object, IterableWithMarker<HealthMonitor>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<HealthMonitor> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(lbaasApi.listHealthMonitors(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listHealthMonitors()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/MembersToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/MembersToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/MembersToPagedIterable.java
new file mode 100644
index 0000000..23b1719
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/MembersToPagedIterable.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Member;
+import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+/**
+ * Makes Members work as a PagedIterable.
+ */
+public class MembersToPagedIterable extends Arg0ToPagedIterable.FromCaller<Member, MembersToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected MembersToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Member>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final LBaaSApi lbaasApi = api.getLBaaSApi(region).get();
+ return new Function<Object, IterableWithMarker<Member>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Member> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(lbaasApi.listMembers(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listMembers()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseHealthMonitors.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseHealthMonitors.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseHealthMonitors.java
new file mode 100644
index 0000000..d74ceaf
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseHealthMonitors.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions.lbaas.v1;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors;
+
+import com.google.inject.TypeLiteral;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParseHealthMonitors extends ParseJson<HealthMonitors> {
+
+ @Inject
+ public ParseHealthMonitors(Json json) {
+ super(json, TypeLiteral.get(HealthMonitors.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseMembers.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseMembers.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseMembers.java
new file mode 100644
index 0000000..252a5b0
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseMembers.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions.lbaas.v1;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members;
+
+import com.google.inject.TypeLiteral;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParseMembers extends ParseJson<Members> {
+
+ @Inject
+ public ParseMembers(Json json) {
+ super(json, TypeLiteral.get(Members.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParsePools.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParsePools.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParsePools.java
new file mode 100644
index 0000000..adf81da
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParsePools.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions.lbaas.v1;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools;
+
+import com.google.inject.TypeLiteral;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParsePools extends ParseJson<Pools> {
+
+ @Inject
+ public ParsePools(Json json) {
+ super(json, TypeLiteral.get(Pools.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseVIPs.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseVIPs.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseVIPs.java
new file mode 100644
index 0000000..d97710c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseVIPs.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions.lbaas.v1;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs;
+
+import com.google.inject.TypeLiteral;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParseVIPs extends ParseJson<VIPs> {
+
+ @Inject
+ public ParseVIPs(Json json) {
+ super(json, TypeLiteral.get(VIPs.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/PoolsToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/PoolsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/PoolsToPagedIterable.java
new file mode 100644
index 0000000..c59b966
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/PoolsToPagedIterable.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pool;
+import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+/**
+ * Makes Pools work as a PagedIterable.
+ */
+public class PoolsToPagedIterable extends Arg0ToPagedIterable.FromCaller<Pool, PoolsToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected PoolsToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Pool>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final LBaaSApi lbaasApi = api.getLBaaSApi(region).get();
+ return new Function<Object, IterableWithMarker<Pool>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Pool> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(lbaasApi.listPools(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listPools()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/VIPsToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/VIPsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/VIPsToPagedIterable.java
new file mode 100644
index 0000000..5731b2f
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/VIPsToPagedIterable.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.functions.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIP;
+import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+/**
+ * Makes VIPs work as a PagedIterable.
+ */
+public class VIPsToPagedIterable extends Arg0ToPagedIterable.FromCaller<VIP, VIPsToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected VIPsToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<VIP>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final LBaaSApi lbaasApi = api.getLBaaSApi(region).get();
+ return new Function<Object, IterableWithMarker<VIP>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<VIP> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(lbaasApi.listVIPs(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listVIPs()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/handlers/NeutronErrorHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/handlers/NeutronErrorHandler.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/handlers/NeutronErrorHandler.java
new file mode 100644
index 0000000..5aaaae5
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/handlers/NeutronErrorHandler.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.handlers;
+
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ResourceNotFoundException;
+
+import javax.inject.Singleton;
+
+import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
+
+/**
+ * This will parse and set an appropriate exception on the command object.
+ */
+@Singleton
+public class NeutronErrorHandler implements HttpErrorHandler {
+ public void handleError(HttpCommand command, HttpResponse response) {
+ // it is important to always read fully and close streams
+ byte[] data = closeClientButKeepContentStream(response);
+ String message = data != null ? new String(data) : null;
+
+ Exception exception = message != null ? new HttpResponseException(command, response, message)
+ : new HttpResponseException(command, response);
+ message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
+ response.getStatusLine());
+ switch (response.getStatusCode()) {
+ case 400:
+ break;
+ case 401:
+ case 403:
+ exception = new AuthorizationException(message, exception);
+ break;
+ case 404:
+ if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
+ exception = new ResourceNotFoundException(message, exception);
+ }
+ break;
+ case 409:
+ exception = new IllegalStateException(exception.getMessage(), exception);
+ break;
+ }
+ command.setException(exception);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/options/EmptyOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/options/EmptyOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/options/EmptyOptions.java
new file mode 100644
index 0000000..98205fc
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/options/EmptyOptions.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.options;
+
+import com.google.inject.Inject;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import java.util.Map;
+
+/**
+ * This class is used for methods who don't need a wrapper around their JSON body
+ *
+ */
+public class EmptyOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ return bindToRequest(request, (Object) postParams);
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/NeutronApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/NeutronApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/NeutronApi.java
new file mode 100644
index 0000000..a5ff027
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/NeutronApi.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0;
+
+import java.io.Closeable;
+import java.util.Set;
+
+import org.jclouds.location.Region;
+import org.jclouds.location.Zone;
+import org.jclouds.location.functions.RegionToEndpoint;
+import org.jclouds.location.functions.ZoneToEndpoint;
+import org.jclouds.openstack.neutron.v2_0.extensions.RouterApi;
+import org.jclouds.openstack.neutron.v2_0.features.NetworkApi;
+import org.jclouds.openstack.neutron.v2_0.features.PortApi;
+import org.jclouds.openstack.neutron.v2_0.features.SubnetApi;
+import org.jclouds.openstack.v2_0.features.ExtensionApi;
+import org.jclouds.rest.annotations.Delegate;
+import org.jclouds.rest.annotations.EndpointParam;
+
+import com.google.common.base.Optional;
+import com.google.inject.Provides;
+
+/**
+ * Provides access to the OpenStack Networking (Neutron) v2 API.
+ * <p/>
+ *
+ * @deprecated Please use {@link org.jclouds.openstack.neutron.v2.NeutronApi} as this
+ * interface will be removed in jclouds 3.0.
+ */
+@Deprecated
+public interface NeutronApi extends Closeable {
+
+ /**
+ * @return the Region codes configured
+ */
+ @Provides
+ @Region
+ Set<String> getConfiguredRegions();
+
+ /**
+ * Provides access to Extension features.
+ */
+ @Delegate
+ ExtensionApi getExtensionApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+
+ /**
+ * Provides access to Network features.
+ */
+ @Delegate
+ NetworkApi getNetworkApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+
+ /**
+ * Provides access to Subnet features.
+ */
+ @Delegate
+ SubnetApi getSubnetApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+
+ /**
+ * Provides access to Port features.
+ */
+ @Delegate
+ PortApi getPortApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+
+ /**
+ * Provides access to Router features.
+ */
+ @Delegate
+ Optional<? extends RouterApi> getRouterApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+
+ /**
+ * @return the Zone codes configured
+ * @deprecated Please use {@link #getConfiguredRegions()} as this method will be removed in jclouds 3.0.
+ */
+ @Deprecated
+ @Provides
+ @Zone
+ Set<String> getConfiguredZones();
+
+ /**
+ * Provides access to Extension features.
+ * @deprecated Please use {@link #getExtensionApi(String)} as this method will be removed in jclouds 3.0.
+ */
+ @Deprecated
+ @Delegate
+ ExtensionApi getExtensionApiForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) String zone);
+
+ /**
+ * Provides access to Network features.
+ * @deprecated Please use {@link #getNetworkApi(String)} as this method will be removed in jclouds 3.0.
+ */
+ @Deprecated
+ @Delegate
+ NetworkApi getNetworkApiForZone(@EndpointParam(parser = ZoneToEndpoint.class) String zone);
+
+ /**
+ * Provides access to Subnet features.
+ * @deprecated Please use {@link #getSubnetApi(String)} as this method will be removed in jclouds 3.0.
+ */
+ @Deprecated
+ @Delegate
+ SubnetApi getSubnetApiForZone(@EndpointParam(parser = ZoneToEndpoint.class) String zone);
+
+ /**
+ * Provides access to Port features.
+ * @deprecated Please use {@link #getPortApi(String)} as this method will be removed in jclouds 3.0.
+ */
+ @Deprecated
+ @Delegate
+ PortApi getPortApiForZone(@EndpointParam(parser = ZoneToEndpoint.class) String zone);
+
+ /**
+ * Provides access to Router features.
+ * @deprecated Please use {@link #getRouterApi(String)} as this method will be removed in jclouds 3.0.
+ */
+ @Deprecated
+ @Delegate
+ Optional<? extends RouterApi> getRouterExtensionForZone(@EndpointParam(parser = ZoneToEndpoint.class) String zone);
+}
[47/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/UseNodeCredentialsButOverrideFromTemplate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/UseNodeCredentialsButOverrideFromTemplate.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/UseNodeCredentialsButOverrideFromTemplate.java
new file mode 100644
index 0000000..ff75a03
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/UseNodeCredentialsButOverrideFromTemplate.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.strategy;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.options.RunScriptOptions;
+import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate;
+import org.jclouds.domain.LoginCredentials;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+/**
+ * GCE needs the credentials to create the node so the node credentials already take the Image credentials into account,
+ * as such only overriding the TemplateOptions credentials is required.
+ */
+@Singleton
+public class UseNodeCredentialsButOverrideFromTemplate extends PrioritizeCredentialsFromTemplate {
+
+
+ @Inject
+ public UseNodeCredentialsButOverrideFromTemplate(
+ Function<Template, LoginCredentials> credentialsFromImageOrTemplateOptions) {
+ super(credentialsFromImageOrTemplateOptions);
+ }
+
+ public LoginCredentials apply(Template template, LoginCredentials fromNode) {
+ RunScriptOptions options = checkNotNull(template.getOptions(), "template options are required");
+ LoginCredentials.Builder builder = LoginCredentials.builder(fromNode);
+ if (options.getLoginUser() != null)
+ builder.user(template.getOptions().getLoginUser());
+ if (options.getLoginPassword() != null)
+ builder.password(options.getLoginPassword());
+ if (options.getLoginPrivateKey() != null)
+ builder.privateKey(options.getLoginPrivateKey());
+ if (options.shouldAuthenticateSudo() != null && options.shouldAuthenticateSudo())
+ builder.authenticateSudo(true);
+ return builder.build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java
new file mode 100644
index 0000000..2a1b3f2
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.config;
+
+import static com.google.common.base.Suppliers.compose;
+import static com.google.inject.name.Names.named;
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
+
+import java.net.URI;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.domain.Credentials;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.Project;
+import org.jclouds.googlecomputeengine.domain.SlashEncodedIds;
+import org.jclouds.googlecomputeengine.handlers.GoogleComputeEngineErrorHandler;
+import org.jclouds.googlecomputeengine.predicates.GlobalOperationDonePredicate;
+import org.jclouds.googlecomputeengine.predicates.RegionOperationDonePredicate;
+import org.jclouds.googlecomputeengine.predicates.ZoneOperationDonePredicate;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.Uris;
+import org.jclouds.http.annotation.ClientError;
+import org.jclouds.http.annotation.Redirection;
+import org.jclouds.http.annotation.ServerError;
+import org.jclouds.json.config.GsonModule.DateAdapter;
+import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
+import org.jclouds.location.Provider;
+import org.jclouds.location.suppliers.ImplicitLocationSupplier;
+import org.jclouds.location.suppliers.implicit.FirstZone;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.jclouds.rest.config.HttpApiModule;
+import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Splitter;
+import com.google.common.base.Supplier;
+import com.google.common.collect.Iterables;
+import com.google.inject.Provides;
+import com.google.inject.Scopes;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Configures the GoogleCompute connection.
+ */
+@ConfiguresHttpApi
+public class GoogleComputeEngineHttpApiModule extends HttpApiModule<GoogleComputeEngineApi> {
+ public GoogleComputeEngineHttpApiModule() {
+ }
+
+ @Override
+ protected void configure() {
+ bind(DateAdapter.class).to(Iso8601DateAdapter.class);
+ bind(new TypeLiteral<Predicate<AtomicReference<Operation>>>() {
+ }).annotatedWith(named("global")).to(GlobalOperationDonePredicate.class);
+ bind(new TypeLiteral<Predicate<AtomicReference<Operation>>>() {
+ }).annotatedWith(named("region")).to(RegionOperationDonePredicate.class);
+ bind(new TypeLiteral<Predicate<AtomicReference<Operation>>>() {
+ }).annotatedWith(named("zone")).to(ZoneOperationDonePredicate.class);
+ bind(ImplicitLocationSupplier.class).to(FirstZone.class).in(Scopes.SINGLETON);
+ super.configure();
+ }
+
+ @Override
+ protected void bindErrorHandlers() {
+ bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(GoogleComputeEngineErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(GoogleComputeEngineErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(GoogleComputeEngineErrorHandler.class);
+ }
+
+ @Provides
+ @Singleton
+ @UserProject
+ public Supplier<String> supplyProject(@Provider final Supplier<Credentials> creds,
+ final GoogleComputeEngineApi api,
+ AtomicReference<AuthorizationException> authException,
+ @Named(PROPERTY_SESSION_INTERVAL) long seconds) {
+ return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
+ compose(new Function<Credentials, String>() {
+ public String apply(Credentials in) {
+ // ID should be of the form project_id@developer.gserviceaccount.com
+ // OR (increasingly often) project_id-extended_uid@developer.gserviceaccount.com
+ // where project_id is the NUMBER;
+ // HERE we also accept simply "project" as the identity, if no "@" is present;
+ // this is used in tests, but not sure if it is valid in the wild.
+ String projectName = in.identity;
+ if (projectName.indexOf("@") != -1) {
+ projectName = Iterables.get(Splitter.on("@").split(projectName), 0);
+ if (projectName.indexOf("-") != -1) {
+ // if ID is of the form project_id-extended_uid@developer.gserviceaccount.com
+ projectName = Iterables.get(Splitter.on("-").split(projectName), 0);
+ }
+ }
+ Project project = api.getProjectApi().get(projectName);
+ return project.getName();
+ }
+ }, creds), seconds, TimeUnit.SECONDS);
+ }
+
+ @Provides
+ @Singleton
+ @Named("machineTypeToURI")
+ public Function<String, URI> provideMachineTypeNameToURIFunction(@Provider final Supplier<URI> endpoint,
+ @UserProject final Supplier<String> userProject) {
+ return new Function<String, URI>() {
+ @Override
+ public URI apply(String input) {
+ SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(input);
+ return Uris.uriBuilder(endpoint.get()).appendPath("/projects/").appendPath(userProject.get())
+ .appendPath("/zones/").appendPath(slashEncodedIds.getFirstId())
+ .appendPath("/machineTypes/").appendPath(slashEncodedIds.getSecondId()).build();
+ }
+ };
+ }
+
+ @Provides
+ @Singleton
+ @Named("networkToURI")
+ public Function<String, URI> provideNetworkNameToURIFunction(@Provider final Supplier<URI> endpoint,
+ @UserProject final Supplier<String> userProject) {
+ return new Function<String, URI>() {
+ @Override
+ public URI apply(String input) {
+ return Uris.uriBuilder(endpoint.get()).appendPath("/projects/").appendPath(userProject.get())
+ .appendPath("/global/networks/").appendPath(input).build();
+ }
+ };
+ }
+
+ @Provides
+ @Singleton
+ @Named("zoneToURI")
+ public Function<String, URI> provideZoneNameToURIFunction(@Provider final Supplier<URI> endpoint,
+ @UserProject final Supplier<String> userProject) {
+ return new Function<String, URI>() {
+ @Override
+ public URI apply(String input) {
+ return Uris.uriBuilder(endpoint.get()).appendPath("/projects/").appendPath(userProject.get())
+ .appendPath("/zones/").appendPath(input).build();
+ }
+ };
+ }
+
+ @Provides
+ @Singleton
+ @Named("regionToURI")
+ public Function<String, URI> provideRegionNameToURIFunction(@Provider final Supplier<URI> endpoint,
+ @UserProject final Supplier<String> userProject) {
+ return new Function<String, URI>() {
+ @Override
+ public URI apply(String input) {
+ return Uris.uriBuilder(endpoint.get()).appendPath("/projects/").appendPath(userProject.get())
+ .appendPath("/regions/").appendPath(input).build();
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java
new file mode 100644
index 0000000..cd7e8d1
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java
@@ -0,0 +1,413 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.config;
+
+import static org.jclouds.googlecomputeengine.domain.Firewall.Rule;
+
+import java.beans.ConstructorProperties;
+import java.lang.reflect.Type;
+import java.net.URI;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Singleton;
+
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.InstanceTemplate;
+import org.jclouds.googlecomputeengine.domain.Metadata;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.Project;
+import org.jclouds.googlecomputeengine.domain.Quota;
+import org.jclouds.googlecomputeengine.options.FirewallOptions;
+import org.jclouds.googlecomputeengine.options.RouteOptions;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.oauth.v2.domain.ClaimSet;
+import org.jclouds.oauth.v2.domain.Header;
+import org.jclouds.oauth.v2.json.ClaimSetTypeAdapter;
+import org.jclouds.oauth.v2.json.HeaderTypeAdapter;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Range;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+
+public class GoogleComputeEngineParserModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(GsonModule.DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class);
+ }
+
+ @Provides
+ @Singleton
+ public Map<Type, Object> provideCustomAdapterBindings() {
+ return new ImmutableMap.Builder<Type, Object>()
+ .put(Metadata.class, new MetadataTypeAdapter())
+ .put(Operation.class, new OperationTypeAdapter())
+ .put(Header.class, new HeaderTypeAdapter())
+ .put(ClaimSet.class, new ClaimSetTypeAdapter())
+ .put(Project.class, new ProjectTypeAdapter())
+ .put(Instance.class, new InstanceTypeAdapter())
+ .put(InstanceTemplate.class, new InstanceTemplateTypeAdapter())
+ .put(FirewallOptions.class, new FirewallOptionsTypeAdapter())
+ .put(RouteOptions.class, new RouteOptionsTypeAdapter())
+ .put(Rule.class, new RuleTypeAdapter())
+ .build();
+ }
+
+ /**
+ * Parser for operations that unwraps errors avoiding an extra intermediate object.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
+ */
+ @Singleton
+ private static class OperationTypeAdapter implements JsonDeserializer<Operation> {
+
+ @Override
+ public Operation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws
+ JsonParseException {
+ Operation.Builder operationBuilder = ((Operation) context.deserialize(json,
+ OperationInternal.class)).toBuilder();
+ JsonObject error = json.getAsJsonObject().getAsJsonObject("error");
+ if (error != null) {
+ JsonArray array = error.getAsJsonArray("errors");
+ if (array != null) {
+ for (JsonElement element : array) {
+ operationBuilder.addError((Operation.Error) context.deserialize(element, Operation.Error.class));
+ }
+ }
+ }
+ return operationBuilder.build();
+ }
+
+ private static class OperationInternal extends Operation {
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "targetLink", "targetId",
+ "clientOperationId", "status", "statusMessage", "user", "progress", "insertTime", "startTime",
+ "endTime", "httpErrorStatusCode", "httpErrorMessage", "operationType", "region", "zone"
+ })
+ private OperationInternal(String id, Date creationTimestamp, URI selfLink, String name,
+ String description, URI targetLink, String targetId, String clientOperationId,
+ Status status, String statusMessage, String user, int progress, Date insertTime,
+ Date startTime, Date endTime, int httpErrorStatusCode, String httpErrorMessage,
+ String operationType, URI region, URI zone) {
+ super(id, creationTimestamp, selfLink, name, description, targetLink, targetId, clientOperationId,
+ status, statusMessage, user, progress, insertTime, startTime, endTime, httpErrorStatusCode,
+ httpErrorMessage, operationType, null, region, zone);
+ }
+ }
+ }
+
+ @Singleton
+ private static class InstanceTemplateTypeAdapter implements JsonSerializer<InstanceTemplate> {
+
+ @Override
+ public JsonElement serialize(InstanceTemplate src, Type typeOfSrc, JsonSerializationContext context) {
+ InstanceTemplateInternal template = new InstanceTemplateInternal(src);
+ JsonObject instance = (JsonObject) context.serialize(template, InstanceTemplateInternal.class);
+
+ // deal with network
+ JsonArray networkInterfaces = new JsonArray();
+ for (InstanceTemplate.NetworkInterface networkInterface : template.getNetworkInterfaces()){
+ networkInterfaces.add(context.serialize(networkInterface, InstanceTemplate.NetworkInterface.class));
+ }
+ instance.add("networkInterfaces", networkInterfaces);
+
+ // deal with persistent disks
+ if (src.getDisks() != null && !src.getDisks().isEmpty()) {
+ JsonArray disks = new JsonArray();
+ for (InstanceTemplate.PersistentDisk persistentDisk : src.getDisks()) {
+ JsonObject disk = (JsonObject) context.serialize(persistentDisk, InstanceTemplate.PersistentDisk.class);
+ disk.addProperty("type", "PERSISTENT");
+ disks.add(disk);
+ }
+ instance.add("disks", disks);
+ }
+
+ // deal with metadata
+ if (src.getMetadata() != null && !src.getMetadata().isEmpty()) {
+ Metadata metadata = Metadata.builder()
+ .items(src.getMetadata())
+ .build();
+ JsonObject metadataJson = (JsonObject) context.serialize(metadata);
+ instance.add("metadata", metadataJson);
+ return instance;
+ }
+
+ return instance;
+ }
+
+ private static class InstanceTemplateInternal extends InstanceTemplate {
+ private InstanceTemplateInternal(InstanceTemplate template) {
+ super(template.getMachineType());
+ name(template.getName());
+ description(template.getDescription());
+ image(template.getImage());
+ serviceAccounts(template.getServiceAccounts());
+ networkInterfaces(template.getNetworkInterfaces());
+ }
+ }
+ }
+
+ @Singleton
+ private static class InstanceTypeAdapter implements JsonDeserializer<Instance> {
+
+ @Override
+ public Instance deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws
+ JsonParseException {
+ Instance.Builder instanceBuilder = ((Instance) context.deserialize(json,
+ InstanceInternal.class)).toBuilder();
+ JsonObject object = (JsonObject) json;
+ if (object.get("disks") != null) {
+ JsonArray disks = (JsonArray) object.get("disks");
+ for (JsonElement element : disks) {
+ JsonObject disk = (JsonObject) element;
+ if (disk.get("type").getAsString().equals("PERSISTENT")) {
+ instanceBuilder.addDisk((Instance.PersistentAttachedDisk) context.deserialize(disk,
+ Instance.PersistentAttachedDisk.class));
+ } else {
+ instanceBuilder.addDisk((Instance.AttachedDisk) context.deserialize(disk,
+ Instance.AttachedDisk.class));
+ }
+ }
+
+ }
+
+ return Instance.builder().fromInstance(instanceBuilder.build()).build();
+ }
+
+
+ private static class InstanceInternal extends Instance {
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "tags", "machineType",
+ "status", "statusMessage", "zone", "networkInterfaces", "metadata", "serviceAccounts"
+ })
+ private InstanceInternal(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Tags tags, URI machineType, Status status, String statusMessage,
+ URI zone, Set<NetworkInterface> networkInterfaces, Metadata metadata,
+ Set<ServiceAccount> serviceAccounts) {
+ super(id, creationTimestamp, selfLink, name, description, tags, machineType,
+ status, statusMessage, zone, networkInterfaces, null, metadata, serviceAccounts);
+ }
+ }
+ }
+
+ /**
+ * Parser for Metadata.
+ */
+ @Singleton
+ private static class MetadataTypeAdapter implements JsonDeserializer<Metadata>, JsonSerializer<Metadata> {
+
+
+ @Override
+ public Metadata deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws
+ JsonParseException {
+ ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
+ JsonObject metadata = json.getAsJsonObject();
+ JsonArray items = metadata.getAsJsonArray("items");
+ if (items != null) {
+ for (JsonElement element : items) {
+ JsonObject object = element.getAsJsonObject();
+ builder.put(object.get("key").getAsString(), object.get("value").getAsString());
+ }
+ }
+ String fingerprint = null;
+ if (metadata.getAsJsonPrimitive("fingerprint") != null) {
+ fingerprint = metadata.getAsJsonPrimitive("fingerprint").getAsString();
+ } else {
+ fingerprint = "";
+ }
+ return new Metadata(fingerprint, builder.build());
+ }
+
+ @Override
+ public JsonElement serialize(Metadata src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonObject metadataObject = new JsonObject();
+ metadataObject.add("kind", new JsonPrimitive("compute#metadata"));
+ JsonArray items = new JsonArray();
+ for (Map.Entry<String, String> entry : src.getItems().entrySet()) {
+ JsonObject object = new JsonObject();
+ object.addProperty("key", entry.getKey());
+ object.addProperty("value", entry.getValue());
+ items.add(object);
+ }
+ metadataObject.add("items", items);
+ if (src.getFingerprint() != null) {
+ metadataObject.addProperty("fingerprint", src.getFingerprint());
+ }
+ return metadataObject;
+ }
+ }
+
+
+
+ @Singleton
+ private static class ProjectTypeAdapter implements JsonDeserializer<Project> {
+
+ @Override
+ public Project deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws
+ JsonParseException {
+ return Project.builder().fromProject((Project) context.deserialize(json, ProjectInternal.class)).build();
+ }
+
+ private static class ProjectInternal extends Project {
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "commonInstanceMetadata", "quotas",
+ "externalIpAddresses"
+ })
+ private ProjectInternal(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Metadata commonInstanceMetadata, Set<Quota> quotas, Set<String> externalIpAddresses) {
+ super(id, creationTimestamp, selfLink, name, description, commonInstanceMetadata, quotas,
+ externalIpAddresses);
+ }
+
+ }
+ }
+
+ @Singleton
+ private static class FirewallOptionsTypeAdapter implements JsonSerializer<FirewallOptions> {
+
+ @Override
+ public JsonElement serialize(FirewallOptions src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonObject firewall = new JsonObject();
+ if (src.getName() != null) {
+ firewall.addProperty("name", src.getName());
+ }
+ if (src.getNetwork() != null) {
+ firewall.addProperty("network", src.getNetwork().toString());
+ }
+ if (!src.getSourceRanges().isEmpty()) {
+ firewall.add("sourceRanges", buildArrayOfStrings(src.getSourceRanges()));
+ }
+ if (!src.getSourceTags().isEmpty()) {
+ firewall.add("sourceTags", buildArrayOfStrings(src.getSourceTags()));
+ }
+ if (!src.getTargetTags().isEmpty()) {
+ firewall.add("targetTags", buildArrayOfStrings(src.getTargetTags()));
+ }
+ if (!src.getAllowed().isEmpty()) {
+ JsonArray rules = new JsonArray();
+ for (Rule rule : src.getAllowed()) {
+ rules.add(context.serialize(rule, Firewall.Rule.class));
+ }
+ firewall.add("allowed", rules);
+ }
+ return firewall;
+ }
+ }
+
+ @Singleton
+ private static class RouteOptionsTypeAdapter implements JsonSerializer<RouteOptions> {
+
+ @Override
+ public JsonElement serialize(RouteOptions src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonObject route = new JsonObject();
+ if (src.getName() != null) {
+ route.addProperty("name", src.getName());
+ }
+ if (src.getNetwork() != null) {
+ route.addProperty("network", src.getNetwork().toString());
+ }
+ if (src.getNextHopGateway() != null) {
+ route.addProperty("nextHopGateway", src.getNextHopGateway().toString());
+ }
+ if (src.getNextHopInstance() != null) {
+ route.addProperty("nextHopInstance", src.getNextHopInstance().toString());
+ }
+ if (src.getNextHopNetwork() != null) {
+ route.addProperty("nextHopNetwork", src.getNextHopNetwork().toString());
+ }
+ if (src.getDestRange() != null) {
+ route.addProperty("destRange", src.getDestRange());
+ }
+ if (src.getDescription() != null) {
+ route.addProperty("description", src.getDescription());
+ }
+ if (src.getPriority() != null) {
+ route.addProperty("priority", src.getPriority());
+ }
+ if (src.getNextHopIp() != null) {
+ route.addProperty("nextHopIp", src.getNextHopIp());
+ }
+ if (!src.getTags().isEmpty()) {
+ route.add("tags", buildArrayOfStrings(src.getTags()));
+ }
+ return route;
+ }
+ }
+
+ private static JsonArray buildArrayOfStrings(Set<String> strings) {
+ JsonArray array = new JsonArray();
+ for (String string : strings) {
+ array.add(new JsonPrimitive(string));
+ }
+ return array;
+ }
+
+
+ private static class RuleTypeAdapter implements JsonDeserializer<Firewall.Rule>, JsonSerializer<Firewall.Rule> {
+
+ @Override
+ public Firewall.Rule deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws
+ JsonParseException {
+ JsonObject rule = json.getAsJsonObject();
+ Rule.Builder builder = Rule.builder();
+ builder.IpProtocol(IpProtocol.fromValue(rule.get("IPProtocol").getAsString()));
+ if (rule.get("ports") != null) {
+ JsonArray ports = (JsonArray) rule.get("ports");
+ for (JsonElement port : ports) {
+ String portAsString = port.getAsString();
+ if (portAsString.contains("-")) {
+ String[] split = portAsString.split("-");
+ builder.addPortRange(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
+ } else {
+ builder.addPort(Integer.parseInt(portAsString));
+ }
+ }
+ }
+ return builder.build();
+ }
+
+ @Override
+ public JsonElement serialize(Firewall.Rule src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonObject ruleObject = new JsonObject();
+ ruleObject.addProperty("IPProtocol", src.getIpProtocol().value());
+ if (src.getPorts() != null && !src.getPorts().isEmpty()) {
+ JsonArray ports = new JsonArray();
+ for (Range<Integer> range : src.getPorts().asRanges()) {
+ ports.add(new JsonPrimitive(range.lowerEndpoint() == range.upperEndpoint() ? range.lowerEndpoint() + "" :
+ range.lowerEndpoint() + "-" + range.upperEndpoint()));
+ }
+ ruleObject.add("ports", ports);
+ }
+ return ruleObject;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/OAuthModuleWithoutTypeAdapters.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/OAuthModuleWithoutTypeAdapters.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/OAuthModuleWithoutTypeAdapters.java
new file mode 100644
index 0000000..03f2f46
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/OAuthModuleWithoutTypeAdapters.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.config;
+
+import org.jclouds.oauth.v2.config.CredentialType;
+import org.jclouds.oauth.v2.config.OAuthModule;
+import org.jclouds.oauth.v2.domain.OAuthCredentials;
+import org.jclouds.oauth.v2.domain.Token;
+import org.jclouds.oauth.v2.domain.TokenRequest;
+import org.jclouds.oauth.v2.functions.BuildTokenRequest;
+import org.jclouds.oauth.v2.functions.FetchToken;
+import org.jclouds.oauth.v2.functions.OAuthCredentialsSupplier;
+import org.jclouds.oauth.v2.functions.SignOrProduceMacForToken;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Overrides OAuthModule leaving TypeAdapters bindings out.
+ * <p/>
+ * TODO overcome this by using multibindings on GSonModule?
+ */
+public class OAuthModuleWithoutTypeAdapters extends OAuthModule {
+
+ @Override
+ protected void configure() {
+ bind(new TypeLiteral<Function<byte[], byte[]>>() {
+ }).to(SignOrProduceMacForToken.class);
+ bind(new TypeLiteral<Supplier<OAuthCredentials>>() {
+ }).to(OAuthCredentialsSupplier.class);
+ bind(new TypeLiteral<Function<GeneratedHttpRequest, TokenRequest>>() {
+ }).to(BuildTokenRequest.class);
+ bind(new TypeLiteral<Function<TokenRequest, Token>>() {
+ }).to(FetchToken.class);
+ bind(CredentialType.class).toProvider(OAuthModule.CredentialTypeFromPropertyOrDefault.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/UserProject.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/UserProject.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/UserProject.java
new file mode 100644
index 0000000..e932d1c
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/config/UserProject.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.config;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Qualifies a property as the user's project id.
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
+@Qualifier
+public @interface UserProject {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/AbstractDisk.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/AbstractDisk.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/AbstractDisk.java
new file mode 100644
index 0000000..2cc8d8e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/AbstractDisk.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Date;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+
+/**
+ * A persistent disk resource
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/disks"/>
+ */
+@Beta
+public abstract class AbstractDisk extends Resource {
+
+ protected final Integer sizeGb;
+ protected final String status;
+
+ protected AbstractDisk(Kind kind, String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Integer sizeGb, String status) {
+ super(kind, id, creationTimestamp, selfLink, name, description);
+ this.sizeGb = checkNotNull(sizeGb, "sizeGb of %s", name);
+ this.status = checkNotNull(status, "status of %s", name);
+ }
+
+ /**
+ * @return size of the persistent disk, specified in GB.
+ */
+ public int getSizeGb() {
+ return sizeGb;
+ }
+
+ /**
+ * @return the status of disk creation.
+ */
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .omitNullValues()
+ .add("sizeGb", sizeGb)
+ .add("status", status);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromAbstractDisk(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends Resource.Builder<T> {
+
+ protected Integer sizeGb;
+ protected String status;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.AbstractDisk#getSizeGb()
+ */
+ public T sizeGb(Integer sizeGb) {
+ this.sizeGb = sizeGb;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.AbstractDisk#getStatus()
+ */
+ public T status(String status) {
+ this.status = status;
+ return self();
+ }
+
+ public T fromAbstractDisk(AbstractDisk in) {
+ return super.fromResource(in)
+ .sizeGb(in.getSizeGb())
+ .status(in.getStatus());
+ }
+
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Address.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Address.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Address.java
new file mode 100644
index 0000000..207cf75
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Address.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Optional.fromNullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+
+/**
+ * Represents an Address resource.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/addresses"/>
+ */
+@Beta
+public final class Address extends Resource {
+
+ private final String status;
+ private final Optional<URI> user;
+ private final URI region;
+ private final String address;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "status", "user",
+ "region", "address"
+ })
+ private Address(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ String status, URI user, URI region, String address) {
+ super(Kind.ADDRESS, id, creationTimestamp, selfLink, name, description);
+ this.status = checkNotNull(status, "status of %s", name);
+ this.user = fromNullable(user);
+ this.region = checkNotNull(region, "region of %s", name);
+ this.address = checkNotNull(address, "address of %s", name);
+ }
+
+ /**
+ * @return The status of the address. Valid items are RESERVED and IN USE.
+ * A reserved address is currently available to the project and can be
+ * used by a resource. An in-use address is currently being used by a resource.
+ */
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ * @return URL of the resource currently using this address.
+ */
+ public Optional<URI> getUser() {
+ return user;
+ }
+
+ /**
+ * @return URL of the region where the address resides.
+ */
+ public URI getRegion() {
+ return region;
+ }
+
+ /**
+ * @return The IP address represented by this resource.
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Address that = Address.class.cast(obj);
+ return equal(this.kind, that.kind)
+ && equal(this.name, that.name)
+ && equal(this.region, that.region);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .omitNullValues()
+ .add("status", status)
+ .add("user", user.orNull())
+ .add("region", region)
+ .add("address", address);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromAddress(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+ private String status;
+ private URI user;
+ private URI region;
+ private String address;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Address#getStatus()
+ */
+ public Builder status(String status) {
+ this.status = status;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Address#getUser()
+ */
+ public Builder user(URI user) {
+ this.user = user;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Address#getRegion()
+ */
+ public Builder region(URI region) {
+ this.region = region;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Address#getAddress()
+ */
+ public Builder address(String address) {
+ this.address = address;
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Address build() {
+ return new Address(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, status, user, region, address);
+ }
+
+ public Builder fromAddress(Address in) {
+ return super.fromResource(in)
+ .status(in.getStatus())
+ .user(in.getUser().orNull())
+ .region(in.getRegion())
+ .address(in.getAddress());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Deprecated.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Deprecated.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Deprecated.java
new file mode 100644
index 0000000..5a48acf
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Deprecated.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Optional.fromNullable;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+
+/**
+ * Deprecation information for an image or kernel
+ */
+public class Deprecated {
+ private final Optional<String> state;
+ private final Optional<URI> replacement;
+ private final Optional<String> deprecated;
+ private final Optional<String> obsolete;
+ private final Optional<String> deleted;
+
+ @ConstructorProperties({"state", "replacement", "deprecated", "obsolete", "deleted"})
+ public Deprecated(String state, URI replacement, String deprecated, String obsolete,
+ String deleted) {
+ this.state = fromNullable(state);
+ this.replacement = fromNullable(replacement);
+ this.deprecated = fromNullable(deprecated);
+ this.obsolete = fromNullable(obsolete);
+ this.deleted = fromNullable(deleted);
+ }
+
+ /**
+ * @return The deprecation state of this image.
+ */
+ public Optional<String> getState() {
+ return state;
+ }
+
+ /**
+ * @return A fully-qualified URL of the suggested replacement for the deprecated image.
+ */
+ public Optional<URI> getReplacement() {
+ return replacement;
+ }
+
+ /**
+ * @return An optional RFC3339 timestamp for when the deprecation state of this resource will be changed to DEPRECATED.
+ */
+ public Optional<String> getDeprecated() {
+ return deprecated;
+ }
+
+ /**
+ * @return An optional RFC3339 timestamp on or after which the deprecation state of this resource will be changed toOBSOLETE.
+ */
+ public Optional<String> getObsolete() {
+ return obsolete;
+ }
+
+ /**
+ * @return An optional RFC3339 timestamp on or after which the deprecation state of this resource will be changed to DELETED.
+ */
+ public Optional<String> getDeleted() {
+ return deleted;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(state, replacement, deprecated, obsolete, deleted);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Deprecated that = Deprecated.class.cast(obj);
+ return equal(this.state, that.state)
+ && equal(this.replacement, that.replacement)
+ && equal(this.deprecated, that.deprecated)
+ && equal(this.obsolete, that.obsolete)
+ && equal(this.deleted, that.deleted);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("state", state.orNull())
+ .add("replacement", replacement.orNull())
+ .add("deprecated", deprecated.orNull())
+ .add("obsolete", obsolete.orNull())
+ .add("deleted", deleted.orNull());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromDeprecated(this);
+ }
+
+ public static class Builder {
+ private String state;
+ private URI replacement;
+ private String deprecated;
+ private String obsolete;
+ private String deleted;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Deprecated#getState()
+ */
+ public Builder state(String state) {
+ this.state = state;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Deprecated#getReplacement()
+ */
+ public Builder replacement(URI replacement) {
+ this.replacement = replacement;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Deprecated#getDeprecated()
+ */
+ public Builder deprecated(String deprecated) {
+ this.deprecated = deprecated;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Deprecated#getObsolete()
+ */
+ public Builder obsolete(String obsolete) {
+ this.obsolete = obsolete;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Deprecated#getDeprecated()
+ */
+ public Builder deleted(String deleted) {
+ this.deleted = deleted;
+ return this;
+ }
+
+ public Deprecated build() {
+ return new Deprecated(state, replacement, deprecated, obsolete, deleted);
+ }
+
+ public Builder fromDeprecated(Deprecated in) {
+ return new Builder().state(in.getState().orNull())
+ .replacement(in.getReplacement().orNull())
+ .deprecated(in.getDeprecated().orNull())
+ .obsolete(in.getObsolete().orNull())
+ .deleted(in.getDeleted().orNull());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java
new file mode 100644
index 0000000..91d1502
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+
+/**
+ * A persistent disk resource
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/disks"/>
+ */
+@Beta
+public final class Disk extends AbstractDisk {
+
+ private final URI zone;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "sizeGb", "zone",
+ "status"
+ })
+ private Disk(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Integer sizeGb, URI zone, String status) {
+ super(Kind.DISK, id, creationTimestamp, selfLink, name, description, sizeGb, status);
+ this.zone = checkNotNull(zone, "zone of %s", name);
+ }
+
+ /**
+ * @return URL for the zone where the persistent disk resides.
+ */
+ public URI getZone() {
+ return zone;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Disk that = Disk.class.cast(obj);
+ return equal(this.kind, that.kind)
+ && equal(this.name, that.name)
+ && equal(this.zone, that.zone);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .omitNullValues()
+ .add("zone", zone);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromDisk(this);
+ }
+
+ public static final class Builder extends AbstractDisk.Builder<Builder> {
+
+ private URI zone;
+
+ /**
+ * @see Disk#getZone()
+ */
+ public Builder zone(URI zone) {
+ this.zone = zone;
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Disk build() {
+ return new Disk(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, super.sizeGb, zone, super.status);
+ }
+
+ public Builder fromDisk(Disk in) {
+ return super.fromAbstractDisk(in)
+ .zone(in.getZone());
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java
new file mode 100644
index 0000000..aee2cd4
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java
@@ -0,0 +1,379 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.Range.closed;
+import static com.google.common.collect.Range.singleton;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+import java.util.Set;
+
+import org.jclouds.net.domain.IpProtocol;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.RangeSet;
+import com.google.common.collect.TreeRangeSet;
+
+/**
+ * Represents a network firewall
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/firewalls"/>
+ * @see <a href="https://developers.google.com/compute/docs/networking#firewalls"/>
+ */
+@Beta
+public final class Firewall extends Resource {
+
+ private final URI network;
+ private final Set<String> sourceRanges;
+ private final Set<String> sourceTags;
+ private final Set<String> targetTags;
+ private final Set<Rule> allowed;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "network", "sourceRanges",
+ "sourceTags", "targetTags", "allowed"
+ })
+ protected Firewall(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ URI network, Set<String> sourceRanges, Set<String> sourceTags, Set<String> targetTags,
+ Set<Rule> allowed) {
+ super(Kind.FIREWALL, id, creationTimestamp, selfLink, name, description);
+ this.network = checkNotNull(network, "network of %s", name);
+ this.sourceRanges = sourceRanges == null ? ImmutableSet.<String>of() : sourceRanges;
+ this.sourceTags = sourceTags == null ? ImmutableSet.<String>of() : sourceTags;
+ this.targetTags = targetTags == null ? ImmutableSet.<String>of() : targetTags;
+ this.allowed = allowed == null ? ImmutableSet.<Rule>of() : allowed;
+ }
+
+ /**
+ * @return URI of the network to which this firewall is applied; provided by the client when the firewall is created.
+ */
+ public URI getNetwork() {
+ return network;
+ }
+
+ /**
+ * One or both of sourceRanges and sourceTags may be set; an inbound connection is allowed if either the range or
+ * the tag of the source matches.
+ *
+ * @return a list of IP address blocks expressed in CIDR format which this rule applies to.
+ */
+ public Set<String> getSourceRanges() {
+ return sourceRanges;
+ }
+
+ /**
+ * @return a list of instance items which this rule applies to. One or both of sourceRanges and sourceTags may be
+ * set; an inbound connection is allowed if either the range or the tag of the source matches.
+ */
+ public Set<String> getSourceTags() {
+ return sourceTags;
+ }
+
+ /**
+ * If no targetTags are specified, the firewall rule applies to all instances on the specified network.
+ *
+ * @return a list of instance items indicating sets of instances located on network which may make network
+ * connections as specified in allowed.
+ */
+ public Set<String> getTargetTags() {
+ return targetTags;
+ }
+
+ /**
+ * Each rule specifies a protocol and port-range tuple that describes a permitted connection.
+ *
+ * @return the list of rules specified by this firewall.
+ */
+ public Set<Rule> getAllowed() {
+ return allowed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("network", network)
+ .add("sourceRanges", sourceRanges)
+ .add("sourceTags", sourceTags)
+ .add("targetTags", targetTags)
+ .add("allowed", allowed);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromFirewall(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private URI network;
+ private ImmutableSet.Builder<String> sourceRanges = ImmutableSet.builder();
+ private ImmutableSet.Builder<String> sourceTags = ImmutableSet.builder();
+ private ImmutableSet.Builder<String> targetTags = ImmutableSet.builder();
+ private ImmutableSet.Builder<Rule> allowed = ImmutableSet.builder();
+
+ /**
+ * @see Firewall#getNetwork()
+ */
+ public Builder network(URI network) {
+ this.network = network;
+ return this;
+ }
+
+ /**
+ * @see Firewall#getSourceRanges()
+ */
+ public Builder addSourceRange(String sourceRange) {
+ this.sourceRanges.add(checkNotNull(sourceRange));
+ return this;
+ }
+
+ /**
+ * @see Firewall#getSourceRanges()
+ */
+ public Builder sourceRanges(Set<String> sourceRanges) {
+ this.sourceRanges.addAll(checkNotNull(sourceRanges));
+ return this;
+ }
+
+ /**
+ * @see Firewall#getSourceTags()
+ */
+ public Builder addSourceTag(String sourceTag) {
+ this.sourceTags.add(checkNotNull(sourceTag));
+ return this;
+ }
+
+ /**
+ * @see Firewall#getSourceTags()
+ */
+ public Builder sourceTags(Set<String> sourceTags) {
+ this.sourceTags.addAll(checkNotNull(sourceTags));
+ return this;
+ }
+
+ /**
+ * @see Firewall#getTargetTags()
+ */
+ public Builder addTargetTag(String targetTag) {
+ this.targetTags.add(checkNotNull(targetTag));
+ return this;
+ }
+
+ /**
+ * @see Firewall#getTargetTags()
+ */
+ public Builder targetTags(Set<String> targetTags) {
+ this.targetTags.addAll(checkNotNull(targetTags));
+ return this;
+ }
+
+ /**
+ * @see Firewall#getAllowed()
+ */
+ public Builder addAllowed(Rule firewallRule) {
+ this.allowed.add(checkNotNull(firewallRule));
+ return this;
+ }
+
+ /**
+ * @see Firewall#getAllowed()
+ */
+ public Builder allowed(Set<Rule> firewallRules) {
+ this.allowed = ImmutableSet.builder();
+ this.allowed.addAll(firewallRules);
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Firewall build() {
+ return new Firewall(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, network, sourceRanges.build(), sourceTags.build(), targetTags.build(),
+ allowed.build());
+ }
+
+ public Builder fromFirewall(Firewall in) {
+ return super.fromResource(in).network(in.getNetwork()).sourceRanges(in.getSourceRanges()).sourceTags(in
+ .getSourceTags()).targetTags(in.getTargetTags()).allowed(in.getAllowed());
+ }
+
+ }
+
+ /**
+ * A Firewall rule. Rule specifies a protocol and port-range tuple that describes a
+ * permitted connection.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/firewalls"/>
+ */
+ public static final class Rule {
+
+ private final IpProtocol ipProtocol;
+ private final RangeSet<Integer> ports;
+
+ /* Some handy shortcuts */
+ public static Rule permitTcpRule(Integer start, Integer end) { return Rule.builder().IpProtocol(IpProtocol.TCP).addPortRange(start, end).build(); }
+ public static Rule permitTcpRule(Integer port) { return Rule.builder().IpProtocol(IpProtocol.TCP).addPort(port).build(); }
+ public static Rule permitUdpRule(Integer start, Integer end) { return Rule.builder().IpProtocol(IpProtocol.UDP).addPortRange(start, end).build(); }
+ public static Rule permitUdpRule(Integer port) { return Rule.builder().IpProtocol(IpProtocol.UDP).addPort(port).build(); }
+ @ConstructorProperties({
+ "IpProtocol", "ports"
+ })
+ private Rule(IpProtocol IpProtocol, RangeSet<Integer> ports) {
+ this.ipProtocol = checkNotNull(IpProtocol);
+ this.ports = ports == null ? TreeRangeSet.<Integer>create() : ports;
+ }
+
+ /**
+ * This can either be a well known protocol string (tcp, udp or icmp) or the IP protocol number.
+ *
+ * @return this is the IP protocol that is allowed for this rule.
+ */
+ public IpProtocol getIpProtocol() {
+ return ipProtocol;
+ }
+
+ /**
+ * Each entry must be either an integer or a range. If not specified, connections through any port are allowed.
+ * Example inputs include: ["22"], ["80,"443"], and ["12345-12349"].
+ * <p/>
+ * It is an error to specify this for any protocol that isn't UDP or TCP.
+ *
+ * @return An optional list of ports which are allowed.
+ */
+ public RangeSet<Integer> getPorts() {
+ return ports;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(ipProtocol, ports);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Rule that = Rule.class.cast(obj);
+ return equal(this.ipProtocol, that.ipProtocol)
+ && equal(this.ports, that.ports);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .add("IpProtocol", ipProtocol).add("ports", ports);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromFirewallRule(this);
+ }
+
+ public static final class Builder {
+
+ private IpProtocol ipProtocol;
+ private RangeSet<Integer> ports = TreeRangeSet.create();
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall.Rule#getIpProtocol()
+ */
+ public Builder IpProtocol(IpProtocol IpProtocol) {
+ this.ipProtocol = IpProtocol;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall.Rule#getPorts()
+ */
+ public Builder addPort(Integer port) {
+ this.ports.add(singleton(checkNotNull(port, "port")));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall.Rule#getPorts()
+ */
+ public Builder addPortRange(Integer start, Integer end) {
+ checkState(checkNotNull(start, "start") < checkNotNull(end, "end"),
+ "start of range must be lower than end of range");
+ this.ports.add(closed(start, end));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall.Rule#getPorts()
+ */
+ public Builder ports(RangeSet<Integer> ports) {
+ this.ports = TreeRangeSet.create();
+ this.ports.addAll(ports);
+ return this;
+ }
+
+ public Rule build() {
+ return new Rule(ipProtocol, ports);
+ }
+
+ public Builder fromFirewallRule(Rule firewallRule) {
+ return new Builder().IpProtocol(firewallRule.getIpProtocol()).ports(firewallRule.getPorts());
+ }
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Image.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Image.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Image.java
new file mode 100644
index 0000000..424aaa1
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Image.java
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Optional.fromNullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+
+/**
+ * Represents a disk image to use on an instance.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/images"/>
+ */
+@Beta
+public final class Image extends Resource {
+
+ private final String sourceType;
+ private final RawDisk rawDisk;
+ private final Optional<Deprecated> deprecated;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "sourceType",
+ "rawDisk", "deprecated"
+ })
+ protected Image(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ String sourceType, RawDisk rawDisk, Deprecated deprecated) {
+ super(Kind.IMAGE, id, creationTimestamp, selfLink, name, description);
+ this.sourceType = checkNotNull(sourceType, "sourceType of %s", name);
+ // rawDisk may be null for user created private images
+ this.rawDisk = rawDisk; // checkNotNull(rawDisk, "rawDisk of %s", name);
+ this.deprecated = fromNullable(deprecated);
+ }
+
+ /**
+ * @return must be RAW; provided by the client when the disk image is created.
+ */
+ public String getSourceType() {
+ return sourceType;
+ }
+
+ /**
+ * @return the raw disk image parameters.
+ */
+ public RawDisk getRawDisk() {
+ return rawDisk;
+ }
+
+ /**
+ * @return the deprecation information for this image
+ */
+ public Optional<Deprecated> getDeprecated() {
+ return deprecated;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .omitNullValues()
+ .add("sourceType", sourceType)
+ .add("rawDisk", rawDisk)
+ .add("deprecated", deprecated.orNull());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromImage(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private String sourceType;
+ private RawDisk rawDisk;
+ private Deprecated deprecated;
+
+ /**
+ * @see Image#getSourceType()
+ */
+ public Builder sourceType(String sourceType) {
+ this.sourceType = checkNotNull(sourceType, "sourceType");
+ return this;
+ }
+
+ /**
+ * @see Image#getDeprecated()
+ */
+ public Builder deprecated(Deprecated deprecated) {
+ this.deprecated = checkNotNull(deprecated, "deprecated");
+ return this;
+ }
+
+ /**
+ * @see Image#getRawDisk()
+ */
+ public Builder rawDisk(RawDisk rawDisk) {
+ this.rawDisk = checkNotNull(rawDisk);
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Image build() {
+ return new Image(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, sourceType, rawDisk, deprecated);
+ }
+
+ public Builder fromImage(Image in) {
+ return super.fromResource(in)
+ .sourceType(in.getSourceType())
+ .rawDisk(in.getRawDisk())
+ .deprecated(in.getDeprecated().orNull());
+ }
+
+ }
+
+ /**
+ * A raw disk image, usually the base for an image.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/images"/>
+ */
+ public static class RawDisk {
+
+ private final String source;
+ private final String containerType;
+ private final Optional<String> sha1Checksum;
+
+ @ConstructorProperties({
+ "source", "containerType", "sha1Checksum"
+ })
+ private RawDisk(String source, String containerType, String sha1Checksum) {
+ this.source = checkNotNull(source, "source");
+ this.containerType = checkNotNull(containerType, "containerType");
+ this.sha1Checksum = fromNullable(sha1Checksum);
+ }
+
+ /**
+ * @return the full Google Cloud Storage URL where the disk image is stored; provided by the client when the disk
+ * image is created.
+ */
+ public String getSource() {
+ return source;
+ }
+
+ /**
+ * @return the format used to encode and transmit the block device.
+ */
+ public String getContainerType() {
+ return containerType;
+ }
+
+ /**
+ * @return an optional SHA1 checksum of the disk image before unpackaging; provided by the client when the disk
+ * image is created.
+ */
+ public Optional<String> getSha1Checksum() {
+ return sha1Checksum;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(source, containerType, sha1Checksum);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ RawDisk that = RawDisk.class.cast(obj);
+ return equal(this.source, that.source)
+ && equal(this.containerType, that.containerType)
+ && equal(this.sha1Checksum, that.sha1Checksum);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("source", source)
+ .add("containerType", containerType)
+ .add("sha1Checksum", sha1Checksum.orNull());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromImageRawDisk(this);
+ }
+
+ public static class Builder {
+
+ private String source;
+ private String containerType;
+ private String sha1Checksum;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Image.RawDisk#getSource()
+ */
+ public Builder source(String source) {
+ this.source = checkNotNull(source);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Image.RawDisk#getContainerType()
+ */
+ public Builder containerType(String containerType) {
+ this.containerType = checkNotNull(containerType);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Image.RawDisk#getSha1Checksum()
+ */
+ public Builder sha1Checksum(String sha1Checksum) {
+ this.sha1Checksum = sha1Checksum;
+ return this;
+ }
+
+ public RawDisk build() {
+ return new RawDisk(source, containerType, sha1Checksum);
+ }
+
+ public Builder fromImageRawDisk(RawDisk rawDisk) {
+ return new Builder().source(rawDisk.getSource())
+ .containerType(rawDisk.getContainerType())
+ .sha1Checksum(rawDisk.getSha1Checksum().orNull());
+ }
+ }
+ }
+}
[25/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiMockTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiMockTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiMockTest.java
new file mode 100644
index 0000000..c28b1c8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiMockTest.java
@@ -0,0 +1,436 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.FloatingIP;
+import org.jclouds.openstack.neutron.v2.domain.FloatingIPs;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiMockTest;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+
+/**
+ * Tests Floating Api Guice wiring and parsing
+ *
+ */
+@Test
+public class FloatingIPApiMockTest extends BaseNeutronApiMockTest {
+
+ public void testCreateFloatingIP() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/floatingip_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ FloatingIP.CreateFloatingIP createFip = FloatingIP.createBuilder("376da547-b977-4cfe-9cba-275c80debf57")
+ .portId("ce705c24-c1ef-408a-bda3-7bbd946164ab")
+ .build();
+
+ FloatingIP floatingIP = api.create(createFip);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "POST", "/v2.0/floatingips", "/floatingip_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(floatingIP);
+ assertEquals(floatingIP.getRouterId(), "d23abc8d-2991-4a55-ba98-2aaea84cc72f");
+ assertEquals(floatingIP.getTenantId(), "4969c491a3c74ee4af974e6d800c62de");
+ assertEquals(floatingIP.getFloatingNetworkId(), "376da547-b977-4cfe-9cba-275c80debf57");
+ assertEquals(floatingIP.getFixedIpAddress(), "10.0.0.3");
+ assertEquals(floatingIP.getFloatingIpAddress(), "172.24.4.228");
+ assertEquals(floatingIP.getPortId(), "ce705c24-c1ef-408a-bda3-7bbd946164ab");
+ assertEquals(floatingIP.getId(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateFloatingIPFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ FloatingIP.CreateFloatingIP createFip = FloatingIP.createBuilder("376da547-b977-4cfe-9cba-275c80debf57")
+ .portId("ce705c24-c1ef-408a-bda3-7bbd946164ab")
+ .build();
+
+ FloatingIP floatingIP = api.create(createFip);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageFloatingIP() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/floatingip_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ FloatingIPs floatingIPs = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(floatingIPs);
+ assertEquals(floatingIPs.size(), 2);
+ assertEquals(floatingIPs.first().get().getId(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7");
+ assertEquals(floatingIPs.get(1).getId(), "61cea855-49cb-4846-997d-801b70c71bdd");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageFloatingIPFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ FloatingIPs floatingIPs = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(floatingIPs);
+ assertTrue(floatingIPs.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedFloatingIP() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/floatingip_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/floatingip_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<FloatingIP> floatingIPs = api.list().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718");
+
+ /*
+ * Check response
+ */
+ assertNotNull(floatingIPs);
+ assertEquals(floatingIPs.size(), 4);
+ assertEquals(floatingIPs.get(0).getId(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7");
+ assertEquals(floatingIPs.get(3).getId(), "61cea855-49cb-4846-997d-801b70c71bdd2");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedFloatingIPFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<FloatingIP> floatingIPs = api.list().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips");
+
+ /*
+ * Check response
+ */
+ assertNotNull(floatingIPs);
+ assertTrue(floatingIPs.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetFloatingIP() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/floatingip_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ FloatingIP floatingIP = api.get("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips/12345");
+
+ /*
+ * Check response
+ */
+ assertNotNull(floatingIP);
+ assertEquals(floatingIP.getId(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7");
+ assertEquals(floatingIP.getPortId(), "ce705c24-c1ef-408a-bda3-7bbd946164ab");
+ assertEquals(floatingIP.getFloatingIpAddress(), "172.24.4.228");
+ assertEquals(floatingIP.getFixedIpAddress(), "10.0.0.3");
+ assertEquals(floatingIP.getFloatingNetworkId(), "376da547-b977-4cfe-9cba-275c80debf57");
+ assertEquals(floatingIP.getRouterId(), "d23abc8d-2991-4a55-ba98-2aaea84cc72f");
+ assertEquals(floatingIP.getTenantId(), "4969c491a3c74ee4af974e6d800c62de");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetFloatingIPFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ FloatingIP floatingIP = api.get("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/floatingips/12345");
+
+ /*
+ * Check response
+ */
+ assertNull(floatingIP);
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateFloatingIP() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/floatingip_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ FloatingIP.UpdateFloatingIP updateFloatingIP = FloatingIP.updateBuilder()
+ .portId("fc861431-0e6c-4842-a0ed-e2363f9bc3a8")
+ .build();
+
+ FloatingIP floatingIP = api.update("12345", updateFloatingIP);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/floatingips/12345", "/floatingip_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(floatingIP);
+ assertEquals(floatingIP.getPortId(), "fc861431-0e6c-4842-a0ed-e2363f9bc3a8");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateFloatingIPDissociate() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/floatingip_update_dissociate_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ FloatingIP.UpdateFloatingIP updateFloatingIP = FloatingIP.updateBuilder().build();
+
+ FloatingIP floatingIP = api.update("12345", updateFloatingIP);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/floatingips/12345", "/floatingip_update_dissociate_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(floatingIP);
+ assertNull(floatingIP.getPortId());
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateFloatingIPFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ FloatingIP.UpdateFloatingIP updateFloatingIP = FloatingIP.updateBuilder()
+ .portId("fc861431-0e6c-4842-a0ed-e2363f9bc3a8")
+ .build();
+
+ FloatingIP floatingIP = api.update("12345", updateFloatingIP);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/floatingips/12345", "/floatingip_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(floatingIP);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteFloatingIP() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ boolean result = api.delete("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/floatingips/12345");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteFloatingIPFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get();
+
+ boolean result = api.delete("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/floatingips/12345");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiLiveTest.java
new file mode 100644
index 0000000..2a006e8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiLiveTest.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.neutron.v2.domain.ExternalGatewayInfo;
+import org.jclouds.openstack.neutron.v2.domain.Network;
+import org.jclouds.openstack.neutron.v2.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2.domain.Port;
+import org.jclouds.openstack.neutron.v2.domain.Router;
+import org.jclouds.openstack.neutron.v2.domain.RouterInterface;
+import org.jclouds.openstack.neutron.v2.domain.Subnet;
+import org.jclouds.openstack.neutron.v2.features.NetworkApi;
+import org.jclouds.openstack.neutron.v2.features.PortApi;
+import org.jclouds.openstack.neutron.v2.features.SubnetApi;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ * Tests parsing and Guice wiring of RouterApi
+ */
+@Test(groups = "live", testName = "RouterApiLiveTest")
+public class RouterApiLiveTest extends BaseNeutronApiLiveTest {
+
+ public void testCreateUpdateAndDeleteRouter() {
+ for (String region : api.getConfiguredRegions()) {
+ RouterApi routerApi = api.getRouterApi(region).get();
+ NetworkApi networkApi = api.getNetworkApi(region);
+ SubnetApi subnetApi = api.getSubnetApi(region);
+
+ Network network = networkApi.create(
+ Network.createBuilder("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build());
+ assertNotNull(network);
+
+ Subnet subnet = subnetApi.create(Subnet.createBuilder(network.getId(), "192.168.0.0/16").ipVersion(4).build());
+ assertNotNull(subnet);
+
+ Router router = routerApi.create(Router.createBuilder().name("jclouds-router-test")
+ .externalGatewayInfo(ExternalGatewayInfo.builder().networkId(network.getId()).build()).build());
+ assertNotNull(router);
+
+ /* List and Get test */
+ Set<Router> routers = api.getRouterApi(region).get().list().concat().toSet();
+ Router routerList = routers.iterator().next();
+ Router routerGet = api.getRouterApi(region).get().get(routerList.getId());
+
+ assertNotNull(routerGet);
+ assertEquals(routerGet, routerList);
+ /***/
+
+ routerGet = routerApi.get(router.getId());
+
+ assertEquals(routerGet.getName(), router.getName());
+ assertEquals(routerGet.getId(), router.getId());
+ assertEquals(routerGet.getExternalGatewayInfo(), router.getExternalGatewayInfo());
+
+ Router routerUpdate = routerApi.update(router.getId(), Router.updateBuilder().name("jclouds-router-test-rename").build());
+ assertNotNull(routerUpdate);
+ assertEquals(routerUpdate.getName(), "jclouds-router-test-rename");
+
+ routerGet = routerApi.get(router.getId());
+
+ assertEquals(routerGet.getId(), router.getId());
+ assertEquals(routerGet.getName(), "jclouds-router-test-rename");
+
+ assertTrue(routerApi.delete(router.getId()));
+ assertTrue(subnetApi.delete(subnet.getId()));
+ assertTrue(networkApi.delete(network.getId()));
+ }
+ }
+
+ public void testCreateAndDeleteRouterInterfaceForSubnet() {
+ for (String region : api.getConfiguredRegions()) {
+ RouterApi routerApi = api.getRouterApi(region).get();
+ NetworkApi networkApi = api.getNetworkApi(region);
+ SubnetApi subnetApi = api.getSubnetApi(region);
+
+ Network network = networkApi.create(Network.createBuilder("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build());
+ assertNotNull(network);
+
+ Subnet subnet = subnetApi.create(Subnet.createBuilder(network.getId(), "192.168.0.0/16").ipVersion(4).build());
+ assertNotNull(subnet);
+
+ Network network2 = networkApi.create(Network.createBuilder("jclouds-network-test2").external(true).networkType(NetworkType.LOCAL).build());
+ assertNotNull(network2);
+
+ Subnet subnet2 = subnetApi.create(Subnet.createBuilder(network2.getId(), "192.169.0.0/16").ipVersion(4).build());
+ assertNotNull(subnet2);
+
+ Router router = routerApi.create(Router.createBuilder().name("jclouds-router-test").build());
+ assertNotNull(router);
+
+ RouterInterface routerInterface = routerApi.addInterfaceForSubnet(router.getId(), subnet.getId());
+ assertNotNull(routerInterface);
+
+ RouterInterface routerInterface2 = routerApi.addInterfaceForSubnet(router.getId(), subnet2.getId());
+ assertNotNull(routerInterface2);
+
+ assertTrue(routerApi.removeInterfaceForSubnet(router.getId(), subnet.getId()));
+ assertTrue(routerApi.removeInterfaceForSubnet(router.getId(), subnet2.getId()));
+ assertTrue(routerApi.delete(router.getId()));
+ assertTrue(subnetApi.delete(subnet.getId()));
+ assertTrue(networkApi.delete(network.getId()));
+ assertTrue(subnetApi.delete(subnet2.getId()));
+ assertTrue(networkApi.delete(network2.getId()));
+ }
+ }
+
+ public void testCreateAndDeleteRouterInterfaceForPort() {
+ for (String region : api.getConfiguredRegions()) {
+ RouterApi routerApi = api.getRouterApi(region).get();
+ NetworkApi networkApi = api.getNetworkApi(region);
+ SubnetApi subnetApi = api.getSubnetApi(region);
+ PortApi portApi = api.getPortApi(region);
+
+ Network network = networkApi.create(Network.createBuilder("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build());
+ assertNotNull(network);
+
+ Subnet subnet = subnetApi.create(Subnet.createBuilder(network.getId(), "192.168.0.0/16").ipVersion(4).build());
+ assertNotNull(subnet);
+
+ Network network2 = networkApi.create(Network.createBuilder("jclouds-network-test2").external(true).networkType(NetworkType.LOCAL).build());
+ assertNotNull(network2);
+
+ Subnet subnet2 = subnetApi.create(Subnet.createBuilder(network2.getId(), "192.169.0.0/16").ipVersion(4).build());
+ assertNotNull(subnet2);
+
+ Port port = portApi.create(Port.createBuilder(network.getId()).build());
+ assertNotNull(port);
+
+ Port port2 = portApi.create(Port.createBuilder(network2.getId()).build());
+ assertNotNull(port2);
+
+ Router router = routerApi.create(Router.createBuilder().name("jclouds-router-test").build());
+ assertNotNull(router);
+
+ RouterInterface routerInterface = routerApi.addInterfaceForPort(router.getId(), port.getId());
+ assertNotNull(routerInterface);
+
+ RouterInterface routerInterface2 = routerApi.addInterfaceForPort(router.getId(), port2.getId());
+ assertNotNull(routerInterface2);
+
+ assertTrue(routerApi.removeInterfaceForPort(router.getId(), port.getId()));
+ assertTrue(routerApi.removeInterfaceForPort(router.getId(), port2.getId()));
+ assertTrue(routerApi.delete(router.getId()));
+ assertTrue(subnetApi.delete(subnet.getId()));
+ assertTrue(networkApi.delete(network.getId()));
+ assertTrue(subnetApi.delete(subnet2.getId()));
+ assertTrue(networkApi.delete(network2.getId()));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiMockTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiMockTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiMockTest.java
new file mode 100644
index 0000000..00232f8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/RouterApiMockTest.java
@@ -0,0 +1,631 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.ExternalGatewayInfo;
+import org.jclouds.openstack.neutron.v2.domain.NetworkStatus;
+import org.jclouds.openstack.neutron.v2.domain.Router;
+import org.jclouds.openstack.neutron.v2.domain.RouterInterface;
+import org.jclouds.openstack.neutron.v2.domain.Routers;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiMockTest;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+
+/**
+ * Tests NetworkApi Guice wiring and parsing
+ *
+ */
+@Test
+public class RouterApiMockTest extends BaseNeutronApiMockTest {
+
+ public void testCreateRouter() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/router_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ Router.CreateRouter createRouter = Router.createBuilder().name("another_router").adminStateUp(Boolean.TRUE)
+ .externalGatewayInfo(ExternalGatewayInfo.builder().networkId("8ca37218-28ff-41cb-9b10-039601ea7e6b").build())
+ .build();
+
+ Router router = api.create(createRouter);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "POST", "/v2.0/routers", "/router_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(router);
+ assertEquals(router.getName(), "another_router");
+ assertEquals(router.getExternalGatewayInfo().getNetworkId(), "8ca37218-28ff-41cb-9b10-039601ea7e6b");
+ assertEquals(router.getStatus(), NetworkStatus.ACTIVE);
+ assertEquals(router.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(router.getId(), "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e");
+ assertEquals(router.getTenantId(), "6b96ff0cb17a4b859e1e575d221683d3");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateRouterFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ Router.CreateRouter createRouter = Router.createBuilder().name("another_router").adminStateUp(Boolean.TRUE)
+ .externalGatewayInfo(ExternalGatewayInfo.builder().networkId("8ca37218-28ff-41cb-9b10-039601ea7e6b").build())
+ .build();
+
+ api.create(createRouter);
+ fail("Should have failed with not found exception");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageRouter() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/router_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ Routers routers = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/routers?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(routers);
+ assertEquals(routers.size(), 2);
+ assertEquals(routers.first().get().getId(), "a9254bdb-2613-4a13-ac4c-adc581fba50d");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageRouterFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ Routers routers = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/routers?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(routers);
+ assertTrue(routers.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedRouter() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/router_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/router_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Router> routers = api.list().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/routers");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/routers?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718");
+
+ /*
+ * Check response
+ */
+ assertNotNull(routers);
+ assertEquals(routers.size(), 4);
+ assertEquals(routers.get(0).getId(), "a9254bdb-2613-4a13-ac4c-adc581fba50d");
+ assertEquals(routers.get(3).getId(), "a9254bdb-2613-4a13-ac4c-adc581fba50d_4");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedRouterFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Router> routers = api.list().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/routers");
+
+ /*
+ * Check response
+ */
+ assertNotNull(routers);
+ assertTrue(routers.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetRouter() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/router_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ Router router = api.get("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/routers/12345");
+
+ /*
+ * Check response
+ */
+ assertNotNull(router);
+ assertEquals(router.getName(), "router1");
+ assertEquals(router.getExternalGatewayInfo().getNetworkId(), "3c5bcddd-6af9-4e6b-9c3e-c153e521cab8");
+ assertEquals(router.getStatus(), NetworkStatus.ACTIVE);
+ assertEquals(router.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(router.getId(), "a9254bdb-2613-4a13-ac4c-adc581fba50d");
+ assertEquals(router.getTenantId(), "33a40233088643acb66ff6eb0ebea679");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetRouterFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ Router router = api.get("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/routers/12345");
+
+ /*
+ * Check response
+ */
+ assertNull(router);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateRouter() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/router_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ Router.UpdateRouter updateRouter = Router.updateBuilder()
+ .externalGatewayInfo(
+ ExternalGatewayInfo.builder().networkId("8ca37218-28ff-41cb-9b10-039601ea7e6b").build())
+ .build();
+
+ Router router = api.update("12345", updateRouter);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345", "/router_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(router);
+ assertEquals(router.getName(), "another_router");
+ assertEquals(router.getExternalGatewayInfo().getNetworkId(), "8ca37218-28ff-41cb-9b10-039601ea7e6b");
+ assertEquals(router.getStatus(), NetworkStatus.ACTIVE);
+ assertEquals(router.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(router.getId(), "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e");
+ assertEquals(router.getTenantId(), "6b96ff0cb17a4b859e1e575d221683d3");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateRouterFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ Router.UpdateRouter updateRouter = Router.updateBuilder()
+ .externalGatewayInfo(
+ ExternalGatewayInfo.builder().networkId("8ca37218-28ff-41cb-9b10-039601ea7e6b").build())
+ .build();
+
+ Router router = api.update("12345", updateRouter);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345", "/router_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(router);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteRouter() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ boolean result = api.delete("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/routers/12345");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteRouterFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ boolean result = api.delete("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/routers/12345");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testAddRouterInterfaceForSubnet() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/router_add_interface_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ RouterInterface routerInterface = api.addInterfaceForSubnet("12345", "a2f1f29d-571b-4533-907f-5803ab96ead1");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/add_router_interface", "/router_add_interface_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(routerInterface);
+ assertEquals(routerInterface.getSubnetId(), "a2f1f29d-571b-4533-907f-5803ab96ead1");
+ assertEquals(routerInterface.getPortId(), "3a44f4e5-1694-493a-a1fb-393881c673a4");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testAddRouterInterfaceForSubnetFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ RouterInterface routerInterface = api.addInterfaceForSubnet("12345", "a2f1f29d-571b-4533-907f-5803ab96ead1");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/add_router_interface", "/router_add_interface_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(routerInterface);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testAddRouterInterfaceForPort() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/router_add_interface_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ RouterInterface routerInterface = api.addInterfaceForPort("12345", "portid");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/add_router_interface", "/router_add_interface_port_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(routerInterface);
+ assertEquals(routerInterface.getSubnetId(), "a2f1f29d-571b-4533-907f-5803ab96ead1");
+ assertEquals(routerInterface.getPortId(), "3a44f4e5-1694-493a-a1fb-393881c673a4");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testAddRouterInterfaceForPortFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ RouterInterface routerInterface = api.addInterfaceForPort("12345", "portid");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/add_router_interface", "/router_add_interface_port_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(routerInterface);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testRemoveRouterInterfaceForSubnet() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ boolean result = api.removeInterfaceForSubnet("12345", "a2f1f29d-571b-4533-907f-5803ab96ead1");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/remove_router_interface", "/router_remove_interface_subnet_request.json");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testRemoveRouterInterfaceForSubnetFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ boolean result = api.removeInterfaceForSubnet("12345", "a2f1f29d-571b-4533-907f-5803ab96ead1");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/remove_router_interface", "/router_remove_interface_subnet_request.json");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testRemoveRouterInterfaceForPort() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ boolean result = api.removeInterfaceForPort("12345", "portid");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/remove_router_interface", "/router_remove_interface_port_request.json");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testRemoveRouterInterfaceForPortFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ RouterApi api = neutronApi.getRouterApi("RegionOne").get();
+
+ boolean result = api.removeInterfaceForPort("12345", "portid");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/routers/12345/remove_router_interface", "/router_remove_interface_port_request.json");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/SecurityGroupApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/SecurityGroupApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/SecurityGroupApiLiveTest.java
new file mode 100644
index 0000000..a7ef1a6
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/SecurityGroupApiLiveTest.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.openstack.neutron.v2.domain.Rule;
+import org.jclouds.openstack.neutron.v2.domain.RuleDirection;
+import org.jclouds.openstack.neutron.v2.domain.RuleEthertype;
+import org.jclouds.openstack.neutron.v2.domain.RuleProtocol;
+import org.jclouds.openstack.neutron.v2.domain.SecurityGroup;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ * Tests parsing and Guice wiring of RouterApi
+ */
+@Test(groups = "live", testName = "SecurityGroupApiLiveTest")
+public class SecurityGroupApiLiveTest extends BaseNeutronApiLiveTest {
+
+ /**
+ * Smoke test for the Security Group extension for Neutron
+ */
+ public void testCreateUpdateAndDeleteSecurityGroup() {
+ for (String region : api.getConfiguredRegions()) {
+ SecurityGroupApi sgApi = null;
+ Rule rule = null;
+ SecurityGroup securityGroup = null;
+
+ try {
+ sgApi = api.getSecurityGroupApi(region).get();
+
+ securityGroup = sgApi.create(
+ SecurityGroup.createBuilder().name("jclouds-test").description("jclouds test security group")
+ .build());
+ assertNotNull(securityGroup);
+
+ rule = sgApi.create(
+ Rule.createBuilder(RuleDirection.EGRESS, securityGroup.getId())
+ .ethertype(RuleEthertype.IPV6)
+ .portRangeMax(90)
+ .portRangeMin(80)
+ .protocol(RuleProtocol.TCP)
+ .build());
+
+ assertNotNull(rule);
+
+ // Refresh
+ securityGroup = sgApi.getSecurityGroup(securityGroup.getId());
+
+ assertEquals(securityGroup.getName(), "jclouds-test");
+ assertEquals(securityGroup.getDescription(), "jclouds test security group");
+
+ assertEquals(securityGroup.getRules().size(), 3);
+
+ Rule newSecGroupRule = null;
+
+ for (Rule sgr : securityGroup.getRules()) {
+ if (sgr.getId().equals(rule.getId())) {
+ newSecGroupRule = sgr;
+ break;
+ }
+ }
+ assertNotNull(newSecGroupRule, "Did not find the new rule in the group.");
+
+ assertEquals(rule, newSecGroupRule);
+
+ assertEquals(rule.getEthertype(), RuleEthertype.IPV6);
+ assertEquals(rule.getProtocol(), RuleProtocol.TCP);
+ assertEquals(rule.getPortRangeMax().intValue(), 90);
+ assertEquals(rule.getPortRangeMin().intValue(), 80);
+ assertEquals(rule.getDirection(), RuleDirection.EGRESS);
+ } finally {
+ try {
+ assertTrue(sgApi.deleteRule(rule.getId()));
+ } finally {
+ assertTrue(sgApi.deleteSecurityGroup(securityGroup.getId()));
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/SecurityGroupApiMockTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/SecurityGroupApiMockTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/SecurityGroupApiMockTest.java
new file mode 100644
index 0000000..dfe6a80
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/SecurityGroupApiMockTest.java
@@ -0,0 +1,659 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.Rule;
+import org.jclouds.openstack.neutron.v2.domain.RuleDirection;
+import org.jclouds.openstack.neutron.v2.domain.RuleEthertype;
+import org.jclouds.openstack.neutron.v2.domain.RuleProtocol;
+import org.jclouds.openstack.neutron.v2.domain.Rules;
+import org.jclouds.openstack.neutron.v2.domain.SecurityGroup;
+import org.jclouds.openstack.neutron.v2.domain.SecurityGroups;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiMockTest;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+
+/**
+ * Tests NetworkApi Guice wiring and parsing
+ *
+ */
+@Test
+public class SecurityGroupApiMockTest extends BaseNeutronApiMockTest {
+
+ public void testCreateSecurityGroup() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/security_group_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ SecurityGroup.CreateSecurityGroup createSecurityGroup = SecurityGroup.createBuilder().name("new-webservers")
+ .description("security group for webservers")
+ .build();
+
+ SecurityGroup securityGroup = api.create(createSecurityGroup);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "POST", "/v2.0/security-groups", "/security_group_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(securityGroup);
+ assertEquals(securityGroup.getId(), "2076db17-a522-4506-91de-c6dd8e837028");
+ assertEquals(securityGroup.getTenantId(), "e4f50856753b4dc6afee5fa6b9b6c550");
+ assertEquals(securityGroup.getName(), "new-webservers");
+ assertEquals(securityGroup.getDescription(), "security group for webservers");
+
+ Rule sgr0 = securityGroup.getRules().get(0);
+ Rule sgr1 = securityGroup.getRules().get(1);
+
+ assertEquals(sgr0.getId(), "38ce2d8e-e8f1-48bd-83c2-d33cb9f50c3d");
+ assertEquals(sgr1.getId(), "565b9502-12de-4ffd-91e9-68885cff6ae1");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateSecurityGroupFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ SecurityGroup.CreateSecurityGroup createSecurityGroup = SecurityGroup.createBuilder().name("new-webservers")
+ .description("security group for webservers")
+ .build();
+
+ SecurityGroup securityGroup = api.create(createSecurityGroup);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateSecurityGroupRule() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/security_group_rule_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ Rule.CreateRule createSecurityGroupRule = Rule.createBuilder(
+ RuleDirection.INGRESS, "a7734e61-b545-452d-a3cd-0189cbd9747a")
+ .portRangeMin(80)
+ .portRangeMax(80)
+ .ethertype(RuleEthertype.IPV4)
+ .protocol(RuleProtocol.TCP)
+ .remoteGroupId("85cc3048-abc3-43cc-89b3-377341426ac5")
+ .build();
+
+ Rule rule = api.create(createSecurityGroupRule);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "POST", "/v2.0/security-group-rules", "/security_group_rule_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(rule);
+ assertEquals(rule.getId(), "2bc0accf-312e-429a-956e-e4407625eb62");
+ assertEquals(rule.getTenantId(), "e4f50856753b4dc6afee5fa6b9b6c550");
+ assertEquals(rule.getDirection(), RuleDirection.INGRESS);
+ assertEquals(rule.getPortRangeMax().intValue(), 80);
+ assertEquals(rule.getPortRangeMin().intValue(), 80);
+ assertEquals(rule.getEthertype(), RuleEthertype.IPV4);
+ assertEquals(rule.getProtocol(), RuleProtocol.TCP);
+ assertEquals(rule.getRemoteGroupId(), "85cc3048-abc3-43cc-89b3-377341426ac5");
+ assertEquals(rule.getSecurityGroupId(), "a7734e61-b545-452d-a3cd-0189cbd9747a");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateSecurityGroupRuleFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ Rule.CreateRule createSecurityGroupRule = Rule.createBuilder(
+ RuleDirection.INGRESS, "a7734e61-b545-452d-a3cd-0189cbd9747a")
+ .portRangeMin(80)
+ .portRangeMax(80)
+ .ethertype(RuleEthertype.IPV4)
+ .protocol(RuleProtocol.TCP)
+ .remoteGroupId("85cc3048-abc3-43cc-89b3-377341426ac5")
+ .build();
+
+ Rule rule = api.create(createSecurityGroupRule);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageSecurityGroup() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/security_group_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ SecurityGroups securityGroups = api.listSecurityGroups(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-groups?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(securityGroups);
+ assertEquals(securityGroups.size(), 2);
+ // Ensures the full collection is parsed and ordering is preserved.
+ assertEquals(securityGroups.first().get().getId(), "85cc3048-abc3-43cc-89b3-377341426ac5");
+ assertEquals(securityGroups.get(1).getId(), "85cc3048-abc3-43cc-89b3-377341426ac52");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageSecurityGroupFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ SecurityGroups securityGroups = api.listSecurityGroups(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-groups?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(securityGroups);
+ assertTrue(securityGroups.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageSecurityGroupRule() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/security_group_rule_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ Rules rules = api.listRules(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-group-rules?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(rules);
+ assertEquals(rules.size(), 4);
+ // Ensures the full collection is parsed and ordering is preserved.
+ assertEquals(rules.first().get().getId(), "3c0e45ff-adaf-4124-b083-bf390e5482ff");
+ assertEquals(rules.get(3).getId(), "f7d45c89-008e-4bab-88ad-d6811724c51c");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageSecurityGroupRuleFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ Rules rules = api.listRules(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-group-rules?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(rules);
+ assertTrue(rules.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedSecurityGroups() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/security_group_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/security_group_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<SecurityGroup> securityGroups = api.listSecurityGroups().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-groups");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-groups?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718");
+
+ /*
+ * Check response
+ */
+ assertNotNull(securityGroups);
+ assertEquals(securityGroups.size(), 4);
+ // Ensures ordering is preserved and both pages are parsed.
+ assertEquals(securityGroups.get(0).getId(), "85cc3048-abc3-43cc-89b3-377341426ac5");
+ assertEquals(securityGroups.get(3).getId(), "85cc3048-abc3-43cc-89b3-377341426ac524");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedSecurityGroupsFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<SecurityGroup> securityGroups = api.listSecurityGroups().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-groups");
+
+ /*
+ * Check response
+ */
+ assertNotNull(securityGroups);
+ assertTrue(securityGroups.isEmpty());
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedSecurityGroupRules() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/security_group_rule_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/security_group_rule_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Rule> rules = api.listRules().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-group-rules");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-group-rules?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718");
+
+ /*
+ * Check response
+ */
+ assertNotNull(rules);
+ assertEquals(rules.size(), 8);
+ // Ensures both pages are tested and ordering is preserved.
+ assertEquals(rules.get(0).getId(), "3c0e45ff-adaf-4124-b083-bf390e5482ff");
+ assertEquals(rules.get(7).getId(), "f7d45c89-008e-4bab-88ad-d6811724c51c2");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedSecurityGroupRulesFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Rule> rules = api.listRules().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-group-rules");
+
+ /*
+ * Check response
+ */
+ assertNotNull(rules);
+ assertTrue(rules.isEmpty());
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetSecurityGroup() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/security_group_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ SecurityGroup securityGroup = api.getSecurityGroup("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-groups/12345");
+
+ /*
+ * Check response
+ */
+ assertNotNull(securityGroup);
+ assertEquals(securityGroup.getName(), "default");
+ assertEquals(securityGroup.getDescription(), "default");
+ assertEquals(securityGroup.getId(), "85cc3048-abc3-43cc-89b3-377341426ac5");
+ assertEquals(securityGroup.getTenantId(), "e4f50856753b4dc6afee5fa6b9b6c550");
+ Rule sgr = securityGroup.getRules().get(0);
+ assertEquals(sgr.getId(), "3c0e45ff-adaf-4124-b083-bf390e5482ff");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetSecurityGroupFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ SecurityGroup securityGroup = api.getSecurityGroup("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-groups/12345");
+
+ /*
+ * Check response
+ */
+ assertNull(securityGroup);
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetSecurityGroupRule() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/security_group_rule_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ Rule rule = api.get("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-group-rules/12345");
+
+ /*
+ * Check response
+ */
+ assertNotNull(rule);
+ assertEquals(rule.getDirection(), RuleDirection.EGRESS);
+ assertEquals(rule.getEthertype(), RuleEthertype.IPV6);
+ assertEquals(rule.getId(), "3c0e45ff-adaf-4124-b083-bf390e5482ff");
+ assertEquals(rule.getTenantId(), "e4f50856753b4dc6afee5fa6b9b6c550");
+ assertEquals(rule.getSecurityGroupId(), "85cc3048-abc3-43cc-89b3-377341426ac5");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetSecurityGroupRuleFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ Rule rule = api.get("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/security-group-rules/12345");
+
+ /*
+ * Check response
+ */
+ assertNull(rule);
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteSecurityGroup() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ boolean result = api.deleteSecurityGroup("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/security-groups/12345");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteSecurityGroupFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ boolean result = api.deleteSecurityGroup("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/security-groups/12345");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteSecurityGroupRule() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ boolean result = api.deleteRule("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/security-group-rules/12345");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteSecurityGroupRuleFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne").get();
+
+ boolean result = api.deleteRule("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/security-group-rules/12345");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+}
[10/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java
new file mode 100644
index 0000000..8f4aa29
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
+import static org.jclouds.vcloud.VCloudMediaType.VAPPTEMPLATE_XML;
+import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.ovf.Envelope;
+import org.jclouds.ovf.xml.EnvelopeHandler;
+import org.jclouds.predicates.validators.DnsNameValidator;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.ParamValidators;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.PayloadParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.vcloud.binders.BindCaptureVAppParamsToXmlPayload;
+import org.jclouds.vcloud.binders.BindCloneVAppTemplateParamsToXmlPayload;
+import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
+import org.jclouds.vcloud.binders.OrgNameCatalogNameVAppTemplateNameToEndpoint;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+import org.jclouds.vcloud.options.CaptureVAppOptions;
+import org.jclouds.vcloud.options.CloneVAppTemplateOptions;
+import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
+import org.jclouds.vcloud.xml.TaskHandler;
+import org.jclouds.vcloud.xml.VAppHandler;
+import org.jclouds.vcloud.xml.VAppTemplateHandler;
+
+
+/**
+ * Provides access to VApp Template functionality in vCloud
+ * <p/>
+ *
+ * @see <a href="http://communities.vmware.com/community/developer/forums/vcloudapi" />
+ */
+@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
+public interface VAppTemplateApi {
+ /**
+ * returns the vapp template corresponding to a catalog item in the catalog associated with the
+ * specified name. Note that the org and catalog parameters can be null to choose default.
+ *
+ * @param orgName
+ * organization name, or null for the default
+ * @param catalogName
+ * catalog name, or null for the default
+ * @param itemName
+ * item you wish to lookup
+ *
+ * @throws NoSuchElementException
+ * if you specified an org, catalog, or catalog item name that isn't present
+ */
+ @GET
+ @Consumes(VAPPTEMPLATE_XML)
+ @XMLResponseParser(VAppTemplateHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(OrgNameCatalogNameVAppTemplateNameToEndpoint.class)
+ VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable @PayloadParam("orgName") String orgName,
+ @Nullable @PayloadParam("catalogName") String catalogName,
+ @PayloadParam("itemName") String itemName);
+
+ /**
+ */
+ @POST
+ @Path("/action/instantiateVAppTemplate")
+ @Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
+ @Consumes(VAPP_XML)
+ @XMLResponseParser(VAppHandler.class)
+ @MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class)
+ VApp createVAppInVDCByInstantiatingTemplate(
+ @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, @EndpointParam URI vdc,
+ @PayloadParam("template") URI template, InstantiateVAppTemplateOptions... options);
+
+ @POST
+ @Path("/action/cloneVAppTemplate")
+ @Produces("application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml")
+ @Consumes(TASK_XML)
+ @XMLResponseParser(TaskHandler.class)
+ @MapBinder(BindCloneVAppTemplateParamsToXmlPayload.class)
+ Task copyVAppTemplateToVDCAndName(@PayloadParam("Source") URI sourceVAppTemplate,
+ @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
+ CloneVAppTemplateOptions... options);
+
+ @POST
+ @Path("/action/cloneVAppTemplate")
+ @Produces("application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml")
+ @Consumes(TASK_XML)
+ @XMLResponseParser(TaskHandler.class)
+ @PayloadParams(keys = "IsSourceDelete", values = "true")
+ @MapBinder(BindCloneVAppTemplateParamsToXmlPayload.class)
+ Task moveVAppTemplateToVDCAndRename(@PayloadParam("Source") URI toClone,
+ @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
+ CloneVAppTemplateOptions... options);
+
+ /**
+ * The captureVApp request creates a vApp template from an instantiated vApp. <h4>Note</h4>
+ * Before it can be captured, a vApp must be undeployed
+ *
+ * @param targetVdcHref
+ * @param sourceVAppHref
+ * @param newTemplateName
+ * @param options
+ * @return template in progress
+ */
+ @POST
+ @Path("/action/captureVApp")
+ @Produces("application/vnd.vmware.vcloud.captureVAppParams+xml")
+ @Consumes(VAPPTEMPLATE_XML)
+ @XMLResponseParser(VAppTemplateHandler.class)
+ @MapBinder(BindCaptureVAppParamsToXmlPayload.class)
+ VAppTemplate captureVAppAsTemplateInVDC(@PayloadParam("vApp") URI toCapture,
+ @PayloadParam("templateName") @ParamValidators(DnsNameValidator.class) String templateName,
+ @EndpointParam URI vdc, CaptureVAppOptions... options);
+
+ @GET
+ @Consumes(VAPPTEMPLATE_XML)
+ @XMLResponseParser(VAppTemplateHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ VAppTemplate getVAppTemplate(@EndpointParam URI vAppTemplate);
+
+ @GET
+ @Consumes(MediaType.TEXT_XML)
+ @Path("/ovf")
+ @XMLResponseParser(EnvelopeHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Envelope getOvfEnvelopeForVAppTemplate(@EndpointParam URI href);
+
+ /**
+ * delete a vAppTemplate, vApp, or media image. You cannot delete an object if it is in use. Any
+ * object that is being copied or moved is in use. Other criteria that determine whether an
+ * object is in use depend on the object type.
+ * <ul>
+ * <li>A vApptemplate is in use if it is being instantiated. After instantiation is complete, the
+ * template is no longer in use.</li>
+ * <li>A vApp is in use if it is deployed.</li>
+ * <li>A media image is in use if it is inserted in a Vm.</li>
+ * </ul>
+ *
+ * @param id
+ * href of the vApp
+ * @return task of the operation in progress
+ */
+ @DELETE
+ @Consumes(TASK_XML)
+ @Fallback(Fallbacks.VoidOnNotFoundOr404.class)
+ @XMLResponseParser(TaskHandler.class)
+ Task deleteVAppTemplate(@EndpointParam URI href);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java
new file mode 100644
index 0000000..7b02798
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.vcloud.binders.OrgNameAndVDCNameToEndpoint;
+import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+import org.jclouds.vcloud.xml.VDCHandler;
+
+
+/**
+ * Provides access to VDC functionality in vCloud
+ * <p/>
+ */
+@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
+public interface VDCApi {
+ @GET
+ @XMLResponseParser(VDCHandler.class)
+ @Consumes(VDC_XML)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ VDC getVDC(@EndpointParam URI vdc);
+
+ /**
+ * returns the VDC in the organization associated with the specified name. Note that both
+ * parameters can be null to choose default.
+ *
+ * @param orgName
+ * organization name, or null for the default
+ * @param vdcName
+ * catalog name, or null for the default
+ * @throws NoSuchElementException
+ * if you specified an org or vdc name that isn't present
+ */
+ @GET
+ @XMLResponseParser(VDCHandler.class)
+ @Consumes(VDC_XML)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(OrgNameAndVDCNameToEndpoint.class)
+ VDC findVDCInOrgNamed(@Nullable @PayloadParam("orgName") String orgName,
+ @Nullable @PayloadParam("vdcName") String vdcName);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java
new file mode 100644
index 0000000..40b7e43
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java
@@ -0,0 +1,326 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.vcloud.VCloudMediaType.DEPLOYVAPPPARAMS_XML;
+import static org.jclouds.vcloud.VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML;
+import static org.jclouds.vcloud.VCloudMediaType.NETWORKCONNECTIONSECTION_XML;
+import static org.jclouds.vcloud.VCloudMediaType.RASDITEM_XML;
+import static org.jclouds.vcloud.VCloudMediaType.RASDITEMLIST_XML;
+import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
+import static org.jclouds.vcloud.VCloudMediaType.UNDEPLOYVAPPPARAMS_XML;
+import static org.jclouds.vcloud.VCloudMediaType.VM_XML;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.rest.annotations.*;
+import org.jclouds.vcloud.binders.*;
+import org.jclouds.vcloud.domain.*;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+import org.jclouds.vcloud.xml.TaskHandler;
+import org.jclouds.vcloud.xml.VmHandler;
+
+
+/**
+ * Provides access to VM functionality in vCloud
+ * <p/>
+ *
+ * @author Adrian Cole
+ */
+@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
+public interface VmApi {
+
+ @GET
+ @Consumes(VM_XML)
+ @XMLResponseParser(VmHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Vm getVm(@EndpointParam URI href);
+
+ /**
+ * To deploy a vApp, the client makes a request to its action/deploy URL. Deploying a vApp
+ * automatically deploys all of the virtual machines it contains. To deploy a virtual machine,
+ * the client makes a request to its action/deploy URL.
+ * <p/>
+ * Deploying a Vm implicitly deploys the parent vApp if that vApp is not already deployed.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(DEPLOYVAPPPARAMS_XML)
+ @Path("/action/deploy")
+ @MapBinder(BindDeployVAppParamsToXmlPayload.class)
+ @XMLResponseParser(TaskHandler.class)
+ Task deployVm(@EndpointParam URI href);
+
+ /**
+ * like {@link #deploy(URI)}, except deploy transitions to power on state
+ *
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(DEPLOYVAPPPARAMS_XML)
+ @Path("/action/deploy")
+ @MapBinder(BindDeployVAppParamsToXmlPayload.class)
+ @PayloadParams(keys = "powerOn", values = "true")
+ @XMLResponseParser(TaskHandler.class)
+ Task deployAndPowerOnVm(@EndpointParam URI href);
+
+ /**
+ * Undeploying a vApp powers off or suspends any running virtual machines it contains, then frees
+ * the resources reserved for the vApp and sets the vApp’s deploy attribute to a value of false
+ * to indicate that it is not deployed.
+ * <p/>
+ * Undeploying a virtual machine powers off or suspends the virtual machine, then frees the
+ * resources reserved for it and sets the its deploy attribute to a value of false to indicate
+ * that it is not deployed. This operation has no effect on the containing vApp.
+ * <h4>NOTE</h4>
+ * Using this method will simply power off the vms. In order to save their state, use
+ * {@link #undeployAndSaveStateOf}
+ *
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(UNDEPLOYVAPPPARAMS_XML)
+ @Path("/action/undeploy")
+ @MapBinder(BindUndeployVAppParamsToXmlPayload.class)
+ @XMLResponseParser(TaskHandler.class)
+ Task undeployVm(@EndpointParam URI href);
+
+ /**
+ * like {@link #undeploy(URI)}, where the undeployed virtual machines are suspended and their
+ * suspend state saved
+ *
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(UNDEPLOYVAPPPARAMS_XML)
+ @Path("/action/undeploy")
+ @MapBinder(BindUndeployVAppParamsToXmlPayload.class)
+ @PayloadParams(keys = "saveState", values = "true")
+ @XMLResponseParser(TaskHandler.class)
+ Task undeployAndSaveStateOfVm(@EndpointParam URI href);
+
+ /**
+ * A powerOn request to a vApp URL powers on all of the virtual machines in the vApp, as
+ * specified in the vApp’s StartupSection field.
+ * <p/>
+ * A powerOn request to a virtual machine URL powers on the specified virtual machine and forces
+ * deployment of the parent vApp.
+ * <p/>
+ * <h4>NOTE</h4> A powerOn request to a vApp or virtual machine that is undeployed forces
+ * deployment.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Path("/power/action/powerOn")
+ @XMLResponseParser(TaskHandler.class)
+ Task powerOnVm(@EndpointParam URI href);
+
+ /**
+ * A powerOff request to a vApp URL powers off all of the virtual machines in the vApp, as
+ * specified in its StartupSection field.
+ * <p/>
+ * A powerOff request to a virtual machine URL powers off the specified virtual machine.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Path("/power/action/powerOff")
+ @XMLResponseParser(TaskHandler.class)
+ Task powerOffVm(@EndpointParam URI href);
+
+ /**
+ * Detach disk
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(DiskAttachOrDetachParams.DISK_XML)
+ @Path("/disk/action/detach")
+ @MapBinder(BindDiskAttachOrDetachParamsToXmlPayload.class)
+ @XMLResponseParser(TaskHandler.class)
+ Task detachDisk(
+ @EndpointParam URI href,
+ @PayloadParam("params") DiskAttachOrDetachParams diskAttachOrDetachParams);
+
+ /**
+ * Attach disk
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces("application/vnd.vmware.vcloud.diskAttachOrDetachParams+xml")
+ @Path("/disk/action/attach")
+ @MapBinder(BindDiskAttachOrDetachParamsToXmlPayload.class)
+ @XMLResponseParser(TaskHandler.class)
+ Task attachDisk(
+ @EndpointParam URI href,
+ @PayloadParam("params") DiskAttachOrDetachParams diskAttachOrDetachParams);
+
+ /**
+ * A shutdown request to a vApp URL shuts down all of the virtual machines in the vApp, as
+ * specified in its StartupSection field.
+ * <p/>
+ * A shutdown request to a virtual machine URL shuts down the specified virtual machine.
+ * <p/>
+ * <h4>NOTE</h4Because this request sends a signal to the guest OS, the vCloud API cannot track
+ * the progress or verify the result of the requested operation. Hence, void is returned
+ */
+ @POST
+ @Path("/power/action/shutdown")
+ void shutdownVm(@EndpointParam URI href);
+
+ /**
+ * A reset request to a vApp URL resets all of the virtual machines in the vApp, as specified in
+ * its StartupSection field.
+ * <p/>
+ * A reset request to a virtual machine URL resets the specified virtual machine.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Path("/power/action/reset")
+ @XMLResponseParser(TaskHandler.class)
+ Task resetVm(@EndpointParam URI href);
+
+ /**
+ * A reboot request to a vApp URL reboots all of the virtual machines in the vApp, as specified
+ * in its StartupSection field.
+ * <p/>
+ * A reboot request to a virtual machine URL reboots the specified virtual machine.
+ * <p/>
+ * <h4>NOTE</h4> Because this request sends a signal to the guest OS, the vCloud API cannot track
+ * the progress or verify the result of the requested operation. Hence, void is returned
+ */
+ @POST
+ @Path("/power/action/reboot")
+ void rebootVm(@EndpointParam URI href);
+
+ /**
+ * A suspend request to a vApp URL suspends all of the virtual machines in the vApp, as specified
+ * in its StartupSection field.
+ * <p/>
+ * A suspend request to a virtual machine URL suspends the specified virtual machine.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Path("/power/action/suspend")
+ @XMLResponseParser(TaskHandler.class)
+ Task suspendVm(@EndpointParam URI href);
+
+ /**
+ * Get a Screen Thumbnail for a Virtual Machine
+ *
+ * @param href
+ * to snapshot
+ */
+ @GET
+ @Path("/screen")
+ @Consumes("image/png")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ InputStream getScreenThumbnailForVm(@EndpointParam URI vm);
+
+ /**
+ * Modify the Guest Customization Section of a Virtual Machine
+ *
+ * @param href
+ * uri to modify
+ * @param updated
+ * guestCustomizationSection
+ * @return task in progress
+ */
+ @PUT
+ @Consumes(TASK_XML)
+ @Produces(GUESTCUSTOMIZATIONSECTION_XML)
+ @Path("/guestCustomizationSection")
+ @XMLResponseParser(TaskHandler.class)
+ Task updateGuestCustomizationOfVm(
+ @BinderParam(BindGuestCustomizationSectionToXmlPayload.class) GuestCustomizationSection guestCustomizationSection,
+ @EndpointParam URI href);
+
+ /**
+ * Modify the Network Connection Section of a Virtual Machine
+ *
+ * @param href
+ * uri to modify
+ * @param updated
+ * networkConnectionSection
+ * @return task in progress
+ */
+ @PUT
+ @Consumes(TASK_XML)
+ @Produces(NETWORKCONNECTIONSECTION_XML)
+ @Path("/networkConnectionSection")
+ @XMLResponseParser(TaskHandler.class)
+ Task updateNetworkConnectionOfVm(
+ @BinderParam(BindNetworkConnectionSectionToXmlPayload.class) NetworkConnectionSection networkConnectionSection,
+ @EndpointParam URI href);
+
+ /**
+ * update the cpuCount of an existing VM
+ *
+ * @param href
+ * to update
+ * @param cpuCount
+ * count to change the primary cpu to
+ */
+ @PUT
+ @Consumes(TASK_XML)
+ @Produces(RASDITEM_XML)
+ @Path("/virtualHardwareSection/cpu")
+ @XMLResponseParser(TaskHandler.class)
+ Task updateCPUCountOfVm(@BinderParam(BindCPUCountToXmlPayload.class) int cpuCount,
+ @EndpointParam URI href);
+
+ /**
+ * update the memoryInMB of an existing VM
+ *
+ * @param href
+ * to update
+ * @param memoryInMB
+ * memory in MB to assign to the VM
+ */
+ @PUT
+ @Consumes(TASK_XML)
+ @Produces(RASDITEM_XML)
+ @Path("/virtualHardwareSection/memory")
+ @XMLResponseParser(TaskHandler.class)
+ Task updateMemoryMBOfVm(@BinderParam(BindMemoryToXmlPayload.class) int memoryInMB,
+ @EndpointParam URI href);
+
+ /**
+ * update the networkCards of an existing VM
+ *
+ * @param href
+ * to update
+ * @param networkCards
+ * new list of Network Interface Cards (NICs)
+ */
+ @PUT
+ @Consumes(TASK_XML)
+ @Produces(RASDITEMLIST_XML)
+ @Path("/virtualHardwareSection/networkCards")
+ @MapBinder(BindVCloudNetworkAdapterToXmlPayload.class)
+ @XMLResponseParser(TaskHandler.class)
+ Task updateNetworkCardsOfVm(@PayloadParam("params") Iterable<VCloudNetworkAdapter> networkCards,
+ @EndpointParam URI href);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java
new file mode 100644
index 0000000..1d3ba5d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.filters;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpException;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpRequestFilter;
+import org.jclouds.rest.annotations.ApiVersion;
+import org.jclouds.vcloud.VCloudToken;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.net.HttpHeaders;
+
+/**
+ * Adds the VCloud Token to the request as a cookie
+ */
+@Singleton
+public class AddVCloudAuthorizationAndCookieToRequest implements HttpRequestFilter {
+ private Supplier<String> vcloudTokenProvider;
+ private final String apiVersion;
+
+ @Inject
+ public AddVCloudAuthorizationAndCookieToRequest(@VCloudToken Supplier<String> authTokenProvider, @ApiVersion final String apiVersion) {
+ this.vcloudTokenProvider = authTokenProvider;
+ this.apiVersion = apiVersion;
+ }
+
+ @Override
+ public HttpRequest filter(HttpRequest request) throws HttpException {
+ String token = vcloudTokenProvider.get();
+ String acceptType = request.getFirstHeaderOrNull(HttpHeaders.ACCEPT) == null
+ ? "application/*+xml"
+ : request.getFirstHeaderOrNull(HttpHeaders.ACCEPT);
+ String version = ";version=" + apiVersion;
+ String acceptHeader = acceptType + version;
+ return request.toBuilder()
+ .replaceHeaders(ImmutableMultimap.of(HttpHeaders.ACCEPT,
+ acceptHeader, "x-vcloud-authorization", token,
+ HttpHeaders.COOKIE, "vcloud-token=" +
+ token)).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java
new file mode 100644
index 0000000..db18f9e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.transform;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.ReferenceType;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+
+@Singleton
+public class CatalogItemsInCatalog implements Function<Catalog, Iterable<CatalogItem>> {
+ @Resource
+ public Logger logger = Logger.NULL;
+
+ private final VCloudApi aclient;
+
+ @Inject
+ CatalogItemsInCatalog(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ @Override
+ public Iterable<CatalogItem> apply(Catalog from) {
+ return transform(filter(from.values(), new Predicate<ReferenceType>() {
+ public boolean apply(ReferenceType input) {
+ return input.getType().equals(VCloudMediaType.CATALOGITEM_XML);
+ }
+ }), new Function<ReferenceType, CatalogItem>() {
+ public CatalogItem apply(ReferenceType from) {
+ return aclient.getCatalogApi().getCatalogItem(from.getHref());
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java
new file mode 100644
index 0000000..f6ccf7d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.Org;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+@Singleton
+public class CatalogItemsInOrg implements Function<Org, Iterable<CatalogItem>> {
+
+ private final Function<Org, Iterable<Catalog>> allCatalogsInOrg;
+
+ private final Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog;
+
+ @Inject
+ CatalogItemsInOrg(Function<Org, Iterable<Catalog>> allCatalogsInOrg,
+ Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog) {
+ this.allCatalogsInOrg = allCatalogsInOrg;
+ this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
+ }
+
+ @Override
+ public Iterable<CatalogItem> apply(Org from) {
+ return Iterables.concat(Iterables.transform(allCatalogsInOrg.apply(from),
+ new Function<Catalog, Iterable<? extends CatalogItem>>() {
+ @Override
+ public Iterable<? extends CatalogItem> apply(Catalog from) {
+ return allCatalogItemsInCatalog.apply(from);
+ }
+
+ }));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java
new file mode 100644
index 0000000..917f651
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import static com.google.common.collect.Iterables.transform;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableSet;
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+
+import com.google.common.base.Function;
+
+import java.util.Collection;
+
+@Singleton
+public class CatalogsInOrg implements Function<Org, Iterable<Catalog>> {
+ @Resource
+ public Logger logger = Logger.NULL;
+
+ private final VCloudApi aclient;
+
+ @Inject
+ CatalogsInOrg(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ @Override
+ public Iterable<Catalog> apply(final Org org) {
+ Collection<ReferenceType> filtered = Collections2.filter(
+ org.getCatalogs().values(), new Predicate<ReferenceType>() {
+ @Override
+ public boolean apply(ReferenceType type) {
+ if (type == null) {
+ return false;
+ }
+ return !ImmutableSet.of("add", "remove").contains(type.getRelationship());
+ }
+ });
+
+ return transform(filtered, new Function<ReferenceType, Catalog>() {
+ public Catalog apply(ReferenceType from) {
+ return aclient.getCatalogApi().getCatalog(from.getHref());
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java
new file mode 100644
index 0000000..eeecb8d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.collect.Iterables.get;
+
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.ovf.Network;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.base.Function;
+
+@Singleton
+public class DefaultNetworkNameInTemplate implements Function<VAppTemplate, String> {
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ @Override
+ public String apply(VAppTemplate vAppTemplate) {
+ checkArgument(vAppTemplate != null, "vAppTemplate was null!");
+ Set<Network> networks = vAppTemplate.getNetworkSection().getNetworks();
+ checkArgument(networks.size() > 0, "no networks found in vAppTemplate %s", vAppTemplate);
+ if (networks.size() > 1)
+ logger.warn("multiple networks found for %s, choosing first from: %s", vAppTemplate.getName(), networks);
+ return get(networks, 0).getName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java
new file mode 100644
index 0000000..25c18a1
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import static com.google.common.collect.Iterables.transform;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.network.OrgNetwork;
+
+import com.google.common.base.Function;
+
+@Singleton
+public class NetworksInOrg implements Function<Org, Iterable<OrgNetwork>> {
+ @Resource
+ public Logger logger = Logger.NULL;
+
+ private final VCloudApi aclient;
+
+ @Inject
+ NetworksInOrg(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ @Override
+ public Iterable<OrgNetwork> apply(final Org org) {
+ return transform(org.getNetworks().values(), new Function<ReferenceType, OrgNetwork>() {
+ public OrgNetwork apply(ReferenceType from) {
+ return aclient.getNetworkApi().getNetwork(from.getHref());
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java
new file mode 100644
index 0000000..bc762a5
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.Org;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+
+@Singleton
+public class OrgNameToEndpoint implements Function<Object, URI> {
+ private final Supplier<Map<String, ReferenceType>> orgNameToEndpointSupplier;
+ private final Supplier<ReferenceType> defaultOrg;
+
+ @Inject
+ public OrgNameToEndpoint(@Org Supplier<Map<String, ReferenceType>> orgNameToEndpointSupplier,
+ @Org Supplier<ReferenceType> defaultOrg) {
+ this.orgNameToEndpointSupplier = orgNameToEndpointSupplier;
+ this.defaultOrg = defaultOrg;
+ }
+
+ public URI apply(Object from) {
+ try {
+ Map<String, ReferenceType> orgNameToEndpoint = orgNameToEndpointSupplier.get();
+ return from == null ? defaultOrg.get().getHref() : orgNameToEndpoint.get(from).getHref();
+ } catch (NullPointerException e) {
+ throw new NoSuchElementException("org " + from + " not found in " + orgNameToEndpointSupplier.get().keySet());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java
new file mode 100644
index 0000000..1d3fc4a
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.TasksList;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+
+@Singleton
+public class OrgNameToTasksListEndpoint implements Function<Object, URI> {
+ private final Supplier<Map<String, Org>> orgMap;
+ private final Supplier<ReferenceType> defaultTasksList;
+
+ @Inject
+ public OrgNameToTasksListEndpoint(Supplier<Map<String, Org>> orgMap,
+ @TasksList Supplier<ReferenceType> defaultTasksList) {
+ this.orgMap = orgMap;
+ this.defaultTasksList = defaultTasksList;
+ }
+
+ public URI apply(Object from) {
+ Object org = from;
+ if (org == null)
+ return defaultTasksList.get().getHref();
+ try {
+ return checkNotNull(orgMap.get().get(org)).getTasksList().getHref();
+ } catch (NullPointerException e) {
+ throw new NoSuchElementException(org + " not found in " + orgMap.get());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java
new file mode 100644
index 0000000..72be2f6
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import static com.google.common.collect.Iterables.transform;
+
+import java.net.URI;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.domain.Org;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
+
+@Singleton
+public class OrgsForLocations implements Function<Iterable<Location>, Iterable<Org>> {
+ @Resource
+ public Logger logger = Logger.NULL;
+ private final VCloudApi aclient;
+
+ @Inject
+ OrgsForLocations(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ /**
+ * Zones are assignable, but we want regions. so we look for zones, whose
+ * parent is region. then, we use a set to extract the unique set.
+ */
+ @Override
+ public Iterable<Org> apply(Iterable<Location> from) {
+ FluentIterable<URI> uris = FluentIterable.from(from).filter(new Predicate<Location>() {
+ public boolean apply(Location input) {
+ return input.getScope() == LocationScope.ZONE;
+ }
+ }).transform(new Function<Location, URI>() {
+ public URI apply(Location from) {
+ return URI.create(from.getParent().getId());
+ }
+ });
+ return transform(uris, new Function<URI, Org>() {
+ public Org apply(URI from) {
+ return aclient.getOrgApi().getOrg(from);
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java
new file mode 100644
index 0000000..ce3cd9e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import static com.google.common.collect.Iterables.transform;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.domain.Org;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+
+@Singleton
+public class OrgsForNames implements Function<Iterable<String>, Iterable<Org>> {
+ @Resource
+ public Logger logger = Logger.NULL;
+ private final VCloudApi aclient;
+
+ @Inject
+ OrgsForNames(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ @Override
+ public Iterable<Org> apply(Iterable<String> from) {
+ return Iterables.filter(transform(from, new Function<String, Org>() {
+ public Org apply(String from) {
+ return aclient.getOrgApi().findOrgNamed(from);
+ }
+ }), Predicates.notNull());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java
new file mode 100644
index 0000000..d9900fd
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.http.HttpUtils.releasePayload;
+
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.inject.Inject;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.vcloud.VCloudToken;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VCloudSession;
+import org.jclouds.vcloud.endpoints.Org;
+import org.jclouds.vcloud.xml.OrgListHandler;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+import com.google.common.net.HttpHeaders;
+
+/**
+ * This parses {@link VCloudSession} from HTTP headers.
+ */
+@Singleton
+public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCloudSession> {
+ static final Pattern pattern = Pattern.compile("(vcloud-token)=?([^;]+)(;.*)?");
+
+ private final ParseSax.Factory factory;
+ private final Provider<OrgListHandler> orgHandlerProvider;
+
+ @Inject
+ private ParseLoginResponseFromHeaders(Factory factory, Provider<OrgListHandler> orgHandlerProvider) {
+ this.factory = factory;
+ this.orgHandlerProvider = orgHandlerProvider;
+ }
+
+ /**
+ * parses the http response headers to create a new {@link VCloudSession} object.
+ */
+ public VCloudSession apply(HttpResponse from) {
+ try {
+ final String token = parseTokenFromHeaders(from);
+ final Map<String, ReferenceType> org = factory.create(orgHandlerProvider.get()).parse(
+ checkNotNull(from.getPayload().getInput(), "no payload in http response to login request %s", from));
+
+ return new VCloudSession() {
+ @VCloudToken
+ public String getVCloudToken() {
+ return token;
+ }
+
+ @Org
+ public Map<String, ReferenceType> getOrgs() {
+ return org;
+ }
+ };
+ } finally {
+ releasePayload(from);
+ }
+ }
+
+ public String parseTokenFromHeaders(HttpResponse from) {
+ String cookieHeader = from.getFirstHeaderOrNull("x-vcloud-authorization");
+ if (cookieHeader != null) {
+ Matcher matcher = pattern.matcher(cookieHeader);
+ return matcher.find() ? matcher.group(2) : cookieHeader;
+ } else {
+ try {
+ cookieHeader = Iterables.find(from.getHeaders().get(HttpHeaders.SET_COOKIE), Predicates.contains(pattern));
+ Matcher matcher = pattern.matcher(cookieHeader);
+ matcher.find();
+ return matcher.group(2);
+ } catch (NoSuchElementException e) {
+ throw new HttpResponseException(String.format("Header %s or %s must be present", "x-vcloud-authorization",
+ HttpHeaders.SET_COOKIE), null, from);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java
new file mode 100644
index 0000000..d3a6a9b
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.transform;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
+@Singleton
+public class VAppTemplatesForCatalogItems implements Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ private Logger logger = Logger.NULL;
+ private final VCloudApi aclient;
+
+ @Inject
+ VAppTemplatesForCatalogItems(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ @Override
+ public Iterable<VAppTemplate> apply(Iterable<CatalogItem> from) {
+ return filter(transform(filter(from, new Predicate<CatalogItem>() {
+ public boolean apply(CatalogItem input) {
+ return input.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML);
+ }
+ }), new Function<CatalogItem, VAppTemplate>() {
+ public VAppTemplate apply(CatalogItem from) {
+ return aclient.getVAppTemplateApi().getVAppTemplate(from.getEntity().getHref());
+ }
+ }), Predicates.notNull());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java
new file mode 100644
index 0000000..992c2af
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import static com.google.common.base.Predicates.and;
+import static com.google.common.base.Predicates.notNull;
+import static com.google.common.collect.Iterables.filter;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableSet;
+
+@Singleton
+public class VAppTemplatesInOrg implements Function<Org, Iterable<VAppTemplate>> {
+
+ private final Function<Org, Iterable<CatalogItem>> allCatalogItemsInOrg;
+ private final Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> vAppTemplatesForCatalogItems;
+
+ @Inject
+ VAppTemplatesInOrg(Function<Org, Iterable<CatalogItem>> allCatalogItemsInOrg,
+ Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> vAppTemplatesForCatalogItems) {
+ this.allCatalogItemsInOrg = allCatalogItemsInOrg;
+ this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems;
+ }
+
+ @Override
+ public Iterable<VAppTemplate> apply(Org from) {
+ Iterable<CatalogItem> catalogs = allCatalogItemsInOrg.apply(from);
+ Iterable<VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs);
+ return filter(vAppTemplates, and(notNull(), new Predicate<VAppTemplate>() {
+ @Override
+ public boolean apply(VAppTemplate input) {
+ if (input == null)
+ return false;
+ return ImmutableSet.of(Status.RESOLVED, Status.OFF).contains(input.getStatus());
+ }
+ }));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java
new file mode 100644
index 0000000..4457233
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import static com.google.common.collect.Iterables.transform;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VDC;
+
+import com.google.common.base.Function;
+
+@Singleton
+public class VDCsInOrg implements Function<Org, Iterable<VDC>> {
+ @Resource
+ public Logger logger = Logger.NULL;
+
+ private final VCloudApi aclient;
+
+ @Inject
+ VDCsInOrg(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ @Override
+ public Iterable<VDC> apply(final Org org) {
+ return transform(org.getVDCs().values(), new Function<ReferenceType, VDC>() {
+ public VDC apply(ReferenceType from) {
+ return aclient.getVDCApi().getVDC(from.getHref());
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java
new file mode 100644
index 0000000..2c9f96f
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.handlers;
+
+import static org.jclouds.http.HttpUtils.releasePayload;
+
+import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.logging.Logger;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.jclouds.util.Strings2;
+import org.jclouds.vcloud.VCloudResponseException;
+import org.jclouds.vcloud.domain.VCloudError;
+import org.jclouds.vcloud.domain.VCloudError.MinorCode;
+import org.jclouds.vcloud.util.VCloudUtils;
+
+/**
+ * This will parse and set an appropriate exception on the command object.
+ */
+@Singleton
+public class ParseVCloudErrorFromHttpResponse implements HttpErrorHandler {
+ @Resource
+ protected Logger logger = Logger.NULL;
+ public static final Pattern RESOURCE_PATTERN = Pattern.compile(".*/v[^/]+/([^/]+)/([0-9]+)");
+ private final VCloudUtils utils;
+
+ @Inject
+ public ParseVCloudErrorFromHttpResponse(VCloudUtils utils) {
+ this.utils = utils;
+ }
+
+ public void handleError(HttpCommand command, HttpResponse response) {
+ HttpRequest request = command.getCurrentRequest();
+ Exception exception = new HttpResponseException(command, response);
+ try {
+ VCloudError error = null;
+ String message = null;
+ if (response.getPayload() != null) {
+ try {
+ error = utils.parseErrorFromContent(request, response);
+ if (error != null) {
+ message = error.getMessage();
+ exception = new VCloudResponseException(command, response, error);
+ } else {
+ message = Strings2.toStringAndClose(response.getPayload().openStream());
+ exception = message != null ? new HttpResponseException(command, response, message) : exception;
+ }
+ } catch (IOException e) {
+ } finally {
+ response.getPayload().release();
+ }
+ }
+ message = message != null ? message : String.format("%s -> %s", request.getRequestLine(), response
+ .getStatusLine());
+
+ switch (response.getStatusCode()) {
+ case 400:
+ if (error != null
+ && ((error.getMinorErrorCode() != null && error.getMinorErrorCode() == MinorCode.BUSY_ENTITY)
+ || (error.getMessage() != null && error.getMessage().indexOf("is not running") != -1)))
+ exception = new IllegalStateException(message, exception);
+ else
+ exception = new IllegalArgumentException(message, exception);
+ break;
+ case 401:
+ case 403:
+ if (error != null
+ && ((error.getMinorErrorCode() != null && error.getMinorErrorCode() == MinorCode.ACCESS_TO_RESOURCE_IS_FORBIDDEN)
+ || (error.getMessage() != null && error.getMessage().indexOf("No access to entity") != -1)))
+ exception = new ResourceNotFoundException(message, exception);
+ else
+ exception = new AuthorizationException(exception.getMessage(), exception);
+ break;
+ case 404:
+ if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
+ String path = command.getCurrentRequest().getEndpoint().getPath();
+ Matcher matcher = RESOURCE_PATTERN.matcher(path);
+ if (matcher.find()) {
+ message = String.format("%s %s not found", matcher.group(1), matcher.group(2));
+ } else {
+ message = path;
+ }
+ exception = new ResourceNotFoundException(message);
+ }
+ break;
+ }
+ } finally {
+ releasePayload(response);
+ command.setException(exception);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java
new file mode 100644
index 0000000..a333874
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.vcloud.http.filters;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import org.jclouds.domain.Credentials;
+import org.jclouds.http.HttpException;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpRequest.Builder;
+import org.jclouds.http.HttpRequestFilter;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.location.Provider;
+import org.jclouds.rest.annotations.ApiVersion;
+
+@Singleton
+public class VCloudBasicAuthentication implements HttpRequestFilter
+{
+ private final Supplier<Credentials> creds;
+ private final String apiVersion;
+
+ @Inject
+ public VCloudBasicAuthentication(@Provider Supplier<Credentials> creds, @ApiVersion String apiVersion)
+ {
+ this.creds = ((Supplier)Preconditions.checkNotNull(creds, "creds"));
+ this.apiVersion = apiVersion;
+ }
+
+ public HttpRequest filter(HttpRequest request) throws HttpException
+ {
+ Credentials currentCreds = (Credentials)Preconditions.checkNotNull(this.creds.get(), "credential supplier returned null");
+ String acceptType = request.getFirstHeaderOrNull("Accept") == null ? "application/*+xml" : request.getFirstHeaderOrNull("Accept");
+
+ String version = ";version=" + this.apiVersion;
+ String acceptHeader = acceptType + version;
+
+ request = ((HttpRequest.Builder)request.toBuilder().replaceHeader("Accept", new String[] { acceptHeader })).build();
+
+ return ((HttpRequest.Builder)request.toBuilder().replaceHeader("Authorization", new String[] { BasicAuthentication.basic(currentCreds.identity, currentCreds.credential) })).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java
new file mode 100644
index 0000000..3769fda
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.vcloud.http.filters;
+
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpException;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpRequestFilter;
+
+@Singleton
+public class VCloudSupportedVersions implements HttpRequestFilter
+{
+ @SuppressWarnings("rawtypes")
+public HttpRequest filter(HttpRequest request)
+ throws HttpException
+ {
+ return ((HttpRequest.Builder)request.toBuilder().replaceHeader("Accept", new String[] { "*/*" })).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java
new file mode 100644
index 0000000..74a7be4
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.internal;
+
+import java.io.Closeable;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.Endpoint;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.VCloudSession;
+import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
+import org.jclouds.vcloud.http.filters.VCloudBasicAuthentication;
+
+@Endpoint(org.jclouds.vcloud.endpoints.VCloudLogin.class)
+@RequestFilters(VCloudBasicAuthentication.class)
+public interface VCloudLoginApi extends Closeable {
+
+ /**
+ * This request returns a token to use in subsequent requests. After 30 minutes of inactivity,
+ * the token expires and you have to request a new token with this call.
+ */
+ @POST
+ @ResponseParser(ParseLoginResponseFromHeaders.class)
+ @Consumes({VCloudMediaType.SESSION_XML,VCloudMediaType.ORGLIST_XML})
+ VCloudSession login();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java
new file mode 100644
index 0000000..f004f97
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.loaders;
+
+import java.net.URI;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.ovf.Envelope;
+import org.jclouds.vcloud.VCloudApi;
+
+import com.google.common.cache.CacheLoader;
+
+@Singleton
+public class OVFLoader extends CacheLoader<URI, Envelope> {
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ private final VCloudApi client;
+
+ @Inject
+ OVFLoader(VCloudApi client) {
+ this.client = client;
+ }
+
+ @Override
+ public Envelope load(URI template) {
+ return client.getVAppTemplateApi().getOvfEnvelopeForVAppTemplate(template);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java
new file mode 100644
index 0000000..ee707db
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.loaders;
+
+import java.net.URI;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.cache.CacheLoader;
+
+@Singleton
+public class VAppTemplateLoader extends CacheLoader<URI, VAppTemplate> {
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ private final VCloudApi client;
+
+ @Inject
+ VAppTemplateLoader(VCloudApi client) {
+ this.client = client;
+ }
+
+ @Override
+ public VAppTemplate load(URI template) {
+ return client.getVAppTemplateApi().getVAppTemplate(template);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java
new file mode 100644
index 0000000..38fb340
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.location;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.find;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.location.suppliers.ImplicitLocationSupplier;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.VDC;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+
+@Singleton
+public class DefaultVDC implements ImplicitLocationSupplier {
+ private final Supplier<Set<? extends Location>> locationsSupplier;
+ private final IsDefaultVDC isDefaultVDC;
+
+ @Inject
+ DefaultVDC(@Memoized Supplier<Set<? extends Location>> locationsSupplier, IsDefaultVDC isDefaultVDC) {
+ this.locationsSupplier = checkNotNull(locationsSupplier, "locationsSupplierSupplier");
+ this.isDefaultVDC = checkNotNull(isDefaultVDC, "isDefaultVDC");
+ }
+
+ @Override
+ public Location get() {
+ return find(locationsSupplier.get(), isDefaultVDC);
+ }
+
+
+ @Singleton
+ public static class IsDefaultVDC implements Predicate<Location> {
+ private final Supplier<ReferenceType> defaultVDCSupplier;
+
+ @Inject
+ IsDefaultVDC(@VDC Supplier<ReferenceType> defaultVDCSupplier) {
+ this.defaultVDCSupplier = checkNotNull(defaultVDCSupplier, "defaultVDCSupplier");
+ }
+
+ @Override
+ public boolean apply(Location input) {
+ ReferenceType defaultVDC = defaultVDCSupplier.get();
+ return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString());
+ }
+
+ @Override
+ public String toString() {
+ return "isDefaultVDC()";
+ }
+ }
+}
[03/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-carrenza-with-default-namespace.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-carrenza-with-default-namespace.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-carrenza-with-default-namespace.xml
new file mode 100644
index 0000000..88fec20
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-carrenza-with-default-namespace.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CatalogItem xmlns="http://www.vmware.com/vcloud/v1" name="ubuntu10.10x64" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://myvdc.carrenza.net/api/v1.0/schema/master.xsd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml" href="https://myvdc.carrenza.net/api/v1.0/catalog/5d2c147a-d26d-487a-9a05-577ee175186b"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3"/>
+ <Link rel="remove" href="https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3"/>
+ <Description> </Description>
+ <Entity type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="ubuntu10.10x64" href="https://myvdc.carrenza.net/api/v1.0/vAppTemplate/vappTemplate-123766ea-2b55-482c-8adf-735ab1952834"/>
+</CatalogItem>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-carrenza-with-vcloud-namespace.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-carrenza-with-vcloud-namespace.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-carrenza-with-vcloud-namespace.xml
new file mode 100644
index 0000000..917c143
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-carrenza-with-vcloud-namespace.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<vcloud:CatalogItem xmlns:vcloud="http://www.vmware.com/vcloud/v1" name="ubuntu10.10x64" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://myvdc.carrenza.net/api/v1.0/schema/master.xsd">
+ <vcloud:Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml" href="https://myvdc.carrenza.net/api/v1.0/catalog/5d2c147a-d26d-487a-9a05-577ee175186b"/>
+ <vcloud:Link rel="edit" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3"/>
+ <vcloud:Link rel="remove" href="https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3"/>
+ <vcloud:Description> </vcloud:Description>
+ <vcloud:Entity type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="ubuntu10.10x64" href="https://myvdc.carrenza.net/api/v1.0/vAppTemplate/vappTemplate-123766ea-2b55-482c-8adf-735ab1952834"/>
+</vcloud:CatalogItem>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-hosting.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-hosting.xml
new file mode 100644
index 0000000..6f88d04
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-hosting.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CatalogItem
+ href="https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"
+ name="Windows 2008 Datacenter 64 Bit"
+ xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 catalogItem.xsd"
+ xmlns="http://www.vmware.com/vcloud/v0.8"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <Description>Windows 2008 Datacenter 64 Bit</Description>
+ <Entity href="https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2"
+ type="application/vnd.vmware.vcloud.vAppTemplate+xml"
+ name="Windows 2008 Datacenter 64 Bit" />
+ <Property key="Foo">Bar</Property>
+ <Property key="Hello">World</Property>
+</CatalogItem>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-terremark.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-terremark.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-terremark.xml
new file mode 100644
index 0000000..feb8b82
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem-terremark.xml
@@ -0,0 +1,16 @@
+<CatalogItem
+ href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22"
+ type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Web Server 2008 R2 (64-bit)"
+ xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Link rel="down"
+ href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22/options/compute"
+ type="application/xml" name="Compute Options" />
+ <Link rel="down"
+ href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22/options/customization"
+ type="application/xml" name="Customization Options" />
+ <Entity
+ href="https://services.vcloudexpress.terremark.com/api/v0.8/vAppTemplate/22"
+ type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="Windows Web Server 2008 R2 (64-bit)" />
+ <Property key="LicensingCost">0</Property>
+</CatalogItem>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem1.0-vcd15.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem1.0-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem1.0-vcd15.xml
new file mode 100644
index 0000000..b344071
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalogItem1.0-vcd15.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CatalogItem xmlns="http://www.vmware.com/vcloud/v1" name="UbuntuServer-x64-2GB" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://zone.myvcloud.com/api/v1.0/catalogItem/ceb369f7-1d07-4e32-9dbd-ebb5aa6ca55c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 https://zone.myvcloud.com/api/v1.0/schema/master.xsd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml" href="https://zone.myvcloud.com/api/v1.0/catalog/3155f393-1e1d-4572-8c9c-d76f72ddb658"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://zone.myvcloud.com/api/v1.0/catalogItem/ceb369f7-1d07-4e32-9dbd-ebb5aa6ca55c"/>
+ <Link rel="remove" href="https://zone.myvcloud.com/api/v1.0/catalogItem/ceb369f7-1d07-4e32-9dbd-ebb5aa6ca55c"/>
+ <Description> </Description>
+ <Entity type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="UbuntuServer-x64-2GB" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728"/>
+</CatalogItem>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVApp-default.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVApp-default.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVApp-default.xml
new file mode 100644
index 0000000..0e8ba8d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVApp-default.xml
@@ -0,0 +1 @@
+<CloneVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="false" name="my-vapp" powerOn="false" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/4181" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVApp.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVApp.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVApp.xml
new file mode 100644
index 0000000..b6cd733
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVApp.xml
@@ -0,0 +1 @@
+<CloneVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="true" name="new-linux-server" powerOn="true" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vApp</Description><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/201" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVAppTemplate-default.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVAppTemplate-default.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVAppTemplate-default.xml
new file mode 100644
index 0000000..00b11e7
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVAppTemplate-default.xml
@@ -0,0 +1 @@
+<CloneVAppTemplateParams xmlns="http://vcloud.safesecureweb.com/ns/vcloud.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-vapptemplate" xsi:schemaLocation="http://vcloud.safesecureweb.com/ns/vcloud.xsd http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Source href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181" type="application/vnd.vmware.vcloud.vAppTemplate+xml"/></CloneVAppTemplateParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVAppTemplate.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVAppTemplate.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVAppTemplate.xml
new file mode 100644
index 0000000..e612b98
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/copyVAppTemplate.xml
@@ -0,0 +1 @@
+<CloneVAppTemplateParams xmlns="http://vcloud.safesecureweb.com/ns/vcloud.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="new-linux-server" xsi:schemaLocation="http://vcloud.safesecureweb.com/ns/vcloud.xsd http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vAppTemplate</Description><Source href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201" type="application/vnd.vmware.vcloud.vAppTemplate+xml"/></CloneVAppTemplateParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/cpuItem.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/cpuItem.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/cpuItem.xml
new file mode 100644
index 0000000..d5e437b
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/cpuItem.xml
@@ -0,0 +1 @@
+<Item xmlns="http://www.vmware.com/vcloud/v1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"><rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits><rasd:Description>Number of Virtual CPUs</rasd:Description><rasd:ElementName>2 virtual CPU(s)</rasd:ElementName><rasd:InstanceID>4</rasd:InstanceID><rasd:ResourceType>3</rasd:ResourceType><rasd:VirtualQuantity>2</rasd:VirtualQuantity><rasd:Weight>0</rasd:Weight></Item>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/guestCustomization.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/guestCustomization.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/guestCustomization.xml
new file mode 100644
index 0000000..644720f
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/guestCustomization.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<GuestCustomizationSection
+ type="application/vnd.vmware.vcloud.guestCustomizationSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/"
+ ovf:required="false">
+ <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
+ <Enabled>true</Enabled>
+ <ChangeSid>false</ChangeSid>
+ <VirtualMachineId>2087535248</VirtualMachineId>
+ <JoinDomainEnabled>false</JoinDomainEnabled>
+ <UseOrgSettings>false</UseOrgSettings>
+ <AdminPasswordEnabled>true</AdminPasswordEnabled>
+ <AdminPasswordAuto>true</AdminPasswordAuto>
+ <ResetPasswordRequired>false</ResetPasswordRequired>
+ <CustomizationScript>cat > /root/foo.txt<<EOF
+I '"love"' {asc|!}*&
+EOF
+</CustomizationScript>
+ <ComputerName>RHEL5</ComputerName>
+ <Link rel="edit"
+ type="application/vnd.vmware.vcloud.guestCustomizationSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/" />
+</GuestCustomizationSection>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/guestCustomizationSection.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/guestCustomizationSection.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/guestCustomizationSection.xml
new file mode 100644
index 0000000..2fadb53
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/guestCustomizationSection.xml
@@ -0,0 +1,3 @@
+<GuestCustomizationSection xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" href="http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection" ovf:required="false" type="application/vnd.vmware.vcloud.guestCustomizationSection+xml"><ovf:Info>Specifies Guest OS Customization Settings</ovf:Info><CustomizationScript>cat > /tmp/foo.txt<<EOF
+I love candy
+EOF</CustomizationScript></GuestCustomizationSection>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiatedvapp.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiatedvapp.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiatedvapp.xml
new file mode 100644
index 0000000..9d98c2d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiatedvapp.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VApp xmlns="http://www.vmware.com/vcloud/v1" deployed="false" status="0" name="vcds-a47" type="application/vnd.vmware.vcloud.vApp+xml" href="https://zone01.bluelock.com/api/v1.0/vApp/vapp-dba20113-1a4a-4ec9-a5ad-52dc69ee0825" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://zone01.bluelock.com/api/v1.0/schema/master.xsd">
+ <Link rel="down" type="application/vnd.vmware.vcloud.controlAccess+xml" href="https://zone01.bluelock.com/api/v1.0/vApp/vapp-dba20113-1a4a-4ec9-a5ad-52dc69ee0825/controlAccess/"/>
+ <Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml" href="https://zone01.bluelock.com/api/v1.0/vdc/9db4ee77-33e7-4b83-96be-eee9925eaa9b"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.owner+xml" href="https://zone01.bluelock.com/api/v1.0/vApp/vapp-dba20113-1a4a-4ec9-a5ad-52dc69ee0825/owner"/>
+ <Description>OS-Ubuntu10.04_x64</Description>
+ <Tasks>
+ <Task status="running" startTime="2012-07-11T20:37:49.521-04:00" operation="Creating Virtual Application vcds-a47(dba20113-1a4a-4ec9-a5ad-52dc69ee0825)" expiryTime="2012-08-25T20:37:49.521-04:00" type="application/vnd.vmware.vcloud.task+xml" href="https://zone01.bluelock.com/api/v1.0/task/fee48ffc-8ba2-452e-a57f-ada0cd2eda31">
+ <Link rel="task:cancel" href="https://zone01.bluelock.com/api/v1.0/task/fee48ffc-8ba2-452e-a57f-ada0cd2eda31/action/cancel"/>
+ <Owner type="application/vnd.vmware.vcloud.vApp+xml" name="vcds-a47" href="https://zone01.bluelock.com/api/v1.0/vApp/vapp-dba20113-1a4a-4ec9-a5ad-52dc69ee0825"/>
+ </Task>
+ </Tasks>
+</VApp>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiationparams-description.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiationparams-description.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiationparams-description.xml
new file mode 100644
index 0000000..6728290
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiationparams-description.xml
@@ -0,0 +1 @@
+<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" deploy="true" name="my-vapp" powerOn="true"><Description>my foo</Description><InstantiationParams><NetworkConfigSection><ovf:Info>Configuration parameters for logical networks</ovf:Info><NetworkConfig networkName="vAppNet-vApp Internal"><Configuration><ParentNetwork href="https://vcenterprise.bluelock.com/api/v1.0/network/1990"/><FenceMode>bridged</FenceMode></Configuration></NetworkConfig></NetworkConfigSection></InstantiationParams><Source href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"/><AllEULAsAccepted>true</AllEULAsAccepted></InstantiateVAppTemplateParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiationparams-network.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiationparams-network.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiationparams-network.xml
new file mode 100644
index 0000000..e3bcb58
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiationparams-network.xml
@@ -0,0 +1 @@
+<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" deploy="true" name="my-vapp" powerOn="true"><InstantiationParams><NetworkConfigSection><ovf:Info>Configuration parameters for logical networks</ovf:Info><NetworkConfig networkName="aloha"><Configuration><ParentNetwork href="https://vcenterprise.bluelock.com/api/v1.0/network/1991"/><FenceMode>natRouted</FenceMode></Configuration></NetworkConfig></NetworkConfigSection></InstantiationParams><Source href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"/><AllEULAsAccepted>true</AllEULAsAccepted></InstantiateVAppTemplateParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiationparams.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiationparams.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiationparams.xml
new file mode 100644
index 0000000..9df9961
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/instantiationparams.xml
@@ -0,0 +1 @@
+<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" deploy="true" name="my-vapp" powerOn="true"><InstantiationParams><NetworkConfigSection><ovf:Info>Configuration parameters for logical networks</ovf:Info><NetworkConfig networkName="vAppNet-vApp Internal"><Configuration><ParentNetwork href="https://vcenterprise.bluelock.com/api/v1.0/network/1990"/><FenceMode>bridged</FenceMode></Configuration></NetworkConfig></NetworkConfigSection></InstantiationParams><Source href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"/><AllEULAsAccepted>true</AllEULAsAccepted></InstantiateVAppTemplateParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/log4j.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/log4j.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/log4j.xml
new file mode 100644
index 0000000..63810d3
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/log4j.xml
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+ <!--
+ For more configuration infromation and examples see the Apache
+ Log4j website: http://logging.apache.org/log4j/
+ -->
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
+ debug="false">
+
+ <!-- A time/date based rolling appender -->
+ <appender name="WIREFILE" class="org.apache.log4j.DailyRollingFileAppender">
+ <param name="File" value="target/test-data/jclouds-wire.log" />
+ <param name="Append" value="true" />
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd" />
+
+ <param name="Threshold" value="TRACE" />
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
+
+ <!--
+ The full pattern: Date MS Priority [Category]
+ (Thread:NDC) Message\n <param name="ConversionPattern"
+ value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
+ <param name="File" value="target/test-data/jclouds.log" />
+ <param name="Append" value="true" />
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd" />
+
+ <param name="Threshold" value="TRACE" />
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
+
+ <!--
+ The full pattern: Date MS Priority [Category]
+ (Thread:NDC) Message\n <param name="ConversionPattern"
+ value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- A time/date based rolling appender -->
+ <appender name="COMPUTEFILE" class="org.apache.log4j.DailyRollingFileAppender">
+ <param name="File" value="target/test-data/jclouds-compute.log" />
+ <param name="Append" value="true" />
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd" />
+
+ <param name="Threshold" value="TRACE" />
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
+
+ <!--
+ The full pattern: Date MS Priority [Category]
+ (Thread:NDC) Message\n <param name="ConversionPattern"
+ value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- A time/date based rolling appender -->
+ <appender name="SSHFILE" class="org.apache.log4j.DailyRollingFileAppender">
+ <param name="File" value="target/test-data/jclouds-ssh.log" />
+ <param name="Append" value="true" />
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd" />
+
+ <param name="Threshold" value="TRACE" />
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
+
+ <!--
+ The full pattern: Date MS Priority [Category]
+ (Thread:NDC) Message\n <param name="ConversionPattern"
+ value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <appender name="ASYNCCOMPUTE" class="org.apache.log4j.AsyncAppender">
+ <appender-ref ref="COMPUTEFILE" />
+ </appender>
+
+ <appender name="ASYNCSSH" class="org.apache.log4j.AsyncAppender">
+ <appender-ref ref="SSHFILE" />
+ </appender>
+
+ <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
+ <appender-ref ref="FILE" />
+ </appender>
+
+ <appender name="ASYNCWIRE" class="org.apache.log4j.AsyncAppender">
+ <appender-ref ref="WIREFILE" />
+ </appender>
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jclouds">
+ <priority value="DEBUG" />
+ <appender-ref ref="ASYNC" />
+ </category>
+
+ <category name="jclouds.headers">
+ <priority value="DEBUG" />
+ <appender-ref ref="ASYNCWIRE" />
+ </category>
+
+ <category name="jclouds.ssh">
+ <priority value="DEBUG" />
+ <appender-ref ref="ASYNCSSH" />
+ </category>
+
+ <category name="jclouds.wire">
+ <priority value="DEBUG" />
+ <appender-ref ref="ASYNCWIRE" />
+ </category>
+
+ <category name="jclouds.compute">
+ <priority value="TRACE" />
+ <appender-ref ref="ASYNCCOMPUTE" />
+ </category>
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <priority value="WARN" />
+ </root>
+
+</log4j:configuration>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/memoryItem.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/memoryItem.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/memoryItem.xml
new file mode 100644
index 0000000..df35b83
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/memoryItem.xml
@@ -0,0 +1 @@
+<Item xmlns="http://www.vmware.com/vcloud/v1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"><rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits><rasd:Description>Memory Size</rasd:Description><rasd:ElementName>512 MB of memory</rasd:ElementName><rasd:InstanceID>5</rasd:InstanceID><rasd:Reservation>0</rasd:Reservation><rasd:ResourceType>4</rasd:ResourceType><rasd:VirtualQuantity>512</rasd:VirtualQuantity><rasd:Weight>0</rasd:Weight></Item>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/moveVApp.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/moveVApp.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/moveVApp.xml
new file mode 100644
index 0000000..919d136
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/moveVApp.xml
@@ -0,0 +1 @@
+<CloneVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="true" name="new-linux-server" powerOn="true" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vApp</Description><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/201" type="application/vnd.vmware.vcloud.vApp+xml"/><IsSourceDelete>true</IsSourceDelete></CloneVAppParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/moveVAppTemplate.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/moveVAppTemplate.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/moveVAppTemplate.xml
new file mode 100644
index 0000000..2f72f2b
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/moveVAppTemplate.xml
@@ -0,0 +1 @@
+<CloneVAppTemplateParams xmlns="http://vcloud.safesecureweb.com/ns/vcloud.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="new-linux-server" xsi:schemaLocation="http://vcloud.safesecureweb.com/ns/vcloud.xsd http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vAppTemplate</Description><Source href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201" type="application/vnd.vmware.vcloud.vAppTemplate+xml"/><IsSourceDelete>true</IsSourceDelete></CloneVAppTemplateParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/networkconnection.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/networkconnection.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/networkconnection.xml
new file mode 100644
index 0000000..5400fc7
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/networkconnection.xml
@@ -0,0 +1,7 @@
+<NetworkConnection network="internet01">
+ <NetworkConnectionIndex>0</NetworkConnectionIndex>
+ <IpAddress>174.47.101.164</IpAddress>
+ <IsConnected>true</IsConnected>
+ <MACAddress>00:50:56:01:01:f2</MACAddress>
+ <IpAddressAllocationMode>POOL</IpAddressAllocationMode>
+</NetworkConnection>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/networkconnectionsection.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/networkconnectionsection.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/networkconnectionsection.xml
new file mode 100644
index 0000000..9550ef6
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/networkconnectionsection.xml
@@ -0,0 +1,18 @@
+<NetworkConnectionSection
+ type="application/vnd.vmware.vcloud.networkConnectionSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/networkConnectionSection/"
+ ovf:required="false">
+ <ovf:Info>Specifies the available VM network connections</ovf:Info>
+ <PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
+ <NetworkConnection network="internet01">
+ <NetworkConnectionIndex>0</NetworkConnectionIndex>
+ <IpAddress>174.47.101.164</IpAddress>
+ <IsConnected>true</IsConnected>
+ <MACAddress>00:50:56:01:01:f2</MACAddress>
+ <IpAddressAllocationMode>POOL</IpAddressAllocationMode>
+ </NetworkConnection>
+ <Link rel="edit"
+ type="application/vnd.vmware.vcloud.networkConnectionSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/networkConnectionSection/" />
+</NetworkConnectionSection>
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org-1.0.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org-1.0.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org-1.0.xml
new file mode 100644
index 0000000..af9803f
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org-1.0.xml
@@ -0,0 +1,24 @@
+<Org name="ExampleOrg" type="application/vnd.vmware.vcloud.org+xml"
+ href="http://vcloud.example.com/api/v1.0/org/5" >
+ <Link type="application/vnd.vmware.vcloud.catalog+xml" rel="down"
+ href="http://vcloud.example.com/api/v1.0/catalog/32" name="Main Catalog" />
+ <Link type="application/vnd.vmware.vcloud.controlAccess+xml" rel="down"
+ href="http://vcloud.example.com/api/v1.0/catalog/32/controlAccess" />
+ <Link type="application/vnd.vmware.vcloud.controlAccess+xml" rel="controlAccess"
+ href="http://vcloud.example.com/api/v1.0/catalog/32/action/controlAccess" />
+ <Link type="application/vnd.vmware.vcloud.catalog+xml" rel="down"
+ href="http://vcloud.example.com/api/v1.0/catalog/37" name="Shared Catalog" />
+ <Link type="application/vnd.vmware.vcloud.controlAccess+xml" rel="down"
+ href="http://vcloud.example.com/api/v1.0/catalog/37/controlAccess" />
+ <Link type="application/vnd.vmware.vcloud.controlAccess+xml" rel="controlAccess"
+ href="http://vcloud.example.com/api/v1.0/catalog/37/action/controlAccess" />
+ <Link type="application/vnd.vmware.vcloud.vdc+xml" rel="down"
+ href="http://vcloud.example.com/api/v1.0/vdc/5" name="ExampleVdc01" />
+ <Link type="application/vnd.vmware.vcloud.tasksList+xml" rel="down"
+ href="http://vcloud.example.com/api/v1.0/tasksList/5" />
+ <Link type="application/vnd.vmware.vcloud.network+xml" rel="down"
+ href="http://vcloud.example.com/api/v1.0/network/14" name="TestNetwork" />
+ <Link type="application/vnd.vmware.vcloud.network+xml" rel="down"
+ href="http://vcloud.example.com/api/v1.0/network/54" name="ProductionNetwork" />
+ <Description>Example Corp's Primary Organization.</Description>
+</Org>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org-hosting.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org-hosting.xml
new file mode 100644
index 0000000..3bd9842
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org-hosting.xml
@@ -0,0 +1,12 @@
+<Org href="https://vcloud.safesecureweb.com/api/v0.8/org/188849"
+ name="Customer 188849" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8/organization.xsd"
+ xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <Link rel="down" href="https://vcloud.safesecureweb.com/api/v0.8/catalog/1"
+ type="application/vnd.vmware.vcloud.catalog+xml" name="HMS Shared Catalog" />
+ <Link rel="down"
+ href="https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"
+ type="application/vnd.vmware.vcloud.vdc+xml" name="188849 Virtual DataCenter" />
+ <Link rel="down"
+ href="https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849"
+ type="application/vnd.vmware.vcloud.tasksList+xml" name="188849 Task List" />
+</Org>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org-savvis.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org-savvis.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org-savvis.xml
new file mode 100644
index 0000000..c2517c7
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org-savvis.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<vApp:Org xmlns:vApp="http://www.vmware.com/vcloud/v0.8"
+ xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common"
+ xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
+ xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
+ xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
+ name="607968.0">
+ <vApp:Link
+ href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/607968.0/vdc/2826"
+ name="GravDataCenter1(Saved)" rel="down"
+ type="application/vnd.vmware.vcloud.vdc+xml" />
+ <vApp:Description>Gravitant Inc</vApp:Description>
+</vApp:Org>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org.xml
new file mode 100644
index 0000000..1728721
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org.xml
@@ -0,0 +1,5 @@
+<Org href="https://services.vcloudexpress.terremark.com/api/v0.8/org/48" name="adrian@jclouds.org" xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32" type="application/vnd.vmware.vcloud.vdc+xml" name="Miami Environment 1"/>
+ <Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog" type="application/vnd.vmware.vcloud.catalog+xml" name="Miami Environment 1 Catalog"/>
+ <Link rel="down" href="https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/32" type="application/vnd.vmware.vcloud.tasksList+xml" name="Miami Environment 1 Tasks List"/>
+</Org>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org1.0-vcd15.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org1.0-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org1.0-vcd15.xml
new file mode 100644
index 0000000..d0ca5b7
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/org1.0-vcd15.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Org xmlns="http://www.vmware.com/vcloud/v1" name="jclouds" type="application/vnd.vmware.vcloud.org+xml" href="https://zone.myvcloud.com/api/v1.0/org/c076f90a-397a-49fa-89b8-b294c1599cd0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 https://zone.myvcloud.com/api/v1.0/schema/master.xsd">
+ <Link rel="down" type="application/vnd.vmware.vcloud.vdc+xml" name="orgVDC-jclouds-Tier1-PAYG" href="https://zone.myvcloud.com/api/v1.0/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.tasksList+xml" href="https://zone.myvcloud.com/api/v1.0/tasksList/c076f90a-397a-49fa-89b8-b294c1599cd0"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.catalog+xml" name="jclouds" href="https://zone.myvcloud.com/api/v1.0/catalog/3155f393-1e1d-4572-8c9c-d76f72ddb658"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.controlAccess+xml" href="https://zone.myvcloud.com/api/v1.0/org/c076f90a-397a-49fa-89b8-b294c1599cd0/catalog/3155f393-1e1d-4572-8c9c-d76f72ddb658/controlAccess/"/>
+ <Link rel="controlAccess" type="application/vnd.vmware.vcloud.controlAccess+xml" href="https://zone.myvcloud.com/api/v1.0/org/c076f90a-397a-49fa-89b8-b294c1599cd0/catalog/3155f393-1e1d-4572-8c9c-d76f72ddb658/action/controlAccess"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.network+xml" name="orgNet-jclouds-External" href="https://zone.myvcloud.com/api/v1.0/network/b466c0c5-8a5c-4335-b703-a2e2e6b5f3e1"/>
+ <Description>Customer jclouds</Description>
+ <FullName>jclouds</FullName>
+</Org>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orgList1.0-vcd15.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orgList1.0-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orgList1.0-vcd15.xml
new file mode 100644
index 0000000..40f3cbe
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orgList1.0-vcd15.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<OrgList xmlns="http://www.vmware.com/vcloud/v1" type="application/vnd.vmware.vcloud.orgList+xml" href="https://zone.myvcloud.com/api/v1.0/org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 https://zone.myvcloud.com/api/v1.0/schema/master.xsd">
+ <Org type="application/vnd.vmware.vcloud.org+xml" name="jclouds" href="https://zone.myvcloud.com/api/v1.0/org/c076f90a-397a-49fa-89b8-b294c1599cd0"/>
+</OrgList>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orglist-savvis.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orglist-savvis.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orglist-savvis.xml
new file mode 100644
index 0000000..4de503b
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orglist-savvis.xml
@@ -0,0 +1,3 @@
+<vApp:OrgList xmlns:vApp="http://www.vmware.com/vcloud/v0.8">
+<vApp:Org name="SAVVISStation Integration Testing" type="application/vnd.vmware.vcloud.org+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0"/>
+</vApp:OrgList>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orglist.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orglist.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orglist.xml
new file mode 100644
index 0000000..e6117b3
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orglist.xml
@@ -0,0 +1,3 @@
+<OrgList xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+<Org href="https://services.vcloudexpress.terremark.com/api/v0.8/org/48" type="application/vnd.vmware.vcloud.org+xml" name="adrian@jclouds.org"/>
+</OrgList>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orgnetwork-bridged.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orgnetwork-bridged.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orgnetwork-bridged.xml
new file mode 100644
index 0000000..cb2a0d3
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orgnetwork-bridged.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<OrgNetwork xmlns="http://www.vmware.com/vcloud/v1" name="internet01" type="application/vnd.vmware.vcloud.network+xml" href="https://vcenterprise.bluelock.com/api/v1.0/network/758634723" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://vcenterprise.bluelock.com/api/v1.0/org/9566014"/>
+ <Description/>
+ <Configuration>
+ <IpScope>
+ <IsInherited>true</IsInherited>
+ <Gateway>174.47.101.161</Gateway>
+ <Netmask>255.255.255.224</Netmask>
+ <Dns1>24.172.173.113</Dns1>
+ <IpRanges>
+ <IpRange>
+ <StartAddress>174.47.101.164</StartAddress>
+ <EndAddress>174.47.101.190</EndAddress>
+ </IpRange>
+ </IpRanges>
+ </IpScope>
+ <FenceMode>bridged</FenceMode>
+ </Configuration>
+</OrgNetwork>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orgnetwork-isolated.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orgnetwork-isolated.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orgnetwork-isolated.xml
new file mode 100644
index 0000000..ac3a66a
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/orgnetwork-isolated.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<OrgNetwork xmlns="http://www.vmware.com/vcloud/v1" name="isolation01" type="application/vnd.vmware.vcloud.network+xml" href="https://vcenterprise.bluelock.com/api/v1.0/network/990419644" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://vcenterprise.bluelock.com/api/v1.0/org/9566014"/>
+ <Description/>
+ <Configuration>
+ <IpScope>
+ <IsInherited>false</IsInherited>
+ <Gateway>192.168.15.1</Gateway>
+ <Netmask>255.255.255.0</Netmask>
+ <Dns1>23.172.173.113</Dns1>
+ <IpRanges>
+ <IpRange>
+ <StartAddress>192.168.15.100</StartAddress>
+ <EndAddress>192.168.15.199</EndAddress>
+ </IpRange>
+ </IpRanges>
+ </IpScope>
+ <FenceMode>isolated</FenceMode>
+ <Features>
+ <DhcpService>
+ <IsEnabled>false</IsEnabled>
+ <DefaultLeaseTime>3600</DefaultLeaseTime>
+ <MaxLeaseTime>7200</MaxLeaseTime>
+ <IpRange>
+ <StartAddress>192.168.15.2</StartAddress>
+ <EndAddress>192.168.15.99</EndAddress>
+ </IpRange>
+ </DhcpService>
+ </Features>
+ </Configuration>
+</OrgNetwork>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/os.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/os.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/os.xml
new file mode 100644
index 0000000..3196a27
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/os.xml
@@ -0,0 +1,11 @@
+<ovf:OperatingSystemSection xmlns:vcloud="http://www.vmware.com/vcloud/v1"
+ xmlns:vmw="http://www.vmware.com/schema/ovf" ovf:id="80"
+ vcloud:href="https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/"
+ vcloud:type="application/vnd.vmware.vcloud.operatingSystemSection+xml"
+ vmw:osType="rhel5_64Guest">
+ <ovf:Info>Specifies the operating system installed</ovf:Info>
+ <ovf:Description>Red Hat Enterprise Linux 5 (64-bit)</ovf:Description>
+ <Link rel="edit"
+ type="application/vnd.vmware.vcloud.operatingSystemSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/" />
+</ovf:OperatingSystemSection>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/ovf-multi-vm.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/ovf-multi-vm.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/ovf-multi-vm.xml
new file mode 100644
index 0000000..fa4bb37
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/ovf-multi-vm.xml
@@ -0,0 +1,285 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ovf:Envelope xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vcloud="http://www.vmware.com/vcloud/v1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_VirtualSystemSettingData.xsd http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd http://www.vmware.com/vcloud/v1 http://zone.myvcloud.com/api/v1.0/schema/master.xsd">
+ <ovf:References/>
+ <ovf:NetworkSection>
+ <ovf:Info>The list of logical networks</ovf:Info>
+ <ovf:Network ovf:name="vapp net">
+ <ovf:Description/>
+ </ovf:Network>
+ </ovf:NetworkSection>
+ <vcloud:NetworkConfigSection ovf:required="false">
+ <ovf:Info>The configuration parameters for logical networks</ovf:Info>
+ <vcloud:NetworkConfig networkName="vapp net">
+ <vcloud:Description/>
+ <vcloud:Configuration>
+ <vcloud:IpScope>
+ <vcloud:IsInherited>false</vcloud:IsInherited>
+ <vcloud:Gateway>192.168.2.1</vcloud:Gateway>
+ <vcloud:Netmask>255.255.255.0</vcloud:Netmask>
+ <vcloud:Dns1>195.225.219.131</vcloud:Dns1>
+ <vcloud:IpRanges>
+ <vcloud:IpRange>
+ <vcloud:StartAddress>192.168.2.100</vcloud:StartAddress>
+ <vcloud:EndAddress>192.168.2.199</vcloud:EndAddress>
+ </vcloud:IpRange>
+ </vcloud:IpRanges>
+ </vcloud:IpScope>
+ <vcloud:FenceMode>isolated</vcloud:FenceMode>
+ <vcloud:Features>
+ <vcloud:DhcpService>
+ <vcloud:IsEnabled>false</vcloud:IsEnabled>
+ <vcloud:DefaultLeaseTime>7200</vcloud:DefaultLeaseTime>
+ <vcloud:MaxLeaseTime>7200</vcloud:MaxLeaseTime>
+ <vcloud:IpRange/>
+ </vcloud:DhcpService>
+ </vcloud:Features>
+ </vcloud:Configuration>
+ <vcloud:IsDeployed>false</vcloud:IsDeployed>
+ </vcloud:NetworkConfig>
+ </vcloud:NetworkConfigSection>
+ <vcloud:LeaseSettingsSection ovf:required="false">
+ <ovf:Info>Lease settings section</ovf:Info>
+ <vcloud:DeploymentLeaseInSeconds>0</vcloud:DeploymentLeaseInSeconds>
+ <vcloud:StorageLeaseInSeconds>0</vcloud:StorageLeaseInSeconds>
+ </vcloud:LeaseSettingsSection>
+ <vcloud:CustomizationSection ovf:required="false">
+ <ovf:Info>VApp template customization section</ovf:Info>
+ <vcloud:CustomizeOnInstantiate>true</vcloud:CustomizeOnInstantiate>
+ </vcloud:CustomizationSection>
+ <ovf:VirtualSystemCollection ovf:id="centos-web/db-5.5">
+ <ovf:Info>A collection of virtual machines: </ovf:Info>
+ <ovf:Name>centos-web/db-5.5</ovf:Name>
+ <ovf:StartupSection>
+ <ovf:Info>VApp startup section</ovf:Info>
+ <ovf:Item ovf:stopDelay="0" ovf:stopAction="powerOff" ovf:startDelay="0" ovf:startAction="powerOn" ovf:order="0" ovf:id="centos-web"/>
+ <ovf:Item ovf:stopDelay="0" ovf:stopAction="powerOff" ovf:startDelay="0" ovf:startAction="powerOn" ovf:order="0" ovf:id="centos-db"/>
+ </ovf:StartupSection>
+ <ovf:VirtualSystem ovf:id="centos-db">
+ <ovf:Info>A virtual machine: </ovf:Info>
+ <ovf:Name>centos-db</ovf:Name>
+ <ovf:OperatingSystemSection xmlns:vmw="http://www.vmware.com/schema/ovf" ovf:id="100" vmw:osType="other26xLinux64Guest">
+ <ovf:Info>Specifies the operating system installed</ovf:Info>
+ <ovf:Description>Other 2.6x Linux (64-bit)</ovf:Description>
+ </ovf:OperatingSystemSection>
+ <ovf:VirtualHardwareSection>
+ <ovf:Info>Virtual hardware requirements</ovf:Info>
+ <ovf:System>
+ <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
+ <vssd:InstanceID>0</vssd:InstanceID>
+ <vssd:VirtualSystemIdentifier>centos-db</vssd:VirtualSystemIdentifier>
+ <vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>
+ </ovf:System>
+ <ovf:Item>
+ <rasd:Address>00:50:56:01:06:81</rasd:Address>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
+ <rasd:Connection vcloud:ipAddress="192.168.2.100" vcloud:primaryNetworkConnection="true" vcloud:ipAddressingMode="POOL">vapp net</rasd:Connection>
+
+ <rasd:Description>PCNet32 ethernet adapter</rasd:Description>
+ <rasd:ElementName>Network adapter 0</rasd:ElementName>
+ <rasd:InstanceID>1</rasd:InstanceID>
+ <rasd:ResourceSubType>PCNet32</rasd:ResourceSubType>
+ <rasd:ResourceType>10</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>SCSI Controller</rasd:Description>
+ <rasd:ElementName>SCSI Controller 0</rasd:ElementName>
+ <rasd:InstanceID>2</rasd:InstanceID>
+ <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
+ <rasd:ResourceType>6</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:Description>Hard disk</rasd:Description>
+ <rasd:ElementName>Hard disk 1</rasd:ElementName>
+ <rasd:HostResource vcloud:capacity="8192" vcloud:busType="6" vcloud:busSubType="lsilogic"/>
+ <rasd:InstanceID>2000</rasd:InstanceID>
+ <rasd:Parent>2</rasd:Parent>
+ <rasd:ResourceType>17</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>IDE Controller</rasd:Description>
+ <rasd:ElementName>IDE Controller 0</rasd:ElementName>
+ <rasd:InstanceID>3</rasd:InstanceID>
+ <rasd:ResourceType>5</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:Description>CD/DVD Drive</rasd:Description>
+ <rasd:ElementName>CD/DVD Drive 1</rasd:ElementName>
+ <rasd:HostResource/>
+ <rasd:InstanceID>3000</rasd:InstanceID>
+ <rasd:Parent>3</rasd:Parent>
+ <rasd:ResourceType>15</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:Description>Floppy Drive</rasd:Description>
+ <rasd:ElementName>Floppy Drive 1</rasd:ElementName>
+ <rasd:HostResource/>
+ <rasd:InstanceID>8000</rasd:InstanceID>
+ <rasd:ResourceType>14</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
+ <rasd:Description>Number of Virtual CPUs</rasd:Description>
+ <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
+ <rasd:InstanceID>4</rasd:InstanceID>
+ <rasd:Reservation>0</rasd:Reservation>
+ <rasd:ResourceType>3</rasd:ResourceType>
+ <rasd:VirtualQuantity>1</rasd:VirtualQuantity>
+ <rasd:Weight>0</rasd:Weight>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
+ <rasd:Description>Memory Size</rasd:Description>
+ <rasd:ElementName>2048 MB of memory</rasd:ElementName>
+ <rasd:InstanceID>5</rasd:InstanceID>
+ <rasd:Reservation>0</rasd:Reservation>
+ <rasd:ResourceType>4</rasd:ResourceType>
+ <rasd:VirtualQuantity>2048</rasd:VirtualQuantity>
+ <rasd:Weight>0</rasd:Weight>
+ </ovf:Item>
+ </ovf:VirtualHardwareSection>
+ <vcloud:NetworkConnectionSection ovf:required="false">
+ <ovf:Info>Specifies the available VM network connections</ovf:Info>
+ <vcloud:PrimaryNetworkConnectionIndex>0</vcloud:PrimaryNetworkConnectionIndex>
+ <vcloud:NetworkConnection network="vapp net">
+ <vcloud:NetworkConnectionIndex>0</vcloud:NetworkConnectionIndex>
+ <vcloud:IpAddress>192.168.2.100</vcloud:IpAddress>
+ <vcloud:IsConnected>true</vcloud:IsConnected>
+ <vcloud:MACAddress>00:50:56:01:06:81</vcloud:MACAddress>
+ <vcloud:IpAddressAllocationMode>POOL</vcloud:IpAddressAllocationMode>
+ </vcloud:NetworkConnection>
+ </vcloud:NetworkConnectionSection>
+ <vcloud:GuestCustomizationSection ovf:required="false">
+ <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
+ <vcloud:Enabled>true</vcloud:Enabled>
+ <vcloud:ChangeSid>false</vcloud:ChangeSid>
+ <vcloud:JoinDomainEnabled>false</vcloud:JoinDomainEnabled>
+ <vcloud:UseOrgSettings>false</vcloud:UseOrgSettings>
+ <vcloud:AdminPasswordEnabled>false</vcloud:AdminPasswordEnabled>
+ <vcloud:AdminPasswordAuto>true</vcloud:AdminPasswordAuto>
+ <vcloud:ResetPasswordRequired>false</vcloud:ResetPasswordRequired>
+ <vcloud:ComputerName>centos-db</vcloud:ComputerName>
+ </vcloud:GuestCustomizationSection>
+ </ovf:VirtualSystem>
+ <ovf:VirtualSystem ovf:id="centos-web">
+ <ovf:Info>A virtual machine: </ovf:Info>
+ <ovf:Name>centos-web</ovf:Name>
+ <ovf:OperatingSystemSection xmlns:vmw="http://www.vmware.com/schema/ovf" ovf:id="100" vmw:osType="other26xLinux64Guest">
+ <ovf:Info>Specifies the operating system installed</ovf:Info>
+ <ovf:Description>Other 2.6x Linux (64-bit)</ovf:Description>
+ </ovf:OperatingSystemSection>
+ <ovf:VirtualHardwareSection>
+ <ovf:Info>Virtual hardware requirements</ovf:Info>
+ <ovf:System>
+ <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
+ <vssd:InstanceID>0</vssd:InstanceID>
+ <vssd:VirtualSystemIdentifier>centos-web</vssd:VirtualSystemIdentifier>
+ <vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>
+ </ovf:System>
+ <ovf:Item>
+ <rasd:Address>00:50:56:01:06:82</rasd:Address> <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
+ <rasd:Connection vcloud:ipAddress="192.168.2.101" vcloud:primaryNetworkConnection="true" vcloud:ipAddressingMode="POOL">vapp net</rasd:Connection>
+
+ <rasd:Description>PCNet32 ethernet adapter</rasd:Description>
+ <rasd:ElementName>Network adapter 0</rasd:ElementName>
+ <rasd:InstanceID>1</rasd:InstanceID>
+ <rasd:ResourceSubType>PCNet32</rasd:ResourceSubType>
+ <rasd:ResourceType>10</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>SCSI Controller</rasd:Description>
+ <rasd:ElementName>SCSI Controller 0</rasd:ElementName>
+ <rasd:InstanceID>2</rasd:InstanceID>
+ <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
+ <rasd:ResourceType>6</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:Description>Hard disk</rasd:Description>
+ <rasd:ElementName>Hard disk 1</rasd:ElementName>
+ <rasd:HostResource vcloud:capacity="8192" vcloud:busType="6" vcloud:busSubType="lsilogic"/>
+ <rasd:InstanceID>2000</rasd:InstanceID>
+ <rasd:Parent>2</rasd:Parent>
+ <rasd:ResourceType>17</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>IDE Controller</rasd:Description>
+ <rasd:ElementName>IDE Controller 0</rasd:ElementName>
+ <rasd:InstanceID>3</rasd:InstanceID>
+ <rasd:ResourceType>5</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:Description>CD/DVD Drive</rasd:Description>
+ <rasd:ElementName>CD/DVD Drive 1</rasd:ElementName>
+ <rasd:HostResource/>
+ <rasd:InstanceID>3000</rasd:InstanceID>
+ <rasd:Parent>3</rasd:Parent>
+ <rasd:ResourceType>15</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:Description>Floppy Drive</rasd:Description>
+ <rasd:ElementName>Floppy Drive 1</rasd:ElementName>
+ <rasd:HostResource/>
+ <rasd:InstanceID>8000</rasd:InstanceID>
+ <rasd:ResourceType>14</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
+ <rasd:Description>Number of Virtual CPUs</rasd:Description>
+ <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
+ <rasd:InstanceID>4</rasd:InstanceID>
+ <rasd:Reservation>0</rasd:Reservation>
+ <rasd:ResourceType>3</rasd:ResourceType>
+ <rasd:VirtualQuantity>1</rasd:VirtualQuantity>
+ <rasd:Weight>0</rasd:Weight>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
+ <rasd:Description>Memory Size</rasd:Description>
+ <rasd:ElementName>2048 MB of memory</rasd:ElementName>
+ <rasd:InstanceID>5</rasd:InstanceID>
+ <rasd:Reservation>0</rasd:Reservation>
+ <rasd:ResourceType>4</rasd:ResourceType>
+ <rasd:VirtualQuantity>2048</rasd:VirtualQuantity>
+ <rasd:Weight>0</rasd:Weight>
+ </ovf:Item>
+ </ovf:VirtualHardwareSection>
+ <vcloud:NetworkConnectionSection ovf:required="false">
+ <ovf:Info>Specifies the available VM network connections</ovf:Info>
+ <vcloud:PrimaryNetworkConnectionIndex>0</vcloud:PrimaryNetworkConnectionIndex>
+ <vcloud:NetworkConnection network="vapp net">
+ <vcloud:NetworkConnectionIndex>0</vcloud:NetworkConnectionIndex>
+ <vcloud:IpAddress>192.168.2.101</vcloud:IpAddress>
+ <vcloud:IsConnected>true</vcloud:IsConnected>
+ <vcloud:MACAddress>00:50:56:01:06:82</vcloud:MACAddress>
+ <vcloud:IpAddressAllocationMode>POOL</vcloud:IpAddressAllocationMode>
+ </vcloud:NetworkConnection>
+ </vcloud:NetworkConnectionSection>
+ <vcloud:GuestCustomizationSection ovf:required="false">
+ <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
+ <vcloud:Enabled>true</vcloud:Enabled>
+ <vcloud:ChangeSid>false</vcloud:ChangeSid>
+ <vcloud:JoinDomainEnabled>false</vcloud:JoinDomainEnabled>
+ <vcloud:UseOrgSettings>false</vcloud:UseOrgSettings>
+ <vcloud:AdminPasswordEnabled>false</vcloud:AdminPasswordEnabled>
+ <vcloud:AdminPasswordAuto>true</vcloud:AdminPasswordAuto>
+ <vcloud:ResetPasswordRequired>false</vcloud:ResetPasswordRequired>
+ <vcloud:ComputerName>centos-web</vcloud:ComputerName>
+ </vcloud:GuestCustomizationSection>
+ </ovf:VirtualSystem>
+ </ovf:VirtualSystemCollection>
+</ovf:Envelope>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/ovf-ubuntu64.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/ovf-ubuntu64.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/ovf-ubuntu64.xml
new file mode 100644
index 0000000..7679573
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/ovf-ubuntu64.xml
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ovf:Envelope xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vcloud="http://www.vmware.com/vcloud/v1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_VirtualSystemSettingData.xsd http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd http://www.vmware.com/vcloud/v1 https://zone.myvcloud.com/api/v1.0/schema/master.xsd">
+ <ovf:References/>
+ <ovf:NetworkSection>
+ <ovf:Info>The list of logical networks</ovf:Info>
+ <ovf:Network ovf:name="none">
+ <ovf:Description>This is a special place-holder used for disconnected network interfaces.</ovf:Description>
+ </ovf:Network>
+ </ovf:NetworkSection>
+ <vcloud:NetworkConfigSection ovf:required="false">
+ <ovf:Info>The configuration parameters for logical networks</ovf:Info>
+ <vcloud:NetworkConfig networkName="none">
+ <vcloud:Description>This is a special place-holder used for disconnected network interfaces.</vcloud:Description>
+ <vcloud:Configuration>
+ <vcloud:IpScope>
+ <vcloud:IsInherited>false</vcloud:IsInherited>
+ <vcloud:Gateway>196.254.254.254</vcloud:Gateway>
+ <vcloud:Netmask>255.255.0.0</vcloud:Netmask>
+ <vcloud:Dns1>196.254.254.254</vcloud:Dns1>
+ </vcloud:IpScope>
+ <vcloud:FenceMode>isolated</vcloud:FenceMode>
+ </vcloud:Configuration>
+ <vcloud:IsDeployed>false</vcloud:IsDeployed>
+ </vcloud:NetworkConfig>
+ </vcloud:NetworkConfigSection>
+ <vcloud:LeaseSettingsSection ovf:required="false">
+ <ovf:Info>Lease settings section</ovf:Info>
+ <vcloud:DeploymentLeaseInSeconds>0</vcloud:DeploymentLeaseInSeconds>
+ <vcloud:StorageLeaseInSeconds>5184000</vcloud:StorageLeaseInSeconds>
+ <vcloud:StorageLeaseExpiration>2012-03-12T17:40:44.491-06:00</vcloud:StorageLeaseExpiration>
+ </vcloud:LeaseSettingsSection>
+ <vcloud:CustomizationSection ovf:required="false">
+ <ovf:Info>VApp template customization section</ovf:Info>
+ <vcloud:CustomizeOnInstantiate>true</vcloud:CustomizeOnInstantiate>
+ </vcloud:CustomizationSection>
+ <ovf:VirtualSystem ovf:id="UbuntuServer-x64-2GB">
+ <ovf:Info>A virtual machine: </ovf:Info>
+ <ovf:Name>UbuntuServer-x64-2GB</ovf:Name>
+ <ovf:OperatingSystemSection xmlns:vmw="http://www.vmware.com/schema/ovf" ovf:id="94" vmw:osType="ubuntu64Guest">
+ <ovf:Info>Specifies the operating system installed</ovf:Info>
+ <ovf:Description>Ubuntu Linux (64-bit)</ovf:Description>
+ </ovf:OperatingSystemSection>
+ <ovf:VirtualHardwareSection>
+ <ovf:Info>Virtual hardware requirements</ovf:Info>
+ <ovf:System>
+ <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
+ <vssd:InstanceID>0</vssd:InstanceID>
+ <vssd:VirtualSystemIdentifier>UbuntuServer-x64-2GB</vssd:VirtualSystemIdentifier>
+ <vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>
+ </ovf:System>
+ <ovf:Item>
+ <rasd:Address>00:50:56:01:02:9f</rasd:Address>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:Connection vcloud:primaryNetworkConnection="true" vcloud:ipAddressingMode="NONE">none</rasd:Connection>
+ <rasd:Description>PCNet32 ethernet adapter</rasd:Description>
+ <rasd:ElementName>Network adapter 0</rasd:ElementName>
+ <rasd:InstanceID>1</rasd:InstanceID>
+ <rasd:ResourceSubType>PCNet32</rasd:ResourceSubType>
+ <rasd:ResourceType>10</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>SCSI Controller</rasd:Description>
+ <rasd:ElementName>SCSI Controller 0</rasd:ElementName>
+ <rasd:InstanceID>2</rasd:InstanceID>
+ <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
+ <rasd:ResourceType>6</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:Description>Hard disk</rasd:Description>
+ <rasd:ElementName>Hard disk 1</rasd:ElementName>
+ <rasd:HostResource vcloud:capacity="2048" vcloud:busType="6" vcloud:busSubType="lsilogic"/>
+ <rasd:InstanceID>2000</rasd:InstanceID>
+ <rasd:Parent>2</rasd:Parent>
+ <rasd:ResourceType>17</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>IDE Controller</rasd:Description>
+ <rasd:ElementName>IDE Controller 0</rasd:ElementName>
+ <rasd:InstanceID>3</rasd:InstanceID>
+ <rasd:ResourceType>5</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:Description>CD/DVD Drive</rasd:Description>
+ <rasd:ElementName>CD/DVD Drive 1</rasd:ElementName>
+ <rasd:HostResource/>
+ <rasd:InstanceID>3000</rasd:InstanceID>
+ <rasd:Parent>3</rasd:Parent>
+ <rasd:ResourceType>15</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:Description>Floppy Drive</rasd:Description>
+ <rasd:ElementName>Floppy Drive 1</rasd:ElementName>
+ <rasd:HostResource/>
+ <rasd:InstanceID>8000</rasd:InstanceID>
+ <rasd:ResourceType>14</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
+ <rasd:Description>Number of Virtual CPUs</rasd:Description>
+ <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
+ <rasd:InstanceID>4</rasd:InstanceID>
+ <rasd:Reservation>0</rasd:Reservation>
+ <rasd:ResourceType>3</rasd:ResourceType>
+ <rasd:VirtualQuantity>1</rasd:VirtualQuantity>
+ <rasd:Weight>0</rasd:Weight>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
+ <rasd:Description>Memory Size</rasd:Description>
+ <rasd:ElementName>256 MB of memory</rasd:ElementName>
+ <rasd:InstanceID>5</rasd:InstanceID>
+ <rasd:Reservation>0</rasd:Reservation>
+ <rasd:ResourceType>4</rasd:ResourceType>
+ <rasd:VirtualQuantity>256</rasd:VirtualQuantity>
+ <rasd:Weight>0</rasd:Weight>
+ </ovf:Item>
+ </ovf:VirtualHardwareSection>
+ <vcloud:NetworkConnectionSection ovf:required="false">
+ <ovf:Info>Specifies the available VM network connections</ovf:Info>
+ <vcloud:PrimaryNetworkConnectionIndex>0</vcloud:PrimaryNetworkConnectionIndex>
+ <vcloud:NetworkConnection network="none">
+ <vcloud:NetworkConnectionIndex>0</vcloud:NetworkConnectionIndex>
+ <vcloud:IsConnected>false</vcloud:IsConnected>
+ <vcloud:MACAddress>00:50:56:01:02:9f</vcloud:MACAddress>
+ <vcloud:IpAddressAllocationMode>NONE</vcloud:IpAddressAllocationMode>
+ </vcloud:NetworkConnection>
+ </vcloud:NetworkConnectionSection>
+ <vcloud:GuestCustomizationSection ovf:required="false">
+ <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
+ <vcloud:Enabled>true</vcloud:Enabled>
+ <vcloud:ChangeSid>false</vcloud:ChangeSid>
+ <vcloud:JoinDomainEnabled>false</vcloud:JoinDomainEnabled>
+ <vcloud:UseOrgSettings>false</vcloud:UseOrgSettings>
+ <vcloud:AdminPasswordEnabled>true</vcloud:AdminPasswordEnabled>
+ <vcloud:AdminPasswordAuto>true</vcloud:AdminPasswordAuto>
+ <vcloud:ResetPasswordRequired>false</vcloud:ResetPasswordRequired>
+ <vcloud:ComputerName>UbuntuServer</vcloud:ComputerName>
+ </vcloud:GuestCustomizationSection>
+ </ovf:VirtualSystem>
+</ovf:Envelope>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-1.0.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-1.0.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-1.0.xml
new file mode 100644
index 0000000..20fde3f
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-1.0.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Task status="running" startTime="2010-08-23T02:09:52.443-04:00"
+ operation="Creating Virtual Application vApp_acole_2(607806320)"
+ expiryTime="2010-11-21T02:09:52.443-05:00" endTime="9999-12-31T23:59:59.999-05:00"
+ type="application/vnd.vmware.vcloud.task+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/task/3cc08ir8oczbze3n1a3">
+ <Owner type="application/vnd.vmware.vcloud.vApp+xml" name="vApp_acole_2"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-607806320" />
+</Task>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-error.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-error.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-error.xml
new file mode 100644
index 0000000..77147f8
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-error.xml
@@ -0,0 +1,9 @@
+<Task href="http://10.150.4.49/api/v0.8/task/23" type="application/vnd.vmware.vcloud.task+xml"
+ status="error" startTime="2009-12-07T19:05:02" endTime="2009-12-10T14:40:32">
+ <Owner href="http://10.150.4.49/api/v0.8/org/1" type="application/vnd.vmware.vcloud.org+xml"
+ name="APIOrg" />
+ <Result href="http://10.150.4.49/api/v0.8/vapp/1" type="application/vnd.vmware.vcloud.vApp+xml"
+ name="testapp1" />
+ <Error message="Error processing job" majorErrorCode="500"
+ minorErrorCode=" Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00" />
+</Task>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-hosting.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-hosting.xml
new file mode 100644
index 0000000..f4af4a2
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-hosting.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Task href="https://vcloud.safesecureweb.com/api/v0.8/task/97806" xmlns="http://www.vmware.com/vcloud/v0.8"
+ xmlns:common="http://www.vmware.com/vcloud/common"
+ xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8/task
+ https://vcloud.safesecureweb.com/ns/vcloud/task-1.0.xsd
+ http://www.vmware.com/vcloud/common
+ https://vcloud.safesecureweb.com/ns/vcloud/common-1.0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ status="success" startTime="2010-01-14T20:04:51Z" endTime="2010-01-14T20:05:02Z" expiryTime="2010-01-15T20:05:02Z">
+
+ <Owner href="https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96" type="application/vnd.vmware.vcloud.vApp+xml" name="188849-96" />
+</Task>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-self.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-self.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-self.xml
new file mode 100644
index 0000000..4a17424
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-self.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Task xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:common="http://www/vmware.com/vcloud/common"
+ xsi:schemaLocation="http://www/vmware.com/vcloud/task
+ https://vcloud.safesecureweb.com/ns/vcloud/task-1.0.xsd
+ http://www.vmware.com/vcloud/common
+ https://vcloud.safesecureweb.com/ns/vcloud/common-1.0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" status="queued">
+ <Link rel="self"
+ href="https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"
+ type="application/vnd.vmware.vcloud.task+xml" />
+</Task>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-vcd15.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-vcd15.xml
new file mode 100644
index 0000000..452287d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task-vcd15.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<vcloud:Task xmlns:vcloud="http://www.vmware.com/vcloud/v1" status="running" startTime="2012-03-15T22:47:02.058-06:00" operation="Updating Virtual Machine UbuntuServer-x64-2GB(c9004a47-5e21-4cf1-860c-670d8965b24a)" expiryTime="2012-06-13T22:47:02.058-06:00" type="application/vnd.vmware.vcloud.task+xml" href="https://mycloud.greenhousedata.com/api/v1.0/task/77a33fd4-3401-423c-8167-6711fc51ee9a" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://mycloud.greenhousedata.com/api/v1.0/schema/master.xsd">
+ <vcloud:Link rel="task:cancel" href="https://mycloud.greenhousedata.com/api/v1.0/task/77a33fd4-3401-423c-8167-6711fc51ee9a/action/cancel"/>
+ <vcloud:Owner type="application/vnd.vmware.vcloud.vm+xml" name="UbuntuServer-x64-2GB" href="https://mycloud.greenhousedata.com/api/v1.0/vApp/vm-c9004a47-5e21-4cf1-860c-670d8965b24a"/>
+</vcloud:Task>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task.xml
new file mode 100644
index 0000000..bd0514e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/task.xml
@@ -0,0 +1,8 @@
+<Task href="https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"
+ status="success" startTime="2009-08-24T21:29:32.983Z" endTime="2009-08-24T21:29:44.65Z">
+ <Owner href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1"
+ type="application/vnd.vmware.vcloud.vdc+xml" name="VDC Name" />
+ <Result
+ href="https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012"
+ type="application/vnd.vmware.vcloud.vApp+xml" name="Server1" />
+</Task>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/taskslist-hosting.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/taskslist-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/taskslist-hosting.xml
new file mode 100644
index 0000000..1511d13
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/taskslist-hosting.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tasks xmlns="http://www.vmware.com/vcloud/tasks" xmlns:common="http://www.vmware.com/vcloud/v0.8"
+ xmlns:task="http://www.vmware.com/vcloud/task"
+ xsi:schemaLocation="http://www.vmware.com/vcloud/tasks
+ https://vcloud.safesecureweb.com/ns/vcloud/tasks-1.0.xsd
+ http://www.vmware.com/vcloud/v0.8
+ https://vcloud.safesecureweb.com/ns/vcloud/common-1.0.xsd
+ http://www.vmware.com/vcloud/task
+ https://vcloud.safesecureweb.com/ns/vcloud/task-1.0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <Link rel="self"
+ href="https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849"
+ type="application/vnd.vmware.vcloud.tasksList+xml" />
+</tasks>
\ No newline at end of file
[06/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java
new file mode 100644
index 0000000..c5094d5
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.internal.BaseVCloudApiTest;
+import org.jclouds.vcloud.options.CatalogItemOptions;
+import org.jclouds.vcloud.xml.CatalogHandler;
+import org.jclouds.vcloud.xml.CatalogItemHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code CatalogApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "CatalogApiTest")
+public class CatalogApiTest extends BaseVCloudApiTest<CatalogApi> {
+
+ public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CatalogApi.class, "getCatalog", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, CatalogHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testCatalogInOrg() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CatalogApi.class, "findCatalogInOrgNamed", String.class, String.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org", "catalog"));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, CatalogHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CatalogApi.class, "getCatalogItem", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, CatalogItemHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CatalogApi.class, "findCatalogItemInOrgCatalogNamed", String.class,
+ String.class, String.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org", "catalog", "item"));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, CatalogItemHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testAddVAppTemplateOrMediaImageToCatalogAndNameItem() throws SecurityException, NoSuchMethodException,
+ IOException {
+ Invokable<?, ?> method = method(CatalogApi.class, "addVAppTemplateOrMediaImageToCatalogAndNameItem", URI.class,
+ URI.class, String.class, CatalogItemOptions[].class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI.create("http://fooentity"), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), "myname", CatalogItemOptions.Builder
+ .description("mydescription")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/catalog/1/catalogItems HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
+ assertPayloadEquals(
+ request,
+ "<CatalogItem xmlns=\"http://www.vmware.com/vcloud/v1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"myname\" xsi:schemaLocation=\"http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd\"><Description>mydescription</Description><Entity href=\"http://fooentity\"/></CatalogItem>",
+ "application/vnd.vmware.vcloud.catalogItem+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, CatalogItemHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java
new file mode 100644
index 0000000..b7d7102
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "live", enabled = true, singleThreaded = true, testName = "NetworkApiLiveTest")
+public class NetworkApiLiveTest extends BaseVCloudApiLiveTest {
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java
new file mode 100644
index 0000000..d6ce452
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.internal.BaseVCloudApiTest;
+import org.jclouds.vcloud.xml.OrgNetworkHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code NetworkApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "NetworkApiTest")
+public class NetworkApiTest extends BaseVCloudApiTest<NetworkApi> {
+
+ public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(NetworkApi.class, "getNetwork", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/network/2")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/network/2 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, OrgNetworkHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testFindNetworkInOrgVDCNamed() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(NetworkApi.class, "findNetworkInOrgVDCNamed", String.class, String.class,
+ String.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org", "vdc", "network"));
+
+ assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/network/1990 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, OrgNetworkHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java
new file mode 100644
index 0000000..d1c8528
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "live", enabled = true, singleThreaded = true, testName = "OrgApiLiveTest")
+public class OrgApiLiveTest extends BaseVCloudApiLiveTest {
+
+ @Test
+ public void testListOrgs() throws Exception {
+ for (ReferenceType response : getVCloudApi().getOrgApi().listOrgs().values()) {
+ assertNotNull(response);
+ assertNotNull(response.getName());
+ assertNotNull(response.getHref());
+ assertEquals(getVCloudApi().getOrgApi().getOrg(response.getHref()).getName(), response.getName());
+ assertEquals(getVCloudApi().getOrgApi().findOrgNamed(response.getName()).getName(), response.getName());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java
new file mode 100644
index 0000000..1080dde
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.internal.BaseVCloudApiTest;
+import org.jclouds.vcloud.xml.OrgHandler;
+import org.jclouds.vcloud.xml.OrgListHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code OrgApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "OrgApiTest")
+public class OrgApiTest extends BaseVCloudApiTest<OrgApi> {
+
+ public void testlistOrgs() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(OrgApi.class, "listOrgs");
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.orgList+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, OrgListHandler.class);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(request);
+ }
+
+ public void testOrg() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(OrgApi.class, "getOrg", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/org/1")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, OrgHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testFindOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(OrgApi.class, "findOrgNamed", String.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org"));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, OrgHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java
new file mode 100644
index 0000000..5be4bf4
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "live", enabled = true, singleThreaded = true, testName = "TaskApiLiveTest")
+public class TaskApiLiveTest extends BaseVCloudApiLiveTest {
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java
new file mode 100644
index 0000000..75518f0
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.internal.BaseVCloudApiTest;
+import org.jclouds.vcloud.xml.TaskHandler;
+import org.jclouds.vcloud.xml.TasksListHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code TaskApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "TaskApiTest")
+public class TaskApiTest extends BaseVCloudApiTest<TaskApi> {
+
+ public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(TaskApi.class, "getTasksList", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TasksListHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testFindTasksListInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(TaskApi.class, "findTasksListInOrgNamed", String.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org"));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TasksListHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(TaskApi.class, "getTask", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/task/1")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/task/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(TaskApi.class, "cancelTask", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/task/1")));
+
+ assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/task/1/action/cancel HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java
new file mode 100644
index 0000000..cf4aca3
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.testng.Assert.assertNotNull;
+
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VAppApiLiveTest")
+public class VAppApiLiveTest extends BaseVCloudApiLiveTest {
+
+ @Test
+ public void testGetVApp() throws Exception {
+ Org org = getVCloudApi().getOrgApi().findOrgNamed(null);
+ for (ReferenceType vdc : org.getVDCs().values()) {
+ VDC response = getVCloudApi().getVDCApi().getVDC(vdc.getHref());
+ for (ReferenceType item : response.getResourceEntities().values()) {
+ if (item.getType().equals(VCloudMediaType.VAPP_XML)) {
+ try {
+ VApp app = getVCloudApi().getVAppApi().getVApp(item.getHref());
+ assertNotNull(app);
+ } catch (RuntimeException e) {
+
+ }
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java
new file mode 100644
index 0000000..73ca9a1
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java
@@ -0,0 +1,313 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.util.Strings2;
+import org.jclouds.vcloud.internal.BaseVCloudApiTest;
+import org.jclouds.vcloud.options.CloneVAppOptions;
+import org.jclouds.vcloud.xml.TaskHandler;
+import org.jclouds.vcloud.xml.VAppHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code VAppApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "VAppApiTest")
+public class VAppApiTest extends BaseVCloudApiTest<VAppApi> {
+
+ public void testopyVAppToVDCAndName() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "copyVAppToVDCAndName", URI.class, URI.class, String.class,
+ CloneVAppOptions[].class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapp"));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp-default.xml")),
+ "application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testCopyVAppToVDCAndNameOptions() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "copyVAppToVDCAndName", URI.class, URI.class, String.class,
+ CloneVAppOptions[].class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions()
+ .deploy().powerOn().description("The description of the new vApp")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp.xml")),
+ "application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testMoveVAppToVDCAndRenameOptions() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "moveVAppToVDCAndRename", URI.class, URI.class, String.class,
+ CloneVAppOptions[].class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions()
+ .deploy().powerOn().description("The description of the new vApp")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/moveVApp.xml")),
+ "application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "deployVApp", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>",
+ "application/vnd.vmware.vcloud.deployVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testDeployAndPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "deployAndPowerOnVApp", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" powerOn=\"true\"/>",
+ "application/vnd.vmware.vcloud.deployVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "getVApp", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, VAppHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testRebootVApp() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "rebootVApp", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reboot HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "undeployVApp", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>",
+ "application/vnd.vmware.vcloud.undeployVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testUndeployAndSaveStateOfVAppSaveState() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "undeployAndSaveStateOfVApp", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request,
+ "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" saveState=\"true\"/>",
+ "application/vnd.vmware.vcloud.undeployVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "deleteVApp", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request, "DELETE https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "powerOnVApp", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testPowerOffVApp() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "powerOffVApp", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testResetVApp() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "resetVApp", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testSuspendVApp() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "suspendVApp", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testShutdownVApp() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppApi.class, "shutdownVApp", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java
new file mode 100644
index 0000000..e883235
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
+import org.jclouds.vcloud.options.CatalogItemOptions;
+import org.jclouds.vcloud.predicates.TaskSuccess;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+
+@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VAppTemplateApiLiveTest")
+public class VAppTemplateApiLiveTest extends BaseVCloudApiLiveTest {
+ @Test
+ public void testGetVAppTemplate() throws Exception {
+ Org org = getVCloudApi().getOrgApi().findOrgNamed(null);
+ for (ReferenceType cat : org.getCatalogs().values()) {
+ Catalog response = getVCloudApi().getCatalogApi().getCatalog(cat.getHref());
+ for (ReferenceType resource : response.values()) {
+ if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
+ CatalogItem item = getVCloudApi().getCatalogApi().getCatalogItem(resource.getHref());
+ if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
+ VAppTemplate template = getVCloudApi().getVAppTemplateApi().getVAppTemplate(item.getEntity().getHref());
+ if (template != null) {
+ // the UUID in the href is the only way to actually link templates
+ assertEquals(template.getHref(), item.getEntity().getHref());
+ } else {
+ // null can be no longer available or auth exception
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testGetOvfEnvelopeForVAppTemplate() throws Exception {
+ Org org = getVCloudApi().getOrgApi().findOrgNamed(null);
+ for (ReferenceType cat : org.getCatalogs().values()) {
+ Catalog response = getVCloudApi().getCatalogApi().getCatalog(cat.getHref());
+ for (ReferenceType resource : response.values()) {
+ if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
+ CatalogItem item = getVCloudApi().getCatalogApi().getCatalogItem(resource.getHref());
+ if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
+ getVCloudApi().getVAppTemplateApi().getOvfEnvelopeForVAppTemplate(item.getEntity().getHref());
+ // null can be no longer available or auth exception
+ }
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testFindVAppTemplate() throws Exception {
+ Org org = getVCloudApi().getOrgApi().findOrgNamed(null);
+ for (ReferenceType cat : org.getCatalogs().values()) {
+ Catalog response = getVCloudApi().getCatalogApi().getCatalog(cat.getHref());
+ for (ReferenceType resource : response.values()) {
+ if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
+ CatalogItem item = getVCloudApi().getCatalogApi().getCatalogItem(resource.getHref());
+ if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
+ VAppTemplate template = getVCloudApi().getVAppTemplateApi().findVAppTemplateInOrgCatalogNamed(
+ org.getName(), response.getName(), item.getEntity().getName());
+ if (template != null) {
+ // the UUID in the href is the only way to actually link templates
+ assertEquals(template.getHref(), item.getEntity().getHref());
+ } else {
+ // null can be no longer available or auth exception
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testCaptureVApp() throws Exception {
+ String group = prefix + "cap";
+ NodeMetadata node = null;
+ VAppTemplate vappTemplate = null;
+ CatalogItem item = null;
+ try {
+
+ node = getOnlyElement(client.createNodesInGroup(group, 1));
+
+ Predicate<URI> taskTester = retry(new TaskSuccess(getVCloudApi()), 600, 5, SECONDS);
+
+ // I have to undeploy first
+ Task task = getVCloudApi().getVAppApi().undeployVApp(URI.create(node.getId()));
+
+ // wait up to ten minutes per above
+ assert taskTester.apply(task.getHref()) : node;
+
+ VApp vApp = getVCloudApi().getVAppApi().getVApp(URI.create(node.getId()));
+
+ // wait up to ten minutes per above
+ assertEquals(vApp.getStatus(), Status.OFF);
+
+ // vdc is equiv to the node's location
+ // vapp uri is the same as the node's id
+ vappTemplate = getVCloudApi().getVAppTemplateApi().captureVAppAsTemplateInVDC(URI.create(node.getId()),
+ group, URI.create(node.getLocation().getId()));
+
+ assertEquals(vappTemplate.getName(), group);
+
+ task = vappTemplate.getTasks().get(0);
+
+ // wait up to ten minutes per above
+ assert taskTester.apply(task.getHref()) : vappTemplate;
+
+ item = getVCloudApi().getCatalogApi().addVAppTemplateOrMediaImageToCatalogAndNameItem(
+ vappTemplate.getHref(),
+ getVCloudApi().getCatalogApi().findCatalogInOrgNamed(null, null).getHref(), "fooname",
+ CatalogItemOptions.Builder.description("description").properties(ImmutableMap.of("foo", "bar")));
+
+ assertEquals(item.getName(), "fooname");
+ assertEquals(item.getDescription(), "description");
+ assertEquals(item.getProperties(), ImmutableMap.of("foo", "bar"));
+ assertEquals(item.getEntity().getName(), "fooname");
+ assertEquals(item.getEntity().getHref(), vappTemplate.getHref());
+ assertEquals(item.getEntity().getType(), vappTemplate.getType());
+
+ } finally {
+ if (item != null)
+ getVCloudApi().getCatalogApi().deleteCatalogItem(item.getHref());
+ if (vappTemplate != null)
+ getVCloudApi().getVAppTemplateApi().deleteVAppTemplate(vappTemplate.getHref());
+ if (node != null)
+ client.destroyNode(node.getId());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java
new file mode 100644
index 0000000..12bef2e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.ovf.xml.EnvelopeHandler;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.util.Strings2;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.jclouds.vcloud.domain.network.NetworkConfig;
+import org.jclouds.vcloud.internal.BaseVCloudApiTest;
+import org.jclouds.vcloud.options.CaptureVAppOptions;
+import org.jclouds.vcloud.options.CloneVAppTemplateOptions;
+import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
+import org.jclouds.vcloud.xml.TaskHandler;
+import org.jclouds.vcloud.xml.VAppHandler;
+import org.jclouds.vcloud.xml.VAppTemplateHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code VAppTemplateApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "VAppTemplateApiTest")
+public class VAppTemplateApiTest extends BaseVCloudApiTest<VAppTemplateApi> {
+
+ public void testCreateVAppInVDCByInstantiatingTemplate() throws SecurityException, NoSuchMethodException,
+ IOException {
+ Invokable<?, ?> method = method(VAppTemplateApi.class, "createVAppInVDCByInstantiatingTemplate", String.class,
+ URI.class, URI.class, InstantiateVAppTemplateOptions[].class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("my-vapp", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"),
+ addNetworkConfig(new NetworkConfig("aloha", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED))));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
+ assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
+ "/instantiationparams-network.xml")), "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml",
+ false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, VAppHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testCreateVAppInVDCByInstantiatingTemplateOptionsIllegalName() throws SecurityException,
+ NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppTemplateApi.class, "createVAppInVDCByInstantiatingTemplate", String.class,
+ URI.class, URI.class, InstantiateVAppTemplateOptions[].class);
+ processor.createRequest(method, ImmutableList.<Object> of("CentOS 01", URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), addNetworkConfig(new NetworkConfig(null,
+ URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), null))));
+ }
+
+ public void testcopyVAppTemplateToVDCAndName() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppTemplateApi.class, "copyVAppTemplateToVDCAndName", URI.class, URI.class,
+ String.class, CloneVAppTemplateOptions[].class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181"), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapptemplate"));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
+ "/copyVAppTemplate-default.xml")), "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testcopyVAppTemplateToVDCAndNameOptions() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppTemplateApi.class, "copyVAppTemplateToVDCAndName", URI.class, URI.class,
+ String.class, CloneVAppTemplateOptions[].class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server",
+ new CloneVAppTemplateOptions().description("The description of the new vAppTemplate")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVAppTemplate.xml")),
+ "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testmoveVAppTemplateToVDCAndRenameOptions() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppTemplateApi.class, "moveVAppTemplateToVDCAndRename", URI.class, URI.class,
+ String.class, CloneVAppTemplateOptions[].class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server",
+ new CloneVAppTemplateOptions().description("The description of the new vAppTemplate")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/moveVAppTemplate.xml")),
+ "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testcaptureVAppAsTemplateInVDC() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppTemplateApi.class, "captureVAppAsTemplateInVDC", URI.class, String.class,
+ URI.class, CaptureVAppOptions[].class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-template", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
+ assertPayloadEquals(request, Strings2
+ .toStringAndClose(getClass().getResourceAsStream("/captureVApp-default.xml")),
+ "application/vnd.vmware.vcloud.captureVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testcaptureVAppAsTemplateInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppTemplateApi.class, "captureVAppAsTemplateInVDC", URI.class, String.class,
+ URI.class, CaptureVAppOptions[].class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "my-template", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), new CaptureVAppOptions()
+ .withDescription("The description of the new vApp Template")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
+ assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/captureVApp.xml")),
+ "application/vnd.vmware.vcloud.captureVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppTemplateApi.class, "findVAppTemplateInOrgCatalogNamed", String.class,
+ String.class, String.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org", "catalog", "template"));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppTemplateApi.class, "getVAppTemplate", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testGetOvfEnvelopeForVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VAppTemplateApi.class, "getOvfEnvelopeForVAppTemplate", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2/ovf HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: text/xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, EnvelopeHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java
new file mode 100644
index 0000000..be1efdc
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VDCApiLiveTest")
+public class VDCApiLiveTest extends BaseVCloudApiLiveTest {
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java
new file mode 100644
index 0000000..0296453
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.NoSuchElementException;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.internal.BaseVCloudApiTest;
+import org.jclouds.vcloud.xml.VDCHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code VDCApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "VDCApiTest")
+public class VDCApiTest extends BaseVCloudApiTest<VDCApi> {
+
+ @Test(expectedExceptions = NoSuchElementException.class)
+ public void testFindVDCInOrgNamedBadVDC() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VDCApi.class, "findVDCInOrgNamed", String.class, String.class);
+ processor.createRequest(method, ImmutableList.<Object> of("org", "vdc1"));
+ }
+
+ @Test(expectedExceptions = NoSuchElementException.class)
+ public void testFindVDCInOrgNamedBadOrg() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VDCApi.class, "findVDCInOrgNamed", String.class, String.class);
+ processor.createRequest(method, ImmutableList.<Object> of("org1", "vdc"));
+ }
+
+ public void testFindVDCInOrgNamedNullOrg() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VDCApi.class, "findVDCInOrgNamed", String.class, String.class);
+ GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "vdc"));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, VDCHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testFindVDCInOrgNamedNullOrgAndVDC() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VDCApi.class, "findVDCInOrgNamed", String.class, String.class);
+ GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, null));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, VDCHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VDCApi.class, "getVDC", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, VDCHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java
new file mode 100644
index 0000000..f6b3d92
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.collect.Iterables.get;
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static com.google.common.io.BaseEncoding.base64;
+import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import org.jclouds.compute.domain.ExecResponse;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.common.net.HostAndPort;
+
+/**
+ * This tests that we can use guest customization as an alternative to bootstrapping with ssh. There
+ * are a few advantages to this, including the fact that it can work inside google appengine where
+ * network sockets (ssh:22) are prohibited.
+ */
+@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VmApiLiveTest")
+public class VmApiLiveTest extends BaseVCloudApiLiveTest {
+
+ @Test
+ public void testGetThumbnailOfVm() throws Exception {
+ Org org = getVCloudApi().getOrgApi().findOrgNamed(null);
+ for (ReferenceType vdc : org.getVDCs().values()) {
+ VDC response = getVCloudApi().getVDCApi().getVDC(vdc.getHref());
+ for (ReferenceType item : response.getResourceEntities().values()) {
+ if (item.getType().equals(VCloudMediaType.VAPP_XML)) {
+ try {
+ VApp app = getVCloudApi().getVAppApi().getVApp(item.getHref());
+ assertNotNull(app);
+ for (Vm vm : app.getChildren()) {
+ assert getVCloudApi().getVmApi().getScreenThumbnailForVm(vm.getHref()) != null;
+ }
+ } catch (RuntimeException e) {
+
+ }
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testGetVm() throws Exception {
+ Org org = getVCloudApi().getOrgApi().findOrgNamed(null);
+ for (ReferenceType vdc : org.getVDCs().values()) {
+ VDC response = getVCloudApi().getVDCApi().getVDC(vdc.getHref());
+ for (ReferenceType item : response.getResourceEntities().values()) {
+ if (item.getType().equals(VCloudMediaType.VAPP_XML)) {
+ try {
+ VApp app = getVCloudApi().getVAppApi().getVApp(item.getHref());
+ assertNotNull(app);
+ for (Vm vm : app.getChildren()) {
+ assertEquals(getVCloudApi().getVmApi().getVm(vm.getHref()).getHref(), vm.getHref());
+ }
+ } catch (RuntimeException e) {
+
+ }
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testExtendedOptionsWithCustomizationScript() throws Exception {
+ String PARSE_VMTOOLSD = "vmtoolsd --cmd=\"info-get guestinfo.ovfenv\" |grep vCloud_CustomizationInfo|sed 's/.*value=\"\\(.*\\)\".*/\\1/g'";
+
+ String group = prefix + "cus";
+
+ NodeMetadata node = null;
+ try {
+
+ TemplateOptions options = client.templateOptions();
+ options.blockOnPort(22, 180);
+ options.as(VCloudTemplateOptions.class).customizationScript(script);
+ options.as(VCloudTemplateOptions.class).description(group);
+ node = getOnlyElement(client.createNodesInGroup(group, 1, options));
+
+ VApp vapp = client.getContext().unwrapApi(VCloudApi.class).getVAppApi().getVApp(
+ node.getUri());
+ assertEquals(vapp.getDescription(), group);
+
+ Vm vm = Iterables.get(vapp.getChildren(), 0);
+ String apiOutput = vm.getGuestCustomizationSection().getCustomizationScript();
+ checkApiOutput(apiOutput);
+
+ ExecResponse vmTools = client.runScriptOnNode(node.getId(), PARSE_VMTOOLSD,
+ wrapInInitScript(false).runAsRoot(false));
+ checkApiOutput(new String(base64().decode(vmTools.getOutput().trim()), UTF_8));
+
+ ExecResponse foo = client.runScriptOnNode(node.getId(), "cat /root/foo.txt", wrapInInitScript(false)
+ .runAsRoot(false));
+ checkCustomizationOccurred(foo);
+
+ } finally {
+ if (node != null)
+ client.destroyNode(node.getId());
+ }
+ }
+
+ protected void checkCustomizationOccurred(ExecResponse exec) {
+ // note that vmwaretools throws in \r characters when executing scripts
+ assert exec.getOutput().equals(iLoveAscii + "\r\n") : exec;
+ }
+
+ protected void checkApiOutput(String apiOutput) {
+ checkApiOutput1_0_1(apiOutput);
+ }
+
+ // make sure the script has a lot of screwy characters, knowing our parser
+ // throws-out \r
+ protected String iLoveAscii = "I '\"love\"' {asc|!}*&";
+
+ String script = "cat > /root/foo.txt<<EOF\n" + iLoveAscii + "\nEOF\n";
+
+ protected void checkApiOutput1_0_1(String apiOutput) {
+ // in 1.0.1, vcloud director seems to pass through characters via api
+ // flawlessly
+ assertEquals(apiOutput, script);
+ }
+
+ protected void checkApiOutput1_0_0(String apiOutput) {
+ // in 1.0.0, vcloud director seems to remove all newlines
+ assertEquals(apiOutput, script.replace("\n", ""));
+ }
+
+ protected HostAndPort getSocket(NodeMetadata node) {
+ return HostAndPort.fromParts(get(node.getPublicAddresses(), 0), 22);
+ }
+
+}
[46/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java
new file mode 100644
index 0000000..e67366e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java
@@ -0,0 +1,1187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Optional.fromNullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.getLast;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Represents a virtual machine.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/>
+ */
+@Beta
+public class Instance extends Resource {
+
+ public enum Status {
+ PROVISIONING,
+ STAGING,
+ RUNNING,
+ STOPPING,
+ STOPPED,
+ TERMINATED
+ }
+
+ protected final Tags tags;
+ protected final URI machineType;
+ protected final Status status;
+ protected final Optional<String> statusMessage;
+ protected final URI zone;
+ protected final Set<NetworkInterface> networkInterfaces;
+ protected final Set<AttachedDisk> disks;
+ protected final Metadata metadata;
+ protected final Set<ServiceAccount> serviceAccounts;
+
+ protected Instance(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Tags tags, URI machineType, Status status, String statusMessage,
+ URI zone, Set<NetworkInterface> networkInterfaces, Set<AttachedDisk> disks,
+ Metadata metadata, Set<ServiceAccount> serviceAccounts) {
+ super(Kind.INSTANCE, id, creationTimestamp, selfLink, name, description);
+ this.tags = checkNotNull(tags, "tags");
+ this.machineType = checkNotNull(machineType, "machineType of %s", name);
+ this.status = checkNotNull(status, "status");
+ this.statusMessage = fromNullable(statusMessage);
+ this.zone = checkNotNull(zone, "zone of %s", name);
+ this.networkInterfaces = networkInterfaces == null ? ImmutableSet.<NetworkInterface>of() : networkInterfaces;
+ this.disks = disks == null ? ImmutableSet.<AttachedDisk>of() : disks;
+ this.metadata = checkNotNull(metadata, "metadata");
+ this.serviceAccounts = serviceAccounts == null ? ImmutableSet.<ServiceAccount>of() : serviceAccounts;
+ }
+
+ /**
+ * Used to identify valid sources or targets for network firewalls. Provided by the client when the instance is
+ * created. Each tag must be unique, must be 1-63 characters long, and comply with RFC1035.
+ *
+ * @return an optional set of items applied to this instance.
+ */
+ public Tags getTags() {
+ return tags;
+ }
+
+ /**
+ * @return URL of the machine type resource describing which machine type to use to host the instance.
+ */
+ public URI getMachineType() {
+ return machineType;
+ }
+
+ /**
+ * @return Instance status
+ */
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * @return an optional, human-readable explanation of the status.
+ */
+ @Nullable
+ public Optional<String> getStatusMessage() {
+ return statusMessage;
+ }
+
+ /**
+ * @return URL of the zone resource describing where this instance should be hosted; provided by the client when
+ * the instance is created.
+ */
+ public URI getZone() {
+ return zone;
+ }
+
+ /**
+ * @return set of NetworkInterfaces
+ * @see NetworkInterface
+ */
+ public Set<NetworkInterface> getNetworkInterfaces() {
+ return networkInterfaces;
+ }
+
+ /**
+ * @return array of disks associated with this instance. Persistent disks must be created before
+ * you can assign them.
+ * @see org.jclouds.googlecomputeengine.domain.Instance.AttachedDisk
+ */
+ public Set<AttachedDisk> getDisks() {
+ return disks;
+ }
+
+ /**
+ * @return metadata for this instance
+ */
+ public Metadata getMetadata() {
+ return metadata;
+ }
+
+ /**
+ * @return list of service accounts each with specified scopes.
+ * @see ServiceAccount
+ */
+ public Set<ServiceAccount> getServiceAccounts() {
+ return serviceAccounts;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Instance that = Instance.class.cast(obj);
+ return equal(this.kind, that.kind)
+ && equal(this.name, that.name)
+ && equal(this.zone, that.zone);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .omitNullValues()
+ .add("items", tags)
+ .add("machineType", machineType)
+ .add("status", status)
+ .add("statusMessage", statusMessage.orNull())
+ .add("zone", zone)
+ .add("networkInterfaces", networkInterfaces)
+ .add("disks", disks)
+ .add("metadata", metadata)
+ .add("serviceAccounts", serviceAccounts);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromInstance(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private Tags tags;
+ private URI machineType;
+ private Status status;
+ private String statusMessage;
+ private URI zone;
+ private Metadata metadata;
+ private ImmutableSet.Builder<NetworkInterface> networkInterfaces = ImmutableSet.builder();
+ private ImmutableSet.Builder<AttachedDisk> disks = ImmutableSet.builder();
+ private ImmutableSet.Builder<ServiceAccount> serviceAccounts = ImmutableSet.builder();
+
+
+ /**
+ * @see Instance#getTags()
+ */
+ public Builder tags(Tags tags) {
+ this.tags = tags;
+ return this;
+ }
+
+ /**
+ * @see Instance#getMachineType()
+ */
+ public Builder machineType(URI machineType) {
+ this.machineType = machineType;
+ return this;
+ }
+
+ /**
+ * @see Instance#getStatus()
+ */
+ public Builder status(Status status) {
+ this.status = status;
+ return this;
+ }
+
+ /**
+ * @see Instance#getStatusMessage()
+ */
+ public Builder statusMessage(String statusMessage) {
+ this.statusMessage = statusMessage;
+ return this;
+ }
+
+ /**
+ * @see Instance#getZone()
+ */
+ public Builder zone(URI zone) {
+ this.zone = zone;
+ return this;
+ }
+
+ /**
+ * @see Instance#getNetworkInterfaces()
+ */
+ public Builder addNetworkInterface(NetworkInterface networkInterface) {
+ this.networkInterfaces.add(networkInterface);
+ return this;
+ }
+
+ /**
+ * @see Instance#getNetworkInterfaces()
+ */
+ public Builder networkInterfaces(Set<NetworkInterface> networkInterfaces) {
+ this.networkInterfaces.addAll(networkInterfaces);
+ return this;
+ }
+
+ /**
+ * @see Instance#getDisks()
+ */
+ public Builder addDisk(AttachedDisk disk) {
+ this.disks.add(disk);
+ return this;
+ }
+
+ /**
+ * @see Instance#getDisks()
+ */
+ public Builder disks(Set<AttachedDisk> disks) {
+ this.disks.addAll(disks);
+ return this;
+ }
+
+ /**
+ * @see Instance#getMetadata()
+ */
+ public Builder metadata(Metadata metadata) {
+ this.metadata = metadata;
+ return this;
+ }
+
+ /**
+ * @see Instance#getServiceAccounts()
+ */
+ public Builder addServiceAccount(ServiceAccount serviceAccount) {
+ this.serviceAccounts.add(serviceAccount);
+ return this;
+ }
+
+ /**
+ * @see Instance#getServiceAccounts()
+ */
+ public Builder serviceAccounts(Set<ServiceAccount> serviceAccounts) {
+ this.serviceAccounts.addAll(serviceAccounts);
+ return this;
+ }
+
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Instance build() {
+ return new Instance(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, tags, machineType, status, statusMessage, zone,
+ networkInterfaces.build(), disks.build(), metadata, serviceAccounts.build());
+ }
+
+ public Builder fromInstance(Instance in) {
+ return super.fromResource(in)
+ .tags(in.getTags())
+ .machineType(in.getMachineType())
+ .status(in.getStatus())
+ .statusMessage(in.getStatusMessage().orNull())
+ .zone(in.getZone())
+ .networkInterfaces(in.getNetworkInterfaces())
+ .disks(in.getDisks())
+ .metadata(in.getMetadata())
+ .serviceAccounts(in.getServiceAccounts());
+ }
+ }
+
+
+
+
+ /**
+ * Tags for an instance, with their fingerprint.
+ */
+ public static class Tags {
+ private final String fingerprint;
+ private final Set<String> items;
+
+ @ConstructorProperties({"fingerprint", "items"})
+ public Tags(String fingerprint, @Nullable Set<String> items) {
+ this.fingerprint = checkNotNull(fingerprint);
+ this.items = items == null ? ImmutableSet.<String>of() : items;
+ }
+
+ /**
+ * Used to identify valid sources or targets for network firewalls. Provided by the client when the instance is
+ * created. Each tag must be unique, must be 1-63 characters long, and comply with RFC1035.
+ *
+ * @return an optional set of items applied to this instance.
+ */
+ public Set<String> getItems() {
+ return items;
+ }
+
+ /**
+ * Gets the fingerprint for the items - needed for updating them.
+ *
+ * @return the fingerprint string for the items.
+ */
+ public String getFingerprint() {
+ return fingerprint;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(fingerprint, items);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Tags that = Tags.class.cast(obj);
+ return equal(this.items, that.items)
+ && equal(this.fingerprint, that.fingerprint);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .add("items", items)
+ .add("fingerprint", fingerprint);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static final class Builder {
+
+ private ImmutableSet.Builder<String> items = ImmutableSet.builder();
+ private String fingerprint;
+
+ /**
+ * @see Tags#getItems()
+ */
+ public Builder addItem(String item) {
+ this.items.add(item);
+ return this;
+ }
+
+ /**
+ * @see Tags#getItems()
+ */
+ public Builder items(Set<String> items) {
+ this.items.addAll(items);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.Tags#getFingerprint()
+ */
+ public Builder fingerprint(String fingerprint) {
+ this.fingerprint = fingerprint;
+ return this;
+ }
+
+ public Tags build() {
+ return new Tags(this.fingerprint, this.items.build());
+ }
+
+ public Builder fromTags(Tags in) {
+ return this.fingerprint(in.getFingerprint())
+ .items(in.getItems());
+ }
+ }
+ }
+
+ /**
+ * A disk attached to an Instance.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/>
+ */
+ public static class AttachedDisk {
+
+ private final int index;
+
+ public AttachedDisk(Integer index) {
+ this.index = checkNotNull(index, "index");
+ }
+
+ public boolean isPersistent() {
+ return false;
+ }
+
+ /**
+ * @return a zero-based index to assign to this disk, where 0 is reserved for the boot disk.
+ */
+ public int getIndex() {
+ return index;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(index);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ AttachedDisk that = AttachedDisk.class.cast(obj);
+ return equal(this.index, that.index);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this).add("index", index);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static AttachedDisk ephemeralDiskAtIndex(Integer index) {
+ return new AttachedDisk(index);
+ }
+ }
+
+ public static class PersistentAttachedDisk extends AttachedDisk {
+ public enum Mode {
+ READ_WRITE,
+ READ_ONLY;
+ }
+
+ @ConstructorProperties({"mode", "source", "deviceName", "index", "deleteOnTerminate",
+ "boot"})
+ public PersistentAttachedDisk(Mode mode, URI source, String deviceName, Integer index,
+ boolean deleteOnTerminate, boolean boot) {
+ super(index);
+ this.mode = checkNotNull(mode, "mode");
+ this.source = checkNotNull(source, "source");
+ this.deviceName = fromNullable(deviceName);
+ this.deleteOnTerminate = deleteOnTerminate;
+ this.boot = boot;
+ }
+
+ private final Mode mode;
+ private final URI source;
+ private final boolean deleteOnTerminate;
+ private final Optional<String> deviceName;
+ private final boolean boot;
+
+ @Override
+ public boolean isPersistent() {
+ return true;
+ }
+
+ /**
+ * @return the mode in which to attach this disk, either READ_WRITE or READ_ONLY.
+ */
+ public Mode getMode() {
+ return mode;
+ }
+
+ /**
+ * @return the URL of the persistent disk resource.
+ */
+ public URI getSource() {
+ return source;
+ }
+
+ /**
+ * @return the Name of the persistent disk resource
+ */
+ public String getSourceDiskName() {
+ return getLast(Splitter.on("/").split(source.toString()), null);
+ }
+
+ /**
+ * @return Must be unique within the instance when specified. This represents a unique
+ * device name that is reflected into the /dev/ tree of a Linux operating system running within the
+ * instance. If not specified, a default will be chosen by the system.
+ */
+ public Optional<String> getDeviceName() {
+ return deviceName;
+ }
+
+
+ /**
+ * @return If true, delete the disk and all its data when the associated instance is deleted.
+ */
+ public boolean isDeleteOnTerminate() {
+ return deleteOnTerminate;
+ }
+
+ /**
+ * @return If true, this is the boot disk for this instance.
+ */
+ public boolean isBoot() {
+ return boot;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this).add("boot", boot);
+ }
+
+
+ public static final class Builder {
+
+ private Mode mode;
+ private URI source;
+ private String deviceName;
+ private Integer index;
+ private boolean deleteOnTerminate;
+ private boolean boot;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk#getMode()
+ */
+ public Builder mode(Mode mode) {
+ this.mode = mode;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk#getSource()
+ */
+ public Builder source(URI source) {
+ this.source = source;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk#getDeviceName()
+ */
+ public Builder deviceName(String deviceName) {
+ this.deviceName = deviceName;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.AttachedDisk#getIndex()
+ */
+ public Builder index(Integer index) {
+ this.index = index;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk#isDeleteOnTerminate()
+ */
+ public Builder deleteOnTerminate(Boolean deleteOnTerminate) {
+ this.deleteOnTerminate = deleteOnTerminate;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk#isBoot()
+ */
+ public Builder boot(Boolean boot) {
+ this.boot = boot;
+ return this;
+ }
+
+ public PersistentAttachedDisk build() {
+ return new PersistentAttachedDisk(this.mode, this.source, this.deviceName, this.index,
+ this.deleteOnTerminate, this.boot);
+ }
+
+ public Builder fromPersistentAttachedDisk(PersistentAttachedDisk in) {
+ return this.mode(in.getMode())
+ .source(in.getSource())
+ .deviceName(in.getDeviceName().orNull())
+ .index(in.getIndex())
+ .deleteOnTerminate(in.isDeleteOnTerminate())
+ .boot(in.isBoot());
+ }
+ }
+ }
+
+ /**
+ * A network interface for an Instance.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/>
+ */
+ public static final class NetworkInterface {
+
+ private final String name;
+ private final URI network;
+ private final Optional<String> networkIP;
+ private final Set<AccessConfig> accessConfigs;
+
+ @ConstructorProperties({
+ "name", "network", "networkIP", "accessConfigs"
+ })
+ private NetworkInterface(String name, URI network, String networkIP,
+ Set<AccessConfig> accessConfigs) {
+ this.name = checkNotNull(name, "name");
+ this.network = checkNotNull(network, "network");
+ this.networkIP = fromNullable(networkIP);
+ this.accessConfigs = accessConfigs == null ? ImmutableSet.<AccessConfig>of() : accessConfigs;
+ }
+
+ /**
+ * @return the name of the network interface
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return URL of the network resource attached to this interface.
+ */
+ public URI getNetwork() {
+ return network;
+ }
+
+ /**
+ * @return An IPV4 internal network address to assign to this instance.
+ */
+ public Optional<String> getNetworkIP() {
+ return networkIP;
+ }
+
+ /**
+ * @return array of access configurations for this interface.
+ */
+ public Set<AccessConfig> getAccessConfigs() {
+ return accessConfigs;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, network, networkIP, accessConfigs);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ NetworkInterface that = NetworkInterface.class.cast(obj);
+ return equal(this.name, that.name)
+ && equal(this.network, that.network);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .add("name", name)
+ .add("network", network).add("networkIP", networkIP).add("accessConfigs",
+ accessConfigs);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromNetworkInterface(this);
+ }
+
+ public static class Builder {
+
+ private String name;
+ private URI network;
+ private String networkIP;
+ private ImmutableSet.Builder<AccessConfig> accessConfigs = ImmutableSet.builder();
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface#getName()
+ */
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface#getNetwork()
+ */
+ public Builder network(URI network) {
+ this.network = network;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface#getNetworkIP()
+ */
+ public Builder networkIP(String networkIP) {
+ this.networkIP = networkIP;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface#getAccessConfigs()
+ */
+ public Builder addAccessConfig(AccessConfig accessConfig) {
+ this.accessConfigs.add(accessConfig);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface#getAccessConfigs()
+ */
+ public Builder accessConfigs(Set<AccessConfig> accessConfigs) {
+ this.accessConfigs = ImmutableSet.builder();
+ this.accessConfigs.addAll(accessConfigs);
+ return this;
+ }
+
+ public NetworkInterface build() {
+ return new NetworkInterface(this.name, this.network, this.networkIP, this.accessConfigs.build());
+ }
+
+ public Builder fromNetworkInterface(NetworkInterface in) {
+ return this.network(in.getNetwork())
+ .networkIP(in.getNetworkIP().orNull())
+ .accessConfigs(in.getAccessConfigs());
+ }
+ }
+
+ /**
+ * Access configuration to an instance's network.
+ * <p/>
+ * This specifies how this interface is configured to interact with other network services,
+ * such as connecting to the internet. Currently, ONE_TO_ONE_NAT is the only access config supported.
+ */
+ public static final class AccessConfig {
+
+ public enum Type {
+ ONE_TO_ONE_NAT
+ }
+
+ private Optional<String> name;
+ private Type type;
+ private Optional<String> natIP;
+
+ @ConstructorProperties({
+ "name", "type", "natIP"
+ })
+ private AccessConfig(String name, Type type, String natIP) {
+ this.name = fromNullable(name);
+ this.type = checkNotNull(type, "type");
+ this.natIP = fromNullable(natIP);
+ }
+
+ /**
+ * @return name of this access configuration.
+ */
+ public Optional<String> getName() {
+ return name;
+ }
+
+ /**
+ * @return type of configuration. Must be set to ONE_TO_ONE_NAT. This configures port-for-port NAT to the
+ * internet.
+ */
+ public Type getType() {
+ return type;
+ }
+
+ /**
+ * @return an external IP address associated with this instance, if there is one.
+ */
+ @Nullable
+ public Optional<String> getNatIP() {
+ return natIP;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, type, natIP);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ AccessConfig that = AccessConfig.class.cast(obj);
+ return equal(this.name, that.name)
+ && equal(this.type, that.type)
+ && equal(this.natIP, that.natIP);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .add("name", name).add("type", type).add("natIP", natIP);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromAccessConfig(this);
+ }
+
+ public static class Builder {
+
+ private String name;
+ private Type type;
+ private String natIP;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig#getName()
+ */
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig#getType()
+ */
+ public Builder type(Type type) {
+ this.type = type;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig#getNatIP()
+ */
+ public Builder natIP(String natIP) {
+ this.natIP = natIP;
+ return this;
+ }
+
+ public AccessConfig build() {
+ return new AccessConfig(name, type, natIP);
+ }
+
+ public Builder fromAccessConfig(AccessConfig in) {
+ return this.name(in.getName().orNull())
+ .type(in.getType())
+ .natIP(in.getNatIP().orNull());
+ }
+ }
+ }
+ }
+
+ /**
+ * The output of an instance's serial port;
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/instances/serialPort"/>
+ */
+ public static final class SerialPortOutput {
+
+ private final Optional<String> selfLink;
+ private final String contents;
+
+ @ConstructorProperties({
+ "selfLink", "contents"
+ })
+ public SerialPortOutput(String selfLink, String contents) {
+ this.selfLink = fromNullable(selfLink);
+ this.contents = checkNotNull(contents, "contents");
+ }
+
+ /**
+ * @return unique identifier for the resource; defined by the server (output only).
+ */
+ public Optional<String> getSelfLink() {
+ return selfLink;
+ }
+
+ /**
+ * @return the contents of the console output.
+ */
+ public String getContents() {
+ return contents;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(selfLink, contents);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ SerialPortOutput that = SerialPortOutput.class.cast(obj);
+ return equal(this.selfLink, that.selfLink);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this).add("selfLink", selfLink).add("contents", contents);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromInstanceSerialPortOutput(this);
+ }
+
+ public static final class Builder {
+
+ private String selfLink;
+ private String contents;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.SerialPortOutput#getSelfLink()
+ */
+ public Builder selfLink(String selfLink) {
+ this.selfLink = checkNotNull(selfLink);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.SerialPortOutput#getContents()
+ */
+ public Builder contents(String contents) {
+ this.contents = contents;
+ return this;
+ }
+
+ public SerialPortOutput build() {
+ return new SerialPortOutput(selfLink, contents);
+ }
+
+ public Builder fromInstanceSerialPortOutput(SerialPortOutput in) {
+ return this.selfLink(in.getSelfLink().orNull())
+ .contents(in.getContents());
+ }
+ }
+
+ }
+
+ /**
+ * A service account for which access tokens are to be made available to the instance through metadata queries.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/>
+ */
+ public static final class ServiceAccount {
+
+ private final String email;
+ private final Set<String> scopes;
+
+ @ConstructorProperties({
+ "email", "scopes"
+ })
+ public ServiceAccount(String email, Set<String> scopes) {
+ this.email = checkNotNull(email, "email");
+ this.scopes = checkNotNull(scopes, "scopes");
+ }
+
+ /**
+ * @return email address of the service account.
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * @return the list of scopes to be made available for this service account.
+ */
+ public Set<String> getScopes() {
+ return scopes;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(email, scopes);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ ServiceAccount that = ServiceAccount.class.cast(obj);
+ return equal(this.email, that.email)
+ && equal(this.scopes, that.scopes);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this).add("email", email).add("scopes", scopes);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromInstanceServiceAccount(this);
+ }
+
+ public static final class Builder {
+
+ private String email;
+ private ImmutableSet.Builder<String> scopes = ImmutableSet.builder();
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.ServiceAccount#getEmail()
+ */
+ public Builder email(String email) {
+ this.email = checkNotNull(email);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.ServiceAccount#getScopes()
+ */
+ public Builder addScopes(String scopes) {
+ this.scopes.add(scopes);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance.ServiceAccount#getScopes()
+ */
+ public Builder scopes(Set<String> scopes) {
+ this.scopes.addAll(scopes);
+ return this;
+ }
+
+ public ServiceAccount build() {
+ return new ServiceAccount(email, scopes.build());
+ }
+
+ public Builder fromInstanceServiceAccount(ServiceAccount in) {
+ return this.email(in.getEmail()).scopes(in.getScopes());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceInZone.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceInZone.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceInZone.java
new file mode 100644
index 0000000..09a3088
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceInZone.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class InstanceInZone extends SlashEncodedIds {
+ protected final Instance instance;
+
+ public InstanceInZone(Instance instance, String zoneId) {
+ super(zoneId, checkNotNull(instance, "instance").getName());
+ this.instance = instance;
+ }
+
+ public Instance getInstance() {
+ return instance;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ InstanceInZone that = InstanceInZone.class.cast(obj);
+ return equal(this.instance, that.instance)
+ && equal(this.firstId, that.firstId)
+ && equal(this.secondId, that.secondId);
+ }
+
+ @Override
+ public String toString() {
+ return "[instance=" + instance + ", zoneId=" + firstId + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceTemplate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceTemplate.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceTemplate.java
new file mode 100644
index 0000000..e86bed2
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceTemplate.java
@@ -0,0 +1,445 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig.Type;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+/**
+ * Optional information for creating an instance.
+ */
+public class InstanceTemplate {
+
+ protected String name;
+ protected String description;
+ protected URI machineType;
+ protected URI image;
+ protected Set<Instance.ServiceAccount> serviceAccounts = Sets.newLinkedHashSet();
+
+ protected transient List<PersistentDisk> disks = Lists.newArrayList();
+ protected transient Set<NetworkInterface> networkInterfaces = Sets.newLinkedHashSet();
+ protected transient Map<String, String> metadata = Maps.newLinkedHashMap();
+ protected transient String machineTypeName;
+
+
+ protected InstanceTemplate(URI machineType) {
+ this.machineType = checkNotNull(machineType, "machineType");
+ }
+
+ protected InstanceTemplate(String machineTypeName) {
+ this.machineTypeName = checkNotNull(machineTypeName, "machineTypeName");
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getName()
+ */
+ public InstanceTemplate name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getDescription()
+ */
+ public InstanceTemplate description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getImage()
+ */
+ public InstanceTemplate image(URI image) {
+ this.image = image;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getMachineType()
+ */
+ public InstanceTemplate machineType(URI machineType) {
+ this.machineType = machineType;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getMachineType()
+ */
+ public InstanceTemplate machineType(String machineTypeName) {
+ this.machineTypeName = machineTypeName;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
+ */
+ public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source) {
+ this.disks.add(new PersistentDisk(mode, source, null, false, false));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
+ */
+ public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, Boolean deleteOnTerminate) {
+ this.disks.add(new PersistentDisk(mode, source, null, deleteOnTerminate, false));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
+ */
+ public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, String deviceName, Boolean deleteOnTerminate) {
+ this.disks.add(new PersistentDisk(mode, source, deviceName, deleteOnTerminate, false));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
+ */
+ public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, String deviceName,
+ Boolean deleteOnTerminate, Boolean boot) {
+ this.disks.add(new PersistentDisk(mode, source, deviceName, deleteOnTerminate, boot));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
+ */
+ public InstanceTemplate disks(List<PersistentDisk> disks) {
+ this.disks = Lists.newArrayList();
+ this.disks.addAll(checkNotNull(disks, "disks"));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getNetworkInterfaces()
+ */
+ public InstanceTemplate addNetworkInterface(URI network) {
+ this.networkInterfaces.add(new NetworkInterface(checkNotNull(network, "network"), null, null));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getNetworkInterfaces()
+ */
+ public InstanceTemplate addNetworkInterface(URI network, Type type) {
+ this.networkInterfaces.add(new NetworkInterface(checkNotNull(network, "network"), null,
+ ImmutableSet.of(Instance.NetworkInterface.AccessConfig.builder()
+ .type(type)
+ .build())));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getNetworkInterfaces()
+ */
+ public InstanceTemplate addNetworkInterface(NetworkInterface networkInterface) {
+ this.networkInterfaces.add(networkInterface);
+ return this;
+ }
+
+ public InstanceTemplate networkInterfaces(Set<NetworkInterface> networkInterfaces) {
+ this.networkInterfaces = Sets.newLinkedHashSet(networkInterfaces);
+ return this;
+ }
+
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getMetadata()
+ */
+ public InstanceTemplate addMetadata(String key, String value) {
+ this.metadata.put(checkNotNull(key, "key"), checkNotNull(value, "value of %", key));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getMetadata()
+ */
+ public InstanceTemplate metadata(Map<String, String> metadata) {
+ this.metadata = Maps.newLinkedHashMap();
+ this.metadata.putAll(checkNotNull(metadata, "metadata"));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getServiceAccounts()
+ */
+ public InstanceTemplate addServiceAccount(Instance.ServiceAccount serviceAccount) {
+ this.serviceAccounts.add(checkNotNull(serviceAccount, "serviceAccount"));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getServiceAccounts()
+ */
+ public InstanceTemplate serviceAccounts(Set<Instance.ServiceAccount> serviceAccounts) {
+ this.serviceAccounts = Sets.newLinkedHashSet();
+ this.serviceAccounts.addAll(checkNotNull(serviceAccounts, "serviceAccounts"));
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getDescription()
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
+ */
+ public List<PersistentDisk> getDisks() {
+ return disks;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getImage()
+ */
+ public URI getImage() {
+ return image;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getMachineType()
+ */
+ public URI getMachineType() {
+ return machineType;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getMachineType()
+ */
+ public String getMachineTypeName() {
+ return machineTypeName;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getMetadata()
+ */
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getNetworkInterfaces()
+ */
+ public Set<NetworkInterface> getNetworkInterfaces() {
+ return networkInterfaces;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getServiceAccounts()
+ */
+ public Set<Instance.ServiceAccount> getServiceAccounts() {
+ return serviceAccounts;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Instance#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static InstanceTemplate fromInstanceTemplate(InstanceTemplate instanceTemplate) {
+ return Builder.fromInstanceTemplate(instanceTemplate);
+ }
+
+ public static class Builder {
+
+ public InstanceTemplate forMachineType(URI machineType) {
+ return new InstanceTemplate(machineType);
+ }
+
+ public InstanceTemplate forMachineType(String machineTypeName) {
+ return new InstanceTemplate(machineTypeName);
+ }
+
+ public static InstanceTemplate fromInstanceTemplate(InstanceTemplate instanceTemplate) {
+ return InstanceTemplate.builder()
+ .forMachineType(instanceTemplate.getMachineType())
+ .networkInterfaces(instanceTemplate.getNetworkInterfaces())
+ .name(instanceTemplate.getName())
+ .description(instanceTemplate.getDescription())
+ .image(instanceTemplate.getImage())
+ .disks(instanceTemplate.getDisks())
+ .metadata(instanceTemplate.getMetadata())
+ .serviceAccounts(instanceTemplate.getServiceAccounts());
+ }
+ }
+
+
+ public static class PersistentDisk {
+
+ public enum Mode {
+ READ_WRITE,
+ READ_ONLY
+ }
+
+ public PersistentDisk(Mode mode, URI source, String deviceName, Boolean deleteOnTerminate,
+ Boolean boot) {
+ this.mode = checkNotNull(mode, "mode");
+ this.source = checkNotNull(source, "source");
+ this.deviceName = deviceName;
+ this.deleteOnTerminate = checkNotNull(deleteOnTerminate, "deleteOnTerminate");
+ this.boot = checkNotNull(boot, "boot");
+ }
+
+ private final Mode mode;
+ private final URI source;
+ private final Boolean deleteOnTerminate;
+ private final String deviceName;
+ private final Boolean boot;
+
+ /**
+ * @return the mode in which to attach this disk, either READ_WRITE or READ_ONLY.
+ */
+ public Mode getMode() {
+ return mode;
+ }
+
+ /**
+ * @return the URL of the persistent disk resource.
+ */
+ public URI getSource() {
+ return source;
+ }
+
+ /**
+ * @return Must be unique within the instance when specified. This represents a unique
+ * device name that is reflected into the /dev/ tree of a Linux operating system running within the
+ * instance. If not specified, a default will be chosen by the system.
+ */
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+
+ /**
+ * @return If true, delete the disk and all its data when the associated instance is deleted.
+ */
+ public boolean isDeleteOnTerminate() {
+ return deleteOnTerminate;
+ }
+
+ /**
+ * @return If true, boot from this disk.
+ */
+ public boolean isBoot() {
+ return boot;
+ }
+ }
+
+ public static class NetworkInterface {
+
+ private final URI network;
+ private final String networkIP;
+ private final Set<Instance.NetworkInterface.AccessConfig> accessConfigs;
+
+ public NetworkInterface(URI network, String networkIP, Set<Instance.NetworkInterface.AccessConfig>
+ accessConfigs) {
+ this.networkIP = networkIP;
+ this.network = network;
+ this.accessConfigs = accessConfigs != null ? accessConfigs : ImmutableSet.<Instance.NetworkInterface.AccessConfig>of();
+ }
+
+ public Set<Instance.NetworkInterface.AccessConfig> getAccessConfigs() {
+ return accessConfigs;
+ }
+
+ public URI getNetwork() {
+ return network;
+ }
+
+ public String getNetworkIP() {
+ return networkIP;
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof InstanceTemplate) {
+ final InstanceTemplate other = InstanceTemplate.class.cast(object);
+ return equal(description, other.description)
+ && equal(image, other.image)
+ && equal(disks, other.disks)
+ && equal(networkInterfaces, other.networkInterfaces)
+ && equal(metadata, other.metadata)
+ && equal(serviceAccounts, other.serviceAccounts);
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(description, image, disks, networkInterfaces, metadata, serviceAccounts);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ Objects.ToStringHelper toString = Objects.toStringHelper("")
+ .omitNullValues();
+ toString.add("description", description);
+ if (disks.size() > 0)
+ toString.add("disks", disks);
+ if (metadata.size() > 0)
+ toString.add("metadata", metadata);
+ if (serviceAccounts.size() > 0)
+ toString.add("serviceAccounts", serviceAccounts);
+ toString.add("image", image);
+ toString.add("networkInterfaces", networkInterfaces);
+ return toString;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/ListPage.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/ListPage.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/ListPage.java
new file mode 100644
index 0000000..63107e7
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/ListPage.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.googlecomputeengine.domain.Resource.Kind;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Iterator;
+
+import org.jclouds.collect.IterableWithMarker;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * The collection returned from any <code>listFirstPage()</code> method.
+ */
+public class ListPage<T> extends IterableWithMarker<T> {
+
+ private final Kind kind;
+ private final String id;
+ private final URI selfLink;
+ private final String nextPageToken;
+ private final Iterable<T> items;
+
+ @ConstructorProperties({
+ "kind", "id", "selfLink", "nextPageToken", "items"
+ })
+ protected ListPage(Kind kind, String id, URI selfLink, String nextPageToken, Iterable<T> items) {
+ this.id = checkNotNull(id, "id");
+ this.kind = checkNotNull(kind, "kind of %id", id);
+ this.selfLink = checkNotNull(selfLink, "selfLink of %id", id);
+ this.nextPageToken = nextPageToken;
+ this.items = items != null ? ImmutableSet.copyOf(items) : ImmutableSet.<T>of();
+ }
+
+ public Kind getKind() {
+ return kind;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public URI getSelfLink() {
+ return selfLink;
+ }
+
+ @Override
+ public Optional<Object> nextMarker() {
+ return Optional.<Object>fromNullable(nextPageToken);
+ }
+
+ @Override
+ public Iterator<T> iterator() {
+ return checkNotNull(items, "items").iterator();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(kind, id);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ ListPage<?> that = ListPage.class.cast(obj);
+ return equal(this.kind, that.kind)
+ && equal(this.id, that.id);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("kind", kind)
+ .add("id", id)
+ .add("selfLink", selfLink)
+ .add("nextPageToken", nextPageToken)
+ .add("items", items);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static <T> Builder<T> builder() {
+ return new Builder<T>();
+ }
+
+ public Builder<T> toBuilder() {
+ return new Builder<T>().fromPagedList(this);
+ }
+
+ public static final class Builder<T> {
+
+ private Kind kind;
+ private String id;
+ private URI selfLink;
+ private String nextPageToken;
+ private ImmutableSet.Builder<T> items = ImmutableSet.builder();
+
+ public Builder<T> kind(Kind kind) {
+ this.kind = kind;
+ return this;
+ }
+
+ public Builder<T> id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ public Builder<T> selfLink(URI selfLink) {
+ this.selfLink = selfLink;
+ return this;
+ }
+
+ public Builder<T> addItem(T item) {
+ this.items.add(item);
+ return this;
+ }
+
+ public Builder<T> items(Iterable<T> items) {
+ this.items.addAll(items);
+ return this;
+ }
+
+ public Builder<T> nextPageToken(String nextPageToken) {
+ this.nextPageToken = nextPageToken;
+ return this;
+ }
+
+ public ListPage<T> build() {
+ return new ListPage<T>(kind, id, selfLink, nextPageToken, items.build());
+ }
+
+ public Builder<T> fromPagedList(ListPage<T> in) {
+ return this
+ .kind(in.getKind())
+ .id(in.getId())
+ .selfLink(in.getSelfLink())
+ .nextPageToken((String) in.nextMarker().orNull())
+ .items(in);
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java
new file mode 100644
index 0000000..6a538e5
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java
@@ -0,0 +1,348 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Optional.fromNullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+import java.util.List;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Represents a machine type used to host an instance.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/machineTypes"/>
+ */
+@Beta
+public final class MachineType extends Resource {
+
+ private final Integer guestCpus;
+ private final Integer memoryMb;
+ private final List<ScratchDisk> scratchDisks;
+ private final Integer maximumPersistentDisks;
+ private final Long maximumPersistentDisksSizeGb;
+ private final String zone;
+ private final Optional<Deprecated> deprecated;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "guestCpus", "memoryMb",
+ "scratchDisks", "maximumPersistentDisks", "maximumPersistentDisksSizeGb", "zone", "deprecated"
+ })
+ private MachineType(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ int guestCpus, int memoryMb, List<ScratchDisk> scratchDisks,
+ int maximumPersistentDisks, long maximumPersistentDisksSizeGb, String zone,
+ @Nullable Deprecated deprecated) {
+ super(Kind.MACHINE_TYPE, id, creationTimestamp, selfLink, name, description);
+ this.guestCpus = checkNotNull(guestCpus, "guestCpus of %s", name);
+ this.memoryMb = checkNotNull(memoryMb, "memoryMb of %s", name);
+ this.scratchDisks = scratchDisks == null ? ImmutableList.<ScratchDisk>of() : scratchDisks;
+ this.maximumPersistentDisks = checkNotNull(maximumPersistentDisks, "maximumPersistentDisks of %s", name);
+ this.maximumPersistentDisksSizeGb = maximumPersistentDisksSizeGb;
+ this.zone = checkNotNull(zone, "zone of %s", name);
+ this.deprecated = fromNullable(deprecated);
+ }
+
+ /**
+ * @return count of CPUs exposed to the instance.
+ */
+ public int getGuestCpus() {
+ return guestCpus;
+ }
+
+ /**
+ * @return physical memory assigned to the instance, defined in MB.
+ */
+ public int getMemoryMb() {
+ return memoryMb;
+ }
+
+ /**
+ * @return extended scratch disks assigned to the instance.
+ */
+ public List<ScratchDisk> getScratchDisks() {
+ return scratchDisks;
+ }
+
+ /**
+ * @return maximum persistent disks allowed.
+ */
+ public int getMaximumPersistentDisks() {
+ return maximumPersistentDisks;
+ }
+
+ /**
+ * @return maximum total persistent disks size (GB) allowed.
+ */
+ public long getMaximumPersistentDisksSizeGb() {
+ return maximumPersistentDisksSizeGb;
+ }
+
+ /**
+ * @return the zones that this machine type can run in.
+ */
+ public String getZone() {
+ return zone;
+ }
+
+ /**
+ * @return the deprecation information for this machine type
+ */
+ public Optional<Deprecated> getDeprecated() {
+ return deprecated;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ MachineType that = MachineType.class.cast(obj);
+ return equal(this.kind, that.kind)
+ && equal(this.name, that.name)
+ && equal(this.zone, that.zone);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("guestCpus", guestCpus)
+ .add("memoryMb", memoryMb)
+ .add("scratchDisks", scratchDisks)
+ .add("maximumPersistentDisks", maximumPersistentDisks)
+ .add("maximumPersistentDisksSizeGb", maximumPersistentDisksSizeGb)
+ .add("zone", zone)
+ .add("deprecated", deprecated.orNull());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromMachineType(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private Integer guestCpus;
+ private Integer memoryMb;
+ private Integer imageSpaceGb;
+ private ImmutableList.Builder<ScratchDisk> scratchDisks = ImmutableList.builder();
+ private Integer maximumPersistentDisks;
+ private Long maximumPersistentDisksSizeGb;
+ private String zone;
+ private Deprecated deprecated;
+
+ /**
+ * @see MachineType#getGuestCpus()
+ */
+ public Builder guestCpus(int guesCpus) {
+ this.guestCpus = guesCpus;
+ return this;
+ }
+
+ /**
+ * @see MachineType#getMemoryMb()
+ */
+ public Builder memoryMb(int memoryMb) {
+ this.memoryMb = memoryMb;
+ return this;
+ }
+
+ /**
+ * @see MachineType#getImageSpaceGb()
+ */
+ public Builder imageSpaceGb(int imageSpaceGb) {
+ this.imageSpaceGb = imageSpaceGb;
+ return this;
+ }
+
+ /**
+ * @see MachineType#getScratchDisks()
+ */
+ public Builder addScratchDisk(int diskGb) {
+ this.scratchDisks.add(ScratchDisk.builder().diskGb(diskGb).build());
+ return this;
+ }
+
+ /**
+ * @see MachineType#getScratchDisks()
+ */
+ public Builder scratchDisks(List<ScratchDisk> scratchDisks) {
+ this.scratchDisks.addAll(scratchDisks);
+ return this;
+ }
+
+ /**
+ * @see MachineType#getMaximumPersistentDisks()
+ */
+ public Builder maximumPersistentDisks(int maximumPersistentDisks) {
+ this.maximumPersistentDisks = maximumPersistentDisks;
+ return this;
+ }
+
+ /**
+ * @see MachineType#getMaximumPersistentDisksSizeGb()
+ */
+ public Builder maximumPersistentDisksSizeGb(long maximumPersistentDisksSizeGb) {
+ this.maximumPersistentDisksSizeGb = maximumPersistentDisksSizeGb;
+ return this;
+ }
+
+ /**
+ * @see MachineType#getZone()
+ */
+ public Builder zone(String zone) {
+ this.zone = zone;
+ return this;
+ }
+
+ /**
+ * @see MachineType#getDeprecated()
+ */
+ public Builder deprecated(Deprecated deprecated) {
+ this.deprecated = deprecated;
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public MachineType build() {
+ return new MachineType(id, creationTimestamp, selfLink, name, description, guestCpus, memoryMb,
+ scratchDisks.build(), maximumPersistentDisks, maximumPersistentDisksSizeGb, zone, deprecated);
+ }
+
+
+ public Builder fromMachineType(MachineType in) {
+ return super.fromResource(in).memoryMb(in.getMemoryMb()).scratchDisks(in
+ .getScratchDisks()).maximumPersistentDisks(in.getMaximumPersistentDisks())
+ .maximumPersistentDisksSizeGb(in.getMaximumPersistentDisksSizeGb()).zone(in.getZone())
+ .deprecated(in.getDeprecated().orNull());
+ }
+ }
+
+ /**
+ * An scratch disk of a MachineType
+ */
+ public static final class ScratchDisk {
+
+ private final int diskGb;
+
+ @ConstructorProperties({
+ "diskGb"
+ })
+ private ScratchDisk(int diskGb) {
+ this.diskGb = diskGb;
+ }
+
+ /**
+ * @return size of the scratch disk, defined in GB.
+ */
+ public int getDiskGb() {
+ return diskGb;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(diskGb);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ ScratchDisk that = ScratchDisk.class.cast(obj);
+ return equal(this.diskGb, that.diskGb);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .add("diskGb", diskGb);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromScratchDisk(this);
+ }
+
+ public static class Builder {
+
+ private int diskGb;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.MachineType.ScratchDisk#getDiskGb()
+ */
+ public Builder diskGb(int diskGb) {
+ this.diskGb = diskGb;
+ return this;
+ }
+
+ public ScratchDisk build() {
+ return new ScratchDisk(diskGb);
+ }
+
+ public Builder fromScratchDisk(ScratchDisk in) {
+ return new Builder().diskGb(in.getDiskGb());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineTypeInZone.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineTypeInZone.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineTypeInZone.java
new file mode 100644
index 0000000..0a4b5fb
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineTypeInZone.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class MachineTypeInZone extends SlashEncodedIds {
+ protected final MachineType machineType;
+
+ public MachineTypeInZone(MachineType machineType, String zoneId) {
+ super(zoneId, checkNotNull(machineType, "machineType").getName());
+ this.machineType = machineType;
+ }
+
+ public MachineType getMachineType() {
+ return machineType;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ MachineTypeInZone that = MachineTypeInZone.class.cast(obj);
+ return equal(this.machineType, that.machineType)
+ && equal(this.firstId, that.firstId)
+ && equal(this.secondId, that.secondId);
+ }
+
+ @Override
+ public String toString() {
+ return "[machineType=" + machineType + ", zoneId=" + firstId + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Metadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Metadata.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Metadata.java
new file mode 100644
index 0000000..53a8cfb
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Metadata.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+
+import java.beans.ConstructorProperties;
+import java.util.Map;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Metadata for an instance or project, with their fingerprint.
+ */
+public class Metadata {
+ @Nullable
+ private final String fingerprint;
+ private final Map<String, String> items;
+
+ @ConstructorProperties({"fingerprint", "items"})
+ public Metadata(@Nullable String fingerprint, @Nullable Map<String, String> items) {
+ this.fingerprint = fingerprint;
+ this.items = items == null ? ImmutableMap.<String, String>of() : items;
+ }
+
+ /**
+ * @return an optional map of metadata key/value pairs for this instance/project
+ */
+ public Map<String, String> getItems() {
+ return items;
+ }
+
+ /**
+ * Gets the fingerprint for the items - needed for updating them.
+ *
+ * @return the fingerprint string for the items.
+ */
+ public String getFingerprint() {
+ return fingerprint;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(fingerprint, items);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Metadata that = Metadata.class.cast(obj);
+ return equal(this.items, that.items)
+ && equal(this.fingerprint, that.fingerprint);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .add("items", items)
+ .add("fingerprint", fingerprint);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static final class Builder {
+
+ private ImmutableMap.Builder<String, String> items = ImmutableMap.builder();
+ private String fingerprint;
+
+ /**
+ * @see Metadata#getItems()
+ */
+ public Builder addItem(String key, String value) {
+ this.items.put(key, value);
+ return this;
+ }
+
+ /**
+ * @see Metadata#getItems()
+ */
+ public Builder items(Map<String, String> items) {
+ this.items.putAll(items);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Metadata#getFingerprint()
+ */
+ public Builder fingerprint(String fingerprint) {
+ this.fingerprint = fingerprint;
+ return this;
+ }
+
+ public Metadata build() {
+ return new Metadata(this.fingerprint, this.items.build());
+ }
+
+ public Builder fromMetadata(Metadata in) {
+ return this.fingerprint(in.getFingerprint())
+ .items(in.getItems());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Network.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Network.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Network.java
new file mode 100644
index 0000000..0919c89
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Network.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+
+import static com.google.common.base.Optional.fromNullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+
+/**
+ * Represents a network used to enable instance communication.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/networks"/>
+ */
+@Beta
+public final class Network extends Resource {
+
+ private final String IPv4Range;
+ private final Optional<String> gatewayIPv4;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "IPv4Range",
+ "gatewayIPv4"
+ })
+ protected Network(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ String IPv4Range, String gatewayIPv4) {
+ super(Kind.NETWORK, id, creationTimestamp, selfLink, name, description);
+ this.IPv4Range = checkNotNull(IPv4Range);
+ this.gatewayIPv4 = fromNullable(gatewayIPv4);
+ }
+
+ /**
+ * @return Required; The range of internal addresses that are legal on this network. This range is a CIDR
+ * specification, for example: 192.168.0.0/16.
+ */
+ public String getIPv4Range() {
+ return IPv4Range;
+ }
+
+ /**
+ * This must be within the range specified by IPv4Range, and is typically the first usable address in that range.
+ * If not specified, the default value is the first usable address in IPv4Range.
+ *
+ * @return an optional address that is used for default routing to other networks.
+ */
+ public Optional<String> getGatewayIPv4() {
+ return gatewayIPv4;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .omitNullValues()
+ .add("IPv4Range", IPv4Range)
+ .add("gatewayIPv4", gatewayIPv4.orNull());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromNetwork(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private String IPv4Range;
+ private String gatewayIPv4;
+
+ /**
+ * @see Network#getIPv4Range()
+ */
+ public Builder IPv4Range(String IPv4Range) {
+ this.IPv4Range = IPv4Range;
+ return this;
+ }
+
+ /**
+ * @see Network#getGatewayIPv4()
+ */
+ public Builder gatewayIPv4(String gatewayIPv4) {
+ this.gatewayIPv4 = gatewayIPv4;
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Network build() {
+ return new Network(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, IPv4Range, gatewayIPv4);
+ }
+
+ public Builder fromNetwork(Network in) {
+ return super.fromResource(in);
+ }
+ }
+
+}
[43/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java
new file mode 100644
index 0000000..3d208af
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import java.net.URI;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.Route;
+import org.jclouds.googlecomputeengine.functions.internal.ParseRoutes;
+import org.jclouds.googlecomputeengine.handlers.RouteBinder;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.googlecomputeengine.options.RouteOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+
+/**
+ * Provides access to Routes via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/routess"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface RouteApi {
+
+ /**
+ * Returns the specified route resource
+ *
+ * @param routeName name of the region resource to return.
+ * @return If successful, this method returns a Route resource
+ */
+ @Named("Routes:get")
+ @GET
+ @Path("/global/routes/{route}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ Route get(@PathParam("route") String routeName);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.RouteApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Routes:list")
+ @GET
+ @Path("/global/routes")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseRoutes.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Route> listFirstPage();
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.RouteApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Routes:list")
+ @GET
+ @Path("/global/routes")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseRoutes.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Route> listAtMarker(String marker);
+
+ /**
+ * Retrieves the listFirstPage of route resources available to the specified project.
+ * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
+ * has not been set.
+ *
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the listFirstPage
+ * @see org.jclouds.googlecomputeengine.options.ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("Routes:list")
+ @GET
+ @Path("/global/routes")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseRoutes.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Route> listAtMarker(String marker, ListOptions listOptions);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.RouteApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Routes:list")
+ @GET
+ @Path("/global/routes")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseRoutes.class)
+ @Transform(ParseRoutes.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Route> list();
+
+ /**
+ * A paged version of RegionApi#listFirstPage()
+ *
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see org.jclouds.googlecomputeengine.features.RouteApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see org.jclouds.collect.PagedIterable
+ */
+ @Named("Routes:list")
+ @GET
+ @Path("/global/routes")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseRoutes.class)
+ @Transform(ParseRoutes.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Route> list(ListOptions listOptions);
+
+ /**
+ * Deletes the specified route resource.
+ *
+ * @param routeName name of the route resource to delete.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field. If the route did not exist the result is null.
+ */
+ @Named("Routes:delete")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/routes/{route}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Operation delete(@PathParam("route") String routeName);
+
+ /**
+ * Creates a route resource in the specified project using the data included in the request.
+ *
+ * @param name the name of the route to be inserted.
+ * @param network the network to which to add the route
+ * @param routeOptions the options of the route to add
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Routes:insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/global/routes")
+ @OAuthScopes({COMPUTE_SCOPE})
+ @MapBinder(RouteBinder.class)
+ Operation createInNetwork(@PayloadParam("name") String name,
+ @PayloadParam("network") URI network,
+ @PayloadParam("options") RouteOptions routeOptions);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java
new file mode 100644
index 0000000..e0ac384
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.Snapshot;
+import org.jclouds.googlecomputeengine.functions.internal.ParseSnapshots;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+
+/**
+ * Provides access to Snapshots via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/snapshots"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+public interface SnapshotApi {
+
+ /**
+ * Returns the specified snapshot resource.
+ *
+ * @param snapshotName name of the snapshot resource to return.
+ * @return a Snapshot resource.
+ */
+ @Named("Snapshots:get")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/snapshots/{snapshot}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Snapshot get(@PathParam("snapshot") String snapshotName);
+
+ /**
+ * Deletes the specified snapshot resource.
+ *
+ * @param snapshotName name of the snapshot resource to delete.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Snapshots:delete")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/snapshots/{snapshot}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Operation delete(@PathParam("snapshot") String snapshotName);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.SnapshotApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Snapshots:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/snapshots")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseSnapshots.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Snapshot> listFirstPage();
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.SnapshotApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Snapshots:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/snapshots")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseSnapshots.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Snapshot> listAtMarker(@QueryParam("pageToken") @Nullable String marker);
+
+ /**
+ * Retrieves the listPage of persistent disk resources contained within the specified project and zone.
+ * By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has
+ * not been set.
+ *
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the listPage
+ * @see org.jclouds.googlecomputeengine.options.ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("Snapshots:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/snapshots")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseSnapshots.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Snapshot> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions listOptions);
+
+ /**
+ * A paged version of SnapshotApi#listPage(String)
+ *
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see org.jclouds.collect.PagedIterable
+ * @see org.jclouds.googlecomputeengine.features.SnapshotApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Snapshots:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/snapshots")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseSnapshots.class)
+ @Transform(ParseSnapshots.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Snapshot> list();
+
+ @Named("Snapshots:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/snapshots")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseSnapshots.class)
+ @Transform(ParseSnapshots.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Snapshot> list(ListOptions options);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java
new file mode 100644
index 0000000..26d10a6
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Zone;
+import org.jclouds.googlecomputeengine.functions.internal.ParseZones;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+
+/**
+ * Provides access to Zones via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/zones"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface ZoneApi {
+
+ /**
+ * Returns the specified zone resource
+ *
+ * @param zoneName name of the zone resource to return.
+ * @return If successful, this method returns a Zone resource
+ */
+ @Named("Zones:get")
+ @GET
+ @Path("/zones/{zone}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ Zone get(@PathParam("zone") String zoneName);
+
+ /**
+ * @see ZoneApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Zones:list")
+ @GET
+ @Path("/zones")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseZones.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Zone> listFirstPage();
+
+ /**
+ * @see ZoneApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Zones:list")
+ @GET
+ @Path("/zones")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseZones.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Zone> listAtMarker(String marker);
+
+ /**
+ * Retrieves the listFirstPage of zone resources available to the specified project.
+ * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
+ * has not been set.
+ *
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the listFirstPage
+ * @see ListOptions
+ * @see ListPage
+ */
+ @Named("Zones:list")
+ @GET
+ @Path("/zones")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseZones.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Zone> listAtMarker(String marker, ListOptions listOptions);
+
+ /**
+ * @see ZoneApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Zones:list")
+ @GET
+ @Path("/zones")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseZones.class)
+ @Transform(ParseZones.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Zone> list();
+
+ /**
+ * A paged version of ZoneApi#listFirstPage()
+ *
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see ZoneApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see PagedIterable
+ */
+ @Named("Zones:list")
+ @GET
+ @Path("/zones")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseZones.class)
+ @Transform(ParseZones.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Zone> list(ListOptions listOptions);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java
new file mode 100644
index 0000000..3dd69e1
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.functions.internal.ParseZoneOperations;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+
+/**
+ * Provides access to Operations via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+public interface ZoneOperationApi {
+
+ /**
+ * Retrieves the specified operation resource.
+ *
+ * @param zone the zone the operation is in
+ * @param operationName name of the operation resource to return.
+ * @return If successful, this method returns an Operation resource
+ */
+ @Named("ZoneOperations:get")
+ @GET
+ @Path("/zones/{zone}/operations/{operation}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ Operation getInZone(@PathParam("zone") String zone, @PathParam("operation") String operationName);
+
+ /**
+ * Deletes the specified operation resource.
+ *
+ * @param zone the zone the operation is in
+ * @param operationName name of the operation resource to delete.
+ */
+ @Named("ZoneOperations:delete")
+ @DELETE
+ @Path("/zones/{zone}/operations/{operation}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ void deleteInZone(@PathParam("zone") String zone, @PathParam("operation") String operationName);
+
+ /**
+ * @see ZoneOperationApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("ZoneOperations:list")
+ @GET
+ @Path("/zones/{zone}/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseZoneOperations.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Operation> listFirstPageInZone(@PathParam("zone") String zone);
+
+ /**
+ * @see ZoneOperationApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("ZoneOperations:list")
+ @GET
+ @Path("/zones/{zone}/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseZoneOperations.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Operation> listAtMarkerInZone(@PathParam("zone") String zone,
+ @QueryParam("pageToken") @Nullable String marker);
+
+ /**
+ * Retrieves the listFirstPage of operation resources contained within the specified project.
+ * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
+ * has not been set.
+ *
+ * @param zone the zone to list in
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the list, starting at marker
+ * @see ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("ZoneOperations:list")
+ @GET
+ @Path("/zones/{zone}/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseZoneOperations.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Operation> listAtMarkerInZone(@PathParam("zone") String zone,
+ @QueryParam("pageToken") @Nullable String marker,
+ ListOptions listOptions);
+
+ /**
+ * @see ZoneOperationApi#listInZone(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("ZoneOperations:list")
+ @GET
+ @Path("/zones/{zone}/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseZoneOperations.class)
+ @Transform(ParseZoneOperations.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Operation> listInZone(@PathParam("zone") String zone);
+
+ /**
+ * A paged version of ZoneOperationApi#listFirstPageInZone(String)
+ *
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see PagedIterable
+ * @see ZoneOperationApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("ZoneOperations:list")
+ @GET
+ @Path("/zones/{zone}/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseZoneOperations.class)
+ @Transform(ParseZoneOperations.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Operation> listInZone(@PathParam("zone") String zone, ListOptions listOptions);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/CreateNetworkIfNeeded.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/CreateNetworkIfNeeded.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/CreateNetworkIfNeeded.java
new file mode 100644
index 0000000..c6bc1ac
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/CreateNetworkIfNeeded.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_INTERVAL;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_TIMEOUT;
+import static org.jclouds.util.Predicates2.retry;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.internal.NetworkAndAddressRange;
+import org.jclouds.logging.Logger;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.util.concurrent.Atomics;
+
+@Singleton
+public class CreateNetworkIfNeeded implements Function<NetworkAndAddressRange, Network> {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ protected final GoogleComputeEngineApi api;
+ protected final Supplier<String> userProject;
+ private final Predicate<AtomicReference<Operation>> operationDonePredicate;
+ private final long operationCompleteCheckInterval;
+ private final long operationCompleteCheckTimeout;
+
+ @Inject
+ public CreateNetworkIfNeeded(GoogleComputeEngineApi api,
+ @UserProject Supplier<String> userProject,
+ @Named("global") Predicate<AtomicReference<Operation>> operationDonePredicate,
+ @Named(OPERATION_COMPLETE_INTERVAL) Long operationCompleteCheckInterval,
+ @Named(OPERATION_COMPLETE_TIMEOUT) Long operationCompleteCheckTimeout) {
+ this.api = checkNotNull(api, "api");
+ this.userProject = checkNotNull(userProject, "userProject");
+ this.operationCompleteCheckInterval = checkNotNull(operationCompleteCheckInterval,
+ "operation completed check interval");
+ this.operationCompleteCheckTimeout = checkNotNull(operationCompleteCheckTimeout,
+ "operation completed check timeout");
+ this.operationDonePredicate = checkNotNull(operationDonePredicate, "operationDonePredicate");
+ }
+
+ @Override
+ public Network apply(NetworkAndAddressRange input) {
+ checkNotNull(input, "input");
+
+ Network nw = api.getNetworkApiForProject(userProject.get()).get(input.getName());
+ if (nw != null) {
+ return nw;
+ }
+
+ if (input.getGateway().isPresent()) {
+ AtomicReference<Operation> operation = Atomics.newReference(api.getNetworkApiForProject(userProject
+ .get()).createInIPv4RangeWithGateway(input.getName(), input.getIpV4Range(), input.getGateway().get()));
+ retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
+ MILLISECONDS).apply(operation);
+
+ checkState(!operation.get().getHttpError().isPresent(), "Could not create network, operation failed" + operation);
+ } else {
+ AtomicReference<Operation> operation = Atomics.newReference(api.getNetworkApiForProject(userProject
+ .get()).createInIPv4Range(input.getName(), input.getIpV4Range()));
+ retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
+ MILLISECONDS).apply(operation);
+
+ checkState(!operation.get().getHttpError().isPresent(), "Could not create network, operation failed" + operation);
+ }
+ return checkNotNull(api.getNetworkApiForProject(userProject.get()).get(input.getName()),
+ "no network with name %s was found", input.getName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToPagedIterable.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToPagedIterable.java
new file mode 100644
index 0000000..588be0a
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToPagedIterable.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Predicates.instanceOf;
+import static com.google.common.collect.Iterables.tryFind;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.collect.PagedIterables;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.InvocationContext;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+@Beta
+public abstract class BaseToPagedIterable<T, I extends BaseToPagedIterable<T, I>> implements
+ Function<ListPage<T>, PagedIterable<T>>, InvocationContext<I> {
+
+ private GeneratedHttpRequest request;
+
+ @Override
+ public PagedIterable<T> apply(ListPage<T> input) {
+ if (input.nextMarker() == null)
+ return PagedIterables.of(input);
+
+ Optional<Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class));
+
+ Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
+
+ assert project.isPresent() : String.format("programming error, method %s should have a string param for the "
+ + "project", request.getCaller().get().getInvokable());
+
+ return PagedIterables.advance(
+ input, fetchNextPage(project.get().toString(), (ListOptions) listOptions.orNull()));
+ }
+
+ protected abstract Function<Object, IterableWithMarker<T>> fetchNextPage(String projectName,
+ ListOptions listOptions);
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public I setContext(HttpRequest request) {
+ this.request = GeneratedHttpRequest.class.cast(request);
+ return (I) this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java
new file mode 100644
index 0000000..a4cc52d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Predicates.instanceOf;
+import static com.google.common.collect.Iterables.tryFind;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.collect.PagedIterables;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.InvocationContext;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+@Beta
+public abstract class BaseWithRegionToPagedIterable<T, I extends BaseWithRegionToPagedIterable<T, I>> implements
+ Function<ListPage<T>, PagedIterable<T>>, InvocationContext<I> {
+
+ private GeneratedHttpRequest request;
+
+ @Override
+ public PagedIterable<T> apply(ListPage<T> input) {
+ if (input.nextMarker() == null)
+ return PagedIterables.of(input);
+
+ Optional <Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class));
+
+ Optional<Object> region = tryFind(request.getInvocation().getArgs(), instanceOf(String.class));
+
+ Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
+
+ assert project.isPresent() : String.format("programming error, method %s should have a string param for the "
+ + "project", request.getCaller().get().getInvokable());
+
+ assert region.isPresent() : String.format("programming error, method %s should have a string param for the "
+ + "region", request.getCaller().get().getInvokable());
+
+ return PagedIterables.advance(
+ input, fetchNextPage(project.get().toString(), region.get().toString(), (ListOptions) listOptions.orNull()));
+ }
+
+ protected abstract Function<Object, IterableWithMarker<T>> fetchNextPage(String projectName,
+ String regionName,
+ ListOptions listOptions);
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public I setContext(HttpRequest request) {
+ this.request = GeneratedHttpRequest.class.cast(request);
+ return (I) this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java
new file mode 100644
index 0000000..d9dcbf2
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Predicates.instanceOf;
+import static com.google.common.collect.Iterables.tryFind;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.collect.PagedIterables;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.InvocationContext;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+@Beta
+public abstract class BaseWithZoneToPagedIterable<T, I extends BaseWithZoneToPagedIterable<T, I>> implements
+ Function<ListPage<T>, PagedIterable<T>>, InvocationContext<I> {
+
+ private GeneratedHttpRequest request;
+
+ @Override
+ public PagedIterable<T> apply(ListPage<T> input) {
+ if (input.nextMarker() == null)
+ return PagedIterables.of(input);
+
+ Optional<Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class));
+
+ Optional<Object> zone = tryFind(request.getInvocation().getArgs(), instanceOf(String.class));
+
+ Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
+
+ assert project.isPresent() : String.format("programming error, method %s should have a string param for the "
+ + "project", request.getCaller().get().getInvokable());
+
+ assert zone.isPresent() : String.format("programming error, method %s should have a string param for the "
+ + "zone", request.getCaller().get().getInvokable());
+
+ return PagedIterables.advance(
+ input, fetchNextPage(project.get().toString(), zone.get().toString(), (ListOptions) listOptions.orNull()));
+ }
+
+ protected abstract Function<Object, IterableWithMarker<T>> fetchNextPage(String projectName,
+ String zoneName,
+ ListOptions listOptions);
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public I setContext(HttpRequest request) {
+ this.request = GeneratedHttpRequest.class.cast(request);
+ return (I) this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/PATCH.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/PATCH.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/PATCH.java
new file mode 100644
index 0000000..4e287dc
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/PATCH.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.ws.rs.HttpMethod;
+
+/**
+ * Indicates that the annotated method responds to HTTP PATCH requests
+ *
+ * @see javax.ws.rs.HttpMethod
+ */
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@HttpMethod("PATCH")
+public @interface PATCH {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java
new file mode 100644
index 0000000..59b4408
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.Address;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+@Singleton
+public class ParseAddresses extends ParseJson<ListPage<Address>> {
+
+ @Inject
+ public ParseAddresses(Json json) {
+ super(json, new TypeLiteral<ListPage<Address>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseWithRegionToPagedIterable<Address, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Address>> fetchNextPage(final String projectName,
+ final String regionName,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Address>>() {
+
+ @Override
+ public IterableWithMarker<Address> apply(Object input) {
+ return api.getAddressApiForProject(projectName)
+ .listAtMarkerInRegion(regionName, input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java
new file mode 100644
index 0000000..eca4a11
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.Disk;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+@Singleton
+public class ParseDisks extends ParseJson<ListPage<Disk>> {
+
+ @Inject
+ public ParseDisks(Json json) {
+ super(json, new TypeLiteral<ListPage<Disk>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseWithZoneToPagedIterable<Disk, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Disk>> fetchNextPage(final String projectName,
+ final String zoneName,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Disk>>() {
+
+ @Override
+ public IterableWithMarker<Disk> apply(Object input) {
+ return api.getDiskApiForProject(projectName)
+ .listAtMarkerInZone(zoneName, input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java
new file mode 100644
index 0000000..05d11bd
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+public class ParseFirewalls extends ParseJson<ListPage<Firewall>> {
+
+ @Inject
+ public ParseFirewalls(Json json) {
+ super(json, new TypeLiteral<ListPage<Firewall>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseToPagedIterable<Firewall, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Firewall>> fetchNextPage(final String projectName,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Firewall>>() {
+
+ @Override
+ public IterableWithMarker<Firewall> apply(Object input) {
+ return api.getFirewallApiForProject(projectName).listAtMarker(input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java
new file mode 100644
index 0000000..b2a589e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+public class ParseGlobalOperations extends ParseJson<ListPage<Operation>> {
+
+ @Inject
+ public ParseGlobalOperations(Json json) {
+ super(json, new TypeLiteral<ListPage<Operation>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseToPagedIterable<Operation, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Operation>>() {
+
+ @Override
+ public IterableWithMarker<Operation> apply(Object input) {
+ return api.getGlobalOperationApiForProject(projectName).listAtMarker(input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java
new file mode 100644
index 0000000..6d23343
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+public class ParseImages extends ParseJson<ListPage<Image>> {
+
+ @Inject
+ public ParseImages(Json json) {
+ super(json, new TypeLiteral<ListPage<Image>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseToPagedIterable<Image, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Image>> fetchNextPage(final String projectName,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Image>>() {
+
+ @Override
+ public IterableWithMarker<Image> apply(Object input) {
+ return api.getImageApiForProject(projectName).listAtMarker(input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java
new file mode 100644
index 0000000..001a98c
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+public class ParseInstances extends ParseJson<ListPage<Instance>> {
+
+ @Inject
+ public ParseInstances(Json json) {
+ super(json, new TypeLiteral<ListPage<Instance>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseWithZoneToPagedIterable<Instance, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Instance>> fetchNextPage(final String project,
+ final String zone,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Instance>>() {
+
+ @Override
+ public IterableWithMarker<Instance> apply(Object input) {
+ return api.getInstanceApiForProject(project)
+ .listAtMarkerInZone(zone, input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java
new file mode 100644
index 0000000..be78b92
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.MachineType;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+public class ParseMachineTypes extends ParseJson<ListPage<MachineType>> {
+
+ @Inject
+ public ParseMachineTypes(Json json) {
+ super(json, new TypeLiteral<ListPage<MachineType>>() {});
+ }
+
+ public static class ToPagedIterable extends BaseWithZoneToPagedIterable<MachineType, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<MachineType>> fetchNextPage(final String project,
+ final String zone,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<MachineType>>() {
+
+ @Override
+ public IterableWithMarker<MachineType> apply(Object input) {
+ return api.getMachineTypeApiForProject(project)
+ .listAtMarkerInZone(zone, input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java
new file mode 100644
index 0000000..0aa550b
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+public class ParseNetworks extends ParseJson<ListPage<Network>> {
+
+ @Inject
+ public ParseNetworks(Json json) {
+ super(json, new TypeLiteral<ListPage<Network>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseToPagedIterable<Network, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Network>> fetchNextPage(final String projectName,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Network>>() {
+
+ @Override
+ public IterableWithMarker<Network> apply(Object input) {
+ return api.getNetworkApiForProject(projectName).listAtMarker(input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java
new file mode 100644
index 0000000..84c8954
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+public class ParseRegionOperations extends ParseJson<ListPage<Operation>> {
+
+ @Inject
+ public ParseRegionOperations(Json json) {
+ super(json, new TypeLiteral<ListPage<Operation>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseWithRegionToPagedIterable<Operation, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName,
+ final String regionName,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Operation>>() {
+
+ @Override
+ public IterableWithMarker<Operation> apply(Object input) {
+ return api.getRegionOperationApiForProject(projectName)
+ .listAtMarkerInRegion(regionName, input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java
new file mode 100644
index 0000000..ca1819e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Region;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+public class ParseRegions extends ParseJson<ListPage<Region>> {
+
+ @Inject
+ public ParseRegions(Json json) {
+ super(json, new TypeLiteral<ListPage<Region>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseToPagedIterable<Region, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Region>> fetchNextPage(final String projectName,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Region>>() {
+
+ @Override
+ public IterableWithMarker<Region> apply(Object input) {
+ return api.getRegionApiForProject(projectName).listAtMarker(input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java
new file mode 100644
index 0000000..6191892
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Route;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+public class ParseRoutes extends ParseJson<ListPage<Route>> {
+
+ @Inject
+ public ParseRoutes(Json json) {
+ super(json, new TypeLiteral<ListPage<Route>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseToPagedIterable<Route, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Route>> fetchNextPage(final String projectName,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Route>>() {
+
+ @Override
+ public IterableWithMarker<Route> apply(Object input) {
+ return api.getRouteApiForProject(projectName).listAtMarker(input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java
new file mode 100644
index 0000000..66ac2e7
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Snapshot;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+@Singleton
+public class ParseSnapshots extends ParseJson<ListPage<Snapshot>> {
+
+ @Inject
+ public ParseSnapshots(Json json) {
+ super(json, new TypeLiteral<ListPage<Snapshot>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseToPagedIterable<Snapshot, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Snapshot>> fetchNextPage(final String projectName,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Snapshot>>() {
+
+ @Override
+ public IterableWithMarker<Snapshot> apply(Object input) {
+ return api.getSnapshotApiForProject(projectName)
+ .listAtMarker(input.toString(), options);
+ }
+ };
+ }
+ }
+}
[22/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/ExtensionApiMockTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/ExtensionApiMockTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/ExtensionApiMockTest.java
new file mode 100644
index 0000000..b9615d6
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/ExtensionApiMockTest.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiMockTest;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.openstack.v2_0.features.ExtensionApi;
+import org.testng.annotations.Test;
+
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+
+/**
+ * Tests annotation parsing of {@code ExtensionApi}
+ */
+@Test(groups = "unit", testName = "ExtensionApiMockTest")
+public class ExtensionApiMockTest extends BaseNeutronApiMockTest {
+
+ public void testListExtensions() throws Exception {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse()
+ .setResponseCode(200).setBody(stringFromResource("/extension_list.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ ExtensionApi api = neutronApi.getExtensionApi("RegionOne");
+
+ Set<Extension> extensions = api.list();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertExtensions(server, "/v2.0");
+
+ /*
+ * Check response
+ */
+ assertNotNull(extensions);
+ assertEquals(extensions.size(), 17);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListExtensionsIsEmpty() throws Exception {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ ExtensionApi api = neutronApi.getExtensionApi("RegionOne");
+
+ Set<Extension> extensions = api.list();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/extensions");
+
+ /*
+ * Check response
+ */
+ assertTrue(extensions.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetExtensionByAlias() throws Exception {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse()
+ .setResponseCode(200).setBody(stringFromResource("/extension_details.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+
+ Extension routerExtension = neutronApi.getExtensionApi("RegionOne").get("router");
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/extensions/router");
+
+ /*
+ * Check response
+ */
+ assertNotNull(routerExtension);
+ assertEquals(routerExtension.getName(), "Neutron L3 Router");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetExtensionByAliasFail() throws Exception {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+
+ Extension routerExtension = neutronApi.getExtensionApi("RegionOne").get("router");
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/extensions/router");
+
+ /*
+ * Check response
+ */
+ assertNull(routerExtension);
+ } finally {
+ server.shutdown();
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/NetworkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/NetworkApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/NetworkApiLiveTest.java
new file mode 100644
index 0000000..1d4e3a0
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/NetworkApiLiveTest.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.features;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Sets;
+import org.jclouds.openstack.neutron.v2.domain.Network;
+import org.jclouds.openstack.neutron.v2.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiLiveTest;
+import org.jclouds.openstack.neutron.v2.util.PredicateUtil;
+import org.testng.annotations.Test;
+
+import java.util.Set;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * Tests parsing and Guice wiring of NetworkApi
+ */
+@Test(groups = "live", testName = "NetworkApiLiveTest")
+public class NetworkApiLiveTest extends BaseNeutronApiLiveTest {
+
+ public void testCreateUpdateAndDeleteNetwork() {
+ for (String region : api.getConfiguredRegions()) {
+ NetworkApi networkApi = api.getNetworkApi(region);
+ Network net = networkApi.create(Network.createBuilder("jclouds-test").networkType(NetworkType.LOCAL).build());
+ Network test = networkApi.create(Network.createBuilder("jclouds-test").build());
+ assertNotNull(net);
+
+ /* List and get tests */
+ Network networkList = api.getNetworkApi(region).list().concat().toSet().iterator().next();
+ assertNotNull(networkList);
+ Network networkGet = api.getNetworkApi(region).get(networkList.getId());
+ assertEquals(networkList, networkGet);
+ /****/
+
+ Network network = networkApi.get(net.getId());
+
+ assertEquals(network.getId(), net.getId());
+ assertEquals(network.getName(), "jclouds-test");
+ assertEquals(network.getNetworkType(), NetworkType.LOCAL);
+ assertTrue(network.getSubnets().isEmpty());
+ assertNotNull(networkApi.update(net.getId(), Network.updateBuilder().name("jclouds-live-test").build()));
+
+ network = networkApi.get(net.getId());
+
+ assertEquals(network.getId(), net.getId());
+ assertEquals(network.getName(), "jclouds-live-test");
+ assertTrue(network.getSubnets().isEmpty());
+
+ Network net2 = networkApi.create(Network.createBuilder("jclouds-test2").networkType(NetworkType.LOCAL).build());
+ assertNotNull(net2);
+
+ assertTrue(networkApi.delete(net.getId()));
+ assertTrue(networkApi.delete(net2.getId()));
+ assertTrue(networkApi.delete(test.getId()));
+ }
+ }
+
+ public void testBulkCreateNetwork() {
+ for (String region : api.getConfiguredRegions()) {
+ NetworkApi networkApi = api.getNetworkApi(region);
+ Set<Network> nets = networkApi.createBulk(
+ ImmutableList.of(
+ Network.createBuilder("jclouds-live-test-1").networkType(NetworkType.LOCAL).adminStateUp(true).build(),
+ Network.createBuilder("jclouds-live-test-2").networkType(NetworkType.LOCAL).adminStateUp(false).build(),
+ Network.createBuilder("jclouds-live-test-3").networkType(NetworkType.LOCAL).adminStateUp(false).build()
+ )
+ ).toSet();
+ Set<Network> existingNets = networkApi.list().concat().toSet();
+
+ assertNotNull(nets);
+ assertTrue(!nets.isEmpty());
+ assertEquals(nets.size(), 3);
+
+ for (Network net : nets) {
+ Predicate<Network> idEqualsPredicate = PredicateUtil.createIdEqualsPredicate(net.getId());
+ assertEquals(1, Sets.filter(existingNets, idEqualsPredicate).size());
+ assertTrue(networkApi.delete(net.getId()));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/NetworkApiMockTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/NetworkApiMockTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/NetworkApiMockTest.java
new file mode 100644
index 0000000..641e276
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/NetworkApiMockTest.java
@@ -0,0 +1,464 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.features;
+
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.Network;
+import org.jclouds.openstack.neutron.v2.domain.NetworkStatus;
+import org.jclouds.openstack.neutron.v2.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2.domain.Networks;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiMockTest;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * Tests NetworkApi Guice wiring and parsing
+ *
+ */
+@Test
+public class NetworkApiMockTest extends BaseNeutronApiMockTest {
+
+ public void testCreateNetwork() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/network_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ Network.CreateNetwork createNetwork = Network.createBuilder("jclouds-wibble")
+ .networkType(NetworkType.LOCAL)
+ .build();
+
+ Network network = api.create(createNetwork);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "POST", "/v2.0/networks", "/network_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(network);
+ assertEquals(network.getName(), "jclouds-wibble");
+ assertEquals(network.getNetworkType(), NetworkType.LOCAL);
+ assertEquals(network.getTenantId(), "1234567890");
+ assertEquals(network.getStatus(), NetworkStatus.ACTIVE);
+ assertEquals(network.getId(), "624312ff-d14b-4ba3-9834-1c78d23d574d");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateNetworkFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404).setBody(stringFromResource("/network_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ Network.CreateNetwork createNetwork = Network.createBuilder("jclouds-wibble")
+ .networkType(NetworkType.LOCAL)
+ .build();
+
+ Network network = api.create(createNetwork);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageNetwork() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/network_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ Networks networks = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/networks?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(networks);
+ assertEquals(networks.first().get().getId(), "396f12f8-521e-4b91-8e21-2e003500433a");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ // These fail tests uncover issues with the fallback annotations.
+ public void testListSpecificPageNetworkFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404).setBody(stringFromResource("/network_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ Networks networks = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/networks?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertTrue(networks.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedNetwork() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/network_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/network_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Network> networks = api.list().concat().toList();
+ assertEquals(networks.size(), 4);
+ // look at last element
+ assertEquals(networks.get(3).getId(), "71c1e68c-171a-4aa2-aca5-50ea153a3718_2");
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/networks");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/networks?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718");
+
+ /*
+ * Check response
+ */
+ assertNotNull(networks);
+ assertEquals(networks.get(0).getId(), "396f12f8-521e-4b91-8e21-2e003500433a");
+ assertEquals(networks.get(3).getId(), "71c1e68c-171a-4aa2-aca5-50ea153a3718_2");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedNetworkFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404).setBody(stringFromResource("/network_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Network> networks = api.list().concat().toList();
+
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/networks");
+
+ /*
+ * Check response
+ */
+ assertTrue(networks.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetNetwork() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/network_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ Network network = api.get("12345");
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/networks/12345");
+
+ /*
+ * Check response
+ */
+ assertNotNull(network);
+ assertEquals(network.getName(), "jclouds-wibble");
+ assertEquals(network.getId(), "624312ff-d14b-4ba3-9834-1c78d23d574d");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetNetworkFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ Network network = api.get("12345");
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/networks/12345");
+
+ /*
+ * Check response
+ */
+ assertNull(network);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateNetworkBulk() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/network_bulk_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ Network.CreateNetwork createNetwork1 = Network.createBuilder("jclouds-wibble")
+ .networkType(NetworkType.LOCAL)
+ .build();
+
+ Network.CreateNetwork createNetwork2 = Network.createBuilder("jclouds-wibble2")
+ .networkType(NetworkType.LOCAL)
+ .build();
+
+ FluentIterable<Network> networks = api.createBulk(ImmutableList.of(createNetwork1, createNetwork2));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "POST", "/v2.0/networks", "/network_bulk_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(networks);
+ assertEquals(networks.size(), 2);
+ assertEquals(networks.get(0).getName(), "jclouds-wibble");
+ assertEquals(networks.get(0).getNetworkType(), NetworkType.LOCAL);
+ assertEquals(networks.get(0).getTenantId(), "1234567890");
+ assertEquals(networks.get(0).getStatus(), NetworkStatus.ACTIVE);
+ assertEquals(networks.get(0).getId(), "624312ff-d14b-4ba3-9834-1c78d23d574d");
+
+ assertEquals(networks.get(1).getName(), "jclouds-wibble2");
+ assertEquals(networks.get(1).getNetworkType(), NetworkType.LOCAL);
+ assertEquals(networks.get(1).getTenantId(), "1234567890");
+ assertEquals(networks.get(1).getStatus(), NetworkStatus.ACTIVE);
+ assertEquals(networks.get(1).getId(), "624312ff-d14b-4ba3-9834-1c78d23d574e");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateNetworkBulkFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ Network.CreateNetwork createNetwork1 = Network.createBuilder("jclouds-wibble")
+ .networkType(NetworkType.LOCAL)
+ .build();
+
+ Network.CreateNetwork createNetwork2 = Network.createBuilder("jclouds-wibble2")
+ .networkType(NetworkType.LOCAL)
+ .build();
+
+ FluentIterable<Network> networks = api.createBulk(ImmutableList.of(createNetwork1, createNetwork2));
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateNetwork() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/network_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ Network.UpdateNetwork updateNetwork = Network.updateBuilder()
+ .name("jclouds-wibble-updated")
+ .networkType(NetworkType.LOCAL)
+ .build();
+
+ Network network = api.update("123456", updateNetwork);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/networks/123456", "/network_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(network);
+ assertEquals(network.getName(), "updated_name");
+ assertEquals(network.getId(), "fc68ea2c-b60b-4b4f-bd82-94ec81110766");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateNetworkFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ Network.UpdateNetwork updateNetwork = Network.updateBuilder()
+ .name("jclouds-wibble-updated")
+ .networkType(NetworkType.LOCAL)
+ .build();
+
+ Network network = api.update("123456", updateNetwork);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/networks/123456");
+
+ /*
+ * Check response
+ */
+ assertNull(network);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteNetwork() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ boolean result = api.delete("123456");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/networks/123456");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteNetworkFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ NetworkApi api = neutronApi.getNetworkApi("RegionOne");
+
+ boolean result = api.delete("123456");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/networks/123456");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/PortApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/PortApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/PortApiLiveTest.java
new file mode 100644
index 0000000..bcde014
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/PortApiLiveTest.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.features;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.jclouds.openstack.neutron.v2.domain.IP;
+import org.jclouds.openstack.neutron.v2.domain.Network;
+import org.jclouds.openstack.neutron.v2.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2.domain.Port;
+import org.jclouds.openstack.neutron.v2.domain.Subnet;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiLiveTest;
+import org.jclouds.openstack.neutron.v2.util.PredicateUtil;
+import org.testng.annotations.Test;
+
+import java.util.Set;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * Tests PortApi in combination with the Network & SubnetApi
+ */
+@Test(groups = "live", testName = "PortApiLiveTest")
+public class PortApiLiveTest extends BaseNeutronApiLiveTest {
+
+ public void testCreateUpdateAndDeletePort() {
+ for (String region : api.getConfiguredRegions()) {
+ NetworkApi networkApi = api.getNetworkApi(region);
+ SubnetApi subnetApi = api.getSubnetApi(region);
+ PortApi portApi = api.getPortApi(region);
+ String networkId = networkApi.create(
+ Network.createBuilder("JClouds-Live-Network").networkType(NetworkType.LOCAL).build()).getId();
+ String ipv4SubnetId = subnetApi.create(Subnet.createBuilder(networkId, "198.51.100.0/24").ipVersion(4)
+ .name("JClouds-Live-IPv4-Subnet").build()).getId();
+ String ipv6SubnetId = subnetApi.create(Subnet.createBuilder(networkId, "a1ca:1e1:c:107d::/96").ipVersion(6)
+ .name("JClouds-Live-IPv6-Subnet").build()).getId();
+
+ assertNotNull(networkId);
+ assertNotNull(ipv4SubnetId);
+ assertNotNull(ipv6SubnetId);
+
+ String ipv4PortId = portApi.create(Port.createBuilder(networkId).name("JClouds-Live-IPv4-Port")
+ .fixedIps(ImmutableSet.copyOf(getFixedAddresses(ipv4SubnetId))).build()).getId();
+ String ipv6PortId = portApi.create(Port.createBuilder(networkId).name("JClouds-Live-IPv6-Port")
+ .fixedIps(ImmutableSet.copyOf(getFixedAddresses(ipv6SubnetId))).build()).getId();
+
+ /* List and get test */
+ Port portList = api.getPortApi(region).list().concat().toSet().iterator().next();
+ assertNotNull(portList);
+ Port portGet = api.getPortApi(region).get(portList.getId());
+ assertEquals(portList, portGet);
+ /****/
+
+ assertNotNull(ipv4PortId);
+ assertNotNull(ipv6PortId);
+
+ Port ipv4Port = portApi.get(ipv4PortId);
+ assertNotNull(ipv4Port);
+ assertEquals(ipv4Port.getId(), ipv4PortId);
+ assertEquals(ipv4Port.getName(), "JClouds-Live-IPv4-Port");
+
+ Port ipv6Port = portApi.get(ipv6PortId);
+ assertNotNull(ipv6Port);
+ assertEquals(ipv6Port.getId(), ipv6PortId);
+ assertEquals(ipv6Port.getName(), "JClouds-Live-IPv6-Port");
+
+ assertNotNull(portApi.update(ipv4PortId, Port.updateBuilder().name("Updated").build()));
+ Port updatedIpv4Port = portApi.get(ipv4PortId);
+ assertEquals(updatedIpv4Port.getName(), "Updated");
+
+ assertTrue(portApi.delete(ipv4PortId));
+ assertTrue(portApi.delete(ipv6PortId));
+ assertTrue(subnetApi.delete(ipv4SubnetId));
+ assertTrue(subnetApi.delete(ipv6SubnetId));
+ assertTrue(networkApi.delete(networkId));
+ }
+ }
+
+ public void testBulkCreatePort() {
+ for (String region : api.getConfiguredRegions()) {
+ NetworkApi networkApi = api.getNetworkApi(region);
+ SubnetApi subnetApi = api.getSubnetApi(region);
+ PortApi portApi = api.getPortApi(region);
+
+ String networkId = networkApi.create(
+ Network.createBuilder("JClouds-Live-Network").networkType(NetworkType.LOCAL).build()).getId();
+ String ipv4SubnetId = subnetApi.create(Subnet.createBuilder(networkId, "198.51.100.0/24").ipVersion(4)
+ .name("JClouds-Live-IPv4-Subnet").build()).getId();
+ String ipv6SubnetId = subnetApi.create(Subnet.createBuilder(networkId, "a1ca:1e1:c:107d::/96").ipVersion(6)
+ .name("JClouds-Live-IPv6-Subnet").build()).getId();
+
+ assertNotNull(networkId);
+ assertNotNull(ipv4SubnetId);
+ assertNotNull(ipv6SubnetId);
+
+ Set<? extends Port> ports = portApi.createBulk(
+ ImmutableList.of(
+ Port.createBuilder(networkId).name("JClouds-Live-IPv4-Subnet-1")
+ .fixedIps(ImmutableSet.copyOf(getFixedAddresses(ipv4SubnetId))).build(),
+ Port.createBuilder(networkId).name("JClouds-Live-IPv4-Subnet-2")
+ .fixedIps(ImmutableSet.copyOf(getFixedAddresses(ipv4SubnetId))).build(),
+ Port.createBuilder(networkId).name("JClouds-Live-IPv6-Subnet-1")
+ .fixedIps(ImmutableSet.copyOf(getFixedAddresses(ipv6SubnetId))).build(),
+ Port.createBuilder(networkId).name("JClouds-Live-IPv6-Subnet-2")
+ .fixedIps(ImmutableSet.copyOf(getFixedAddresses(ipv6SubnetId))).build()
+ )
+ ).toSet();
+ Set<? extends Port> existingPorts = portApi.list().concat().toSet();
+
+ assertNotNull(ports);
+ assertFalse(ports.isEmpty());
+ assertEquals(ports.size(), 4);
+
+ for (Port port : ports) {
+ Predicate<Port> idEqualsPredicate = PredicateUtil.createIdEqualsPredicate(port.getId());
+ assertEquals(1, Sets.filter(existingPorts, idEqualsPredicate).size());
+ assertTrue(portApi.delete(port.getId()));
+ }
+ assertTrue(subnetApi.delete(ipv4SubnetId));
+ assertTrue(subnetApi.delete(ipv6SubnetId));
+ assertTrue(networkApi.delete(networkId));
+ }
+ }
+
+ public Set<IP> getFixedAddresses(String subnetId) {
+ return ImmutableSet.of(
+ IP.builder().subnetId(subnetId).build()
+ );
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/PortApiMockTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/PortApiMockTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/PortApiMockTest.java
new file mode 100644
index 0000000..8f7ebc8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/PortApiMockTest.java
@@ -0,0 +1,492 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.features;
+
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.AddressPair;
+import org.jclouds.openstack.neutron.v2.domain.NetworkStatus;
+import org.jclouds.openstack.neutron.v2.domain.Port;
+import org.jclouds.openstack.neutron.v2.domain.Ports;
+import org.jclouds.openstack.neutron.v2.domain.VIFType;
+import org.jclouds.openstack.neutron.v2.domain.VNICType;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiMockTest;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * Tests NetworkApi Guice wiring and parsing
+ *
+ */
+@Test
+public class PortApiMockTest extends BaseNeutronApiMockTest {
+
+ public void testCreatePort() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/port_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ Port.CreatePort createPort = Port.createBuilder("6aeaf34a-c482-4bd3-9dc3-7faf36412f12")
+ .name("port1")
+ .adminStateUp(Boolean.TRUE)
+ .deviceId("d6b4d3a5-c700-476f-b609-1493dd9dadc0")
+ .allowedAddressPairs(ImmutableSet.of(AddressPair.builder("12", "111.222.333.444").build()))
+ .build();
+
+ Port port = api.create(createPort);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "POST", "/v2.0/ports", "/port_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(port);
+ assertEquals(port.getAllowedAddressPairs().iterator().next().getIpAddress(), "192.168.1.1");
+ assertEquals(port.getAllowedAddressPairs().iterator().next().getMacAddress(), "12:12");
+ assertEquals(port.getName(), "port1");
+ assertEquals(port.getStatus(), NetworkStatus.ACTIVE);
+ assertEquals(port.getId(), "ebe69f1e-bc26-4db5-bed0-c0afb4afe3db");
+ assertEquals(port.getDeviceId(), "d6b4d3a5-c700-476f-b609-1493dd9dadc0");
+ assertEquals(port.getDeviceOwner(), "");
+ assertEquals(port.getMacAddress(), "fa:16:3e:a6:50:c1");
+ assertEquals(port.getNetworkId(), "6aeaf34a-c482-4bd3-9dc3-7faf36412f12");
+ assertEquals(port.getFixedIps().iterator().next().getIpAddress(), "192.168.111.4");
+ assertEquals(port.getFixedIps().iterator().next().getSubnetId(), "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27");
+ assertEquals(port.getTenantId(), "cf1a5775e766426cb1968766d0191908");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreatePortFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ Port.CreatePort createPort = Port.createBuilder("6aeaf34a-c482-4bd3-9dc3-7faf36412f12")
+ .name("port1")
+ .adminStateUp(Boolean.TRUE)
+ .deviceId("d6b4d3a5-c700-476f-b609-1493dd9dadc0")
+ .allowedAddressPairs(ImmutableSet.of(AddressPair.builder("12", "111.222.333.444").build()))
+ .build();
+
+ Port port = api.create(createPort);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPagePort() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/port_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ Ports ports = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/ports?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(ports);
+ assertEquals(ports.size(), 2);
+ assertEquals(ports.first().get().getId(), "24e6637e-c521-45fc-8b8b-d7331aa3c99f");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPagePortFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ Ports ports = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/ports?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertTrue(ports.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedPort() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/port_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/port_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Port> ports = api.list().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/ports");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/ports?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718");
+
+ /*
+ * Check response
+ */
+ assertNotNull(ports);
+ assertEquals(ports.size(), 4);
+ assertEquals(ports.get(0).getId(), "24e6637e-c521-45fc-8b8b-d7331aa3c99f");
+ assertEquals(ports.get(3).getId(), "e54dfd9b-ce6e-47f7-af47-1609cfd1cdb0_4");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedPortFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Port> ports = api.list().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/ports");
+
+ /*
+ * Check response
+ */
+ assertTrue(ports.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateBulkPort() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/port_create_bulk_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ Port.CreatePort createPort1 = Port.createBuilder("64239a54-dcc4-4b39-920b-b37c2144effa")
+ .name("port1")
+ .adminStateUp(Boolean.TRUE)
+ .deviceId("24df1d04-d5cb-41e1-8de5-61ed77c558df")
+ .securityGroups(ImmutableSet.of("dbc107f4-afcd-4d5a-9352-f68f82241d5b"))
+ .build();
+
+ Port.CreatePort createPort2 = Port.createBuilder("e6031bc2-901a-4c66-82da-f4c32ed89406")
+ .name("port2")
+ .adminStateUp(Boolean.FALSE)
+ .securityGroups(
+ ImmutableSet.of("8bf3f7cc-8471-40b1-815f-9da47e79775b", "dbc107f4-afcd-4d5a-9352-f68f82241d5b"))
+ .build();
+
+ FluentIterable<Port> ports = api.createBulk(ImmutableList.of(createPort1, createPort2));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "POST", "/v2.0/ports", "/port_create_bulk_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(ports);
+ assertEquals(ports.size(), 2);
+ assertEquals(ports.get(0).getName(), "port1");
+ assertEquals(ports.get(1).getName(), "port2");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateBulkPortFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ Port.CreatePort createPort1 = Port.createBuilder("64239a54-dcc4-4b39-920b-b37c2144effa")
+ .name("port1")
+ .adminStateUp(Boolean.TRUE)
+ .deviceId("24df1d04-d5cb-41e1-8de5-61ed77c558df")
+ .securityGroups(ImmutableSet.of("dbc107f4-afcd-4d5a-9352-f68f82241d5b"))
+ .build();
+
+ Port.CreatePort createPort2 = Port.createBuilder("e6031bc2-901a-4c66-82da-f4c32ed89406")
+ .name("port2")
+ .adminStateUp(Boolean.FALSE)
+ .securityGroups(
+ ImmutableSet.of("8bf3f7cc-8471-40b1-815f-9da47e79775b", "dbc107f4-afcd-4d5a-9352-f68f82241d5b"))
+ .build();
+
+ FluentIterable<Port> ports = api.createBulk(ImmutableList.of(createPort1, createPort2));
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetPort() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/port_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ Port port = api.get("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/ports/12345");
+
+ /*
+ * Check response
+ */
+ assertNotNull(port);
+ assertEquals(port.getName(), "jclouds-wibble");
+ assertEquals(port.getStatus(), NetworkStatus.ACTIVE);
+ assertEquals(port.getId(), "624312ff-d14b-4ba3-9834-1c78d23d574d");
+ assertEquals(port.getTenantId(), "1234567890");
+ assertEquals(port.getNetworkId(), "1234567890");
+ assertEquals(port.getVnicType(), VNICType.NORMAL);
+ assertEquals(port.getVifType(), VIFType.HYPERV);
+ assertEquals(port.getVifDetails().get("name1"), "value1");
+ assertEquals(((Map<String, Double>)port.getVifDetails().get("name2")).get("mapname2").intValue(), 3);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetPortFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ Port port = api.get("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/ports/12345");
+
+ /*
+ * Check response
+ */
+ assertNull(port);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdatePort() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(201).setBody(stringFromResource("/port_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ Port.UpdatePort updatePort = Port.updateBuilder()
+ .securityGroups(
+ ImmutableSet.of("85cc3048-abc3-43cc-89b3-377341426ac5", "c5ab5c29-2c99-44cb-a4b8-e70a88b77799"))
+ .build();
+
+ Port port = api.update("12345", updatePort);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/ports/12345", "/port_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(port);
+ assertEquals(port.getId(), "1d8591f4-7b62-428e-857d-e82a15e5a7f1");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdatePortFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(
+ new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ Port.UpdatePort updatePort = Port.updateBuilder()
+ .securityGroups(ImmutableSet.of("85cc3048-abc3-43cc-89b3-377341426ac5", "c5ab5c29-2c99-44cb-a4b8-e70a88b77799"))
+ .build();
+
+ Port port = api.update("12345", updatePort);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/ports/12345", "/port_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(port);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeletePort() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ boolean result = api.delete("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/ports/12345");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeletePortFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ PortApi api = neutronApi.getPortApi("RegionOne");
+
+ boolean result = api.delete("12345");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/ports/12345");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/SubnetApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/SubnetApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/SubnetApiLiveTest.java
new file mode 100644
index 0000000..3c5d7a8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/SubnetApiLiveTest.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.features;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.jclouds.openstack.neutron.v2.domain.AllocationPool;
+import org.jclouds.openstack.neutron.v2.domain.HostRoute;
+import org.jclouds.openstack.neutron.v2.domain.Network;
+import org.jclouds.openstack.neutron.v2.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2.domain.Subnet;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiLiveTest;
+import org.jclouds.openstack.neutron.v2.util.PredicateUtil;
+import org.testng.annotations.Test;
+
+import java.util.Set;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * Tests subnet api in combination with the network api
+ */
+@Test(groups = "live", testName = "SubnetApiLiveTest")
+public class SubnetApiLiveTest extends BaseNeutronApiLiveTest {
+
+ public void testCreateUpdateAndDeleteSubnet() {
+ for (String region : api.getConfiguredRegions()) {
+ NetworkApi networkApi = api.getNetworkApi(region);
+ String networkId = networkApi.create(Network.createBuilder("jclouds-live-test").networkType(NetworkType.LOCAL).build()).getId();
+
+ SubnetApi subnetApi = api.getSubnetApi(region);
+ ImmutableSet<AllocationPool> allocationPools = ImmutableSet.of(
+ AllocationPool.builder().start("a3:bc00::10").end("a3:bc00::20").build(),
+ AllocationPool.builder().start("a3:bc00::50").end("a3:bc00::90").build()
+ );
+ ImmutableSet<HostRoute> hostRoutes = ImmutableSet.of(
+ HostRoute.builder().destinationCidr("a3:bc00::/48").nextHop("a3:bc00::0004").build()
+ );
+ Subnet subnet = subnetApi.create(Subnet.createBuilder(networkId, "a3:bc00::/48").ipVersion(6).allocationPools(allocationPools).hostRoutes(hostRoutes).build());
+ assertNotNull(subnet);
+
+ /* Test list and get */
+ Subnet subnetList = api.getSubnetApi(region).list().concat().toSet().iterator().next();
+ assertNotNull(subnetList);
+ Subnet subnetGet = api.getSubnetApi(region).get(subnetList.getId());
+ assertEquals(subnetList, subnetGet);
+ /***/
+
+ Subnet retrievedSubnet = subnetApi.get(subnet.getId());
+
+ assertEquals(retrievedSubnet.getId(), subnet.getId());
+ assertEquals(retrievedSubnet.getCidr(), "a3:bc00::/48");
+ assertTrue(retrievedSubnet.getDnsNameservers().isEmpty());
+ assertEquals(retrievedSubnet.getAllocationPools().size(), 2);
+ assertEquals(retrievedSubnet.getHostRoutes().size(), 1);
+ assertNotNull(subnetApi.update(retrievedSubnet.getId(), Subnet.updateBuilder().name("jclouds-live-test-update").build()));
+
+ retrievedSubnet = subnetApi.get(retrievedSubnet.getId());
+
+ assertEquals(retrievedSubnet.getId(), subnet.getId());
+ assertEquals(retrievedSubnet.getName(), "jclouds-live-test-update");
+ assertTrue(retrievedSubnet.getDnsNameservers().isEmpty());
+
+ Subnet subnet2 = subnetApi.create(Subnet.createBuilder(networkId, "a3:bd01::/48").ipVersion(6).build());
+ assertNotNull(subnet2);
+
+ assertTrue(subnetApi.delete(subnet.getId()));
+ assertTrue(subnetApi.delete(subnet2.getId()));
+ assertTrue(networkApi.delete(networkId));
+ }
+ }
+
+ public void testBulkCreateSubnet() {
+ for (String region : api.getConfiguredRegions()) {
+ NetworkApi networkApi = api.getNetworkApi(region);
+ String networkId = networkApi.create(Network.createBuilder("jclouds-live-test").networkType(NetworkType.LOCAL).build()).getId();
+
+ SubnetApi subnetApi = api.getSubnetApi(region);
+ Set<? extends Subnet> subnets = subnetApi.createBulk(
+ ImmutableList.of(
+ Subnet.createBuilder("jclouds-live-test-1", "a3:bd01::/48").ipVersion(6).networkId(networkId).build(),
+ Subnet.createBuilder("jclouds-live-test-2", "a3:bd02::/48").ipVersion(6).networkId(networkId).build(),
+ Subnet.createBuilder("jclouds-live-test-3", "a3:bd03::/48").ipVersion(6).networkId(networkId).build()
+ )
+ ).toSet();
+ Set<Subnet> existingSubnets = subnetApi.list().concat().toSet();
+
+ assertNotNull(subnets);
+ assertTrue(!subnets.isEmpty());
+ assertEquals(subnets.size(), 3);
+
+ for (Subnet net : subnets) {
+ Predicate<Subnet> idEqualsPredicate = PredicateUtil.createIdEqualsPredicate(net.getId());
+ assertEquals(1, Sets.filter(existingSubnets, idEqualsPredicate).size());
+ assertTrue(subnetApi.delete(net.getId()));
+ }
+ assertTrue(networkApi.delete(networkId));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/SubnetApiMockTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/SubnetApiMockTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/SubnetApiMockTest.java
new file mode 100644
index 0000000..3571b0c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/SubnetApiMockTest.java
@@ -0,0 +1,472 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.features;
+
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.IPv6DHCPMode;
+import org.jclouds.openstack.neutron.v2.domain.Subnet;
+import org.jclouds.openstack.neutron.v2.domain.Subnets;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiMockTest;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * Tests NetworkApi Guice wiring and parsing
+ *
+ */
+@Test
+public class SubnetApiMockTest extends BaseNeutronApiMockTest {
+
+ public void testCreateSubnet() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/subnet_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ Subnet.CreateSubnet createSubnet = Subnet.createBuilder("1234567890", "10.0.3.0/24")
+ .name("jclouds-wibble")
+ .ipVersion(4)
+ .build();
+
+ Subnet subnet = api.create(createSubnet);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "POST", "/v2.0/subnets", "/subnet_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(subnet);
+ assertEquals(subnet.getName(), "jclouds-wibble");
+ assertEquals(subnet.getIpVersion().intValue(), 4);
+ assertEquals(subnet.getCidr(), "10.0.3.0/24");
+ assertEquals(subnet.getTenantId(), "1234567890");
+ assertEquals(subnet.getId(), "624312ff-d14b-4ba3-9834-1c78d23d574d");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateSubnetFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ Subnet.CreateSubnet createSubnet = Subnet.createBuilder("1234567890", "cidr")
+ .name("jclouds-wibble")
+ .ipVersion(4)
+ .build();
+
+ Subnet subnet = api.create(createSubnet);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageSubnet() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/subnet_list_response_pages1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ Subnets subnets = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/subnets?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(subnets);
+ assertEquals(subnets.first().get().getId(), "16dba3bc-f3fa-4775-afdc-237e12c72f6a");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageSubnetFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ Subnets subnets = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/subnets?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertTrue(subnets.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedSubnet() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/subnet_list_response_pages1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/subnet_list_response_pages2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Subnet> subnets = api.list().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/subnets");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/subnets?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718");
+
+ /*
+ * Check response
+ */
+ assertNotNull(subnets);
+ assertEquals(subnets.size(), 4);
+ assertEquals(subnets.get(0).getId(), "16dba3bc-f3fa-4775-afdc-237e12c72f6a");
+ assertEquals(subnets.get(3).getId(), "6ba4c788-661f-49ab-9bf8-5f10cbbb2f57");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedSubnetFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Subnet> subnets = api.list().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/subnets");
+
+ /*
+ * Check response
+ */
+ assertTrue(subnets.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetSubnet() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/subnet_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ Subnet subnet = api.get("12345");
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/subnets/12345");
+
+ /*
+ * Check response
+ */
+ assertNotNull(subnet);
+ assertEquals(subnet.getName(), "jclouds-wibble");
+ assertEquals(subnet.getId(), "624312ff-d14b-4ba3-9834-1c78d23d574d");
+ assertEquals(subnet.getTenantId(), "1234567890");
+ assertEquals(subnet.getIPv6AddressMode(), IPv6DHCPMode.SLAAC);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetSubnetFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ Subnet subnet = api.get("12345");
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "GET", "/v2.0/subnets/12345");
+
+ /*
+ * Check response
+ */
+ assertNull(subnet);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateBulkSubnet() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/subnet_bulk_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ Subnet.CreateSubnet createSubnet1 = Subnet.createBuilder("e6031bc2-901a-4c66-82da-f4c32ed89406",
+ "192.168.199.0/24")
+ .ipVersion(4)
+ .build();
+
+ Subnet.CreateSubnet createSubnet2 = Subnet.createBuilder("64239a54-dcc4-4b39-920b-b37c2144effa",
+ "10.56.4.0/22")
+ .ipVersion(4)
+ .build();
+
+ FluentIterable<Subnet> subnets = api.createBulk(ImmutableList.of(createSubnet1, createSubnet2));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "POST", "/v2.0/subnets", "/subnet_bulk_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(subnets);
+ assertEquals(subnets.size(), 2);
+ assertEquals(subnets.get(0).getName(), "");
+ assertEquals(subnets.get(0).getIpVersion().intValue(), 4);
+ assertEquals(subnets.get(0).getCidr(), "192.168.199.0/24");
+ assertTrue(subnets.get(0).getDnsNameservers().isEmpty());
+ assertTrue(subnets.get(0).getEnableDhcp());
+ assertTrue(subnets.get(0).getHostRoutes().isEmpty());
+ assertEquals(subnets.get(0).getTenantId(), "d19231fc08ec4bc4829b668040d34512");
+ assertEquals(subnets.get(0).getId(), "0468a7a7-290d-4127-aedd-6c9449775a24");
+ assertEquals(subnets.get(0).getNetworkId(), "e6031bc2-901a-4c66-82da-f4c32ed89406");
+ assertEquals(subnets.get(0).getAllocationPools().iterator().next().getStart(), "192.168.199.2");
+ assertEquals(subnets.get(0).getAllocationPools().iterator().next().getEnd(), "192.168.199.254");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateBulkSubnetFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ Subnet.CreateSubnet createSubnet1 = Subnet.createBuilder("e6031bc2-901a-4c66-82da-f4c32ed89406",
+ "192.168.199.0/24")
+ .ipVersion(4)
+ .build();
+
+ Subnet.CreateSubnet createSubnet2 = Subnet.createBuilder("64239a54-dcc4-4b39-920b-b37c2144effa",
+ "10.56.4.0/22")
+ .ipVersion(4)
+ .build();
+
+ FluentIterable<Subnet> subnets = api.createBulk(ImmutableList.of(createSubnet1, createSubnet2));
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateSubnet() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/subnet_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ Subnet.UpdateSubnet updateSubnet = Subnet.updateBuilder()
+ .name("new_name")
+ .gatewayIp("10.0.3.254")
+ .build();
+
+ Subnet subnet = api.update("12345", updateSubnet);
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/subnets/12345", "/subnet_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(subnet);
+ assertEquals(subnet.getName(), "new_name");
+ assertEquals(subnet.getId(), "9436e561-47bf-436a-b1f1-fe23a926e031");
+ assertEquals(subnet.getTenantId(), "c1210485b2424d48804aad5d39c61b8f");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateSubnetFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ Subnet.UpdateSubnet updateSubnet = Subnet.updateBuilder()
+ .name("new_name")
+ .gatewayIp("10.0.3.254")
+ .build();
+
+ Subnet subnet = api.update("12345", updateSubnet);
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/subnets/12345", "/subnet_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(subnet);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteSubnet() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ boolean result = api.delete("12345");
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/subnets/12345");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteSubnetFail() throws IOException, InterruptedException, URISyntaxException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ SubnetApi api = neutronApi.getSubnetApi("RegionOne");
+
+ boolean result = api.delete("12345");
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 2);
+ assertAuthentication(server);
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/subnets/12345");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/internal/BaseNeutronApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/internal/BaseNeutronApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/internal/BaseNeutronApiLiveTest.java
new file mode 100644
index 0000000..f220a92
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/internal/BaseNeutronApiLiveTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.internal;
+
+import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.testng.annotations.Test;
+
+import java.util.Properties;
+
+/**
+ * Tests behavior of {@code NeutronApi}
+ *
+ */
+@Test(groups = "live")
+public class BaseNeutronApiLiveTest extends BaseApiLiveTest<NeutronApi> {
+
+ public BaseNeutronApiLiveTest() {
+ provider = "openstack-neutron";
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties props = super.setupProperties();
+ setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
+ return props;
+ }
+
+}
[31/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/VIFType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/VIFType.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/VIFType.java
new file mode 100644
index 0000000..5417065
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/VIFType.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.domain;
+
+public enum VIFType {
+ UNBOUND("unbound"),
+ BINDING_FAILED("binding_failed"),
+ IOVISOR("iovisor"),
+ OVS("ovs"),
+ BRIDGE("bridge"),
+ _802_QBG("802.1qbg"),
+ _802_QBH("802.1qbh"),
+ HYPERV("hyperv"),
+ MIDONET("midonet"),
+ MLNX_DIRECT("mlnx_direct"),
+ MLNX_HOSTDEV("hostdev"),
+ OTHER("other"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private String name;
+
+ private VIFType(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * */
+ public static VIFType fromValue(String name){
+ if (name != null) {
+ for (VIFType value : VIFType.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/VNICType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/VNICType.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/VNICType.java
new file mode 100644
index 0000000..80fd4aa
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/VNICType.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.domain;
+
+/**
+ * Enumerates supported VNIC types.
+ */
+public enum VNICType {
+ NORMAL("normal"),
+ DIRECT("direct"),
+ MACVTAP("macvtap"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private String name;
+
+ private VNICType(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * */
+ public static VNICType fromValue(String name){
+ if (name != null) {
+ for (VNICType value : VNICType.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitor.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitor.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitor.java
new file mode 100644
index 0000000..593690d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitor.java
@@ -0,0 +1,450 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * A Neutron LBaaS v1 HealthMonitor.
+ */
+public class HealthMonitor {
+
+ // Mandatory attributes when creating
+ @Named("tenant_id")
+ private String tenantId;
+ private ProbeType type;
+ // Mandatory attributes that can be updated
+ private Integer delay;
+ private Integer timeout;
+ @Named("max_retries")
+ private Integer maxRetries;
+ // Optional attributes that can be updated
+ @Named("http_method")
+ private HttpMethod httpMethod;
+ @Named("url_path")
+ private String urlPath;
+ @Named("expected_codes")
+ private String expectedCodes;
+ @Named("admin_state_up")
+ private Boolean adminStateUp;
+ // Read-only attributes
+ private String id;
+ private ImmutableList<PoolStatus> pools;
+ private LBaaSStatus status;
+ @Named("status_description")
+ private String statusDescription;
+
+ /**
+ * Deserialization constructor
+ */
+ @ConstructorProperties({ "id", "tenant_id", "type", "delay", "timeout", "max_retries", "http_method", "url_path",
+ "expected_codes", "pools", "admin_state_up", "status", "status_description" })
+ private HealthMonitor(String id, String tenantId, ProbeType type, Integer delay, Integer timeout,
+ Integer maxRetries, HttpMethod httpMethod, String urlPath, String expectedCodes,
+ ImmutableList<PoolStatus> pools, Boolean adminStateUp, LBaaSStatus status, String statusDescription) {
+ this.id = id;
+ this.tenantId = tenantId;
+ this.type = type;
+ this.delay = delay;
+ this.timeout = timeout;
+ this.maxRetries = maxRetries;
+ this.httpMethod = httpMethod;
+ this.urlPath = urlPath;
+ this.expectedCodes = expectedCodes;
+ this.pools = pools;
+ this.adminStateUp = adminStateUp;
+ this.status = status;
+ this.statusDescription = statusDescription;
+ }
+
+ /**
+ * Default constructor.
+ */
+ private HealthMonitor() {
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param healthMonitor the HealthMonitor to copy from.
+ */
+ private HealthMonitor(HealthMonitor healthMonitor) {
+ this(healthMonitor.id, healthMonitor.tenantId, healthMonitor.type, healthMonitor.delay, healthMonitor.timeout,
+ healthMonitor.maxRetries, healthMonitor.httpMethod, healthMonitor.urlPath, healthMonitor.expectedCodes,
+ healthMonitor.pools, healthMonitor.adminStateUp, healthMonitor.status, healthMonitor.statusDescription);
+ }
+
+ /**
+ * @return the id of the HealthMonitor.
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the tenant id of the HealthMonitor.
+ */
+ @Nullable
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return the probe type for this HealthMonitor.
+ */
+ @Nullable
+ public ProbeType getType() {
+ return type;
+ }
+
+ /**
+ * @return the delay for this HealthMonitor.
+ */
+ @Nullable
+ public Integer getDelay() {
+ return delay;
+ }
+
+ /**
+ * @return the timeout for this HealthMonitor.
+ */
+ @Nullable
+ public Integer getTimeout() {
+ return timeout;
+ }
+
+ /**
+ * @return the max retries for this HealthMonitor.
+ */
+ @Nullable
+ public Integer getMaxRetries() {
+ return maxRetries;
+ }
+
+ /**
+ * @return the HTTP method for this HealthMonitor.
+ */
+ @Nullable
+ public HttpMethod getHttpMethod() {
+ return httpMethod;
+ }
+
+ /**
+ * @return the URL path for this HealthMonitor.
+ */
+ @Nullable
+ public String getUrlPath() {
+ return urlPath;
+ }
+
+ /**
+ * @return the expected codes for this HealthMonitor.
+ */
+ @Nullable
+ public String getExpectedCodes() {
+ return expectedCodes;
+ }
+
+ /**
+ * @return the pools for this HealthMonitor.
+ */
+ @Nullable
+ public ImmutableList<PoolStatus> getPools() {
+ return pools;
+ }
+
+ /**
+ * @return the administrative state for this HealthMonitor.
+ */
+ @Nullable
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the status for this HealthMonitor.
+ */
+ @Nullable
+ public LBaaSStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @return the status description for this HealthMonitor.
+ */
+ @Nullable
+ public String getStatusDescription() {
+ return statusDescription;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ HealthMonitor that = (HealthMonitor) o;
+
+ return Objects.equal(this.id, that.id) && Objects.equal(this.tenantId, that.tenantId)
+ && Objects.equal(this.type, that.type) && Objects.equal(this.delay, that.delay)
+ && Objects.equal(this.timeout, that.timeout) && Objects.equal(this.maxRetries, that.maxRetries)
+ && Objects.equal(this.httpMethod, that.httpMethod) && Objects.equal(this.urlPath, that.urlPath)
+ && Objects.equal(this.expectedCodes, that.expectedCodes) && Objects.equal(this.pools, that.pools)
+ && Objects.equal(this.adminStateUp, that.adminStateUp) && Objects.equal(this.status, that.status)
+ && Objects.equal(this.statusDescription, that.statusDescription);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, tenantId, type, delay, timeout, maxRetries, httpMethod, urlPath, expectedCodes,
+ pools, adminStateUp, status, statusDescription);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this).add("id", id).add("tenantId", tenantId).add("type", type)
+ .add("delay", delay).add("timeout", timeout).add("maxRetries", maxRetries).add("httpMethod", httpMethod)
+ .add("urlPath", urlPath).add("expectedCodes", expectedCodes).add("pools", pools)
+ .add("adminStateUp", adminStateUp).add("status", status).add("statusDescription", statusDescription)
+ .toString();
+ }
+
+ /*
+ * Methods to get the Create and Update builders follow.
+ */
+
+ /**
+ * @return the Builder for creating a new HealthMonitor.
+ */
+ public static CreateBuilder createBuilder(ProbeType type, Integer delay, Integer timeout, Integer maxRetries) {
+ return new CreateBuilder(type, delay, timeout, maxRetries);
+ }
+
+ /**
+ * @return the Builder for updating a HealthMonitor.
+ */
+ public static UpdateBuilder updateBuilder() {
+ return new UpdateBuilder();
+ }
+
+ private abstract static class Builder<ParameterizedBuilderType> {
+ protected HealthMonitor healthMonitor;
+
+ /**
+ * Default constructor.
+ */
+ private Builder() {
+ healthMonitor = new HealthMonitor();
+ }
+
+ protected abstract ParameterizedBuilderType self();
+
+ /**
+ * Provides the delay for this HealthMonitor's Builder.
+ *
+ * @return the Builder.
+ * @see HealthMonitor#getDelay()
+ */
+ public ParameterizedBuilderType delay(Integer delay) {
+ healthMonitor.delay = delay;
+ return self();
+ }
+
+ /**
+ * Provides the timeout for this HealthMonitor's Builder.
+ *
+ * @return the Builder.
+ * @see HealthMonitor#getTimeout()
+ */
+ public ParameterizedBuilderType timeout(Integer timeout) {
+ healthMonitor.timeout = timeout;
+ return self();
+ }
+
+ /**
+ * Provides the max retries for this HealthMonitor's Builder.
+ *
+ * @return the Builder.
+ * @see HealthMonitor#getMaxRetries()
+ */
+ public ParameterizedBuilderType maxRetries(Integer maxRetries) {
+ healthMonitor.maxRetries = maxRetries;
+ return self();
+ }
+
+ /**
+ * Provides the HTTP method for this HealthMonitor's Builder.
+ *
+ * @return the Builder.
+ * @see HealthMonitor#getHttpMethod()
+ */
+ public ParameterizedBuilderType httpMethod(HttpMethod httpMethod) {
+ healthMonitor.httpMethod = httpMethod;
+ return self();
+ }
+
+ /**
+ * Provides the URL path for this HealthMonitor's Builder.
+ *
+ * @return the Builder.
+ * @see HealthMonitor#getUrlPath()
+ */
+ public ParameterizedBuilderType urlPath(String urlPath) {
+ healthMonitor.urlPath = urlPath;
+ return self();
+ }
+
+ /**
+ * Provides the expected codes for this HealthMonitor's Builder.
+ *
+ * @return the Builder.
+ * @see HealthMonitor#getExpectedCodes()
+ */
+ public ParameterizedBuilderType expectedCodes(String expectedCodes) {
+ healthMonitor.expectedCodes = expectedCodes;
+ return self();
+ }
+
+ /**
+ * Provides the administrative state for this HealthMonitor's Builder.
+ *
+ * @return the Builder.
+ * @see HealthMonitor#getAdminStateUp()
+ */
+ public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) {
+ healthMonitor.adminStateUp = adminStateUp;
+ return self();
+ }
+ }
+
+ /**
+ * Create builder (inheriting from Builder).
+ */
+ public static class CreateBuilder extends Builder<CreateBuilder> {
+ /**
+ * Supply required properties for creating a HealthMonitor's CreateBuilder.
+ *
+ * @param type the probe type.
+ * @param delay the delay.
+ * @param timeout the timeout.
+ * @param maxRetries the max retries.
+ */
+ private CreateBuilder(ProbeType type, Integer delay, Integer timeout, Integer maxRetries) {
+ type(type).delay(delay).timeout(timeout).maxRetries(maxRetries);
+ }
+
+ /**
+ * Provides the tenantId for this HealthMonitor's CreateBuilder. Admin-only.
+ * When keystone is enabled, it is not mandatory to specify tenant_id for resources in create requests, as the
+ * tenant identifier will be derived from the Authentication token. Please note that the default authorization
+ * settings only allow administrative users to create resources on behalf of a different tenant.
+ *
+ * @return the Builder.
+ * @see HealthMonitor#getTenantId()
+ */
+ public CreateBuilder tenantId(String tenantId) {
+ healthMonitor.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * Provides the probe type for this HealthMonitor's Builder.
+ *
+ * @return the Builder.
+ * @see HealthMonitor#getType()
+ */
+ public CreateBuilder type(ProbeType type) {
+ healthMonitor.type = type;
+ return self();
+ }
+
+ /**
+ * @return a CreateHealthMonitor constructed with this Builder.
+ */
+ public CreateHealthMonitor build() {
+ return new CreateHealthMonitor(healthMonitor);
+ }
+
+ @Override
+ protected CreateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Update builder (inheriting from Builder).
+ */
+ public static class UpdateBuilder extends Builder<UpdateBuilder> {
+ /**
+ * Supply required properties for creating a HealthMonitor's UpdateBuilder.
+ */
+ private UpdateBuilder() {
+ }
+
+ /**
+ * @return an UpdateHealthMonitor constructed with this Builder.
+ */
+ public UpdateHealthMonitor build() {
+ return new UpdateHealthMonitor(healthMonitor);
+ }
+
+ @Override
+ protected UpdateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Create options - extend the domain class, passed to API create calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class CreateHealthMonitor extends HealthMonitor {
+ /**
+ * Copy constructor.
+ *
+ * @param healthMonitor the HealthMonitor to copy from.
+ */
+ private CreateHealthMonitor(HealthMonitor healthMonitor) {
+ super(healthMonitor);
+ }
+ }
+
+ /**
+ * Update options - extend the domain class, passed to API update calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class UpdateHealthMonitor extends HealthMonitor {
+ /**
+ * Copy constructor.
+ *
+ * @param healthMonitor the HealthMonitor to copy from.
+ */
+ private UpdateHealthMonitor(HealthMonitor healthMonitor) {
+ super(healthMonitor);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitorStatus.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitorStatus.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitorStatus.java
new file mode 100644
index 0000000..64e3aea
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitorStatus.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * A Neutron LBaaS v1 HealthMonitorStatus.
+ * Contains an id and status describing the health monitor's status.
+ *
+ * @see Pool#getHealthMonitorsStatus()
+ */
+public class HealthMonitorStatus {
+
+ // Mandatory attributes
+ @Named("monitor_id")
+ protected final String id;
+ protected final LBaaSStatus status;
+ // Optional attributes
+ @Named("status_description")
+ protected final String statusDescription;
+
+ @ConstructorProperties({ "monitor_id", "status", "status_description" })
+ protected HealthMonitorStatus(String id, LBaaSStatus status, String statusDescription) {
+ this.id = id;
+ this.status = status;
+ this.statusDescription = statusDescription;
+ }
+
+ /**
+ * @return the id of the HealthMonitorStatus.
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the status of the HealthMonitorStatus
+ */
+ @Nullable
+ public LBaaSStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @return the status description of the HealthMonitorStatus
+ */
+ @Nullable
+ public String getStatusDescription() {
+ return statusDescription;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, status, statusDescription);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ HealthMonitorStatus that = HealthMonitorStatus.class.cast(obj);
+ return Objects.equal(this.id, that.id) && Objects.equal(this.status, that.status)
+ && Objects.equal(this.statusDescription, that.statusDescription);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this).add("id", id).add("status", status)
+ .add("statusDescription", statusDescription);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitors.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitors.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitors.java
new file mode 100644
index 0000000..a254938
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitors.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A collection of Neutron LBaaS v1 HealthMonitors.
+ */
+public class HealthMonitors extends PaginatedCollection<HealthMonitor> {
+ public static final HealthMonitors EMPTY = new HealthMonitors(ImmutableSet.<HealthMonitor> of(),
+ ImmutableSet.<Link> of());
+
+ @ConstructorProperties({ "health_monitors", "health_monitors_links" })
+ protected HealthMonitors(Iterable<HealthMonitor> healthMonitors, Iterable<Link> healthMonitorsLinks) {
+ super(healthMonitors, healthMonitorsLinks);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HttpMethod.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HttpMethod.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HttpMethod.java
new file mode 100644
index 0000000..f795c66
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HttpMethod.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+
+/**
+ * Enumerates supported HTTP methods used by probes of type HTTP/HTTPS that are sent by health monitor to verify member state.
+ */
+public enum HttpMethod {
+ /**
+ * Health monitor sends a GET HTTP request to the member.
+ */
+ GET("GET"),
+ /**
+ * Health monitor sends a POST HTTP request to the member.
+ */
+ POST("POST"),
+ /**
+ * Health monitor sends a PUT HTTP request to the member.
+ */
+ PUT("PUT"),
+ /**
+ * Health monitor sends a DELETE HTTP request to the member.
+ */
+ DELETE("DELETE"),
+ /**
+ * Health monitor sends a HEAD HTTP request to the member.
+ */
+ HEAD("HEAD"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private String name;
+
+ private HttpMethod(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * */
+ public static HttpMethod fromValue(String name){
+ if (name != null) {
+ for (HttpMethod value : HttpMethod.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/LBaaSStatus.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/LBaaSStatus.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/LBaaSStatus.java
new file mode 100644
index 0000000..85820fc
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/LBaaSStatus.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+/**
+ * Enumerates supported Neutron LBaaS v1 resources status.
+ */
+public enum LBaaSStatus {
+ /**
+ * The LBaaS v1 resource is ready and active.
+ */
+ ACTIVE("active"),
+ /**
+ * The LBaaS v1 resource is being created.
+ */
+ PENDING_CREATE("pending_create"),
+ /**
+ * The LBaaS v1 resource is being updated.
+ */
+ PENDING_UPDATE("pending_update"),
+ /**
+ * The LBaaS v1 resource is going to be deleted.
+ */
+ PENDING_DELETE("pending_delete"),
+ /**
+ * The LBaaS v1 resource is created but not active.
+ */
+ INACTIVE("inactive"),
+ /**
+ * The LBaaS v1 resource is in an error state.
+ */
+ ERROR("error"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private String name;
+
+ private LBaaSStatus(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * */
+ public static LBaaSStatus fromValue(String name){
+ if (name != null) {
+ for (LBaaSStatus value : LBaaSStatus.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Member.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Member.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Member.java
new file mode 100644
index 0000000..da53e23
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Member.java
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * A Neutron LBaaS v1 Member.
+ */
+public class Member {
+
+ // Mandatory attributes when creating
+ @Named("tenant_id")
+ private String tenantId;
+ private String address;
+ @Named("protocol_port")
+ private Integer protocolPort;
+ // Mandatory attributes that can be updated
+ @Named("pool_id")
+ private String poolId;
+ // Optional attributes that can be updated
+ private Integer weight;
+ @Named("admin_state_up")
+ private Boolean adminStateUp;
+ // Read-only attributes
+ private String id;
+ private LBaaSStatus status;
+ @Named("status_description")
+ private String statusDescription;
+
+ /**
+ * Deserialization constructor.
+ */
+ @ConstructorProperties({ "id", "tenant_id", "pool_id", "address", "protocol_port", "weight", "admin_state_up",
+ "status", "status_description" })
+ private Member(String id, String tenantId, String poolId, String address, Integer protocolPort, Integer weight,
+ Boolean adminStateUp, LBaaSStatus status, String statusDescription) {
+ this.id = id;
+ this.tenantId = tenantId;
+ this.poolId = poolId;
+ this.address = address;
+ this.protocolPort = protocolPort;
+ this.weight = weight;
+ this.adminStateUp = adminStateUp;
+ this.status = status;
+ this.statusDescription = statusDescription;
+ }
+
+ /**
+ * Default constructor.
+ */
+ private Member() {
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param member the Member to copy from.
+ */
+ private Member(Member member) {
+ this(member.id, member.tenantId, member.poolId, member.address, member.protocolPort, member.weight,
+ member.adminStateUp, member.status, member.statusDescription);
+ }
+
+ /**
+ * @return the id of the Member.
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the tenant id of the Member.
+ */
+ @Nullable
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return the pool id for this Member.
+ */
+ @Nullable
+ public String getPoolId() {
+ return poolId;
+ }
+
+ /**
+ * @return the address for this Member.
+ */
+ @Nullable
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * @return the protocol port for this Member.
+ */
+ @Nullable
+ public Integer getProtocolPort() {
+ return protocolPort;
+ }
+
+ /**
+ * @return the weight for this Member.
+ */
+ @Nullable
+ public Integer getWeight() {
+ return weight;
+ }
+
+ /**
+ * @return the administrative state for this Member.
+ */
+ @Nullable
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the status for this Member.
+ */
+ @Nullable
+ public LBaaSStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @return the status description for this Member.
+ */
+ @Nullable
+ public String getStatusDescription() {
+ return statusDescription;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Member that = (Member) o;
+
+ return Objects.equal(this.id, that.id) && Objects.equal(this.tenantId, that.tenantId)
+ && Objects.equal(this.poolId, that.poolId) && Objects.equal(this.address, that.address)
+ && Objects.equal(this.protocolPort, that.protocolPort) && Objects.equal(this.weight, that.weight)
+ && Objects.equal(this.adminStateUp, that.adminStateUp) && Objects.equal(this.status, that.status)
+ && Objects.equal(this.statusDescription, that.statusDescription);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, tenantId, poolId, address, protocolPort, weight, adminStateUp, status,
+ statusDescription);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this).add("id", id).add("tenantId", tenantId).add("poolId", poolId)
+ .add("address", address).add("protocolPort", protocolPort).add("weight", weight)
+ .add("adminStateUp", adminStateUp).add("status", status).add("statusDescription", statusDescription)
+ .toString();
+ }
+
+ /*
+ * Methods to get the Create and Update builders follow.
+ */
+
+ /**
+ * @return the Builder for creating a new Member.
+ */
+ public static CreateBuilder createBuilder(String poolId, String address, Integer port) {
+ return new CreateBuilder(poolId, address, port);
+ }
+
+ /**
+ * @return the Builder for updating a Member.
+ */
+ public static UpdateBuilder updateBuilder() {
+ return new UpdateBuilder();
+ }
+
+ private abstract static class Builder<ParameterizedBuilderType> {
+ protected Member member;
+
+ /**
+ * Default constructor.
+ */
+ private Builder() {
+ member = new Member();
+ }
+
+ protected abstract ParameterizedBuilderType self();
+
+ /**
+ * Provides the pool id for this Member's Builder.
+ *
+ * @return the Builder.
+ * @see Member#getPoolId()
+ */
+ public ParameterizedBuilderType poolId(String poolId) {
+ member.poolId = poolId;
+ return self();
+ }
+
+ /**
+ * Provides the weight for this Member's Builder.
+ *
+ * @return the Builder.
+ * @see Member#getWeight()
+ */
+ public ParameterizedBuilderType weight(Integer weight) {
+ member.weight = weight;
+ return self();
+ }
+
+ /**
+ * Provides the administrative state for this Member's Builder.
+ *
+ * @return the Builder.
+ * @see Member#getAdminStateUp()
+ */
+ public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) {
+ member.adminStateUp = adminStateUp;
+ return self();
+ }
+ }
+
+ /**
+ * Create builder (inheriting from Builder).
+ */
+ public static class CreateBuilder extends Builder<CreateBuilder> {
+ /**
+ * Supply required properties for creating a Member's CreateBuilder.
+ *
+ * @param poolId the pool id.
+ * @param address the IP address.
+ * @param port the protocol port.
+ */
+ private CreateBuilder(String poolId, String address, Integer port) {
+ poolId(poolId).address(address).protocolPort(port);
+ }
+
+ /**
+ * Provides the tenantId for this Member's Builder. Admin-only.
+ * When keystone is enabled, it is not mandatory to specify tenant_id for resources in create requests, as the
+ * tenant identifier will be derived from the Authentication token. Please note that the default authorization
+ * settings only allow administrative users to create resources on behalf of a different tenant.
+ *
+ * @return the Builder.
+ * @see Member#getTenantId()
+ */
+ public CreateBuilder tenantId(String tenantId) {
+ member.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * Provides the address for this Member's Builder.
+ *
+ * @return the Builder.
+ * @see Member#getAddress()
+ */
+ public CreateBuilder address(String address) {
+ member.address = address;
+ return self();
+ }
+
+ /**
+ * Provides the protocol port for this Member's Builder.
+ *
+ * @return the Builder.
+ * @see Member#getProtocolPort()
+ */
+ public CreateBuilder protocolPort(Integer protocolPort) {
+ member.protocolPort = protocolPort;
+ return self();
+ }
+
+ /**
+ * @return a CreateMember constructed with this Builder.
+ */
+ public CreateMember build() {
+ return new CreateMember(member);
+ }
+
+ @Override
+ protected CreateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Update builder (inheriting from Builder).
+ */
+ public static class UpdateBuilder extends Builder<UpdateBuilder> {
+ /**
+ * Supply required properties for creating a Member's UpdateBuilder.
+ */
+ private UpdateBuilder() {
+ }
+
+ /**
+ * @return a UpdateMember constructed with this Builder.
+ */
+ public UpdateMember build() {
+ return new UpdateMember(member);
+ }
+
+ @Override
+ protected UpdateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Create options - extend the domain class, passed to API create calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class CreateMember extends Member {
+ /**
+ * Copy constructor.
+ *
+ * @param member the Member to copy from.
+ */
+ private CreateMember(Member member) {
+ super(member);
+ }
+ }
+
+ /**
+ * Update options - extend the domain class, passed to API update calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class UpdateMember extends Member {
+ /**
+ * Copy constructor.
+ *
+ * @param member the Member to copy from.
+ */
+ private UpdateMember(Member member) {
+ super(member);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Members.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Members.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Members.java
new file mode 100644
index 0000000..74a464d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Members.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A collection of of Neutron LBaaS v1 Members.
+ */
+public class Members extends PaginatedCollection<Member> {
+ public static final Members EMPTY = new Members(ImmutableSet.<Member> of(), ImmutableSet.<Link> of());
+
+ @ConstructorProperties({ "members", "members_links" })
+ protected Members(Iterable<Member> members, Iterable<Link> membersLinks) {
+ super(members, membersLinks);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pool.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pool.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pool.java
new file mode 100644
index 0000000..c1aa88d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pool.java
@@ -0,0 +1,481 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A Neutron LBaaS v1 Pool.
+ */
+public class Pool {
+
+ // Load balancing methods that must be supported by all providers.
+ // Not an enum type because any provider may support additional balancing methods.
+ public static String ROUND_ROBIN = "ROUND_ROBIN";
+ public static String LEAST_CONNECTIONS = "LEAST_CONNECTIONS";
+ public static String SOURCE_IP = "SOURCE_IP";
+
+ // Mandatory attributes when creating
+ @Named("tenant_id")
+ private String tenantId;
+ @Named("subnet_id")
+ private String subnetId;
+ private Protocol protocol;
+ // Mandatory attributes that can be updated
+ @Named("lb_method")
+ private String lbMethod;
+ // Optional attributes when creating
+ private String provider;
+ // Optional attributes that can be updated
+ private String name;
+ private String description;
+ @Named("health_monitors")
+ private ImmutableSet<String> healthMonitors;
+ @Named("admin_state_up")
+ private Boolean adminStateUp;
+ // Read-only attributes
+ private String id;
+ @Named("vip_id")
+ private String vipId;
+ private ImmutableSet<String> members;
+ @Named("health_monitors_status")
+ private ImmutableList<HealthMonitorStatus> healthMonitorsStatus;
+ private LBaaSStatus status;
+ @Named("status_description")
+ private String statusDescription;
+
+ /**
+ * Deserialization constructor.
+ */
+ @ConstructorProperties({ "id", "tenant_id", "vip_id", "name", "description", "subnet_id", "protocol", "provider",
+ "lb_method", "health_monitors", "health_monitors_status", "members", "admin_state_up", "status",
+ "status_description" })
+ private Pool(String id, String tenantId, String vipId, String name, String description, String subnetId,
+ Protocol protocol, String provider, String lbMethod, ImmutableSet<String> healthMonitors,
+ ImmutableList<HealthMonitorStatus> healthMonitorsStatus, ImmutableSet<String> members, Boolean adminStateUp,
+ LBaaSStatus status, String statusDescription) {
+ this.id = id;
+ this.tenantId = tenantId;
+ this.vipId = vipId;
+ this.name = name;
+ this.description = description;
+ this.subnetId = subnetId;
+ this.protocol = protocol;
+ this.provider = provider;
+ this.lbMethod = lbMethod;
+ this.healthMonitors = healthMonitors;
+ this.healthMonitorsStatus = healthMonitorsStatus;
+ this.members = members;
+ this.adminStateUp = adminStateUp;
+ this.status = status;
+ this.statusDescription = statusDescription;
+ }
+
+ /**
+ * Default constructor.
+ */
+ private Pool() {
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param pool the Pool to copy from.
+ */
+ private Pool(Pool pool) {
+ this(pool.id, pool.tenantId, pool.vipId, pool.name, pool.description, pool.subnetId, pool.protocol,
+ pool.provider, pool.lbMethod, pool.healthMonitors, pool.healthMonitorsStatus, pool.members,
+ pool.adminStateUp, pool.status, pool.statusDescription);
+ }
+
+ /**
+ * @return the id of the Pool.
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the tenant id of the Pool.
+ */
+ @Nullable
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return the virtual IP id of the Pool.
+ */
+ @Nullable
+ public String getVIPId() {
+ return vipId;
+ }
+
+ /**
+ * @return the name of the Pool.
+ */
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the description of the Pool.
+ */
+ @Nullable
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @return the subnet id for this Pool.
+ */
+ @Nullable
+ public String getSubnetId() {
+ return subnetId;
+ }
+
+ /**
+ * @return the protocol for this Pool.
+ */
+ @Nullable
+ public Protocol getProtocol() {
+ return protocol;
+ }
+
+ /**
+ * @return the provider for this Pool.
+ */
+ @Nullable
+ public String getProvider() {
+ return provider;
+ }
+
+ /**
+ * @return the load balancing method for this Pool.
+ */
+ @Nullable
+ public String getLBMethod() {
+ return lbMethod;
+ }
+
+ /**
+ * @return the health monitors for this Pool.
+ */
+ @Nullable
+ public ImmutableSet<String> getHealthMonitors() {
+ return healthMonitors;
+ }
+
+ /**
+ * @return the health monitors status for this Pool.
+ */
+ @Nullable
+ public ImmutableList<HealthMonitorStatus> getHealthMonitorsStatus() {
+ return healthMonitorsStatus;
+ }
+
+ /**
+ * @return the members for this Pool.
+ */
+ @Nullable
+ public ImmutableSet<String> getMembers() {
+ return members;
+ }
+
+ /**
+ * @return the administrative state for this Pool.
+ */
+ @Nullable
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the status for this Pool.
+ */
+ @Nullable
+ public LBaaSStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @return the status description for this Pool.
+ */
+ @Nullable
+ public String getStatusDescription() {
+ return statusDescription;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Pool that = (Pool) o;
+
+ return Objects.equal(this.id, that.id) && Objects.equal(this.tenantId, that.tenantId)
+ && Objects.equal(this.vipId, that.vipId) && Objects.equal(this.name, that.name)
+ && Objects.equal(this.description, that.description) && Objects.equal(this.subnetId, that.subnetId)
+ && Objects.equal(this.protocol, that.protocol) && Objects.equal(this.provider, that.provider)
+ && Objects.equal(this.lbMethod, that.lbMethod) && Objects.equal(this.healthMonitors, that.healthMonitors)
+ && Objects.equal(this.healthMonitorsStatus, that.healthMonitorsStatus)
+ && Objects.equal(this.members, that.members) && Objects.equal(this.adminStateUp, that.adminStateUp)
+ && Objects.equal(this.status, that.status) && Objects.equal(this.statusDescription, that.statusDescription);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, tenantId, vipId, name, description, subnetId, protocol, provider, lbMethod,
+ healthMonitors, healthMonitorsStatus, members, adminStateUp, status, statusDescription);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this).add("id", id).add("tenantId", tenantId).add("vipId", vipId)
+ .add("name", name).add("description", description).add("subnetId", subnetId).add("protocol", protocol)
+ .add("provider", provider).add("lbMethod", lbMethod).add("healthMonitors", healthMonitors)
+ .add("healthMonitorsStatus", healthMonitorsStatus).add("members", members)
+ .add("adminStateUp", adminStateUp).add("status", status).add("statusDescription", statusDescription)
+ .toString();
+ }
+
+ /*
+ * Methods to get the Create and Update builders follow.
+ */
+
+ /**
+ * @return the Builder for creating a new Pool.
+ */
+ public static CreateBuilder createBuilder(String subnetId, Protocol protocol, String lbMethod) {
+ return new CreateBuilder(subnetId, protocol, lbMethod);
+ }
+
+ /**
+ * @return the Builder for updating a Pool.
+ */
+ public static UpdateBuilder updateBuilder() {
+ return new UpdateBuilder();
+ }
+
+ private abstract static class Builder<ParameterizedBuilderType> {
+ protected Pool pool;
+
+ /**
+ * Default constructor.
+ */
+ private Builder() {
+ pool = new Pool();
+ }
+
+ protected abstract ParameterizedBuilderType self();
+
+ /**
+ * Provides the name for this Pool's Builder.
+ *
+ * @return the Builder.
+ * @see Pool#getName()
+ */
+ public ParameterizedBuilderType name(String name) {
+ pool.name = name;
+ return self();
+ }
+
+ /**
+ * Provides the description for this Pool's Builder.
+ *
+ * @return the Builder.
+ * @see Pool#getDescription()
+ */
+ public ParameterizedBuilderType description(String description) {
+ pool.description = description;
+ return self();
+ }
+
+ /**
+ * Provides the load balancing method for this Pool's Builder.
+ *
+ * @return the Builder.
+ * @see Pool#getLBMethod()
+ */
+ public ParameterizedBuilderType lbMethod(String lbMethod) {
+ pool.lbMethod = lbMethod;
+ return self();
+ }
+
+ /**
+ * Provides the health monitors for this Pool's Builder.
+ *
+ * @return the Builder.
+ * @see Pool#getHealthMonitors()
+ */
+ public ParameterizedBuilderType healthMonitors(ImmutableSet<String> healthMonitors) {
+ pool.healthMonitors = healthMonitors;
+ return self();
+ }
+
+ /**
+ * Provides the administrative state for this Pool's Builder.
+ *
+ * @return the Builder.
+ * @see Pool#getAdminStateUp()
+ */
+ public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) {
+ pool.adminStateUp = adminStateUp;
+ return self();
+ }
+ }
+
+ /**
+ * Create builder (inheriting from Builder).
+ */
+ public static class CreateBuilder extends Builder<CreateBuilder> {
+ /**
+ * Supply required properties for creating a Pool's CreateBuilder.
+ *
+ * @param subnetId the subnet id.
+ * @param protocol the protocol.
+ * @param lbMethod the load balancing method.
+ */
+ private CreateBuilder(String subnetId, Protocol protocol, String lbMethod) {
+ subnetId(subnetId).protocol(protocol).lbMethod(lbMethod);
+ }
+
+ /**
+ * Provides the tenantId for this Pool's Builder. Admin-only.
+ * When keystone is enabled, it is not mandatory to specify tenant_id for resources in create requests, as the
+ * tenant identifier will be derived from the Authentication token. Please note that the default authorization
+ * settings only allow administrative users to create resources on behalf of a different tenant.
+ *
+ * @return the Builder.
+ * @see Pool#getTenantId()
+ */
+ public CreateBuilder tenantId(String tenantId) {
+ pool.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * Provides the subnet id for this Pool's Builder.
+ *
+ * @return the Builder.
+ * @see Pool#getSubnetId()
+ */
+ public CreateBuilder subnetId(String subnetId) {
+ pool.subnetId = subnetId;
+ return self();
+ }
+
+ /**
+ * Provides the protocol for this Pool's Builder.
+ *
+ * @return the Builder.
+ * @see Pool#getProtocol()
+ */
+ public CreateBuilder protocol(Protocol protocol) {
+ pool.protocol = protocol;
+ return self();
+ }
+
+ /**
+ * Provides the provider for this Pool's Builder.
+ *
+ * @return the Builder.
+ * @see Pool#getProvider()
+ */
+ public CreateBuilder provider(String provider) {
+ pool.provider = provider;
+ return self();
+ }
+
+ /**
+ * @return a CreatePool constructed with this Builder.
+ */
+ public CreatePool build() {
+ return new CreatePool(pool);
+ }
+
+ @Override
+ protected CreateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Update builder (inheriting from Builder).
+ */
+ public static class UpdateBuilder extends Builder<UpdateBuilder> {
+ /**
+ * Supply required properties for creating a Pool's UpdateBuilder.
+ */
+ private UpdateBuilder() {
+ }
+
+ /**
+ * @return a UpdatePool constructed with this Builder.
+ */
+ public UpdatePool build() {
+ return new UpdatePool(pool);
+ }
+
+ @Override
+ protected UpdateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Create options - extend the domain class, passed to API create calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class CreatePool extends Pool {
+ /**
+ * Copy constructor.
+ *
+ * @param pool the Pool to copy from.
+ */
+ private CreatePool(Pool pool) {
+ super(pool);
+ }
+ }
+
+ /**
+ * Update options - extend the domain class, passed to API update calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class UpdatePool extends Pool {
+ /**
+ * Copy constructor.
+ *
+ * @param pool the Pool to copy from.
+ */
+ private UpdatePool(Pool pool) {
+ super(pool);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/PoolStatus.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/PoolStatus.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/PoolStatus.java
new file mode 100644
index 0000000..869eb81
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/PoolStatus.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * A Neutron LBaaS v1 PoolStatus.
+ * Contains an id and status describing the pool's status.
+ *
+ * @see HealthMonitor#getPools()
+ */
+public class PoolStatus {
+
+ // Mandatory attributes
+ @Named("pool_id")
+ protected final String id;
+ protected final LBaaSStatus status;
+ // Optional attributes
+ @Named("status_description")
+ protected final String statusDescription;
+
+ @ConstructorProperties({ "pool_id", "status", "status_description" })
+ protected PoolStatus(String id, LBaaSStatus status, String statusDescription) {
+ this.id = id;
+ this.status = status;
+ this.statusDescription = statusDescription;
+ }
+
+ /**
+ * @return the id of the PoolStatus.
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the status of the PoolStatus.
+ */
+ @Nullable
+ public LBaaSStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @return the status description of the PoolStatus.
+ */
+ @Nullable
+ public String getStatusDescription() {
+ return statusDescription;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, status, statusDescription);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ PoolStatus that = PoolStatus.class.cast(obj);
+ return Objects.equal(this.id, that.id) && Objects.equal(this.status, that.status)
+ && Objects.equal(this.statusDescription, that.statusDescription);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this).add("id", id).add("status", status)
+ .add("statusDescription", statusDescription);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pools.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pools.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pools.java
new file mode 100644
index 0000000..c30bc13
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pools.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A collection of of Neutron LBaaS v1 Pools.
+ */
+public class Pools extends PaginatedCollection<Pool> {
+ public static final Pools EMPTY = new Pools(ImmutableSet.<Pool> of(), ImmutableSet.<Link> of());
+
+ @ConstructorProperties({ "pools", "pools_links" })
+ protected Pools(Iterable<Pool> pools, Iterable<Link> poolsLinks) {
+ super(pools, poolsLinks);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/ProbeType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/ProbeType.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/ProbeType.java
new file mode 100644
index 0000000..fb5d565
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/ProbeType.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+/**
+ * Enumerates supported types of probe sent by health monitor to verify member state.
+ */
+public enum ProbeType {
+ /**
+ * Health monitor pings the members by using ICMP.
+ */
+ PING("PING"),
+ /**
+ * Health monitor connects to the members by using TCP.
+ */
+ TCP("TCP"),
+ /**
+ * Health monitor sends an HTTP request to the member.
+ */
+ HTTP("HTTP"),
+ /**
+ * Health monitor sends a secure HTTP request to the member.
+ */
+ HTTPS("HTTPS"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private String name;
+
+ private ProbeType(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * */
+ public static ProbeType fromValue(String name){
+ if (name != null) {
+ for (ProbeType value : ProbeType.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Protocol.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Protocol.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Protocol.java
new file mode 100644
index 0000000..e353863
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Protocol.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+/**
+ * Enumerates supported protocols.
+ * Protocol must be specified for the front-end (see {@link VIP}) and for the back-end instances (see {@link Pool}).
+ */
+public enum Protocol {
+ /**
+ * Use TCP for routing traffic.
+ */
+ TCP("TCP"),
+ /**
+ * Use HTTP for routing traffic.
+ */
+ HTTP("HTTP"),
+ /**
+ * Use HTTPS for routing traffic.
+ */
+ HTTPS("HTTPS"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private String name;
+
+ private Protocol(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * */
+ public static Protocol fromValue(String name){
+ if (name != null) {
+ for (Protocol value : Protocol.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/SessionPersistence.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/SessionPersistence.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/SessionPersistence.java
new file mode 100644
index 0000000..b1c49dd
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/SessionPersistence.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * A Neutron LBaaS v1 SessionPersistence.
+ * Contains a type and cookie name describing the session persistence.
+ */
+public class SessionPersistence {
+
+ // Mandatory attributes
+ protected final Type type;
+ // Optional attributes
+ @Named("cookie_name")
+ protected final String cookieName;
+
+ @ConstructorProperties({ "type", "cookie_name" })
+ protected SessionPersistence(Type type, String cookieName) {
+ this.type = type;
+ this.cookieName = cookieName;
+ }
+
+ /**
+ * @return the type of the SessionPersistence.
+ */
+ @Nullable
+ public Type getType() {
+ return type;
+ }
+
+ /**
+ * @return the cookie name of the SessionPersistence.
+ */
+ @Nullable
+ public String getCookieName() {
+ return cookieName;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(type, cookieName);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ SessionPersistence that = SessionPersistence.class.cast(obj);
+ return Objects.equal(this.type, that.type) && Objects.equal(this.cookieName, that.cookieName);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this).add("type", type).add("cookieName", cookieName);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ /*
+ * Methods to get the builder follow.
+ */
+
+ /**
+ * @return the Builder for SessionPersistence.
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder.
+ */
+ public static class Builder {
+ protected Type type;
+ protected String cookieName;
+
+ /**
+ * Provides the type to the SessionPersistence's Builder.
+ *
+ * @return the Builder.
+ * @see SessionPersistence#getType()
+ */
+ public Builder type(Type type) {
+ this.type = type;
+ return this;
+ }
+
+ /**
+ * Provides the cookie name to the SessionPersistence's Builder.
+ *
+ * @return the Builder.
+ * @see SessionPersistence#getCookieName()
+ */
+ public Builder cookieName(String cookieName) {
+ this.cookieName = cookieName;
+ return this;
+ }
+
+ /**
+ * @return a SessionPersistence constructed with this Builder.
+ */
+ public SessionPersistence build() {
+ return new SessionPersistence(type, cookieName);
+ }
+ }
+
+ /**
+ * Enumerates supported SessionPersistence types.
+ */
+ public static enum Type {
+ /**
+ * All connections that originate from the same source IP address are handled by the same member of the pool.
+ */
+ SOURCE_IP("SOURCE_IP"),
+ /**
+ * The load balancing function creates a cookie on the first request from a client. Subsequent requests that
+ * contain the same cookie value are handled by the same member of the pool.
+ */
+ HTTP_COOKIE("HTTP_COOKIE"),
+ /**
+ * The load balancing function relies on a cookie established by the back-end application. All requests with the
+ * same cookie value are handled by the same member of the pool.
+ */
+ APP_COOKIE("APP_COOKIE"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private String name;
+
+ private Type(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * */
+ public static Type fromValue(String name){
+ if (name != null) {
+ for (Type value : Type.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+ }
+}
[36/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseImageTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseImageTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseImageTest.java
new file mode 100644
index 0000000..99cfd6f
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseImageTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class ParseImageTest extends BaseGoogleComputeEngineParseTest<Image> {
+
+ @Override
+ public String resource() {
+ return "/image_get.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Image expected() {
+ return Image.builder()
+ .id("12941197498378735318")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-07-16T22:16:13.468"))
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-2" +
+ "-v20120326"))
+ .name("centos-6-2-v20120326")
+ .description("DEPRECATED. CentOS 6.2 image; Created Mon, 26 Mar 2012 21:19:09 +0000")
+ .sourceType("RAW")
+ .rawDisk(
+ Image.RawDisk.builder()
+ .source("")
+ .containerType("TAR")
+ .build()
+ ).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceListTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceListTest.java
new file mode 100644
index 0000000..ad6041b
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceListTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Resource;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+
+import com.google.common.collect.ImmutableSet;
+
+public class ParseInstanceListTest extends BaseGoogleComputeEngineParseTest<ListPage<Instance>> {
+
+ @Override
+ public String resource() {
+ return "/instance_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListPage<Instance> expected() {
+ return ListPage.<Instance>builder()
+ .kind(Resource.Kind.INSTANCE_LIST)
+ .id("projects/myproject/zones/us-central1-a/instances")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances"))
+ .items(ImmutableSet.of(new ParseInstanceTest().expected()))
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceSerialOutputTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceSerialOutputTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceSerialOutputTest.java
new file mode 100644
index 0000000..f44baa1
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceSerialOutputTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+
+public class ParseInstanceSerialOutputTest extends BaseGoogleComputeEngineParseTest<Instance.SerialPortOutput> {
+
+ @Override
+ public String resource() {
+ return "/instance_serial_port.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Instance.SerialPortOutput expected() {
+ return Instance.SerialPortOutput.builder()
+ .contents("console output").build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceTest.java
new file mode 100644
index 0000000..5abdf6a
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceTest.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.Metadata;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+
+import com.google.common.collect.ImmutableMap;
+
+public class ParseInstanceTest extends BaseGoogleComputeEngineParseTest<Instance> {
+
+ @Override
+ public String resource() {
+ return "/instance_get.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Instance expected() {
+ return Instance.builder()
+ .id("13051190678907570425")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T23:48:20.758"))
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-0"))
+ .description("desc")
+ .name("test-0")
+ .machineType(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1" +
+ "-standard-1"))
+ .status(Instance.Status.RUNNING)
+ .zone(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"))
+ .addNetworkInterface(
+ Instance.NetworkInterface.builder()
+ .name("nic0")
+ .networkIP("10.240.121.115")
+ .network(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/default"))
+ .build()
+ )
+ .addDisk(
+ Instance.PersistentAttachedDisk.builder()
+ .index(0)
+ .mode(Instance.PersistentAttachedDisk.Mode.READ_WRITE)
+ .deviceName("test")
+ .source(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/test"))
+ .boot(true)
+ .build()
+ )
+ .tags(Instance.Tags.builder().fingerprint("abcd").addItem("aTag").build())
+ .metadata(Metadata.builder()
+ .items(ImmutableMap.of("aKey", "aValue",
+ "jclouds-image",
+ "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140718",
+ "jclouds-delete-boot-disk", "true"))
+ .fingerprint("efgh")
+ .build())
+ .addServiceAccount(Instance.ServiceAccount.builder().email("default").addScopes("myscope").build())
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseMachineTypeListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseMachineTypeListTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseMachineTypeListTest.java
new file mode 100644
index 0000000..f8146d2
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseMachineTypeListTest.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import static org.jclouds.googlecomputeengine.domain.Resource.Kind.MACHINE_TYPE_LIST;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.MachineType;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+
+public class ParseMachineTypeListTest extends BaseGoogleComputeEngineParseTest<ListPage<MachineType>> {
+
+
+ @Override
+ public String resource() {
+ return "/machinetype_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListPage<MachineType> expected() {
+ SimpleDateFormatDateService dateService = new SimpleDateFormatDateService();
+ return ListPage.<MachineType>builder()
+ .kind(MACHINE_TYPE_LIST)
+ .id("projects/myproject/machineTypes")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes"))
+ .addItem(MachineType.builder()
+ .id("4618642685664990776")
+ .creationTimestamp(dateService.iso8601DateParse("2013-04-25T13:32:49.088-07:00"))
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/f1-micro"))
+ .zone("us-central1-a")
+ .name("f1-micro")
+ .description("1 vCPU (shared physical core) and 0.6 GB RAM")
+ .guestCpus(1)
+ .memoryMb(614)
+ .maximumPersistentDisks(4)
+ .maximumPersistentDisksSizeGb(3072)
+ .build())
+ .addItem(MachineType.builder()
+ .id("12907738072351752276")
+ .creationTimestamp(dateService.iso8601DateParse("2012-06-07T20:48:14.670"))
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1"))
+ .zone("us-central1-a")
+ .name("n1-standard-1")
+ .description("1 vCPU, 3.75 GB RAM, and a 10 GB ephemeral root disk")
+ .guestCpus(1)
+ .memoryMb(3840)
+ .maximumPersistentDisks(16)
+ .maximumPersistentDisksSizeGb(128)
+ .build())
+ .addItem(MachineType.builder()
+ .id("12908560709887590691")
+ .creationTimestamp(dateService.iso8601DateParse("2012-06-07T20:51:19.936"))
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-8-d"))
+ .zone("us-central1-a")
+ .name("n1-standard-8-d")
+ .description("8 vCPUs, 30 GB RAM, a 10 GB ephemeral root disk, " +
+ "and 2 extra 1770 GB ephemeral disks")
+ .guestCpus(8)
+ .memoryMb(30720)
+ .addScratchDisk(1770)
+ .addScratchDisk(1770)
+ .maximumPersistentDisks(16)
+ .maximumPersistentDisksSizeGb(1024)
+ .build())
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseMachineTypeTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseMachineTypeTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseMachineTypeTest.java
new file mode 100644
index 0000000..c1f1fad
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseMachineTypeTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.MachineType;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+
+public class ParseMachineTypeTest extends BaseGoogleComputeEngineParseTest<MachineType> {
+
+
+ @Override
+ public String resource() {
+ return "/machinetype.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public MachineType expected() {
+ SimpleDateFormatDateService dateService = new SimpleDateFormatDateService();
+ return MachineType.builder()
+ .id("12907738072351752276")
+ .creationTimestamp(dateService.iso8601DateParse("2012-06-07T20:48:14.670"))
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1" +
+ "-standard-1"))
+ .zone("us-central1-a")
+ .name("n1-standard-1")
+ .description("1 vCPU, 3.75 GB RAM, and a 10 GB ephemeral root disk")
+ .guestCpus(1)
+ .memoryMb(3840)
+ .addScratchDisk(1770)
+ .addScratchDisk(1770)
+ .maximumPersistentDisks(16)
+ .maximumPersistentDisksSizeGb(128)
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseMetadataTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseMetadataTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseMetadataTest.java
new file mode 100644
index 0000000..877bc31
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseMetadataTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.domain.Metadata;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+@Test(groups = "unit")
+public class ParseMetadataTest extends BaseGoogleComputeEngineParseTest<Metadata> {
+
+ @Override
+ public String resource() {
+ return "/metadata.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Metadata expected() {
+ return new Metadata("efgh",
+ ImmutableMap.<String, String>builder()
+ .put("propA", "valueA")
+ .put("propB", "valueB")
+ .build());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseNetworkListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseNetworkListTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseNetworkListTest.java
new file mode 100644
index 0000000..61d56ba
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseNetworkListTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.domain.Resource;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+
+import com.google.common.collect.ImmutableSet;
+
+public class ParseNetworkListTest extends BaseGoogleComputeEngineParseTest<ListPage<Network>> {
+
+ @Override
+ public String resource() {
+ return "/network_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListPage<Network> expected() {
+ return ListPage.<Network>builder()
+ .kind(Resource.Kind.NETWORK_LIST)
+ .id("projects/myproject/networks")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/networks"))
+ .items(ImmutableSet.of(new ParseNetworkTest().expected()))
+ .build();
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseNetworkTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseNetworkTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseNetworkTest.java
new file mode 100644
index 0000000..cd0fdcf
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseNetworkTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+
+public class ParseNetworkTest extends BaseGoogleComputeEngineParseTest<Network> {
+
+ @Override
+ public String resource() {
+ return "/network_get.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Network expected() {
+ return Network.builder()
+ .id("13024414170909937976")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-10-24T20:13:19.967"))
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/networks/jclouds-test"))
+ .name("default")
+ .description("Default network for the project")
+ .IPv4Range("10.0.0.0/8")
+ .gatewayIPv4("10.0.0.1")
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseOperationListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseOperationListTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseOperationListTest.java
new file mode 100644
index 0000000..ec407a3
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseOperationListTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.Resource;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+
+public class ParseOperationListTest extends BaseGoogleComputeEngineParseTest<ListPage<Operation>> {
+
+ @Override
+ public String resource() {
+ return "/global_operation_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListPage<Operation> expected() {
+ return ListPage.<Operation>builder()
+ .kind(Resource.Kind.OPERATION_LIST)
+ .id("projects/myproject/global/operations")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/operations"))
+ .addItem(new ParseOperationTest().expected())
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseOperationTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseOperationTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseOperationTest.java
new file mode 100644
index 0000000..cb561bf
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseOperationTest.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class ParseOperationTest extends BaseGoogleComputeEngineParseTest<Operation> {
+
+ @Override
+ public String resource() {
+ return "/global_operation.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Operation expected() {
+ SimpleDateFormatDateService dateService = new SimpleDateFormatDateService();
+ return Operation.builder().id("13053095055850848306")
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/operations/operation-1354084865060-4cf88735faeb8" +
+ "-bbbb12cb"))
+ .name("operation-1354084865060-4cf88735faeb8-bbbb12cb")
+ .targetLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/firewalls/jclouds-test-delete"))
+ .targetId("13053094017547040099")
+ .status(Operation.Status.DONE)
+ .user("user@developer.gserviceaccount.com")
+ .progress(100)
+ .insertTime(dateService.iso8601DateParse("2012-11-28T06:41:05.060"))
+ .startTime(dateService.iso8601DateParse("2012-11-28T06:41:05.142"))
+ .endTime(dateService.iso8601DateParse("2012-11-28T06:41:06.142"))
+ .operationType("insert")
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseProjectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseProjectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseProjectTest.java
new file mode 100644
index 0000000..3e549df
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseProjectTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+import java.util.Date;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.domain.Metadata;
+import org.jclouds.googlecomputeengine.domain.Project;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+@Test(groups = "unit")
+public class ParseProjectTest extends BaseGoogleComputeEngineParseTest<Project> {
+
+ @Override
+ public String resource() {
+ return "/project.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Project expected() {
+ return Project.builder()
+ .id("13024414184846275913")
+ .creationTimestamp(new Date(Long.parseLong("1351109596252")))
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject"))
+ .name("myproject")
+ .description("")
+ .commonInstanceMetadata(Metadata.builder()
+ .items(ImmutableMap.<String, String>builder()
+ .put("propA", "valueA")
+ .put("propB", "valueB")
+ .build())
+ .fingerprint("efgh")
+ .build())
+ .addQuota("INSTANCES", 0, 8)
+ .addQuota("CPUS", 0, 8)
+ .addQuota("EPHEMERAL_ADDRESSES", 0, 8)
+ .addQuota("DISKS", 0, 8)
+ .addQuota("DISKS_TOTAL_GB", 0, 100)
+ .addQuota("SNAPSHOTS", 0, 1000)
+ .addQuota("NETWORKS", 1, 5)
+ .addQuota("FIREWALLS", 2, 100)
+ .addQuota("IMAGES", 0, 100)
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseQuotaTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseQuotaTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseQuotaTest.java
new file mode 100644
index 0000000..894dd0e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseQuotaTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.domain.Quota;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class ParseQuotaTest extends BaseGoogleComputeEngineParseTest<Quota> {
+
+ @Override
+ public String resource() {
+ return "/quota.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Quota expected() {
+ return Quota.builder().metric("INSTANCES").usage(0.0).limit(8.0).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRegionListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRegionListTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRegionListTest.java
new file mode 100644
index 0000000..8dfdea1
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRegionListTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Region;
+import org.jclouds.googlecomputeengine.domain.Resource;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "unit")
+public class ParseRegionListTest extends BaseGoogleComputeEngineParseTest<ListPage<Region>> {
+
+ @Override
+ public String resource() {
+ return "/region_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListPage<Region> expected() {
+ return ListPage.<Region>builder()
+ .kind(Resource.Kind.REGION_LIST)
+ .id("projects/myproject/regions")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions"))
+ .items(ImmutableSet.of(
+ new ParseRegionTest().expected(),
+ Region.builder()
+ .id("6396763663251190992")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse
+ ("2013-07-08T14:40:37.939-07:00"))
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/regions/us-central2"))
+ .name("us-central2")
+ .description("us-central2")
+ .status(Region.Status.UP)
+ .zone(URI.create("https://www.googleapis.com/compute/v1/zones/us-central2-a"))
+ .addQuota("INSTANCES", 0, 8)
+ .addQuota("CPUS", 0, 8)
+ .addQuota("EPHEMERAL_ADDRESSES", 0, 8)
+ .addQuota("DISKS", 0, 8)
+ .addQuota("DISKS_TOTAL_GB", 0, 100)
+ .addQuota("SNAPSHOTS", 0, 1000)
+ .addQuota("NETWORKS", 1, 5)
+ .addQuota("FIREWALLS", 2, 100)
+ .addQuota("IMAGES", 0, 100)
+ .build()))
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRegionTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRegionTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRegionTest.java
new file mode 100644
index 0000000..fab9915
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRegionTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Region;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "unit")
+public class ParseRegionTest extends BaseGoogleComputeEngineParseTest<Region> {
+
+ @Override
+ public String resource() {
+ return "/region_get.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Region expected() {
+ return Region.builder()
+ .id("12912210600542709766")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-08T14:40:37.939-07:00"))
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1"))
+ .name("us-central1")
+ .description("us-central1")
+ .status(Region.Status.UP)
+ .zones(ImmutableSet.of(URI.create("https://www.googleapis.com/compute/v1/zones/us-central1-a"),
+ URI.create("https://www.googleapis.com/compute/v1/zones/us-central1-b")))
+ .addQuota("INSTANCES", 0, 8)
+ .addQuota("CPUS", 0, 8)
+ .addQuota("EPHEMERAL_ADDRESSES", 0, 8)
+ .addQuota("DISKS", 0, 8)
+ .addQuota("DISKS_TOTAL_GB", 0, 100)
+ .addQuota("SNAPSHOTS", 0, 1000)
+ .addQuota("NETWORKS", 1, 5)
+ .addQuota("FIREWALLS", 2, 100)
+ .addQuota("IMAGES", 0, 100)
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRouteListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRouteListTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRouteListTest.java
new file mode 100644
index 0000000..3a378aa
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRouteListTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Resource.Kind;
+import org.jclouds.googlecomputeengine.domain.Route;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "unit")
+public class ParseRouteListTest extends BaseGoogleComputeEngineParseTest<ListPage<Route>> {
+
+ @Override
+ public String resource() {
+ return "/route_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListPage<Route> expected() {
+ return ListPage.<Route>builder()
+ .kind(Kind.ROUTE_LIST)
+ .id("projects/myproject/global/routes")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/routes"))
+ .items(ImmutableSet.of(new ParseRouteTest().expected(),
+ Route.builder()
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/routes/default-route-fc92a41ecb5a8d17"))
+ .id("507025480040058551")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-08T14:40:38.502-07:00"))
+ .name("default-route-fc92a41ecb5a8d17")
+ .description("Default route to the Internet.")
+ .network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"))
+ .destRange("0.0.0.0/0")
+ .priority(1000)
+ .nextHopGateway(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/gateways/default-internet-gateway"))
+ .build())
+ ).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRouteTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRouteTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRouteTest.java
new file mode 100644
index 0000000..5ffd845
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseRouteTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Route;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "unit")
+public class ParseRouteTest extends BaseGoogleComputeEngineParseTest<Route> {
+
+ @Override
+ public String resource() {
+ return "/route_get.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Route expected() {
+ return Route.builder()
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/routes/default-route-c99ebfbed0e1f375"))
+ .id("7241926205630356071")
+ .name("default-route-c99ebfbed0e1f375")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-08T14:40:38.502-07:00"))
+ .description("Default route to the virtual network.")
+ .network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"))
+ .destRange("10.240.0.0/16")
+ .priority(1000)
+ .nextHopNetwork(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"))
+ .tags(ImmutableSet.of("fooTag", "barTag"))
+ .build();
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseSnapshotListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseSnapshotListTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseSnapshotListTest.java
new file mode 100644
index 0000000..f52aa3f
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseSnapshotListTest.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Resource.Kind;
+import org.jclouds.googlecomputeengine.domain.Snapshot;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "unit")
+public class ParseSnapshotListTest extends BaseGoogleComputeEngineParseTest<ListPage<Snapshot>> {
+
+ @Override
+ public String resource() {
+ return "/snapshot_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListPage<Snapshot> expected() {
+ return ListPage.<Snapshot>builder()
+ .kind(Kind.SNAPSHOT_LIST)
+ .id("projects/myproject/global/snapshots")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots"))
+ .items(ImmutableSet.of(
+ new ParseSnapshotTest().expected(), Snapshot.builder()
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/snapshots/test-snap2"))
+ .id("13895715048576107883")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse
+ ("2013-07-26T12:57:01.927-07:00"))
+ .status("READY")
+ .sizeGb(10)
+ .sourceDisk(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
+ .name("test-snap2")
+ .description("")
+ .sourceDiskId("8243603669926824540")
+ .build()))
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseSnapshotTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseSnapshotTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseSnapshotTest.java
new file mode 100644
index 0000000..f3e7a01
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseSnapshotTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Snapshot;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class ParseSnapshotTest extends BaseGoogleComputeEngineParseTest<Snapshot> {
+
+ @Override
+ public String resource() {
+ return "/snapshot_get.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Snapshot expected() {
+ return Snapshot.builder()
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots/test-snap"))
+ .id("9734455566806191190")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-26T12:54:23.173-07:00"))
+ .status("READY")
+ .sizeGb(10)
+ .sourceDisk(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
+ .name("test-snap")
+ .description("")
+ .sourceDiskId("8243603669926824540")
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneListTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneListTest.java
new file mode 100644
index 0000000..54fe1a2
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneListTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Resource;
+import org.jclouds.googlecomputeengine.domain.Zone;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "unit")
+public class ParseZoneListTest extends BaseGoogleComputeEngineParseTest<ListPage<Zone>> {
+
+ @Override
+ public String resource() {
+ return "/zone_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListPage<Zone> expected() {
+ return ListPage.<Zone>builder()
+ .kind(Resource.Kind.ZONE_LIST)
+ .id("projects/myproject/zones")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones"))
+ .items(ImmutableSet.of(
+ new ParseZoneTest().expected()
+ , Zone.builder()
+ .id("13024414164050619686")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse
+ ("2012-10-24T20:13:19.271"))
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-b"))
+ .name("us-central1-b")
+ .description("us-central1-b")
+ .status(Zone.Status.UP)
+ .addMaintenanceWindow(Zone.MaintenanceWindow.builder()
+ .name("2013-02-17-planned-outage")
+ .description("maintenance zone")
+ .beginTime(new SimpleDateFormatDateService().iso8601DateParse
+ ("2013-02-17T08:00:00.000"))
+ .endTime(new SimpleDateFormatDateService().iso8601DateParse
+ ("2013-03-03T08:00:00.000"))
+ .build())
+ .build()))
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneTest.java
new file mode 100644
index 0000000..48cdbfc
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Zone;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class ParseZoneTest extends BaseGoogleComputeEngineParseTest<Zone> {
+
+ @Override
+ public String resource() {
+ return "/zone_get.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Zone expected() {
+ return Zone.builder()
+ .id("13020128040171887099")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-10-19T16:42:54.131"))
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"))
+ .name("us-central1-a")
+ .description("us-central1-a")
+ .status(Zone.Status.DOWN)
+ .addMaintenanceWindow(Zone.MaintenanceWindow.builder()
+ .name("2012-11-10-planned-outage")
+ .description("maintenance zone")
+ .beginTime(new SimpleDateFormatDateService().iso8601DateParse("2012-11-10T20:00:00.000"))
+ .endTime(new SimpleDateFormatDateService().iso8601DateParse("2012-12-02T20:00:00.000"))
+ .build())
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/predicates/NetworkFirewallPredicatesTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/predicates/NetworkFirewallPredicatesTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/predicates/NetworkFirewallPredicatesTest.java
new file mode 100644
index 0000000..58ed81c
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/predicates/NetworkFirewallPredicatesTest.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.predicates;
+
+import static org.jclouds.googlecomputeengine.compute.functions.FirewallToIpPermissionTest.fwForTest;
+import static org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.equalsIpPermission;
+import static org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.hasPortRange;
+import static org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.hasProtocol;
+import static org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.hasSourceRange;
+import static org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.hasSourceTag;
+import static org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.providesIpPermission;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.Date;
+
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Range;
+
+@Test(groups = "unit")
+public class NetworkFirewallPredicatesTest {
+
+ public static Firewall getFwForTestSourceTags() {
+ Firewall.Builder builder = Firewall.builder();
+
+ builder.network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
+ builder.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test"));
+ builder.addSourceTag("tag-1");
+ builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.TCP)
+ .addPortRange(1, 10).build());
+ builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.TCP)
+ .addPort(33).build());
+ builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.ICMP).build());
+ builder.id("abcd");
+ builder.creationTimestamp(new Date());
+ builder.name("jclouds-test");
+
+ return builder.build();
+ }
+
+ public static Firewall getFwForTestSourceTagsExact() {
+ Firewall.Builder builder = Firewall.builder();
+
+ builder.network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
+ builder.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test"));
+ builder.addSourceTag("tag-1");
+ builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.TCP)
+ .addPortRange(1, 10).build());
+ builder.id("abcd");
+ builder.creationTimestamp(new Date());
+ builder.name("jclouds-test");
+
+ return builder.build();
+ }
+
+ @Test
+ public void testHasProtocol() {
+ assertTrue(hasProtocol(IpProtocol.TCP).apply(fwForTest()),
+ "Firewall " + fwForTest() + " should contain a TCP rule.");
+ }
+
+ @Test
+ public void testHasProtocolFails() {
+ assertFalse(hasProtocol(IpProtocol.UDP).apply(fwForTest()),
+ "Firewall " + fwForTest() + " should NOT contain a UDP rule.");
+ }
+
+ @Test
+ public void testHasPortRange() {
+ assertTrue(hasPortRange(Range.closed(2, 9)).apply(fwForTest()),
+ "Firewall " + fwForTest() + " should contain the port range 2-9.");
+ }
+
+ @Test
+ public void testHasPortRangeFails() {
+ assertFalse(hasPortRange(Range.closed(11, 15)).apply(fwForTest()),
+ "Firewall " + fwForTest() + " should NOT contain the port range 11-15.");
+ }
+
+ @Test
+ public void testHasSourceTag() {
+ assertTrue(hasSourceTag("tag-1").apply(getFwForTestSourceTags()),
+ "Firewall " + getFwForTestSourceTags() + " should contain the source tag 'tag-1'.");
+ }
+
+ @Test
+ public void testHasSourceTagFails() {
+ assertFalse(hasSourceTag("tag-1").apply(fwForTest()),
+ "Firewall " + fwForTest() + " should NOT contain the source tag 'tag-1'.");
+ }
+
+ @Test
+ public void testHasSourceRange() {
+ assertTrue(hasSourceRange("0.0.0.0/0").apply(fwForTest()),
+ "Firewall " + fwForTest() + " should contain the source range '0.0.0.0/0'.");
+ }
+
+ @Test
+ public void testHasSourceRangeFails() {
+ assertFalse(hasSourceRange("0.0.0.0/0").apply(getFwForTestSourceTags()),
+ "Firewall " + getFwForTestSourceTags() + " should NOT contain the source range '0.0.0.0/0'.");
+ }
+
+ @Test
+ public void testEqualsIpPermission() {
+ IpPermission perm = IpPermission.builder().groupId("tag-1")
+ .fromPort(1).toPort(10).ipProtocol(IpProtocol.TCP).build();
+
+ assertTrue(equalsIpPermission(perm).apply(getFwForTestSourceTagsExact()),
+ "Firewall " + getFwForTestSourceTagsExact() + " should match IpPermission " + perm + " but does not.");
+ }
+
+ @Test
+ public void testEqualsIpPermissionFails() {
+ IpPermission perm = IpPermission.builder().groupId("tag-1")
+ .fromPort(1).toPort(10).ipProtocol(IpProtocol.TCP).build();
+
+ assertFalse(equalsIpPermission(perm).apply(getFwForTestSourceTags()),
+ "Firewall " + getFwForTestSourceTags() + " should not match IpPermission " + perm + " but does.");
+ }
+
+ @Test
+ public void testProvidesIpPermission() {
+ IpPermission perm = IpPermission.builder().groupId("tag-1")
+ .fromPort(1).toPort(10).ipProtocol(IpProtocol.TCP).build();
+
+ assertTrue(providesIpPermission(perm).apply(getFwForTestSourceTagsExact()),
+ "Firewall " + getFwForTestSourceTagsExact() + " should provide IpPermission " + perm + " but does not.");
+
+ assertTrue(providesIpPermission(perm).apply(getFwForTestSourceTags()),
+ "Firewall " + getFwForTestSourceTags() + " should inexactly provide IpPermission " + perm + " but does not.");
+ }
+
+ @Test
+ public void testProvidesIpPermissionFails() {
+ IpPermission perm = IpPermission.builder().groupId("tag-1")
+ .fromPort(1).toPort(10).ipProtocol(IpProtocol.TCP).build();
+
+ assertFalse(providesIpPermission(perm).apply(fwForTest()),
+ "Firewall " + fwForTest() + " should not provide IpPermission " + perm + " but does.");
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/OAuthApiMetadataTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/OAuthApiMetadataTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/OAuthApiMetadataTest.java
new file mode 100644
index 0000000..d6ea17f
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/OAuthApiMetadataTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.reflect.TypeToken;
+import org.jclouds.View;
+import org.jclouds.apis.internal.BaseApiMetadataTest;
+import org.testng.annotations.Test;
+
+/**
+ * Tests that OAuthApiMetadata is properly registered in ServiceLoader
+ * <p/>
+ * <pre>
+ * META-INF/services/org.jclouds.apis.ApiMetadata
+ * </pre>
+ */
+@Test(groups = "unit")
+public class OAuthApiMetadataTest extends BaseApiMetadataTest {
+
+ public OAuthApiMetadataTest() {
+ super(new OAuthApiMetadata(), ImmutableSet.<TypeToken<? extends View>>of());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java
new file mode 100644
index 0000000..901cdfe
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/OAuthTestUtils.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Throwables;
+import com.google.common.io.Files;
+import org.jclouds.oauth.v2.config.CredentialType;
+import org.jclouds.oauth.v2.config.OAuthProperties;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE;
+
+/**
+ * Utils for OAuth tests.
+ */
+public class OAuthTestUtils {
+
+ public static Properties defaultProperties(Properties properties) {
+ try {
+ properties = properties == null ? new Properties() : properties;
+ properties.put("oauth.identity", "foo");
+ properties.put("oauth.credential",
+ Files.asCharSource(new File("src/test/resources/testpk.pem"), Charsets.UTF_8).read());
+ properties.put("oauth.endpoint", "http://localhost:5000/o/oauth2/token");
+ properties.put(AUDIENCE, "https://accounts.google.com/o/oauth2/token");
+ return properties;
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ public static Properties bearerTokenAuthProperties(Properties properties) {
+ properties = properties == null ? new Properties() : properties;
+ properties.put("oauth.identity", "761326798069-r5mljlln1rd4lrbhg75efgigp36m78j5@developer.gserviceaccount.com");
+ properties.put("oauth.credential", "1/8xbJqaOZXSUZbHLl5EOtu1pxz3fmmetKx9W8CV4t79M");
+ properties.put("oauth.endpoint", "http://localhost:5000/o/oauth2/token");
+ properties.put(AUDIENCE, "https://accounts.google.com/o/oauth2/token");
+ properties.put(OAuthProperties.CREDENTIAL_TYPE, CredentialType.BEARER_TOKEN_CREDENTIALS.toString());
+ return properties;
+ }
+
+ public static String setCredential(Properties overrides, String key) {
+ String val = null;
+ String credentialFromFile = null;
+ String testKey = "test." + key;
+
+ if (System.getProperties().containsKey(testKey)) {
+ val = System.getProperty(testKey);
+ }
+ checkNotNull(val, String.format("the property %s must be set (pem private key file path or private key as a string)", testKey));
+
+ if (val.startsWith("-----BEGIN")) {
+ return val;
+ }
+
+ try {
+ credentialFromFile = Files.toString(new File(val), Charsets.UTF_8);
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ overrides.setProperty(key, credentialFromFile);
+ return credentialFromFile;
+ }
+
+ public static String getMandatoryProperty(Properties properties, String key) {
+ checkNotNull(properties);
+ checkNotNull(key);
+ String value = properties.getProperty(key);
+ return checkNotNull(value, String.format("mandatory property %s or test.%s was not present", key, key));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/features/OAuthApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/features/OAuthApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/features/OAuthApiExpectTest.java
new file mode 100644
index 0000000..2008e5d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/features/OAuthApiExpectTest.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.features;
+
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.io.BaseEncoding.base64Url;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+import java.util.Properties;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.oauth.v2.OAuthApi;
+import org.jclouds.oauth.v2.OAuthTestUtils;
+import org.jclouds.oauth.v2.domain.ClaimSet;
+import org.jclouds.oauth.v2.domain.Header;
+import org.jclouds.oauth.v2.domain.Token;
+import org.jclouds.oauth.v2.domain.TokenRequest;
+import org.jclouds.oauth.v2.internal.BaseOAuthApiExpectTest;
+import org.testng.annotations.Test;
+
+/**
+ * Tests that a token requess is well formed.
+ */
+@Test(groups = "unit")
+public class OAuthApiExpectTest extends BaseOAuthApiExpectTest {
+
+ private static final String header = "{\"alg\":\"RS256\",\"typ\":\"JWT\"}";
+
+ private static final String claims = "{\"iss\":\"761326798069-r5mljlln1rd4lrbhg75efgigp36m78j5@developer" +
+ ".gserviceaccount.com\"," +
+ "\"scope\":\"https://www.googleapis.com/auth/prediction\",\"aud\":\"https://accounts.google" +
+ ".com/o/oauth2/token\",\"exp\":1328573381,\"iat\":1328569781}";
+
+ private static final Token TOKEN = new Token.Builder().accessToken
+ ("1/8xbJqaOZXSUZbHLl5EOtu1pxz3fmmetKx9W8CV4t79M").tokenType("Bearer").expiresIn(3600).build();
+
+ private static final ClaimSet CLAIM_SET = new ClaimSet.Builder().addClaim("iss",
+ "761326798069-r5mljlln1rd4lrbhg75efgigp36m78j5@developer" +
+ ".gserviceaccount.com")
+ .addClaim("scope", "https://www.googleapis.com/auth/prediction")
+ .addClaim("aud", "https://accounts.google.com/o/oauth2/token")
+ .expirationTime(1328573381)
+ .emissionTime(1328569781).build();
+
+ private static final Header HEADER = new Header.Builder().signerAlgorithm("RS256").type("JWT").build();
+
+ private static final String URL_ENCODED_TOKEN_REQUEST =
+ "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&" +
+ // Base64 Encoded Header
+ "assertion=" + base64Url().omitPadding().encode(header.getBytes(UTF_8)) + "." +
+ // Base64 Encoded Claims
+ base64Url().omitPadding().encode(claims.getBytes(UTF_8)) + "." +
+ // Base64 encoded {header}.{claims} signature (using SHA256)
+ "W2Lesr_98AzVYiMbzxFqmwcOjpIWlwqkC6pNn1fXND9oSDNNnFhy-AAR6DKH-x9ZmxbY80" +
+ "R5fH-OCeWumXlVgceKN8Z2SmgQsu8ElTpypQA54j_5j8vUImJ5hsOUYPeyF1U2BUzZ3L5g" +
+ "03PXBA0YWwRU9E1ChH28dQBYuGiUmYw";
+
+ private static final HttpRequest TOKEN_REQUEST = HttpRequest.builder()
+ .method("POST")
+ .endpoint(URI.create("http://localhost:5000/o/oauth2/token"))
+ .addHeader("Accept", MediaType.APPLICATION_JSON)
+ .payload(payloadFromStringWithContentType(URL_ENCODED_TOKEN_REQUEST, "application/x-www-form-urlencoded"))
+ .build();
+
+ private static final HttpResponse TOKEN_RESPONSE = HttpResponse.builder().statusCode(200).payload(
+ payloadFromString("{\n" +
+ " \"access_token\" : \"1/8xbJqaOZXSUZbHLl5EOtu1pxz3fmmetKx9W8CV4t79M\",\n" +
+ " \"token_type\" : \"Bearer\",\n" +
+ " \"expires_in\" : 3600\n" +
+ "}")).build();
+
+ @Override
+ protected Properties setupProperties() {
+ return OAuthTestUtils.defaultProperties(super.setupProperties());
+ }
+
+ public void testGenerateJWTRequest() {
+ OAuthApi api = requestSendsResponse(TOKEN_REQUEST, TOKEN_RESPONSE);
+ assertEquals(api.authenticate(new TokenRequest(HEADER, CLAIM_SET)), TOKEN);
+ }
+}
[04/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java
new file mode 100644
index 0000000..7895c81
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.UnknownHostException;
+
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.vcloud.domain.NetworkConnection;
+import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code NetworkConnectionHandler}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "NetworkConnectionHandlerTest")
+public class NetworkConnectionHandlerTest extends BaseHandlerTest {
+
+ public void testDefault() throws UnknownHostException {
+ InputStream is = getClass().getResourceAsStream("/networkconnection.xml");
+
+ NetworkConnection result = factory.create(injector.getInstance(NetworkConnectionHandler.class)).parse(is);
+
+ checkNetworkConnection(result);
+
+ }
+
+ @Test(enabled = false)
+ public static void checkNetworkConnection(NetworkConnection result) {
+ assertEquals(result.getNetwork(), "internet01");
+ assertEquals(result.getNetworkConnectionIndex(), 0);
+ assertEquals(result.getIpAddress(), "174.47.101.164");
+ assertEquals(result.getExternalIpAddress(), null);
+ assertEquals(result.isConnected(), true);
+ assertEquals(result.getMACAddress(), "00:50:56:01:01:f2");
+ assertEquals(result.getIpAddressAllocationMode(), IpAddressAllocationMode.POOL);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java
new file mode 100644
index 0000000..632981e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.NetworkConnectionSection;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code NetworkConnectionSectionHandler}
+ */
+@Test(groups = "unit")
+public class NetworkConnectionSectionHandlerTest {
+ public void testVCloud1_0() {
+ InputStream is = getClass().getResourceAsStream("/networkconnectionsection.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ NetworkConnectionSection result = factory.create(injector.getInstance(NetworkConnectionSectionHandler.class))
+ .parse(is);
+ checkNetworkConnectionSection(result);
+ }
+
+ @Test(enabled = false)
+ static void checkNetworkConnectionSection(NetworkConnectionSection result) {
+ assertEquals(result.getHref(), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/networkConnectionSection/"));
+ assertEquals(result.getType(), VCloudMediaType.NETWORKCONNECTIONSECTION_XML);
+ assertEquals(result.getInfo(), "Specifies the available VM network connections");
+ assertEquals(result.getPrimaryNetworkConnectionIndex(), Integer.valueOf(0));
+ assertEquals(result.getEdit(), new ReferenceTypeImpl(null, VCloudMediaType.NETWORKCONNECTIONSECTION_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/networkConnectionSection/")));
+ NetworkConnectionHandlerTest.checkNetworkConnection(Iterables.getOnlyElement(result.getConnections()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java
new file mode 100644
index 0000000..6c56e66
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
+import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.internal.OrgImpl;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code OrgHandler}
+ */
+@Test(groups = "unit")
+public class OrgHandlerTest {
+
+ public void testApplyInputStream() {
+ InputStream is = getClass().getResourceAsStream("/org-1.0.xml");
+
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+
+ Org result = factory.create(injector.getInstance(OrgHandler.class)).parse(is);
+ assertEquals(result.getName(), "ExampleOrg");
+ assertEquals(result.getFullName(), "ExampleOrg");
+ assertEquals(result.getDescription(), "Example Corp's Primary Organization.");
+ assertEquals(result.getHref(), URI.create("http://vcloud.example.com/api/v1.0/org/5"));
+ assertEquals(result.getCatalogs(), ImmutableMap.of("Main Catalog", new ReferenceTypeImpl("Main Catalog",
+ CATALOG_XML, URI.create("http://vcloud.example.com/api/v1.0/catalog/32")), "Shared Catalog",
+ new ReferenceTypeImpl("Shared Catalog", CATALOG_XML, URI
+ .create("http://vcloud.example.com/api/v1.0/catalog/37"))));
+ assertEquals(result.getVDCs(), ImmutableMap.of("ExampleVdc01", new ReferenceTypeImpl("ExampleVdc01",
+ VCloudMediaType.VDC_XML, URI.create("http://vcloud.example.com/api/v1.0/vdc/5"))));
+ assertEquals(result.getNetworks(), ImmutableMap.of("TestNetwork", new ReferenceTypeImpl("TestNetwork",
+ VCloudMediaType.NETWORK_XML, URI.create("http://vcloud.example.com/api/v1.0/network/14")),
+ "ProductionNetwork", new ReferenceTypeImpl("ProductionNetwork", VCloudMediaType.NETWORK_XML, URI
+ .create("http://vcloud.example.com/api/v1.0/network/54"))));
+ assertEquals(result.getTasksList(), new ReferenceTypeImpl(null, TASKSLIST_XML, URI
+ .create("http://vcloud.example.com/api/v1.0/tasksList/5")));
+ }
+
+ public void testTerremark() {
+ InputStream is = getClass().getResourceAsStream("/org.xml");
+
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+
+ Org result = factory.create(injector.getInstance(OrgHandler.class)).parse(is);
+ assertEquals(result.getName(), "adrian@jclouds.org");
+ assertEquals(result.getFullName(), "adrian@jclouds.org");
+ assertEquals(result.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"));
+ assertEquals(result.getCatalogs(), ImmutableMap.of("Miami Environment 1 Catalog", new ReferenceTypeImpl(
+ "Miami Environment 1 Catalog", CATALOG_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"))));
+ assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new ReferenceTypeImpl(
+ "Miami Environment 1", VCloudMediaType.VDC_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))));
+ assertEquals(result.getTasksList(), new ReferenceTypeImpl("Miami Environment 1 Tasks List", TASKSLIST_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/32")));
+ }
+
+ public void testHosting() {
+ InputStream is = getClass().getResourceAsStream("/org-hosting.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ Org result = factory.create(injector.getInstance(OrgHandler.class)).parse(is);
+ assertEquals(result.getName(), "Customer 188849");
+ assertEquals(result.getFullName(), "Customer 188849");
+ assertEquals(result.getHref(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/188849"));
+ assertEquals(result.getCatalogs(), ImmutableMap.of("HMS Shared Catalog", new ReferenceTypeImpl(
+ "HMS Shared Catalog", CATALOG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))));
+ assertEquals(result.getVDCs(), ImmutableMap.of("188849 Virtual DataCenter", new ReferenceTypeImpl(
+ "188849 Virtual DataCenter", VCloudMediaType.VDC_XML, URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"))));
+ assertEquals(result.getTasksList(), new ReferenceTypeImpl("188849 Task List", TASKSLIST_XML, URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849")));
+ }
+
+ public void testSavvis() {
+ InputStream is = getClass().getResourceAsStream("/org-savvis.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ Org result = factory.create(injector.getInstance(OrgHandler.class)).parse(is);
+ assertEquals(result, new OrgImpl("607968.0", null, null, "607968.0", "Gravitant Inc", ImmutableMap
+ .<String, ReferenceType> of(), ImmutableMap.<String, ReferenceType> of("GravDataCenter1(Saved)",
+ new ReferenceTypeImpl("GravDataCenter1(Saved)", "application/vnd.vmware.vcloud.vdc+xml", URI
+ .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/607968.0/vdc/2826"))),
+ ImmutableMap.<String, ReferenceType> of(), null, ImmutableSet.<Task> of()));
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java
new file mode 100644
index 0000000..68bf197
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Map;
+
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests behavior of {@code OrgListHandler}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "OrgListHandlerTest")
+public class OrgListHandlerTest extends BaseHandlerTest {
+
+ public void testApplyInputStream() {
+ InputStream is = getClass().getResourceAsStream("/orglist.xml");
+
+ Map<String, ReferenceType> result = factory.create(injector.getInstance(OrgListHandler.class)).parse(is);
+ assertEquals(result, ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
+ "application/vnd.vmware.vcloud.org+xml", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
+ }
+
+
+ public void testSavvis() {
+ InputStream is = getClass().getResourceAsStream("/orglist-savvis.xml");
+
+ Map<String, ReferenceType> result = factory.create(injector.getInstance(OrgListHandler.class)).parse(is);
+ assertEquals(result, ImmutableMap.of("SAVVISStation Integration Testing", new ReferenceTypeImpl("SAVVISStation Integration Testing",
+ "application/vnd.vmware.vcloud.org+xml", URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0"))));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java
new file mode 100644
index 0000000..22b81c6
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.network.DhcpService;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.jclouds.vcloud.domain.network.IpRange;
+import org.jclouds.vcloud.domain.network.IpScope;
+import org.jclouds.vcloud.domain.network.OrgNetwork;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code OrgNetworkHandler}
+ */
+@Test(groups = "unit")
+public class OrgNetworkHandlerTest {
+ public void testIsolated() {
+ InputStream is = getClass().getResourceAsStream("/orgnetwork-isolated.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ OrgNetwork result = factory.create(injector.getInstance(OrgNetworkHandler.class)).parse(is);
+ assertEquals(result.getName(), "isolation01");
+ assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/990419644"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.network+xml");
+ assertEquals(result.getOrg(), new ReferenceTypeImpl(null, VCloudMediaType.ORG_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getTasks(), ImmutableList.of());
+ assert result.getConfiguration() != null;
+
+ assertEquals(result.getConfiguration().getIpScope(), new IpScope(false, "192.168.15.1", "255.255.255.0",
+ "23.172.173.113", null, null,
+ ImmutableSet.<IpRange> of(new IpRange("192.168.15.100", "192.168.15.199")), ImmutableSet.<String> of()));
+ assertEquals(result.getConfiguration().getParentNetwork(), null);
+ assertEquals(result.getConfiguration().getFenceMode(), FenceMode.ISOLATED);
+ assert result.getConfiguration().getFeatures() != null;
+
+ assertEquals(result.getConfiguration().getFeatures().getDhcpService(), new DhcpService(false, 3600, 7200,
+ new IpRange("192.168.15.2", "192.168.15.99")));
+ assertEquals(result.getConfiguration().getFeatures().getFirewallService(), null);
+ assertEquals(result.getConfiguration().getFeatures().getNatService(), null);
+
+ assertEquals(result.getNetworkPool(), null);
+ assertEquals(result.getAllowedExternalIpAddresses(), ImmutableSet.<String> of());
+
+ }
+
+ public void testBridged() {
+ InputStream is = getClass().getResourceAsStream("/orgnetwork-bridged.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ OrgNetwork result = factory.create(injector.getInstance(OrgNetworkHandler.class)).parse(is);
+ assertEquals(result.getName(), "internet01");
+ assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/758634723"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.network+xml");
+ assertEquals(result.getOrg(), new ReferenceTypeImpl(null, VCloudMediaType.ORG_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getTasks(), ImmutableList.of());
+ assert result.getConfiguration() != null;
+
+ assertEquals(result.getConfiguration().getIpScope(), new IpScope(true, "174.47.101.161", "255.255.255.224",
+ "24.172.173.113", null, null,
+ ImmutableSet.<IpRange> of(new IpRange("174.47.101.164", "174.47.101.190")), ImmutableSet.<String> of()));
+ assertEquals(result.getConfiguration().getParentNetwork(), null);
+ assertEquals(result.getConfiguration().getFenceMode(), FenceMode.BRIDGED);
+ assert result.getConfiguration().getFeatures() == null;
+ assertEquals(result.getNetworkPool(), null);
+ assertEquals(result.getAllowedExternalIpAddresses(), ImmutableSet.<String> of());
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java
new file mode 100644
index 0000000..c264c60
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.SortedMap;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSortedMap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code SupportedVersionsHandler}
+ */
+@Test(groups = "unit")
+public class SupportedVersionsHandlerTest {
+
+ public void testApplyInputStream() {
+ InputStream is = getClass().getResourceAsStream("/versions.xml");
+
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+
+ SortedMap<String, URI> result = factory.create(
+ injector.getInstance(SupportedVersionsHandler.class)).parse(is);
+ assertEquals(result, ImmutableSortedMap.of("0.8", URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/login")));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java
new file mode 100644
index 0000000..f5a4688
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.date.DateService;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.TaskStatus;
+import org.jclouds.vcloud.domain.VCloudError.MinorCode;
+import org.jclouds.vcloud.domain.internal.ErrorImpl;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.internal.TaskImpl;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code TaskHandler}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "TaskHandlerTest")
+public class TaskHandlerTest extends BaseHandlerTest {
+
+ private DateService dateService;
+
+ @BeforeTest
+ @Override
+ protected void setUpInjector() {
+ super.setUpInjector();
+ dateService = injector.getInstance(DateService.class);
+ }
+
+ public void testHrefWhenTaskElementIsNamespaced() {
+ InputStream is = getClass().getResourceAsStream("/task-vcd15.xml");
+ Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
+ assertEquals(result.getHref(), URI.create("https://mycloud.greenhousedata.com/api/v1.0/task/77a33fd4-3401-423c-8167-6711fc51ee9a"));
+ }
+
+ public void test() {
+ InputStream is = getClass().getResourceAsStream("/task-1.0.xml");
+
+ Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
+
+ Task expects = new TaskImpl(URI.create("https://vcenterprise.bluelock.com/api/v1.0/task/3cc08ir8oczbze3n1a3"),
+ "Creating Virtual Application vApp_acole_2(607806320)", TaskStatus.RUNNING, dateService
+ .iso8601DateParse("2010-08-23T02:09:52.443-04:00"), dateService
+ .iso8601DateParse("9999-12-31T23:59:59.999-05:00"), dateService
+ .iso8601DateParse("2010-11-21T02:09:52.443-05:00"), new ReferenceTypeImpl("vApp_acole_2",
+ VCloudMediaType.VAPP_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-607806320"))
+
+ , null
+
+ );
+ assertEquals(result, expects);
+
+ }
+
+ public void testTerremark() {
+ InputStream is = getClass().getResourceAsStream("/task.xml");
+
+ Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
+ Task expects = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"), null,
+ TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), dateService
+ .iso8601DateParse("2009-08-24T21:29:44.65Z"), null, new ReferenceTypeImpl("Server1",
+ VCloudMediaType.VAPP_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null
+
+ );
+ assertEquals(result, expects);
+
+ }
+
+ public void testSelf() {
+ InputStream is = getClass().getResourceAsStream("/task-self.xml");
+
+ Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
+
+ Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"), null,
+ TaskStatus.QUEUED, null, null, null, null, null);
+ assertEquals(result, expects);
+
+ }
+
+ public void testApplyInputStream2() {
+ InputStream is = getClass().getResourceAsStream("/task-hosting.xml");
+
+ Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
+
+ Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/97806"), null,
+ TaskStatus.SUCCESS, dateService.iso8601SecondsDateParse("2010-01-14T20:04:51Z"), dateService
+ .iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService
+ .iso8601SecondsDateParse("2010-01-15T20:05:02Z"),
+
+ new ReferenceTypeImpl("188849-96", VCloudMediaType.VAPP_XML, URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96")), null);
+ assertEquals(result, expects);
+ }
+
+ public void testError() {
+ InputStream is = getClass().getResourceAsStream("/task-error.xml");
+
+ Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
+
+ Task expects = new TaskImpl(URI.create("http://10.150.4.49/api/v0.8/task/23"), null, TaskStatus.ERROR,
+ dateService.iso8601SecondsDateParse("2009-12-07T19:05:02Z"), dateService
+ .iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null, new ReferenceTypeImpl("testapp1",
+ VCloudMediaType.VAPP_XML, URI.create("http://10.150.4.49/api/v0.8/vapp/1")), new ErrorImpl(
+ "Error processing job", 500, MinorCode.UNRECOGNIZED,
+ " Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00", null));
+ assertEquals(result, expects);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java
new file mode 100644
index 0000000..24552b0
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.date.DateService;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.TaskStatus;
+import org.jclouds.vcloud.domain.TasksList;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.internal.TaskImpl;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSortedSet;
+
+/**
+ * Tests behavior of {@code TasksListHandler}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "TasksListHandlerTest")
+public class TasksListHandlerTest extends BaseHandlerTest {
+
+ private DateService dateService;
+
+ @BeforeTest
+ @Override
+ protected void setUpInjector() {
+ super.setUpInjector();
+ dateService = injector.getInstance(DateService.class);
+ }
+
+ public void testApplyInputStream() {
+ InputStream is = getClass().getResourceAsStream("/taskslist.xml");
+
+ TasksList result = factory.create(injector.getInstance(TasksListHandler.class)).parse(is);
+ assertEquals(result.getLocation(), URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/1"));
+ Task task1 = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3300"),
+ null, TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:30:19.587Z"), dateService
+ .iso8601DateParse("2009-08-24T21:30:32.63Z"), null, new ReferenceTypeImpl("Server1",
+ VCloudMediaType.VAPP_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null);
+ Task task2 = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
+ null, TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), dateService
+ .iso8601DateParse("2009-08-24T21:29:44.65Z"), null, new ReferenceTypeImpl("Server1",
+ VCloudMediaType.VAPP_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null);
+ assertEquals(result.getTasks(), ImmutableSortedSet.of(task1, task2));
+ }
+
+ public void testApplyInputStreamHosting() {
+ InputStream is = getClass().getResourceAsStream("/taskslist-hosting.xml");
+
+ TasksList result = factory.create(injector.getInstance(TasksListHandler.class)).parse(is);
+ assertEquals(result.getLocation(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849"));
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java
new file mode 100644
index 0000000..992e343
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code VAppHandler}
+ */
+@Test(groups = "unit")
+public class VAppHandlerTest {
+
+ public void testRhelOffStatic() {
+ InputStream is = getClass().getResourceAsStream("/vapp-rhel-off-static.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule() {
+
+ @Override
+ protected void configure() {
+ super.configure();
+ bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
+ }
+ });
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
+ assertEquals(result.getName(), "vApp_acole_2");
+ assertEquals(result.getDescription(), "foo");
+ assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-607806320"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.vApp+xml");
+ assertEquals(result.getStatus(), Status.OFF);
+ assertEquals(
+ result.getVDC(),
+ new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439")));
+ assertEquals(result.getTasks(), ImmutableList.of());
+ assert result.isOvfDescriptorUploaded();
+ assert result.getNetworkSection() != null;
+ Vm vm = Iterables.getOnlyElement(result.getChildren());
+ VmHandlerTest.checkVm(vm);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java
new file mode 100644
index 0000000..c0cc110
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.date.DateService;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.ovf.Network;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.GuestCustomizationSection;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.TaskStatus;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.internal.TaskImpl;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code VAppTemplateHandler}
+ */
+@Test(groups = "unit")
+public class VAppTemplateHandlerTest {
+
+ public void testUbuntuTemplate() {
+ VAppTemplate result = parseTemplate();
+ assertEquals(result.getName(), "Ubuntu Template");
+ assertEquals(result.getHref(), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml");
+ assertEquals(result.getStatus(), Status.OFF);
+ assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439")));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getTasks(), ImmutableList.of());
+ assertEquals(result.getVAppScopedLocalId(), null);
+ assert result.isOvfDescriptorUploaded();
+ Vm vm = Iterables.getOnlyElement(result.getChildren());
+ assertEquals(vm.getName(), "Ubuntu1004");
+ assertEquals(vm.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vm-172837194"));
+ // NOTE this is vAppTemplate not VM!
+ assertEquals(vm.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml");
+ assertEquals(vm.getStatus(), null);
+ assertEquals(vm.getParent(), new ReferenceTypeImpl(null, VCloudMediaType.VAPPTEMPLATE_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921")));
+ assertEquals(vm.getDescription(), null);
+ assertEquals(vm.getTasks(), ImmutableList.of());
+ assertEquals(vm.getVAppScopedLocalId(), "02_ubuntu_template");
+
+ GuestCustomizationSection guestC = vm.getGuestCustomizationSection();
+
+ assertEquals(guestC.getType(), VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML);
+ assertEquals(
+ guestC.getHref(),
+ URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vm-172837194/guestCustomizationSection/"));
+ assertEquals(guestC.getInfo(), "Specifies Guest OS Customization Settings");
+ assertEquals(guestC.isEnabled(), Boolean.TRUE);
+ assertEquals(guestC.shouldChangeSid(), Boolean.FALSE);
+ assertEquals(guestC.getVirtualMachineId(), "172837194");
+ assertEquals(guestC.isJoinDomainEnabled(), Boolean.FALSE);
+ assertEquals(guestC.useOrgSettings(), Boolean.FALSE);
+ assertEquals(guestC.getDomainName(), null);
+ assertEquals(guestC.getDomainUserName(), null);
+ assertEquals(guestC.getDomainUserPassword(), null);
+ assertEquals(guestC.isAdminPasswordEnabled(), Boolean.TRUE);
+ assertEquals(guestC.isAdminPasswordAuto(), Boolean.TRUE);
+ assertEquals(guestC.getAdminPassword(), "%3eD%gmF");
+ assertEquals(guestC.isResetPasswordRequired(), Boolean.FALSE);
+ assertEquals(
+ guestC.getCustomizationScript(),
+ "#!/bin/bash if [ \"$1\" = \"postcustomization\" ]; then echo \"post customization\" touch /root/.postcustomization sleep 30 #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server echo \"completed\" fi");
+ assertEquals(guestC.getComputerName(), "Ubuntu1004");
+ assertEquals(guestC.getEdit(), null);
+
+ VCloudNetworkSection network = result.getNetworkSection();
+ assertEquals(
+ network.getHref(),
+ URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/networkSection/"));
+ assertEquals(network.getType(), VCloudMediaType.NETWORKSECTION_XML);
+ assertEquals(network.getInfo(), "The list of logical networks");
+ assertEquals(network.getNetworks(), ImmutableSet.of(new Network("vAppNet-vApp Internal", null)));
+
+ }
+
+ public static VAppTemplate parseTemplate() {
+ InputStream is = VAppTemplateHandlerTest.class.getResourceAsStream("/vAppTemplate.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VAppTemplate result = factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
+ return result;
+ }
+
+ public void testCopyingTemplate() {
+ InputStream is = getClass().getResourceAsStream("/vAppTemplate-copying.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ DateService dateService = injector.getInstance(DateService.class);
+
+ VAppTemplate result = factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
+ assertEquals(result.getName(), "Ubuntu10.04_v2");
+ assertEquals(result.getHref(), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml");
+ assertEquals(result.getStatus(), Status.UNRESOLVED);
+ assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/105186609")));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getTasks(), ImmutableList.of(new TaskImpl(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/task/q62gxhi32xgd9yrqvr"),
+ "Copying Virtual Application Template Ubuntu10.04_v2(699683881)", TaskStatus.RUNNING, dateService
+ .iso8601DateParse("2010-09-17T23:20:46.039-04:00"), dateService
+ .iso8601DateParse("9999-12-31T23:59:59.999-05:00"), dateService
+ .iso8601DateParse("2010-12-16T23:20:46.039-05:00"), new ReferenceTypeImpl("Ubuntu10.04_v2",
+ "application/vnd.vmware.vcloud.vAppTemplate+xml",
+ URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881")),
+ null)));
+ assertEquals(result.getVAppScopedLocalId(), null);
+ assert result.isOvfDescriptorUploaded();
+ assertEquals(result.getChildren(), ImmutableList.of());
+ assertEquals(result.getNetworkSection(), null);
+
+ }
+
+ public void testVAppTemplateWithNewlinesAndNamespacedElements() {
+ InputStream is = getClass().getResourceAsStream("/vAppTemplate1.0-vcd15_withNewlines.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+
+ factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java
new file mode 100644
index 0000000..d5cc9da
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.AllocationModel;
+import org.jclouds.vcloud.domain.Capacity;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.domain.VDCStatus;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code VDCHandler}
+ */
+@Test(groups = "unit")
+public class VDCHandlerTest {
+ public void testVCloud1_0() {
+ InputStream is = getClass().getResourceAsStream("/vdc-1.0.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
+ assertEquals(result.getName(), "Jclouds-Commit-compG1xstorA01");
+ assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.vdc+xml");
+ assertEquals(result.getStatus(), VDCStatus.READY);
+ assertEquals(result.getOrg(), new ReferenceTypeImpl(null, VCloudMediaType.ORG_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getTasks(), ImmutableList.of());
+ assertEquals(result.getAllocationModel(), AllocationModel.ALLOCATION_POOL);
+ assertEquals(result.getStorageCapacity(), new Capacity("MB", 1024000, 1024000, 0, 0));
+ assertEquals(result.getCpuCapacity(), new Capacity("MHz", 20000, 20000, 0, 0));
+ assertEquals(result.getMemoryCapacity(), new Capacity("MB", 30720, 30720, 0, 0));
+ assertEquals(result.getResourceEntities(), ImmutableMap.<String, ReferenceType> of());
+ assertEquals(result.getAvailableNetworks(), ImmutableMap.of("isolation01", new ReferenceTypeImpl("isolation01",
+ "application/vnd.vmware.vcloud.network+xml", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/network/990419644")), "internet01",
+ new ReferenceTypeImpl("internet01", "application/vnd.vmware.vcloud.network+xml", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/network/758634723"))));
+ assertEquals(result.getNicQuota(), 0);
+ assertEquals(result.getNetworkQuota(), 100);
+ assertEquals(result.getVmQuota(), 50);
+ assert result.isEnabled();
+ }
+
+ public void testTerremark() {
+ InputStream is = getClass().getResourceAsStream("/vdc.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
+ assertEquals(result.getName(), "Miami Environment 1");
+ assertEquals(result.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getStorageCapacity(), new Capacity("bytes * 10^9", 100, 0, 8, 0));
+ assertEquals(result.getCpuCapacity(), new Capacity("hz * 10^6", 5000, 0, 0, 0));
+ assertEquals(result.getMemoryCapacity(), new Capacity("bytes * 2^20", 10240, 0, 0, 0));
+ assertEquals(result.getVmQuota(), 0);
+ assertEquals(result.getResourceEntities(), ImmutableMap.<String, ReferenceType> of("adriantest",
+ new ReferenceTypeImpl("adriantest", VCloudMediaType.VAPP_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15124")), "centos-53",
+ new ReferenceTypeImpl("centos-53", VCloudMediaType.VAPP_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15120"))));
+ assertEquals(result.getAvailableNetworks(), ImmutableMap.of("10.114.34.128/26", new ReferenceTypeImpl(
+ "10.114.34.128/26", "application/vnd.vmware.vcloud.network+xml", URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"))));
+ }
+
+ public void testHostingDotCom() {
+ InputStream is = getClass().getResourceAsStream("/vdc-hosting.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
+ assertEquals(result.getName(), "vDC Name");
+ assertEquals(result.getHref(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"));
+ assertEquals(result.getDescription(), "vDC Name");
+ assertEquals(result.getStorageCapacity(), new Capacity("bytes * 10^9", 0, 0, 40960, 0));
+ assertEquals(result.getCpuCapacity(), new Capacity("hz * 10^6", 0, 0, 2400, 0));
+ assertEquals(result.getMemoryCapacity(), new Capacity("bytes * 10^9", 0, 0, 2, 0));
+ assertEquals(result.getVmQuota(), 0);
+ assertEquals(result.getResourceEntities(), new ImmutableMap.Builder<String, ReferenceType>().put(
+ "Plesk (Linux) 64-bit Template",
+ new ReferenceTypeImpl("Plesk (Linux) 64-bit Template", "application/vnd.vmware.vcloud.vAppTemplate+xml",
+ URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/1"))).put(
+
+ "Windows 2008 Datacenter 64 Bit Template",
+ new ReferenceTypeImpl("Windows 2008 Datacenter 64 Bit Template",
+ "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2"))).put(
+ "Cent OS 64 Bit Template",
+ new ReferenceTypeImpl("Cent OS 64 Bit Template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"))).put(
+ "cPanel (Linux) 64 Bit Template",
+ new ReferenceTypeImpl("cPanel (Linux) 64 Bit Template",
+ "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/4"))).put(
+ "188849-1",
+ new ReferenceTypeImpl("188849-1", "application/vnd.vmware.vcloud.vApp+xml", URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1"))).put(
+ "188849-2",
+ new ReferenceTypeImpl("188849-2", "application/vnd.vmware.vcloud.vApp+xml", URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-2"))).build());
+
+ assertEquals(result.getAvailableNetworks(), ImmutableMap.<String, ReferenceType> of());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java
new file mode 100644
index 0000000..342b04a
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemSectionHandlerTest;
+import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
+import org.jclouds.vcloud.xml.ovf.VCloudVirtualHardwareSectionHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code VmHandler}
+ */
+@Test(groups = "unit")
+public class VmHandlerTest {
+ public void testVCloud1_0() {
+ InputStream is = getClass().getResourceAsStream("/vm-rhel-off-static.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule() {
+
+ @Override
+ protected void configure() {
+ super.configure();
+ bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
+ }
+ });
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ Vm result = factory.create(injector.getInstance(VmHandler.class)).parse(is);
+ checkVm(result);
+ }
+
+ static void checkVm(Vm result) {
+ assertEquals(result.getName(), "RHEL5");
+ assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.vm+xml");
+ assertEquals(result.getStatus(), Status.OFF);
+ assertEquals(result.getParent(), new ReferenceTypeImpl(null, VCloudMediaType.VAPP_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-607806320")));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getTasks(), ImmutableList.of());
+ assertEquals(result.getVAppScopedLocalId(), "10_rhel_template");
+ VCloudVirtualHardwareSectionHandlerTest.checkHardware(result.getVirtualHardwareSection());
+ VCloudOperatingSystemSectionHandlerTest.checkOs(result.getOperatingSystemSection());
+ NetworkConnectionSectionHandlerTest.checkNetworkConnectionSection(result.getNetworkConnectionSection());
+ GuestCustomizationSectionHandlerTest.checkGuestCustomization(result.getGuestCustomizationSection());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java
new file mode 100644
index 0000000..307b3f1
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml.ovf;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.UnknownHostException;
+
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code VCloudOperatingSystemSectionHandler}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "VCloudOperatingSystemSectionHandlerTest")
+public class VCloudOperatingSystemSectionHandlerTest extends BaseHandlerTest {
+
+ public void testDefault() throws UnknownHostException {
+ InputStream is = getClass().getResourceAsStream("/os.xml");
+
+ VCloudOperatingSystemSection result = factory.create(injector.getInstance(VCloudOperatingSystemHandler.class)).parse(is);
+
+ checkOs(result);
+
+ }
+
+ @Test(enabled = false)
+ public static void checkOs(VCloudOperatingSystemSection result) {
+ assertEquals(result.getHref(), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/"));
+ assertEquals(result.getDescription(), "Red Hat Enterprise Linux 5 (64-bit)");
+ assertEquals(result.getEdit(), new ReferenceTypeImpl(null,
+ "application/vnd.vmware.vcloud.operatingSystemSection+xml",
+ URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/")));
+ assertEquals(result.getId(), Integer.valueOf(80));
+ assertEquals(result.getVmwOsType(), "rhel5_64Guest");
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.operatingSystemSection+xml");
+ assertEquals(result.getInfo(), "Specifies the operating system installed");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java
new file mode 100644
index 0000000..72be94a
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml.ovf;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.UnknownHostException;
+
+import org.jclouds.cim.ResourceAllocationSettingData;
+import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
+import org.jclouds.cim.VirtualSystemSettingData;
+import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.ovf.EditableResourceAllocationSettingData;
+import org.jclouds.vcloud.domain.ovf.VCloudHardDisk;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
+import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
+import org.jclouds.vcloud.xml.VCloudVirtualHardwareHandler;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.inject.Guice;
+
+/**
+ * Tests behavior of {@code VCloudVirtualHardwareSectionHandler}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "VCloudVirtualHardwareSectionHandlerTest")
+public class VCloudVirtualHardwareSectionHandlerTest extends BaseHandlerTest {
+ @BeforeTest
+ @Override
+ protected void setUpInjector() {
+ injector = Guice.createInjector(new SaxParserModule() {
+ public void configure() {
+ super.configure();
+ bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
+ }
+ });
+ factory = injector.getInstance(ParseSax.Factory.class);
+ assert factory != null;
+ }
+
+ public void testDefault() throws UnknownHostException {
+ InputStream is = getClass().getResourceAsStream("/virtualhardwaresection.xml");
+
+ VCloudVirtualHardwareSection result = factory.create(injector.getInstance(VCloudVirtualHardwareHandler.class))
+ .parse(is);
+
+ checkHardware(result);
+
+ }
+
+ @Test(enabled = false)
+ public static void checkHardware(VCloudVirtualHardwareSection result) {
+ VirtualSystemSettingData system = VirtualSystemSettingData.builder().instanceID("0").elementName(
+ "Virtual Hardware Family").virtualSystemIdentifier("RHEL5").virtualSystemType("vmx-07").build();
+
+ assertEquals(result.getHref(), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.virtualHardwareSection+xml");
+ assertEquals(result.getSystem().toString(), system.toString());
+ assertEquals(result.getInfo(), "Virtual hardware requirements");
+
+ assertEquals(Iterables.get(result.getItems(), 0).toString(), VCloudNetworkAdapter.builder()
+ .instanceID("1").elementName("Network adapter 0").description("PCNet32 ethernet adapter").resourceType(
+ ResourceType.ETHERNET_ADAPTER).resourceSubType("PCNet32").automaticAllocation(true).connection(
+ "internet01").address("00:50:56:01:01:f2").addressOnParent("0").ipAddress("174.47.101.164")
+ .primaryNetworkConnection(true).ipAddressingMode("POOL").build().toString());
+
+ assertEquals(Iterables.get(result.getItems(), 1).toString(), ResourceAllocationSettingData
+ .builder().instanceID("2").elementName("SCSI Controller 0").description("SCSI Controller").resourceType(
+ ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic").address("0").build().toString());
+
+ assertEquals(Iterables.get(result.getItems(), 2).toString(), VCloudHardDisk.builder().instanceID(
+ "2000").elementName("Hard disk 1").description("Hard disk").resourceType(ResourceType.DISK_DRIVE)
+ .addressOnParent("0").parent("2").capacity(30720).busType(6).busSubType("lsilogic").build().toString());
+
+ assertEquals(Iterables.get(result.getItems(), 3).toString(), ResourceAllocationSettingData
+ .builder().instanceID("3").elementName("IDE Controller 0").description("IDE Controller").resourceType(
+ ResourceType.IDE_CONTROLLER).address("0").build().toString());
+
+ assertEquals(Iterables.get(result.getItems(), 4).toString(), ResourceAllocationSettingData
+ .builder().instanceID("3002").elementName("CD/DVD Drive 1").description("CD/DVD Drive").resourceType(
+ ResourceType.CD_DRIVE).addressOnParent("0").automaticAllocation(false).parent("3").build()
+ .toString());
+
+ assertEquals(Iterables.get(result.getItems(), 5).toString(), ResourceAllocationSettingData
+ .builder().instanceID("8000").elementName("Floppy Drive 1").description("Floppy Drive").resourceType(
+ ResourceType.FLOPPY_DRIVE).addressOnParent("0").automaticAllocation(false).build().toString());
+
+ assertEquals(
+ Iterables.get(result.getItems(), 6).toString(),
+ EditableResourceAllocationSettingData
+ .builder()
+ .instanceID("4")
+ .elementName("1 virtual CPU(s)")
+ .description("Number of Virtual CPUs")
+ .resourceType(ResourceType.PROCESSOR)
+ .virtualQuantity(1l)
+ .allocationUnits("hertz * 10^6")
+ .reservation(0l)
+ .weight(0)
+ .edit(
+ new ReferenceTypeImpl(
+ null,
+ "application/vnd.vmware.vcloud.rasdItem+xml",
+ URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/cpu"),"edit"))
+ .build().toString());
+
+ assertEquals(
+ Iterables.get(result.getItems(), 7).toString(),
+ EditableResourceAllocationSettingData
+ .builder()
+ .instanceID("5")
+ .elementName("384 MB of memory")
+ .description("Memory Size")
+ .resourceType(ResourceType.MEMORY)
+ .virtualQuantity(384l)
+ .allocationUnits("byte * 2^20")
+ .reservation(0l)
+ .weight(0)
+ .edit(
+ new ReferenceTypeImpl(
+ null,
+ "application/vnd.vmware.vcloud.rasdItem+xml",
+ URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/memory"),"edit"))
+ .build().toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/captureVApp-default.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/captureVApp-default.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/captureVApp-default.xml
new file mode 100644
index 0000000..0570872
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/captureVApp-default.xml
@@ -0,0 +1 @@
+<CaptureVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-template" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/4181" type="application/vnd.vmware.vcloud.vApp+xml"/></CaptureVAppParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/captureVApp.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/captureVApp.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/captureVApp.xml
new file mode 100644
index 0000000..35e62d0
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/captureVApp.xml
@@ -0,0 +1 @@
+<CaptureVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-template" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vApp Template</Description><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/201" type="application/vnd.vmware.vcloud.vApp+xml"/></CaptureVAppParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog-blank.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog-blank.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog-blank.xml
new file mode 100644
index 0000000..6bc4038
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog-blank.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Catalog xmlns="http://www.vmware.com/vcloud/v1" name="Jclouds-private" type="application/vnd.vmware.vcloud.catalog+xml" href="https://vcenterprise.bluelock.com/api/v1.0/catalog/921222081" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://vcenterprise.bluelock.com/api/v1.0/org/9566014"/>
+ <Link rel="add" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcenterprise.bluelock.com/api/v1.0/catalog/921222081/catalogItems"/>
+ <CatalogItems/>
+ <IsPublished>false</IsPublished>
+</Catalog>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog-hosting.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog-hosting.xml
new file mode 100644
index 0000000..be510a9
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog-hosting.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Catalog href="https://vcloud.safesecureweb.com/api/v0.8/catalog/1"
+ name="HMSCatalog" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8/catalog.xsd"
+ xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <Description>HMS Shared Catalog</Description>
+
+ <Link rel="add"
+ href="https://vcloud.safesecureweb.com/api/v0.8/catalog/1/catalogItems"
+ type="application/vnd.vmware.vcloud.catalogItem+xml" />
+
+ <CatalogItems>
+ <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml"
+ href="https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1"
+ name="Plesk (Linux) 64-bit Template" />
+ <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml"
+ href="https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"
+ name="Windows 2008 Datacenter 64 Bit Template" />
+ <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml"
+ href="https://vcloud.safesecureweb.com/api/v0.8/catalogItem/3"
+ name="Cent OS 64 Bit Template" />
+ <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml"
+ href="https://vcloud.safesecureweb.com/api/v0.8/catalogItem/4"
+ name="cPanel (Linux) 64 Bit Template" />
+ </CatalogItems>
+</Catalog>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog.xml
new file mode 100644
index 0000000..f2d5eaa
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog.xml
@@ -0,0 +1,27 @@
+<Catalog href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog" type="application/vnd.vmware.vcloud.catalog+xml" name="Miami Environment 1" xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <CatalogItems>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/5" type="application/vnd.vmware.vcloud.catalogItem+xml" name="CentOS 5.3 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/6" type="application/vnd.vmware.vcloud.catalogItem+xml" name="CentOS 5.3 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/7" type="application/vnd.vmware.vcloud.catalogItem+xml" name="RHEL 5.3 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/8" type="application/vnd.vmware.vcloud.catalogItem+xml" name="RHEL 5.3 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/11" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Ubuntu JeOS 9.04 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/12" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Ubuntu JeOS 9.04 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/9" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Ubuntu Server 9.04 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/10" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Ubuntu Server 9.04 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/1" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Enterprise R2 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/2" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Enterprise R2 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/3" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Standard R2 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/4" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Standard R2 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/23" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Enterprise (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Enterprise (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Enterprise R2 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Standard (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Standard (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/19" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Standard R2 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/14" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Standard w.SQL 2008 Web (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/20" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Web Server 2008 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Web Server 2008 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Web Server 2008 R2 (64-bit)"/>
+ </CatalogItems>
+</Catalog>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog1.0-vcd15.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog1.0-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog1.0-vcd15.xml
new file mode 100644
index 0000000..0208e59
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/catalog1.0-vcd15.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Catalog xmlns="http://www.vmware.com/vcloud/v1" name="jclouds" type="application/vnd.vmware.vcloud.catalog+xml" href="https://zone.myvcloud.com/api/v1.0/catalog/3155f393-1e1d-4572-8c9c-d76f72ddb658" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 https://zone.myvcloud.com/api/v1.0/schema/master.xsd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://zone.myvcloud.com/api/v1.0/org/c076f90a-397a-49fa-89b8-b294c1599cd0"/>
+ <Link rel="add" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://zone.myvcloud.com/api/v1.0/catalog/3155f393-1e1d-4572-8c9c-d76f72ddb658/catalogItems"/>
+ <CatalogItems>
+ <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml" name="UbuntuServer-x64-2GB" href="https://zone.myvcloud.com/api/v1.0/catalogItem/ceb369f7-1d07-4e32-9dbd-ebb5aa6ca55c"/>
+ </CatalogItems>
+ <IsPublished>false</IsPublished>
+</Catalog>
\ No newline at end of file
[24/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiLiveTest.java
new file mode 100644
index 0000000..0665906
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiLiveTest.java
@@ -0,0 +1,637 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.extensions.lbaas.v1;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.neutron.v2.domain.Network;
+import org.jclouds.openstack.neutron.v2.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2.domain.Subnet;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitor;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HttpMethod;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.LBaaSStatus;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Member;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pool;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.ProbeType;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Protocol;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.SessionPersistence;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIP;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs;
+import org.jclouds.openstack.neutron.v2.features.NetworkApi;
+import org.jclouds.openstack.neutron.v2.features.SubnetApi;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiLiveTest;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests parsing and Guice wiring of RouterApi
+ */
+@Test(groups = "live", testName = "LBaaSApiLiveTest")
+public class LBaaSApiLiveTest extends BaseNeutronApiLiveTest {
+
+ private Logger logger = getLoggingModule().createLoggerFactory().getLogger(LBaaSApiLiveTest.class.getName());
+
+ private Map<String, Network> networks;
+ private Map<String, Subnet> subnets;
+
+ public void testLBaaSPresence() throws Exception {
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lBaaSv1Api = api.getLBaaSApi(region);
+
+ /*
+ * Check response
+ */
+ assertNotNull(lBaaSv1Api);
+ if (lBaaSv1Api.isPresent()) {
+ logger.info("LBaaS API Version 1 is available");
+ } else {
+ logger.info("LBaaS API Version 1 is unavailable");
+ }
+ }
+ }
+
+ @BeforeClass
+ public void createSubnets() {
+ networks = new HashMap<String, Network>();
+ subnets = new HashMap<String, Subnet>();
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lbaasApiExtension = api.getLBaaSApi(region);
+ if (!lbaasApiExtension.isPresent()) {
+ continue;
+ }
+ NetworkApi networkApi = api.getNetworkApi(region);
+ SubnetApi subnetApi = api.getSubnetApi(region);
+
+ Network network = networkApi.create(Network.createBuilder("jclouds-lbaas-test-network").networkType(NetworkType.LOCAL).build());
+ assertNotNull(network);
+ networks.put(region, network);
+
+ Subnet subnet = subnetApi.create(Subnet.createBuilder(network.getId(), "10.0.0.0/24").ipVersion(4).name("jclouds-lbaas-test-subnet").build());
+ assertNotNull(subnet);
+ subnets.put(region, subnet);
+ }
+ }
+
+ @AfterClass
+ public void deleteSubnets() {
+ for (String region : api.getConfiguredRegions()) {
+ NetworkApi networkApi = api.getNetworkApi(region);
+ SubnetApi subnetApi = api.getSubnetApi(region);
+
+ try {
+ Subnet subnet = subnets.get(region);
+ if (subnet != null) {
+ assertTrue(subnetApi.delete(subnet.getId()));
+ }
+ } finally {
+ Network network = networks.get(region);
+ if (network != null) {
+ assertTrue(networkApi.delete(network.getId()));
+ }
+ }
+ }
+ networks = null;
+ subnets = null;
+ }
+
+ public void testCreateUpdateAndDeletePool() {
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lbaasApiExtension = api.getLBaaSApi(region);
+ if (!lbaasApiExtension.isPresent()) {
+ continue;
+ }
+ LBaaSApi lbaasApi = lbaasApiExtension.get();
+
+ Subnet subnet = subnets.get(region);
+ Pool pool = null;
+
+ try {
+ // Create
+ Pool.CreatePool createPool = Pool.createBuilder(subnet.getId(), Protocol.HTTP, Pool.ROUND_ROBIN)
+ .name("jclouds-lbaas-test-pool").description(null).healthMonitors(null).provider(null).adminStateUp(null).build();
+ pool = lbaasApi.createPool(createPool);
+ assertNotNull(pool);
+ assertNotNull(pool.getId());
+ assertEquals(pool.getTenantId(), subnet.getTenantId());
+ assertNull(pool.getVIPId());
+ assertEquals(pool.getName(), "jclouds-lbaas-test-pool");
+ assertEquals(pool.getDescription(), "");
+ assertEquals(pool.getSubnetId(), subnet.getId());
+ assertEquals(pool.getProtocol(), Protocol.HTTP);
+ assertNotNull(pool.getProvider());
+ assertEquals(pool.getLBMethod(), Pool.ROUND_ROBIN);
+ assertNotNull(pool.getHealthMonitors());
+ assertTrue(pool.getHealthMonitors().isEmpty());
+ assertNotNull(pool.getHealthMonitorsStatus());
+ assertTrue(pool.getHealthMonitorsStatus().isEmpty());
+ assertNotNull(pool.getMembers());
+ assertTrue(pool.getMembers().isEmpty());
+ assertEquals(pool.getAdminStateUp(), Boolean.TRUE);
+ assertTrue(pool.getStatus() == LBaaSStatus.PENDING_CREATE || pool.getStatus() == LBaaSStatus.ACTIVE);
+ assertNull(pool.getStatusDescription());
+
+ // List and Get
+ Pools pools = lbaasApi.listPools(PaginationOptions.Builder.queryParameters(ImmutableMap.of("name", "jclouds-lbaas-test-pool").asMultimap()));
+ assertNotNull(pools);
+ assertFalse(pools.isEmpty());
+ Pool poolList = pools.first().get();
+ Pool poolGet = lbaasApi.getPool(poolList.getId());
+ assertNotNull(poolGet);
+ assertEquals(poolGet, poolList);
+
+ poolGet = lbaasApi.getPool(pool.getId());
+ assertNotNull(poolGet);
+ assertEquals(poolGet.getName(), pool.getName());
+ assertEquals(poolGet.getId(), pool.getId());
+
+ // Update
+ Pool.UpdatePool updatePool = Pool.updateBuilder().name("jclouds-lbaas-test-pool-renamed").description("new description").lbMethod(Pool.ROUND_ROBIN)
+ .healthMonitors(null).adminStateUp(Boolean.FALSE).build();
+ Pool poolUpdate = lbaasApi.updatePool(pool.getId(), updatePool);
+ assertNotNull(poolUpdate);
+ assertEquals(poolUpdate.getName(), "jclouds-lbaas-test-pool-renamed");
+ assertEquals(poolUpdate.getLBMethod(), Pool.ROUND_ROBIN);
+ assertNotNull(poolUpdate.getHealthMonitors());
+ assertTrue(poolUpdate.getHealthMonitors().isEmpty());
+ assertNotNull(poolUpdate.getHealthMonitorsStatus());
+ assertTrue(poolUpdate.getHealthMonitorsStatus().isEmpty());
+ assertEquals(poolUpdate.getAdminStateUp(), Boolean.FALSE);
+
+ poolGet = lbaasApi.getPool(pool.getId());
+ assertNotNull(poolGet);
+ assertEquals(poolGet.getId(), pool.getId());
+ assertEquals(poolGet.getTenantId(), subnet.getTenantId());
+ assertNull(poolGet.getVIPId());
+ assertEquals(poolGet.getName(), "jclouds-lbaas-test-pool-renamed");
+ assertEquals(poolGet.getDescription(), "new description");
+ assertEquals(poolGet.getSubnetId(), subnet.getId());
+ assertEquals(poolGet.getProtocol(), Protocol.HTTP);
+ assertNotNull(poolGet.getProvider());
+ assertEquals(poolGet.getLBMethod(), Pool.ROUND_ROBIN);
+ assertNotNull(poolGet.getHealthMonitors());
+ assertTrue(poolGet.getHealthMonitors().isEmpty());
+ assertNotNull(poolGet.getHealthMonitorsStatus());
+ assertTrue(poolGet.getHealthMonitorsStatus().isEmpty());
+ assertNotNull(poolGet.getMembers());
+ assertTrue(poolGet.getMembers().isEmpty());
+ assertEquals(poolGet.getAdminStateUp(), Boolean.FALSE);
+ assertTrue(poolGet.getStatus() == LBaaSStatus.PENDING_UPDATE || poolGet.getStatus() == LBaaSStatus.ACTIVE);
+ assertNull(poolGet.getStatusDescription());
+ } finally {
+ if (pool != null) {
+ // Delete
+ assertTrue(lbaasApi.deletePool(pool.getId()));
+ Pool poolGet = lbaasApi.getPool(pool.getId());
+ assertNull(poolGet);
+ }
+ }
+ }
+ }
+
+ public void testCreateUpdateAndDeleteMember() {
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lbaasApiExtension = api.getLBaaSApi(region);
+ if (!lbaasApiExtension.isPresent()) {
+ continue;
+ }
+ LBaaSApi lbaasApi = lbaasApiExtension.get();
+
+ Subnet subnet = subnets.get(region);
+ Pool pool1 = null;
+ Pool pool2 = null;
+ Member member = null;
+
+ try {
+ // Create pools
+ Pool.CreateBuilder createBuilder = Pool.createBuilder(subnet.getId(), Protocol.HTTP, Pool.ROUND_ROBIN)
+ .name("jclouds-lbaas-test-member-pool-1").description(null).healthMonitors(null).provider(null).adminStateUp(null);
+ pool1 = lbaasApi.createPool(createBuilder.build());
+ assertNotNull(pool1);
+ createBuilder.name("jclouds-lbaas-test-member-pool-2");
+ pool2 = lbaasApi.createPool(createBuilder.build());
+ assertNotNull(pool2);
+
+ // Create
+ Member.CreateMember createMember = Member.createBuilder(pool1.getId(), "10.0.0.100", 80)
+ .weight(null).adminStateUp(null).build();
+ member = lbaasApi.createMember(createMember);
+ assertNotNull(member);
+ assertNotNull(member.getId());
+ assertEquals(member.getTenantId(), subnet.getTenantId());
+ assertEquals(member.getPoolId(), pool1.getId());
+ assertEquals(member.getAddress(), "10.0.0.100");
+ assertEquals(member.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(member.getWeight(), Integer.valueOf(1));
+ assertEquals(member.getAdminStateUp(), Boolean.TRUE);
+ assertTrue(member.getStatus() == LBaaSStatus.PENDING_CREATE || member.getStatus() == LBaaSStatus.ACTIVE);
+ assertNull(member.getStatusDescription());
+
+ // List and Get
+ Members members = lbaasApi.listMembers(PaginationOptions.Builder.queryParameters(ImmutableMap.of("tenant_id", subnet.getTenantId()).asMultimap()));
+ assertNotNull(members);
+ assertFalse(members.isEmpty());
+ Member memberList = members.first().get();
+ Member memberGet = lbaasApi.getMember(memberList.getId());
+ assertNotNull(memberGet);
+ assertEquals(memberGet, memberList);
+
+ memberGet = lbaasApi.getMember(member.getId());
+ assertNotNull(memberGet);
+ assertEquals(memberGet.getId(), member.getId());
+
+ // Verify member appears in pool1 and not in pool2
+ Pool pool1Get = lbaasApi.getPool(pool1.getId());
+ assertNotNull(pool1Get);
+ assertNotNull(pool1Get.getMembers());
+ assertFalse(pool1Get.getMembers().isEmpty());
+ assertEquals(pool1Get.getMembers().iterator().next(), member.getId());
+ Pool pool2Get = lbaasApi.getPool(pool2.getId());
+ assertNotNull(pool2Get);
+ assertNotNull(pool2Get.getMembers());
+ assertTrue(pool2Get.getMembers().isEmpty());
+
+ // Update
+ Member.UpdateMember updateMember = Member.updateBuilder()
+ .poolId(pool2.getId()).weight(2).adminStateUp(Boolean.FALSE).build();
+ Member memberUpdate = lbaasApi.updateMember(member.getId(), updateMember);
+ assertNotNull(memberUpdate);
+ assertEquals(memberUpdate.getPoolId(), pool2.getId());
+ assertEquals(memberUpdate.getWeight(), Integer.valueOf(2));
+ assertEquals(memberUpdate.getAdminStateUp(), Boolean.FALSE);
+
+ memberGet = lbaasApi.getMember(member.getId());
+ assertNotNull(memberGet);
+ assertNotNull(memberGet.getId());
+ assertEquals(memberGet.getTenantId(), subnet.getTenantId());
+ assertEquals(memberGet.getPoolId(), pool2.getId());
+ assertEquals(member.getAddress(), "10.0.0.100");
+ assertEquals(memberGet.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(memberGet.getWeight(), Integer.valueOf(2));
+ assertEquals(memberGet.getAdminStateUp(), Boolean.FALSE);
+ assertTrue(memberGet.getStatus() == LBaaSStatus.PENDING_UPDATE || memberGet.getStatus() == LBaaSStatus.ACTIVE);
+ assertNull(memberGet.getStatusDescription());
+
+ // Verify member appears in pool2 and not in pool1
+ pool1Get = lbaasApi.getPool(pool1.getId());
+ assertNotNull(pool1Get);
+ assertNotNull(pool1Get.getMembers());
+ assertTrue(pool1Get.getMembers().isEmpty());
+ pool2Get = lbaasApi.getPool(pool2.getId());
+ assertNotNull(pool2Get);
+ assertNotNull(pool2Get.getMembers());
+ assertFalse(pool2Get.getMembers().isEmpty());
+ assertEquals(pool2Get.getMembers().iterator().next(), member.getId());
+ } finally {
+ if (member != null) {
+ // Delete
+ assertTrue(lbaasApi.deleteMember(member.getId()));
+ Member memberGet = lbaasApi.getMember(member.getId());
+ assertNull(memberGet);
+
+ // Verify member does not appear in pool1 and in pool2
+ Pool pool1Get = lbaasApi.getPool(pool1.getId());
+ assertNotNull(pool1Get);
+ assertNotNull(pool1Get.getMembers());
+ assertTrue(pool1Get.getMembers().isEmpty());
+ Pool pool2Get = lbaasApi.getPool(pool2.getId());
+ assertNotNull(pool2Get);
+ assertNotNull(pool2Get.getMembers());
+ assertTrue(pool2Get.getMembers().isEmpty());
+ }
+ if (pool2 != null) {
+ assertTrue(lbaasApi.deletePool(pool2.getId()));
+ }
+ if (pool1 != null) {
+ assertTrue(lbaasApi.deletePool(pool1.getId()));
+ }
+ }
+ }
+ }
+
+ public void testCreateUpdateAndDeleteVIP() {
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lbaasApiExtension = api.getLBaaSApi(region);
+ if (!lbaasApiExtension.isPresent()) {
+ continue;
+ }
+ LBaaSApi lbaasApi = lbaasApiExtension.get();
+
+ Subnet subnet = subnets.get(region);
+ Pool pool1 = null;
+ Pool pool2 = null;
+ VIP vip = null;
+
+ try {
+ // Create pools
+ Pool.CreateBuilder createBuilder = Pool.createBuilder(subnet.getId(), Protocol.HTTP, Pool.ROUND_ROBIN)
+ .name("jclouds-lbaas-test-vip-pool-1").description(null).healthMonitors(null).provider(null).adminStateUp(null);
+ pool1 = lbaasApi.createPool(createBuilder.build());
+ assertNotNull(pool1);
+ createBuilder.name("jclouds-lbaas-test-vip-pool-2");
+ pool2 = lbaasApi.createPool(createBuilder.build());
+ assertNotNull(pool2);
+
+ // Create
+ VIP.CreateVIP createVIP = VIP.createBuilder(subnet.getId(), Protocol.HTTP, 80, pool1.getId())
+ .name("jclouds-lbaas-test-vip").description(null).address(null).sessionPersistence(null).connectionLimit(null).build();
+ vip = lbaasApi.createVIP(createVIP);
+ assertNotNull(vip);
+ assertNotNull(vip.getId());
+ assertEquals(vip.getTenantId(), subnet.getTenantId());
+ assertEquals(vip.getName(), "jclouds-lbaas-test-vip");
+ assertEquals(vip.getDescription(), "");
+ assertEquals(vip.getSubnetId(), subnet.getId());
+ assertNotNull(vip.getAddress());
+ assertNotNull(vip.getPortId());
+ assertEquals(vip.getProtocol(), Protocol.HTTP);
+ assertEquals(vip.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(vip.getPoolId(), pool1.getId());
+ assertNull(vip.getSessionPersistence());
+ assertEquals(vip.getConnectionLimit(), Integer.valueOf(-1));
+ assertEquals(vip.getAdminStateUp(), Boolean.TRUE);
+ assertTrue(vip.getStatus() == LBaaSStatus.PENDING_CREATE || vip.getStatus() == LBaaSStatus.ACTIVE);
+ assertNull(vip.getStatusDescription());
+
+ // List and Get
+ VIPs vips = lbaasApi.listVIPs(PaginationOptions.Builder.queryParameters(ImmutableMap.of("tenant_id", subnet.getTenantId()).asMultimap()));
+ assertNotNull(vips);
+ assertFalse(vips.isEmpty());
+ VIP vipList = vips.first().get();
+ VIP vipGet = lbaasApi.getVIP(vipList.getId());
+ assertNotNull(vipGet);
+ assertEquals(vipGet, vipList);
+
+ vipGet = lbaasApi.getVIP(vip.getId());
+ assertNotNull(vipGet);
+ assertEquals(vipGet.getId(), vip.getId());
+
+ // Verify VIP appears in pool1 and not in pool2
+ Pool pool1Get = lbaasApi.getPool(pool1.getId());
+ assertNotNull(pool1Get);
+ assertEquals(pool1Get.getVIPId(), vip.getId());
+ Pool pool2Get = lbaasApi.getPool(pool2.getId());
+ assertNotNull(pool2Get);
+ assertNotEquals(pool2Get.getVIPId(), vip.getId());
+
+ // Update
+ SessionPersistence sessionPersistence = SessionPersistence.builder().type(SessionPersistence.Type.HTTP_COOKIE).cookieName(null).build();
+ VIP.UpdateVIP updateVIP = VIP.updateBuilder()
+ .name("jclouds-lbaas-test-vip-renamed").description("new description").poolId(pool2.getId())
+ .sessionPersistence(sessionPersistence).connectionLimit(2).adminStateUp(Boolean.FALSE).build();
+ VIP vipUpdate = lbaasApi.updateVIP(vip.getId(), updateVIP);
+ assertNotNull(vipUpdate);
+ assertEquals(vipUpdate.getName(), "jclouds-lbaas-test-vip-renamed");
+ assertEquals(vipUpdate.getDescription(), "new description");
+ assertEquals(vipUpdate.getPoolId(), pool2.getId());
+ assertEquals(vipUpdate.getSessionPersistence(), sessionPersistence);
+ assertEquals(vipUpdate.getConnectionLimit(), Integer.valueOf(2));
+ assertEquals(vipUpdate.getAdminStateUp(), Boolean.FALSE);
+
+ vipGet = lbaasApi.getVIP(vip.getId());
+ assertNotNull(vipGet);
+ assertNotNull(vipGet.getId());
+ assertEquals(vipGet.getTenantId(), subnet.getTenantId());
+ assertEquals(vipGet.getName(), "jclouds-lbaas-test-vip-renamed");
+ assertEquals(vipGet.getDescription(), "new description");
+ assertEquals(vipGet.getSubnetId(), subnet.getId());
+ assertNotNull(vipGet.getAddress());
+ assertNotNull(vipGet.getPortId());
+ assertEquals(vipGet.getProtocol(), Protocol.HTTP);
+ assertEquals(vipGet.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(vipGet.getPoolId(), pool2.getId());
+ assertEquals(vipGet.getSessionPersistence(), sessionPersistence);
+ assertEquals(vipGet.getConnectionLimit(), Integer.valueOf(2));
+ assertEquals(vipGet.getAdminStateUp(), Boolean.FALSE);
+ assertTrue(vipGet.getStatus() == LBaaSStatus.PENDING_UPDATE || vipGet.getStatus() == LBaaSStatus.ACTIVE);
+ assertNull(vipGet.getStatusDescription());
+
+ // Verify VIP appears in pool2 and not in pool1
+ pool1Get = lbaasApi.getPool(pool1.getId());
+ assertNotNull(pool1Get);
+ assertNotEquals(pool1Get.getVIPId(), vip.getId());
+ pool2Get = lbaasApi.getPool(pool2.getId());
+ assertNotNull(pool2Get);
+ assertEquals(pool2Get.getVIPId(), vip.getId());
+ } finally {
+ if (vip != null) {
+ // Delete
+ assertTrue(lbaasApi.deleteVIP(vip.getId()));
+ VIP vipGet = lbaasApi.getVIP(vip.getId());
+ assertNull(vipGet);
+
+ // Verify VIP does not appear in pool1 and in pool2
+ Pool pool1Get = lbaasApi.getPool(pool1.getId());
+ assertNotNull(pool1Get);
+ assertNotEquals(pool1Get.getVIPId(), vip.getId());
+ Pool pool2Get = lbaasApi.getPool(pool2.getId());
+ assertNotNull(pool2Get);
+ assertNotEquals(pool2Get.getVIPId(), vip.getId());
+ }
+ if (pool2 != null) {
+ assertTrue(lbaasApi.deletePool(pool2.getId()));
+ }
+ if (pool1 != null) {
+ assertTrue(lbaasApi.deletePool(pool1.getId()));
+ }
+ }
+ }
+ }
+
+ public void testCreateUpdateAndDeleteHealthMonitor() {
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lbaasApiExtension = api.getLBaaSApi(region);
+ if (!lbaasApiExtension.isPresent()) {
+ continue;
+ }
+ LBaaSApi lbaasApi = lbaasApiExtension.get();
+
+ Subnet subnet = subnets.get(region);
+ HealthMonitor healthMonitor = null;
+
+ try {
+ // Create
+ HealthMonitor.CreateHealthMonitor createHealthMonitor = HealthMonitor.createBuilder(ProbeType.HTTP, Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1))
+ .httpMethod(null).urlPath(null).expectedCodes(null).adminStateUp(null).build();
+ healthMonitor = lbaasApi.createHealthMonitor(createHealthMonitor);
+ assertNotNull(healthMonitor);
+ assertNotNull(healthMonitor.getId());
+ assertEquals(healthMonitor.getTenantId(), subnet.getTenantId());
+ assertEquals(healthMonitor.getType(), ProbeType.HTTP);
+ assertEquals(healthMonitor.getDelay(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getTimeout(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getMaxRetries(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getHttpMethod(), HttpMethod.GET);
+ assertEquals(healthMonitor.getUrlPath(), "/");
+ assertEquals(healthMonitor.getExpectedCodes(), "200");
+ assertNotNull(healthMonitor.getPools());
+ assertTrue(healthMonitor.getPools().isEmpty());
+ assertEquals(healthMonitor.getAdminStateUp(), Boolean.TRUE);
+ //assertEquals(healthMonitor.getStatus(), LBaaSStatus.PENDING_CREATE);
+ assertNull(healthMonitor.getStatus());
+ assertNull(healthMonitor.getStatusDescription());
+
+ // List and Get
+ HealthMonitors healthMonitors = lbaasApi.listHealthMonitors(PaginationOptions.Builder.queryParameters(ImmutableMap.of("tenant_id", subnet.getTenantId()).asMultimap()));
+ assertNotNull(healthMonitors);
+ assertFalse(healthMonitors.isEmpty());
+ HealthMonitor healthMonitorList = healthMonitors.first().get();
+ HealthMonitor healthMonitorGet = lbaasApi.getHealthMonitor(healthMonitorList.getId());
+ assertNotNull(healthMonitorGet);
+ assertEquals(healthMonitorGet, healthMonitorList);
+
+ healthMonitorGet = lbaasApi.getHealthMonitor(healthMonitor.getId());
+ assertNotNull(healthMonitorGet);
+ assertEquals(healthMonitorGet.getId(), healthMonitor.getId());
+
+ // Update
+ HealthMonitor.UpdateHealthMonitor updateHealthMonitor = HealthMonitor.updateBuilder().delay(Integer.valueOf(2)).timeout(Integer.valueOf(2)).maxRetries(Integer.valueOf(2))
+ .httpMethod(HttpMethod.HEAD).urlPath("/index.html").expectedCodes("201").adminStateUp(Boolean.FALSE).build();
+ HealthMonitor healthMonitorUpdate = lbaasApi.updateHealthMonitor(healthMonitor.getId(), updateHealthMonitor);
+ assertNotNull(healthMonitorUpdate);
+ assertEquals(healthMonitorUpdate.getDelay(), Integer.valueOf(2));
+ assertEquals(healthMonitorUpdate.getTimeout(), Integer.valueOf(2));
+ assertEquals(healthMonitorUpdate.getMaxRetries(), Integer.valueOf(2));
+ assertEquals(healthMonitorUpdate.getHttpMethod(), HttpMethod.HEAD);
+ assertEquals(healthMonitorUpdate.getUrlPath(), "/index.html");
+ assertEquals(healthMonitorUpdate.getExpectedCodes(), "201");
+ assertEquals(healthMonitorUpdate.getAdminStateUp(), Boolean.FALSE);
+
+ healthMonitorGet = lbaasApi.getHealthMonitor(healthMonitor.getId());
+ assertNotNull(healthMonitorGet);
+ assertNotNull(healthMonitorGet.getId());
+ assertEquals(healthMonitorGet.getTenantId(), subnet.getTenantId());
+ assertEquals(healthMonitorGet.getType(), ProbeType.HTTP);
+ assertEquals(healthMonitorGet.getDelay(), Integer.valueOf(2));
+ assertEquals(healthMonitorGet.getTimeout(), Integer.valueOf(2));
+ assertEquals(healthMonitorGet.getMaxRetries(), Integer.valueOf(2));
+ assertEquals(healthMonitorGet.getHttpMethod(), HttpMethod.HEAD);
+ assertEquals(healthMonitorGet.getUrlPath(), "/index.html");
+ assertEquals(healthMonitorGet.getExpectedCodes(), "201");
+ assertNotNull(healthMonitorGet.getPools());
+ assertTrue(healthMonitorGet.getPools().isEmpty());
+ assertEquals(healthMonitorGet.getAdminStateUp(), Boolean.FALSE);
+ //assertEquals(healthMonitorGet.getStatus(), LBaaSStatus.PENDING_UPDATE);
+ assertNull(healthMonitorGet.getStatus());
+ assertNull(healthMonitorGet.getStatusDescription());
+ } finally {
+ if (healthMonitor != null) {
+ // Delete
+ assertTrue(lbaasApi.deleteHealthMonitor(healthMonitor.getId()));
+ HealthMonitor healthMonitorGet = lbaasApi.getHealthMonitor(healthMonitor.getId());
+ assertNull(healthMonitorGet);
+ }
+ }
+ }
+ }
+
+ public void testAssociateAndDisassociateHealthMonitorWithPool() {
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lbaasApiExtension = api.getLBaaSApi(region);
+ if (!lbaasApiExtension.isPresent()) {
+ continue;
+ }
+ LBaaSApi lbaasApi = lbaasApiExtension.get();
+
+ Subnet subnet = subnets.get(region);
+ Pool pool = null;
+ HealthMonitor healthMonitor = null;
+
+ try {
+ // Create pool
+ Pool.CreatePool poolCreateOptions = Pool.createBuilder(subnet.getId(), Protocol.TCP, Pool.ROUND_ROBIN)
+ .name("jclouds-lbaas-test-pool-association").build();
+ pool = lbaasApi.createPool(poolCreateOptions);
+ assertNotNull(pool);
+ assertNotNull(pool.getId());
+ assertNotNull(pool.getHealthMonitors());
+ assertTrue(pool.getHealthMonitors().isEmpty());
+ assertNotNull(pool.getHealthMonitorsStatus());
+ assertTrue(pool.getHealthMonitorsStatus().isEmpty());
+
+ // Create health monitor
+ HealthMonitor.CreateHealthMonitor healthMonitorCreateOptions = HealthMonitor.createBuilder(ProbeType.HTTP, Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1)).build();
+ healthMonitor = lbaasApi.createHealthMonitor(healthMonitorCreateOptions);
+ assertNotNull(healthMonitor);
+ assertNotNull(healthMonitor.getId());
+ assertNotNull(healthMonitor.getPools());
+ assertTrue(healthMonitor.getPools().isEmpty());
+
+ // Associate health monitor with pool
+ HealthMonitor healthMonitorAssociated = lbaasApi.associateHealthMonitor(pool.getId(), healthMonitor.getId());
+ assertNotNull(healthMonitorAssociated);
+
+ // Verify health monitor is associated with pool
+ Pool poolGet = lbaasApi.getPool(pool.getId());
+ assertNotNull(poolGet);
+ assertNotNull(poolGet.getHealthMonitors());
+ assertEquals(poolGet.getHealthMonitors().size(), 1);
+ assertEquals(poolGet.getHealthMonitors().iterator().next(), healthMonitor.getId());
+ assertNotNull(poolGet.getHealthMonitorsStatus());
+ assertEquals(poolGet.getHealthMonitorsStatus().size(), 1);
+ assertEquals(poolGet.getHealthMonitorsStatus().iterator().next().getId(), healthMonitor.getId());
+
+ HealthMonitor healthMonitorGet = lbaasApi.getHealthMonitor(healthMonitor.getId());
+ assertNotNull(healthMonitorGet);
+ assertNotNull(healthMonitorGet.getPools());
+ assertEquals(healthMonitorGet.getPools().size(), 1);
+ assertEquals(healthMonitorGet.getPools().iterator().next().getId(), pool.getId());
+
+ // Disassociate health monitor from pool
+ assertTrue(lbaasApi.disassociateHealthMonitor(pool.getId(), healthMonitor.getId()));
+
+ // Verify health monitor is disassociated from pool
+ poolGet = lbaasApi.getPool(pool.getId());
+ assertNotNull(poolGet);
+ assertNotNull(poolGet.getHealthMonitors());
+ assertTrue(poolGet.getHealthMonitors().isEmpty());
+ assertNotNull(poolGet.getHealthMonitorsStatus());
+ assertTrue(poolGet.getHealthMonitorsStatus().isEmpty());
+
+ healthMonitorGet = lbaasApi.getHealthMonitor(healthMonitor.getId());
+ assertNotNull(healthMonitorGet);
+ assertNotNull(healthMonitorGet.getPools());
+ assertTrue(healthMonitorGet.getPools().isEmpty());
+ } finally {
+ if (healthMonitor != null) {
+ assertTrue(lbaasApi.deleteHealthMonitor(healthMonitor.getId()));
+ }
+ if (pool != null) {
+ assertTrue(lbaasApi.deletePool(pool.getId()));
+ }
+ }
+ }
+ }
+
+}
[32/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Port.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Port.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Port.java
new file mode 100644
index 0000000..a9ab61e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Port.java
@@ -0,0 +1,763 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A Neutron port
+ *
+ * @see <a
+ * href="http://docs.openstack.org/api/openstack-network/1.0/content/Ports.html">api
+ * doc</a>
+ */
+public class Port {
+
+ private String id;
+ private NetworkStatus status;
+
+ // Extensions
+
+ // portbindings.py
+ // The service will return the vif type for the specific port.
+ @Named("binding:vif_type")
+ private VIFType vifType;
+ // The service may return a dictionary containing additional
+ // information needed by the interface driver. The set of items
+ // returned may depend on the value of VIF_TYPE.
+ @Named("binding:vif_details")
+ private ImmutableMap<String, Object> vifDetails;
+
+ // Plugins
+
+ // qos.py
+ @Named("queue_id")
+ private String qosQueueId;
+
+ private String name;
+ @Named("network_id")
+ private String networkId;
+ @Named("admin_state_up")
+ private Boolean adminStateUp;
+ @Named("mac_address")
+ private String macAddress;
+ @Named("fixed_ips")
+ private ImmutableSet<IP> fixedIps;
+ @Named("device_id")
+ private String deviceId;
+ @Named("device_owner")
+ private String deviceOwner;
+ @Named("tenant_id")
+ private String tenantId;
+ @Named("security_groups")
+ private ImmutableSet<String> securityGroups;
+
+ // Extensions
+
+ // allowedaddresspairs.py
+ @Named("allowed_address_pairs")
+ private ImmutableSet<AddressPair> allowedAddressPairs;
+
+ // extra_dhcp_opt.py
+ @Named("extra_dhcp_opts")
+ private ImmutableSet<ExtraDhcpOption> extraDhcpOptions;
+
+ // portbindings.py
+ // The type of vnic that this port should be attached to
+ @Named("binding:vnic_type")
+ private VNICType vnicType;
+ // In some cases different implementations may be run on different hosts.
+ // The host on which the port will be allocated.
+ @Named("binding:host_id")
+ private String hostId;
+ // The profile will be a dictionary that enables the application running
+ // on the specific host to pass and receive vif port specific information to
+ // the plugin.
+ @Named("binding:profile")
+ private ImmutableMap<String, Object> profile;
+
+ // portsecurity.py
+ @Named("port_security_enabled")
+ private Boolean portSecurity;
+
+ // Plugins
+
+ // n1kv.py
+ @Named("n1kv:profile_id")
+ private String profileId;
+
+ // maclearning.py
+ @Named("mac_learning_enabled")
+ private Boolean macLearning;
+
+ // qos.py
+ @Named("rxtx_factor")
+ private Integer qosRxtxFactor;
+
+ @ConstructorProperties({"id", "status", "binding:vif_type", "binding:vif_details", "queue_id", "name", "network_id",
+ "admin_state_up", "mac_address", "fixed_ips", "device_id", "device_owner", "tenant_id", "security_groups",
+ "allowed_address_pairs", "extra_dhcp_opts", "binding:vnic_type", "binding:host_id", "binding:profile",
+ "port_security_enabled", "n1kv:profile_id", "mac_learning_enabled", "rxtx_factor"})
+ protected Port(String id, NetworkStatus status, VIFType vifType, ImmutableMap<String, Object> vifDetails, String qosQueueId,
+ String name, String networkId, Boolean adminStateUp, String macAddress, ImmutableSet<IP> fixedIps, String deviceId,
+ String deviceOwner, String tenantId, ImmutableSet<String> securityGroups, ImmutableSet<AddressPair> allowedAddressPairs,
+ ImmutableSet<ExtraDhcpOption> extraDhcpOptions, VNICType vnicType, String hostId, ImmutableMap<String, Object> profile,
+ Boolean portSecurity, String profileId, Boolean macLearning, Integer qosRxtxFactor) {
+ this.id = id;
+ this.status = status;
+ this.vifType = vifType;
+ this.vifDetails = vifDetails;
+ this.qosQueueId = qosQueueId;
+ this.name = name;
+ this.networkId = networkId;
+ this.adminStateUp = adminStateUp;
+ this.macAddress = macAddress;
+ this.fixedIps = fixedIps;
+ this.deviceId = deviceId;
+ this.deviceOwner = deviceOwner;
+ this.tenantId = tenantId;
+ this.securityGroups = securityGroups;
+ this.allowedAddressPairs = allowedAddressPairs;
+ this.extraDhcpOptions = extraDhcpOptions;
+ this.vnicType = vnicType;
+ this.hostId = hostId;
+ this.profile = profile;
+ this.portSecurity = portSecurity;
+ this.profileId = profileId;
+ this.macLearning = macLearning;
+ this.qosRxtxFactor = qosRxtxFactor;
+ }
+
+ /**
+ * Default constructor.
+ */
+ private Port() {}
+
+ /**
+ * Copy constructor
+ * @param port
+ */
+ private Port(Port port) {
+ this(port.id,
+ port.status,
+ port.vifType,
+ port.vifDetails,
+ port.qosQueueId,
+ port.name,
+ port.networkId,
+ port.adminStateUp,
+ port.macAddress,
+ port.fixedIps,
+ port.deviceId,
+ port.deviceOwner,
+ port.tenantId,
+ port.securityGroups,
+ port.allowedAddressPairs,
+ port.extraDhcpOptions,
+ port.vnicType,
+ port.hostId,
+ port.profile,
+ port.portSecurity,
+ port.profileId,
+ port.macLearning,
+ port.qosRxtxFactor);
+ }
+
+ /**
+ * @return the id of the Port
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the status of the Port
+ */
+ @Nullable
+ public NetworkStatus getStatus() {
+ return status;
+ }
+
+ /**
+ *
+ * @return the vifType of the Port. Visible to only administrative users.
+ *
+ */
+ @Nullable
+ public VIFType getVifType() {
+ return vifType;
+ }
+
+ /**
+ * @return the vifDetails of the Port. A dictionary that enables the application to pass information about functions
+ * that Networking API v2.0 provides. Specify the following value: port_filter : Boolean to define whether
+ * Networking API v2.0 provides port filtering features such as security group and anti-MAC/IP spoofing. Visible to
+ * only administrative users.
+ */
+ @Nullable
+ public ImmutableMap<String, Object> getVifDetails() {
+ return vifDetails;
+ }
+
+ /**
+ * @return the qosQueueId of the Port
+ */
+ @Nullable
+ public String getQosQueueId() {
+ return qosQueueId;
+ }
+
+ /**
+ * @return the name of the Port
+ */
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the id of the network where this port is associated with.
+ */
+ @Nullable
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ /**
+ * @return the administrative state of port. If false, port does not forward packets.
+ */
+ @Nullable
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the macAddress of the Port
+ */
+ @Nullable
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ /**
+ * @return the set of fixed ips this port has been assigned.
+ */
+ @Nullable
+ public ImmutableSet<IP> getFixedIps() {
+ return fixedIps;
+ }
+
+ /**
+ * @return the id of the device (e.g. server) using this port.
+ */
+ @Nullable
+ public String getDeviceId() {
+ return deviceId;
+ }
+
+ /**
+ * @return the entity (e.g.: dhcp agent) using this port.
+ */
+ @Nullable
+ public String getDeviceOwner() {
+ return deviceOwner;
+ }
+
+ /**
+ * @return the tenantId of the Port
+ */
+ @Nullable
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return the set of security groups
+ */
+ @Nullable
+ public ImmutableSet<String> getSecurityGroups() {
+ return securityGroups;
+ }
+
+ /**
+ * @return the allowedAddressPairs of the Port
+ */
+ @Nullable
+ public ImmutableSet<AddressPair> getAllowedAddressPairs() {
+ return allowedAddressPairs;
+ }
+
+ /**
+ * @return the extraDhcpOptions of the Port
+ */
+ @Nullable
+ public ImmutableSet<ExtraDhcpOption> getExtraDhcpOptions() {
+ return extraDhcpOptions;
+ }
+
+ /**
+ * @return the vnicType of the Port. This extended attribute is visible to only port owners and administrative users.
+ * Specifies a value of normal (virtual nic), direct (pci passthrough), or macvtap (virtual interface with a
+ * tap-like software interface). These values support SR-IOV PCI passthrough networking. The ML2 plug-in supports
+ * the vnic_type.
+ */
+ @Nullable
+ public VNICType getVnicType() {
+ return vnicType;
+ }
+
+ /**
+ * @return the hostId of the Port. The ID of the host where the port is allocated. In some cases, different
+ * implementations can run on different hosts. Visible to only administrative users.
+ */
+ @Nullable
+ public String getHostId() {
+ return hostId;
+ }
+
+ /**
+ * @return the profile of the Port. A dictionary that enables the application to pass information about functions
+ * that the Networking API provides. To enable or disable port filtering features such as security group and
+ * anti-MAC/IP spoofing, specify port_filter: True or port_filter: False. Visible to only administrative users.
+ */
+ @Nullable
+ public ImmutableMap<String, Object> getProfile() {
+ return profile;
+ }
+
+ /**
+ * @return the portSecurity of the Port
+ */
+ @Nullable
+ public Boolean getPortSecurity() {
+ return portSecurity;
+ }
+
+ /**
+ * @return the profileId of the Port
+ */
+ @Nullable
+ public String getProfileId() {
+ return profileId;
+ }
+
+ /**
+ * @return the macLearning of the Port
+ */
+ @Nullable
+ public Boolean getMacLearning() {
+ return macLearning;
+ }
+
+ /**
+ * @return the qosRxtxFactor of the Port
+ */
+ @Nullable
+ public Integer getQosRxtxFactor() {
+ return qosRxtxFactor;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Port that = (Port) o;
+
+ return Objects.equal(this.id, that.id) &&
+ Objects.equal(this.status, that.status) &&
+ Objects.equal(this.vifType, that.vifType) &&
+ Objects.equal(this.vifDetails, that.vifDetails) &&
+ Objects.equal(this.qosQueueId, that.qosQueueId) &&
+ Objects.equal(this.name, that.name) &&
+ Objects.equal(this.networkId, that.networkId) &&
+ Objects.equal(this.adminStateUp, that.adminStateUp) &&
+ Objects.equal(this.macAddress, that.macAddress) &&
+ Objects.equal(this.fixedIps, that.fixedIps) &&
+ Objects.equal(this.deviceId, that.deviceId) &&
+ Objects.equal(this.deviceOwner, that.deviceOwner) &&
+ Objects.equal(this.tenantId, that.tenantId) &&
+ Objects.equal(this.securityGroups, that.securityGroups) &&
+ Objects.equal(this.allowedAddressPairs, that.allowedAddressPairs) &&
+ Objects.equal(this.extraDhcpOptions, that.extraDhcpOptions) &&
+ Objects.equal(this.vnicType, that.vnicType) &&
+ Objects.equal(this.hostId, that.hostId) &&
+ Objects.equal(this.profile, that.profile) &&
+ Objects.equal(this.portSecurity, that.portSecurity) &&
+ Objects.equal(this.profileId, that.profileId) &&
+ Objects.equal(this.macLearning, that.macLearning) &&
+ Objects.equal(this.qosRxtxFactor, that.qosRxtxFactor);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, status, vifType, vifDetails, qosQueueId, name,
+ networkId, adminStateUp, macAddress, fixedIps, deviceId,
+ deviceOwner, tenantId, securityGroups, allowedAddressPairs, extraDhcpOptions,
+ vnicType, hostId, profile, portSecurity, profileId,
+ macLearning, qosRxtxFactor);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this)
+ .add("id", id)
+ .add("status", status)
+ .add("vifType", vifType)
+ .add("vifDetails", vifDetails)
+ .add("qosQueueId", qosQueueId)
+ .add("name", name)
+ .add("networkId", networkId)
+ .add("adminStateUp", adminStateUp)
+ .add("macAddress", macAddress)
+ .add("fixedIps", fixedIps)
+ .add("deviceId", deviceId)
+ .add("deviceOwner", deviceOwner)
+ .add("tenantId", tenantId)
+ .add("securityGroups", securityGroups)
+ .add("allowedAddressPairs", allowedAddressPairs)
+ .add("extraDhcpOptions", extraDhcpOptions)
+ .add("vnicType", vnicType)
+ .add("hostId", hostId)
+ .add("profile", profile)
+ .add("portSecurity", portSecurity)
+ .add("profileId", profileId)
+ .add("macLearning", macLearning)
+ .add("qosRxtxFactor", qosRxtxFactor)
+ .toString();
+ }
+
+ /*
+ * Methods to get the Create and Update builders follow
+ */
+
+ /**
+ * @return the Builder for creating a new Router
+ */
+ public static CreateBuilder createBuilder(String networkId) {
+ return new CreateBuilder(networkId);
+ }
+
+ /**
+ * @return the Builder for updating a Router
+ */
+ public static UpdateBuilder updateBuilder() {
+ return new UpdateBuilder();
+ }
+
+ private abstract static class Builder<ParameterizedBuilderType> {
+ protected Port port;
+
+ /**
+ * No-parameters constructor used when updating.
+ */
+ private Builder() {
+ port = new Port();
+ }
+
+ protected abstract ParameterizedBuilderType self();
+
+ /**
+ * Provide the name to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getName()
+ */
+ public ParameterizedBuilderType name(String name) {
+ port.name = name;
+ return self();
+ }
+
+ /**
+ * Provide the networkId to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getNetworkId()
+ */
+ public ParameterizedBuilderType networkId(String networkId) {
+ port.networkId = networkId;
+ return self();
+ }
+
+ /**
+ * Provide the adminStateUp to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getAdminStateUp()
+ */
+ public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) {
+ port.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ /**
+ * Provide the macAddress to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getMacAddress()
+ */
+ public ParameterizedBuilderType macAddress(String macAddress) {
+ port.macAddress = macAddress;
+ return self();
+ }
+
+ /**
+ * Provide the fixedIps to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getFixedIps()
+ */
+ public ParameterizedBuilderType fixedIps(ImmutableSet<IP> fixedIps) {
+ port.fixedIps = fixedIps;
+ return self();
+ }
+
+ /**
+ * Provide the deviceId to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getDeviceId()
+ */
+ public ParameterizedBuilderType deviceId(String deviceId) {
+ port.deviceId = deviceId;
+ return self();
+ }
+
+ /**
+ * Provide the deviceOwner to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getDeviceOwner()
+ */
+ public ParameterizedBuilderType deviceOwner(String deviceOwner) {
+ port.deviceOwner = deviceOwner;
+ return self();
+ }
+
+ /**
+ * Provide the tenantId to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getTenantId()
+ */
+ public ParameterizedBuilderType tenantId(String tenantId) {
+ port.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * Provide the tenantId to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getSecurityGroups()
+ */
+ public ParameterizedBuilderType securityGroups(ImmutableSet<String> securityGroups) {
+ port.securityGroups = securityGroups;
+ return self();
+ }
+
+ /**
+ * Provide the allowedAddressPairs to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getAllowedAddressPairs()
+ */
+ public ParameterizedBuilderType allowedAddressPairs(ImmutableSet<AddressPair> allowedAddressPairs) {
+ port.allowedAddressPairs = allowedAddressPairs;
+ return self();
+ }
+
+ /**
+ * Provide the extraDhcpOptions to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getExtraDhcpOptions()
+ */
+ public ParameterizedBuilderType extraDhcpOptions(ImmutableSet<ExtraDhcpOption> extraDhcpOptions) {
+ port.extraDhcpOptions = extraDhcpOptions;
+ return self();
+ }
+
+ /**
+ * Provide the vnicType to the Port's Builder.
+ * Specify a value of normal (virtual nic), direct (pci passthrough), or macvtap (virtual interface with a
+ * tap-like software interface). These values support SR-IOV PCI passthrough networking. The ML2 plug-in supports
+ * the vnic_type.
+ *
+ * @return the Builder.
+ * @see Port#getVnicType()
+ */
+ public ParameterizedBuilderType vnicType(VNICType vnicType) {
+ port.vnicType = vnicType;
+ return self();
+ }
+
+ /**
+ * Provide the hostId to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getHostId()
+ */
+ public ParameterizedBuilderType hostId(String hostId) {
+ port.hostId = hostId;
+ return self();
+ }
+
+ /**
+ * Provide the profile to the Port's Builder.
+ * This attribute is a dictionary that can be used (with admin credentials) to supply information influencing the
+ * binding of the port. This functionality is needed for SR-IOV PCI passthrough.
+ *
+ * @return the Builder.
+ * @see Port#getProfile()
+ */
+ public ParameterizedBuilderType profile(ImmutableMap<String, Object> profile) {
+ port.profile = profile;
+ return self();
+ }
+
+ /**
+ * Provide the portSecurity to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getPortSecurity()
+ */
+ public ParameterizedBuilderType portSecurity(Boolean portSecurity) {
+ port.portSecurity = portSecurity;
+ return self();
+ }
+
+ /**
+ * Provide the profileId to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getProfileId()
+ */
+ public ParameterizedBuilderType profileId(String profileId) {
+ port.profileId = profileId;
+ return self();
+ }
+
+ /**
+ * Provide the macLearning to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getMacLearning()
+ */
+ public ParameterizedBuilderType macLearning(Boolean macLearning) {
+ port.macLearning = macLearning;
+ return self();
+ }
+
+ /**
+ * Provide the qosRxtxFactor to the Port's Builder.
+ *
+ * @return the Builder.
+ * @see Port#getQosRxtxFactor()
+ */
+ public ParameterizedBuilderType qosRxtxFactor(int qosRxtxFactor) {
+ port.qosRxtxFactor = qosRxtxFactor;
+ return self();
+ }
+ }
+
+ /**
+ * Create and Update builders (inheriting from Builder)
+ */
+ public static class CreateBuilder extends Builder<CreateBuilder> {
+ /**
+ *
+ * Supply required properties for creating a Builder
+ */
+ private CreateBuilder(String networkId) {
+ port.networkId = networkId;
+ }
+
+ /**
+ * @return a CreatePort constructed with this Builder.
+ */
+ public CreatePort build() {
+ return new CreatePort(port);
+ }
+
+ protected CreateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Create and Update builders (inheriting from Builder)
+ */
+ public static class UpdateBuilder extends Builder<UpdateBuilder> {
+ /**
+ * Supply required properties for updating a Builder
+ */
+ private UpdateBuilder() {
+ }
+
+ /**
+ * @return a UpdatePort constructed with this Builder.
+ */
+ public UpdatePort build() {
+ return new UpdatePort(port);
+ }
+
+ protected UpdateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Create and Update options - extend the domain class, passed to API update and create calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class CreatePort extends Port {
+ /**
+ * Copy constructor
+ */
+ private CreatePort(Port port) {
+ super(port);
+ checkNotNull(port.networkId, "networkId should not be null");
+ }
+ }
+
+ /**
+ * Create and Update options - extend the domain class, passed to API update and create calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class UpdatePort extends Port {
+ /**
+ * Copy constructor
+ */
+ private UpdatePort(Port port) {
+ super(port);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Ports.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Ports.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Ports.java
new file mode 100644
index 0000000..8cf449b
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Ports.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A collection of Ports
+ */
+public class Ports extends PaginatedCollection<Port> {
+ public static final Ports EMPTY = new Ports(ImmutableSet.<Port> of(), ImmutableSet.<Link> of());
+
+ @ConstructorProperties({"ports", "ports_links"})
+ protected Ports(Iterable<Port> ports, Iterable<Link> portsLinks) {
+ super(ports, portsLinks);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Router.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Router.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Router.java
new file mode 100644
index 0000000..0b06531
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Router.java
@@ -0,0 +1,285 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * A Neutron Router
+ *
+ * @see <a
+ * href="http://docs.openstack.org/api/openstack-network/2.0/content/router_ext_concepts.html">api
+ * doc</a>
+ */
+public class Router {
+
+ private String id;
+ private NetworkStatus status;
+
+ private String name;
+ @Named("tenant_id")
+ private String tenantId;
+ @Named("admin_state_up")
+ private Boolean adminStateUp;
+ @Named("external_gateway_info")
+ private ExternalGatewayInfo externalGatewayInfo;
+
+ /**
+ * @param id
+ * @param status
+ * @param name
+ * @param tenantId
+ * @param adminStateUp
+ * @param externalGatewayInfo
+ */
+ @ConstructorProperties({"id", "status", "name", "tenant_id", "admin_state_up", "external_gateway_info"})
+ private Router(String id, NetworkStatus status, String name, String tenantId, Boolean adminStateUp, ExternalGatewayInfo externalGatewayInfo) {
+ this.id = id;
+ this.status = status;
+ this.name = name;
+ this.tenantId = tenantId;
+ this.adminStateUp = adminStateUp;
+ this.externalGatewayInfo = externalGatewayInfo;
+ }
+
+ /**
+ * Default constructor.
+ */
+ private Router() {}
+
+ /**
+ * Copy constructor
+ * @param router
+ */
+ private Router(Router router) {
+ this(router.id, router.status, router.name, router.tenantId, router.adminStateUp, router.externalGatewayInfo);
+ }
+
+ /**
+ * @return the id of the Router
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the status of the Router
+ */
+ @Nullable
+ public NetworkStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @return the name of the Router
+ */
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the tenantId of the Router
+ */
+ @Nullable
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return the adminStateUp of the Router
+ */
+ @Nullable
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the externalGatewayInfo of the Router
+ */
+ @Nullable
+ public ExternalGatewayInfo getExternalGatewayInfo() {
+ return externalGatewayInfo;
+ }
+
+ /**
+ * @return the Builder for creating a new Router
+ */
+ public static CreateBuilder createBuilder() {
+ return new CreateBuilder();
+ }
+
+ /**
+ * @return the Builder for updating a Router
+ */
+ public static UpdateBuilder updateBuilder() {
+ return new UpdateBuilder();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Router that = (Router) o;
+
+ return Objects.equal(this.id, that.id) &&
+ Objects.equal(this.status, that.status) &&
+ Objects.equal(this.name, that.name) &&
+ Objects.equal(this.tenantId, that.tenantId) &&
+ Objects.equal(this.adminStateUp, that.adminStateUp) &&
+ Objects.equal(this.externalGatewayInfo, that.externalGatewayInfo);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, status, name, tenantId, adminStateUp, externalGatewayInfo);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this)
+ .add("id", id)
+ .add("status", status)
+ .add("name", name)
+ .add("tenantId", tenantId)
+ .add("adminStateUp", adminStateUp)
+ .add("externalGatewayInfo", externalGatewayInfo)
+ .toString();
+ }
+
+ private abstract static class Builder<ParameterizedBuilderType> {
+ protected Router router;
+
+ /**
+ * No-parameters constructor used when updating.
+ * */
+ private Builder() {
+ router = new Router();
+ }
+
+ protected abstract ParameterizedBuilderType self();
+
+ /**
+ * Provide the name to the Router's Builder.
+ *
+ * @return the Builder.
+ * @see Router#getName()
+ */
+ public ParameterizedBuilderType name(String name) {
+ router.name = name;
+ return self();
+ }
+
+ /**
+ * Provide the tenantId to the Router's Builder.
+ *
+ * @return the Builder.
+ * @see Router#getTenantId()
+ */
+ public ParameterizedBuilderType tenantId(String tenantId) {
+ router.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * Provide the adminStateUp to the Router's Builder.
+ *
+ * @return the Builder.
+ * @see Router#getAdminStateUp()
+ */
+ public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) {
+ router.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ /**
+ * Provide the externalGatewayInfo to the Router's Builder.
+ *
+ * @return the Builder.
+ * @see Router#getExternalGatewayInfo()
+ */
+ public ParameterizedBuilderType externalGatewayInfo(ExternalGatewayInfo externalGatewayInfo) {
+ router.externalGatewayInfo = externalGatewayInfo;
+ return self();
+ }
+ }
+
+ public static class CreateBuilder extends Builder<CreateBuilder> {
+ /**
+ * Supply required properties for creating a Builder
+ */
+ private CreateBuilder() {
+ }
+
+ /**
+ * @return a CreateRouter constructed with this Builder.
+ */
+ public CreateRouter build() {
+ return new CreateRouter(router);
+ }
+
+ protected CreateBuilder self() {
+ return this;
+ }
+ }
+
+ public static class UpdateBuilder extends Builder<UpdateBuilder> {
+ /**
+ * Supply required properties for updating a Builder
+ */
+ private UpdateBuilder() {
+ }
+
+ /**
+ * @return a UpdateRouter constructed with this Builder.
+ */
+ public UpdateRouter build() {
+ return new UpdateRouter(router);
+ }
+
+ protected UpdateBuilder self() {
+ return this;
+ }
+ }
+
+ public static class CreateRouter extends Router{
+ /**
+ * Copy constructor
+ */
+ private CreateRouter(Router router) {
+ super(router);
+ }
+ }
+ public static class UpdateRouter extends Router{
+ /**
+ * Copy constructor
+ */
+ private UpdateRouter(Router router) {
+ super(router);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RouterInterface.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RouterInterface.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RouterInterface.java
new file mode 100644
index 0000000..3a86612
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RouterInterface.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import com.google.common.base.Objects;
+import org.jclouds.javax.annotation.Nullable;
+
+import javax.inject.Named;
+import java.beans.ConstructorProperties;
+
+/**
+ * A Neutron Router Interface
+ *
+ * @see <a
+ * href="http://docs.openstack.org/api/openstack-network/2.0/content/router_add_interface.html">api
+ * doc</a>
+ */
+public class RouterInterface {
+
+ @Named("subnet_id")
+ protected final String subnetId;
+ @Named("port_id")
+ protected final String portId;
+
+ @ConstructorProperties({"subnet_id", "port_id"})
+ protected RouterInterface(String subnetId, String portId) {
+ this.subnetId = subnetId;
+ this.portId = portId;
+ }
+
+ /**
+ * @return the subnetId of the RouterInterface
+ */
+ @Nullable
+ public String getSubnetId() {
+ return subnetId;
+ }
+
+ /**
+ * @return the portId of the RouterInterface
+ */
+ @Nullable
+ public String getPortId() {
+ return portId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(subnetId, portId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ RouterInterface that = RouterInterface.class.cast(obj);
+ return Objects.equal(this.subnetId, that.subnetId) && Objects.equal(this.portId, that.portId);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this).add("subnetId", subnetId).add("portId", portId);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ /**
+ * @return the Builder for RouterInterface
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Gets a Builder configured as this object.
+ */
+ public Builder toBuilder() {
+ return new Builder().fromRouterInterface(this);
+ }
+
+ public static class Builder {
+ protected String subnetId;
+ protected String portId;
+
+ /**
+ * Provide the subnetId to the RouterInterface's Builder.
+ *
+ * @return the Builder.
+ * @see RouterInterface#getSubnetId()
+ */
+ public Builder subnetId(String subnetId) {
+ this.subnetId = subnetId;
+ return this;
+ }
+
+ /**
+ * Provide the portId to the RouterInterface's Builder.
+ *
+ * @return the Builder.
+ * @see RouterInterface#getPortId()
+ */
+ public Builder portId(String portId) {
+ this.portId = portId;
+ return this;
+ }
+
+ /**
+ * @return a RouterInterface constructed with this Builder.
+ */
+ public RouterInterface build() {
+ return new RouterInterface(subnetId, portId);
+ }
+
+ /**
+ * @return a Builder from another RouterInterface.
+ */
+ public Builder fromRouterInterface(RouterInterface in) {
+ return this.subnetId(in.getSubnetId()).portId(in.getPortId());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Routers.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Routers.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Routers.java
new file mode 100644
index 0000000..c02c382
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Routers.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A collection of Routers
+ */
+public class Routers extends PaginatedCollection<Router> {
+ public static final Routers EMPTY = new Routers(ImmutableSet.<Router> of(), ImmutableSet.<Link> of());
+
+ @ConstructorProperties({"routers", "routers_links"})
+ protected Routers(Iterable<Router> routers, Iterable<Link> routersLinks) {
+ super(routers, routersLinks);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rule.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rule.java
new file mode 100644
index 0000000..89e9d19
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rule.java
@@ -0,0 +1,376 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * Contains a mapping between a MAC address and an IP address.
+ */
+public class Rule {
+
+ private String id;
+ @Named("tenant_id")
+ private String tenantId;
+ private RuleDirection direction;
+ @Named("security_group_id")
+ private String securityGroupId;
+ private RuleEthertype ethertype;
+ @Named("port_range_min")
+ private Integer portRangeMin;
+ @Named("port_range_max")
+ private Integer portRangeMax;
+ private RuleProtocol protocol;
+ @Named("remote_group_id")
+ private String remoteGroupId;
+ @Named("remote_ip_prefix")
+ private String remoteIpPrefix;
+
+ @ConstructorProperties({"id", "tenant_id", "direction", "security_group_id", "ethertype", "port_range_min",
+ "port_range_max", "protocol", "remote_group_id", "remote_ip_prefix"})
+ protected Rule(String id, String tenantId, RuleDirection direction, String securityGroupId,
+ RuleEthertype ethertype, Integer portRangeMin, Integer portRangeMax,
+ RuleProtocol protocol, String remoteGroupId, String remoteIpPrefix) {
+ this.id = id;
+ this.tenantId = tenantId;
+ this.direction = direction;
+ this.securityGroupId = securityGroupId;
+ this.ethertype = ethertype;
+ this.portRangeMin = portRangeMin;
+ this.portRangeMax = portRangeMax;
+ this.protocol = protocol;
+ this.remoteGroupId = remoteGroupId;
+ this.remoteIpPrefix = remoteIpPrefix;
+ }
+
+ private Rule(Rule rule) {
+ this(rule.id,
+ rule.tenantId,
+ rule.direction,
+ rule.securityGroupId,
+ rule.ethertype,
+ rule.portRangeMin,
+ rule.portRangeMax,
+ rule.protocol,
+ rule.remoteGroupId,
+ rule.remoteIpPrefix
+ );
+ }
+
+ private Rule() {}
+
+ /**
+ * @return The identifier for this rule.
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return The identifier of the tenant for this rule.
+ */
+ @Nullable
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return The direction in which the security group rule is applied.
+ */
+ @Nullable
+ public RuleDirection getDirection() {
+ return direction;
+ }
+
+ /**
+ * @return The security group ID to associate with this security group rule.
+ */
+ @Nullable
+ public String getSecurityGroupId() {
+ return securityGroupId;
+ }
+
+ /**
+ * @return The internet protocol version type of this rule.
+ */
+ @Nullable
+ public RuleEthertype getEthertype() {
+ return ethertype;
+ }
+
+ /**
+ * @return The minimum port number in the range that is matched by the security group rule. If the protocol is TCP
+ * or UDP, this value must be less than or equal to the value of the port_range_max attribute. If the protocol is
+ * ICMP, this value must be an ICMP type.
+ */
+ @Nullable
+ public Integer getPortRangeMin() {
+ return portRangeMin;
+ }
+
+ /**
+ * @return The maximum port number in the range that is matched by the security group rule. The port_range_min
+ * attribute constrains the port_range_max attribute. If the protocol is ICMP, this value must be an ICMP type.
+ */
+ @Nullable
+ public Integer getPortRangeMax() {
+ return portRangeMax;
+ }
+
+ /**
+ * @return The protocol that is matched by the security group rule. Valid values are null, tcp, udp, and icmp.
+ */
+ @Nullable
+ public RuleProtocol getProtocol() {
+ return protocol;
+ }
+
+ /**
+ * @return The remote group ID to be associated with this security group rule.
+ */
+ @Nullable
+ public String getRemoteGroupId() {
+ return remoteGroupId;
+ }
+
+ /**
+ * @return The remote IP prefix to be associated with this security group rule. This attribute matches the specified
+ * IP prefix as the source IP address of the IP packet.
+ */
+ @Nullable
+ public String getRemoteIpPrefix() {
+ return remoteIpPrefix;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Rule that = (Rule) o;
+
+ return Objects.equal(this.id, that.id) &&
+ Objects.equal(this.tenantId, that.tenantId) &&
+ Objects.equal(this.direction, that.direction) &&
+ Objects.equal(this.securityGroupId, that.securityGroupId) &&
+ Objects.equal(this.ethertype, that.ethertype) &&
+ Objects.equal(this.portRangeMin, that.portRangeMin) &&
+ Objects.equal(this.portRangeMax, that.portRangeMax) &&
+ Objects.equal(this.protocol, that.protocol) &&
+ Objects.equal(this.remoteGroupId, that.remoteGroupId) &&
+ Objects.equal(this.remoteIpPrefix, that.remoteIpPrefix);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, tenantId, direction, securityGroupId, ethertype, portRangeMin,
+ portRangeMax, protocol, remoteGroupId, remoteIpPrefix);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this)
+ .add("id", id)
+ .add("tenantId", tenantId)
+ .add("direction", direction)
+ .add("securityGroupId", securityGroupId)
+ .add("ethertype", ethertype)
+ .add("portRangeMin", portRangeMin)
+ .add("portRangeMax", portRangeMax)
+ .add("protocol", protocol)
+ .add("remoteGroupId", remoteGroupId)
+ .add("remoteIpPrefix", remoteIpPrefix)
+ .toString();
+ }
+
+
+ /*
+ * Methods to get the Create and Update builders follow
+ */
+
+ /**
+ * @return the Builder for creating a new SecurityGroupRule
+ */
+ public static CreateBuilder createBuilder(RuleDirection direction, String securityGroupId) {
+ return new CreateBuilder(direction, securityGroupId);
+ }
+
+ public abstract static class Builder<ParameterizedBuilderType> {
+ // Keep track of the builder's state.
+ protected Rule rule;
+
+ private Builder() {
+ rule = new Rule();
+ }
+
+ protected abstract ParameterizedBuilderType self();
+
+ /**
+ * The tenant id for this rule. Usually can only be specified by administrators.
+ *
+ * @return the Builder.
+ * @see Rule#getTenantId()
+ */
+ public ParameterizedBuilderType tenantId(String tenantId) {
+ rule.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * The direction in which the security group rule is applied.
+ *
+ * @return the Builder.
+ * @see Rule#getDirection()
+ */
+ public ParameterizedBuilderType direction(RuleDirection direction) {
+ rule.direction = direction;
+ return self();
+ }
+
+ /**
+ * The security group ID to associate with this security group rule.
+ *
+ * @return the Builder.
+ * @see Rule#getSecurityGroupId()
+ */
+ public ParameterizedBuilderType securityGroupId(String securityGroupId) {
+ rule.securityGroupId = securityGroupId;
+ return self();
+ }
+
+ /**
+ * The internet protocol version for this rule.
+ *
+ * @return the Builder.
+ * @see Rule#getEthertype()
+ */
+ public ParameterizedBuilderType ethertype(RuleEthertype ethertype) {
+ rule.ethertype = ethertype;
+ return self();
+ }
+
+ /**
+ * The minimum port number in the range that is matched by the security group rule.
+ *
+ * @return the Builder.
+ * @see Rule#getPortRangeMin()
+ */
+ public ParameterizedBuilderType portRangeMin(Integer portRangeMin) {
+ rule.portRangeMin = portRangeMin;
+ return self();
+ }
+
+ /**
+ * The maximum port number in the range that is matched by the security group rule.
+ *
+ * @return the Builder.
+ * @see Rule#getPortRangeMax()
+ */
+ public ParameterizedBuilderType portRangeMax(Integer portRangeMax) {
+ rule.portRangeMax = portRangeMax;
+ return self();
+ }
+
+ /**
+ * The protocol that is matched by the security group rule. Valid values are null, tcp, udp, and icmp.
+ *
+ * @return the Builder.
+ * @see Rule#getProtocol()
+ */
+ public ParameterizedBuilderType protocol(RuleProtocol protocol) {
+ rule.protocol = protocol;
+ return self();
+ }
+
+ /**
+ * The remote group ID to be associated with this security group rule. You can specify either remote_group_id or
+ * remote_ip_prefix in the request body.
+ *
+ * @return the Builder.
+ * @see Rule#getRemoteGroupId()
+ */
+ public ParameterizedBuilderType remoteGroupId(String remoteGroupId) {
+ rule.remoteGroupId = remoteGroupId;
+ return self();
+ }
+
+ /**
+ * The remote IP prefix to be associated with this security group rule. You can specify either remote_group_id
+ * or remote_ip_prefix in the request body. This attribute matches the specified IP prefix as the source IP
+ * address of the IP packet.
+ *
+ * @return the Builder.
+ * @see Rule#getRemoteIpPrefix()
+ */
+ public ParameterizedBuilderType remoteIpPrefix(String remoteIpPrefix) {
+ rule.remoteIpPrefix = remoteIpPrefix;
+ return self();
+ }
+ }
+
+ /**
+ * This is used to build a CreateBuilder object.
+ */
+ public static class CreateBuilder extends Builder<CreateBuilder> {
+ /**
+ * Supply required properties for creating a Builder
+ */
+ private CreateBuilder(RuleDirection direction, String securityGroupId) {
+ rule.direction = direction;
+ rule.securityGroupId = securityGroupId;
+ }
+
+ /**
+ * @return a CreateRule constructed with this Builder.
+ */
+ public CreateRule build() {
+ return new CreateRule(rule);
+ }
+
+ protected CreateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Create and Update options - extend the domain class, passed to API update and create calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class CreateRule extends Rule {
+ private CreateRule(Rule rule) {
+ super(rule);
+ checkNotNull(this.getDirection(), "direction should not be null");
+ checkNotNull(this.getSecurityGroupId(), "security group id should not be null");
+ checkArgument(this.getPortRangeMax() >= this.getPortRangeMin(),
+ "port range max should be greater than or equal to port range min");
+ checkArgument(this.getRemoteGroupId() == null || this.getRemoteIpPrefix() == null,
+ "You can specify either remote_group_id or remote_ip_prefix in the request body.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleDirection.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleDirection.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleDirection.java
new file mode 100644
index 0000000..52e4273
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleDirection.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.domain;
+
+/**
+ * The direction in which the security group rule is applied.
+ */
+public enum RuleDirection {
+ /**
+ * For a compute instance, an ‘ingress’ security group rule matches traffic that is incoming (ingress) for that instance.
+ */
+ INGRESS("ingress"),
+ /**
+ * An ‘egress’ rule is applied to traffic leaving the instance.
+ */
+ EGRESS("egress"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private String name;
+
+ private RuleDirection(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * */
+ public static RuleDirection fromValue(String name){
+ if (name != null) {
+ for (RuleDirection value : RuleDirection.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleEthertype.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleEthertype.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleEthertype.java
new file mode 100644
index 0000000..dd3aa3f
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleEthertype.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.domain;
+
+/**
+ * The direction in which the security group rule is applied.
+ */
+public enum RuleEthertype {
+ /**
+ * Internet Protocol version 4
+ */
+ IPV4("IPv4"),
+ /**
+ * Internet Protocol version 6
+ */
+ IPV6("IPv6"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private String name;
+
+ private RuleEthertype(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * */
+ public static RuleEthertype fromValue(String name){
+ if (name != null) {
+ for (RuleEthertype value : RuleEthertype.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleProtocol.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleProtocol.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleProtocol.java
new file mode 100644
index 0000000..f6a4574
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleProtocol.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.domain;
+
+/**
+ * The protocol that is matched by the security group rule. Valid values are null, tcp, udp, and icmp.
+ */
+public enum RuleProtocol {
+ /**
+ * Transmission Control Protocol
+ */
+ TCP("tcp"),
+ /**
+ * User Datagram Protocol
+ */
+ UDP("udp"),
+ /**
+ * Internet Control Message Protocol
+ */
+ ICMP("icmp"),
+ /**
+ * Used by jclouds when the service returns an unknown value other than null.
+ */
+ UNRECOGNIZED("unrecognized");
+
+ private String name;
+
+ private RuleProtocol(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ /*
+ * This provides GSON enum support in jclouds.
+ * */
+ public static RuleProtocol fromValue(String name){
+ if (name != null) {
+ for (RuleProtocol value : RuleProtocol.values()) {
+ if (name.equalsIgnoreCase(value.name)) {
+ return value;
+ }
+ }
+ return UNRECOGNIZED;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rules.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rules.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rules.java
new file mode 100644
index 0000000..4794a18
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rules.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A collection of Networks
+ */
+public class Rules extends PaginatedCollection<Rule> {
+ public static final Rules EMPTY = new Rules(ImmutableSet.<Rule> of(), ImmutableSet.<Link> of());
+
+ @ConstructorProperties({"security_group_rules", "security_group_rules_links"})
+ protected Rules(Iterable<Rule> securityGroups, Iterable<Link> securityGroupRulesLinks) {
+ super(securityGroups, securityGroupRulesLinks);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroup.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroup.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroup.java
new file mode 100644
index 0000000..d9b08aa
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroup.java
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Contains a mapping between a MAC address and an IP address.
+ */
+public class SecurityGroup {
+
+ private String id;
+ @Named("tenant_id")
+ private String tenantId;
+ private String name;
+ private String description;
+ @Named("security_group_rules")
+ private ImmutableList<Rule> rules;
+
+ @ConstructorProperties({"id", "tenant_id", "name", "description", "security_group_rules"})
+ protected SecurityGroup(String id, String tenantId, String name, String description,
+ ImmutableList<Rule> rules) {
+ this.id = id;
+ this.tenantId = tenantId;
+ this.name = name;
+ this.description = description;
+ this.rules = rules;
+ }
+
+ private SecurityGroup(SecurityGroup securityGroup) {
+ this(securityGroup.id,
+ securityGroup.tenantId,
+ securityGroup.name,
+ securityGroup.description,
+ securityGroup.rules
+ );
+ }
+
+ private SecurityGroup() {}
+
+ /**
+ * @return The identifier for this Security Group.
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return The identifier of the tenant for this Security Group.
+ */
+ @Nullable
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return The name of the Security Group.
+ */
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return The description of the Security Group.
+ */
+ @Nullable
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @return The collection of rules for this Security Group.
+ */
+ public ImmutableList<Rule> getRules() {
+ return rules != null ? rules : ImmutableList.<Rule>of();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ SecurityGroup that = (SecurityGroup) o;
+
+ return Objects.equal(this.id, that.id) &&
+ Objects.equal(this.tenantId, that.tenantId) &&
+ Objects.equal(this.name, that.name) &&
+ Objects.equal(this.description, that.description) &&
+ Objects.equal(this.rules, that.rules);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, tenantId, name, description, rules);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this)
+ .add("id", id)
+ .add("tenantId", tenantId)
+ .add("name", name)
+ .add("description", description)
+ .add("securityGroupRules", rules)
+ .toString();
+ }
+
+ /*
+ * Methods to get the Create and Update builders follow
+ */
+
+ /**
+ * @return the Builder for creating a new SecurityGroup
+ */
+ public static CreateBuilder createBuilder() {
+ return new CreateBuilder();
+ }
+
+ private abstract static class Builder<ParameterizedBuilderType> {
+ // Keep track of the builder's state.
+ protected SecurityGroup securityGroup;
+
+ private Builder() {
+ securityGroup = new SecurityGroup();
+ }
+
+ protected abstract ParameterizedBuilderType self();
+
+ /**
+ * The tenant id for this Security Group. Usually can only be specified by administrators.
+ *
+ * @return the Builder.
+ * @see SecurityGroup#getTenantId()
+ */
+ public ParameterizedBuilderType tenantId(String tenantId) {
+ securityGroup.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * The name for this Security Group.
+ *
+ * @return the Builder.
+ * @see SecurityGroup#getName()
+ */
+ public ParameterizedBuilderType name(String name) {
+ securityGroup.name = name;
+ return self();
+ }
+
+ /**
+ * The description for this Security Group.
+ *
+ * @return the Builder.
+ * @see SecurityGroup#getDescription()
+ */
+ public ParameterizedBuilderType description(String description) {
+ securityGroup.description = description;
+ return self();
+ }
+ }
+
+ /**
+ * Create and Update builders (inheriting from Builder)
+ */
+ public static class CreateBuilder extends Builder<CreateBuilder> {
+ /**
+ * Supply required properties for creating a Builder
+ */
+ private CreateBuilder() {
+ }
+
+ /**
+ * @return a CreateSecurityGroup constructed with this Builder.
+ */
+ public CreateSecurityGroup build() {
+ return new CreateSecurityGroup(securityGroup);
+ }
+
+ protected CreateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Create and Update options - extend the domain class, passed to API update and create calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class CreateSecurityGroup extends SecurityGroup {
+ private CreateSecurityGroup(SecurityGroup securityGroup) {
+ super(securityGroup);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroups.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroups.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroups.java
new file mode 100644
index 0000000..044ce1c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroups.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A collection of Networks
+ */
+public class SecurityGroups extends PaginatedCollection<SecurityGroup> {
+ public static final SecurityGroups EMPTY = new SecurityGroups(ImmutableSet.<SecurityGroup> of(), ImmutableSet.<Link> of());
+
+ @ConstructorProperties({"security_groups", "security_groups_links"})
+ protected SecurityGroups(Iterable<SecurityGroup> securityGroups, Iterable<Link> securityGroupsLinks) {
+ super(securityGroups, securityGroupsLinks);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnet.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnet.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnet.java
new file mode 100644
index 0000000..6e0cfc0
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnet.java
@@ -0,0 +1,466 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.Collection;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A Neutron subnet
+ *
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api doc</a>
+ */
+public class Subnet {
+
+ private String id;
+
+ private String name;
+ @Named("network_id")
+ private String networkId;
+ @Named("tenant_id")
+ private String tenantId;
+ // Cannot be used for updates.
+ @Named("allocation_pools")
+ private ImmutableSet<AllocationPool> allocationPools;
+ @Named("gateway_ip")
+ private String gatewayIp;
+ @Named("ip_version")
+ private Integer ipVersion;
+ private String cidr;
+ @Named("enable_dhcp")
+ private Boolean enableDhcp;
+ @Named("dns_nameservers")
+ private ImmutableSet<String> dnsNameServers;
+ @Named("host_routes")
+ private ImmutableSet<HostRoute> hostRoutes;
+ @Named("ipv6_address_mode")
+ private IPv6DHCPMode ipv6AddressMode;
+ @Named("ipv6_ra_mode")
+ private IPv6DHCPMode ipv6RaMode;
+
+ @ConstructorProperties({"id", "name", "network_id", "tenant_id", "allocation_pools", "gateway_ip", "ip_version",
+ "cidr", "enable_dhcp", "dns_nameservers", "host_routes", "ipv6_address_mode", "ipv6_ra_mode"})
+ private Subnet(String id, String name, String networkId, String tenantId, ImmutableSet<AllocationPool> allocationPools,
+ String gatewayIp, Integer ipVersion, String cidr, Boolean enableDhcp, ImmutableSet<String> dnsNameServers, ImmutableSet<HostRoute> hostRoutes,
+ IPv6DHCPMode ipv6AddressMode, IPv6DHCPMode ipv6RaMode) {
+ this.id = id;
+ this.name = name;
+ this.networkId = networkId;
+ this.tenantId = tenantId;
+ this.allocationPools = allocationPools;
+ this.gatewayIp = gatewayIp;
+ this.ipVersion = ipVersion;
+ this.cidr = cidr;
+ this.enableDhcp = enableDhcp;
+ this.dnsNameServers = dnsNameServers;
+ this.hostRoutes = hostRoutes;
+ this.ipv6AddressMode = ipv6AddressMode;
+ this.ipv6RaMode = ipv6RaMode;
+ }
+
+ /**
+ * Default constructor.
+ */
+ private Subnet() {}
+
+ /**
+ * Copy constructor
+ * @param subnet
+ */
+ private Subnet(Subnet subnet) {
+ this(subnet.id,
+ subnet.name,
+ subnet.networkId,
+ subnet.tenantId,
+ subnet.allocationPools,
+ subnet.gatewayIp,
+ subnet.ipVersion,
+ subnet.cidr,
+ subnet.enableDhcp,
+ subnet.dnsNameServers,
+ subnet.hostRoutes,
+ subnet.ipv6AddressMode,
+ subnet.ipv6RaMode);
+ }
+
+ /**
+ * @return the id of the subnet
+ */
+ @Nullable
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * @return the name of the subnet
+ */
+ @Nullable
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @return the id of the network this subnet is associated with.
+ */
+ @Nullable
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ /**
+ * @return the id of the tenant where this entity is associated with.
+ */
+ @Nullable
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return the sub-ranges of CIDR available for dynamic allocation to ports.
+ */
+ @Nullable
+ public ImmutableSet<AllocationPool> getAllocationPools() {
+ return allocationPools;
+ }
+
+ /**
+ * @return the default gateway used by devices in this subnet.
+ */
+ @Nullable
+ public String getGatewayIp() {
+ return gatewayIp;
+ }
+
+ /**
+ * @return the IP version used by this subnet.
+ */
+ @Nullable
+ public Integer getIpVersion() {
+ return ipVersion;
+ }
+
+ /**
+ * @return the CIDR representing the IP range for this subnet, based on IP version.
+ */
+ @Nullable
+ public String getCidr() {
+ return cidr;
+ }
+
+ /**
+ * @return true if DHCP is enabled for this subnet, false if not.
+ */
+ @Nullable
+ public Boolean getEnableDhcp() {
+ return enableDhcp;
+ }
+
+ /**
+ * @return Configurable maximum amount of name servers per subnet. The default is 5.
+ */
+ @Nullable
+ public ImmutableSet<String> getDnsNameservers() {
+ return dnsNameServers;
+ }
+
+ /**
+ * @return Configurable maximum amount of routes per subnet. The default is 20.
+ */
+ @Nullable
+ public ImmutableSet<HostRoute> getHostRoutes() {
+ return hostRoutes;
+ }
+
+ /**
+ * @return The IP v6 Address Mode.
+ */
+ @Nullable
+ public IPv6DHCPMode getIPv6AddressMode() {
+ return ipv6AddressMode;
+ }
+
+ /**
+ * @return The IP v6 Router Advertisement mode.
+ */
+ @Nullable
+ public IPv6DHCPMode getIPv6RAMode() {
+ return ipv6RaMode;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, name, networkId, tenantId, allocationPools, gatewayIp,
+ ipVersion, cidr, enableDhcp, dnsNameServers, hostRoutes,
+ ipv6AddressMode, ipv6RaMode);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Subnet that = (Subnet) o;
+
+ return Objects.equal(this.id, that.id) &&
+ Objects.equal(this.name, that.name) &&
+ Objects.equal(this.networkId, that.networkId) &&
+ Objects.equal(this.tenantId, that.tenantId) &&
+ Objects.equal(this.allocationPools, that.allocationPools) &&
+ Objects.equal(this.gatewayIp, that.gatewayIp) &&
+ Objects.equal(this.ipVersion, that.ipVersion) &&
+ Objects.equal(this.cidr, that.cidr) &&
+ Objects.equal(this.enableDhcp, that.enableDhcp) &&
+ Objects.equal(this.dnsNameServers, that.dnsNameServers) &&
+ Objects.equal(this.hostRoutes, that.hostRoutes) &&
+ Objects.equal(this.ipv6AddressMode, that.ipv6AddressMode) &&
+ Objects.equal(this.ipv6RaMode, that.ipv6RaMode);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this)
+ .add("id", id)
+ .add("name", name)
+ .add("networkId", networkId)
+ .add("tenantId", tenantId)
+ .add("allocationPools", allocationPools)
+ .add("gatewayIp", gatewayIp)
+ .add("ipVersion", ipVersion)
+ .add("cidr", cidr)
+ .add("enableDhcp", enableDhcp)
+ .add("dnsNameServers", dnsNameServers)
+ .add("hostRoutes", hostRoutes)
+ .add("ipv6AddressMode", ipv6AddressMode)
+ .add("ipv6RaMode", ipv6RaMode)
+ .toString();
+ }
+
+ /*
+ * Methods to get the Create and Update builders follow
+ */
+
+ /**
+ * @return the Builder for creating a new Router
+ */
+ public static CreateBuilder createBuilder(String networkId, String cidr) {
+ return new CreateBuilder(networkId, cidr);
+ }
+
+ /**
+ * @return the Builder for updating a Router
+ */
+ public static UpdateBuilder updateBuilder() {
+ return new UpdateBuilder();
+ }
+
+ private abstract static class Builder<ParameterizedBuilderType> {
+ protected Subnet subnet;
+
+ /**
+ * No-parameters constructor used when updating.
+ */
+ private Builder() {
+ subnet = new Subnet();
+ }
+
+ protected abstract ParameterizedBuilderType self();
+
+ /**
+ * @see Subnet#getName()
+ */
+ public ParameterizedBuilderType name(String name) {
+ subnet.name = name;
+ return self();
+ }
+
+ /**
+ * @see Subnet#getNetworkId()
+ */
+ public ParameterizedBuilderType networkId(String networkId) {
+ subnet.networkId = networkId;
+ return self();
+ }
+
+ /**
+ * Only administrators can specify a tenant ID that is not their own.
+ * As it is optional, this is usually omitted in requests.
+ * @see Subnet#getTenantId()
+ */
+ public ParameterizedBuilderType tenantId(String tenantId) {
+ subnet.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * @see Subnet#getAllocationPools()
+ */
+ public ParameterizedBuilderType allocationPools(Collection<AllocationPool> allocationPools) {
+ subnet.allocationPools = ImmutableSet.copyOf(allocationPools);
+ return self();
+ }
+
+ /**
+ * @see Subnet#getGatewayIp()
+ */
+ public ParameterizedBuilderType gatewayIp(String gatewayIp) {
+ subnet.gatewayIp = gatewayIp;
+ return self();
+ }
+
+ /**
+ * @see Subnet#getIpVersion()
+ */
+ public ParameterizedBuilderType ipVersion(int ipVersion) {
+ subnet.ipVersion = ipVersion;
+ return self();
+ }
+
+ /**
+ * @see Subnet#getCidr()
+ */
+ public ParameterizedBuilderType cidr(String cidr) {
+ subnet.cidr = cidr;
+ return self();
+ }
+
+ /**
+ * @see Subnet#getEnableDhcp()
+ */
+ public ParameterizedBuilderType enableDhcp(Boolean enableDhcp) {
+ subnet.enableDhcp = enableDhcp;
+ return self();
+ }
+
+ /**
+ * @see Subnet#getDnsNameservers()
+ */
+ public ParameterizedBuilderType dnsNameServers(ImmutableSet<String> dnsNameServers) {
+ subnet.dnsNameServers = dnsNameServers;
+ return self();
+ }
+
+ /**
+ * @see Subnet#getHostRoutes()
+ */
+ public ParameterizedBuilderType hostRoutes(ImmutableSet<HostRoute> hostRoutes) {
+ subnet.hostRoutes = hostRoutes;
+ return self();
+ }
+
+ /**
+ * @see Subnet#getIPv6RAMode()
+ */
+ public ParameterizedBuilderType ipv6RaMode(IPv6DHCPMode ipv6RaMode) {
+ subnet.ipv6RaMode = ipv6RaMode;
+ return self();
+ }
+
+ /**
+ * @see Subnet#getIPv6AddressMode()
+ */
+ public ParameterizedBuilderType ipv6AddressMode(IPv6DHCPMode ipv6AddressMode) {
+ subnet.ipv6AddressMode = ipv6AddressMode;
+ return self();
+ }
+ }
+
+ /**
+ * Create and Update builders (inheriting from Builder)
+ */
+ public static class CreateBuilder extends Builder<CreateBuilder> {
+ /**
+ *
+ * Supply required properties for creating a Builder
+ */
+ private CreateBuilder(String networkId, String cidr) {
+ subnet.networkId = networkId;
+ subnet.cidr = cidr;
+ }
+
+ /**
+ * @return a CreateSubnet constructed with this Builder.
+ */
+ public CreateSubnet build() {
+ return new CreateSubnet(subnet);
+ }
+
+ protected CreateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Create and Update builders (inheriting from Builder)
+ */
+ public static class UpdateBuilder extends Builder<UpdateBuilder> {
+ /**
+ * Supply required properties for updating a Builder
+ */
+ private UpdateBuilder() {
+ }
+
+ /**
+ * @return a UpdateSubnet constructed with this Builder.
+ */
+ public UpdateSubnet build() {
+ return new UpdateSubnet(subnet);
+ }
+
+ protected UpdateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Create and Update options - extend the domain class, passed to API update and create calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class CreateSubnet extends Subnet {
+ /**
+ * Copy constructor
+ */
+ private CreateSubnet(Subnet subnet) {
+ super(subnet);
+ checkNotNull(subnet.networkId, "networkId should not be null");
+ checkNotNull(subnet.cidr, "cidr should not be null");
+ }
+ }
+
+ /**
+ * Create and Update options - extend the domain class, passed to API update and create calls.
+ * Essentially the same as the domain class. Ensure validation and safe typing.
+ */
+ public static class UpdateSubnet extends Subnet {
+ /**
+ * Copy constructor
+ */
+ private UpdateSubnet(Subnet subnet) {
+ super(subnet);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnets.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnets.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnets.java
new file mode 100644
index 0000000..fb9896e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnets.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.domain;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A collection of Subnets
+ */
+public class Subnets extends PaginatedCollection<Subnet> {
+ public static final Subnets EMPTY = new Subnets(ImmutableSet.<Subnet> of(), ImmutableSet.<Link> of());
+
+ @ConstructorProperties({"subnets", "subnets_links"})
+ protected Subnets(Iterable<Subnet> subnets, Iterable<Link> subnetsLinks) {
+ super(subnets, subnetsLinks);
+ }
+}
[16/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindVCloudNetworkAdapterToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindVCloudNetworkAdapterToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindVCloudNetworkAdapterToXmlPayload.java
new file mode 100644
index 0000000..b3fe262
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindVCloudNetworkAdapterToXmlPayload.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import com.google.common.base.Throwables;
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import com.jamesmurty.utils.XMLBuilder;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToStringPayload;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
+
+import javax.inject.Singleton;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+/**
+ * Created by michiel on 17/11/2014.
+ */
+@Singleton
+public class BindVCloudNetworkAdapterToXmlPayload implements MapBinder {
+
+ protected final String ns;
+ protected final String schema;
+
+ protected final BindToStringPayload stringBinder;
+
+ @Inject
+ public BindVCloudNetworkAdapterToXmlPayload(BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
+ @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
+ this.ns = ns;
+ this.schema = schema;
+ this.stringBinder = stringBinder;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
+ "this binder is only valid for GeneratedHttpRequests!");
+
+ Iterable<VCloudNetworkAdapter> networkCards = (Iterable<VCloudNetworkAdapter>) checkNotNull(postParams.remove("params"), "params");
+
+ /*
+ * The Iterable<VCloudNetworkAdapter> needs to be turned into a RasdItemList.
+ */
+ XMLBuilder rasdItemListBuilder;
+ String xml = null;
+ try {
+ rasdItemListBuilder = XMLBuilder.create("RasdItemsList").a("xmlns", ns);
+ //all sorts of other crazy XML attributes
+ rasdItemListBuilder.a("xmlns:rasd", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData");
+ rasdItemListBuilder.a("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
+ rasdItemListBuilder.a("type", "application/vnd.vmware.vcloud.rasdItemsList+xml");
+ //rasdItemListBuilder.a("href", "https://<vcloud>/api/vApp/vm-<UUID>/virtualHardwareSection/networkCards");
+ //rasdItemListBuilder.a("xsi:schemaLocation", "http://www.vmware.com/vcloud/v1.5 http://172.28.44.90/api/v1.5/schema/master.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd");
+
+ for (VCloudNetworkAdapter nic: networkCards) {
+ /*
+ * NOTE: the order of these items IS important.
+ */
+ XMLBuilder rasdItem = rasdItemListBuilder.elem("Item");
+ if (nic.getAddress() != null)
+ rasdItem.elem("rasd:Address").text(nic.getAddress());
+ if (nic.getAddressOnParent() != null)
+ rasdItem.elem("rasd:AddressOnParent").text(nic.getAddressOnParent());
+ if (nic.isAutomaticAllocation() != null)
+ rasdItem.elem("rasd:AutomaticAllocation").text(String.valueOf(nic.isAutomaticAllocation()));
+
+ //the connection handling is a little bit more involved.
+ if (nic.getConnections().size() > 1) {
+ /*
+ * The IP address is an attribute of the <rasd:Connection /> element, and we only store
+ * 1 IP address for the whole NIC. It's not clear to me why the nic.getConnections() returns
+ * a list anyway.
+ */
+ throw new UnsupportedOperationException("Currently we only support 1 connection per NIC.");
+ }
+ if (nic.getConnections() != null) {
+ for (String connection: nic.getConnections()) {
+ XMLBuilder c = rasdItem.elem("rasd:Connection").a("xmlns:vcloud", ns);
+ if (nic.getIpAddress() != null)
+ c.a("vcloud:ipAddress", nic.getIpAddress());
+
+ c.a("vcloud:primaryNetworkConnection", String.valueOf(nic.isPrimaryNetworkConnection()));
+ if (nic.getIpAddressingMode() != null)
+ c.a("vcloud:ipAddressingMode", nic.getIpAddressingMode());
+ c.text(connection);
+ }
+ }
+
+ if (nic.getDescription() != null)
+ rasdItem.elem("rasd:Description").text(nic.getDescription());
+ if (nic.getElementName() != null)
+ rasdItem.elem("rasd:ElementName").text(nic.getElementName());
+ if (nic.getInstanceID() != null)
+ rasdItem.elem("rasd:InstanceID").text(nic.getInstanceID());
+ if (nic.getResourceSubType() != null)
+ rasdItem.elem("rasd:ResourceSubType").text(nic.getResourceSubType());
+ if (nic.getResourceType() != null)
+ rasdItem.elem("rasd:ResourceType").text(nic.getResourceType().value());
+
+ //TODO: remaining items
+ }
+ xml = rasdItemListBuilder.asString();
+ } catch (ParserConfigurationException e) {
+ Throwables.propagate(e);
+ } catch (TransformerException e) {
+ Throwables.propagate(e);
+ }
+
+ return stringBinder.bindToRequest(request, xml);
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object postParams) {
+ throw new IllegalStateException("BindVCloudNetworkAdapterToXmlPayload needs parameters");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java
new file mode 100644
index 0000000..09c81e5
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.Catalog;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.Iterables;
+
+@Singleton
+public class OrgNameAndCatalogNameToEndpoint implements MapBinder {
+ private final Supplier<Map<String, Org>> orgMap;
+ private final Supplier<ReferenceType> defaultOrg;
+ private final Supplier<ReferenceType> defaultCatalog;
+
+ @Inject
+ public OrgNameAndCatalogNameToEndpoint(Supplier<Map<String, Org>> orgMap,
+ @org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg,
+ @Catalog Supplier<ReferenceType> defaultCatalog) {
+ this.orgMap = orgMap;
+ this.defaultOrg = defaultOrg;
+ this.defaultCatalog = defaultCatalog;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Object org = postParams.get("orgName");
+ Object catalog = postParams.get("catalogName");
+ if (org == null && catalog == null)
+ return (R) request.toBuilder().endpoint(defaultCatalog.get().getHref()).build();
+ else if (org == null)
+ org = defaultOrg.get().getName();
+
+ try {
+ Map<String, ReferenceType> catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs();
+ URI endpoint = catalog == null ? Iterables.getLast(catalogs.values()).getHref() : catalogs.get(catalog).getHref();
+ return (R) request.toBuilder().endpoint(endpoint).build();
+ } catch (NullPointerException e) {
+ throw new NoSuchElementException(org + "/" + catalog + " not found in " + orgMap.get());
+ }
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ throw new IllegalStateException(getClass() + " needs parameters");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java
new file mode 100644
index 0000000..b4bc580
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.VDC;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.Iterables;
+
+@Singleton
+public class OrgNameAndVDCNameToEndpoint implements MapBinder {
+ private final Supplier<Map<String, Org>> orgNameToVDCEndpoint;
+ private final Supplier<ReferenceType> defaultOrg;
+ private final Supplier<ReferenceType> defaultVDC;
+
+ @Inject
+ public OrgNameAndVDCNameToEndpoint(Supplier<Map<String, Org>> orgNameToVDCEndpoint,
+ @org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg, @VDC Supplier<ReferenceType> defaultVDC) {
+ this.orgNameToVDCEndpoint = orgNameToVDCEndpoint;
+ this.defaultOrg = defaultOrg;
+ this.defaultVDC = defaultVDC;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Object org = postParams.get("orgName");
+ Object vdc = postParams.get("vdcName");
+ if (org == null && vdc == null)
+ return (R) request.toBuilder().endpoint(defaultVDC.get().getHref()).build();
+ else if (org == null)
+ org = defaultOrg.get().getName();
+
+ try {
+ Map<String, ReferenceType> vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs();
+ URI endpoint = vdc == null ? Iterables.getLast(vdcs.values()).getHref() : vdcs.get(vdc).getHref();
+ return (R) request.toBuilder().endpoint(endpoint).build();
+ } catch (NullPointerException e) {
+ throw new NoSuchElementException(org + "/" + vdc + " not found in " + orgNameToVDCEndpoint.get());
+ }
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ throw new IllegalStateException(getClass() + " needs parameters");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java
new file mode 100644
index 0000000..2d9f762
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.Catalog;
+import org.jclouds.vcloud.endpoints.Org;
+
+import com.google.common.base.Supplier;
+
+@Singleton
+public class OrgNameCatalogNameItemNameToEndpoint implements MapBinder {
+ private final Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> orgCatalogMap;
+ private final Supplier<ReferenceType> defaultOrg;
+ private final Supplier<ReferenceType> defaultCatalog;
+
+ @Inject
+ public OrgNameCatalogNameItemNameToEndpoint(
+ Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> orgCatalogMap,
+ @Org Supplier<ReferenceType> defaultOrg, @Catalog Supplier<ReferenceType> defaultCatalog) {
+ this.orgCatalogMap = orgCatalogMap;
+ this.defaultOrg = defaultOrg;
+ this.defaultCatalog = defaultCatalog;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Object org = postParams.get("orgName");
+ Object catalog = postParams.get("catalogName");
+ Object catalogItem = postParams.get("itemName");
+ if (org == null)
+ org = defaultOrg.get().getName();
+ if (catalog == null)
+ catalog = defaultCatalog.get().getName();
+ try {
+ Map<String, org.jclouds.vcloud.domain.Catalog> catalogs = checkNotNull(orgCatalogMap.get().get(org));
+ return (R) request.toBuilder().endpoint(catalogs.get(catalog).get(catalogItem).getHref()).build();
+ } catch (NullPointerException e) {
+ throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in "
+ + orgCatalogMap.get());
+ }
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ throw new IllegalStateException(getClass() + " needs parameters");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java
new file mode 100644
index 0000000..a8b798d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.Catalog;
+import org.jclouds.vcloud.endpoints.Org;
+
+import com.google.common.base.Supplier;
+
+@Singleton
+public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements MapBinder {
+ private final Supplier<Map<String, Map<String, Map<String, CatalogItem>>>> orgCatalogItemMap;
+ private final Supplier<ReferenceType> defaultOrg;
+ private final Supplier<ReferenceType> defaultCatalog;
+
+ @Inject
+ public OrgNameCatalogNameVAppTemplateNameToEndpoint(
+ Supplier<Map<String, Map<String, Map<String, CatalogItem>>>> orgCatalogItemMap,
+ @Org Supplier<ReferenceType> defaultOrg, @Catalog Supplier<ReferenceType> defaultCatalog) {
+ this.orgCatalogItemMap = orgCatalogItemMap;
+ this.defaultOrg = defaultOrg;
+ this.defaultCatalog = defaultCatalog;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Object org = postParams.get("orgName");
+ Object catalog = postParams.get("catalogName");
+ Object catalogItem = postParams.get("itemName");
+ if (org == null)
+ org = defaultOrg.get().getName();
+ if (catalog == null)
+ catalog = defaultCatalog.get().getName();
+ Map<String, Map<String, Map<String, CatalogItem>>> orgCatalogItemMap = this.orgCatalogItemMap.get();
+
+ if (!orgCatalogItemMap.containsKey(org))
+ throw new NoSuchElementException("org: " + org + " not found in " + orgCatalogItemMap.keySet());
+ Map<String, Map<String, CatalogItem>> catalogs = orgCatalogItemMap.get(org);
+
+ if (!catalogs.containsKey(catalog))
+ throw new NoSuchElementException("catalog: " + org + "/" + catalog + " not found in " + catalogs.keySet());
+ Map<String, CatalogItem> catalogMap = catalogs.get(catalog);
+
+ if (!catalogMap.containsKey(catalogItem))
+ throw new NoSuchElementException("item: " + org + "/" + catalog + "/" + catalogItem + " not found in "
+ + catalogMap.keySet());
+ CatalogItem item = catalogMap.get(catalogItem);
+
+ URI endpoint = checkNotNull(item.getEntity(),
+ "item: " + org + "/" + catalog + "/" + catalogItem + " has no entity").getHref();
+ return (R) request.toBuilder().endpoint(endpoint).build();
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ throw new IllegalStateException(getClass() + " needs parameters");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java
new file mode 100644
index 0000000..11bfeac
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.Org;
+import org.jclouds.vcloud.endpoints.VDC;
+
+import com.google.common.base.Supplier;
+
+@Singleton
+public class OrgNameVDCNameNetworkNameToEndpoint extends OrgNameVDCNameResourceNameToEndpoint {
+ @Inject
+ public OrgNameVDCNameNetworkNameToEndpoint(
+ Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap,
+ @Org Supplier<ReferenceType> defaultOrg, @VDC Supplier<ReferenceType> defaultVDC) {
+ super(orgVDCMap, defaultOrg, defaultVDC);
+ }
+
+ protected URI getEndpointOfResourceInVDC(Object org, Object vDC, Object resource,
+ org.jclouds.vcloud.domain.VDC vDCObject) {
+ ReferenceType resourceEntity = vDCObject.getAvailableNetworks().get(resource);
+ if (resourceEntity == null)
+ throw new NoSuchElementException("network " + resource + " in vdc " + vDC + ", org " + org + " not found in "
+ + vDCObject.getAvailableNetworks().keySet());
+ return resourceEntity.getHref();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java
new file mode 100644
index 0000000..effcc49
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.Org;
+import org.jclouds.vcloud.endpoints.VDC;
+
+import com.google.common.base.Supplier;
+
+@Singleton
+public class OrgNameVDCNameResourceEntityNameToEndpoint extends OrgNameVDCNameResourceNameToEndpoint {
+ @Inject
+ public OrgNameVDCNameResourceEntityNameToEndpoint(
+ Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap,
+ @Org Supplier<ReferenceType> defaultOrg, @VDC Supplier<ReferenceType> defaultVDC) {
+ super(orgVDCMap, defaultOrg, defaultVDC);
+ }
+
+ protected URI getEndpointOfResourceInVDC(Object org, Object vDC, Object resource,
+ org.jclouds.vcloud.domain.VDC vDCObject) {
+ ReferenceType resourceEntity = vDCObject.getResourceEntities().get(resource);
+ if (resourceEntity == null)
+ throw new NoSuchElementException("entity " + resource + " in vdc " + vDC + ", org " + org + " not found in "
+ + vDCObject.getResourceEntities().keySet());
+ return resourceEntity.getHref();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java
new file mode 100644
index 0000000..99ac848
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkState;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.endpoints.Org;
+
+import com.google.common.base.Supplier;
+public abstract class OrgNameVDCNameResourceNameToEndpoint implements MapBinder {
+
+ protected final Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap;
+ protected final Supplier<ReferenceType> defaultOrg;
+ protected final Supplier<ReferenceType> defaultVDC;
+
+ @Inject
+ public OrgNameVDCNameResourceNameToEndpoint(
+ Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap,
+ @Org Supplier<ReferenceType> defaultOrg, @org.jclouds.vcloud.endpoints.VDC Supplier<ReferenceType> defaultVDC) {
+ this.orgVDCMap = orgVDCMap;
+ this.defaultOrg = defaultOrg;
+ this.defaultVDC = defaultVDC;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Object org = postParams.get("orgName");
+ Object vDC = postParams.get("vdcName");
+ Object resource = postParams.get("resourceName");
+ if (org == null)
+ org = defaultOrg.get().getName();
+ if (vDC == null)
+ vDC = defaultVDC.get().getName();
+ Map<String, Map<String, org.jclouds.vcloud.domain.VDC>> orgToVDCs = orgVDCMap.get();
+ checkState(orgToVDCs != null, "could not get map of org name to vdcs!");
+ Map<String, org.jclouds.vcloud.domain.VDC> vDCs = orgToVDCs.get(org);
+ if (vDCs == null)
+ throw new NoSuchElementException("org " + org + " not found in " + orgToVDCs.keySet());
+ org.jclouds.vcloud.domain.VDC vDCObject = vDCs.get(vDC);
+ if (vDCObject == null)
+ throw new NoSuchElementException("vdc " + vDC + " in org " + org + " not found in " + vDCs.keySet());
+ URI endpoint = getEndpointOfResourceInVDC(org, vDC, resource, vDCObject);
+ return (R) request.toBuilder().endpoint(endpoint).build();
+ }
+
+ protected abstract URI getEndpointOfResourceInVDC(Object org, Object vDC, Object resource, VDC vDCObject);
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ throw new IllegalStateException(getClass() + " needs parameters");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java
new file mode 100644
index 0000000..d3538c0
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.config;
+
+import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
+import org.jclouds.domain.Location;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+/**
+ * Configures the {@link VCloudComputeServiceContext}; requires {@link VCloudComputeClientImpl}
+ * bound.
+ */
+public class VCloudComputeServiceContextModule extends
+ ComputeServiceAdapterContextModule<VApp, VAppTemplate, VAppTemplate, Location> {
+
+ @Override
+ protected void configure() {
+ super.configure();
+ install(new VCloudComputeServiceDependenciesModule());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java
new file mode 100644
index 0000000..8b53c90
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.config;
+
+
+import java.util.Map;
+
+import javax.inject.Singleton;
+
+import org.jclouds.compute.ComputeServiceAdapter;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.domain.Location;
+import org.jclouds.functions.IdentityFunction;
+import org.jclouds.vcloud.compute.functions.HardwareForVApp;
+import org.jclouds.vcloud.compute.functions.HardwareForVAppTemplate;
+import org.jclouds.vcloud.compute.functions.ImageForVAppTemplate;
+import org.jclouds.vcloud.compute.functions.VAppToNodeMetadata;
+import org.jclouds.vcloud.compute.internal.VCloudTemplateBuilderImpl;
+import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
+import org.jclouds.vcloud.compute.strategy.VCloudComputeServiceAdapter;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.jclouds.vcloud.domain.network.NetworkConfig;
+import org.jclouds.vcloud.endpoints.Network;
+import org.jclouds.vcloud.functions.VAppTemplatesInOrg;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+
+public class VCloudComputeServiceDependenciesModule extends AbstractModule {
+
+ @VisibleForTesting
+ public static final Map<Status, NodeMetadata.Status> toPortableNodeStatus = ImmutableMap
+ .<Status, NodeMetadata.Status> builder()
+ .put(Status.OFF, NodeMetadata.Status.SUSPENDED)
+ .put(Status.ON, NodeMetadata.Status.RUNNING)
+ .put(Status.RESOLVED, NodeMetadata.Status.PENDING)
+ .put(Status.MIXED, NodeMetadata.Status.PENDING)
+ .put(Status.UNKNOWN, NodeMetadata.Status.UNRECOGNIZED)
+ .put(Status.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED)
+ .put(Status.DEPLOYED, NodeMetadata.Status.PENDING)
+ .put(Status.SUSPENDED, NodeMetadata.Status.SUSPENDED)
+ .put(Status.WAITING_FOR_INPUT, NodeMetadata.Status.PENDING)
+ .put(Status.INCONSISTENT, NodeMetadata.Status.PENDING)
+ .put(Status.ERROR, NodeMetadata.Status.ERROR)
+ .put(Status.UNRESOLVED, NodeMetadata.Status.PENDING).build();
+
+ @Singleton
+ @Provides
+ protected Map<Status, NodeMetadata.Status> toPortableNodeStatus() {
+ return toPortableNodeStatus;
+ }
+
+ @VisibleForTesting
+ public static final Map<Status, Image.Status> toPortableImageStatus = ImmutableMap
+ .<Status, Image.Status> builder()
+ .put(Status.RESOLVED, Image.Status.AVAILABLE)
+ .put(Status.OFF, Image.Status.AVAILABLE)
+ .put(Status.MIXED, Image.Status.PENDING)
+ .put(Status.UNKNOWN, Image.Status.UNRECOGNIZED)
+ .put(Status.UNRECOGNIZED, Image.Status.UNRECOGNIZED)
+ .put(Status.DEPLOYED, Image.Status.PENDING)
+ .put(Status.PENDING_DESCRIPTOR, Image.Status.PENDING)
+ .put(Status.COPYING, Image.Status.PENDING)
+ .put(Status.PENDING_CONTENTS, Image.Status.PENDING)
+ .put(Status.QUARANTINED, Image.Status.PENDING)
+ .put(Status.QUARANTINE_EXPIRED, Image.Status.ERROR)
+ .put(Status.REJECTED, Image.Status.ERROR)
+ .put(Status.TRANSFER_TIMEOUT, Image.Status.ERROR)
+ .put(Status.ERROR, Image.Status.ERROR)
+ .put(Status.UNRESOLVED, Image.Status.PENDING).build();
+
+ @Singleton
+ @Provides
+ protected Map<Status, Image.Status> toPortableImageStatus() {
+ return toPortableImageStatus;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void configure() {
+ bind(new TypeLiteral<ComputeServiceAdapter<VApp, VAppTemplate, VAppTemplate, Location>>() {
+ }).to(VCloudComputeServiceAdapter.class);
+
+ bind(new TypeLiteral<Function<VApp, NodeMetadata>>() {
+ }).to(VAppToNodeMetadata.class);
+
+ bind(TemplateOptions.class).to(VCloudTemplateOptions.class);
+ bind(TemplateBuilder.class).to(VCloudTemplateBuilderImpl.class);
+
+ bind(new TypeLiteral<Function<VApp, Hardware>>() {
+ }).to(new TypeLiteral<HardwareForVApp>() {
+ });
+
+ bind(new TypeLiteral<Function<Org, Iterable<VAppTemplate>>>() {
+ }).to(VAppTemplatesInOrg.class);
+ bind(new TypeLiteral<Function<VAppTemplate, Image>>() {
+ }).to(ImageForVAppTemplate.class);
+ bind(new TypeLiteral<Function<VAppTemplate, Hardware>>() {
+ }).to(HardwareForVAppTemplate.class);
+
+ // we aren't converting from a provider-specific type
+ bind(new TypeLiteral<Function<Location, Location>>() {
+ }).to(Class.class.cast(IdentityFunction.class));
+ }
+
+
+ @Provides
+ @Singleton
+ public Supplier<NetworkConfig> networkConfig(@Network Supplier<ReferenceType> network,
+ final FenceMode defaultFenceMode) {
+ return Suppliers.compose(new Function<ReferenceType, NetworkConfig>() {
+
+ @Override
+ public NetworkConfig apply(ReferenceType input) {
+ return new NetworkConfig(input.getName(), input.getHref(), defaultFenceMode);
+ }
+
+ }, network);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java
new file mode 100644
index 0000000..f7e2cdf
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.functions;
+
+import java.net.URI;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.domain.Location;
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.domain.ReferenceType;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+
+@Singleton
+public class FindLocationForResource implements Function<ReferenceType, Location> {
+
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ final Supplier<Set<? extends Location>> locations;
+
+ @Inject
+ public FindLocationForResource(@Memoized Supplier<Set<? extends Location>> locations) {
+ this.locations = locations;
+ }
+
+ /**
+ * searches for a location associated with this resource.
+ *
+ * @throws NoSuchElementException
+ * if not found
+ */
+ public Location apply(ReferenceType resource) {
+ for (Location input : locations.get()) {
+ do {
+ // The "name" isn't always present, ex inside a vApp we have a rel
+ // link that only includes href and type.
+ if (URI.create(input.getId()).equals(resource.getHref()))
+ return input;
+ } while ((input = input.getParent()) != null);
+ }
+ throw new NoSuchElementException(String.format("resource: %s not found in locations: %s", resource,
+ locations.get()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java
new file mode 100644
index 0000000..ebfb010
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.HardwareBuilder;
+import org.jclouds.compute.predicates.ImagePredicates;
+import org.jclouds.domain.Location;
+import org.jclouds.logging.Logger;
+import org.jclouds.ovf.VirtualHardwareSection;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.Vm;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+public class HardwareForVApp implements Function<VApp, Hardware> {
+
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ private final Function<ReferenceType, Location> findLocationForResource;
+ private final VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder;
+
+ @Inject
+ protected HardwareForVApp(Function<ReferenceType, Location> findLocationForResource,
+ VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder) {
+ this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
+ this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder");
+ }
+
+ @Override
+ public Hardware apply(VApp from) {
+ checkNotNull(from, "VApp");
+ // TODO make this work with composite vApps
+ Vm vm = from.getChildren().size() == 0 ? null : Iterables.get(from.getChildren(), 0);
+ if (vm == null)
+ return null;
+
+ VirtualHardwareSection hardware = vm.getVirtualHardwareSection();
+ HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getItems());
+ builder.location(findLocationForResource.apply(checkNotNull(from, "from").getVDC()));
+ builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage(
+ ImagePredicates.idEquals(from.getHref().toASCIIString()));
+ builder.hypervisor("VMware");
+ return builder.build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java
new file mode 100644
index 0000000..46d1627
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.HardwareBuilder;
+import org.jclouds.compute.predicates.ImagePredicates;
+import org.jclouds.logging.Logger;
+import org.jclouds.ovf.Envelope;
+import org.jclouds.ovf.VirtualHardwareSection;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+@Singleton
+public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware> {
+
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ private final Function<VAppTemplate, Envelope> templateToEnvelope;
+ private final FindLocationForResource findLocationForResource;
+ private final VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder;
+
+ @Inject
+ protected HardwareForVAppTemplate(Function<VAppTemplate, Envelope> templateToEnvelope,
+ FindLocationForResource findLocationForResource,
+ VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder) {
+ this.templateToEnvelope = checkNotNull(templateToEnvelope, "templateToEnvelope");
+ this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
+ this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder");
+ }
+
+ @Override
+ public Hardware apply(VAppTemplate from) {
+ checkNotNull(from, "VAppTemplate");
+
+ Envelope ovf = templateToEnvelope.apply(from);
+
+ if (ovf.getVirtualSystem().getVirtualHardwareSections().size() > 1) {
+ logger.warn("multiple hardware choices found. using first", ovf);
+ }
+ VirtualHardwareSection hardware = Iterables.get(ovf.getVirtualSystem().getVirtualHardwareSections(), 0);
+ HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getItems());
+ if (from.getVDC() != null) {
+ builder.location(findLocationForResource.apply(from.getVDC()));
+ } else {
+ // otherwise, it could be in a public catalog, which is not assigned to a VDC
+ }
+ builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage(
+ ImagePredicates.idEquals(from.getHref().toASCIIString()));
+ builder.hypervisor("VMware");
+ return builder.build();
+
+ }
+
+ protected String getName(String name) {
+ return name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java
new file mode 100644
index 0000000..eb70f28
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.domain.CIMOperatingSystem;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.ImageBuilder;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.logging.Logger;
+import org.jclouds.ovf.Envelope;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.base.Function;
+
+@Singleton
+public class ImageForVAppTemplate implements Function<VAppTemplate, Image> {
+
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ public Logger logger = Logger.NULL;
+
+ private final Map<Status, Image.Status> toPortableImageStatus;
+ private final Function<VAppTemplate, Envelope> templateToEnvelope;
+ private final FindLocationForResource findLocationForResource;
+
+
+ @Inject
+ protected ImageForVAppTemplate(Map<Status, Image.Status> toPortableImageStatus, Function<VAppTemplate, Envelope> templateToEnvelope,
+ FindLocationForResource findLocationForResource) {
+ this.toPortableImageStatus = checkNotNull(toPortableImageStatus, "toPortableImageStatus");
+ this.templateToEnvelope = checkNotNull(templateToEnvelope, "templateToEnvelope");
+ this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
+ }
+
+ @Override
+ public Image apply(VAppTemplate from) {
+ checkNotNull(from, "VAppTemplate");
+ Envelope ovf = templateToEnvelope.apply(from);
+
+ ImageBuilder builder = new ImageBuilder();
+ builder.ids(from.getHref().toASCIIString());
+ builder.uri(from.getHref());
+ builder.name(from.getName());
+ if (from.getVDC() != null) {
+ builder.location(findLocationForResource.apply(from.getVDC()));
+ } else {
+ // otherwise, it could be in a public catalog, which is not assigned to a VDC
+ }
+ builder.description(from.getDescription() != null ? from.getDescription() : from.getName());
+ builder.operatingSystem(CIMOperatingSystem.toComputeOs(ovf));
+ builder.status(toPortableImageStatus.get(from.getStatus()));
+ return builder.build();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java
new file mode 100644
index 0000000..0947c78
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Predicates.not;
+import static com.google.common.base.Strings.isNullOrEmpty;
+import static com.google.common.collect.Iterables.filter;
+import static org.jclouds.compute.util.ComputeServiceUtils.addMetadataAndParseTagsFromCommaDelimitedValue;
+import static org.jclouds.compute.util.ComputeServiceUtils.groupFromMapOrName;
+import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom;
+import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getIpsFromVApp;
+import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.domain.Credentials;
+import org.jclouds.logging.Logger;
+import org.jclouds.util.InetAddresses2.IsPrivateIPAddress;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.VApp;
+
+import com.google.common.base.Function;
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableMap;
+
+@Singleton
+public class VAppToNodeMetadata implements Function<VApp, NodeMetadata> {
+ @Resource
+ protected static Logger logger = Logger.NULL;
+
+ protected final FindLocationForResource findLocationForResourceInVDC;
+ protected final Function<VApp, Hardware> hardwareForVApp;
+ protected final Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus;
+ protected final Map<String, Credentials> credentialStore;
+ protected final GroupNamingConvention nodeNamingConvention;
+
+ @Inject
+ protected VAppToNodeMetadata(Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus, Map<String, Credentials> credentialStore,
+ FindLocationForResource findLocationForResourceInVDC, Function<VApp, Hardware> hardwareForVApp,
+ GroupNamingConvention.Factory namingConvention) {
+ this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
+ this.hardwareForVApp = checkNotNull(hardwareForVApp, "hardwareForVApp");
+ this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC");
+ this.credentialStore = checkNotNull(credentialStore, "credentialStore");
+ this.vAppStatusToNodeStatus = checkNotNull(vAppStatusToNodeStatus, "vAppStatusToNodeStatus");
+ }
+
+ public NodeMetadata apply(VApp from) {
+ NodeMetadataBuilder builder = new NodeMetadataBuilder();
+ builder.ids(from.getHref().toASCIIString());
+ builder.uri(from.getHref());
+ builder.name(from.getName());
+ String groupName = "";
+ Map<String, String> metadataMap;
+
+ if (!isNullOrEmpty(from.getDescription())
+ && from.getDescription().indexOf('=') != -1
+ && from.getDescription().indexOf('\n') != -1) {
+ try {
+ metadataMap = Splitter.on('\n').withKeyValueSeparator("=").split(from.getDescription());
+
+ addMetadataAndParseTagsFromCommaDelimitedValue(builder, metadataMap);
+ } catch (IllegalArgumentException iae) {
+ // no op
+ metadataMap = ImmutableMap.of();
+ }
+ } else {
+ metadataMap = ImmutableMap.of();
+ }
+ builder.hostname(from.getName());
+ builder.location(findLocationForResourceInVDC.apply(from.getVDC()));
+ builder.group(groupFromMapOrName(metadataMap, from.getName(), nodeNamingConvention));
+ builder.operatingSystem(toComputeOs(from, null));
+ builder.hardware(hardwareForVApp.apply(from));
+ builder.status(vAppStatusToNodeStatus.get(from.getStatus()));
+ Set<String> addresses = getIpsFromVApp(from);
+ builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE)));
+ builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE));
+
+ // normally, we don't affect the credential store when reading vApps.
+ // However, login user, etc, is actually in the metadata, so lets see
+ Credentials fromApi = getCredentialsFrom(from);
+ if (fromApi != null && !credentialStore.containsKey("node#" + from.getHref().toASCIIString()))
+ credentialStore.put("node#" + from.getHref().toASCIIString(), fromApi);
+ return builder.build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java
new file mode 100644
index 0000000..2f3bd42
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.functions;
+
+import javax.inject.Singleton;
+
+import org.jclouds.cim.ResourceAllocationSettingData;
+import org.jclouds.cim.functions.HardwareBuilderFromResourceAllocations;
+import org.jclouds.compute.domain.Volume;
+import org.jclouds.compute.domain.internal.VolumeImpl;
+import org.jclouds.vcloud.domain.ovf.VCloudHardDisk;
+
+@Singleton
+public class VCloudHardwareBuilderFromResourceAllocations extends HardwareBuilderFromResourceAllocations {
+ @Override
+ public Volume apply(ResourceAllocationSettingData from) {
+ if (from instanceof VCloudHardDisk) {
+ VCloudHardDisk vDisk = VCloudHardDisk.class.cast(from);
+ return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, vDisk.getCapacity() / 1024f, null,
+ "0".equals(from.getAddressOnParent()), true);
+ } else {
+ return super.apply(from);
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java
new file mode 100644
index 0000000..c08a622
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.functions;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.concurrent.ExecutionException;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.ovf.Envelope;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.base.Function;
+import com.google.common.cache.LoadingCache;
+
+@Singleton
+public class ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException implements
+ Function<VAppTemplate, Envelope> {
+
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ private final LoadingCache<URI, Envelope> envelopes;
+
+ @Inject
+ protected ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException(LoadingCache<URI, Envelope> envelopes) {
+ this.envelopes = checkNotNull(envelopes, "envelopes");
+ }
+
+ @Override
+ public Envelope apply(VAppTemplate from) {
+ checkArgument(from.getChildren().size() == 1, "multiple vms are not supported: %s", from);
+
+ checkArgument(from.isOvfDescriptorUploaded(), "ovf descriptor is not uploaded: %s", from);
+ Envelope ovf = getOVFForVAppTemplateAndValidate(from);
+ return ovf;
+ }
+
+ private Envelope getOVFForVAppTemplateAndValidate(VAppTemplate from) throws IllegalArgumentException {
+ Envelope ovf;
+ try {
+ ovf = envelopes.get(from.getHref());
+ checkArgument(ovf.getVirtualSystem().getVirtualHardwareSections().size() > 0,
+ "no hardware sections exist in ovf %s", ovf);
+ } catch (ExecutionException e) {
+ throw new IllegalArgumentException("no ovf envelope found for: " + from, e);
+ }
+ return ovf;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java
new file mode 100644
index 0000000..8304466
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.internal;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.domain.internal.TemplateBuilderImpl;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.compute.strategy.GetImageStrategy;
+import org.jclouds.compute.suppliers.ImageCacheSupplier;
+import org.jclouds.domain.Location;
+
+import com.google.common.base.Supplier;
+
+public class VCloudTemplateBuilderImpl extends TemplateBuilderImpl {
+
+ @Inject
+ protected VCloudTemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
+ ImageCacheSupplier images, @Memoized Supplier<Set<? extends Hardware>> sizes,
+ Supplier<Location> defaultLocation, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
+ @Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, GetImageStrategy getImageStrategy) {
+ super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, getImageStrategy);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java
new file mode 100644
index 0000000..0910db4
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java
@@ -0,0 +1,349 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Strings.emptyToNull;
+
+import java.net.URI;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.vcloud.domain.NetworkConnection;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Contains options supported in the {@code ComputeService#runNode} operation on
+ * the "vcloud" provider. <h2>
+ * Usage</h2> The recommended way to instantiate a VCloudTemplateOptions object
+ * is to statically import VCloudTemplateOptions.* and invoke a static creation
+ * method followed by an instance mutator (if needed):
+ * <p/>
+ * <code>
+ * import static org.jclouds.compute.options.VCloudTemplateOptions.Builder.*;
+ * <p/>
+ * ComputeService client = // get connection
+ * templateBuilder.options(inboundPorts(22, 80, 8080, 443));
+ * Set<NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build());
+ * <code>
+ */
+public class VCloudTemplateOptions extends TemplateOptions implements Cloneable {
+ @Override
+ public VCloudTemplateOptions clone() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ copyTo(options);
+ return options;
+ }
+
+ @Override
+ public void copyTo(TemplateOptions to) {
+ super.copyTo(to);
+ if (to instanceof VCloudTemplateOptions) {
+ VCloudTemplateOptions eTo = VCloudTemplateOptions.class.cast(to);
+ if (getCustomizationScript() != null)
+ eTo.customizationScript(getCustomizationScript());
+ if (getDescription() != null)
+ eTo.description(getDescription());
+ if (getNetworkConnections() != null)
+ eTo.networkConnections(getNetworkConnections());
+ if (getParentNetwork() != null)
+ eTo.parentNetwork(getParentNetwork());
+ if (getFenceMode() != null)
+ eTo.fenceMode(getFenceMode());
+ }
+ }
+
+ private String description = null;
+ private String customizationScript = null;
+ // This Hashtable maps TemplateOptions.networks[i] to each networks' specific vCloud options
+ // We index by network 'name' (href in vCloud)
+ private Hashtable<String, NetworkConnection> networkConnections = null;
+ private URI parentNetwork = null;
+ private FenceMode fenceMode = null;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ VCloudTemplateOptions that = VCloudTemplateOptions.class.cast(o);
+ return super.equals(that) && equal(this.description, that.description)
+ && equal(this.customizationScript, that.customizationScript)
+ && equal(this.networkConnections, that.networkConnections)
+ && equal(this.parentNetwork, that.parentNetwork);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), description, customizationScript, networkConnections,
+ parentNetwork);
+ }
+
+ @Override
+ public ToStringHelper string() {
+ return super.string().add("description", description).add("customizationScript", customizationScript)
+ .add("networkConnections", networkConnections).add("parentNetwork", parentNetwork);
+ }
+
+ /**
+ * Optional description. Used for the Description of the vApp created by this
+ * instantiation.
+ */
+ public VCloudTemplateOptions description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * Specifies the customizationScript used to run instances with
+ */
+ public VCloudTemplateOptions customizationScript(String customizationScript) {
+ this.customizationScript = checkNotNull(emptyToNull(customizationScript), "customizationScript must be defined");
+ return this;
+ }
+
+ /**
+ * Specifies the networkConnections settings used to for network interfaces on
+ * the VMs. This lets you specify things like ip address allocation mode,
+ * the actual IP (in case of fixed IP) etc.
+ */
+ public VCloudTemplateOptions networkConnections(Hashtable<String, NetworkConnection> networkConnections) {
+ this.networkConnections = networkConnections;
+ return this;
+ }
+
+ /**
+ * Specifies the parentNetwork to connect the the network interfaces on the
+ * VMs to.
+ *
+ * @see InstantiateVAppTemplateOptions#addNetworkConfig
+ */
+ public VCloudTemplateOptions parentNetwork(URI parentNetwork) {
+ this.parentNetwork = parentNetwork;
+ return this;
+ }
+
+ /**
+ * How to connect to the parent network
+ *
+ * @see InstantiateVAppTemplateOptions#addNetworkConfig
+ */
+ public VCloudTemplateOptions fenceMode(FenceMode fenceMode) {
+ this.fenceMode = fenceMode;
+ return this;
+ }
+
+ public static class Builder {
+ /**
+ * @see VCloudTemplateOptions#description
+ */
+ public static VCloudTemplateOptions description(String description) {
+ return new VCloudTemplateOptions().description(description);
+ }
+
+ /**
+ * @see VCloudTemplateOptions#customizationScript
+ */
+ public static VCloudTemplateOptions customizationScript(String customizationScript) {
+ return new VCloudTemplateOptions().customizationScript(customizationScript);
+ }
+
+ /**
+ * @see VCloudTemplateOptions#networkConnections
+ */
+ public static VCloudTemplateOptions networkConnections(Hashtable<String, NetworkConnection> networkConnections) {
+ return new VCloudTemplateOptions().networkConnections(networkConnections);
+ }
+
+ /**
+ * @see VCloudTemplateOptions#parentNetwork(URI parentNetwork)
+ */
+ public static VCloudTemplateOptions parentNetwork(URI parentNetwork) {
+ return new VCloudTemplateOptions().parentNetwork(parentNetwork);
+ }
+
+ /**
+ * @see VCloudTemplateOptions#fenceMode(FenceMode)
+ */
+ public static VCloudTemplateOptions fenceMode(FenceMode fenceMode) {
+ return new VCloudTemplateOptions().fenceMode(fenceMode);
+ }
+
+ // methods that only facilitate returning the correct object type
+ /**
+ * @see TemplateOptions#inboundPorts
+ */
+ public static VCloudTemplateOptions inboundPorts(int... ports) {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ return VCloudTemplateOptions.class.cast(options.inboundPorts(ports));
+ }
+
+ /**
+ * @see TemplateOptions#port
+ */
+ public static VCloudTemplateOptions blockOnPort(int port, int seconds) {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ return VCloudTemplateOptions.class.cast(options.blockOnPort(port, seconds));
+ }
+
+ /**
+ * @see TemplateOptions#userMetadata(Map)
+ */
+ public static VCloudTemplateOptions userMetadata(Map<String, String> userMetadata) {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ return VCloudTemplateOptions.class.cast(options.userMetadata(userMetadata));
+ }
+
+ /**
+ * @see TemplateOptions#userMetadata(String, String)
+ */
+ public static VCloudTemplateOptions userMetadata(String key, String value) {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ return VCloudTemplateOptions.class.cast(options.userMetadata(key, value));
+ }
+
+ /**
+ * @see TemplateOptions#nodeNames(Iterable)
+ */
+ public static VCloudTemplateOptions nodeNames(Iterable<String> nodeNames) {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ return VCloudTemplateOptions.class.cast(options.nodeNames(nodeNames));
+ }
+
+ /**
+ * @see TemplateOptions#networks(Iterable)
+ */
+ public static VCloudTemplateOptions networks(Iterable<String> networks) {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ return VCloudTemplateOptions.class.cast(options.networks(networks));
+ }
+
+ }
+
+ /**
+ * @return description of the vApp
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @return customizationScript on the vms
+ */
+ public String getCustomizationScript() {
+ return customizationScript;
+ }
+
+ /**
+ * @return ipAddressAllocationMode on the vms
+ */
+ public Hashtable<String, NetworkConnection> getNetworkConnections() { return networkConnections; }
+
+ /**
+ * @return parentNetwork to connect to the vms
+ */
+ public URI getParentNetwork() {
+ return parentNetwork;
+ }
+
+ /**
+ * @return FenceMode to connect the parent network with
+ */
+ public FenceMode getFenceMode() {
+ return fenceMode;
+ }
+
+ // methods that only facilitate returning the correct object type
+
+ /**
+ * @see TemplateOptions#blockOnPort
+ */
+ @Override
+ public VCloudTemplateOptions blockOnPort(int port, int seconds) {
+ return VCloudTemplateOptions.class.cast(super.blockOnPort(port, seconds));
+ }
+
+ /**
+ *
+ * special thing is that we do assume if you are passing groups that you have
+ * everything you need already defined. for example, our option inboundPorts
+ * normally creates ingress rules accordingly but if we notice you've
+ * specified securityGroups, we do not mess with rules at all
+ *
+ * @see TemplateOptions#inboundPorts
+ */
+ @Override
+ public VCloudTemplateOptions inboundPorts(int... ports) {
+ return VCloudTemplateOptions.class.cast(super.inboundPorts(ports));
+ }
+
+ /**
+ * @see TemplateOptions#authorizePublicKey(String)
+ */
+ @Override
+ public VCloudTemplateOptions authorizePublicKey(String publicKey) {
+ return VCloudTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
+ }
+
+ /**
+ * @see TemplateOptions#installPrivateKey(String)
+ */
+ @Override
+ public VCloudTemplateOptions installPrivateKey(String privateKey) {
+ return VCloudTemplateOptions.class.cast(super.installPrivateKey(privateKey));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public VCloudTemplateOptions userMetadata(Map<String, String> userMetadata) {
+ return VCloudTemplateOptions.class.cast(super.userMetadata(userMetadata));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public VCloudTemplateOptions userMetadata(String key, String value) {
+ return VCloudTemplateOptions.class.cast(super.userMetadata(key, value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public VCloudTemplateOptions nodeNames(Iterable<String> nodeNames) {
+ return VCloudTemplateOptions.class.cast(super.nodeNames(nodeNames));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public VCloudTemplateOptions networks(Iterable<String> networks) {
+ return VCloudTemplateOptions.class.cast(super.networks(networks));
+ }
+
+}
[35/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/features/OAuthApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/features/OAuthApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/features/OAuthApiLiveTest.java
new file mode 100644
index 0000000..4ac5950
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/features/OAuthApiLiveTest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.features;
+
+import static com.google.common.base.Preconditions.checkState;
+import static org.jclouds.oauth.v2.OAuthTestUtils.getMandatoryProperty;
+import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE;
+import static org.jclouds.oauth.v2.config.OAuthProperties.SCOPES;
+import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Properties;
+
+import org.jclouds.oauth.v2.OAuthConstants;
+import org.jclouds.oauth.v2.domain.ClaimSet;
+import org.jclouds.oauth.v2.domain.Header;
+import org.jclouds.oauth.v2.domain.Token;
+import org.jclouds.oauth.v2.domain.TokenRequest;
+import org.jclouds.oauth.v2.internal.BaseOAuthApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ * A live test for authentication. Requires the following properties to be set:
+ * - test.oauth.endpoint
+ * - test.oauth.identity
+ * - test.oauth.credential
+ * - test.jclouds.oauth.audience
+ * - test.jclouds.oauth.scopes
+ * - test.jclouds.oauth.signature-or-mac-algorithm
+ */
+@Test(groups = "live", singleThreaded = true)
+public class OAuthApiLiveTest extends BaseOAuthApiLiveTest {
+
+ private Properties properties;
+
+ @Override
+ protected Properties setupProperties() {
+ properties = super.setupProperties();
+ return properties;
+
+ }
+
+ @Test(groups = "live", singleThreaded = true)
+ public void testAuthenticateJWTToken() throws Exception {
+ assertTrue(properties != null, "properties were not set");
+ String signatureAlgorithm = getMandatoryProperty(properties, SIGNATURE_OR_MAC_ALGORITHM);
+ checkState(OAuthConstants.OAUTH_ALGORITHM_NAMES_TO_SIGNATURE_ALGORITHM_NAMES.containsKey(signatureAlgorithm)
+ , String.format("Algorithm not supported: " + signatureAlgorithm));
+
+ Header header = Header.builder().signerAlgorithm(signatureAlgorithm).type("JWT").build();
+
+ String scopes = getMandatoryProperty(properties, SCOPES);
+ String audience = getMandatoryProperty(properties, AUDIENCE);
+
+ long now = nowInSeconds();
+
+ ClaimSet claimSet = ClaimSet.builder().addClaim("aud", audience).addClaim("scope", scopes).addClaim("iss",
+ identity).emissionTime(now).expirationTime(now + 3600).build();
+
+ TokenRequest tokenRequest = TokenRequest.builder().header(header).claimSet(claimSet).build();
+ Token token = api.authenticate(tokenRequest);
+
+ assertNotNull(token, "no token when authenticating " + tokenRequest);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsFromPKTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsFromPKTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsFromPKTest.java
new file mode 100644
index 0000000..e3794d6
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsFromPKTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.functions;
+
+import static com.google.common.base.Suppliers.ofInstance;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.security.spec.InvalidKeySpecException;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
+
+import org.jclouds.domain.Credentials;
+import org.jclouds.oauth.v2.domain.OAuthCredentials;
+import org.jclouds.oauth.v2.functions.OAuthCredentialsSupplier.OAuthCredentialsForCredentials;
+import org.testng.annotations.Test;
+
+/**
+ * Test loading the credentials by extracting a pk from a PKCS12 keystore.
+ */
+@Test(groups = "unit")
+public class OAuthCredentialsFromPKTest {
+
+ public static OAuthCredentials loadOAuthCredentials() throws IOException, NoSuchAlgorithmException,
+ CertificateException, InvalidKeySpecException {
+ OAuthCredentialsSupplier loader = new OAuthCredentialsSupplier(ofInstance(new Credentials("foo",
+ Files.asCharSource(new File("src/test/resources/testpk.pem"), Charsets.UTF_8).read())),
+ new OAuthCredentialsForCredentials("RS256"), "RS256");
+ return loader.get();
+ }
+
+
+ public void testLoadPKString() throws IOException, NoSuchAlgorithmException, KeyStoreException,
+ CertificateException, UnrecoverableKeyException, InvalidKeySpecException {
+ OAuthCredentials creds = loadOAuthCredentials();
+ assertNotNull(creds);
+ assertEquals(creds.identity, "foo");
+ assertNotNull(creds.privateKey);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsSupplierTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsSupplierTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsSupplierTest.java
new file mode 100644
index 0000000..2b3d094
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/functions/OAuthCredentialsSupplierTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.functions;
+
+import com.google.common.base.Suppliers;
+import org.jclouds.domain.Credentials;
+import org.jclouds.oauth.v2.OAuthTestUtils;
+import org.jclouds.rest.AuthorizationException;
+import org.testng.annotations.Test;
+
+import java.util.Properties;
+
+import static org.jclouds.oauth.v2.functions.OAuthCredentialsSupplier.OAuthCredentialsForCredentials;
+import static org.testng.Assert.assertNotNull;
+
+@Test(groups = "unit")
+public class OAuthCredentialsSupplierTest {
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testAuthorizationExceptionIsThrownOnBadKeys() {
+ OAuthCredentialsSupplier supplier = new OAuthCredentialsSupplier(Suppliers.ofInstance(new Credentials("MOMMA",
+ "MIA")), new OAuthCredentialsForCredentials("RS256"), "RS256");
+ supplier.get();
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testGSEChildExceptionsPropagateAsAuthorizationException() {
+ OAuthCredentialsSupplier supplier = new OAuthCredentialsSupplier(Suppliers.ofInstance(new Credentials("MOMMA",
+ "MIA")), new OAuthCredentialsForCredentials("MOMMA"), "MOMMA");
+ supplier.get();
+ }
+
+ public void testCredentialsAreLoadedOnRightAlgoAndCredentials() {
+ Properties propertied = OAuthTestUtils.defaultProperties(new Properties());
+ Credentials validCredentials = new Credentials(propertied.getProperty("oauth.identity"),
+ propertied.getProperty("oauth.credential"));
+ OAuthCredentialsSupplier supplier = new OAuthCredentialsSupplier(Suppliers.ofInstance(validCredentials),
+ new OAuthCredentialsForCredentials("RS256"), "RS256");
+ assertNotNull(supplier.get());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/functions/SignerFunctionTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/functions/SignerFunctionTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/functions/SignerFunctionTest.java
new file mode 100644
index 0000000..2a64822
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/functions/SignerFunctionTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.functions;
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.base.Suppliers.ofInstance;
+import static com.google.common.io.BaseEncoding.base64Url;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.AssertJUnit.assertEquals;
+
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.spec.InvalidKeySpecException;
+
+import org.testng.annotations.Test;
+
+/**
+ * Tests the SignOrProduceMacForToken
+ */
+@Test(groups = "unit")
+public class SignerFunctionTest {
+
+ private static final String PAYLOAD = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.\n" +
+ "eyJpc3MiOiI3NjEzMjY3OTgwNjktcjVtbGpsbG4xcmQ0bHJiaGc3NWVmZ2lncDM2bTc4ajVAZ" +
+ "GV2ZWxvcGVyLmdzZXJ2aWNlYWNjb3VudC5jb20iLCJzY29wZSI6Imh0dHBzOi8vd3d3Lmdvb2ds" +
+ "ZWFwaXMuY29tL2F1dGgvcHJlZGljdGlvbiIsImF1ZCI6Imh0dHBzOi8vYWNjb3VudHMuZ29vZ2x" +
+ "lLmNvbS9vL29hdXRoMi90b2tlbiIsImV4cCI6MTMyODU1NDM4NSwiaWF0IjoxMzI4NTUwNzg1fQ";
+
+ private static final String SHA256withRSA_PAYLOAD_SIGNATURE_RESULT =
+ "bmQrCv4gjkLWDK1JNJni74_kPiSDUMF_FImgqKJMUIgkDX1m2Sg3bH1yjF-cjBN7CvfAscnageo" +
+ "GtL2TGbwoTjJgUO5Yy0esavUUF-mBQHQtSw-2nL-9TNyM4SNi6fHPbgr83GGKOgA86r" +
+ "I9-nj3oUGd1fQty2k4Lsd-Zdkz6es";
+
+
+ public void testSignPayload() throws InvalidKeyException, IOException, NoSuchAlgorithmException,
+ CertificateException, InvalidKeySpecException {
+ SignOrProduceMacForToken signer = new SignOrProduceMacForToken("RS256",
+ ofInstance(OAuthCredentialsFromPKTest
+ .loadOAuthCredentials()));
+ signer.loadSignatureOrMacOrNone();
+ byte[] payloadSignature = signer.apply(PAYLOAD.getBytes(UTF_8));
+ assertNotNull(payloadSignature);
+
+ assertEquals(base64Url().omitPadding().encode(payloadSignature), SHA256withRSA_PAYLOAD_SIGNATURE_RESULT);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/handlers/OAuthErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/handlers/OAuthErrorHandlerTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/handlers/OAuthErrorHandlerTest.java
new file mode 100644
index 0000000..255c5c7
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/handlers/OAuthErrorHandlerTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.handlers;
+
+import org.easymock.IArgumentMatcher;
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import java.net.URI;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reportMatcher;
+import static org.easymock.EasyMock.verify;
+
+@Test(groups = "unit")
+public class OAuthErrorHandlerTest {
+
+ @Test
+ public void test409MakesIllegalStateException() {
+ assertCodeMakes(
+ "POST",
+ URI.create("http://oauth.org"),
+ 409,
+ "HTTP/1.1 409 Conflict",
+ "\"{\"code\":\"InvalidState\",\"message\":\"An incompatible transition has already been queued for this" +
+ " resource\"}\"",
+ IllegalStateException.class);
+ }
+
+ private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content,
+ Class<? extends Exception> expected) {
+ assertCodeMakes(method, uri, statusCode, message, "application/json", content, expected);
+ }
+
+ private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType,
+ String content, Class<? extends Exception> expected) {
+
+ OAuthErrorHandler function = new OAuthErrorHandler();
+
+ HttpCommand command = createMock(HttpCommand.class);
+ HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build();
+ HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build();
+ response.getPayload().getContentMetadata().setContentType(contentType);
+
+ expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
+ command.setException(classEq(expected));
+
+ replay(command);
+
+ function.handleError(command, response);
+
+ verify(command);
+ }
+
+ public static Exception classEq(final Class<? extends Exception> in) {
+ reportMatcher(new IArgumentMatcher() {
+
+ @Override
+ public void appendTo(StringBuffer buffer) {
+ buffer.append("classEq(");
+ buffer.append(in);
+ buffer.append(")");
+ }
+
+ @Override
+ public boolean matches(Object arg) {
+ return arg.getClass() == in;
+ }
+
+ });
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/Base64UrlSafeTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/Base64UrlSafeTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/Base64UrlSafeTest.java
new file mode 100644
index 0000000..f6d938a
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/Base64UrlSafeTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.internal;
+
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.io.BaseEncoding.base64Url;
+import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Test;
+
+/**
+ * Tests that the Base64 implementations used to Base64 encode the tokens are Url safe.
+ */
+@Test(groups = "unit")
+public class Base64UrlSafeTest {
+
+ public static final String STRING_THAT_GENERATES_URL_UNSAFE_BASE64_ENCODING = "§1234567890'+±!\"#$%&/()"
+ + "=?*qwertyuiopº´WERTYUIOPªàsdfghjklç~ASDFGHJKLÇ^<zxcvbnm,.->ZXCVBNM;:_@€";
+
+ public void testUsedBase64IsUrlSafe() {
+ String encoded = base64Url().omitPadding().encode(STRING_THAT_GENERATES_URL_UNSAFE_BASE64_ENCODING.getBytes(UTF_8));
+ assertTrue(!encoded.contains("+"));
+ assertTrue(!encoded.contains("/"));
+ assertTrue(!encoded.endsWith("="));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthApiExpectTest.java
new file mode 100644
index 0000000..a44bad1
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthApiExpectTest.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.internal;
+
+import org.jclouds.oauth.v2.OAuthApi;
+
+public class BaseOAuthApiExpectTest extends BaseOAuthExpectTest<OAuthApi> {
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthApiLiveTest.java
new file mode 100644
index 0000000..ba1c616
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthApiLiveTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.oauth.v2.OAuthTestUtils.setCredential;
+import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE;
+import static org.jclouds.oauth.v2.config.OAuthProperties.SCOPES;
+import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM;
+
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.oauth.v2.OAuthApi;
+import org.testng.annotations.Test;
+
+
+@Test(groups = "live")
+public class BaseOAuthApiLiveTest extends BaseApiLiveTest<OAuthApi> {
+
+ public BaseOAuthApiLiveTest() {
+ provider = "oauth";
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties props = super.setupProperties();
+ setCredential(props, "oauth.credential");
+ checkNotNull(setIfTestSystemPropertyPresent(props, "oauth.endpoint"), "test.oauth.endpoint must be set");
+ checkNotNull(setIfTestSystemPropertyPresent(props, AUDIENCE), "test.jclouds.oauth.audience must be set");
+ setIfTestSystemPropertyPresent(props, SCOPES);
+ setIfTestSystemPropertyPresent(props, SIGNATURE_OR_MAC_ALGORITHM);
+ return props;
+ }
+
+ protected long nowInSeconds() {
+ return TimeUnit.SECONDS.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthAuthenticatedApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthAuthenticatedApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthAuthenticatedApiLiveTest.java
new file mode 100644
index 0000000..aefdcdd
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthAuthenticatedApiLiveTest.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.internal;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE;
+import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM;
+import static org.testng.Assert.assertNotNull;
+
+import java.io.Closeable;
+import java.util.Properties;
+
+import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.config.ValueOfConfigurationKeyOrNull;
+import org.jclouds.oauth.v2.OAuthApi;
+import org.jclouds.oauth.v2.OAuthConstants;
+import org.jclouds.oauth.v2.domain.ClaimSet;
+import org.jclouds.oauth.v2.domain.Header;
+import org.jclouds.oauth.v2.domain.Token;
+import org.jclouds.oauth.v2.domain.TokenRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.reflect.TypeToken;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.Module;
+
+/**
+ * A base test of oauth authenticated rest providers. Providers must set the following properties:
+ * <p/>
+ * - oauth.endpoint
+ * - oauth.audience
+ * - oauth.signature-or-mac-algorithm
+ * <p/>
+ * - oauth.scopes is provided by the subclass
+ * <p/>
+ * This test asserts that a provider can authenticate with oauth for a given scope, or more simply
+ * that authentication/authorization is working.
+ */
+
+@Test(groups = "live")
+public abstract class BaseOAuthAuthenticatedApiLiveTest<A extends Closeable> extends BaseApiLiveTest<A> {
+
+ protected abstract String getScopes();
+
+ private OAuthApi oauthApi;
+
+ public void testAuthenticate() {
+ // obtain the necessary properties from the context
+ String signatureAlgorithm = checkNotNull(propFunction.apply(SIGNATURE_OR_MAC_ALGORITHM),
+ SIGNATURE_OR_MAC_ALGORITHM);
+
+ checkState(OAuthConstants.OAUTH_ALGORITHM_NAMES_TO_SIGNATURE_ALGORITHM_NAMES.containsKey(signatureAlgorithm)
+ , String.format("Algorithm not supported: " + signatureAlgorithm));
+
+ String audience = checkNotNull(propFunction.apply(AUDIENCE), AUDIENCE);
+
+ // obtain the scopes from the subclass
+ String scopes = getScopes();
+
+ Header header = Header.builder().signerAlgorithm(signatureAlgorithm).type("JWT").build();
+
+ long now = SECONDS.convert(System.currentTimeMillis(), MILLISECONDS);
+
+ ClaimSet claimSet = ClaimSet.builder()
+ .addClaim("aud", audience)
+ .addClaim("scope", scopes)
+ .addClaim("iss", identity)
+ .emissionTime(now)
+ .expirationTime(now + 3600).build();
+
+ TokenRequest tokenRequest = TokenRequest.builder().header(header).claimSet(claimSet).build();
+
+ Token token = oauthApi.authenticate(tokenRequest);
+
+ assertNotNull(token, "no token when authenticating " + tokenRequest);
+ }
+
+ @SuppressWarnings({ "unchecked", "serial" })
+ protected A create(Properties props, Iterable<Module> modules) {
+ Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
+ propFunction = injector.getInstance(ValueOfConfigurationKeyOrNull.class);
+ try {
+ oauthApi = injector.getInstance(OAuthApi.class);
+ } catch (Exception e) {
+ throw new IllegalStateException("Provider has no OAuthApi bound. Was the OAuthAuthenticationModule added?");
+ }
+ return (A) injector.getInstance(Key.get(new TypeToken<A>(getClass()) {
+ }.getType()));
+ }
+
+ private Function<String, String> propFunction;
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthExpectTest.java
new file mode 100644
index 0000000..18fe151
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/internal/BaseOAuthExpectTest.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.internal;
+
+import org.jclouds.rest.internal.BaseRestApiExpectTest;
+
+public class BaseOAuthExpectTest<T> extends BaseRestApiExpectTest<T> {
+
+ public BaseOAuthExpectTest() {
+ provider = "oauth";
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/json/JWTTokenRequestFormatTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/json/JWTTokenRequestFormatTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/json/JWTTokenRequestFormatTest.java
new file mode 100644
index 0000000..fa3307f
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/json/JWTTokenRequestFormatTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.json;
+
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.jclouds.ContextBuilder;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.oauth.v2.OAuthApiMetadata;
+import org.jclouds.oauth.v2.OAuthTestUtils;
+import org.jclouds.oauth.v2.domain.ClaimSet;
+import org.jclouds.oauth.v2.domain.Header;
+import org.jclouds.oauth.v2.domain.TokenRequest;
+import org.jclouds.oauth.v2.domain.TokenRequestFormat;
+import org.jclouds.util.Strings2;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
+
+@Test(groups = "unit")
+public class JWTTokenRequestFormatTest {
+ public static final String STRING_THAT_GENERATES_URL_UNSAFE_BASE64_ENCODING = "§1234567890'+±!\"#$%&/()" +
+ "=?*qwertyuiopº´WERTYUIOPªàsdfghjklç~ASDFGHJKLÇ^<zxcvbnm," +
+ ".->ZXCVBNM;:_@€";
+
+ public void testPayloadIsUrlSafe() throws IOException {
+
+ TokenRequestFormat tokenRequestFormat = ContextBuilder.newBuilder(new OAuthApiMetadata()).overrides
+ (OAuthTestUtils.defaultProperties(null)).build().utils()
+ .injector().getInstance(TokenRequestFormat.class);
+ Header header = new Header.Builder().signerAlgorithm("a").type("b").build();
+ ClaimSet claimSet = new ClaimSet.Builder().addClaim("ist", STRING_THAT_GENERATES_URL_UNSAFE_BASE64_ENCODING)
+ .build();
+ TokenRequest tokenRequest = new TokenRequest.Builder().claimSet(claimSet).header(header).build();
+ HttpRequest request = tokenRequestFormat.formatRequest(HttpRequest.builder().method("GET").endpoint
+ ("http://localhost").build(), tokenRequest);
+
+ assertNotNull(request.getPayload());
+
+ String payload = Strings2.toStringAndClose(request.getPayload().getInput());
+
+ // make sure the paylod is in the format {header}.{claims}.{signature}
+ Iterable<String> parts = Splitter.on(".").split(payload);
+
+ assertSame(Iterables.size(parts), 3);
+
+ assertTrue(!payload.contains("+"));
+ assertTrue(!payload.contains("/"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/parse/ParseTokenTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/parse/ParseTokenTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/parse/ParseTokenTest.java
new file mode 100644
index 0000000..bcaa9e4
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/oauth/v2/parse/ParseTokenTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.parse;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.oauth.v2.domain.Token;
+import org.testng.annotations.Test;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+@Test(groups = "unit")
+public class ParseTokenTest extends BaseItemParserTest<Token> {
+
+ @Override
+ public String resource() {
+ return "/tokenResponse.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Token expected() {
+ return Token.builder().expiresIn(3600).tokenType("Bearer").accessToken
+ ("1/8xbJqaOZXSUZbHLl5EOtu1pxz3fmmetKx9W8CV4t79M").build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/GoogleComputeEngineServiceExpectTest/firewall_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/GoogleComputeEngineServiceExpectTest/firewall_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/GoogleComputeEngineServiceExpectTest/firewall_list.json
new file mode 100644
index 0000000..c965349
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/GoogleComputeEngineServiceExpectTest/firewall_list.json
@@ -0,0 +1,37 @@
+{
+ "kind": "compute#firewallList",
+ "id": "projects/google/firewalls",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/google/global/firewalls",
+ "items": [
+ {
+
+ "kind": "compute#firewall",
+ "id": "12862241031274216284",
+ "creationTimestamp": "2012-04-13T03:05:02.855",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test-delete",
+ "name": "jclouds-test-delete",
+ "description": "Internal traffic from default allowed",
+ "network": "https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test-delete",
+ "sourceRanges": [
+ "10.0.0.0/8"
+ ],
+ "allowed": [
+ {
+ "IPProtocol": "tcp",
+ "ports": [
+ "1-65535"
+ ]
+ },
+ {
+ "IPProtocol": "udp",
+ "ports": [
+ "1-65535"
+ ]
+ },
+ {
+ "IPProtocol": "icmp"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/GoogleComputeEngineServiceExpectTest/network_get.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/GoogleComputeEngineServiceExpectTest/network_get.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/GoogleComputeEngineServiceExpectTest/network_get.json
new file mode 100644
index 0000000..e9308f0
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/GoogleComputeEngineServiceExpectTest/network_get.json
@@ -0,0 +1,10 @@
+{
+ "kind": "compute#network",
+ "id": "13024414170909937976",
+ "creationTimestamp": "2012-10-24T20:13:19.967",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test-delete",
+ "name": "jclouds-test-delete",
+ "description": "Default network for the project",
+ "IPv4Range": "10.0.0.0/8",
+ "gatewayIPv4": "10.0.0.1"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/address_get.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/address_get.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/address_get.json
new file mode 100644
index 0000000..f93e497
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/address_get.json
@@ -0,0 +1,12 @@
+{
+
+ "kind": "compute#address",
+ "id": "4439373783165447583",
+ "creationTimestamp": "2013-07-26T13:57:20.204-07:00",
+ "status": "RESERVED",
+ "region": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1",
+ "name": "test-ip1",
+ "description": "",
+ "address": "173.255.115.190",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/address_insert.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/address_insert.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/address_insert.json
new file mode 100644
index 0000000..4bccf63
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/address_insert.json
@@ -0,0 +1 @@
+{"name":"test-ip1"}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/address_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/address_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/address_list.json
new file mode 100644
index 0000000..cbfa9d5
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/address_list.json
@@ -0,0 +1,31 @@
+{
+ "kind": "compute#addressList",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses",
+ "id": "projects/myproject/regions/us-central1/addresses",
+ "items": [
+ {
+
+ "kind": "compute#address",
+ "id": "4439373783165447583",
+ "creationTimestamp": "2013-07-26T13:57:20.204-07:00",
+ "status": "RESERVED",
+ "region": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1",
+ "name": "test-ip1",
+ "description": "",
+ "address": "173.255.115.190",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1"
+ },
+ {
+
+ "kind": "compute#address",
+ "id": "4881363978908129158",
+ "creationTimestamp": "2013-07-26T14:08:21.552-07:00",
+ "status": "RESERVED",
+ "region": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1",
+ "name": "test-ip2",
+ "description": "",
+ "address": "173.255.118.115",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip2"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_create_snapshot.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_create_snapshot.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_create_snapshot.json
new file mode 100644
index 0000000..6499744
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_create_snapshot.json
@@ -0,0 +1 @@
+{"name":"test-snap"}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_get.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_get.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_get.json
new file mode 100644
index 0000000..88ddd54
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_get.json
@@ -0,0 +1,10 @@
+{
+ "kind": "compute#disk",
+ "id": "13050421646334304115",
+ "creationTimestamp": "2012-11-25T01:38:48.306",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1",
+ "name": "testimage1",
+ "sizeGb": "1",
+ "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a",
+ "status": "READY"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_insert.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_insert.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_insert.json
new file mode 100644
index 0000000..8699cdd
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_insert.json
@@ -0,0 +1 @@
+{"name":"testimage1","sizeGb":1}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_list.json
new file mode 100644
index 0000000..bdca33d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/disk_list.json
@@ -0,0 +1,17 @@
+{
+ "kind": "compute#diskList",
+ "id": "projects/myproject/zones/us-central1-a/disks",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks",
+ "items": [
+ {
+ "kind": "compute#disk",
+ "id": "13050421646334304115",
+ "creationTimestamp": "2012-11-25T01:38:48.306",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1",
+ "name": "testimage1",
+ "sizeGb": "1",
+ "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a",
+ "status": "READY"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/firewall_get.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/firewall_get.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/firewall_get.json
new file mode 100644
index 0000000..74ced74
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/firewall_get.json
@@ -0,0 +1,30 @@
+{
+
+ "kind": "compute#firewall",
+ "id": "12862241031274216284",
+ "creationTimestamp": "2012-04-13T03:05:02.855",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test",
+ "name": "jclouds-test",
+ "description": "Internal traffic from default allowed",
+ "network": "https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test",
+ "sourceRanges": [
+ "10.0.0.0/8"
+ ],
+ "allowed": [
+ {
+ "IPProtocol": "tcp",
+ "ports": [
+ "1-65535"
+ ]
+ },
+ {
+ "IPProtocol": "udp",
+ "ports": [
+ "1-65535"
+ ]
+ },
+ {
+ "IPProtocol": "icmp"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/firewall_insert.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/firewall_insert.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/firewall_insert.json
new file mode 100644
index 0000000..fabe1bd
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/firewall_insert.json
@@ -0,0 +1 @@
+{"name":"%s","network":"https://www.googleapis.com/compute/v1/projects/myproject/global/networks/%s","sourceRanges":[%s],"sourceTags":[%s],"targetTags":[%s],"allowed":[{"IPProtocol":"tcp","ports":[%s]}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/firewall_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/firewall_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/firewall_list.json
new file mode 100644
index 0000000..ab7d0b7
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/firewall_list.json
@@ -0,0 +1,58 @@
+{
+ "kind": "compute#firewallList",
+ "id": "projects/google/firewalls",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/google/global/firewalls",
+ "items": [
+ {
+
+ "kind": "compute#firewall",
+ "id": "12862241031274216284",
+ "creationTimestamp": "2012-04-13T03:05:02.855",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test",
+ "name": "jclouds-test",
+ "description": "Internal traffic from default allowed",
+ "network": "https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test",
+ "sourceRanges": [
+ "10.0.0.0/8"
+ ],
+ "allowed": [
+ {
+ "IPProtocol": "tcp",
+ "ports": [
+ "1-65535"
+ ]
+ },
+ {
+ "IPProtocol": "udp",
+ "ports": [
+ "1-65535"
+ ]
+ },
+ {
+ "IPProtocol": "icmp"
+ }
+ ]
+ },
+ {
+
+ "kind": "compute#firewall",
+ "id": "12862241067393040785",
+ "creationTimestamp": "2012-04-13T03:05:04.365",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/google/global/firewalls/default-ssh",
+ "name": "default-ssh",
+ "description": "SSH allowed from anywhere",
+ "network": "https://www.googleapis.com/compute/v1/projects/google/global/networks/default",
+ "sourceRanges": [
+ "0.0.0.0/0"
+ ],
+ "allowed": [
+ {
+ "IPProtocol": "tcp",
+ "ports": [
+ "22"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/global_operation.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/global_operation.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/global_operation.json
new file mode 100644
index 0000000..17d77483
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/global_operation.json
@@ -0,0 +1,15 @@
+{
+ "kind": "compute#operation",
+ "id": "13053095055850848306",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "targetLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test-delete",
+ "targetId": "13053094017547040099",
+ "status": "DONE",
+ "user": "user@developer.gserviceaccount.com",
+ "progress": 100,
+ "insertTime": "2012-11-28T06:41:05.060",
+ "startTime": "2012-11-28T06:41:05.142",
+ "endTime": "2012-11-28T06:41:06.142",
+ "operationType": "insert"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/global_operation_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/global_operation_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/global_operation_list.json
new file mode 100644
index 0000000..32b881a
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/global_operation_list.json
@@ -0,0 +1,22 @@
+{
+ "kind": "compute#operationList",
+ "id": "projects/myproject/global/operations",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/operations",
+ "items": [
+ {
+ "kind": "compute#operation",
+ "id": "13053095055850848306",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "targetLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test-delete",
+ "targetId": "13053094017547040099",
+ "status": "DONE",
+ "user": "user@developer.gserviceaccount.com",
+ "progress": 100,
+ "insertTime": "2012-11-28T06:41:05.060",
+ "startTime": "2012-11-28T06:41:05.142",
+ "endTime": "2012-11-28T06:41:06.142",
+ "operationType": "insert"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_get.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_get.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_get.json
new file mode 100644
index 0000000..23cb0d2
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_get.json
@@ -0,0 +1,13 @@
+{
+ "kind": "compute#image",
+ "id": "12941197498378735318",
+ "creationTimestamp": "2012-07-16T22:16:13.468",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120326",
+ "name": "centos-6-2-v20120326",
+ "description": "DEPRECATED. CentOS 6.2 image; Created Mon, 26 Mar 2012 21:19:09 +0000",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_insert.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_insert.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_insert.json
new file mode 100644
index 0000000..fd030a7
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_insert.json
@@ -0,0 +1,4 @@
+{"sourceType": "RAW", "rawDisk": {
+ "source": "https://storage.googleapis.com/mybuket/myimage.image.tar.gz",
+ "containerType": "TAR"
+}, "kind": "compute#image", "name": "myimage"}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list.json
new file mode 100644
index 0000000..6010f5a
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list.json
@@ -0,0 +1,24 @@
+{
+ "kind": "compute#imageList",
+ "id": "projects/centos-cloud/global/images",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images",
+ "items": [
+ {
+ "kind": "compute#image",
+ "id": "12941197498378735318",
+ "creationTimestamp": "2012-07-16T22:16:13.468",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120326",
+ "name": "centos-6-2-v20120326",
+ "description": "DEPRECATED. CentOS 6.2 image; Created Mon, 26 Mar 2012 21:19:09 +0000",
+ "sourceType": "RAW",
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20130104"
+ },
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ }
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_centos.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_centos.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_centos.json
new file mode 100644
index 0000000..55e1b21
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_centos.json
@@ -0,0 +1,183 @@
+{
+ "kind": "compute#imageList",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images",
+ "id": "projects/centos-cloud/global/images",
+ "items": [
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20131120",
+ "id": "11748647391859510935",
+ "creationTimestamp": "2013-11-25T15:13:50.611-08:00",
+ "name": "centos-6-v20131120",
+ "description": "SCSI-enabled CentOS 6 built on 2013-11-20",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140318"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "269993565",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140318",
+ "id": "11743140967858608122",
+ "creationTimestamp": "2014-03-19T15:01:13.388-07:00",
+ "name": "centos-6-v20140318",
+ "description": "CentOS 6.5 x86_64 built on 2014-03-18",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140408"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "341230444",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140408",
+ "id": "18033188469723077298",
+ "creationTimestamp": "2014-04-09T10:31:57.518-07:00",
+ "name": "centos-6-v20140408",
+ "description": "CentOS 6.5 x86_64 built on 2014-04-08",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140415"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "342252847",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140415",
+ "id": "10463166969914166288",
+ "creationTimestamp": "2014-04-22T12:05:16.927-07:00",
+ "name": "centos-6-v20140415",
+ "description": "CentOS 6.5 x86_64 built on 2014-04-15",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140522"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1026663807",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140522",
+ "id": "14390164727436022001",
+ "creationTimestamp": "2014-06-03T10:21:42.109-07:00",
+ "name": "centos-6-v20140522",
+ "description": "CentOS 6.5 x86_64 built on 2014-05-22",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140606"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1028292810",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140605",
+ "id": "16310166269920012092",
+ "creationTimestamp": "2014-06-05T11:04:45.767-07:00",
+ "name": "centos-6-v20140605",
+ "description": "CentOS 6.5 x86_64 built on 2014-06-05",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140606"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1028745777",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140606",
+ "id": "6290630306542078308",
+ "creationTimestamp": "2014-06-06T13:16:42.265-07:00",
+ "name": "centos-6-v20140606",
+ "description": "CentOS 6.5 x86_64 built on 2014-06-06",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140619"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1028757792",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140619",
+ "id": "3614861379648377676",
+ "creationTimestamp": "2014-06-24T13:28:11.552-07:00",
+ "name": "centos-6-v20140619",
+ "description": "CentOS 6.5 x86_64 built on 2014-06-19",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140718"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1029860991",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140718",
+ "id": "16259951858818091437",
+ "creationTimestamp": "2014-07-24T09:02:18.298-07:00",
+ "name": "centos-6-v20140718",
+ "description": "CentOS 6.5 x86_64 built on 2014-07-18",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1031630715",
+ "diskSizeGb": "10"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_debian.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_debian.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_debian.json
new file mode 100644
index 0000000..c2614c9
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_debian.json
@@ -0,0 +1,400 @@
+{
+ "kind": "compute#imageList",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images",
+ "id": "projects/debian-cloud/global/images",
+ "items": [
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20131127",
+ "id": "12371298324486102144",
+ "creationTimestamp": "2013-12-02T17:49:01.206-08:00",
+ "name": "backports-debian-7-wheezy-v20131127",
+ "description": "Debian GNU/Linux 7.2 (wheezy) with backports kernel built on 2013-11-27",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140318"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "365056004",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140318",
+ "id": "4359542978415320596",
+ "creationTimestamp": "2014-03-19T14:59:48.212-07:00",
+ "name": "backports-debian-7-wheezy-v20140318",
+ "description": "Debian GNU/Linux 7.4 (wheezy) amd64 with backports kernel built on 2014-03-18",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140331"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "363791902",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140331",
+ "id": "15835408046770346721",
+ "creationTimestamp": "2014-04-02T13:22:10.344-07:00",
+ "name": "backports-debian-7-wheezy-v20140331",
+ "description": "Debian GNU/Linux 7.4 (wheezy) amd64 with backports kernel and SSH packages built on 2014-03-31",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140408"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "442398181",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140408",
+ "id": "11347897274148340677",
+ "creationTimestamp": "2014-04-09T10:34:36.072-07:00",
+ "name": "backports-debian-7-wheezy-v20140408",
+ "description": "Debian GNU/Linux 7.4 (wheezy) amd64 with backports kernel and SSH packages built on 2014-04-08",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140415"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "460293681",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140415",
+ "id": "1961353585117201359",
+ "creationTimestamp": "2014-04-22T12:05:21.799-07:00",
+ "name": "backports-debian-7-wheezy-v20140415",
+ "description": "Debian GNU/Linux 7.4 (wheezy) amd64 with backports kernel and SSH packages built on 2014-04-15",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140522"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1305361944",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140522",
+ "id": "9086860851120583043",
+ "creationTimestamp": "2014-06-03T10:22:40.439-07:00",
+ "name": "backports-debian-7-wheezy-v20140522",
+ "description": "Debian GNU/Linux 7.5 (wheezy) amd64 with backports kernel and SSH packages built on 2014-05-22",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140606"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1291544127",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140605",
+ "id": "3162880700849242534",
+ "creationTimestamp": "2014-06-05T11:15:06.942-07:00",
+ "name": "backports-debian-7-wheezy-v20140605",
+ "description": "Debian GNU/Linux 7.5 (wheezy) amd64 with backports kernel and SSH packages built on 2014-06-05",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140606"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1342678611",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140606",
+ "id": "10385475893990329896",
+ "creationTimestamp": "2014-06-06T13:16:42.088-07:00",
+ "name": "backports-debian-7-wheezy-v20140606",
+ "description": "Debian GNU/Linux 7.5 (wheezy) amd64 with backports kernel and SSH packages built on 2014-06-06",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140619"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1356729999",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140619",
+ "id": "15689321734978914353",
+ "creationTimestamp": "2014-06-24T13:29:10.490-07:00",
+ "name": "backports-debian-7-wheezy-v20140619",
+ "description": "Debian GNU/Linux 7.5 (wheezy) amd64 with backports kernel and SSH packages built on 2014-06-19",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140718"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1281043596",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140718",
+ "id": "12577251946941921963",
+ "creationTimestamp": "2014-07-24T09:10:05.365-07:00",
+ "name": "backports-debian-7-wheezy-v20140718",
+ "description": "Debian GNU/Linux 7.6 (wheezy) amd64 with backports kernel and SSH packages built on 2014-07-18",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1335987075",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20131014",
+ "id": "2768298251193329825",
+ "creationTimestamp": "2013-10-28T13:52:08.233-07:00",
+ "name": "debian-7-wheezy-v20131014",
+ "description": "Debian GNU/Linux 7.2 (wheezy) built on 2013-10-14",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20131120",
+ "deprecated": "2013-12-02T12:00:00Z"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "405683884",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20131120",
+ "id": "17312518942796567788",
+ "creationTimestamp": "2013-11-25T15:17:00.436-08:00",
+ "name": "debian-7-wheezy-v20131120",
+ "description": "Debian GNU/Linux 7.2 (wheezy) built on 2013-11-20",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140318"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "341857472",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140318",
+ "id": "17164003659829548087",
+ "creationTimestamp": "2014-03-19T15:00:34.317-07:00",
+ "name": "debian-7-wheezy-v20140318",
+ "description": "Debian GNU/Linux 7.4 (wheezy) amd64 built on 2014-03-18",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140408"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "357365652",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140408",
+ "id": "5009074516965108296",
+ "creationTimestamp": "2014-04-09T10:32:46.862-07:00",
+ "name": "debian-7-wheezy-v20140408",
+ "description": "Debian GNU/Linux 7.4 (wheezy) amd64 built on 2014-04-08",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140415"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "387525228",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140415",
+ "id": "17362901286054305778",
+ "creationTimestamp": "2014-04-22T12:05:19.303-07:00",
+ "name": "debian-7-wheezy-v20140415",
+ "description": "Debian GNU/Linux 7.4 (wheezy) amd64 built on 2014-04-15",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140522"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1151530332",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140522",
+ "id": "5741466168076626639",
+ "creationTimestamp": "2014-06-03T10:22:05.775-07:00",
+ "name": "debian-7-wheezy-v20140522",
+ "description": "Debian GNU/Linux 7.5 (wheezy) amd64 built on 2014-05-22",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140606"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1129290498",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140605",
+ "id": "15036511115619902874",
+ "creationTimestamp": "2014-06-05T11:10:23.037-07:00",
+ "name": "debian-7-wheezy-v20140605",
+ "description": "Debian GNU/Linux 7.5 (wheezy) amd64 built on 2014-06-05",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140606"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1064425338",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140606",
+ "id": "16280724435269635469",
+ "creationTimestamp": "2014-06-06T13:16:42.897-07:00",
+ "name": "debian-7-wheezy-v20140606",
+ "description": "Debian GNU/Linux 7.5 (wheezy) amd64 built on 2014-06-06",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140619"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1108438332",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140619",
+ "id": "15990799122418306096",
+ "creationTimestamp": "2014-06-24T13:28:42.697-07:00",
+ "name": "debian-7-wheezy-v20140619",
+ "description": "Debian GNU/Linux 7.5 (wheezy) amd64 built on 2014-06-19",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140718"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1158839577",
+ "diskSizeGb": "10"
+ },
+ {
+ "kind": "compute#image",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140718",
+ "id": "11535450626613878896",
+ "creationTimestamp": "2014-07-24T09:06:16.694-07:00",
+ "name": "debian-7-wheezy-v20140718",
+ "description": "Debian GNU/Linux 7.6 (wheezy) amd64 built on 2014-07-18",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ },
+ "status": "READY",
+ "archiveSizeBytes": "1195066695",
+ "diskSizeGb": "10"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_empty.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_empty.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_empty.json
new file mode 100644
index 0000000..f082e08
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_empty.json
@@ -0,0 +1,6 @@
+{
+ "kind": "compute#imageList",
+ "id": "projects/debian-cloud/global/images",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images",
+ "items": [ ]
+}
[05/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java
new file mode 100644
index 0000000..b8e786c
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java
@@ -0,0 +1,318 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.http.functions.ReturnInputStream;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.util.Strings2;
+import org.jclouds.vcloud.domain.GuestCustomizationSection;
+import org.jclouds.vcloud.internal.BaseVCloudApiTest;
+import org.jclouds.vcloud.utils.TestUtils;
+import org.jclouds.vcloud.xml.TaskHandler;
+import org.jclouds.vcloud.xml.VmHandler;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code VmApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "VmApiTest")
+public class VmApiTest extends BaseVCloudApiTest<VmApi> {
+
+ public void testGetThumbnailOfVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "getScreenThumbnailForVm", URI.class);
+ GeneratedHttpRequest request = processor
+ .createRequest(method, ImmutableList.<Object> of(URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
+
+ assertRequestLineEquals(request, "GET http://vcloud.example.com/api/v1.0/vApp/vm-12/screen HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: image/png\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ReturnInputStream.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ @Test(dataProvider = "ignoreOnWindows", description = "see http://code.google.com/p/jclouds/issues/detail?id=402")
+ public void testUpdateGuestConfiguration() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "updateGuestCustomizationOfVm", GuestCustomizationSection.class,
+ URI.class);
+ GuestCustomizationSection guest = new GuestCustomizationSection(URI
+ .create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection"));
+ guest.setCustomizationScript("cat > /tmp/foo.txt<<EOF\nI love candy\nEOF");
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(guest, URI
+ .create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
+
+ assertRequestLineEquals(request,
+ "PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
+ "/guestCustomizationSection.xml")), "application/vnd.vmware.vcloud.guestCustomizationSection+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testUpdateCPUCountOfVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "updateCPUCountOfVm", int.class, URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, URI
+ .create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
+
+ assertRequestLineEquals(request,
+ "PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/virtualHardwareSection/cpu HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/cpuItem.xml")),
+ "application/vnd.vmware.vcloud.rasdItem+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testUpdateMemoryMBOfVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "updateMemoryMBOfVm", int.class, URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(512, URI
+ .create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
+
+ assertRequestLineEquals(request,
+ "PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/virtualHardwareSection/memory HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/memoryItem.xml")),
+ "application/vnd.vmware.vcloud.rasdItem+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testDeployVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "deployVm", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>",
+ "application/vnd.vmware.vcloud.deployVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testDeployAndPowerOnVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "deployAndPowerOnVm", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" powerOn=\"true\"/>",
+ "application/vnd.vmware.vcloud.deployVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testGetVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "getVm", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vm/1")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vm/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vm+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, VmHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testRebootVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "rebootVm", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reboot HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testUndeployVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "undeployVm", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>",
+ "application/vnd.vmware.vcloud.undeployVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testUndeployAndSaveStateOfVmSaveState() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "undeployAndSaveStateOfVm", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request,
+ "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" saveState=\"true\"/>",
+ "application/vnd.vmware.vcloud.undeployVAppParams+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testPowerOnVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "powerOnVm", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testPowerOffVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "powerOffVm", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testResetVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "resetVm", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testSuspendVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "suspendVm", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, TaskHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ public void testShutdownVm() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VmApi.class, "shutdownVm", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ @DataProvider
+ public Object[][] ignoreOnWindows() {
+ return TestUtils.isWindowsOs() ? TestUtils.NO_INVOCATIONS
+ : TestUtils.SINGLE_NO_ARG_INVOCATION;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java
new file mode 100644
index 0000000..40d1fd5
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.filters;
+
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.http.HttpRequest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.net.HttpHeaders;
+
+@Test(testName = "AddVCloudAuthorizationAndCookieToRequestTest")
+public class AddVCloudAuthorizationAndCookieToRequestTest {
+
+ private AddVCloudAuthorizationAndCookieToRequest filter;
+
+ @BeforeTest
+ void setUp() {
+ filter = new AddVCloudAuthorizationAndCookieToRequest(new Supplier<String>() {
+ public String get() {
+ return "token";
+ }
+ }, "1.0");
+ }
+
+ @Test
+ public void testApply() {
+ HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
+ request = filter.filter(request);
+ assertEquals(request.getHeaders().size(), 3);
+ assertEquals(request.getFirstHeaderOrNull(HttpHeaders.COOKIE), "vcloud-token=token");
+ assertEquals(request.getFirstHeaderOrNull("x-vcloud-authorization"), "token");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java
new file mode 100644
index 0000000..66a4f4a
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.VCloudSession;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests behavior of {@code ParseLoginResponseFromHeaders}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "ParseLoginResponseFromHeadersTest")
+public class ParseLoginResponseFromHeadersTest extends BaseHandlerTest {
+
+ private ParseLoginResponseFromHeaders parser;
+
+ @BeforeTest
+ void setUp() {
+ parser = injector.getInstance(ParseLoginResponseFromHeaders.class);
+ }
+
+ @Test
+ public void testApply() {
+ HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
+ .payload(getClass().getResourceAsStream("/orglist.xml"))
+ .addHeader("x-vcloud-authorization", "vcloud-token=9er4d061-4bff-48fa-84b1-5da7166764d2; path=/").build();
+ response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
+ response.getPayload().getContentMetadata().setContentLength(307l);
+
+ VCloudSession reply = parser.apply(response);
+ assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2");
+ assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
+ VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
+
+ }
+
+ @Test
+ public void testApplyBlueLock() {
+ HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
+ .payload(getClass().getResourceAsStream("/orglist.xml"))
+ .addHeader("x-vcloud-authorization", "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0=").build();
+ response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
+ response.getPayload().getContentMetadata().setContentLength(307l);
+
+ VCloudSession reply = parser.apply(response);
+ assertEquals(reply.getVCloudToken(), "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0=");
+ assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
+ VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
+
+ }
+
+ @Test
+ public void testApplyTerremark() {
+ HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
+ .payload(getClass().getResourceAsStream("/orglist.xml"))
+ .addHeader("Set-Cookie", "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/").build();
+ response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
+ response.getPayload().getContentMetadata().setContentLength(307l);
+
+ VCloudSession reply = parser.apply(response);
+ assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d");
+ assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
+ VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
+
+ }
+
+ @Test
+ public void testApplyTerremarkMultipleCookies() {
+ HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
+ .payload(getClass().getResourceAsStream("/orglist.xml"))
+ .addHeader("Set-Cookie", "NSC_ESUO_21654_72.46.239.132_443=fooo;expires=Thu, 02-Jun-2011 17:19:26 GMT;path=/;secure;httponly")
+ .addHeader("Set-Cookie", "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/").build();
+ response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
+ response.getPayload().getContentMetadata().setContentLength(307l);
+
+ VCloudSession reply = parser.apply(response);
+ assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d");
+ assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
+ VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
+
+ }
+
+ @Test(expectedExceptions = HttpResponseException.class)
+ public void testUnmatchedCookieThrowsHttpResponseException() {
+ HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
+ .payload(getClass().getResourceAsStream("/orglist.xml"))
+ .addHeader("Set-Cookie", "NSC_ESUO_21654_72.46.239.132_443=fooo;expires=Thu, 02-Jun-2011 17:19:26 GMT;path=/;secure;httponly").build();
+ response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
+ response.getPayload().getContentMetadata().setContentLength(307l);
+
+ parser.apply(response);
+ }
+
+ @Test(expectedExceptions = HttpResponseException.class)
+ public void testNoThrowsHttpResponseException() {
+ HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
+ .payload(getClass().getResourceAsStream("/orglist.xml")).build();
+ response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
+ response.getPayload().getContentMetadata().setContentLength(307l);
+
+ parser.apply(response);
+ }
+
+ @Test
+ public void testApplyVirtacore() {
+ HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
+ .payload(getClass().getResourceAsStream("/orglist.xml"))
+ .addHeader("x-vcloud-authorization", "vcloud-token=IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48=").build();
+ response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
+ response.getPayload().getContentMetadata().setContentLength(307l);
+
+ VCloudSession reply = parser.apply(response);
+ assertEquals(reply.getVCloudToken(), "IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48=");
+ assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
+ VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java
new file mode 100644
index 0000000..9466191
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.handlers;
+
+import java.net.URI;
+
+import org.jclouds.http.BaseHttpErrorHandlerTest;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.testng.annotations.Test;
+
+@Test(groups = { "unit" })
+public class ParseVCloudErrorFromHttpResponseTest extends BaseHttpErrorHandlerTest {
+
+ @Test
+ public void testGet404SetsResourceNotFoundException() {
+ assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 404,
+ "", "", ResourceNotFoundException.class);
+ }
+
+ @Test
+ public void testGet403NoAcessToEntitySetsResourceNotFoundException() {
+ assertCodeMakes(
+ "GET",
+ URI.create("https://zone01.bluelock.com/api/v1.0/vApp/vapp-1535788985"),
+ 403,
+ "HTTP/1.1 403",
+ VCloudMediaType.ERROR_XML,
+ "<Error xmlns=\"http://www.vmware.com/vcloud/v1\" minorErrorCode=\"ACCESS_TO_RESOURCE_IS_FORBIDDEN\" message=\"No access to entity "(com.vmware.vcloud.entity.vapp:1535788985)".\" majorErrorCode=\"403\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd\"></Error>\n",
+ ResourceNotFoundException.class);
+ }
+
+ @Test
+ public void testGet403NoAcessToEntitySetsResourceNotFoundExceptionOnAPI1_0AgainstVCD1_5() {
+ assertCodeMakes(
+ "GET",
+ URI.create("https://mycloud.greenhousedata.com/api/v1.0/vApp/vapp-d3a1f2cd-d07b-4ddc-bf7b-fb7468b4d95a"),
+ 403,
+ "HTTP/1.1 403",
+ // NOTE VCD 1.5 appends the api version to the media type
+ VCloudMediaType.ERROR_XML + ";1.0",
+ "<Error xmlns=\"http://www.vmware.com/vcloud/v1\" minorErrorCode=\"ACCESS_TO_RESOURCE_IS_FORBIDDEN\" message=\"No access to entity "(com.vmware.vcloud.entity.vapp:d3a1f2cd-d07b-4ddc-bf7b-fb7468b4d95a)".\" majorErrorCode=\"403\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.vmware.com/vcloud/v1 http://mycloud.greenhousedata.com/api/v1.0/schema/master.xsd\"></Error>",
+ ResourceNotFoundException.class);
+ }
+
+ @Test
+ public void testDelete404SetsHttpResponseException() {
+ assertCodeMakes("DELETE", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"),
+ 404, "", "", HttpResponseException.class);
+ }
+
+ @Test
+ public void testPOSTNotRunningSetsIllegalStateException() {
+ assertCodeMakes(
+ "POST",
+ URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-138351019/action/undeploy"),
+ 400,
+ "HTTP/1.1 400 Bad Request",
+ VCloudMediaType.ERROR_XML,
+ "<Error xmlns=\"http://www.vmware.com/vcloud/v1\" minorErrorCode=\"BAD_REQUEST\" message=\"The requested operation could not be executed since vApp "adriancolecap-78c" is not running"\" majorErrorCode=\"400\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd\"></Error>\n",
+ IllegalStateException.class);
+ }
+
+ @Test
+ public void test401SetsAuthorizationException() {
+ assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 401,
+ "", "", AuthorizationException.class);
+ }
+
+ @Override
+ protected Class<? extends HttpErrorHandler> getHandlerClass() {
+ return ParseVCloudErrorFromHttpResponse.class;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java
new file mode 100644
index 0000000..4ffe512
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.internal;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.net.URI;
+import java.util.List;
+
+import org.jclouds.reflect.Invocation;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.VCloudApiMetadata;
+import org.nnsoft.guice.rocoto.Rocoto;
+import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
+
+import com.google.common.base.Throwables;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class BasePayloadTest {
+
+ protected Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
+ protected void bindConfigurations() {
+ bindProperties(new VCloudApiMetadata().getDefaultProperties());
+ }
+ }));
+
+ protected GeneratedHttpRequest requestForArgs(List<Object> args) {
+ try {
+ Invocation invocation = Invocation.create(method(String.class, "toString"), args);
+ return GeneratedHttpRequest.builder().method("POST").endpoint(URI.create("http://localhost/key"))
+ .invocation(invocation).build();
+ } catch (SecurityException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java
new file mode 100644
index 0000000..a4db473
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.internal;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.jclouds.vcloud.VCloudApi;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.inject.Module;
+
+@Test(groups = "live", enabled = true, singleThreaded = true)
+public abstract class BaseVCloudApiLiveTest extends BaseComputeServiceContextLiveTest {
+
+ // username is too long for name constraints
+ protected String prefix = "vcd";
+
+ protected ComputeService client;
+
+ public BaseVCloudApiLiveTest() {
+ provider = "vcloud";
+ }
+
+ protected VCloudApi getVCloudApi() {
+ return view.unwrapApi(VCloudApi.class);
+ }
+
+ @Override
+ @BeforeClass(groups = { "integration", "live" })
+ public void setupContext() {
+ super.setupContext();
+ client = view.getComputeService();
+ }
+
+ @Override
+ protected Module getSshModule() {
+ return new SshjSshClientModule();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java
new file mode 100644
index 0000000..feeec7c
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java
@@ -0,0 +1,270 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.internal;
+
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.ovf.Envelope;
+import org.jclouds.ovf.xml.EnvelopeHandlerTest;
+import org.jclouds.providers.AnonymousProviderMetadata;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.jclouds.rest.internal.BaseRestAnnotationProcessingTest;
+import org.jclouds.vcloud.VCloudApiMetadata;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.VCloudVersionsApi;
+import org.jclouds.vcloud.config.VCloudHttpApiModule;
+import org.jclouds.vcloud.domain.AllocationModel;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.domain.VCloudSession;
+import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.domain.VDCStatus;
+import org.jclouds.vcloud.domain.internal.CatalogImpl;
+import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
+import org.jclouds.vcloud.domain.internal.OrgImpl;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.internal.VDCImpl;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+import org.jclouds.vcloud.xml.VAppTemplateHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Functions;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.cache.CacheLoader;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.AbstractModule;
+import com.google.inject.Module;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Tests behavior of {@code VCloudApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "BaseVCloudApiTest")
+public abstract class BaseVCloudApiTest<T> extends BaseRestAnnotationProcessingTest<T> {
+
+ @Override
+ protected void checkFilters(HttpRequest request) {
+ assertEquals(request.getFilters().size(), 1);
+ assertEquals(request.getFilters().get(0).getClass(), AddVCloudAuthorizationAndCookieToRequest.class);
+ }
+
+ @Override
+ protected Module createModule() {
+ return new VCloudHttpApiModuleExtension();
+ }
+
+ @Override
+ protected ProviderMetadata createProviderMetadata() {
+ return AnonymousProviderMetadata.forApiWithEndpoint(new VCloudApiMetadata(), "https://vcenterprise.bluelock.com/api/v1.0");
+ }
+
+ protected static final ReferenceTypeImpl ORG_REF = new ReferenceTypeImpl("org", VCloudMediaType.ORG_XML,
+ URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"));
+
+ protected static final ReferenceTypeImpl CATALOG_REF = new ReferenceTypeImpl("catalog", VCloudMediaType.CATALOG_XML,
+ URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"));
+
+ protected static final ReferenceTypeImpl TASKSLIST_REF = new ReferenceTypeImpl("tasksList",
+ VCloudMediaType.TASKSLIST_XML, URI.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"));
+
+ protected static final ReferenceTypeImpl VDC_REF = new ReferenceTypeImpl("vdc", VCloudMediaType.VDC_XML,
+ URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"));
+
+ protected static final ReferenceTypeImpl NETWORK_REF = new ReferenceTypeImpl("network", VCloudMediaType.NETWORK_XML,
+ URI.create("https://vcloud.safesecureweb.com/network/1990"));
+
+ protected static final Org ORG = new OrgImpl(ORG_REF.getName(), ORG_REF.getType(), ORG_REF.getHref(), "org", null,
+ ImmutableMap.<String, ReferenceType> of(CATALOG_REF.getName(), CATALOG_REF),
+ ImmutableMap.<String, ReferenceType> of(VDC_REF.getName(), VDC_REF), ImmutableMap.<String, ReferenceType> of(
+ NETWORK_REF.getName(), NETWORK_REF), TASKSLIST_REF, ImmutableList.<Task> of());
+
+ protected static final VDC VDC = new VDCImpl(VDC_REF.getName(), VDC_REF.getType(), VDC_REF.getHref(),
+ VDCStatus.READY, null, "description", ImmutableSet.<Task> of(), AllocationModel.ALLOCATION_POOL, null, null,
+ null, ImmutableMap.<String, ReferenceType> of(
+ "vapp",
+ new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")),
+ "network",
+ new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))),
+ ImmutableMap.<String, ReferenceType> of(NETWORK_REF.getName(), NETWORK_REF), 0, 0, 0, false);
+
+ @ConfiguresHttpApi
+ public static class VCloudHttpApiModuleExtension extends VCloudHttpApiModule {
+
+ @Override
+ protected Supplier<URI> provideAuthenticationURI(VCloudVersionsApi versionService, String version) {
+ return Suppliers.ofInstance(URI.create("https://vcenterprise.bluelock.com/api/v1.0/login"));
+ }
+
+ @Override
+ protected Supplier<Org> provideOrg(Supplier<Map<String, Org>> orgSupplier,
+ @org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg) {
+ return Suppliers.ofInstance(ORG);
+ }
+
+ @Override
+ protected void installDefaultVCloudEndpointsModule() {
+ install(new AbstractModule() {
+
+ @Override
+ protected void configure() {
+ TypeLiteral<Supplier<ReferenceType>> refTypeSupplier = new TypeLiteral<Supplier<ReferenceType>>() {
+ };
+ bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Org.class).toInstance(
+ Suppliers.<ReferenceType> ofInstance(ORG_REF));
+ bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Catalog.class).toInstance(
+ Suppliers.<ReferenceType> ofInstance(CATALOG_REF));
+ bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.TasksList.class).toInstance(
+ Suppliers.<ReferenceType> ofInstance(TASKSLIST_REF));
+ bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.VDC.class).toInstance(
+ Suppliers.<ReferenceType> ofInstance(VDC_REF));
+ bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Network.class).toInstance(
+ Suppliers.<ReferenceType> ofInstance(NETWORK_REF));
+ }
+
+ });
+ }
+
+ @Override
+ protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
+ AtomicReference<AuthorizationException> authException, final VCloudLoginApi login) {
+ return Suppliers.<VCloudSession> ofInstance(new VCloudSession() {
+
+ @Override
+ public Map<String, ReferenceType> getOrgs() {
+ return ImmutableMap.<String, ReferenceType> of(ORG_REF.getName(), ORG_REF);
+ }
+
+ @Override
+ public String getVCloudToken() {
+ return "token";
+ }
+
+ });
+
+ }
+
+ @Override
+ protected void configure() {
+ super.configure();
+ bind(OrgMapSupplier.class).to(TestOrgMapSupplier.class);
+ bind(OrgCatalogSupplier.class).to(TestOrgCatalogSupplier.class);
+ bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void bindCacheLoaders() {
+ bind(new TypeLiteral<CacheLoader<URI, VAppTemplate>>() {
+ }).toInstance(CacheLoader.class.cast(CacheLoader.from(Functions.constant(VAppTemplateHandlerTest.parseTemplate()))));
+
+ bind(new TypeLiteral<CacheLoader<URI, Envelope>>() {
+ }).toInstance(CacheLoader.class.cast(CacheLoader.from(Functions.constant(EnvelopeHandlerTest.parseEnvelope()))));
+ }
+
+ @Override
+ protected Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
+ @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
+ OrgVDCSupplier supplier) {
+ return Suppliers.<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
+ .<String, Map<String, org.jclouds.vcloud.domain.VDC>> of(ORG_REF.getName(),
+ ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(VDC.getName(), VDC)));
+ }
+
+ @Singleton
+ public static class TestOrgMapSupplier extends OrgMapSupplier {
+
+ @Inject
+ protected TestOrgMapSupplier() {
+ super(null, null);
+ }
+
+ @Override
+ public Map<String, Org> get() {
+ return ImmutableMap.<String, Org> of(ORG.getName(), ORG);
+ }
+ }
+
+ @Singleton
+ public static class TestOrgCatalogSupplier extends OrgCatalogSupplier {
+ @Inject
+ protected TestOrgCatalogSupplier() {
+ super(null, null);
+ }
+
+ @Override
+ public Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>> get() {
+ return ImmutableMap.<String, Map<String, org.jclouds.vcloud.domain.Catalog>> of(
+ ORG_REF.getName(), ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of(
+ CATALOG_REF.getName(),
+ new CatalogImpl(CATALOG_REF.getName(), CATALOG_REF.getType(), CATALOG_REF.getHref(), null,
+ "description", ImmutableMap.<String, ReferenceType> of(
+ "item",
+ new ReferenceTypeImpl("item", "application/vnd.vmware.vcloud.catalogItem+xml", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")),
+ "template",
+ new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml",
+ URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))),
+ ImmutableList.<Task> of(), true, false)));
+ }
+ }
+
+ @Singleton
+ public static class TestOrgCatalogItemSupplier extends OrgCatalogItemSupplier {
+ protected TestOrgCatalogItemSupplier() {
+ super(null, null);
+ }
+
+ @Override
+ public Map<String, Map<String, Map<String, CatalogItem>>> get() {
+ return ImmutableMap.<String, Map<String, Map<String, CatalogItem>>> of(
+ ORG_REF.getName(), ImmutableMap
+ .<String, Map<String, CatalogItem>> of(CATALOG_REF
+ .getName(), ImmutableMap.<String, CatalogItem> of(
+ "template",
+ new CatalogItemImpl("template", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"), "description",
+ new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml",
+ URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")),
+ ImmutableMap.<String, String> of()))));
+
+ }
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java
new file mode 100644
index 0000000..b97cdf0
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.internal;
+
+import static org.jclouds.reflect.Reflection2.method;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.location.Provider;
+import org.jclouds.providers.AnonymousProviderMetadata;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.rest.internal.BaseRestAnnotationProcessingTest;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.endpoints.VCloudLogin;
+import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
+import org.jclouds.vcloud.http.filters.VCloudBasicAuthentication;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableList;
+import com.google.common.net.HttpHeaders;
+import com.google.common.reflect.Invokable;
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.Provides;
+/**
+ * Tests behavior of {@code VCloudLoginApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "VCloudLoginApiTest")
+public class VCloudLoginApiTest extends BaseRestAnnotationProcessingTest<VCloudLoginApi> {
+
+ public void testLogin() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VCloudLoginApi.class, "login");
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
+
+ assertEquals(request.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": application/vnd.vmware.vcloud.orgList+xml\n" + HttpHeaders.ACCEPT + ": application/vnd.vmware.vcloud.session+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseLoginResponseFromHeaders.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ @Override
+ protected void checkFilters(HttpRequest request) {
+ assertEquals(request.getFilters().size(), 1);
+ assertEquals(request.getFilters().get(0).getClass(), VCloudBasicAuthentication.class);
+ }
+
+ @Override
+ protected Module createModule() {
+ return new Module() {
+
+ @Override
+ public void configure(Binder binder) {
+ }
+
+ @Provides
+ @VCloudLogin
+ Supplier<URI> provideURI(@Provider Supplier<URI> uri) {
+ return uri;
+ }
+
+ };
+ }
+
+ @Override
+ protected ProviderMetadata createProviderMetadata() {
+ return AnonymousProviderMetadata.forApiOnEndpoint(VCloudLoginApi.class,
+ "http://localhost:8080/login");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java
new file mode 100644
index 0000000..8994284
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.options;
+
+import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
+import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.description;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.jclouds.vcloud.domain.network.NetworkConfig;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code InstantiateVAppTemplateOptions}
+ */
+@Test(groups = "unit")
+public class InstantiateVAppTemplateOptionsTest {
+
+ Injector injector = Guice.createInjector(new SaxParserModule());
+
+ @Test
+ public void testAddNetworkConfig() {
+ InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
+ options.addNetworkConfig(new NetworkConfig("default", URI.create("http://localhost"), FenceMode.BRIDGED));
+ assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default");
+ assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost"));
+ assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
+ }
+
+ @Test
+ public void testAddNetworkConfigStatic() {
+ InstantiateVAppTemplateOptions options = addNetworkConfig(new NetworkConfig("default",
+ URI.create("http://localhost"), FenceMode.BRIDGED));
+ assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default");
+ assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost"));
+ assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
+ }
+
+ @Test
+ public void testDescription() {
+ InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
+ options.description("foo");
+ assertEquals(options.getDescription(), "foo");
+ }
+
+ @Test
+ public void testDescriptionStatic() {
+ InstantiateVAppTemplateOptions options = description("foo");
+ assertEquals(options.getDescription(), "foo");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java
new file mode 100644
index 0000000..4bdb5b8
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.suppliers;
+
+import static org.easymock.EasyMock.createMock;
+import static org.testng.Assert.assertEquals;
+
+import java.util.NoSuchElementException;
+
+import org.jclouds.config.ValueOfConfigurationKeyOrNull;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.name.Names;
+
+/**
+ * Tests behavior of
+ * {@code OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest")
+public class OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest {
+ ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull = Guice.createInjector().getInstance(
+ ValueOfConfigurationKeyOrNull.class);
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testIllegalArgumentWhenResourcesEmpty() {
+ new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, "foo",
+ Predicates.<ReferenceType> alwaysTrue()).apply(ImmutableSet.<ReferenceType> of());
+ }
+
+ @Test
+ public void testReturnsOnlyResource() {
+ ReferenceType reference = createMock(ReferenceType.class);
+
+ assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull,
+ "foo", Predicates.<ReferenceType> alwaysTrue()).apply(ImmutableSet.<ReferenceType> of(reference)),
+ reference);
+
+ }
+
+ @Test
+ public void testReturnsFirstResourceWhenConfigurationUnspecified() {
+ ReferenceType reference1 = createMock(ReferenceType.class);
+ ReferenceType reference2 = createMock(ReferenceType.class);
+
+ assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull,
+ "foo", Predicates.<ReferenceType> alwaysTrue()).apply(ImmutableList.<ReferenceType> of(reference1,
+ reference2)), reference1);
+
+ }
+
+ @Test
+ public void testReturnsResourceMatchingDefaultPredicateWhenConfigurationUnspecified() {
+ ReferenceType reference1 = createMock(ReferenceType.class);
+ ReferenceType reference2 = createMock(ReferenceType.class);
+
+ assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull,
+ "foo", Predicates.equalTo(reference2)).apply(ImmutableList.<ReferenceType> of(reference1, reference2)),
+ reference2);
+
+ }
+
+ @Test
+ public void testReturnsResourceWithNameMatchingConfigurationKey() {
+ ReferenceType reference1 = new ReferenceTypeImpl("travis tritt", null, null);
+ ReferenceType reference2 = new ReferenceTypeImpl("hail mary", null, null);
+
+ assertEquals(
+ new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(Guice.createInjector(
+ new AbstractModule() {
+ protected void configure() {
+ bindConstant().annotatedWith(Names.named("foo")).to(".*mary.*");
+ }
+ }).getInstance(ValueOfConfigurationKeyOrNull.class), "foo", Predicates.<ReferenceType> alwaysTrue()).apply(ImmutableList
+ .<ReferenceType> of(reference1, reference2)), reference2);
+
+ }
+
+ @Test(expectedExceptions = NoSuchElementException.class)
+ public void testThrowsNoSuchElementWhenNoneMatchConfigurationKey() {
+ ReferenceType reference1 = new ReferenceTypeImpl("travis tritt", null, null);
+ ReferenceType reference2 = new ReferenceTypeImpl("hail mary", null, null);
+
+ new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(Guice.createInjector(new AbstractModule() {
+ protected void configure() {
+ bindConstant().annotatedWith(Names.named("foo")).to(".*happy.*");
+ }
+ }).getInstance(ValueOfConfigurationKeyOrNull.class), "foo", Predicates.<ReferenceType> alwaysTrue())
+ .apply(ImmutableList.<ReferenceType> of(reference1, reference2));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java
new file mode 100644
index 0000000..9a844ed
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.utils;
+
+
+/**
+ * Utility class for test
+ */
+public class TestUtils {
+ public static final Object[][] NO_INVOCATIONS = new Object[0][0];
+ public static final Object[][] SINGLE_NO_ARG_INVOCATION = { new Object[0] };
+
+ public static boolean isWindowsOs() {
+ return System.getProperty("os.name", "").toLowerCase().contains("windows");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java
new file mode 100644
index 0000000..2a883e6
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML;
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.internal.CatalogImpl;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code CatalogHandler}
+ */
+@Test(groups = "unit")
+public class CatalogHandlerTest {
+
+ private Injector injector;
+
+ private Factory factory;
+
+ public void testVCloud1_0() {
+ InputStream is = getClass().getResourceAsStream("/catalog-blank.xml");
+ injector = Guice.createInjector(new SaxParserModule());
+ factory = injector.getInstance(ParseSax.Factory.class);
+ Catalog result = factory.create(injector.getInstance(CatalogHandler.class)).parse(is);
+ assertEquals(result, new CatalogImpl("Jclouds-private", "application/vnd.vmware.vcloud.catalog+xml", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/921222081"), new ReferenceTypeImpl(null,
+ "application/vnd.vmware.vcloud.org+xml", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")), null, ImmutableMap
+ .<String, ReferenceType> of(), ImmutableList.<Task> of(), false, false));
+ }
+
+ public void testTerremark() {
+ InputStream is = getClass().getResourceAsStream("/catalog.xml");
+ injector = Guice.createInjector(new SaxParserModule());
+ factory = injector.getInstance(ParseSax.Factory.class);
+ Catalog result = factory.create(injector.getInstance(CatalogHandler.class)).parse(is);
+ assertEquals(result.getName(), "Miami Environment 1");
+ assert result.getDescription() == null;
+
+ assertEquals(result.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"));
+ assertEquals(result.get("CentOS 5.3 (32-bit)"), new ReferenceTypeImpl("CentOS 5.3 (32-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/5")));
+ assertEquals(result.get("CentOS 5.3 (64-bit)"), new ReferenceTypeImpl("CentOS 5.3 (64-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/6")));
+ assertEquals(result.get("RHEL 5.3 (32-bit)"), new ReferenceTypeImpl("RHEL 5.3 (32-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/7")));
+ assertEquals(result.get("RHEL 5.3 (64-bit)"), new ReferenceTypeImpl("RHEL 5.3 (64-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/8")));
+ assertEquals(result.get("Ubuntu JeOS 9.04 (32-bit)"), new ReferenceTypeImpl("Ubuntu JeOS 9.04 (32-bit)",
+ CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/11")));
+ assertEquals(result.get("Ubuntu JeOS 9.04 (64-bit)"), new ReferenceTypeImpl("Ubuntu JeOS 9.04 (64-bit)",
+ CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/12")));
+ assertEquals(result.get("Ubuntu Server 9.04 (32-bit)"), new ReferenceTypeImpl("Ubuntu Server 9.04 (32-bit)",
+ CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/9")));
+ assertEquals(result.get("Ubuntu Server 9.04 (64-bit)"), new ReferenceTypeImpl("Ubuntu Server 9.04 (64-bit)",
+ CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/10")));
+ assertEquals(result.get("Windows 2003 Enterprise R2 (32-bit)"), new ReferenceTypeImpl(
+ "Windows 2003 Enterprise R2 (32-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/1")));
+ assertEquals(result.get("Windows 2003 Enterprise R2 (64-bit)"), new ReferenceTypeImpl(
+ "Windows 2003 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/2")));
+ assertEquals(result.get("Windows 2003 Standard R2 (32-bit)"), new ReferenceTypeImpl(
+ "Windows 2003 Standard R2 (32-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/3")));
+ assertEquals(result.get("Windows 2003 Standard R2 (64-bit)"), new ReferenceTypeImpl(
+ "Windows 2003 Standard R2 (64-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/4")));
+ assertEquals(result.get("Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"), new ReferenceTypeImpl(
+ "Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/23")));
+ assertEquals(result.get("Windows Server 2008 Enterprise (32-bit)"), new ReferenceTypeImpl(
+ "Windows Server 2008 Enterprise (32-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13")));
+ assertEquals(result.get("Windows Server 2008 Enterprise (64-bit)"), new ReferenceTypeImpl(
+ "Windows Server 2008 Enterprise (64-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15")));
+ assertEquals(result.get("Windows Server 2008 Enterprise R2 (64-bit)"), new ReferenceTypeImpl(
+ "Windows Server 2008 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16")));
+ assertEquals(result.get("Windows Server 2008 Standard (32-bit)"), new ReferenceTypeImpl(
+ "Windows Server 2008 Standard (32-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17")));
+ assertEquals(result.get("Windows Server 2008 Standard (64-bit)"), new ReferenceTypeImpl(
+ "Windows Server 2008 Standard (64-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18")));
+ assertEquals(result.get("Windows Server 2008 Standard R2 (64-bit)"), new ReferenceTypeImpl(
+ "Windows Server 2008 Standard R2 (64-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/19")));
+ assertEquals(result.get("Windows Server 2008 Standard w.SQL 2008 Web (64-bit)"), new ReferenceTypeImpl(
+ "Windows Server 2008 Standard w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/14")));
+ assertEquals(result.get("Windows Web Server 2008 (32-bit)"), new ReferenceTypeImpl(
+ "Windows Web Server 2008 (32-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/20")));
+ assertEquals(result.get("Windows Web Server 2008 (64-bit)"), new ReferenceTypeImpl(
+ "Windows Web Server 2008 (64-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21")));
+ assertEquals(result.get("Windows Web Server 2008 R2 (64-bit)"), new ReferenceTypeImpl(
+ "Windows Web Server 2008 R2 (64-bit)", CATALOGITEM_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22")));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java
new file mode 100644
index 0000000..6f2b100
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSortedMap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code CatalogItemHandler}
+ */
+@Test(groups = "unit")
+public class CatalogItemHandlerTest {
+
+ public void testApplyInputStream() {
+ InputStream is = getClass().getResourceAsStream("/catalogItem-hosting.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is);
+
+ assertEquals(result, new CatalogItemImpl("Windows 2008 Datacenter 64 Bit", URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"), "Windows 2008 Datacenter 64 Bit",
+ new ReferenceTypeImpl("Windows 2008 Datacenter 64 Bit",
+ "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")),
+ ImmutableSortedMap.of("Foo", "Bar", "Hello", "World"
+
+ )));
+
+ }
+
+ public void testApplyInputStreamWithNamespaceUsingVcloud() {
+ InputStream is = getClass().getResourceAsStream("/catalogItem-carrenza-with-vcloud-namespace.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is);
+
+ assertEquals(result, new CatalogItemImpl("ubuntu10.10x64",
+ URI.create("https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3"),
+ null, new ReferenceTypeImpl("ubuntu10.10x64", "application/vnd.vmware.vcloud.vAppTemplate+xml",
+ URI.create("https://myvdc.carrenza.net/api/v1.0/vAppTemplate/vappTemplate-123766ea-2b55-482c-8adf-735ab1952834")),
+ ImmutableSortedMap.<String, String>of()));
+ }
+
+ public void testApplyInputStreamWithNamespaceUsingDefault() {
+ InputStream is = getClass().getResourceAsStream("/catalogItem-carrenza-with-default-namespace.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is);
+
+ assertEquals(result, new CatalogItemImpl("ubuntu10.10x64",
+ URI.create("https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3"),
+ null, new ReferenceTypeImpl("ubuntu10.10x64", "application/vnd.vmware.vcloud.vAppTemplate+xml",
+ URI.create("https://myvdc.carrenza.net/api/v1.0/vAppTemplate/vappTemplate-123766ea-2b55-482c-8adf-735ab1952834")),
+ ImmutableSortedMap.<String, String>of()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java
new file mode 100644
index 0000000..503611e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.UnknownHostException;
+
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.GuestCustomizationSection;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code GuestCustomizationSectionHandler}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "GuestCustomizationSectionHandlerTest")
+public class GuestCustomizationSectionHandlerTest extends BaseHandlerTest {
+
+ public void testDefault() throws UnknownHostException {
+ InputStream is = getClass().getResourceAsStream("/guestCustomization.xml");
+
+ GuestCustomizationSection result = factory.create(injector.getInstance(GuestCustomizationSectionHandler.class))
+ .parse(is);
+
+ checkGuestCustomization(result);
+
+ }
+
+ @Test(enabled = false)
+ public static void checkGuestCustomization(GuestCustomizationSection result) {
+ assertEquals(result.getType(), VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML);
+ assertEquals(result.getHref(),
+ URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/"));
+ assertEquals(result.getInfo(), "Specifies Guest OS Customization Settings");
+ assertEquals(result.isEnabled(), Boolean.TRUE);
+ assertEquals(result.shouldChangeSid(), Boolean.FALSE);
+ assertEquals(result.getVirtualMachineId(), "2087535248");
+ assertEquals(result.isJoinDomainEnabled(), Boolean.FALSE);
+ assertEquals(result.useOrgSettings(), Boolean.FALSE);
+ assertEquals(result.getDomainName(), null);
+ assertEquals(result.getDomainUserName(), null);
+ assertEquals(result.getDomainUserPassword(), null);
+ assertEquals(result.isAdminPasswordEnabled(), Boolean.TRUE);
+ assertEquals(result.isAdminPasswordAuto(), Boolean.TRUE);
+ assertEquals(result.getAdminPassword(), null);
+ assertEquals(result.isResetPasswordRequired(), Boolean.FALSE);
+ assertEquals(result.getCustomizationScript(), "cat > /root/foo.txt<<EOF\nI '\"love\"' {asc|!}*&\nEOF\n");
+ assertEquals(result.getComputerName(), "RHEL5");
+ assertEquals(
+ result.getEdit(),
+ new ReferenceTypeImpl(null, VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/")));
+ }
+}
[07/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java
new file mode 100644
index 0000000..73d6342
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static org.jclouds.util.Strings2.toStringAndClose;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.internal.BasePayloadTest;
+import org.jclouds.vcloud.options.CloneVAppTemplateOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+
+/**
+ * Tests behavior of {@code BindCloneVAppTemplateParamsToXmlPayload}
+ */
+@Test(groups = "unit")
+public class BindCloneVAppTemplateParamsToXmlPayloadTest extends BasePayloadTest {
+ public void testWithDescription() throws IOException {
+ String expected = toStringAndClose(getClass().getResourceAsStream("/copyVAppTemplate.xml"));
+
+ CloneVAppTemplateOptions options = new CloneVAppTemplateOptions()
+ .description("The description of the new vAppTemplate");
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(options));
+
+ BindCloneVAppTemplateParamsToXmlPayload binder = injector
+ .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class);
+
+ Builder<String, Object> map = ImmutableMap.builder();
+ map.put("name", "new-linux-server");
+ map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201");
+
+ assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected);
+ }
+
+ public void testWithDescriptionSourceDelete() throws IOException {
+ String expected = toStringAndClose(getClass().getResourceAsStream("/moveVAppTemplate.xml"));
+
+ CloneVAppTemplateOptions options = new CloneVAppTemplateOptions()
+ .description("The description of the new vAppTemplate");
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(options));
+
+ BindCloneVAppTemplateParamsToXmlPayload binder = injector
+ .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class);
+
+ Builder<String, Object> map = ImmutableMap.builder();
+ map.put("name", "new-linux-server");
+ map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201");
+ map.put("IsSourceDelete", "true");
+
+ assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected);
+ }
+
+ public void testDefault() throws IOException {
+ String expected = toStringAndClose(getClass().getResourceAsStream("/copyVAppTemplate-default.xml"));
+
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
+
+ BindCloneVAppTemplateParamsToXmlPayload binder = injector
+ .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class);
+
+ Builder<String, Object> map = ImmutableMap.builder();
+ map.put("name", "my-vapptemplate");
+ map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181");
+
+ assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java
new file mode 100644
index 0000000..f145e97
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.internal.BasePayloadTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
+
+/**
+ * Tests behavior of {@code BindDeployVAppParamsToXmlPayload}
+ */
+@Test(groups = "unit")
+public class BindDeployVAppParamsToXmlPayloadTest extends BasePayloadTest {
+
+ public void testPowerOnTrue() throws IOException {
+ String expected = "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" powerOn=\"true\"/>";
+
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
+
+ BindDeployVAppParamsToXmlPayload binder = injector.getInstance(BindDeployVAppParamsToXmlPayload.class);
+
+ Map<String, Object> map = Maps.newHashMap();
+ map.put("powerOn", "true");
+ assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
+ }
+
+ public void testDefault() throws IOException {
+ String expected = "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>";
+
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
+
+ BindDeployVAppParamsToXmlPayload binder = injector.getInstance(BindDeployVAppParamsToXmlPayload.class);
+
+ Map<String, Object> map = Maps.newHashMap();
+ assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java
new file mode 100644
index 0000000..ead0bad
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.replay;
+import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Map;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.util.Strings2;
+import org.jclouds.vcloud.VCloudApiMetadata;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.jclouds.vcloud.domain.network.NetworkConfig;
+import org.jclouds.vcloud.endpoints.Network;
+import org.jclouds.vcloud.internal.BasePayloadTest;
+import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
+import org.nnsoft.guice.rocoto.Rocoto;
+import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.base.Functions;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Provides;
+
+/**
+ * Tests behavior of {@code BindInstantiateVAppTemplateParamsToXmlPayload}
+ */
+@Test(groups = "unit")
+public class BindInstantiateVAppTemplateParamsToXmlPayloadTest extends BasePayloadTest {
+ Injector createInjector(final URI vAppTemplate, final VAppTemplate value) {
+
+ return Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
+
+ @Provides
+ @Singleton
+ @Network
+ protected Function<VAppTemplate, String> templateToDefaultNetworkName() {
+ return Functions.forMap(ImmutableMap.of(value, "vAppNet-vApp Internal"));
+ }
+
+ @Provides
+ @Singleton
+ protected LoadingCache<URI, VAppTemplate> templateIdToVAppTemplate() {
+ return CacheBuilder.newBuilder().build(
+ CacheLoader.from(Functions.forMap(ImmutableMap.of(vAppTemplate, value))));
+ }
+
+ @Override
+ protected void bindConfigurations() {
+ bindProperties(new VCloudApiMetadata().getDefaultProperties());
+ }
+
+ @Provides
+ @Singleton
+ public FenceMode defaultFenceMode(@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) {
+ return FenceMode.fromValue(fenceMode);
+ }
+
+ @Network
+ @Provides
+ @Singleton
+ Supplier<ReferenceType> provideNetwork() {
+ return Suppliers.<ReferenceType>ofInstance(new ReferenceTypeImpl(null, null, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/network/1990")));
+ }
+ }));
+ }
+
+ public void testDefault() throws IOException {
+ URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
+ VAppTemplate template = createMock(VAppTemplate.class);
+ replay(template);
+
+ String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/instantiationparams.xml"));
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(new InstantiateVAppTemplateOptions()));
+
+ BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance(
+ BindInstantiateVAppTemplateParamsToXmlPayload.class);
+
+ Map<String, Object> map = Maps.newHashMap();
+ map.put("name", "my-vapp");
+ map.put("template", templateUri.toASCIIString());
+ assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
+ }
+
+ public void testDescription() throws IOException {
+ URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
+ VAppTemplate template = createMock(VAppTemplate.class);
+ replay(template);
+
+ String expected = Strings2.toStringAndClose(getClass()
+ .getResourceAsStream("/instantiationparams-description.xml"));
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(new InstantiateVAppTemplateOptions().description("my foo")));
+
+ BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance(
+ BindInstantiateVAppTemplateParamsToXmlPayload.class);
+
+ Map<String, Object> map = Maps.newHashMap();
+ map.put("name", "my-vapp");
+ map.put("template", templateUri.toASCIIString());
+ assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
+ }
+
+ public void testWhenTemplateDoesntExist() throws IOException {
+ URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
+ VAppTemplate template = createMock(VAppTemplate.class);
+ replay(template);
+
+ String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/instantiationparams.xml"));
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
+
+ BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance(
+ BindInstantiateVAppTemplateParamsToXmlPayload.class);
+
+ Map<String, Object> map = Maps.newHashMap();
+ map.put("name", "my-vapp");
+ map.put("template", templateUri.toASCIIString());
+ assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
+ }
+
+ public void testWithNetworkNameFenceMode() throws IOException {
+ URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
+ VAppTemplate template = createMock(VAppTemplate.class);
+ replay(template);
+
+ InstantiateVAppTemplateOptions options = addNetworkConfig(new NetworkConfig("aloha", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED));
+
+ String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/instantiationparams-network.xml"));
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(options));
+
+ BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance(
+ BindInstantiateVAppTemplateParamsToXmlPayload.class);
+
+ Map<String, Object> map = Maps.newHashMap();
+ map.put("name", "my-vapp");
+ map.put("template", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
+
+ assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java
new file mode 100644
index 0000000..77059b0
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.vcloud.domain.NetworkConnection;
+import org.jclouds.vcloud.domain.NetworkConnectionSection;
+import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
+import org.jclouds.vcloud.internal.BasePayloadTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests behavior of {@code BindNetworkConnectionSectionToXmlPayload}
+ */
+@Test(groups = "unit", testName = "BindNetworkConnectionSectionToXmlPayloadTest")
+public class BindNetworkConnectionSectionToXmlPayloadTest extends BasePayloadTest {
+
+ public void testWithIpAllocationModeNONE() throws IOException {
+
+ HttpRequest request = HttpRequest.builder().endpoint("http://localhost/key").method("GET")
+ .build();
+
+ BindNetworkConnectionSectionToXmlPayload binder = injector
+ .getInstance(BindNetworkConnectionSectionToXmlPayload.class);
+
+ binder.bindToRequest(
+ request,
+ NetworkConnectionSection
+ .builder()
+ .type("application/vnd.vmware.vcloud.networkConnectionSection+xml")
+ .info("Specifies the available VM network connections")
+ .href(URI.create("https://1.1.1.1/api/v1.0/vApp/vm-1/networkConnectionSection/"))
+ .connections(
+ ImmutableSet.<NetworkConnection> of(NetworkConnection.builder().network("none")
+ .ipAddressAllocationMode(IpAddressAllocationMode.NONE).build())).build());
+ assertEquals(request.getPayload().getContentMetadata().getContentType(),
+ "application/vnd.vmware.vcloud.networkConnectionSection+xml");
+
+ assertEquals(
+ request.getPayload().getRawContent(),
+ "<NetworkConnectionSection xmlns=\"http://www.vmware.com/vcloud/v1\" xmlns:ovf=\"http://schemas.dmtf.org/ovf/envelope/1\" href=\"https://1.1.1.1/api/v1.0/vApp/vm-1/networkConnectionSection/\" ovf:required=\"false\" type=\"application/vnd.vmware.vcloud.networkConnectionSection+xml\"><ovf:Info>Specifies the available VM network connections</ovf:Info><NetworkConnection network=\"none\"><NetworkConnectionIndex>0</NetworkConnectionIndex><IsConnected>false</IsConnected><IpAddressAllocationMode>NONE</IpAddressAllocationMode></NetworkConnection></NetworkConnectionSection>");
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java
new file mode 100644
index 0000000..59a4141
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.internal.BasePayloadTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
+
+/**
+ * Tests behavior of {@code BindUndeployVAppParamsToXmlPayload}
+ */
+@Test(groups = "unit")
+public class BindUndeployVAppParamsToXmlPayloadTest extends BasePayloadTest {
+
+ public void testSaveStateTrue() throws IOException {
+ String expected = "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" saveState=\"true\"/>";
+
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
+
+ BindUndeployVAppParamsToXmlPayload binder = injector.getInstance(BindUndeployVAppParamsToXmlPayload.class);
+
+ Map<String, Object> map = Maps.newHashMap();
+ map.put("saveState", "true");
+ assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
+ }
+
+ public void testDefault() throws IOException {
+ String expected = "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>";
+
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
+
+ BindUndeployVAppParamsToXmlPayload binder = injector.getInstance(BindUndeployVAppParamsToXmlPayload.class);
+
+ Map<String, Object> map = Maps.newHashMap();
+ assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java
new file mode 100644
index 0000000..e938600
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute;
+
+import java.net.URI;
+import java.util.Properties;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.compute.ComputeService;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.rest.internal.BaseRestApiExpectTest;
+import org.jclouds.vcloud.VCloudApiMetadata;
+import org.jclouds.vcloud.VCloudMediaType;
+
+import com.google.common.base.Function;
+import com.google.common.net.HttpHeaders;
+import com.google.inject.Module;
+
+/**
+ * Base class for writing VCloud Expect tests for ComputeService operations
+ */
+public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestApiExpectTest<ComputeService> {
+ protected static final String ENDPOINT = "https://zone.myvcloud.com/api";
+
+ protected HttpRequest versionsRequest = HttpRequest.builder().method("GET").endpoint(
+ URI.create(ENDPOINT + "/versions")).addHeader(HttpHeaders.ACCEPT, "*/*").build();
+
+ protected HttpResponse versionsResponseFromVCD1_5 = HttpResponse.builder().statusCode(200)
+ .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/versions-vcd15.xml", "text/xml"))
+ .build();
+
+ // initial auth is using basic
+ protected HttpRequest version1_0LoginRequest = HttpRequest.builder().method("POST").endpoint(ENDPOINT + "/v1.0/login")
+ .addHeader(HttpHeaders.ACCEPT, "application/vnd.vmware.vcloud.session+xml;version=1.0")
+ .addHeader(HttpHeaders.AUTHORIZATION, "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build();
+
+ protected String sessionToken = "AtatAgvJMrwOc9pDQq4RRCRLazThpnTKJDxSVH9oB2I=";
+
+ // login response includes a cookie and also a vcloud extended header with the session token in it
+ // NOTE: vCloud Director 1.5 returns ;version=1.0 on responses to requests made in 1.0 format.
+ protected HttpResponse successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg = HttpResponse.builder().statusCode(200)
+ .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/orgList1.0-vcd15.xml", VCloudMediaType.ORGLIST_XML + ";version=1.0"))
+ .addHeader("x-vcloud-authorization", sessionToken)
+ .addHeader(HttpHeaders.SET_COOKIE, String.format("vcloud-token=%s; Secure; Path=/", sessionToken)).build();
+
+ // objects are looked up by id and the format of the id is hex-hyphen
+ protected String orgId = "c076f90a-397a-49fa-89b8-b294c1599cd0";
+
+ protected HttpRequest version1_0GetOrgRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/org/" + orgId)
+ .addHeader(HttpHeaders.ACCEPT, VCloudMediaType.ORG_XML+";version=1.0")
+ .addHeader("x-vcloud-authorization", sessionToken)
+ .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build();
+
+ protected HttpResponse successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork = HttpResponse.builder().statusCode(200)
+ .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/org1.0-vcd15.xml", VCloudMediaType.ORG_XML + ";version=1.0"))
+ .build();
+
+ protected String catalogId = "3155f393-1e1d-4572-8c9c-d76f72ddb658";
+ protected String vdcId = "e9cd3387-ac57-4d27-a481-9bee75e0690f";
+
+ protected HttpRequest version1_0GetCatalogRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/catalog/" + catalogId)
+ .addHeader(HttpHeaders.ACCEPT, VCloudMediaType.CATALOG_XML +";version=1.0")
+ .addHeader("x-vcloud-authorization", sessionToken)
+ .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build();
+
+ protected HttpResponse successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate = HttpResponse.builder().statusCode(200)
+ .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/catalog1.0-vcd15.xml", VCloudMediaType.CATALOG_XML + ";version=1.0"))
+ .build();
+
+ protected String catalogItemId = "ceb369f7-1d07-4e32-9dbd-ebb5aa6ca55c";
+
+ protected HttpRequest version1_0GetCatalogItemRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/catalogItem/" + catalogItemId)
+ .addHeader(HttpHeaders.ACCEPT, VCloudMediaType.CATALOGITEM_XML +";version=1.0")
+ .addHeader("x-vcloud-authorization", sessionToken)
+ .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build();
+
+ protected HttpResponse successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate = HttpResponse.builder().statusCode(200)
+ .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/catalogItem1.0-vcd15.xml", VCloudMediaType.CATALOGITEM_XML + ";version=1.0"))
+ .build();
+
+ // note vAppTemplate has a prefix in its id
+ protected String templateId = "vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728";
+
+ protected HttpRequest version1_0GetVDCRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/vdc/" + vdcId)
+ .addHeader(HttpHeaders.ACCEPT, VCloudMediaType.VDC_XML +";version=1.0")
+ .addHeader("x-vcloud-authorization", sessionToken)
+ .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build();
+
+ protected HttpResponse successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork = HttpResponse.builder().statusCode(200)
+ .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/vdc1.0-vcd15.xml", VCloudMediaType.VDC_XML + ";version=1.0"))
+ .build();
+
+ protected String networkId = "b466c0c5-8a5c-4335-b703-a2e2e6b5f3e1";
+
+ protected HttpRequest version1_0GetVAppTemplateRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/vAppTemplate/" + templateId)
+ .addHeader(HttpHeaders.ACCEPT, VCloudMediaType.VAPPTEMPLATE_XML +";version=1.0")
+ .addHeader("x-vcloud-authorization", sessionToken)
+ .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build();
+
+ protected HttpResponse successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent = HttpResponse.builder().statusCode(200)
+ .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/template1.0-vcd15.xml", VCloudMediaType.VAPPTEMPLATE_XML + ";version=1.0"))
+ .build();
+
+ protected HttpResponse successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithMultipleVMsAndVDCParent = HttpResponse.builder().statusCode(200)
+ .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/template1.0-vcd15-multi-vm.xml", VCloudMediaType.VAPPTEMPLATE_XML + ";version=1.0"))
+ .build();
+
+ protected HttpRequest version1_0GetOVFForVAppTemplateRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/vAppTemplate/" + templateId + "/ovf")
+ .addHeader(HttpHeaders.ACCEPT, MediaType.TEXT_XML +";version=1.0")
+ .addHeader("x-vcloud-authorization", sessionToken)
+ .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build();
+
+ protected HttpResponse successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM = HttpResponse.builder().statusCode(200)
+ .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/ovf-ubuntu64.xml", MediaType.TEXT_XML + ";version=1.0"))
+ .build();
+
+ protected HttpResponse successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithMultipleVMs = HttpResponse.builder().statusCode(200)
+ .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/ovf-multi-vm.xml", MediaType.TEXT_XML + ";version=1.0"))
+ .build();
+
+ public BaseVCloudComputeServiceExpectTest() {
+ provider = "vcloud";
+ }
+
+ @Override
+ public ComputeService createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
+ return createInjector(fn, module, props).getInstance(ComputeService.class);
+ }
+
+ @Override
+ protected ApiMetadata createApiMetadata() {
+ return new VCloudApiMetadata();
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties props = super.setupProperties();
+ props.setProperty(provider + ".endpoint", ENDPOINT);
+ return props;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java
new file mode 100644
index 0000000..f5d3ec6
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute;
+
+import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.Test;
+
+import com.google.inject.Module;
+
+@Test(groups = "live", enabled = true, singleThreaded = true)
+public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
+
+ public VCloudComputeServiceLiveTest() {
+ provider = "vcloud";
+ }
+
+ @Override
+ public void setServiceDefaults() {
+ // extremely short names needed so that we don't get errors relating to
+ // guestCustomization.computerName being too long
+ group = "vcd";
+ }
+
+ @Override
+ public void testOptionToNotBlock() {
+ // start call has to block until deploy
+ }
+
+ @Override
+ protected Module getSshModule() {
+ return new SshjSshClientModule();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java
new file mode 100644
index 0000000..65534aa
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests behavior of {@code FindLocationForResource}
+ */
+@Test(groups = "unit")
+public class FindLocationForResourceTest {
+ public void testMatchWhenIdIsHref() {
+ Location location = new LocationBuilder().id("http://foo").description("description")
+ .scope(LocationScope.PROVIDER).build();
+ FindLocationForResource converter = new FindLocationForResource(
+ Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(location)));
+ assertEquals(converter.apply(new ReferenceTypeImpl("name", "type", URI.create("http://foo"))), location);
+ }
+
+ @Test(expectedExceptions = NoSuchElementException.class)
+ public void testGracefulWhenHrefIsntLocationId() {
+ FindLocationForResource converter = new FindLocationForResource(
+ Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(new LocationBuilder()
+ .id("http://bar").description("description").scope(LocationScope.PROVIDER).build())));
+ converter.apply(new ReferenceTypeImpl("name", "type", URI.create("http://foo")));
+ }
+
+ @Test(expectedExceptions = NoSuchElementException.class)
+ public void testGracefulWhenLocationIdIsntURI() {
+ FindLocationForResource converter = new FindLocationForResource(
+ Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(new LocationBuilder().id("1")
+ .description("description").scope(LocationScope.PROVIDER).build())));
+ converter.apply(new ReferenceTypeImpl("name", "type", URI.create("http://foo")));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java
new file mode 100644
index 0000000..426de42
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.jclouds.cim.OSType;
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.domain.CIMOperatingSystem;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.ImageBuilder;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.location.suppliers.all.JustProvider;
+import org.jclouds.vcloud.compute.BaseVCloudComputeServiceExpectTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+
+@Test(singleThreaded = true, testName = "ListImagesInVCloudExpectTest")
+public class ListImagesInVCloudExpectTest extends BaseVCloudComputeServiceExpectTest {
+
+ public void testListImagesUsingVCloud1_0ApiOnServerRunningVCloudDirector1_5ReturnsImageWithLocationForVAppTemplateInVDC() throws Exception {
+ ComputeService compute = requestsSendResponses(ImmutableMap.<HttpRequest, HttpResponse>builder()
+ .put(versionsRequest, versionsResponseFromVCD1_5)
+ .put(version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg)
+ .put(version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork)
+ .put(version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate)
+ .put(version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate)
+ .put(version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork)
+ .put(version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent)
+ .put(version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM)
+ .build());
+
+ Location provider = Iterables.getOnlyElement(compute.getContext().utils().injector().getInstance(JustProvider.class).get());
+
+ Location orgLocation = new LocationBuilder().id(ENDPOINT + "/v1.0/org/" + orgId).scope(LocationScope.REGION)
+ .description("jclouds").parent(provider).build();
+
+ Location vdcLocation = new LocationBuilder().id(ENDPOINT + "/v1.0/vdc/" + vdcId).scope(LocationScope.ZONE)
+ .description("orgVDC-jclouds-Tier1-PAYG").parent(orgLocation).build();
+
+ Set<? extends Image> currentImages = compute.listImages();
+ assertEquals(compute.listImages().size(), 1);
+ Image onlyImage = Iterables.get(currentImages, 0);
+
+
+ Image expectedImage = new ImageBuilder()
+ .ids(ENDPOINT + "/v1.0/vAppTemplate/" + templateId)
+ .uri(URI.create(ENDPOINT + "/v1.0/vAppTemplate/" + templateId))
+ .name("UbuntuServer-x64-2GB")
+ .operatingSystem(new CIMOperatingSystem(OSType.UBUNTU_64, "", null, "Ubuntu Linux (64-bit)"))
+ // TODO: this looks like a bug, as it says network interfaces
+ .description("This is a special place-holder used for disconnected network interfaces.")
+ .defaultCredentials(LoginCredentials.builder().identity("root").build())
+ .status(Image.Status.AVAILABLE)
+ .location(vdcLocation).build();
+
+ assertEquals(onlyImage, expectedImage);
+ assertEquals(onlyImage.getStatus(), Image.Status.AVAILABLE);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java
new file mode 100644
index 0000000..3e36be2
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.functions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.io.InputStream;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import javax.inject.Singleton;
+
+import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.domain.Credentials;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudApiMetadata;
+import org.jclouds.vcloud.compute.config.VCloudComputeServiceDependenciesModule;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.internal.VAppImpl;
+import org.jclouds.vcloud.xml.VAppHandler;
+import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+import com.google.inject.name.Names;
+
+/**
+ * Tests behavior of {@code VAppToNodeMetadata}
+ */
+@Test(groups = "unit")
+public class VAppToNodeMetadataTest {
+
+ public Injector createInjectorWithLocation(final Location location) {
+ return Guice.createInjector(new SaxParserModule(), new AbstractModule() {
+
+ @Override
+ protected void configure() {
+ Names.bindProperties(binder(), new VCloudApiMetadata().getDefaultProperties());
+ bind(new TypeLiteral<Function<ReferenceType, Location>>() {
+ }).to(new TypeLiteral<FindLocationForResource>() {
+ });
+ bind(new TypeLiteral<Function<VApp, Hardware>>() {
+ }).to(new TypeLiteral<HardwareForVApp>() {
+ });
+ bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
+ }
+
+ @Memoized
+ @Singleton
+ @Provides
+ Supplier<Set<? extends Location>> supplyLocations() {
+ return Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(location));
+ }
+
+ @Singleton
+ @Provides
+ Map<String, Credentials> supplyCreds() {
+ return Maps.newConcurrentMap();
+ }
+
+ @Singleton
+ @Provides
+ protected Map<Status, NodeMetadata.Status> provideVAppStatusToNodeStatus() {
+ return VCloudComputeServiceDependenciesModule.toPortableNodeStatus;
+ }
+
+ });
+ }
+
+ public void testWhenVDCIsLocation() {
+ Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description")
+ .scope(LocationScope.PROVIDER).build();
+ Injector injector = createInjectorWithLocation(location);
+ InputStream is = getClass().getResourceAsStream("/vapp-pool.xml");
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
+ VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
+ NodeMetadata node = converter.apply(result);
+ assertNotNull(node);
+ assertEquals(node.getUserMetadata(), ImmutableMap.<String, String>of());
+ assertEquals(node.getTags(), ImmutableSet.<String>of());
+ assertEquals(node.getLocation(), location);
+ assertEquals(node.getPrivateAddresses(), ImmutableSet.of("172.16.7.230"));
+ assertEquals(node.getPublicAddresses(), ImmutableSet.of());
+ }
+
+ public void testWithMetadataParseException() {
+ Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description")
+ .scope(LocationScope.PROVIDER).build();
+ Injector injector = createInjectorWithLocation(location);
+ InputStream is = getClass().getResourceAsStream("/vapp-pool.xml");
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
+ VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
+ ImmutableMap<String, String> metadata = ImmutableMap.<String, String>of();
+ ImmutableSet<String> tags = ImmutableSet.<String>of();
+
+ String description = " user=user_ssoid_1\nuid=3b7bb605-bb30-4e62-a3de-9076b052dee7 label='foo-DEVELOPMENT' date=2013-01-22 17:39:28.252";
+
+ result = new VAppImpl(result.getName(), result.getType(), result.getHref(), result.getStatus(), result.getVDC(),
+ description, result.getTasks(), result.isOvfDescriptorUploaded(), result.getChildren(),
+ result.getNetworkSection());
+
+ NodeMetadata node = converter.apply(result);
+ assertNotNull(node);
+ assertEquals(node.getUserMetadata(), metadata);
+ assertEquals(node.getTags(), tags);
+ }
+
+ public void testWithMetadataNoNewLines() {
+ Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description")
+ .scope(LocationScope.PROVIDER).build();
+ Injector injector = createInjectorWithLocation(location);
+ InputStream is = getClass().getResourceAsStream("/vapp-pool.xml");
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
+ VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
+ ImmutableMap<String, String> metadata = ImmutableMap.<String, String>of();
+ ImmutableSet<String> tags = ImmutableSet.<String>of();
+
+ String description = " user=user_ssoid_1 uid=3b7bb605-bb30-4e62-a3de-9076b052dee7 label='foo-DEVELOPMENT' date=2013-01-22 17:39:28.252";
+
+ result = new VAppImpl(result.getName(), result.getType(), result.getHref(), result.getStatus(), result.getVDC(),
+ description, result.getTasks(), result.isOvfDescriptorUploaded(), result.getChildren(),
+ result.getNetworkSection());
+
+ NodeMetadata node = converter.apply(result);
+ assertNotNull(node);
+ assertEquals(node.getUserMetadata(), metadata);
+ assertEquals(node.getTags(), tags);
+ }
+
+ public void testWithEncodedMetadata() {
+ Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description")
+ .scope(LocationScope.PROVIDER).build();
+ Injector injector = createInjectorWithLocation(location);
+ InputStream is = getClass().getResourceAsStream("/vapp-pool.xml");
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
+ VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
+ ImmutableMap<String, String> metadata = ImmutableMap.<String, String>of("foo", "bar");
+ ImmutableSet<String> tags = ImmutableSet.<String>of("tag1", "tag2");
+
+ String description = Joiner
+ .on('\n')
+ .withKeyValueSeparator("=")
+ .join(ImmutableMap.<String, String> builder().putAll(metadata)
+ .put("jclouds_tags", Joiner.on(',').join(tags)).build());
+
+ result = new VAppImpl(result.getName(), result.getType(), result.getHref(), result.getStatus(), result.getVDC(),
+ description, result.getTasks(), result.isOvfDescriptorUploaded(), result.getChildren(),
+ result.getNetworkSection());
+
+ NodeMetadata node = converter.apply(result);
+ assertNotNull(node);
+ assertEquals(node.getUserMetadata(), metadata);
+ assertEquals(node.getTags(), tags);
+
+ }
+
+ public void testGracefulWhenNoIPs() {
+ Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description")
+ .scope(LocationScope.PROVIDER).build();
+ Injector injector = createInjectorWithLocation(location);
+ InputStream is = getClass().getResourceAsStream("/vapp-none.xml");
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
+ VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
+ NodeMetadata node = converter.apply(result);
+ assertNotNull(node);
+ assertEquals(node.getLocation(), location);
+ assertEquals(node.getPrivateAddresses(), ImmutableSet.of());
+ assertEquals(node.getPublicAddresses(), ImmutableSet.of());
+ }
+
+ @Test(expectedExceptions = NoSuchElementException.class)
+ public void testGracefulWhenVDCIsNotLocation() {
+ Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/11111").description("description")
+ .scope(LocationScope.PROVIDER).build();
+ Injector injector = createInjectorWithLocation(location);
+ InputStream is = getClass().getResourceAsStream("/vapp-pool.xml");
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
+ VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
+ NodeMetadata node = converter.apply(result);
+ assertNotNull(node);
+ assertEquals(node.getLocation(), location);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java
new file mode 100644
index 0000000..f43a0e9
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.options;
+
+import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.blockOnPort;
+import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.customizationScript;
+import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.description;
+import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.inboundPorts;
+import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.parentNetwork;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Hashtable;
+
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.vcloud.domain.NetworkConnection;
+import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
+import org.jclouds.vcloud.endpoints.Network;
+import org.testng.annotations.Test;
+
+/**
+ * Tests possible uses of VCloudTemplateOptions and
+ * VCloudTemplateOptions.Builder.*
+ */
+public class VCloudTemplateOptionsTest {
+ @Test
+ public void testnetworkConnections() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ String netUuid = "https://myfunvcloud.com/api/admin/network/aaaabbbb-cccc-1122-3344-1234567890ab";
+ Hashtable<String, NetworkConnection> nets = new Hashtable<String, NetworkConnection>(1);
+ NetworkConnection nc = new NetworkConnection(netUuid, 0, null, null, true, null, IpAddressAllocationMode.POOL);
+ nets.put(netUuid, nc);
+ options.networkConnections(nets);
+ assertEquals(options.getNetworkConnections().get(netUuid), nc);
+ }
+
+ public void testAs() {
+ TemplateOptions options = new VCloudTemplateOptions();
+ assertEquals(options.as(VCloudTemplateOptions.class), options);
+ }
+
+ @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "customizationScript must be defined")
+ public void testcustomizationScriptBadFormat() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ options.customizationScript("");
+ }
+
+ @Test
+ public void testcustomizationScript() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ options.customizationScript("mykeypair");
+ assertEquals(options.getCustomizationScript(), "mykeypair");
+ }
+
+ @Test
+ public void testcustomizationScriptStatic() {
+ VCloudTemplateOptions options = customizationScript("mykeypair");
+ assertEquals(options.getCustomizationScript(), "mykeypair");
+ }
+
+ @Test
+ public void testNullparentNetwork() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ assertEquals(options.getParentNetwork(), null);
+ }
+
+ @Test
+ public void testparentNetwork() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ options.parentNetwork(URI.create("https://network"));
+ assertEquals(options.getParentNetwork(), URI.create("https://network"));
+ }
+
+ @Test
+ public void testparentNetworkStatic() {
+ VCloudTemplateOptions options = parentNetwork(URI.create("https://network"));
+ assertEquals(options.getParentNetwork(), URI.create("https://network"));
+ }
+
+ @Test
+ public void testdescription() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ options.description("mykeypair");
+ assertEquals(options.getDescription(), "mykeypair");
+ }
+
+ @Test
+ public void testdescriptionStatic() {
+ VCloudTemplateOptions options = description("mykeypair");
+ assertEquals(options.getDescription(), "mykeypair");
+ }
+
+ @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "customizationScript must be defined")
+ public void testcustomizationScriptNPE() {
+ customizationScript(null);
+ }
+
+ @Test
+ public void testinstallPrivateKey() throws IOException {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ options.installPrivateKey("-----BEGIN RSA PRIVATE KEY-----");
+ assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----");
+ }
+
+ @Test
+ public void testNullinstallPrivateKey() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ assertEquals(options.getPrivateKey(), null);
+ }
+
+ @Test
+ public void testauthorizePublicKey() throws IOException {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ options.authorizePublicKey("ssh-rsa");
+ assertEquals(options.getPublicKey(), "ssh-rsa");
+ }
+
+ @Test
+ public void testNullauthorizePublicKey() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ assertEquals(options.getPublicKey(), null);
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testblockOnPortBadFormat() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ options.blockOnPort(-1, -1);
+ }
+
+ @Test
+ public void testblockOnPort() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ options.blockOnPort(22, 30);
+ assertEquals(options.getPort(), 22);
+ assertEquals(options.getSeconds(), 30);
+
+ }
+
+ @Test
+ public void testNullblockOnPort() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ assertEquals(options.getPort(), -1);
+ assertEquals(options.getSeconds(), -1);
+ }
+
+ @Test
+ public void testblockOnPortStatic() {
+ VCloudTemplateOptions options = blockOnPort(22, 30);
+ assertEquals(options.getPort(), 22);
+ assertEquals(options.getSeconds(), 30);
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testinboundPortsBadFormat() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ options.inboundPorts(-1, -1);
+ }
+
+ @Test
+ public void testinboundPorts() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ options.inboundPorts(22, 30);
+ assertEquals(options.getInboundPorts()[0], 22);
+ assertEquals(options.getInboundPorts()[1], 30);
+
+ }
+
+ @Test
+ public void testDefaultOpen22() {
+ VCloudTemplateOptions options = new VCloudTemplateOptions();
+ assertEquals(options.getInboundPorts()[0], 22);
+ }
+
+ @Test
+ public void testinboundPortsStatic() {
+ VCloudTemplateOptions options = inboundPorts(22, 30);
+ assertEquals(options.getInboundPorts()[0], 22);
+ assertEquals(options.getInboundPorts()[1], 30);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java
new file mode 100644
index 0000000..2050e3f
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.strategy;
+
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.vcloud.compute.BaseVCloudComputeServiceExpectTest;
+import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.net.HttpHeaders;
+import com.jamesmurty.utils.XMLBuilder;
+
+@Test(singleThreaded = true, testName = "InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest")
+public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest extends
+ BaseVCloudComputeServiceExpectTest {
+
+ String ns = "http://www.vmware.com/vcloud/v1";
+ Properties outputProperties;
+ public InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest() {
+ outputProperties = new Properties();
+ outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+ }
+
+ HttpResponse successfulVersion1_0InstantiatedVApp = HttpResponse.builder()
+ .statusCode(200)
+ .message("HTTP/1.1 200 OK")
+ .payload(payloadFromResourceWithContentType("/instantiatedvapp.xml", "application/vnd.vmware.vcloud.vApp+xml")).build();
+
+ // TODO: finish me!
+ @Test(enabled = false)
+ public void testCreateNodeUsingVCloud1_0ApiAgainstVCloudDirector1_5WhenVAppTemplateHasNetworkNamedNone()
+ throws Exception {
+
+ String group = "group";
+ String name = "group-abcd";
+
+ String instantiateXML = XMLBuilder.create("InstantiateVAppTemplateParams")
+ .a("xmlns", ns).a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1")
+ .a("deploy", "false").a("name", name).a("powerOn", "false")
+ .e("Description").up()
+ .e("InstantiationParams")
+ .e("NetworkConfigSection")
+ .e("ovf:Info").t("Configuration parameters for logical networks").up()
+ .e("NetworkConfig").a("networkName", "orgNet-jclouds-External") // NOTE not "None"
+ .e("Configuration")
+ .e("ParentNetwork").a("href", ENDPOINT + "/v1.0/network/" + networkId).up()
+ .e("FenceMode").t("bridged").up()
+ .up()
+ .up()
+ .up()
+ .up()
+ .e("Source").a("href", ENDPOINT + "/v1.0/vAppTemplate/" + templateId).up()
+ .e("AllEULAsAccepted").t("true").up()
+ .asString(outputProperties);
+
+ HttpRequest version1_0InstantiateWithNetworkNamedSameAsOrgNetwork = HttpRequest.builder().method("POST")
+ .endpoint(ENDPOINT + "/v1.0/vdc/" + vdcId + "/action/instantiateVAppTemplate")
+ .addHeader(HttpHeaders.ACCEPT, "application/vnd.vmware.vcloud.vApp+xml;version=1.0")
+ .addHeader("x-vcloud-authorization", sessionToken)
+ .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken)
+ .payload(payloadFromStringWithContentType(instantiateXML, "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")).build();
+
+ ComputeService compute = requestsSendResponses(ImmutableMap.<HttpRequest, HttpResponse> builder()
+ .put(versionsRequest, versionsResponseFromVCD1_5)
+ .put(version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg)
+ .put(version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork)
+ .put(version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate)
+ .put(version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate)
+ .put(version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork)
+ .put(version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent)
+ .put(version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM)
+ .put(version1_0InstantiateWithNetworkNamedSameAsOrgNetwork, successfulVersion1_0InstantiatedVApp).build());
+
+ InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn starter = compute.getContext()
+ .utils().injector().getInstance(
+ InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.class);
+
+
+ NodeAndInitialCredentials<VApp> appAndCreds = starter.createNodeWithGroupEncodedIntoName(group, name, compute
+ .templateBuilder().build());
+
+ assertEquals(appAndCreds.getNode().getName(), name);
+ assertEquals(appAndCreds.getCredentials(), LoginCredentials.builder().user("root").password("fromVApp").build());
+
+ }
+
+ public void testInstantiateVAppFromTemplateWhenUsingOverriddenNetworkAndFenceMode()
+ throws Exception {
+
+ String name = "group-abcd";
+ FenceMode fenceMode = FenceMode.NAT_ROUTED;
+ URI parentNetwork = URI.create(ENDPOINT + "/v1.0/network/" + "foooooooo");
+
+ String instantiateXML = XMLBuilder.create("InstantiateVAppTemplateParams")
+ .a("xmlns", ns).a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1")
+ .a("deploy", "false").a("name", name).a("powerOn", "false")
+ .e("Description").up()
+ .e("InstantiationParams")
+ .e("NetworkConfigSection")
+ .e("ovf:Info").t("Configuration parameters for logical networks").up()
+ .e("NetworkConfig").a("networkName", "jclouds") // NOTE not "None"
+ .e("Configuration")
+ .e("ParentNetwork").a("href", parentNetwork.toASCIIString()).up()
+ .e("FenceMode").t(fenceMode.toString()).up()
+ .up()
+ .up()
+ .up()
+ .up()
+ .e("Source").a("href", ENDPOINT + "/v1.0/vAppTemplate/" + templateId).up()
+ .e("AllEULAsAccepted").t("true").up()
+ .asString(outputProperties);
+
+ HttpRequest version1_0InstantiateWithCustomizedNetwork = HttpRequest.builder().method("POST")
+ .endpoint(ENDPOINT + "/v1.0/vdc/" + vdcId + "/action/instantiateVAppTemplate")
+ .addHeader(HttpHeaders.ACCEPT, "application/vnd.vmware.vcloud.vApp+xml;version=1.0")
+ .addHeader("x-vcloud-authorization", sessionToken)
+ .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken)
+ .payload(payloadFromStringWithContentType(instantiateXML, "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")).build();
+
+ ComputeService compute = requestsSendResponses(ImmutableMap.<HttpRequest, HttpResponse> builder()
+ .put(versionsRequest, versionsResponseFromVCD1_5)
+ .put(version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg)
+ .put(version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork)
+ .put(version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate)
+ .put(version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate)
+ .put(version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork)
+ .put(version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent)
+ .put(version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM)
+ .put(version1_0InstantiateWithCustomizedNetwork, successfulVersion1_0InstantiatedVApp).build());
+
+ InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn starter = compute.getContext()
+ .utils().injector().getInstance(
+ InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.class);
+
+ Template template = compute.templateBuilder().build();
+ String[] netlist = new String[1];
+ netlist[0] = parentNetwork.toASCIIString();
+ template.getOptions().as(VCloudTemplateOptions.class).fenceMode(fenceMode).networks(netlist);
+ starter.instantiateVAppFromTemplate(name, template);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java
new file mode 100644
index 0000000..232b151
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.strategy;
+
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.vcloud.compute.BaseVCloudComputeServiceExpectTest;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+public class VCloudComputeServiceAdapterTest extends BaseVCloudComputeServiceExpectTest {
+
+ @Test
+ public void testListHardwareProfiles() throws Exception {
+ ComputeService compute = requestsSendResponses(ImmutableMap.<HttpRequest, HttpResponse> builder()
+ .put(versionsRequest, versionsResponseFromVCD1_5)
+ .put(version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg)
+ .put(version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork)
+ .put(version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate)
+ .put(version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate)
+ .put(version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork)
+ .put(version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent)
+ .put(version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM)
+ .build());
+
+ VCloudComputeServiceAdapter adapter = compute.getContext()
+ .utils().injector().getInstance(VCloudComputeServiceAdapter.class);
+
+ Iterable<VAppTemplate> hardwareProfiles = adapter.listHardwareProfiles();
+
+ Iterable<URI> hardwareProfileRefs = Iterables.transform(ImmutableList.copyOf(hardwareProfiles), new Function<VAppTemplate, URI>() {
+ @Override public URI apply(VAppTemplate input) {
+ return input.getHref();
+ }
+ });
+ assertEquals(ImmutableSet.copyOf(hardwareProfileRefs), ImmutableSet.of(URI.create("https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728")));
+ }
+
+ /**
+ * For issue 994. In BaseEnvelopeHandler when it encounters VirtualSystemCollection, it throws IllegalArgumentException
+ * (cannot currently create envelopes with multiple virtual systems).
+ * Thus we do not include the VM in the supported set, but we do return without propagating the exception.
+ */
+ @Test
+ public void testListHardwareProfilesWithUnsupportedTemplate() throws Exception {
+ ComputeService compute = requestsSendResponses(ImmutableMap.<HttpRequest, HttpResponse> builder()
+ .put(versionsRequest, versionsResponseFromVCD1_5)
+ .put(version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg)
+ .put(version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork)
+ .put(version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate)
+ .put(version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate)
+ .put(version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork)
+ .put(version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithMultipleVMsAndVDCParent)
+ .put(version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithMultipleVMs)
+ .build());
+
+ VCloudComputeServiceAdapter adapter = compute.getContext()
+ .utils().injector().getInstance(VCloudComputeServiceAdapter.class);
+
+ Iterable<VAppTemplate> hardwareProfiles = adapter.listHardwareProfiles();
+
+ assertEquals(ImmutableSet.copyOf(hardwareProfiles), ImmutableSet.of());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java
new file mode 100644
index 0000000..a787afb
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.rest.annotations.ApiVersion;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.inject.Key;
+
+@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CatalogApiLiveTest")
+public class CatalogApiLiveTest extends BaseVCloudApiLiveTest {
+ @Test
+ public void testGetCatalog() throws Exception {
+ Org org = getVCloudApi().getOrgApi().findOrgNamed(null);
+ for (ReferenceType catalog : org.getCatalogs().values()) {
+ assertEquals(catalog.getType(), VCloudMediaType.CATALOG_XML);
+ assertNotNull(getVCloudApi().getCatalogApi().getCatalog(catalog.getHref()));
+ }
+ }
+
+ @Test
+ public void testFindCatalogIsWriteableIfNotVersion1_5() throws Exception {
+ // when we are in vCloud 1.0.0 public catalogs don't work, so our default
+ // catalog is private
+ if (!view.utils().injector().getInstance(Key.get(String.class, ApiVersion.class)).startsWith("1.5"))
+ assertTrue(getVCloudApi().getCatalogApi().findCatalogInOrgNamed(null, null).isReadOnly());
+ }
+}
[18/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_list_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_list_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_list_response.json
new file mode 100644
index 0000000..14dcfae
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_list_response.json
@@ -0,0 +1,74 @@
+{"routers": [
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "16dba3bc-f3fa-4775-afdc-237e12c72f6a"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "31083ae2-420d-48b2-ac98-9f7a4fd8dbdc"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "49c6d6fa-ff2a-459d-b975-75a8d31c9a89"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "5d51d012-3491-4db7-b1b5-6f254015015d"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5f9cf7dc-22ca-4097-8e49-1cc8b23faf17"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6319ecad-6bff-48b2-9b53-02ede8cb7588"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6ba4c788-661f-49ab-9bf8-5f10cbbb2f57"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "74ed170b-5069-4353-ab38-9719766dc57e"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "b71fcac1-e864-4031-8c5b-edbecd9ece36"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "c7681895-d84d-4650-9ca0-82c72036b855"
+ }
+]}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_list_response_paged1.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_list_response_paged1.json
new file mode 100644
index 0000000..ef67e54
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_list_response_paged1.json
@@ -0,0 +1,34 @@
+{
+ "routers": [
+ {
+ "status": "ACTIVE",
+ "external_gateway_info": {
+ "network_id": "3c5bcddd-6af9-4e6b-9c3e-c153e521cab8"
+ },
+ "name": "router1",
+ "admin_state_up": true,
+ "tenant_id": "33a40233088643acb66ff6eb0ebea679",
+ "id": "a9254bdb-2613-4a13-ac4c-adc581fba50d"
+ },
+ {
+ "status": "ACTIVE",
+ "external_gateway_info": {
+ "network_id": "3c5bcddd-6af9-4e6b-9c3e-c153e521cab8_2"
+ },
+ "name": "router2",
+ "admin_state_up": true,
+ "tenant_id": "33a40233088643acb66ff6eb0ebea679_2",
+ "id": "a9254bdb-2613-4a13-ac4c-adc581fba50d_2"
+ }
+ ],
+ "routers_links": [
+ {
+ "href": "/v2.0/routers.json?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718",
+ "rel": "next"
+ },
+ {
+ "href": "/v2.0/routers.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_list_response_paged2.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_list_response_paged2.json
new file mode 100644
index 0000000..decec75
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_list_response_paged2.json
@@ -0,0 +1,30 @@
+{
+ "routers": [
+ {
+ "status": "ACTIVE",
+ "external_gateway_info": {
+ "network_id": "3c5bcddd-6af9-4e6b-9c3e-c153e521cab8_3"
+ },
+ "name": "router3",
+ "admin_state_up": true,
+ "tenant_id": "33a40233088643acb66ff6eb0ebea679_3",
+ "id": "a9254bdb-2613-4a13-ac4c-adc581fba50d_3"
+ },
+ {
+ "status": "ACTIVE",
+ "external_gateway_info": {
+ "network_id": "3c5bcddd-6af9-4e6b-9c3e-c153e521cab8_4"
+ },
+ "name": "router4",
+ "admin_state_up": true,
+ "tenant_id": "33a40233088643acb66ff6eb0ebea679_4",
+ "id": "a9254bdb-2613-4a13-ac4c-adc581fba50d_4"
+ }
+ ],
+ "routers_links": [
+ {
+ "href": "/v2.0/routers.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_remove_interface_port_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_remove_interface_port_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_remove_interface_port_request.json
new file mode 100644
index 0000000..bae800a
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_remove_interface_port_request.json
@@ -0,0 +1,3 @@
+{
+ "port_id": "portid"
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_remove_interface_subnet_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_remove_interface_subnet_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_remove_interface_subnet_request.json
new file mode 100644
index 0000000..107e6e4
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_remove_interface_subnet_request.json
@@ -0,0 +1,3 @@
+{
+ "subnet_id": "a2f1f29d-571b-4533-907f-5803ab96ead1"
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_update_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_update_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_update_request.json
new file mode 100644
index 0000000..351c427
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_update_request.json
@@ -0,0 +1,7 @@
+{
+ "router": {
+ "external_gateway_info": {
+ "network_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b"
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_update_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_update_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_update_response.json
new file mode 100644
index 0000000..d851d76
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/router_update_response.json
@@ -0,0 +1,12 @@
+{
+ "router": {
+ "status": "ACTIVE",
+ "external_gateway_info": {
+ "network_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b"
+ },
+ "name": "another_router",
+ "admin_state_up": true,
+ "tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
+ "id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_create_request.json
new file mode 100644
index 0000000..8a93ef9
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_create_request.json
@@ -0,0 +1,6 @@
+{
+ "security_group": {
+ "name": "new-webservers",
+ "description": "security group for webservers"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_create_response.json
new file mode 100644
index 0000000..1ded327
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_create_response.json
@@ -0,0 +1,34 @@
+{
+ "security_group": {
+ "description": "security group for webservers",
+ "id": "2076db17-a522-4506-91de-c6dd8e837028",
+ "name": "new-webservers",
+ "security_group_rules": [
+ {
+ "direction": "egress",
+ "ethertype": "IPv4",
+ "id": "38ce2d8e-e8f1-48bd-83c2-d33cb9f50c3d",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "2076db17-a522-4506-91de-c6dd8e837028",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "egress",
+ "ethertype": "IPv6",
+ "id": "565b9502-12de-4ffd-91e9-68885cff6ae1",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "2076db17-a522-4506-91de-c6dd8e837028",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ],
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_get_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_get_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_get_response.json
new file mode 100644
index 0000000..126b5d2
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_get_response.json
@@ -0,0 +1,58 @@
+{
+ "security_group": {
+ "description": "default",
+ "id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "name": "default",
+ "security_group_rules": [
+ {
+ "direction": "egress",
+ "ethertype": "IPv6",
+ "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "egress",
+ "ethertype": "IPv4",
+ "id": "93aa42e5-80db-4581-9391-3a608bd0e448",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv6",
+ "id": "c0b09f00-1d49-4e64-a0a7-8a186d928138",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv4",
+ "id": "f7d45c89-008e-4bab-88ad-d6811724c51c",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ],
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_list_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_list_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_list_response.json
new file mode 100644
index 0000000..c0cf747
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_list_response.json
@@ -0,0 +1,116 @@
+{
+ "security_groups": [
+ {
+ "description": "default",
+ "id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "name": "default",
+ "security_group_rules": [
+ {
+ "direction": "egress",
+ "ethertype": "IPv6",
+ "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "egress",
+ "ethertype": "IPv4",
+ "id": "93aa42e5-80db-4581-9391-3a608bd0e448",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv6",
+ "id": "c0b09f00-1d49-4e64-a0a7-8a186d928138",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv4",
+ "id": "f7d45c89-008e-4bab-88ad-d6811724c51c",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ],
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "description": "default",
+ "id": "85cc3048-abc3-43cc-89b3-377341426ac52",
+ "name": "default",
+ "security_group_rules": [
+ {
+ "direction": "egress",
+ "ethertype": "IPv6",
+ "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff2",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "egress",
+ "ethertype": "IPv4",
+ "id": "93aa42e5-80db-4581-9391-3a608bd0e4482",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv6",
+ "id": "c0b09f00-1d49-4e64-a0a7-8a186d9281382",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv4",
+ "id": "f7d45c89-008e-4bab-88ad-d6811724c51c2",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ],
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_list_response_paged1.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_list_response_paged1.json
new file mode 100644
index 0000000..dcf91c8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_list_response_paged1.json
@@ -0,0 +1,126 @@
+{
+ "security_groups": [
+ {
+ "description": "default",
+ "id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "name": "default",
+ "security_group_rules": [
+ {
+ "direction": "egress",
+ "ethertype": "IPv6",
+ "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "egress",
+ "ethertype": "IPv4",
+ "id": "93aa42e5-80db-4581-9391-3a608bd0e448",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv6",
+ "id": "c0b09f00-1d49-4e64-a0a7-8a186d928138",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv4",
+ "id": "f7d45c89-008e-4bab-88ad-d6811724c51c",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ],
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "description": "default",
+ "id": "85cc3048-abc3-43cc-89b3-377341426ac52",
+ "name": "default",
+ "security_group_rules": [
+ {
+ "direction": "egress",
+ "ethertype": "IPv6",
+ "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff2",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "egress",
+ "ethertype": "IPv4",
+ "id": "93aa42e5-80db-4581-9391-3a608bd0e4482",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv6",
+ "id": "c0b09f00-1d49-4e64-a0a7-8a186d9281382",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv4",
+ "id": "f7d45c89-008e-4bab-88ad-d6811724c51c2",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ],
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ],
+ "security_groups_links": [
+ {
+ "href": "/v2.0/security-groups.json?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718",
+ "rel": "next"
+ },
+ {
+ "href": "/v2.0/security-groups.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_list_response_paged2.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_list_response_paged2.json
new file mode 100644
index 0000000..ded8067
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_list_response_paged2.json
@@ -0,0 +1,122 @@
+{
+ "security_groups": [
+ {
+ "description": "default",
+ "id": "85cc3048-abc3-43cc-89b3-377341426ac53",
+ "name": "default",
+ "security_group_rules": [
+ {
+ "direction": "egress",
+ "ethertype": "IPv6",
+ "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "egress",
+ "ethertype": "IPv4",
+ "id": "93aa42e5-80db-4581-9391-3a608bd0e448",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv6",
+ "id": "c0b09f00-1d49-4e64-a0a7-8a186d928138",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv4",
+ "id": "f7d45c89-008e-4bab-88ad-d6811724c51c",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ],
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "description": "default",
+ "id": "85cc3048-abc3-43cc-89b3-377341426ac524",
+ "name": "default",
+ "security_group_rules": [
+ {
+ "direction": "egress",
+ "ethertype": "IPv6",
+ "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff2",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "egress",
+ "ethertype": "IPv4",
+ "id": "93aa42e5-80db-4581-9391-3a608bd0e4482",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv6",
+ "id": "c0b09f00-1d49-4e64-a0a7-8a186d9281382",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv4",
+ "id": "f7d45c89-008e-4bab-88ad-d6811724c51c2",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ],
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ],
+ "security_groups_links": [
+ {
+ "href": "/v2.0/security-groups.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_create_request.json
new file mode 100644
index 0000000..14bea85
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_create_request.json
@@ -0,0 +1,11 @@
+{
+ "security_group_rule": {
+ "direction": "ingress",
+ "port_range_min": 80,
+ "ethertype": "IPv4",
+ "port_range_max": 80,
+ "protocol": "tcp",
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "security_group_id": "a7734e61-b545-452d-a3cd-0189cbd9747a"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_create_response.json
new file mode 100644
index 0000000..0037e94
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_create_response.json
@@ -0,0 +1,15 @@
+{
+ "security_group_rule": {
+ "direction": "ingress",
+ "ethertype": "IPv4",
+ "id": "2bc0accf-312e-429a-956e-e4407625eb62",
+ "port_range_max": 80,
+ "port_range_min": 80,
+ "protocol": "tcp",
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "a7734e61-b545-452d-a3cd-0189cbd9747a",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_get_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_get_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_get_response.json
new file mode 100644
index 0000000..7225101
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_get_response.json
@@ -0,0 +1,14 @@
+{
+ "security_group_rule": {
+ "direction": "egress",
+ "ethertype": "IPv6",
+ "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_list_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_list_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_list_response.json
new file mode 100644
index 0000000..fbdeddf
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_list_response.json
@@ -0,0 +1,52 @@
+{
+ "security_group_rules": [
+ {
+ "direction": "egress",
+ "ethertype": "IPv6",
+ "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "egress",
+ "ethertype": "IPv4",
+ "id": "93aa42e5-80db-4581-9391-3a608bd0e448",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv6",
+ "id": "c0b09f00-1d49-4e64-a0a7-8a186d928138",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv4",
+ "id": "f7d45c89-008e-4bab-88ad-d6811724c51c",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_list_response_paged1.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_list_response_paged1.json
new file mode 100644
index 0000000..5ecbfd3
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_list_response_paged1.json
@@ -0,0 +1,62 @@
+{
+ "security_group_rules": [
+ {
+ "direction": "egress",
+ "ethertype": "IPv6",
+ "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "egress",
+ "ethertype": "IPv4",
+ "id": "93aa42e5-80db-4581-9391-3a608bd0e448",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv6",
+ "id": "c0b09f00-1d49-4e64-a0a7-8a186d928138",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv4",
+ "id": "f7d45c89-008e-4bab-88ad-d6811724c51c",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ],
+ "security_group_rules_links": [
+ {
+ "href": "/v2.0/security-group-rules.json?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718",
+ "rel": "next"
+ },
+ {
+ "href": "/v2.0/security-group-rules.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_list_response_paged2.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_list_response_paged2.json
new file mode 100644
index 0000000..1688ede
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/security_group_rule_list_response_paged2.json
@@ -0,0 +1,58 @@
+{
+ "security_group_rules": [
+ {
+ "direction": "egress",
+ "ethertype": "IPv6",
+ "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff2",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "egress",
+ "ethertype": "IPv4",
+ "id": "93aa42e5-80db-4581-9391-3a608bd0e4482",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": null,
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv6",
+ "id": "c0b09f00-1d49-4e64-a0a7-8a186d9281382",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ },
+ {
+ "direction": "ingress",
+ "ethertype": "IPv4",
+ "id": "f7d45c89-008e-4bab-88ad-d6811724c51c2",
+ "port_range_max": null,
+ "port_range_min": null,
+ "protocol": null,
+ "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "remote_ip_prefix": null,
+ "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
+ "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
+ }
+ ],
+ "security_group_rules_links": [
+ {
+ "href": "/v2.0/security-group-rules.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet.json
new file mode 100644
index 0000000..58c4382
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet.json
@@ -0,0 +1,8 @@
+{"subnet": {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-wibble",
+ "tenant_id": "1234567890",
+ "id": "624312ff-d14b-4ba3-9834-1c78d23d574d"
+}}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_bulk_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_bulk_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_bulk_create_request.json
new file mode 100644
index 0000000..0bb8460
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_bulk_create_request.json
@@ -0,0 +1,14 @@
+{
+ "subnets": [
+ {
+ "cidr": "192.168.199.0/24",
+ "ip_version": 4,
+ "network_id": "e6031bc2-901a-4c66-82da-f4c32ed89406"
+ },
+ {
+ "cidr": "10.56.4.0/22",
+ "ip_version": 4,
+ "network_id": "64239a54-dcc4-4b39-920b-b37c2144effa"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_bulk_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_bulk_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_bulk_create_response.json
new file mode 100644
index 0000000..f643084
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_bulk_create_response.json
@@ -0,0 +1,48 @@
+{
+ "subnets": [
+ {
+ "allocation_pools": [
+ {
+ "end": "192.168.199.254",
+ "start": "192.168.199.2"
+ }
+ ],
+ "cidr": "192.168.199.0/24",
+ "dns_nameservers": [
+
+ ],
+ "enable_dhcp": true,
+ "gateway_ip": "192.168.199.1",
+ "host_routes": [
+
+ ],
+ "id": "0468a7a7-290d-4127-aedd-6c9449775a24",
+ "ip_version": 4,
+ "name": "",
+ "network_id": "e6031bc2-901a-4c66-82da-f4c32ed89406",
+ "tenant_id": "d19231fc08ec4bc4829b668040d34512"
+ },
+ {
+ "allocation_pools": [
+ {
+ "end": "10.56.7.254",
+ "start": "10.56.4.2"
+ }
+ ],
+ "cidr": "10.56.4.0/22",
+ "dns_nameservers": [
+
+ ],
+ "enable_dhcp": true,
+ "gateway_ip": "10.56.4.1",
+ "host_routes": [
+
+ ],
+ "id": "b0e7435c-1512-45fb-aa9e-9a7c5932fb30",
+ "ip_version": 4,
+ "name": "",
+ "network_id": "64239a54-dcc4-4b39-920b-b37c2144effa",
+ "tenant_id": "d19231fc08ec4bc4829b668040d34512"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_create_request.json
new file mode 100644
index 0000000..49a53b6
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_create_request.json
@@ -0,0 +1,6 @@
+{"subnet": {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-wibble"
+}}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_create_response.json
new file mode 100644
index 0000000..58c4382
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_create_response.json
@@ -0,0 +1,8 @@
+{"subnet": {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-wibble",
+ "tenant_id": "1234567890",
+ "id": "624312ff-d14b-4ba3-9834-1c78d23d574d"
+}}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_get_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_get_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_get_response.json
new file mode 100644
index 0000000..aead0f9
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_get_response.json
@@ -0,0 +1,9 @@
+{"subnet": {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-wibble",
+ "tenant_id": "1234567890",
+ "id": "624312ff-d14b-4ba3-9834-1c78d23d574d",
+ "ipv6_address_mode": "slaac"
+}}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_list_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_list_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_list_response.json
new file mode 100644
index 0000000..b0061e9
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_list_response.json
@@ -0,0 +1,98 @@
+{"subnets": [
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "16dba3bc-f3fa-4775-afdc-237e12c72f6a"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "31083ae2-420d-48b2-ac98-9f7a4fd8dbdc"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "49c6d6fa-ff2a-459d-b975-75a8d31c9a89"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "5d51d012-3491-4db7-b1b5-6f254015015d"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "5f9cf7dc-22ca-4097-8e49-1cc8b23faf17"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6319ecad-6bff-48b2-9b53-02ede8cb7588"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6ba4c788-661f-49ab-9bf8-5f10cbbb2f57"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "74ed170b-5069-4353-ab38-9719766dc57e"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "b71fcac1-e864-4031-8c5b-edbecd9ece36"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "c7681895-d84d-4650-9ca0-82c72036b855"
+ }
+]}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_list_response_pages1.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_list_response_pages1.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_list_response_pages1.json
new file mode 100644
index 0000000..10b3aaa
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_list_response_pages1.json
@@ -0,0 +1,30 @@
+{
+ "subnets": [
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "16dba3bc-f3fa-4775-afdc-237e12c72f6a"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "wibble",
+ "tenant_id": "1234567890",
+ "id": "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"
+ }
+ ],
+ "subnets_links": [
+ {
+ "href": "/v2.0/subnets.json?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718",
+ "rel": "next"
+ },
+ {
+ "href": "/v2.0/subnets.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_list_response_pages2.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_list_response_pages2.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_list_response_pages2.json
new file mode 100644
index 0000000..0319fbe
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_list_response_pages2.json
@@ -0,0 +1,26 @@
+{
+ "subnets": [
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6319ecad-6bff-48b2-9b53-02ede8cb7588"
+ },
+ {
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "network_id": "1234567890",
+ "name": "jclouds-test",
+ "tenant_id": "1234567890",
+ "id": "6ba4c788-661f-49ab-9bf8-5f10cbbb2f57"
+ }
+ ],
+ "subnets_links": [
+ {
+ "href": "/v2.0/subnets.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_update_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_update_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_update_request.json
new file mode 100644
index 0000000..6345647
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_update_request.json
@@ -0,0 +1,6 @@
+{
+ "subnet": {
+ "gateway_ip": "10.0.3.254",
+ "name": "new_name"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_update_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_update_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_update_response.json
new file mode 100644
index 0000000..40c65e9
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/subnet_update_response.json
@@ -0,0 +1,18 @@
+{
+ "subnet": {
+ "name": "new_name",
+ "network_id": "ed2e3c10-2e43-4297-9006-2863a2d1abbc",
+ "tenant_id": "c1210485b2424d48804aad5d39c61b8f",
+ "allocation_pools": [
+ {
+ "start": "10.0.3.20",
+ "end": "10.0.3.150"
+ }
+ ],
+ "gateway_ip": "10.0.3.254",
+ "ip_version": 4,
+ "cidr": "10.0.3.0/24",
+ "enable_dhcp": true,
+ "id": "9436e561-47bf-436a-b1f1-fe23a926e031"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/README.md
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/README.md b/dependencies/jclouds/apis/openstack-neutron/README.md
new file mode 100644
index 0000000..acf9320
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/README.md
@@ -0,0 +1,23 @@
+Why OpenStack Neutron forked?
+============================
+
+Openstack-neutron 1.8.1 manifest file is malformed in released version.
+This message is passed to Jclouds team and they fixed it in master branch. But it will not be back ported to 1.8.1 release.
+So we have to clone openstack-neutron temporarly.
+When we upgrade to next version we can safely remove openstack-neutron clone from Stratos code base.
+
+Custom changes
+==============
+
+In openstack-neutron/pom.xml,
+
+- <jclouds.osgi.export>org.jclouds.openstack.neutron.v2_0*;version="${project.version}"</jclouds.osgi.export>
+- <jclouds.osgi.import>
+- org.jclouds.rest.internal;version="${jclouds.version}",
+- org.jclouds.labs*;version="${project.version}",
+- org.jclouds*;version="${jclouds.version}",
+- *
+- </jclouds.osgi.import>
++ <jclouds.osgi.export>org.jclouds.openstack.neutron.v2*;version="${project.version}"</jclouds.osgi.export>
++ <jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/README.txt
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/README.txt b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/README.txt
new file mode 100644
index 0000000..b00a7af
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/README.txt
@@ -0,0 +1,6 @@
+#
+# The jclouds API for VMware vCloud (http://www.vmware.com/products/vcloud/).
+#
+# TODO: Implementation status.
+# TODO: Supported features.
+# TODO: Usage example.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/pom.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/pom.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/pom.xml
new file mode 100644
index 0000000..bc8951a
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/pom.xml
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-project</artifactId>
+ <version>1.8.1</version>
+ </parent>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>vcloud</artifactId>
+ <version>1.8.1-stratosv1</version>
+ <name>jclouds vcloud api</name>
+ <description>jclouds components to access an implementation of VMWare vCloud</description>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <jclouds.version>1.8.1</jclouds.version>
+ <test.vcloud.endpoint>FIXME_ENDPOINT</test.vcloud.endpoint>
+ <test.vcloud.api-version>1.0</test.vcloud.api-version>
+ <test.vcloud.build-version/>
+ <test.vcloud.identity>FIXME_IDENTITY</test.vcloud.identity>
+ <test.vcloud.credential>FIXME_CREDENTIAL</test.vcloud.credential>
+ <test.vcloud.template/>
+ <jclouds.osgi.export>org.jclouds.vcloud*;version="${project.version}"</jclouds.osgi.export>
+ <jclouds.osgi.import>
+ org.jclouds.compute.internal;version="${jclouds.version}",
+ org.jclouds.rest.internal;version="${jclouds.version}",
+ org.jclouds*;version="${jclouds.version}",
+ *
+ </jclouds.osgi.import>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.jamesmurty.utils</groupId>
+ <artifactId>java-xmlbuilder</artifactId>
+ <version>0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-core</artifactId>
+ <version>${jclouds.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-core</artifactId>
+ <version>${jclouds.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-compute</artifactId>
+ <version>${jclouds.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-compute</artifactId>
+ <version>${jclouds.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-sshj</artifactId>
+ <version>${jclouds.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-log4j</artifactId>
+ <version>${jclouds.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>live</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>integration</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+ <test.vcloud.endpoint>${test.vcloud.endpoint}</test.vcloud.endpoint>
+ <test.vcloud.api-version>${test.vcloud.api-version}</test.vcloud.api-version>
+ <test.vcloud.build-version>${test.vcloud.build-version}
+ </test.vcloud.build-version>
+ <test.vcloud.identity>${test.vcloud.identity}</test.vcloud.identity>
+ <test.vcloud.credential>${test.vcloud.credential}</test.vcloud.credential>
+ <test.vcloud.template>${test.vcloud.template}</test.vcloud.template>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java
new file mode 100644
index 0000000..fb54599
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+
+import org.jclouds.vcloud.domain.Task;
+
+public class TaskInErrorStateException extends RuntimeException {
+
+ private final Task task;
+
+ public TaskInErrorStateException(Task task) {
+ super("error on task: " + task + " error: " + task.getError());
+ this.task = task;
+ }
+
+ public Task getTask() {
+ return task;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java
new file mode 100644
index 0000000..64eafbe
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+
+import org.jclouds.vcloud.domain.Task;
+
+public class TaskStillRunningException extends RuntimeException {
+
+ private final Task task;
+
+ public TaskStillRunningException(Task task) {
+ super("task still running: " + task);
+ this.task = task;
+ }
+
+ public Task getTask() {
+ return task;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApi.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApi.java
new file mode 100644
index 0000000..1c3b46c
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApi.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+
+import java.io.Closeable;
+
+import org.jclouds.rest.annotations.Delegate;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.vcloud.features.CatalogApi;
+import org.jclouds.vcloud.features.NetworkApi;
+import org.jclouds.vcloud.features.OrgApi;
+import org.jclouds.vcloud.features.TaskApi;
+import org.jclouds.vcloud.features.VAppApi;
+import org.jclouds.vcloud.features.VAppTemplateApi;
+import org.jclouds.vcloud.features.VDCApi;
+import org.jclouds.vcloud.features.VmApi;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+
+/**
+ * Provides access to VCloud resources via their REST API.
+ * <p/>
+ *
+ * @see <a href="http://communities.vmware.com/community/developer/forums/vcloudapi" />
+ */
+@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
+public interface VCloudApi extends Closeable {
+ /**
+ * Provides asynchronous access to VApp Template features.
+ *
+ */
+ @Delegate
+ VAppTemplateApi getVAppTemplateApi();
+
+ /**
+ * Provides synchronous access to VApp features.
+ */
+ @Delegate
+ VAppApi getVAppApi();
+
+ /**
+ * Provides synchronous access to Vm features.
+ */
+ @Delegate
+ VmApi getVmApi();
+
+ /**
+ * Provides synchronous access to Catalog features.
+ */
+ @Delegate
+ CatalogApi getCatalogApi();
+
+ /**
+ * Provides synchronous access to Task features.
+ */
+ @Delegate
+ TaskApi getTaskApi();
+
+ /**
+ * Provides synchronous access to VDC features.
+ */
+ @Delegate
+ VDCApi getVDCApi();
+
+ /**
+ * Provides synchronous access to Network features.
+ */
+ @Delegate
+ NetworkApi getNetworkApi();
+
+ /**
+ * Provides synchronous access to Org features.
+ */
+ @Delegate
+ OrgApi getOrgApi();
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java
new file mode 100644
index 0000000..4c88d8a
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
+import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
+import static org.jclouds.reflect.Reflection2.typeToken;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
+import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule;
+import org.jclouds.vcloud.config.VCloudHttpApiModule;
+import org.jclouds.vcloud.domain.network.FenceMode;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+
+/**
+ * Implementation of {@link ApiMetadata} for VCloud 1.0 API
+ */
+public class VCloudApiMetadata extends BaseHttpApiMetadata<VCloudApi> {
+
+
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
+ }
+
+ public VCloudApiMetadata() {
+ this(new Builder());
+ }
+
+ protected VCloudApiMetadata(Builder builder) {
+ super(builder);
+ }
+
+ public static Properties defaultProperties() {
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
+ properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "1");
+ properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE,
+ String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_VERSION_SCHEMA));
+ properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + "");
+ properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd");
+ properties.setProperty("jclouds.dns_name_length_min", "1");
+ properties.setProperty("jclouds.dns_name_length_max", "80");
+ properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.BRIDGED.toString());
+ // TODO integrate this with the {@link ComputeTimeouts} instead of having
+ // a single timeout for
+ // everything.
+ properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 1200l * 1000l + "");
+ properties.setProperty(PROPERTY_SESSION_INTERVAL, 300 + "");
+ // CIM ostype does not include version info
+ properties.setProperty(TEMPLATE, "osFamily=UBUNTU,os64Bit=true");
+ return properties;
+ }
+
+ public static class Builder extends BaseHttpApiMetadata.Builder<VCloudApi, Builder> {
+ protected Builder() {
+ id("vcloud")
+ .name("VCloud 1.0 API")
+ .identityName("User at Organization (user@org)")
+ .credentialName("Password")
+ .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html"))
+ .version("1.0")
+ .defaultProperties(VCloudApiMetadata.defaultProperties())
+ .view(typeToken(ComputeServiceContext.class))
+ .defaultModules(ImmutableSet.<Class<? extends Module>>of(VCloudHttpApiModule.class, VCloudComputeServiceContextModule.class));
+ }
+
+ @Override
+ public VCloudApiMetadata build() {
+ return new VCloudApiMetadata(this);
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+ }
+}
[09/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java
new file mode 100644
index 0000000..92b3c2e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.location;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.location.Iso3166;
+import org.jclouds.location.Provider;
+import org.jclouds.location.suppliers.LocationsSupplier;
+import org.jclouds.location.suppliers.all.JustProvider;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+import com.google.common.collect.Iterables;
+
+@Singleton
+public class OrgAndVDCToLocationSupplier extends JustProvider implements LocationsSupplier {
+
+ private final Supplier<Map<String, ReferenceType>> orgNameToResource;
+ private final Supplier<Map<String, Org>> orgNameToVDCResource;
+ private final Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier;
+
+ @Inject
+ OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName,
+ @Provider Supplier<URI> endpoint,
+ @org.jclouds.vcloud.endpoints.Org Supplier<Map<String, ReferenceType>> orgNameToResource,
+ Supplier<Map<String, Org>> orgNameToVDCResource,
+ @Iso3166 Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier) {
+ super(providerName, endpoint, isoCodes);
+ this.orgNameToResource = checkNotNull(orgNameToResource, "orgNameToResource");
+ this.orgNameToVDCResource = checkNotNull(orgNameToVDCResource, "orgNameToVDCResource");
+ this.isoCodesByIdSupplier = checkNotNull(isoCodesByIdSupplier, "isoCodesByIdSupplier");
+ }
+
+ @Override
+ public Set<Location> get() {
+ return buildJustProviderOrVDCs().build();
+ }
+
+ protected Builder<Location> buildJustProviderOrVDCs() {
+ Builder<Location> locations = ImmutableSet.builder();
+ Location provider = Iterables.getOnlyElement(super.get());
+ if (orgNameToResource.get().size() == 0)
+ return locations.add(provider);
+ Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get();
+ for (ReferenceType org : orgNameToResource.get().values()) {
+ LocationBuilder builder = new LocationBuilder().scope(LocationScope.REGION).id(org.getHref().toASCIIString())
+ .description(org.getName()).parent(provider);
+ if (isoCodesById.containsKey(org.getHref().toASCIIString()))
+ builder.iso3166Codes(isoCodesById.get(org.getHref().toASCIIString()).get());
+ Location orgL = builder.build();
+ for (ReferenceType vdc : orgNameToVDCResource.get().get(org.getName()).getVDCs().values()) {
+ builder = new LocationBuilder().scope(LocationScope.ZONE).id(vdc.getHref().toASCIIString()).description(
+ vdc.getName()).parent(orgL);
+ if (isoCodesById.containsKey(vdc.getHref().toASCIIString()))
+ builder.iso3166Codes(isoCodesById.get(vdc.getHref().toASCIIString()).get());
+ locations.add(builder.build());
+ }
+ }
+ return locations;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java
new file mode 100644
index 0000000..89580fd
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class CaptureVAppOptions {
+
+ private String description;
+
+ public CaptureVAppOptions withDescription(String description) {
+ checkNotNull(description, "description");
+ this.description = description;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see CaptureVAppOptions#withDescription(String)
+ */
+ public static CaptureVAppOptions withDescription(String description) {
+ CaptureVAppOptions options = new CaptureVAppOptions();
+ return options.withDescription(description);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java
new file mode 100644
index 0000000..6512031
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+public class CatalogItemOptions {
+
+ private String description;
+ private Map<String, String> properties = Maps.newLinkedHashMap();
+
+ /**
+ * optional description for the CatalogItem
+ */
+ public CatalogItemOptions description(String description) {
+ this.description = checkNotNull(description, "description");
+ return this;
+ }
+
+ /**
+ * optional properties for the CatalogItem
+ */
+ public CatalogItemOptions properties(Map<String, String> properties) {
+ this.properties = ImmutableMap.copyOf(checkNotNull(properties, "properties"));
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see CatalogItemOptions#description
+ */
+ public static CatalogItemOptions description(String description) {
+ return new CatalogItemOptions().description(description);
+ }
+
+ /**
+ * @see CatalogItemOptions#properties
+ */
+ public static CatalogItemOptions properties(Map<String, String> properties) {
+ return new CatalogItemOptions().properties(properties);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java
new file mode 100644
index 0000000..e3f5eea
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class CloneOptions {
+
+ private String description;
+
+ /**
+ * the clone should be powered on after it is deployed
+ */
+ public CloneOptions description(String description) {
+ checkNotNull(description, "description");
+ this.description = description;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see CloneOptions#description(String)
+ */
+ public static CloneOptions description(String description) {
+ return new CloneOptions().description(description);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java
new file mode 100644
index 0000000..8aed313
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.options;
+
+import static com.google.common.base.Preconditions.checkState;
+
+public class CloneVAppOptions extends CloneOptions {
+
+ private boolean deploy;
+ private boolean powerOn;
+
+ /**
+ * the clone should be deployed after it is created
+ */
+ public CloneVAppOptions deploy() {
+ this.deploy = true;
+ return this;
+ }
+
+ /**
+ * the clone should be powered on after it is deployed
+ */
+ public CloneVAppOptions powerOn() {
+ checkState(deploy, "must set deploy before setting powerOn");
+ powerOn = true;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public CloneVAppOptions description(String description) {
+ return CloneVAppOptions.class.cast(super.description(description));
+ }
+
+ public boolean isDeploy() {
+ return deploy;
+ }
+
+ public boolean isPowerOn() {
+ return powerOn;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see CloneVAppOptions#deploy()
+ */
+ public static CloneVAppOptions deploy() {
+ return new CloneVAppOptions().deploy();
+ }
+
+ /**
+ * @see CloneVAppOptions#powerOn()
+ */
+ public static CloneVAppOptions powerOn() {
+ return new CloneVAppOptions().powerOn();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public static CloneVAppOptions description(String description) {
+ return new CloneVAppOptions().description(description);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java
new file mode 100644
index 0000000..e10d45d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.options;
+
+public class CloneVAppTemplateOptions extends CloneOptions {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public CloneVAppTemplateOptions description(String description) {
+ return CloneVAppTemplateOptions.class.cast(super.description(description));
+ }
+
+ public static class Builder {
+ /**
+ * {@inheritDoc}
+ */
+ public static CloneVAppTemplateOptions description(String description) {
+ return new CloneVAppTemplateOptions().description(description);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java
new file mode 100644
index 0000000..8d35d1d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import org.jclouds.vcloud.domain.network.NetworkConfig;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.Sets;
+
+public class InstantiateVAppTemplateOptions {
+ private Set<NetworkConfig> networkConfig = Sets.newLinkedHashSet();
+
+ private Boolean customizeOnInstantiate;
+ private String description = null;
+ private boolean deploy = true;
+ private boolean powerOn = true;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public boolean shouldDeploy() {
+ return deploy;
+ }
+
+ public boolean shouldPowerOn() {
+ return powerOn;
+ }
+
+ /**
+ * Optional description. Used for the Description of the vApp created by this
+ * instantiation.
+ */
+ public InstantiateVAppTemplateOptions description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * deploy the vapp after it is instantiated?
+ */
+ public InstantiateVAppTemplateOptions deploy(boolean deploy) {
+ this.deploy = deploy;
+ return this;
+ }
+
+ /**
+ * powerOn the vapp after it is instantiated?
+ */
+ public InstantiateVAppTemplateOptions powerOn(boolean powerOn) {
+ this.powerOn = powerOn;
+ return this;
+ }
+
+ /**
+ * {@networkConfig VAppTemplate}s have internal networks that can be
+ * connected in order to access the internet or other external networks.
+ *
+ * <h4>default behaviour if you don't use this option</h4> By default, we
+ * connect the first internal {@networkConfig
+ * org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection network in the
+ * vapp template}to a default chosen from the org or specified via
+ * {@networkConfig
+ * org.jclouds.vcloud.reference.VCloudConstants#
+ * PROPERTY_VCLOUD_DEFAULT_NETWORK} using the {@networkConfig
+ * org.jclouds.vcloud.domain.FenceMode#BRIDGED} or an
+ * override set by the property {@networkConfig
+ * org.jclouds.vcloud.reference.VCloudConstants#
+ * PROPERTY_VCLOUD_DEFAULT_FENCEMODE}.
+ */
+ public InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
+ this.networkConfig.add(checkNotNull(networkConfig, "networkConfig"));
+ return this;
+ }
+
+ public Set<NetworkConfig> getNetworkConfig() {
+ return networkConfig;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see InstantiateVAppTemplateOptions#description
+ */
+ public static InstantiateVAppTemplateOptions description(String description) {
+ InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
+ return options.description(description);
+ }
+
+ /**
+ * @see InstantiateVAppTemplateOptions#deploy
+ */
+ public static InstantiateVAppTemplateOptions deploy(boolean deploy) {
+ InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
+ return options.deploy(deploy);
+ }
+
+ /**
+ * @see InstantiateVAppTemplateOptions#powerOn
+ */
+ public static InstantiateVAppTemplateOptions powerOn(boolean powerOn) {
+ InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
+ return options.powerOn(powerOn);
+ }
+
+ /**
+ * @see InstantiateVAppTemplateOptions#addNetworkConfig
+ */
+ public static InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
+ InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
+ return options.addNetworkConfig(networkConfig);
+ }
+
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof InstantiateVAppTemplateOptions) {
+ final InstantiateVAppTemplateOptions other = InstantiateVAppTemplateOptions.class.cast(object);
+ return equal(networkConfig, other.networkConfig)
+ && equal(customizeOnInstantiate, other.customizeOnInstantiate) && equal(description, other.description)
+ && equal(deploy, other.deploy) && equal(powerOn, other.powerOn);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(networkConfig, customizeOnInstantiate, description, deploy, powerOn);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ protected ToStringHelper string() {
+ ToStringHelper toString = Objects.toStringHelper("").omitNullValues();
+ toString.add("customizeOnInstantiate", customizeOnInstantiate).add("description", description);
+ if (networkConfig.size() > 0)
+ toString.add("networkConfig", networkConfig);
+ if (!deploy)
+ toString.add("deploy", deploy);
+ if (!powerOn)
+ toString.add("powerOn", powerOn);
+ return toString;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java
new file mode 100644
index 0000000..2b249ce
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.predicates;
+
+import java.net.URI;
+
+import javax.annotation.Resource;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.TaskInErrorStateException;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.TaskStatus;
+
+import com.google.common.base.Predicate;
+import com.google.inject.Inject;
+
+/**
+ *
+ * Tests to see if a task succeeds.
+ */
+@Singleton
+public class TaskSuccess implements Predicate<URI> {
+
+ private final VCloudApi client;
+
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ @Inject
+ public TaskSuccess(VCloudApi client) {
+ this.client = client;
+ }
+
+ public boolean apply(URI taskId) {
+ logger.trace("looking for status on task %s", taskId);
+
+ Task task = client.getTaskApi().getTask(taskId);
+ // perhaps task isn't available, yet
+ if (task == null)
+ return false;
+ logger.trace("%s: looking for status %s: currently: %s", task, TaskStatus.SUCCESS, task.getStatus());
+ if (task.getStatus() == TaskStatus.ERROR)
+ throw new TaskInErrorStateException(task);
+ return task.getStatus() == TaskStatus.SUCCESS;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java
new file mode 100644
index 0000000..2429c6a
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.reference;
+
+/**
+ * Configuration properties and constants used in VCloud connections.
+ */
+public final class VCloudConstants {
+ public static final String PROPERTY_VCLOUD_VERSION_SCHEMA = "jclouds.vcloud.version.schema";
+ /**
+ * name of the default org that your vApp will join, if an org isn't
+ * explicitly specified.
+ */
+ public static final String PROPERTY_VCLOUD_DEFAULT_ORG = "jclouds.vcloud.defaults.org";
+ /**
+ * name of the default catalog to query, if it isn't explicitly specified.
+ */
+ public static final String PROPERTY_VCLOUD_DEFAULT_CATALOG = "jclouds.vcloud.defaults.catalog";
+ /**
+ * name of the VDC that your vApp will join, if a vDC isn't explicitly
+ * specified.
+ */
+ public static final String PROPERTY_VCLOUD_DEFAULT_VDC = "jclouds.vcloud.defaults.vdc";
+ /**
+ * name of the default network, in the default VDC that your vApp will join.
+ */
+ public static final String PROPERTY_VCLOUD_DEFAULT_NETWORK = "jclouds.vcloud.defaults.network";
+ public static final String PROPERTY_VCLOUD_DEFAULT_FENCEMODE = "jclouds.vcloud.defaults.fencemode";
+
+ public static final String PROPERTY_VCLOUD_XML_NAMESPACE = "jclouds.vcloud.xml.ns";
+ public static final String PROPERTY_VCLOUD_XML_SCHEMA = "jclouds.vcloud.xml.schema";
+
+ public static final String PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED = "jclouds.vcloud.timeout.task-complete";
+
+ private VCloudConstants() {
+ throw new AssertionError("intentionally unimplemented");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java
new file mode 100644
index 0000000..158debe
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * This package contains properties and reference data used in vCloud.
+ */
+package org.jclouds.vcloud.reference;
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java
new file mode 100644
index 0000000..938b6fd
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.suppliers;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.NoSuchElementException;
+
+import org.jclouds.config.ValueOfConfigurationKeyOrNull;
+import org.jclouds.vcloud.domain.ReferenceType;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+public class OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault implements
+ Function<Iterable<ReferenceType>, ReferenceType> {
+
+ protected final ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull;
+ protected final String configurationKey;
+ protected final Predicate<ReferenceType> defaultSelector;
+
+ public OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(
+ ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull, String configurationKey,
+ Predicate<ReferenceType> defaultSelector) {
+ this.configurationKey = checkNotNull(configurationKey, "configurationKey");
+ this.valueOfConfigurationKeyOrNull = checkNotNull(valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull");
+ this.defaultSelector = checkNotNull(defaultSelector, "defaultSelector");
+ }
+
+ @Override
+ public ReferenceType apply(Iterable<ReferenceType> referenceTypes) {
+ checkNotNull(referenceTypes, "referenceTypes");
+ checkArgument(Iterables.size(referenceTypes) > 0,
+ "No referenceTypes corresponding to configuration key %s present", configurationKey);
+ if (Iterables.size(referenceTypes) == 1)
+ return Iterables.getLast(referenceTypes);
+ String namingPattern = valueOfConfigurationKeyOrNull.apply(configurationKey);
+ if (namingPattern != null) {
+ return findReferenceTypeWithNameMatchingPattern(referenceTypes, namingPattern);
+ } else {
+ return defaultReferenceType(referenceTypes);
+ }
+ }
+
+ public ReferenceType defaultReferenceType(Iterable<ReferenceType> referenceTypes) {
+ return Iterables.find(referenceTypes, defaultSelector);
+ }
+
+ public ReferenceType findReferenceTypeWithNameMatchingPattern(Iterable<ReferenceType> referenceTypes,
+ String namingPattern) {
+ try {
+ return Iterables.find(referenceTypes, new ReferenceTypeNameMatchesPattern(namingPattern));
+ } catch (NoSuchElementException e) {
+ throw new NoSuchElementException(String.format(
+ "referenceType matching pattern [%s], corresponding to configuration key %s, not in %s", namingPattern,
+ configurationKey, referenceTypes));
+ }
+ }
+
+ static class ReferenceTypeNameMatchesPattern implements Predicate<ReferenceType> {
+
+ private final String namingPattern;
+
+ public ReferenceTypeNameMatchesPattern(String namingPattern) {
+ this.namingPattern = checkNotNull(namingPattern, "namingPattern");
+ }
+
+ @Override
+ public boolean apply(ReferenceType arg0) {
+ return arg0.getName().matches(namingPattern);
+ }
+
+ @Override
+ public String toString() {
+ return "nameMatchesPattern(" + namingPattern + ")";
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java
new file mode 100644
index 0000000..08e1017
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.suppliers;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.concat;
+import static com.google.common.collect.Sets.newLinkedHashSet;
+import static org.jclouds.concurrent.FutureIterables.transformParallel;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.Constants;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+
+@Singleton
+public class VAppTemplatesSupplier implements Supplier<Set<VAppTemplate>> {
+
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ public Logger logger = Logger.NULL;
+
+ private final Supplier<Map<String, Org>> orgMap;
+ private final Function<Org, Iterable<VAppTemplate>> imagesInOrg;
+ private final ListeningExecutorService userExecutor;
+
+ @Inject
+ VAppTemplatesSupplier(Supplier<Map<String, Org>> orgMap,
+ Function<Org, Iterable<VAppTemplate>> imagesInOrg,
+ @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
+ this.orgMap = checkNotNull(orgMap, "orgMap");
+ this.imagesInOrg = checkNotNull(imagesInOrg, "imagesInOrg");
+ this.userExecutor = checkNotNull(userExecutor, "userExecutor");
+ }
+
+ @Override
+ public Set<VAppTemplate> get() {
+ Iterable<Org> orgs = checkNotNull(orgMap.get().values(), "orgs");
+ Iterable<? extends Iterable<VAppTemplate>> images = transformParallel(orgs,
+ new Function<Org, ListenableFuture<? extends Iterable<VAppTemplate>>>() {
+ public ListenableFuture<Iterable<VAppTemplate>> apply(final Org from) {
+ checkNotNull(from, "org");
+ return userExecutor.submit(new Callable<Iterable<VAppTemplate>>() {
+ public Iterable<VAppTemplate> call() throws Exception {
+ return imagesInOrg.apply(from);
+ }
+ public String toString() {
+ return "imagesInOrg(" + from.getHref() + ")";
+ }
+ });
+ }
+ }, userExecutor, null, logger, "images in " + orgs);
+ return newLinkedHashSet(concat(images));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java
new file mode 100644
index 0000000..623ee08
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.util;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VCloudError;
+import org.jclouds.vcloud.domain.VCloudError.MinorCode;
+import org.jclouds.vcloud.domain.internal.ErrorImpl;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+
+public class Utils {
+
+ public static ReferenceType newReferenceType(Map<String, String> attributes, String defaultType) {
+ String uri = attributes.get("href");
+ String type = attributes.get("type");
+ String relationship = attributes.get("rel");
+ // savvis org has null href
+ URI href = (uri != null) ? URI.create(uri) : null;
+ return new ReferenceTypeImpl(attributes.get("name"), type != null ? type : defaultType, href, relationship);
+ }
+
+ public static ReferenceType newReferenceType(Map<String, String> attributes) {
+ return newReferenceType(attributes, null);
+ }
+
+ public static VCloudError newError(Map<String, String> attributes) {
+
+ String vendorSpecificErrorCode = attributes.get("vendorSpecificErrorCode");
+ int errorCode;
+ // remove this logic when vcloud 0.8 is gone
+ try {
+ errorCode = Integer.parseInt(attributes.get("majorErrorCode"));
+ } catch (NumberFormatException e) {
+ errorCode = 500;
+ vendorSpecificErrorCode = attributes.get("majorErrorCode");
+ }
+ MinorCode minorErrorCode = attributes.containsKey("minorErrorCode") ? MinorCode.fromValue(attributes
+ .get("minorErrorCode")) : null;
+ if (minorErrorCode == null || minorErrorCode == MinorCode.UNRECOGNIZED) {
+ vendorSpecificErrorCode = attributes.get("minorErrorCode");
+ }
+
+ return new ErrorImpl(attributes.get("message"), errorCode, minorErrorCode, vendorSpecificErrorCode, attributes
+ .get("stackTrace"));
+ }
+
+ public static void putReferenceType(Map<String, ReferenceType> map, Map<String, String> attributes) {
+ map.put(attributes.get("name"), newReferenceType(attributes));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java
new file mode 100644
index 0000000..67e2445
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.util;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.VCloudError;
+import org.jclouds.vcloud.xml.ErrorHandler;
+
+/**
+ * Needed to sign and verify requests and responses.
+ */
+@Singleton
+public class VCloudUtils {
+ private final ParseSax.Factory factory;
+ private final Provider<ErrorHandler> errorHandlerProvider;
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ @Inject
+ VCloudUtils(Factory factory, Provider<ErrorHandler> errorHandlerProvider) {
+ this.factory = factory;
+ this.errorHandlerProvider = errorHandlerProvider;
+ }
+
+ public VCloudError parseErrorFromContent(HttpRequest request, HttpResponse response) {
+ // HEAD has no content
+ if (response.getPayload() == null)
+ return null;
+ // NOTE in vCloud Datacenter 1.5, if you make vCloud 1.0 requests, the content type
+ // header is suffixed with ;1.0
+ String contentType = response.getPayload().getContentMetadata().getContentType();
+ if (contentType != null && contentType.startsWith(VCloudMediaType.ERROR_XML)) {
+ try {
+ return factory.create(errorHandlerProvider.get()).setContext(request).apply(response);
+ } catch (RuntimeException e) {
+ logger.warn(e, "error parsing error");
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java
new file mode 100644
index 0000000..60bd01f
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+import static org.jclouds.vcloud.util.Utils.putReferenceType;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.internal.CatalogImpl;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class CatalogHandler extends ParseSax.HandlerWithResult<Catalog> {
+
+ protected final TaskHandler taskHandler;
+
+ @Inject
+ public CatalogHandler(TaskHandler taskHandler) {
+ this.taskHandler = taskHandler;
+ }
+
+ private StringBuilder currentText = new StringBuilder();
+
+ private ReferenceType catalog;
+ private Map<String, ReferenceType> contents = Maps.newLinkedHashMap();
+ protected List<Task> tasks = Lists.newArrayList();
+ private String description;
+ private ReferenceType org;
+
+ private boolean published = true;
+ private boolean readOnly = true;
+
+ public Catalog getResult() {
+ return new CatalogImpl(catalog.getName(), catalog.getType(), catalog.getHref(), org, description, contents,
+ tasks, published, readOnly);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (SaxUtils.equalsOrSuffix(qName, "Catalog")) {
+ catalog = newReferenceType(attributes, VCloudMediaType.CATALOG_XML);
+ } else if (SaxUtils.equalsOrSuffix(qName, "CatalogItem")) {
+ putReferenceType(contents, attributes);
+ } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) {
+ org = newReferenceType(attributes);
+ } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "add".equals(attributes.get("rel"))) {
+ readOnly = false;
+ } else {
+ taskHandler.startElement(uri, localName, qName, attrs);
+ }
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ taskHandler.endElement(uri, name, qName);
+ if (SaxUtils.equalsOrSuffix(qName, "Task")) {
+ this.tasks.add(taskHandler.getResult());
+ } else if (SaxUtils.equalsOrSuffix(qName, "Description")) {
+ description = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "IsPublished")) {
+ published = Boolean.parseBoolean(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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java
new file mode 100644
index 0000000..926e8a8
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+
+import java.util.Map;
+import java.util.SortedMap;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Maps;
+
+public class CatalogItemHandler extends ParseSax.HandlerWithResult<CatalogItem> {
+ private StringBuilder currentText = new StringBuilder();
+
+ protected ReferenceType catalogItem;
+ protected ReferenceType entity;
+
+ protected String description;
+ protected String key;
+ protected SortedMap<String, String> properties = Maps.newTreeMap();
+
+ public CatalogItem getResult() {
+ return new CatalogItemImpl(catalogItem.getName(), catalogItem.getHref(), description, entity, properties);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (SaxUtils.equalsOrSuffix(qName, "CatalogItem")) {
+ catalogItem = newReferenceType(attributes);
+ } else if (SaxUtils.equalsOrSuffix(qName, "Entity")) {
+ entity = newReferenceType(attributes);
+ } else if (SaxUtils.equalsOrSuffix(qName, "Property")) {
+ key = attributes.get("key");
+ }
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ if (SaxUtils.equalsOrSuffix(qName, "Description")) {
+ description = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "Property")) {
+ properties.put(key, currentOrNull());
+ key = null;
+ }
+ 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java
new file mode 100644
index 0000000..3c4704a
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import java.util.Map;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.VCloudError;
+import org.jclouds.vcloud.util.Utils;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+public class ErrorHandler extends ParseSax.HandlerWithResult<VCloudError> {
+ private VCloudError error;
+
+ public VCloudError getResult() {
+ return error;
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (SaxUtils.equalsOrSuffix(qName, "Error")) {
+ error = Utils.newError(attributes);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java
new file mode 100644
index 0000000..3fb2227
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+
+import java.util.Map;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.GuestCustomizationSection;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.xml.sax.Attributes;
+
+public class GuestCustomizationSectionHandler extends ParseSax.HandlerWithResult<GuestCustomizationSection> {
+ protected StringBuilder currentText = new StringBuilder();
+ private ReferenceType guest;
+ private ReferenceType edit;
+
+ protected String info;
+ protected String name;
+ protected Boolean enabled;
+ protected Boolean changeSid;
+ protected String virtualMachineId;
+ protected Boolean joinDomainEnabled;
+ protected Boolean useOrgSettings;
+ protected String domainName;
+ protected String domainUserName;
+ protected String domainUserPassword;
+ protected Boolean adminPasswordEnabled;
+ protected Boolean adminPasswordAuto;
+ protected String adminPassword;
+ protected Boolean resetPasswordRequired;
+ protected String customizationScript;
+ protected String computerName;
+
+ public GuestCustomizationSection getResult() {
+ GuestCustomizationSection system = new GuestCustomizationSection(guest.getType(), guest.getHref(), info, enabled,
+ changeSid, virtualMachineId, joinDomainEnabled, useOrgSettings, domainName, domainUserName,
+ domainUserPassword, adminPasswordEnabled, adminPasswordAuto, adminPassword, resetPasswordRequired,
+ customizationScript, computerName, edit);
+ this.guest = null;
+ this.info = null;
+ this.edit = null;
+ this.enabled = null;
+ this.changeSid = null;
+ this.virtualMachineId = null;
+ this.joinDomainEnabled = null;
+ this.useOrgSettings = null;
+ this.domainName = null;
+ this.domainUserName = null;
+ this.domainUserPassword = null;
+ this.adminPasswordEnabled = null;
+ this.adminPasswordAuto = null;
+ this.adminPassword = null;
+ this.resetPasswordRequired = null;
+ this.customizationScript = null;
+ this.computerName = null;
+ return system;
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attrs) {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ this.currentText = new StringBuilder();
+ if (qName.endsWith("GuestCustomizationSection")) {
+ guest = newReferenceType(attributes);
+ } else if (qName.endsWith("Link") && "edit".equals(attributes.get("rel"))) {
+ edit = newReferenceType(attributes);
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) {
+ if (qName.endsWith("Info")) {
+ this.info = currentOrNull();
+ } else if (qName.endsWith("AdminPasswordEnabled")) {
+ this.adminPasswordEnabled = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("JoinDomainEnabled")) {
+ this.joinDomainEnabled = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("Enabled")) {
+ this.enabled = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("ChangeSid")) {
+ this.changeSid = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("VirtualMachineId")) {
+ this.virtualMachineId = currentOrNull();
+ } else if (qName.endsWith("UseOrgSettings")) {
+ this.useOrgSettings = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("DomainName")) {
+ this.domainName = currentOrNull();
+ } else if (qName.endsWith("DomainUserName")) {
+ this.domainUserName = currentOrNull();
+ } else if (qName.endsWith("DomainUserPassword")) {
+ this.domainUserPassword = currentOrNull();
+ } else if (qName.endsWith("AdminPasswordAuto")) {
+ this.adminPasswordAuto = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("AdminPassword")) {
+ this.adminPassword = currentOrNull();
+ } else if (qName.endsWith("ResetPasswordRequired")) {
+ this.resetPasswordRequired = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("CustomizationScript")) {
+ this.customizationScript = currentOrNull();
+ if (this.customizationScript != null)
+ customizationScript = customizationScript.replace(">", ">");
+ } else if (qName.endsWith("ComputerName")) {
+ this.computerName = currentOrNull();
+ } else if (qName.endsWith("Name")) {
+ this.name = 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();
+ return returnVal.equals("") ? null : returnVal;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java
new file mode 100644
index 0000000..aefb753
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import java.util.Map;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.NetworkConnection;
+import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
+import org.xml.sax.Attributes;
+
+public class NetworkConnectionHandler extends ParseSax.HandlerWithResult<NetworkConnection> {
+ protected StringBuilder currentText = new StringBuilder();
+
+ protected String network;
+ protected int networkConnectionIndex;
+ protected String ipAddress;
+ protected String externalIpAddress;
+ protected boolean connected;
+ protected String MACAddress;
+ protected IpAddressAllocationMode ipAddressAllocationMode;
+
+ public NetworkConnection getResult() {
+ NetworkConnection connection = new NetworkConnection(network, networkConnectionIndex, ipAddress,
+ externalIpAddress, connected, MACAddress, ipAddressAllocationMode);
+ this.network = null;
+ this.networkConnectionIndex = -1;
+ this.ipAddress = null;
+ this.externalIpAddress = null;
+ this.connected = false;
+ this.MACAddress = null;
+ this.ipAddressAllocationMode = null;
+ return connection;
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attrs) {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (qName.endsWith("NetworkConnection")) {
+ network = attributes.get("network");
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) {
+ if (qName.endsWith("NetworkConnectionIndex")) {
+ this.networkConnectionIndex = Integer.parseInt(currentOrNull());
+ } else if (qName.endsWith("IpAddress")) {
+ this.ipAddress = currentOrNull();
+ } else if (qName.endsWith("ExternalIpAddress")) {
+ this.externalIpAddress = currentOrNull();
+ } else if (qName.endsWith("IsConnected")) {
+ this.connected = Boolean.parseBoolean(currentOrNull());
+ } else if (qName.endsWith("MACAddress")) {
+ this.MACAddress = currentOrNull();
+ } else if (qName.endsWith("IpAddressAllocationMode")) {
+ this.ipAddressAllocationMode = IpAddressAllocationMode.valueOf(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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java
new file mode 100644
index 0000000..e8d4c74
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.NetworkConnection;
+import org.jclouds.vcloud.domain.NetworkConnectionSection;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.Sets;
+
+public class NetworkConnectionSectionHandler extends ParseSax.HandlerWithResult<NetworkConnectionSection> {
+ protected StringBuilder currentText = new StringBuilder();
+
+ private final NetworkConnectionHandler networkConnectionHandler;
+
+ @Inject
+ public NetworkConnectionSectionHandler(NetworkConnectionHandler networkConnectionHandler) {
+ this.networkConnectionHandler = networkConnectionHandler;
+ }
+
+ protected String info;
+ protected Set<NetworkConnection> connections = Sets.newLinkedHashSet();
+ protected ReferenceType section;
+ protected ReferenceType edit;
+ protected Integer primaryNetworkConnectionIndex;
+ protected boolean inConnections;
+
+ public NetworkConnectionSection getResult() {
+ return new NetworkConnectionSection(section.getType(), section.getHref(), info, primaryNetworkConnectionIndex,
+ connections, edit);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (qName.endsWith("NetworkConnection")) {
+ inConnections = true;
+ }
+ if (inConnections) {
+ networkConnectionHandler.startElement(uri, localName, qName, attrs);
+ } else if (qName.endsWith("NetworkConnectionSection")) {
+ section = newReferenceType(attributes);
+ } else if (qName.endsWith("Link") && "edit".equals(attributes.get("rel"))) {
+ edit = newReferenceType(attributes);
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) {
+ if (qName.endsWith("NetworkConnection")) {
+ inConnections = false;
+ connections.add(networkConnectionHandler.getResult());
+ }
+ if (inConnections) {
+ networkConnectionHandler.endElement(uri, localName, qName);
+ } else if (qName.endsWith("Info")) {
+ this.info = currentOrNull();
+ } else if (qName.endsWith("PrimaryNetworkConnectionIndex")) {
+ this.primaryNetworkConnectionIndex = Integer.valueOf(currentOrNull());
+ }
+ currentText = new StringBuilder();
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) {
+ if (inConnections)
+ networkConnectionHandler.characters(ch, start, length);
+ else
+ currentText.append(ch, start, length);
+ }
+
+ protected String currentOrNull() {
+ String returnVal = currentText.toString().trim();
+ return returnVal.equals("") ? null : returnVal;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java
new file mode 100644
index 0000000..1892e30
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+import static org.jclouds.vcloud.util.Utils.putReferenceType;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.internal.OrgImpl;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class OrgHandler extends ParseSax.HandlerWithResult<Org> {
+
+ protected final TaskHandler taskHandler;
+
+ @Inject
+ public OrgHandler(TaskHandler taskHandler) {
+ this.taskHandler = taskHandler;
+ }
+
+ private StringBuilder currentText = new StringBuilder();
+
+ protected ReferenceType org;
+ protected Map<String, ReferenceType> vdcs = Maps.newLinkedHashMap();
+ protected ReferenceType tasksList;
+ protected Map<String, ReferenceType> catalogs = Maps.newLinkedHashMap();
+ protected Map<String, ReferenceType> networks = Maps.newLinkedHashMap();
+ protected List<Task> tasks = Lists.newArrayList();
+
+ protected String description;
+ protected String fullName;
+
+ public Org getResult() {
+ return new OrgImpl(org.getName(), org.getType(), org.getHref(), fullName != null ? fullName : org.getName(),
+ description, catalogs, vdcs, networks, tasksList, tasks);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (qName.endsWith("Org")) {
+ org = newReferenceType(attributes);
+ } else if (qName.endsWith("Link")) {
+ String type = attributes.get("type");
+ if (type != null) {
+ if (type.indexOf("vdc+xml") != -1) {
+ putReferenceType(vdcs, attributes);
+ } else if (type.indexOf("catalog+xml") != -1) {
+ putReferenceType(catalogs, attributes);
+ } else if (type.indexOf("tasksList+xml") != -1) {
+ tasksList = newReferenceType(attributes);
+ } else if (type.indexOf("network+xml") != -1) {
+ putReferenceType(networks, attributes);
+ }
+ }
+ } else {
+ taskHandler.startElement(uri, localName, qName, attrs);
+ }
+
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ taskHandler.endElement(uri, name, qName);
+ if (qName.endsWith("Task")) {
+ this.tasks.add(taskHandler.getResult());
+ } else if (qName.endsWith("Description")) {
+ description = currentOrNull();
+ } else if (qName.endsWith("FullName")) {
+ fullName = 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java
new file mode 100644
index 0000000..5176165
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.putReferenceType;
+
+import java.util.Map;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Maps;
+
+public class OrgListHandler extends ParseSax.HandlerWithResult<Map<String, ReferenceType>> {
+
+ private Map<String, ReferenceType> org = Maps.newHashMap();
+
+ public Map<String, ReferenceType> getResult() {
+ return org;
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (qName.endsWith("Link") || qName.endsWith("Org")) {
+ String type = attributes.get("type");
+ if (type != null) {
+ if (type.indexOf("org+xml") != -1) {
+ putReferenceType(org, attributes);
+ }
+ }
+ }
+ }
+}
[41/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthProperties.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthProperties.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthProperties.java
new file mode 100644
index 0000000..9394cad
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthProperties.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.config;
+
+/**
+ * Configurable properties for jclouds OAuth
+ */
+public class OAuthProperties {
+
+ /**
+ * The selected signature algorithm to use to sign the requests.
+ * <p/>
+ * This refers to the name the oauth provider expects, i.e., "RSA
+ */
+ public static final String SIGNATURE_OR_MAC_ALGORITHM = "jclouds.oauth.signature-or-mac-algorithm";
+
+ /**
+ * The oauth audience, who this token is intended for. For instance in JWT and for
+ * google API's this property maps to: {"aud","https://accounts.google.com/o/oauth2/token"}
+ *
+ * @see <a href="http://tools.ietf.org/html/draft-jones-json-web-token-04">doc</a>
+ */
+ public static final String AUDIENCE = "jclouds.oauth.audience";
+
+ /**
+ * Optional list of comma-separated scopes to use when no OAuthScopes annotation is present.
+ */
+ public static final String SCOPES = "jclouds.oauth.scopes";
+
+ /**
+ * Specify if credentials are id + private key or if you are reusing an oauth2 token.
+ *
+ * @see org.jclouds.oauth.v2.config.CredentialType
+ */
+ public static final String CREDENTIAL_TYPE = "jclouds.oauth.credential-type";
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthScopes.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthScopes.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthScopes.java
new file mode 100644
index 0000000..57ffd29
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthScopes.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.config;
+
+import javax.inject.Qualifier;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Used to annotate REST methods/ifaces that use OAuthAuthentication.
+ * <p/>
+ * Sets the scopes for the token request for that particular method.
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = {ElementType.TYPE, ElementType.METHOD})
+@Qualifier
+public @interface OAuthScopes {
+
+ /**
+ * @return the OAuth scopes required to access the resource.
+ */
+ String[] value();
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/ClaimSet.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/ClaimSet.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/ClaimSet.java
new file mode 100644
index 0000000..5c0b348
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/ClaimSet.java
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.domain;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Splitter;
+import com.google.common.collect.ForwardingMap;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+import java.util.Map;
+import java.util.Set;
+
+import static com.google.common.base.Objects.ToStringHelper;
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+/**
+ * The claimset for the token.
+ *
+ * @see <a
+ * href="https://developers.google.com/accounts/docs/OAuth2ServiceAccount"
+ * >doc</a>
+ */
+public class ClaimSet extends ForwardingMap<String, String> {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromClaimSet(this);
+ }
+
+ public static class Builder {
+
+ private Set<String> requiredClaims;
+ private ImmutableMap.Builder<String, String> claims = new ImmutableMap.Builder<String, String>();
+ private long emissionTime;
+ private long expirationTime;
+
+ public Builder() {
+ this(ImmutableSet.<String>of());
+ }
+
+ /**
+ * Constructor that allows to predefine a mandatory set of claims as a comma-separated string, e.g, "iss,iat".
+ */
+ public Builder(String commaSeparatedRequiredClaims) {
+ this(ImmutableSet.copyOf(Splitter.on(",").split(checkNotNull(commaSeparatedRequiredClaims))));
+ }
+
+ /**
+ * Constructor that allows to predefine a mandatory set of claims as a set of strings.
+ */
+ public Builder(Set<String> requiredClaims) {
+ this.requiredClaims = ImmutableSet.copyOf(checkNotNull(requiredClaims));
+ }
+
+ /**
+ * Adds a Claim, i.e. key/value pair, e.g., "scope":"all_permissions".
+ */
+ public Builder addClaim(String name, String value) {
+ claims.put(checkNotNull(name), checkNotNull(value, "value of %s", name));
+ return this;
+ }
+
+ /**
+ * @see ClaimSet#getEmissionTime()
+ */
+ public Builder emissionTime(long emmissionTime) {
+ this.emissionTime = emmissionTime;
+ return this;
+ }
+
+ /**
+ * @see ClaimSet#getExpirationTime()
+ */
+ public Builder expirationTime(long expirationTime) {
+ this.expirationTime = expirationTime;
+ return this;
+ }
+
+ /**
+ * Adds a map containing multiple claims
+ */
+ public Builder addAllClaims(Map<String, String> claims) {
+ this.claims.putAll(checkNotNull(claims));
+ return this;
+ }
+
+ public ClaimSet build() {
+ Map<String, String> claimsMap = claims.build();
+ checkState(Sets.intersection(claimsMap.keySet(), requiredClaims).size() == requiredClaims.size(),
+ "not all required claims were present");
+ if (expirationTime == 0) {
+ expirationTime = emissionTime + 3600;
+ }
+ return new ClaimSet(claimsMap, emissionTime, expirationTime);
+ }
+
+ public Builder fromClaimSet(ClaimSet claimSet) {
+ return new Builder().addAllClaims(claimSet.claims).expirationTime(expirationTime).emissionTime(emissionTime);
+ }
+ }
+
+ private final Map<String, String> claims;
+ private final long emissionTime;
+ private final long expirationTime;
+
+ private ClaimSet(Map<String, String> claims, long emissionTime, long expirationTime) {
+ this.claims = claims;
+ this.emissionTime = emissionTime;
+ this.expirationTime = expirationTime;
+ }
+
+ /**
+ * The emission time, in seconds since the epoch.
+ */
+ public long getEmissionTime() {
+ return emissionTime;
+ }
+
+ /**
+ * The expiration time, in seconds since the emission time.
+ */
+ public long getExpirationTime() {
+ return expirationTime;
+ }
+
+ /**
+ * @returns the claims.
+ */
+ @Override
+ protected Map<String, String> delegate() {
+ return claims;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(claims);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ClaimSet other = (ClaimSet) obj;
+ return equal(claims, other.claims);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ protected ToStringHelper string() {
+ return toStringHelper(this).omitNullValues().add("claims", claims)
+ .add("emissionTime", emissionTime).add("expirationTIme", expirationTime);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/Header.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/Header.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/Header.java
new file mode 100644
index 0000000..c230e1d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/Header.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.domain;
+
+import com.google.common.base.Objects;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * The header for the OAuth token, contains the signer algorithm's name and the type of the token
+ *
+ * @see <a href="https://developers.google.com/accounts/docs/OAuth2ServiceAccount">doc</a>
+ */
+public class Header {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromHeader(this);
+ }
+
+ public static class Builder {
+
+ private String signerAlgorithm;
+ private String type;
+
+ /**
+ * @see Header#getSignerAlgorithm()
+ */
+ public Builder signerAlgorithm(String signerAlgorithm) {
+ this.signerAlgorithm = checkNotNull(signerAlgorithm);
+ return this;
+ }
+
+ /**
+ * @see Header#getType()
+ */
+ public Builder type(String type) {
+ this.type = checkNotNull(type);
+ return this;
+ }
+
+ public Header build() {
+ return new Header(signerAlgorithm, type);
+ }
+
+ public Builder fromHeader(Header header) {
+ return new Builder().signerAlgorithm(header.signerAlgorithm).type(header.type);
+ }
+ }
+
+ private final String signerAlgorithm;
+ private final String type;
+
+ protected Header(String signerAlgorithm, String type) {
+ this.signerAlgorithm = checkNotNull(signerAlgorithm);
+ this.type = checkNotNull(type);
+ }
+
+ /**
+ * The name of the algorithm used to compute the signature, e.g., "RS256"
+ */
+ public String getSignerAlgorithm() {
+ return signerAlgorithm;
+ }
+
+ /**
+ * The type of the token, e.g., "JWT"
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Header other = (Header) obj;
+ return equal(this.signerAlgorithm, other.signerAlgorithm) && equal(this.type,
+ other.type);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(signerAlgorithm, type);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this).omitNullValues().add("signerAlgorithm", signerAlgorithm)
+ .add("type", type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/OAuthCredentials.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/OAuthCredentials.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/OAuthCredentials.java
new file mode 100644
index 0000000..78cb402
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/OAuthCredentials.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.domain;
+
+import com.google.common.base.Objects;
+import org.jclouds.domain.Credentials;
+
+import java.security.PrivateKey;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Special kind credentials for oauth authentication that includes {@link java.security.PrivateKey} to sign
+ * requests.
+ */
+public class OAuthCredentials extends Credentials {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromOauthCredentials(this);
+ }
+
+ public static class Builder extends Credentials.Builder<OAuthCredentials> {
+
+ protected PrivateKey privateKey;
+
+ /**
+ * @see OAuthCredentials#privateKey
+ */
+ public Builder privateKey(PrivateKey privateKey) {
+ this.privateKey = checkNotNull(privateKey);
+ return this;
+ }
+
+ /**
+ * @see Credentials#identity
+ */
+ public Builder identity(String identity) {
+ this.identity = checkNotNull(identity);
+ return this;
+ }
+
+ /**
+ * @see Credentials#credential
+ */
+ public Builder credential(String credential) {
+ this.credential = credential;
+ return this;
+ }
+
+ public OAuthCredentials build() {
+ return new OAuthCredentials(checkNotNull(identity), credential, privateKey);
+ }
+
+ public Builder fromOauthCredentials(OAuthCredentials credentials) {
+ return new Builder().privateKey(credentials.privateKey).identity(credentials.identity)
+ .credential(credentials.credential);
+ }
+ }
+
+ /**
+ * The private key associated with Credentials#identity.
+ * Used to sign token requests.
+ */
+ public final PrivateKey privateKey;
+
+ public OAuthCredentials(String identity, String credential, PrivateKey privateKey) {
+ super(identity, credential);
+ this.privateKey = privateKey;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ OAuthCredentials other = (OAuthCredentials) obj;
+ return equal(this.identity, other.identity) && equal(this.credential,
+ other.credential) && equal(this.privateKey,
+ other.privateKey);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(identity, credential, privateKey);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this).omitNullValues().add("identity", identity)
+ .add("credential", credential != null ? credential.hashCode() : null).add("privateKey",
+ privateKey.hashCode());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/Token.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/Token.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/Token.java
new file mode 100644
index 0000000..a18a7eb
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/Token.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.domain;
+
+import com.google.common.base.Objects;
+
+import java.beans.ConstructorProperties;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * The oauth token, obtained upon a successful token request and ready to embed in requests.
+ */
+public class Token {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromToken(this);
+ }
+
+ public static class Builder {
+
+ private String accessToken;
+ private String tokenType;
+ private long expiresIn;
+
+ /**
+ * @see Token#getAccessToken()
+ */
+ public Builder accessToken(String accessToken) {
+ this.accessToken = checkNotNull(accessToken);
+ return this;
+ }
+
+ /**
+ * @see Token#getTokenType()
+ */
+ public Builder tokenType(String tokenType) {
+ this.tokenType = checkNotNull(tokenType);
+ return this;
+ }
+
+ /**
+ * @see Token#getExpiresIn()
+ */
+ public Builder expiresIn(long expiresIn) {
+ this.expiresIn = expiresIn;
+ return this;
+ }
+
+ public Token build() {
+ return new Token(accessToken, tokenType, expiresIn);
+ }
+
+ public Builder fromToken(Token token) {
+ return new Builder().accessToken(token.accessToken).tokenType(token.tokenType).expiresIn(token.expiresIn);
+ }
+ }
+
+ private final String accessToken;
+ private final String tokenType;
+ private final long expiresIn;
+
+ @ConstructorProperties({"access_token", "token_type", "expires_in"})
+ protected Token(String accessToken, String tokenType, long expiresIn) {
+ this.accessToken = accessToken;
+ this.tokenType = tokenType;
+ this.expiresIn = expiresIn;
+ }
+
+ /**
+ * The access token obtained from the OAuth server.
+ */
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ /**
+ * The type of the token, e.g., "Bearer"
+ */
+ public String getTokenType() {
+ return tokenType;
+ }
+
+ /**
+ * In how many seconds this token expires.
+ */
+ public long getExpiresIn() {
+ return expiresIn;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Token other = (Token) obj;
+ return equal(this.accessToken, other.accessToken) && equal(this.tokenType,
+ other.tokenType) && equal(this.expiresIn,
+ other.expiresIn);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(accessToken, tokenType, expiresIn);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this).omitNullValues().add("accessToken", accessToken)
+ .add("tokenType", tokenType).add("expiresIn", expiresIn);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/TokenRequest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/TokenRequest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/TokenRequest.java
new file mode 100644
index 0000000..7d1a6a4
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/TokenRequest.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.domain;
+
+import com.google.common.base.Objects;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * A complete token request.
+ */
+public class TokenRequest {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromTokenRequest(this);
+ }
+
+ public static class Builder {
+ private Header header;
+ private ClaimSet claimSet;
+
+ /**
+ * @see TokenRequest#getClaimSet()
+ */
+ public Builder header(Header header) {
+ this.header = header;
+ return this;
+ }
+
+ /**
+ * @see TokenRequest#getHeader()
+ */
+ public Builder claimSet(ClaimSet claimSet) {
+ this.claimSet = claimSet;
+ return this;
+ }
+
+ public TokenRequest build() {
+ return new TokenRequest(header, claimSet);
+ }
+
+ public Builder fromTokenRequest(TokenRequest tokeRequest) {
+ return new Builder().header(tokeRequest.header).claimSet(tokeRequest.claimSet);
+ }
+ }
+
+ private final Header header;
+ private final ClaimSet claimSet;
+
+ public TokenRequest(Header header, ClaimSet claimSet) {
+ this.header = checkNotNull(header);
+ this.claimSet = checkNotNull(claimSet);
+ }
+
+ /**
+ * The header of this token request.
+ *
+ * @see Header
+ */
+ public Header getHeader() {
+ return header;
+ }
+
+ /**
+ * The claim set of this token request.
+ *
+ * @see ClaimSet
+ */
+ public ClaimSet getClaimSet() {
+ return claimSet;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TokenRequest other = (TokenRequest) obj;
+ return equal(this.header, other.header) && equal(this.claimSet,
+ other.claimSet);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(header, claimSet);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this).omitNullValues().add("header", header)
+ .add("claimSet", claimSet);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/TokenRequestFormat.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/TokenRequestFormat.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/TokenRequestFormat.java
new file mode 100644
index 0000000..f4b80c1
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/domain/TokenRequestFormat.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.domain;
+
+import com.google.inject.ImplementedBy;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.oauth.v2.json.JWTTokenRequestFormat;
+
+import java.util.Set;
+
+/**
+ * Transforms a TokenRequest into a specific format (e.g. JWT token)
+ */
+@ImplementedBy(JWTTokenRequestFormat.class)
+public interface TokenRequestFormat {
+
+ /**
+ * Transforms the provided HttpRequest into a particular token request with a specific format.
+ */
+ <R extends HttpRequest> R formatRequest(R httpRequest, TokenRequest tokenRequest);
+
+ /**
+ * The name of the type of the token request, e.g., "JWT"
+ */
+ String getTypeName();
+
+ /**
+ * The claims that must be present in the token request for it to be valid.
+ */
+ Set<String> requiredClaims();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/filters/BearerTokenAuthenticator.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/filters/BearerTokenAuthenticator.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/filters/BearerTokenAuthenticator.java
new file mode 100644
index 0000000..779ba44
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/filters/BearerTokenAuthenticator.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.filters;
+
+import com.google.common.base.Supplier;
+import org.jclouds.http.HttpException;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.oauth.v2.domain.OAuthCredentials;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+@Singleton
+public class BearerTokenAuthenticator implements OAuthAuthenticationFilter {
+ private final Supplier<OAuthCredentials> creds;
+
+ @Inject
+ BearerTokenAuthenticator(final Supplier<OAuthCredentials> creds) {
+ this.creds = creds;
+ }
+
+ @Override
+ public HttpRequest filter(HttpRequest request) throws HttpException {
+ return request.toBuilder().addHeader("Authorization", String.format("%s %s",
+ "Bearer ", creds.get().credential)).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/filters/OAuthAuthenticationFilter.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/filters/OAuthAuthenticationFilter.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/filters/OAuthAuthenticationFilter.java
new file mode 100644
index 0000000..e6e5714
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/filters/OAuthAuthenticationFilter.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.filters;
+
+import org.jclouds.http.HttpRequestFilter;
+
+/**
+ * Marker interface to specify auth mechanism (credentials or bearer token)
+ *
+ */
+public interface OAuthAuthenticationFilter extends HttpRequestFilter {
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/filters/OAuthAuthenticator.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/filters/OAuthAuthenticator.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/filters/OAuthAuthenticator.java
new file mode 100644
index 0000000..c5c7b6f
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/filters/OAuthAuthenticator.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.filters;
+
+import com.google.common.base.Function;
+import com.google.common.cache.LoadingCache;
+import org.jclouds.http.HttpException;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.oauth.v2.domain.Token;
+import org.jclouds.oauth.v2.domain.TokenRequest;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import static com.google.common.base.Preconditions.checkState;
+
+/**
+ * To be used by client applications to embed an OAuth authentication in their REST requests.
+ * <p/>
+ * TODO when we're able to use the OAuthAuthentication an this should be used automatically
+ */
+@Singleton
+public class OAuthAuthenticator implements OAuthAuthenticationFilter {
+
+ private Function<GeneratedHttpRequest, TokenRequest> tokenRequestBuilder;
+ private Function<TokenRequest, Token> tokenFetcher;
+
+ @Inject
+ OAuthAuthenticator(Function<GeneratedHttpRequest, TokenRequest> tokenRequestBuilder, LoadingCache<TokenRequest,
+ Token> tokenFetcher) {
+ this.tokenRequestBuilder = tokenRequestBuilder;
+ this.tokenFetcher = tokenFetcher;
+ }
+
+ @Override
+ public HttpRequest filter(HttpRequest request) throws HttpException {
+ checkState(request instanceof GeneratedHttpRequest, "request must be an instance of GeneratedHttpRequest");
+ GeneratedHttpRequest generatedHttpRequest = GeneratedHttpRequest.class.cast(request);
+ TokenRequest tokenRequest = tokenRequestBuilder.apply(generatedHttpRequest);
+ Token token = tokenFetcher.apply(tokenRequest);
+ return request.toBuilder().addHeader("Authorization", String.format("%s %s",
+ token.getTokenType(), token.getAccessToken())).build();
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/BuildTokenRequest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/BuildTokenRequest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/BuildTokenRequest.java
new file mode 100644
index 0000000..7b869dc
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/BuildTokenRequest.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.functions;
+
+import static com.google.common.base.Preconditions.checkState;
+import static org.jclouds.oauth.v2.OAuthConstants.ADDITIONAL_CLAIMS;
+import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE;
+import static org.jclouds.oauth.v2.config.OAuthProperties.SCOPES;
+import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM;
+
+import java.util.Map;
+
+import javax.inject.Singleton;
+
+import org.jclouds.Constants;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.domain.ClaimSet;
+import org.jclouds.oauth.v2.domain.Header;
+import org.jclouds.oauth.v2.domain.OAuthCredentials;
+import org.jclouds.oauth.v2.domain.TokenRequest;
+import org.jclouds.oauth.v2.domain.TokenRequestFormat;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.reflect.Invokable;
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+
+/**
+ * The default authenticator.
+ * <p/>
+ * Builds the default token request with the following claims: iss,scope,aud,iat,exp.
+ * <p/>
+ * TODO scopes etc should come from the REST method and not from a global property
+ */
+@Singleton
+public class BuildTokenRequest implements Function<GeneratedHttpRequest, TokenRequest> {
+
+ private final String assertionTargetDescription;
+ private final String signatureAlgorithm;
+ private final TokenRequestFormat tokenRequestFormat;
+ private final Supplier<OAuthCredentials> credentialsSupplier;
+ private final long tokenDuration;
+
+ @Inject(optional = true)
+ @Named(ADDITIONAL_CLAIMS)
+ protected Map<String, String> additionalClaims = ImmutableMap.of();
+
+ @Inject(optional = true)
+ @Named(SCOPES)
+ protected String globalScopes = null;
+
+ // injectable so expect tests can override with a predictable value
+ @Inject(optional = true)
+ protected Supplier<Long> timeSourceMillisSinceEpoch = new Supplier<Long>() {
+ @Override
+ public Long get() {
+ return System.currentTimeMillis();
+ }
+ };
+
+ @Inject
+ public BuildTokenRequest(@Named(AUDIENCE) String assertionTargetDescription,
+ @Named(SIGNATURE_OR_MAC_ALGORITHM) String signatureAlgorithm,
+ TokenRequestFormat tokenRequestFormat, Supplier<OAuthCredentials> credentialsSupplier,
+ @Named(Constants.PROPERTY_SESSION_INTERVAL) long tokenDuration) {
+ this.assertionTargetDescription = assertionTargetDescription;
+ this.signatureAlgorithm = signatureAlgorithm;
+ this.tokenRequestFormat = tokenRequestFormat;
+ this.credentialsSupplier = credentialsSupplier;
+ this.tokenDuration = tokenDuration;
+ }
+
+ @Override
+ public TokenRequest apply(GeneratedHttpRequest request) {
+ long now = timeSourceMillisSinceEpoch.get() / 1000;
+
+ // fetch the token
+ Header header = new Header.Builder()
+ .signerAlgorithm(signatureAlgorithm)
+ .type(tokenRequestFormat.getTypeName())
+ .build();
+
+ ClaimSet claimSet = new ClaimSet.Builder(this.tokenRequestFormat.requiredClaims())
+ .addClaim("iss", credentialsSupplier.get().identity)
+ .addClaim("scope", getOAuthScopes(request))
+ .addClaim("aud", assertionTargetDescription)
+ .emissionTime(now)
+ .expirationTime(now + tokenDuration)
+ .addAllClaims(additionalClaims)
+ .build();
+
+ return new TokenRequest.Builder()
+ .header(header)
+ .claimSet(claimSet)
+ .build();
+ }
+
+ protected String getOAuthScopes(GeneratedHttpRequest request) {
+ Invokable<?, ?> invokable = request.getInvocation().getInvokable();
+
+ OAuthScopes classScopes = invokable.getOwnerType().getRawType().getAnnotation(OAuthScopes.class);
+ OAuthScopes methodScopes = invokable.getAnnotation(OAuthScopes.class);
+
+ // if no annotations are present the rely on globally set scopes
+ if (classScopes == null && methodScopes == null) {
+ checkState(globalScopes != null, String.format("REST class or method should be annotated " +
+ "with OAuthScopes specifying required permissions. Alternatively a global property " +
+ "\"oauth.scopes\" may be set to define scopes globally. REST Class: %s, Method: %s",
+ invokable.getOwnerType(),
+ invokable.getName()));
+ return globalScopes;
+ }
+
+ OAuthScopes scopes = methodScopes != null ? methodScopes : classScopes;
+ return Joiner.on(",").join(scopes.value());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/FetchToken.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/FetchToken.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/FetchToken.java
new file mode 100644
index 0000000..593c885
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/FetchToken.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.functions;
+
+import com.google.common.base.Function;
+import org.jclouds.oauth.v2.OAuthApi;
+import org.jclouds.oauth.v2.domain.Token;
+import org.jclouds.oauth.v2.domain.TokenRequest;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+@Singleton
+public class FetchToken implements Function<TokenRequest, Token> {
+
+ private OAuthApi oAuthApi;
+
+ @Inject
+ public FetchToken(OAuthApi oAuthApi) {
+ this.oAuthApi = oAuthApi;
+ }
+
+ @Override
+ public Token apply(TokenRequest input) {
+ return this.oAuthApi.authenticate(input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/OAuthCredentialsSupplier.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/OAuthCredentialsSupplier.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/OAuthCredentialsSupplier.java
new file mode 100644
index 0000000..45620c0
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/OAuthCredentialsSupplier.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.functions;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Charsets;
+import com.google.common.base.Supplier;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.io.ByteSource;
+import com.google.common.util.concurrent.UncheckedExecutionException;
+import org.jclouds.domain.Credentials;
+import org.jclouds.location.Provider;
+import org.jclouds.oauth.v2.domain.OAuthCredentials;
+import org.jclouds.rest.AuthorizationException;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.KeyFactory;
+import java.security.PrivateKey;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static java.lang.String.format;
+import static org.jclouds.crypto.Pems.privateKeySpec;
+import static org.jclouds.oauth.v2.OAuthConstants.NO_ALGORITHM;
+import static org.jclouds.oauth.v2.OAuthConstants.OAUTH_ALGORITHM_NAMES_TO_KEYFACTORY_ALGORITHM_NAMES;
+import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+/**
+ * Loads {@link OAuthCredentials} from a pem private key using the KeyFactory obtained from the JWT Algorithm
+ * Name<->KeyFactory name mapping in OAuthConstants. The pem pk algorithm must match the KeyFactory algorithm.
+ *
+ * @see org.jclouds.oauth.v2.OAuthConstants#OAUTH_ALGORITHM_NAMES_TO_KEYFACTORY_ALGORITHM_NAMES
+ */
+@Singleton
+public class OAuthCredentialsSupplier implements Supplier<OAuthCredentials> {
+
+ private final Supplier<Credentials> creds;
+ private final LoadingCache<Credentials, OAuthCredentials> keyCache;
+
+ @Inject
+ public OAuthCredentialsSupplier(@Provider Supplier<Credentials> creds, OAuthCredentialsForCredentials loader,
+ @Named(SIGNATURE_OR_MAC_ALGORITHM) String signatureOrMacAlgorithm) {
+ this.creds = creds;
+ checkArgument(OAUTH_ALGORITHM_NAMES_TO_KEYFACTORY_ALGORITHM_NAMES.containsKey(signatureOrMacAlgorithm),
+ format("No mapping for key factory for algorithm: %s", signatureOrMacAlgorithm));
+ // throw out the private key related to old credentials
+ this.keyCache = CacheBuilder.newBuilder().maximumSize(2).build(checkNotNull(loader, "loader"));
+ }
+
+ /**
+ * it is relatively expensive to extract a private key from a PEM. cache the relationship between current credentials
+ * so that the private key is only recalculated once.
+ */
+ @VisibleForTesting
+ static class OAuthCredentialsForCredentials extends CacheLoader<Credentials, OAuthCredentials> {
+ private final String keyFactoryAlgorithm;
+
+ @Inject
+ public OAuthCredentialsForCredentials(@Named(SIGNATURE_OR_MAC_ALGORITHM) String signatureOrMacAlgorithm) {
+ this.keyFactoryAlgorithm = OAUTH_ALGORITHM_NAMES_TO_KEYFACTORY_ALGORITHM_NAMES.get(checkNotNull(
+ signatureOrMacAlgorithm, "signatureOrMacAlgorithm"));
+ }
+
+ @Override
+ public OAuthCredentials load(Credentials in) {
+ try {
+ String identity = in.identity;
+ String privateKeyInPemFormat = in.credential;
+ if (keyFactoryAlgorithm.equals(NO_ALGORITHM)) {
+ return new OAuthCredentials.Builder().identity(identity).credential(privateKeyInPemFormat).build();
+ }
+ KeyFactory keyFactory = KeyFactory.getInstance(keyFactoryAlgorithm);
+ PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec(ByteSource.wrap(
+ privateKeyInPemFormat.getBytes(Charsets.UTF_8))));
+ return new OAuthCredentials.Builder().identity(identity).credential(privateKeyInPemFormat)
+ .privateKey(privateKey).build();
+ } catch (IOException e) {
+ throw propagate(e);
+ // catch security exceptions InvalidKeySpecException and NoSuchAlgorithmException as GSE
+ } catch (GeneralSecurityException e) {
+ throw new AuthorizationException("security exception loading credentials. " + e.getMessage(), e);
+ // catch IAE that is thrown when parsing the pk fails
+ } catch (IllegalArgumentException e) {
+ throw new AuthorizationException("cannot parse pk. " + e.getMessage(), e);
+ }
+ }
+ }
+
+ @Override
+ public OAuthCredentials get() {
+ try {
+ // loader always throws UncheckedExecutionException so no point in using get()
+ return keyCache.getUnchecked(checkNotNull(creds.get(), "credential supplier returned null"));
+ } catch (UncheckedExecutionException e) {
+ Throwable authorizationException = getFirstThrowableOfType(e, AuthorizationException.class);
+ if (authorizationException != null) {
+ throw (AuthorizationException) authorizationException;
+ }
+ throw propagate(e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/SignOrProduceMacForToken.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/SignOrProduceMacForToken.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/SignOrProduceMacForToken.java
new file mode 100644
index 0000000..471812a
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/functions/SignOrProduceMacForToken.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.functions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.base.Throwables;
+import org.jclouds.oauth.v2.domain.OAuthCredentials;
+
+import javax.annotation.PostConstruct;
+import javax.crypto.Mac;
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.Signature;
+import java.security.SignatureException;
+
+import static com.google.common.base.Preconditions.checkState;
+import static java.lang.String.format;
+import static org.jclouds.oauth.v2.OAuthConstants.NO_ALGORITHM;
+import static org.jclouds.oauth.v2.OAuthConstants.OAUTH_ALGORITHM_NAMES_TO_SIGNATURE_ALGORITHM_NAMES;
+import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM;
+
+/**
+ * Function that signs/produces mac's for OAuth tokens, provided a {@link Signature} or a {@link Mac} algorithm and
+ * {@link PrivateKey}
+ */
+public class SignOrProduceMacForToken implements Function<byte[], byte[]> {
+
+ private final Supplier<OAuthCredentials> credentials;
+ private final String signatureOrMacAlgorithm;
+ private Function<byte[], byte[]> signatureOrMacFunction;
+
+
+ @Inject
+ public SignOrProduceMacForToken(@Named(SIGNATURE_OR_MAC_ALGORITHM) String signatureOrMacAlgorithm,
+ Supplier<OAuthCredentials> credentials) {
+ checkState(OAUTH_ALGORITHM_NAMES_TO_SIGNATURE_ALGORITHM_NAMES.containsKey(signatureOrMacAlgorithm),
+ format("the signature algorithm %s is not supported", signatureOrMacAlgorithm));
+ this.signatureOrMacAlgorithm = OAUTH_ALGORITHM_NAMES_TO_SIGNATURE_ALGORITHM_NAMES.get(signatureOrMacAlgorithm);
+ this.credentials = credentials;
+ }
+
+ @PostConstruct
+ public void loadSignatureOrMacOrNone() throws InvalidKeyException, NoSuchAlgorithmException {
+ if (signatureOrMacAlgorithm.equals(NO_ALGORITHM)) {
+ this.signatureOrMacFunction = new Function<byte[], byte[]>() {
+ @Override
+ public byte[] apply(byte[] input) {
+ return null;
+ }
+ };
+ } else if (signatureOrMacAlgorithm.startsWith("SHA")) {
+ this.signatureOrMacFunction = new SignatureGenerator(signatureOrMacAlgorithm, credentials.get().privateKey);
+ } else {
+ this.signatureOrMacFunction = new MessageAuthenticationCodeGenerator(signatureOrMacAlgorithm,
+ credentials.get().privateKey);
+ }
+ }
+
+ @Override
+ public byte[] apply(byte[] input) {
+ return signatureOrMacFunction.apply(input);
+ }
+
+ private static class MessageAuthenticationCodeGenerator implements Function<byte[], byte[]> {
+
+ private Mac mac;
+
+ private MessageAuthenticationCodeGenerator(String macAlgorithm, PrivateKey privateKey) throws
+ NoSuchAlgorithmException, InvalidKeyException {
+ this.mac = Mac.getInstance(macAlgorithm);
+ this.mac.init(privateKey);
+ }
+
+ @Override
+ public byte[] apply(byte[] input) {
+ this.mac.update(input);
+ return this.mac.doFinal();
+ }
+ }
+
+ private static class SignatureGenerator implements Function<byte[], byte[]> {
+
+ private Signature signature;
+
+ private SignatureGenerator(String signatureAlgorithm, PrivateKey privateKey) throws NoSuchAlgorithmException,
+ InvalidKeyException {
+ this.signature = Signature.getInstance(signatureAlgorithm);
+ this.signature.initSign(privateKey);
+ }
+
+ @Override
+ public byte[] apply(byte[] input) {
+ try {
+ signature.update(input);
+ return signature.sign();
+ } catch (SignatureException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/handlers/OAuthErrorHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/handlers/OAuthErrorHandler.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/handlers/OAuthErrorHandler.java
new file mode 100644
index 0000000..78d7844
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/handlers/OAuthErrorHandler.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.handlers;
+
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ResourceNotFoundException;
+
+import javax.inject.Singleton;
+
+import static javax.ws.rs.core.Response.Status;
+import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
+
+/**
+ * This will parse and set an appropriate exception on the command object.
+ */
+@Singleton
+public class OAuthErrorHandler implements HttpErrorHandler {
+ public void handleError(HttpCommand command, HttpResponse response) {
+ // it is important to always read fully and close streams
+ byte[] data = closeClientButKeepContentStream(response);
+ String message = data != null ? new String(data) : null;
+
+ Exception exception = message != null ? new HttpResponseException(command, response, message)
+ : new HttpResponseException(command, response);
+ message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
+ response.getStatusLine());
+ Status status = Status.fromStatusCode(response.getStatusCode());
+ switch (status) {
+ case BAD_REQUEST:
+ break;
+ case UNAUTHORIZED:
+ case FORBIDDEN:
+ exception = new AuthorizationException(message, exception);
+ break;
+ case NOT_FOUND:
+ if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
+ exception = new ResourceNotFoundException(message, exception);
+ }
+ break;
+ case CONFLICT:
+ exception = new IllegalStateException(message, exception);
+ break;
+ }
+ command.setException(exception);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/handlers/OAuthTokenBinder.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/handlers/OAuthTokenBinder.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/handlers/OAuthTokenBinder.java
new file mode 100644
index 0000000..1030804
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/handlers/OAuthTokenBinder.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.handlers;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.oauth.v2.domain.TokenRequest;
+import org.jclouds.oauth.v2.domain.TokenRequestFormat;
+import org.jclouds.rest.Binder;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+/**
+ * Generic implementation of a token binder. Uses a provided {@link TokenRequestFormat} to actually bind tokens to
+ * requests.
+ */
+@Singleton
+public class OAuthTokenBinder implements Binder {
+
+ private final TokenRequestFormat tokenRequestFormat;
+
+ @Inject
+ OAuthTokenBinder(TokenRequestFormat tokenRequestFormat) {
+ this.tokenRequestFormat = tokenRequestFormat;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return tokenRequestFormat.formatRequest(request, (TokenRequest) input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/json/ClaimSetTypeAdapter.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/json/ClaimSetTypeAdapter.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/json/ClaimSetTypeAdapter.java
new file mode 100644
index 0000000..62b3a26
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/json/ClaimSetTypeAdapter.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.json;
+
+import com.google.gson.TypeAdapter;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+import org.jclouds.oauth.v2.domain.ClaimSet;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * JSON TypeAdapter for the ClaimSet type. Pull the claims maps to the root level and adds two properties for the
+ * expiration time and issuing time.
+ */
+public class ClaimSetTypeAdapter extends TypeAdapter<ClaimSet> {
+
+ @Override
+ public void write(JsonWriter out, ClaimSet value) throws IOException {
+ out.beginObject();
+ for (Map.Entry<String, String> entry : value.entrySet()) {
+ out.name(entry.getKey());
+ out.value(entry.getValue());
+ }
+ out.name("exp");
+ out.value(value.getExpirationTime());
+ out.name("iat");
+ out.value(value.getEmissionTime());
+ out.endObject();
+ }
+
+ @Override
+ public ClaimSet read(JsonReader in) throws IOException {
+ ClaimSet.Builder builder = new ClaimSet.Builder();
+ in.beginObject();
+ while (in.hasNext()) {
+ String claimName = in.nextName();
+ String claimValue = in.nextString();
+ builder.addClaim(claimName, claimValue);
+ }
+ in.endObject();
+ return builder.build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/json/HeaderTypeAdapter.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/json/HeaderTypeAdapter.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/json/HeaderTypeAdapter.java
new file mode 100644
index 0000000..f911a54
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/json/HeaderTypeAdapter.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.json;
+
+import com.google.gson.TypeAdapter;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+import org.jclouds.oauth.v2.domain.Header;
+
+import java.io.IOException;
+
+/**
+ * JSON TypeAdapter for the Header type. Simply transforms the field names.
+ */
+public class HeaderTypeAdapter extends TypeAdapter<Header> {
+
+ @Override
+ public void write(JsonWriter out, Header value) throws IOException {
+ out.beginObject();
+ out.name("alg");
+ out.value(value.getSignerAlgorithm());
+ out.name("typ");
+ out.value(value.getType());
+ out.endObject();
+ }
+
+ @Override
+ public Header read(JsonReader in) throws IOException {
+ Header.Builder builder = new Header.Builder();
+ in.beginObject();
+ in.nextName();
+ builder.signerAlgorithm(in.nextString());
+ in.nextName();
+ builder.type(in.nextString());
+ in.endObject();
+ return builder.build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/json/JWTTokenRequestFormat.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/json/JWTTokenRequestFormat.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/json/JWTTokenRequestFormat.java
new file mode 100644
index 0000000..265cb26
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/json/JWTTokenRequestFormat.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.json;
+
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.base.Joiner.on;
+import static com.google.common.io.BaseEncoding.base64Url;
+import static org.jclouds.io.Payloads.newUrlEncodedFormPayload;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.io.Payload;
+import org.jclouds.json.Json;
+import org.jclouds.oauth.v2.domain.TokenRequest;
+import org.jclouds.oauth.v2.domain.TokenRequestFormat;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Formats a token request into JWT format namely:
+ * - transforms the token request to json
+ * - creates the base64 header.claimset portions of the payload.
+ * - uses the provided signer function to create a signature
+ * - creates the full url encoded payload as described in:
+ * https://developers.google.com/accounts/docs/OAuth2ServiceAccount
+ * <p/>
+ */
+@Singleton
+public class JWTTokenRequestFormat implements TokenRequestFormat {
+
+ private static final String ASSERTION_FORM_PARAM = "assertion";
+ private static final String GRANT_TYPE_FORM_PARAM = "grant_type";
+ private static final String GRANT_TYPE_JWT_BEARER = "urn:ietf:params:oauth:grant-type:jwt-bearer";
+
+ private final Function<byte[], byte[]> signer;
+ private final Json json;
+
+ @Inject
+ public JWTTokenRequestFormat(Function<byte[], byte[]> signer, Json json) {
+ this.signer = signer;
+ this.json = json;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <R extends HttpRequest> R formatRequest(R request, TokenRequest tokenRequest) {
+
+ String encodedHeader = json.toJson(tokenRequest.getHeader());
+ String encodedClaimSet = json.toJson(tokenRequest.getClaimSet());
+
+ encodedHeader = base64Url().omitPadding().encode(encodedHeader.getBytes(UTF_8));
+ encodedClaimSet = base64Url().omitPadding().encode(encodedClaimSet.getBytes(UTF_8));
+
+ byte[] signature = signer.apply(on(".").join(encodedHeader, encodedClaimSet).getBytes(UTF_8));
+ String encodedSignature = signature != null ? base64Url().omitPadding().encode(signature) : "";
+
+ // the final assertion in base 64 encoded {header}.{claimSet}.{signature} format
+ String assertion = on(".").join(encodedHeader, encodedClaimSet, encodedSignature);
+ Payload payload = newUrlEncodedFormPayload(ImmutableMultimap.<String, String> builder()
+ .put(GRANT_TYPE_FORM_PARAM, GRANT_TYPE_JWT_BEARER)
+ .put(ASSERTION_FORM_PARAM, assertion).build());
+
+ return (R) request.toBuilder().payload(payload).build();
+ }
+
+ @Override
+ public String getTypeName() {
+ return "JWT";
+ }
+
+ @Override
+ public Set<String> requiredClaims() {
+ // exp and ist (expiration and emission times) are assumed mandatory already
+ return ImmutableSet.of("iss", "scope", "aud");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
new file mode 100644
index 0000000..ab2c67d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.jclouds.googlecomputeengine.GoogleComputeEngineApiMetadata
+org.jclouds.oauth.v2.OAuthApiMetadata
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadataTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadataTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadataTest.java
new file mode 100644
index 0000000..5cb8a99
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadataTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine;
+
+import org.jclouds.View;
+import org.jclouds.apis.internal.BaseApiMetadataTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.reflect.TypeToken;
+
+/**
+ * Tests that GoogleComputeApiMetadata is properly registered in ServiceLoader
+ * <p/>
+ * <pre>
+ * META-INF/services/org.jclouds.apis.ApiMetadata
+ * </pre>
+ */
+@Test(groups = "unit", testName = "GoogleComputeApiMetadataTest")
+public class GoogleComputeEngineApiMetadataTest extends BaseApiMetadataTest {
+ public GoogleComputeEngineApiMetadataTest() {
+ super(new GoogleComputeEngineApiMetadata(), ImmutableSet.<TypeToken<? extends View>>of());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineAuthenticatedRestContextLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineAuthenticatedRestContextLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineAuthenticatedRestContextLiveTest.java
new file mode 100644
index 0000000..8961bb5
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineAuthenticatedRestContextLiveTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine;
+
+import org.jclouds.oauth.v2.internal.BaseOAuthAuthenticatedApiLiveTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "live")
+public class GoogleComputeEngineAuthenticatedRestContextLiveTest extends BaseOAuthAuthenticatedApiLiveTest<GoogleComputeEngineApi> {
+
+ public GoogleComputeEngineAuthenticatedRestContextLiveTest() {
+ provider = "google-compute-engine";
+ }
+
+ @Override
+ public String getScopes() {
+ return GoogleComputeEngineConstants.COMPUTE_SCOPE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java
new file mode 100644
index 0000000..8fa44b9
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.testng.Assert.assertSame;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.features.ImageApi;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+/**
+ * A test specifically for the paging system. The code used is common to all list() methods so we're using Images
+ * but it could be anything else.
+ */
+@Test(groups = "unit")
+public class PageSystemExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ public void testGetSinglePage() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/images")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/image_list_single_page.json")).build();
+
+ ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getImageApiForProject("myproject");
+
+ PagedIterable<Image> images = imageApi.list();
+
+ // expect one page
+ assertSame(images.size(), 1);
+ // with three images
+ assertSame(images.concat().size(), 3);
+ }
+
+ public void testGetMultiplePages() {
+ HttpRequest list1 = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/images?maxResults=3")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpRequest list2 = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/images?pageToken" +
+ "=CgVJTUFHRRIbZ29vZ2xlLmNlbnRvcy02LTItdjIwMTIwNjIx&maxResults=3")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpRequest list3 = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/images?pageToken" +
+ "=CgVJTUFHRRIbZ29vZ2xlLmdjZWwtMTAtMDQtdjIwMTIxMTA2&maxResults=3")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse list1response = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/image_list_multiple_page_1.json")).build();
+
+ HttpResponse list2Response = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/image_list_multiple_page_2.json")).build();
+
+ HttpResponse list3Response = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/image_list_single_page.json")).build();
+
+
+ ImageApi imageApi = orderedRequestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list1, list1response, list2, list2Response, list3, list3Response)
+ .getImageApiForProject("myproject");
+
+ PagedIterable<Image> images = imageApi.list(new ListOptions.Builder().maxResults(3));
+
+ int imageCounter = 0;
+ for (IterableWithMarker<Image> page : images) {
+ for (Image image : page) {
+ imageCounter++;
+ }
+ }
+ assertSame(imageCounter, 9);
+ }
+
+}
[15/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java
new file mode 100644
index 0000000..73868fb
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java
@@ -0,0 +1,497 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.strategy;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Predicates.not;
+import static com.google.common.collect.Iterables.find;
+import static com.google.common.collect.Iterables.get;
+import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
+import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsCommaDelimitedValue;
+import static org.jclouds.util.Predicates2.retry;
+import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import org.jclouds.cim.ResourceAllocationSettingData;
+import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.logging.Logger;
+import org.jclouds.ovf.Network;
+import org.jclouds.predicates.validators.DnsNameValidator;
+import org.jclouds.rest.annotations.BuildVersion;
+import org.jclouds.vcloud.TaskStillRunningException;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
+import org.jclouds.vcloud.domain.*;
+import org.jclouds.vcloud.domain.NetworkConnectionSection.Builder;
+import org.jclouds.vcloud.domain.internal.VmImpl;
+import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
+import org.jclouds.vcloud.domain.network.NetworkConfig;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
+import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Joiner;
+import com.google.common.base.Predicate;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableSet;
+import org.jclouds.vcloud.predicates.TaskSuccess;
+
+@Singleton
+public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ protected final VCloudApi client;
+ protected final Predicate<URI> successTester;
+ protected final LoadingCache<URI, VAppTemplate> vAppTemplates;
+ protected final NetworkConfigurationForNetworkAndOptions networkConfigurationForNetworkAndOptions;
+ protected final String buildVersion;
+
+
+ @Inject
+ protected InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn(VCloudApi client,
+ Predicate<URI> successTester, LoadingCache<URI, VAppTemplate> vAppTemplates, NetworkConfigurationForNetworkAndOptions networkConfigurationForNetworkAndOptions,
+ @BuildVersion String buildVersion) {
+ this.client = client;
+ this.successTester = successTester;
+ this.vAppTemplates = vAppTemplates;
+ this.networkConfigurationForNetworkAndOptions = networkConfigurationForNetworkAndOptions;
+ this.buildVersion = buildVersion;
+ }
+
+ /**
+ * per john ellis at bluelock, vCloud Director 1.5 is more strict than earlier versions.
+ * <p/>
+ * It appears to be 15 characters to match Windows' hostname limitation. Must be alphanumeric, at
+ * least one non-number character and hyphens and underscores are the only non-alpha character
+ * allowed.
+ */
+ public static enum ComputerNameValidator {
+ INSTANCE;
+
+ private DnsNameValidator validator;
+
+ ComputerNameValidator() {
+ this.validator = new DnsNameValidator(3, 15);
+ }
+
+ public void validate(@Nullable String t) throws IllegalArgumentException {
+ this.validator.validate(t);
+ }
+
+ }
+
+ public NodeAndInitialCredentials<VApp> createNodeWithGroupEncodedIntoName(String group, String name, Template template) {
+ // no sense waiting until failures occur later
+ ComputerNameValidator.INSTANCE.validate(name);
+ VApp vAppResponse = instantiateVAppFromTemplate(name, template);
+ waitForTask(vAppResponse.getTasks().get(0));
+ logger.debug("<< instantiated VApp(%s)", vAppResponse.getName());
+
+ // vm data is available after instantiate completes
+ vAppResponse = client.getVAppApi().getVApp(vAppResponse.getHref());
+
+ // per above check, we know there is only a single VM
+ Vm vm = get(vAppResponse.getChildren(), 0);
+
+ template.getOptions().userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, group);
+ VCloudTemplateOptions vOptions = VCloudTemplateOptions.class.cast(template.getOptions());
+
+ // note we cannot do tasks in parallel or VCD will throw "is busy" errors
+
+ // note we must do this before any other customizations as there is a dependency on
+ // valid naming conventions before you can perform commands such as updateCPUCount
+ logger.trace(">> updating customization vm(%s) name->(%s)", vm.getName(), name);
+ waitForTask(updateVmWithNameAndCustomizationScript(vm, name, vOptions.getCustomizationScript()));
+ logger.trace("<< updated customization vm(%s)", name);
+
+ ensureVmHasDesiredNetworkConnectionSettings(vAppResponse, vOptions);
+
+ int cpuCount = (int) getCores(template.getHardware());
+ logger.trace(">> updating cpuCount(%d) vm(%s)", cpuCount, vm.getName());
+ waitForTask(updateCPUCountOfVm(vm, cpuCount));
+ logger.trace("<< updated cpuCount vm(%s)", vm.getName());
+ int memoryMB = template.getHardware().getRam();
+ logger.trace(">> updating memoryMB(%d) vm(%s)", memoryMB, vm.getName());
+ waitForTask(updateMemoryMBOfVm(vm, memoryMB));
+ logger.trace("<< updated memoryMB vm(%s)", vm.getName());
+ logger.trace(">> deploying vApp(%s)", vAppResponse.getName());
+ waitForTask(client.getVAppApi().deployVApp(vAppResponse.getHref()));
+ logger.trace("<< deployed vApp(%s)", vAppResponse.getName());
+
+ // only after deploy is the password valid
+ vAppResponse = client.getVAppApi().getVApp(vAppResponse.getHref());
+
+ logger.trace(">> powering on vApp(%s)", vAppResponse.getName());
+ client.getVAppApi().powerOnVApp(vAppResponse.getHref());
+
+ return new NodeAndInitialCredentials<VApp>(vAppResponse, vAppResponse.getHref().toASCIIString(),
+ getCredentialsFrom(vAppResponse));
+
+ }
+
+ @VisibleForTesting
+ protected VApp instantiateVAppFromTemplate(String name, Template template) {
+ VCloudTemplateOptions vOptions = VCloudTemplateOptions.class.cast(template.getOptions());
+
+ URI templateId = URI.create(template.getImage().getId());
+
+ VAppTemplate vAppTemplate = vAppTemplates.getUnchecked(templateId);
+
+ if (vAppTemplate.getChildren().size() > 1)
+ throw new UnsupportedOperationException("we currently do not support multiple vms in a vAppTemplate "
+ + vAppTemplate);
+
+ VmImpl vmTemplate = VmImpl.class.cast(vAppTemplate.getChildren().iterator().next());
+
+ String description = VCloudTemplateOptions.class.cast(template.getOptions()).getDescription();
+ if (description == null) {
+ Map<String, String> md = metadataAndTagsAsCommaDelimitedValue(template.getOptions());
+ description = Joiner.on('\n').withKeyValueSeparator("=").join(md);
+ }
+
+ InstantiateVAppTemplateOptions options = InstantiateVAppTemplateOptions.Builder.description(description);
+
+ /*
+ * Match up networks in the vApp template with the ones in the options we got passed in, so that
+ * the right ones can be wired together.
+ * Note that in the end the order of the network interfaces is what's important, not the names. The names
+ * might not match up. In the worst case, maybe someone called their vApp networks A and B, but really wants
+ * them cross-connected, i.e. wired up to B and A respectively.
+ * The only potential issue here is that the networks in the vOptions are stored as a Set, which makes little
+ * sense. While the API is what it is, we need to rely on people higher up using sensible underlying
+ * datastructures (that conform to the set interface), which preserve their order.
+ */
+
+ int vmTemplateNumNetworks = vmTemplate.getNetworkConnectionSection().getConnections().size();
+
+ /*
+ * Backwards-compatibility hack: we might get passed in a parent network URI and an empty vOptions.networks list.
+ * In that case, move the parent network URI into the vOptions.networks list, and remove the parent URI.
+ */
+ if (vOptions.getNetworks().size() == 0 && vmTemplateNumNetworks == 1 && vOptions.getParentNetwork() != null) {
+ ArrayList<String> netlist = new ArrayList<String>();
+ netlist.add(vOptions.getParentNetwork().toASCIIString());
+ vOptions.networks(netlist);
+ vOptions.parentNetwork(null);
+ }
+
+ URI[] vOptionsNetworkIdList = new URI[vOptions.getNetworks().size()];
+ NetworkConnection[] vAppTemplateNetworkList =
+ new NetworkConnection[vmTemplateNumNetworks];
+
+ //hopefully this preserves the original order, assuming the original underlying datastructure was ordered.
+ int i = 0;
+ for (String network: vOptions.getNetworks()) {
+ try {
+ vOptionsNetworkIdList[i] = new URI(network);
+ } catch (URISyntaxException e) {
+ logger.error(e, "Failed to convert href '" + network + "' to URI. We expect a href to a network to be " +
+ "passed in, not a name for example.");
+ return null;
+ }
+ i++;
+ }
+
+ //iterate over the NetworkConnectionSection, and put them in order of their connection indices
+ // into the vAppTemplateNetworkList.
+ for (NetworkConnection netCon: vmTemplate.getNetworkConnectionSection().getConnections()) {
+ vAppTemplateNetworkList[netCon.getNetworkConnectionIndex()] = netCon;
+ }
+
+ for (i = 0; i < vOptionsNetworkIdList.length; i++) {
+ URI parentNetwork = vOptionsNetworkIdList[i];
+ NetworkConnection networkConnectionParams = vAppTemplateNetworkList.length > i ? vAppTemplateNetworkList[i] : null;
+ //hook 'em up.
+
+ //use network name from vAppTemplate if possible
+ String networkName;
+ if (networkConnectionParams != null) {
+ networkName = networkConnectionParams.getNetwork();
+ } else {
+ networkName = "jclouds-net-" + String.valueOf(i);
+ }
+
+ Network n = new Network(networkName, null); // ignore description, not needed here.
+ VCloudTemplateOptions networkTemplateOptions = vOptions.clone(); //we'll modify bits here
+ networkTemplateOptions.parentNetwork(parentNetwork);
+
+ NetworkConfig config = networkConfigurationForNetworkAndOptions.apply(n, networkTemplateOptions);
+ // note that in VCD 1.5, the network name after instantiation will be the same as the parent
+ options.addNetworkConfig(config);
+ logger.debug("Connecting vApp network " + n.getName() + " to org network " + parentNetwork + ".");
+ }
+
+ // TODO make disk size specifiable
+ // disk((long) ((template.getHardware().getVolumes().get(0).getSize()) *
+ // 1024 * 1024l));
+
+
+
+ options.deploy(false);
+ options.powerOn(false);
+
+ URI VDC = URI.create(template.getLocation().getId());
+
+ logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) options(%s) ", VDC, templateId, name, options);
+
+ VApp vAppResponse = client.getVAppTemplateApi().createVAppInVDCByInstantiatingTemplate(name, VDC, templateId,
+ options);
+ return vAppResponse;
+ }
+
+ // TODO: filtering on "none" is a hack until we can filter on
+ // vAppTemplate.getNetworkConfigSection().getNetworkConfigs() where
+ // name = getChildren().NetworkConnectionSection.connection where ipallocationmode == none
+ static Predicate<Network> networkWithNoIpAllocation = new Predicate<Network>() {
+
+ @Override
+ public boolean apply(Network input) {
+ return "none".equals(input.getName());
+ }
+
+ };
+
+ public void waitForTask(Task task) {
+ if (!successTester.apply(task.getHref())) {
+ throw new TaskStillRunningException(task);
+ }
+ }
+ /**
+ * Naming constraints modifying a VM on a VApp in vCloud Director (at least v1.5) can be more
+ * strict than those in a vAppTemplate. For example, while it is possible to instantiate a
+ * vAppTemplate with a VM named (incorrectly) {@code Ubuntu_10.04}, you must change the name to a
+ * valid (alphanumeric underscore) name before you can update it.
+ */
+ public Task updateVmWithNameAndCustomizationScript(Vm vm, String name, @Nullable String customizationScript) {
+ GuestCustomizationSection guestConfiguration = vm.getGuestCustomizationSection();
+ guestConfiguration.setComputerName(name);
+ if (customizationScript != null) {
+ // In version 1.0.0, the api returns a script that loses newlines, so we cannot append to a
+ // customization script.
+ // TODO: parameterize whether to overwrite or append existing customization
+ if (!buildVersion.startsWith("1.0.0") && !"".endsWith(buildVersion)
+ && guestConfiguration.getCustomizationScript() != null)
+ customizationScript = guestConfiguration.getCustomizationScript() + "\n" + customizationScript;
+
+ guestConfiguration.setCustomizationScript(customizationScript);
+ }
+ return client.getVmApi().updateGuestCustomizationOfVm(guestConfiguration, vm.getHref());
+ }
+
+ public void ensureVmHasDesiredNetworkConnectionSettings(VApp vApp, VCloudTemplateOptions vOptions) {
+ Network networkToConnect = find(vApp.getNetworkSection().getNetworks(), not(networkWithNoIpAllocation));
+
+ Vm vm = get(vApp.getChildren(), 0);
+
+ NetworkConnectionSection nets = vm.getNetworkConnectionSection();
+ checkArgument(nets.getConnections().size() > 0, "no connections on vm %s", vm);
+
+ /*
+ * Here we want to build the NetworkConnectionSection.
+ * This is not required if:
+ * - the user didn't pass in any vCloud specific NetworkConnection settings, and
+ * - there exist enough NetworkConnectionSections to cover the networks we need to
+ * wire up to the VM
+ *
+ * In case of modifying the existing network connection, its important that
+ * those optional parameters whose value is not being changed needs to be returned
+ * with the existing values or vcloud puts default values for them. When mac address is not
+ * modified then it needs to be returned else vclouds changes the adapter type of the NIC to E1000.
+ *
+ * There are a couple of things that might require changes:
+ * - different parameters (e.g. ip address allocation mode)
+ * - insufficient NetworkConnection items (we need to add more to trigger the
+ * creation of more NICs)
+ * - if the user didn't pass in any vCloud specific NetworkConnections, we might need to
+ * create new ones here.
+ * It's easier to just unconditionally rewrite the network connection section,
+ * than to write some bug-prone code that checks all of the above conditions.
+ */
+
+ /*
+ * We also need to add NICs. If we don't do this, we'll get new NICs, but they'll all be E1000s.
+ * We really want to replicate the type of any existing adapters.
+ *
+ * We add the NICs only when it is needed. In case of vapp template having vm with multiple NICs
+ * and if we update only the existing NICs then vcloud throws error that primary NIC not found.
+ */
+ Set<? extends ResourceAllocationSettingData> allVirtualHWItems = vm.getVirtualHardwareSection().getItems();
+ Iterable<VCloudNetworkAdapter> existingNics = Iterables.filter(allVirtualHWItems, VCloudNetworkAdapter.class);
+ // we want to program all existing nics.
+ ArrayList<VCloudNetworkAdapter> nicsToProgram = Lists.newArrayList(existingNics);
+
+ //the first adapter type will be used as default for newly added ones.
+ String firstAdapterType = "E1000";
+ int nextInstanceID = 1;
+ if (nicsToProgram.size() >= 1) {
+ firstAdapterType = nicsToProgram.get(0).getResourceSubType();
+ nextInstanceID = 1 + Integer.valueOf(nicsToProgram.get(nicsToProgram.size() - 1).getInstanceID());
+ }
+
+ int i = 0;
+ LinkedHashSet<NetworkConnection> connectionsToProgram = new LinkedHashSet<NetworkConnection>();
+ for (String netUuid: vOptions.getNetworks()) {
+ NetworkConnection desiredNC = vOptions.getNetworkConnections().get(netUuid);
+ String netName;
+ String macAddr;
+ NetworkConnection vappNC = findNetworkConnectionByIndexOrNull(nets, i);
+ if (vappNC != null && vappNC.getNetwork() != null) {
+ netName = vappNC.getNetwork();
+ } else {
+ netName = null;
+ }
+
+ if (vappNC != null && vappNC.getMACAddress() != null) {
+ macAddr = vappNC.getMACAddress();
+ } else {
+ macAddr = null;
+ }
+
+ if (desiredNC != null
+ && desiredNC.getNetworkConnectionIndex() != i) {
+ logger.error("Data consistency error: the network '" + netUuid + "'s connection index has been specified "
+ + "in the vCloud specific NetworkConnection settings in VCloudTemplateOptions.networkConnections, but "
+ + "the connection index does not match the "
+ + "position of the network in the TemplateOptions.networks object. Ignoring vCloud specific options for this net.");
+ desiredNC = null;
+ }
+ /*
+ Its not yet clear why the mac address in desiredNC is null. This needs to be explored.
+ This special handling is needed as the mac address is null and if it is not set, it results in NIC
+ type as E1000
+ */
+ if (desiredNC != null && macAddr != null && desiredNC.getMACAddress() == null){
+ NetworkConnection.Builder desiredNCBuilder = desiredNC.toBuilder();
+ desiredNCBuilder.MACAddress(macAddr);
+ desiredNC = desiredNCBuilder.build();
+ }
+ if (desiredNC != null && desiredNC.getIpAddressAllocationMode() == null
+ || desiredNC.getIpAddressAllocationMode() == IpAddressAllocationMode.NONE) {
+ logger.error("Data consistency error: the network '" + netUuid + "'s IP address allocation mode"
+ + "has been set to 'none' or null in the vCloud specific NetworkConnection settings in VCloudTemplateOptions.networkConnections. "
+ + "This is invalid. Ignoring vCloud specific options for this net.");
+ desiredNC = null;
+ }
+
+ NetworkConnection ncToAdd = null;
+ if (desiredNC == null) {
+ // use default settings
+ ncToAdd = new NetworkConnection(netName, i, null, null, true, null,
+ IpAddressAllocationMode.POOL);
+ } else {
+ if (netName != null && !netName.equals(desiredNC.getNetwork())) {
+ //something's probably wrong.
+ logger.warn("vcloud overridden network name '" + desiredNC.getNetwork() + "' doesn't match the vApp's "
+ + " network with index " + i + " name '" + netName + "'");
+ }
+
+ if (netName == null && desiredNC.getNetwork() == null) {
+ //ok we need to come up with some network name.
+ netName = "jclouds-net-" + String.valueOf(i);
+ NetworkConnection.Builder ncBuilder = desiredNC.toBuilder();
+ ncToAdd = ncBuilder.network(netName).connected(desiredNC.isConnected())
+ .externalIpAddress(desiredNC.getExternalIpAddress())
+ .ipAddress(desiredNC.getIpAddress()).ipAddressAllocationMode(desiredNC.getIpAddressAllocationMode())
+ .MACAddress(desiredNC.getMACAddress()).networkConnectionIndex(desiredNC.getNetworkConnectionIndex()).build();
+ } else {
+ ncToAdd = desiredNC;
+ }
+ }
+ connectionsToProgram.add(ncToAdd);
+
+ //OK, we've now setup the network connection. Now we want to check if we need to add a new NIC for it.
+ if (nicsToProgram.size() < connectionsToProgram.size()) {
+ VCloudNetworkAdapter.Builder nicBuilder = VCloudNetworkAdapter.builder();
+ //interesting values
+ nicBuilder.addressOnParent(String.valueOf(i));
+ nicBuilder.automaticAllocation(true);
+ nicBuilder.connection(ncToAdd.getNetwork());
+ nicBuilder.ipAddressingMode(ncToAdd.getIpAddressAllocationMode().toString());
+ nicBuilder.elementName("Network adapter " + String.valueOf(i));
+ nicBuilder.instanceID(String.valueOf(nextInstanceID));
+ nextInstanceID += 1;
+ nicBuilder.resourceSubType(firstAdapterType);
+ nicBuilder.resourceType(ResourceAllocationSettingData.ResourceType.ETHERNET_ADAPTER);
+
+ VCloudNetworkAdapter newNic = nicBuilder.build();
+ nicsToProgram.add(newNic);
+ }
+ i++;
+ }
+
+ // Add new nics only if they are needed
+ if (nicsToProgram.size() < connectionsToProgram.size()) {
+ logger.debug("Programming NICs: %s", nicsToProgram);
+ Task t = client.getVmApi().updateNetworkCardsOfVm(nicsToProgram, vm.getHref());
+ waitForTask(t);
+ }
+
+ // update the NetworkConnectionSection.
+ Builder builder = nets.toBuilder();
+ builder.connections(connectionsToProgram);
+ logger.trace(">> updating networkConnection vm(%s)", vm.getName());
+ logger.debug("New NetworkConnectionSection for VM %s: %s", vm.getName(), builder.build().toString());
+ waitForTask(client.getVmApi().updateNetworkConnectionOfVm(builder.build(), vm.getHref()));
+ logger.trace("<< updated networkConnection vm(%s)", vm.getName());
+ }
+
+ private NetworkConnection findWithPoolAllocationOrFirst(NetworkConnectionSection net) {
+ return find(net.getConnections(), new Predicate<NetworkConnection>() {
+
+ @Override
+ public boolean apply(NetworkConnection input) {
+ return input.getIpAddressAllocationMode() == IpAddressAllocationMode.POOL;
+ }
+
+ }, get(net.getConnections(), 0));
+ }
+
+ private NetworkConnection findNetworkConnectionByIndexOrNull(NetworkConnectionSection net, final int index) {
+ return find(net.getConnections(), new Predicate<NetworkConnection>() {
+
+ @Override
+ public boolean apply(NetworkConnection input) {
+ return input.getNetworkConnectionIndex() == index;
+ }
+
+ }, null);
+ }
+
+ public Task updateCPUCountOfVm(Vm vm, int cpuCount) {
+ return client.getVmApi().updateCPUCountOfVm(cpuCount, vm.getHref());
+ }
+
+ public Task updateMemoryMBOfVm(Vm vm, int memoryInMB) {
+ return client.getVmApi().updateMemoryMBOfVm(memoryInMB, vm.getHref());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java
new file mode 100644
index 0000000..28c8a9b
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.strategy;
+
+import java.net.URI;
+
+import javax.inject.Inject;
+
+import org.jclouds.ovf.Network;
+import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.jclouds.vcloud.domain.network.NetworkConfig;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Supplier;
+
+@Beta
+public class NetworkConfigurationForNetworkAndOptions {
+ protected final Supplier<NetworkConfig> defaultNetworkConfig;
+ protected final FenceMode defaultFenceMode;
+
+ @Inject
+ protected NetworkConfigurationForNetworkAndOptions(Supplier<NetworkConfig> defaultNetworkConfig,
+ FenceMode defaultFenceMode) {
+ this.defaultNetworkConfig = defaultNetworkConfig;
+ this.defaultFenceMode = defaultFenceMode;
+ }
+
+ /**
+ *
+ * returns a {@link NetworkConfig} used to instantiate a vAppTemplate to
+ * either the default parent (org) network, or one specified by options.
+ *
+ * @param networkToConnect
+ * network defined in the VAppTemplate you wish to connect to
+ * @param vOptions
+ * options to override defaults with
+ * @return
+ */
+ public NetworkConfig apply(Network networkToConnect, VCloudTemplateOptions vOptions) {
+ NetworkConfig config;
+ URI userDefinedParentNetwork = vOptions.getParentNetwork();
+ FenceMode fenceMode = vOptions.getFenceMode() != null ? vOptions.getFenceMode() : defaultFenceMode;
+ if (userDefinedParentNetwork != null) {
+ config = NetworkConfig.builder().networkName("jclouds").fenceMode(fenceMode)
+ .parentNetwork(userDefinedParentNetwork).build();
+ } else {
+ config = defaultNetworkConfig.get().toBuilder().fenceMode(fenceMode).build();
+ }
+
+ // if we only have a disconnected network, we are adding a new section
+ // for the upstream
+ if (InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.networkWithNoIpAllocation
+ .apply(networkToConnect)) {
+ // TODO: remove the disconnected entry
+ } else {
+ config = config.toBuilder().networkName(networkToConnect.getName()).build();
+ }
+ return config;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java
new file mode 100644
index 0000000..cd636df
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.strategy;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.contains;
+import static com.google.common.collect.Iterables.filter;
+
+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 javax.inject.Singleton;
+
+import org.jclouds.compute.ComputeServiceAdapter;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.domain.Location;
+import org.jclouds.logging.Logger;
+import org.jclouds.ovf.Envelope;
+import org.jclouds.util.Throwables2;
+import org.jclouds.vcloud.TaskInErrorStateException;
+import org.jclouds.vcloud.TaskStillRunningException;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.suppliers.VAppTemplatesSupplier;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
+/**
+ * defines the connection between the {@link org.jclouds.vcloud.VCloudApi} implementation and the jclouds
+ * {@link ComputeService}
+ */
+@Singleton
+public class VCloudComputeServiceAdapter implements ComputeServiceAdapter<VApp, VAppTemplate, VAppTemplate, Location> {
+
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ protected final VCloudApi client;
+ protected final Predicate<URI> successTester;
+ protected final InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn booter;
+ protected final Supplier<Map<String, Org>> nameToOrg;
+ protected final Supplier<Set<VAppTemplate>> templates;
+ protected final Function<VAppTemplate, Envelope> templateToEnvelope;
+
+ @Inject
+ protected VCloudComputeServiceAdapter(VCloudApi client, Predicate<URI> successTester,
+ InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn booter,
+ Supplier<Map<String, Org>> nameToOrg, VAppTemplatesSupplier templates,
+ Function<VAppTemplate, Envelope> templateToEnvelope) {
+ this.client = checkNotNull(client, "client");
+ this.successTester = checkNotNull(successTester, "successTester");
+ this.booter = checkNotNull(booter, "booter");
+ this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
+ this.templates = checkNotNull(templates, "templates");
+ this.templateToEnvelope = checkNotNull(templateToEnvelope, "templateToEnvelope");
+ }
+
+ @Override
+ public NodeAndInitialCredentials<VApp> createNodeWithGroupEncodedIntoName(String group, String name,
+ Template template) {
+ return booter.createNodeWithGroupEncodedIntoName(group, name, template);
+ }
+
+ @Override
+ public Iterable<VAppTemplate> listHardwareProfiles() {
+ return supportedTemplates();
+ }
+
+ private Iterable<VAppTemplate> supportedTemplates() {
+ return filter(templates.get(), new Predicate<VAppTemplate>() {
+
+ @Override
+ public boolean apply(VAppTemplate from) {
+ try {
+ templateToEnvelope.apply(from);
+ } catch (IllegalArgumentException e) {
+ logger.warn("Unsupported: " + e.getMessage());
+ return false;
+ } catch (RuntimeException e) {
+ IllegalArgumentException e2 = Throwables2.getFirstThrowableOfType(e, IllegalArgumentException.class);
+ if (e2 != null) {
+ logger.warn("Unsupported: " + e2.getMessage());
+ return false;
+ } else {
+ throw e;
+ }
+ }
+ return true;
+ }
+
+ });
+ }
+
+ @Override
+ public Iterable<VAppTemplate> listImages() {
+ return supportedTemplates();
+ }
+
+ @Override
+ public Iterable<VApp> listNodes() {
+ // TODO: parallel or cache
+ Builder<VApp> nodes = ImmutableSet.builder();
+ for (Org org : nameToOrg.get().values()) {
+ for (ReferenceType vdc : org.getVDCs().values()) {
+ for (ReferenceType resource : client.getVDCApi().getVDC(vdc.getHref()).getResourceEntities().values()) {
+ if (resource.getType().equals(VCloudMediaType.VAPP_XML)) {
+ addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource);
+ }
+ }
+ }
+ }
+ return nodes.build();
+ }
+
+ @Override
+ public Iterable<VApp> listNodesByIds(final Iterable<String> ids) {
+ return filter(listNodes(), new Predicate<VApp>() {
+
+ @Override
+ public boolean apply(VApp vm) {
+ return contains(ids, vm.getHref().toASCIIString());
+ }
+ });
+ }
+
+ @VisibleForTesting
+ void addVAppToSetRetryingIfNotYetPresent(Builder<VApp> nodes, ReferenceType vdc, ReferenceType resource) {
+ VApp node = null;
+ int i = 0;
+ while (node == null && i++ < 3) {
+ try {
+ node = client.getVAppApi().getVApp(resource.getHref());
+ nodes.add(node);
+ } catch (NullPointerException e) {
+ logger.warn("vApp %s not yet present in vdc %s", resource.getName(), vdc.getName());
+ }
+ }
+ }
+
+ @Override
+ public Iterable<Location> listLocations() {
+ // Not using the adapter to determine locations
+ return ImmutableSet.<Location>of();
+ }
+
+ @Override
+ public VApp getNode(String in) {
+ URI id = URI.create(in);
+ return client.getVAppApi().getVApp(id);
+ }
+
+ @Override
+ public VAppTemplate getImage(String in) {
+ URI id = URI.create(in);
+ return client.getVAppTemplateApi().getVAppTemplate(id);
+ }
+
+ @Override
+ public void destroyNode(String id) {
+ URI vappId = URI.create(checkNotNull(id, "node.id"));
+ VApp vApp = cancelAnyRunningTasks(vappId);
+ if (vApp.getStatus() != Status.OFF) {
+ logger.debug(">> powering off VApp vApp(%s), current status: %s", vApp.getName(), vApp.getStatus());
+ try {
+ waitForTask(client.getVAppApi().powerOffVApp(vApp.getHref()));
+ vApp = client.getVAppApi().getVApp(vApp.getHref());
+ logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
+ } catch (IllegalStateException e) {
+ logger.warn(e, "<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
+ }
+ logger.debug(">> undeploying vApp(%s), current status: %s", vApp.getName(), vApp.getStatus());
+ try {
+ waitForTask(client.getVAppApi().undeployVApp(vApp.getHref()));
+ vApp = client.getVAppApi().getVApp(vApp.getHref());
+ logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
+ } catch (IllegalStateException e) {
+ logger.warn(e, "<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
+ }
+ }
+ logger.debug(">> deleting vApp(%s)", vApp.getHref());
+ waitForTask(client.getVAppApi().deleteVApp(vApp.getHref()));
+ logger.debug("<< deleted vApp(%s)", vApp.getHref());
+ }
+
+ VApp waitForPendingTasksToComplete(URI vappId) {
+ VApp vApp = client.getVAppApi().getVApp(vappId);
+ if (vApp.getTasks().size() == 0)
+ return vApp;
+ for (Task task : vApp.getTasks())
+ waitForTask(task);
+ return client.getVAppApi().getVApp(vappId);
+ }
+
+ VApp cancelAnyRunningTasks(URI vappId) {
+ VApp vApp = client.getVAppApi().getVApp(vappId);
+ if (vApp.getTasks().size() == 0)
+ return vApp;
+ for (Task task : vApp.getTasks()) {
+ try {
+ client.getTaskApi().cancelTask(task.getHref());
+ waitForTask(task);
+ } catch (TaskInErrorStateException e) {
+ }
+ }
+ return client.getVAppApi().getVApp(vappId);
+
+ }
+
+ public void waitForTask(Task task) {
+ if (!successTester.apply(task.getHref()))
+ throw new TaskStillRunningException(task);
+ }
+
+ @Override
+ public void rebootNode(String in) {
+ URI id = URI.create(checkNotNull(in, "node.id"));
+ waitForTask(client.getVAppApi().resetVApp(id));
+ }
+
+ @Override
+ public void resumeNode(String in) {
+ URI id = URI.create(checkNotNull(in, "node.id"));
+ waitForTask(client.getVAppApi().powerOnVApp(id));
+ }
+
+ @Override
+ public void suspendNode(String in) {
+ URI id = URI.create(checkNotNull(in, "node.id"));
+ waitForTask(client.getVAppApi().powerOffVApp(id));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java
new file mode 100644
index 0000000..905565e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.compute.util;
+
+import static com.google.common.collect.Iterables.filter;
+
+import java.util.Set;
+
+import org.jclouds.cim.CIMPredicates;
+import org.jclouds.cim.ResourceAllocationSettingData;
+import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
+import org.jclouds.compute.domain.CIMOperatingSystem;
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.vcloud.domain.NetworkConnection;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+import com.google.common.collect.Iterables;
+
+public class VCloudComputeUtils {
+ public static OperatingSystem toComputeOs(VApp vApp, OperatingSystem defaultOs) {
+ CIMOperatingSystem cimOs = toComputeOs(vApp);
+ return cimOs != null ? cimOs : defaultOs;
+ }
+
+ public static CIMOperatingSystem toComputeOs(VApp vApp) {
+ // TODO we need to change the design so that it doesn't assume single-vms
+ return vApp.getChildren().size() > 0 ? toComputeOs(Iterables.get(vApp.getChildren(), 0)) : null;
+ }
+
+ public static CIMOperatingSystem toComputeOs(Vm vm) {
+ return CIMOperatingSystem.toComputeOs(vm.getOperatingSystemSection());
+ }
+
+ public static String getVirtualSystemIdentifierOfFirstVMIn(VApp vApp) {
+ return vApp.getChildren().size() > 0 ? getVirtualSystemIdentifierOf(Iterables.get(vApp.getChildren(), 0)) : null;
+ }
+
+ public static String getVirtualSystemIdentifierOf(Vm vm) {
+ if (vm.getVirtualHardwareSection() != null && vm.getVirtualHardwareSection().getSystem() != null)
+ return vm.getVirtualHardwareSection().getSystem().getVirtualSystemIdentifier();
+ return null;
+ }
+
+ public static LoginCredentials getCredentialsFrom(VApp vApp) {
+ return vApp.getChildren().size() > 0 ? getCredentialsFrom(Iterables.get(vApp.getChildren(), 0)) : null;
+ }
+
+ public static LoginCredentials getCredentialsFrom(VAppTemplate vApp) {
+ return vApp.getChildren().size() > 0 ? getCredentialsFrom(Iterables.get(vApp.getChildren(), 0)) : null;
+ }
+
+ public static LoginCredentials getCredentialsFrom(Vm vm) {
+ LoginCredentials.Builder builder = LoginCredentials.builder();
+ if (vm.getGuestCustomizationSection() != null)
+ builder.password(vm.getGuestCustomizationSection().getAdminPassword());
+ return builder.build();
+ }
+
+ public static Set<String> getIpsFromVApp(VApp vApp) {
+ // TODO make this work with composite vApps
+ if (vApp.getChildren().size() == 0)
+ return ImmutableSet.of();
+ Builder<String> ips = ImmutableSet.builder();
+ Vm vm = Iterables.get(vApp.getChildren(), 0);
+ // TODO: figure out how to differentiate public from private ip addresses
+ // assumption is that we'll do this from the network object, which may
+ // have
+ // enough data to tell whether or not it is a public network without
+ // string
+ // parsing. At worst, we could have properties set per cloud provider to
+ // declare the networks which are public, then check against these in
+ // networkconnection.getNetwork
+ if (vm.getNetworkConnectionSection() != null) {
+ for (NetworkConnection connection : vm.getNetworkConnectionSection().getConnections()) {
+ if (connection.getIpAddress() != null)
+ ips.add(connection.getIpAddress());
+ if (connection.getExternalIpAddress() != null)
+ ips.add(connection.getExternalIpAddress());
+ }
+ } else {
+ for (ResourceAllocationSettingData net : filter(vm.getVirtualHardwareSection().getItems(),
+ CIMPredicates.resourceTypeIn(ResourceType.ETHERNET_ADAPTER))) {
+ if (net instanceof VCloudNetworkAdapter) {
+ VCloudNetworkAdapter vNet = VCloudNetworkAdapter.class.cast(net);
+ if (vNet.getIpAddress() != null)
+ ips.add(vNet.getIpAddress());
+ }
+ }
+ }
+ return ips.build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java
new file mode 100644
index 0000000..eb700f3
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.config;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.config.ValueOfConfigurationKeyOrNull;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.Catalog;
+import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+
+@Singleton
+public class DefaultCatalogForOrg implements Function<ReferenceType, ReferenceType> {
+ private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
+ private final Supplier<Map<String, Org>> nameToOrg;
+
+ @Inject
+ public DefaultCatalogForOrg(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull,
+ @Catalog Predicate<ReferenceType> defaultSelector, Supplier<Map<String, Org>> nameToOrg) {
+ this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull(
+ valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_CATALOG,
+ checkNotNull(defaultSelector, "defaultSelector"));
+ this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
+ }
+
+ @Override
+ public ReferenceType apply(ReferenceType defaultOrg) {
+ Org org = nameToOrg.get().get(defaultOrg.getName());
+ checkState(org != null, "could not retrieve Org at %s", defaultOrg);
+ return selector.apply(org.getCatalogs().values());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java
new file mode 100644
index 0000000..e336b95
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.config;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
+
+import java.net.URI;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.config.ValueOfConfigurationKeyOrNull;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.endpoints.Network;
+import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+
+@Singleton
+public class DefaultNetworkForVDC implements Function<ReferenceType, ReferenceType> {
+
+ private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
+ private final Supplier<Map<URI, VDC>> uriToVDC;
+
+ @Inject
+ public DefaultNetworkForVDC(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull,
+ @Network Predicate<ReferenceType> defaultSelector, Supplier<Map<URI, VDC>> uriToVDC) {
+ this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull(
+ valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_NETWORK,
+ checkNotNull(defaultSelector, "defaultSelector"));
+ this.uriToVDC = checkNotNull(uriToVDC, "uriToVDC");
+ }
+
+ @Override
+ public ReferenceType apply(ReferenceType defaultVDC) {
+ org.jclouds.vcloud.domain.VDC vDC = uriToVDC.get().get(defaultVDC.getHref());
+ checkState(vDC != null, "could not retrieve VDC at %s", defaultVDC);
+ return selector.apply(vDC.getAvailableNetworks().values());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java
new file mode 100644
index 0000000..8ed2eba
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.config;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.config.ValueOfConfigurationKeyOrNull;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VCloudSession;
+import org.jclouds.vcloud.endpoints.Org;
+import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+
+@Singleton
+public class DefaultOrgForUser implements Supplier<ReferenceType> {
+
+ private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
+ private final Supplier<VCloudSession> session;
+
+ @Inject
+ public DefaultOrgForUser(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull,
+ @Org Predicate<ReferenceType> defaultSelector, Supplier<VCloudSession> session) {
+ this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull(
+ valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_ORG, checkNotNull(
+ defaultSelector, "defaultSelector"));
+ this.session = checkNotNull(session, "session");
+ }
+
+ @Override
+ public ReferenceType get() {
+ return selector.apply(session.get().getOrgs().values());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java
new file mode 100644
index 0000000..c670161
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.config;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+
+@Singleton
+public class DefaultTasksListForOrg implements Function<ReferenceType, ReferenceType> {
+ private final Supplier<Map<String, Org>> nameToOrg;
+
+ @Inject
+ public DefaultTasksListForOrg(Supplier<Map<String, Org>> nameToOrg) {
+ this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
+ }
+
+ @Override
+ public ReferenceType apply(ReferenceType defaultOrg) {
+ org.jclouds.vcloud.domain.Org org = nameToOrg.get().get(defaultOrg.getName());
+ checkState(org != null, "could not retrieve Org at %s", defaultOrg);
+ return org.getTasksList();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java
new file mode 100644
index 0000000..5a0ba9d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.config;
+
+import java.net.URI;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.Org;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.inject.AbstractModule;
+import com.google.inject.Injector;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+
+public class DefaultVCloudReferencesModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(new TypeLiteral<Supplier<ReferenceType>>() {
+ }).annotatedWith(Org.class).to(DefaultOrgForUser.class);
+ }
+
+ @Provides
+ @Singleton
+ @org.jclouds.vcloud.endpoints.Org
+ protected Predicate<ReferenceType> provideDefaultOrgSelector(Injector i) {
+ return Predicates.alwaysTrue();
+ }
+
+ @Provides
+ @org.jclouds.vcloud.endpoints.TasksList
+ @Singleton
+ protected Supplier<ReferenceType> provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg,
+ @org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg) {
+ return Suppliers.compose(defaultTasksListURIForOrg, defaultOrg);
+ }
+
+ @Provides
+ @org.jclouds.vcloud.endpoints.Catalog
+ @Singleton
+ protected Supplier<ReferenceType> provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg,
+ @org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg) {
+ return Suppliers.compose(defaultCatalogURIForOrg, defaultOrg);
+ }
+
+ @Provides
+ @Singleton
+ @org.jclouds.vcloud.endpoints.Catalog
+ protected Predicate<ReferenceType> provideDefaultCatalogSelector(Injector i) {
+ return i.getInstance(WriteableCatalog.class);
+ }
+
+ @Provides
+ @Singleton
+ protected Supplier<Map<URI, org.jclouds.vcloud.domain.Catalog>> provideCatalogsById(
+ Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> supplier) {
+ return Suppliers
+ .compose(
+ new Function<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>, Map<URI, org.jclouds.vcloud.domain.Catalog>>() {
+
+ @Override
+ public Map<URI, Catalog> apply(Map<String, Map<String, Catalog>> arg0) {
+ Builder<URI, Catalog> builder = ImmutableMap.builder();
+ for (Map<String, Catalog> v1 : arg0.values()) {
+ for (Catalog v2 : v1.values()) {
+ builder.put(v2.getHref(), v2);
+ }
+ }
+ return builder.build();
+ }
+
+ }, supplier);
+ }
+
+ @Singleton
+ public static class WriteableCatalog implements Predicate<ReferenceType> {
+
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ private final Supplier<Map<URI, org.jclouds.vcloud.domain.Catalog>> catalogsByIdSupplier;
+
+ @Inject
+ public WriteableCatalog(Supplier<Map<URI, org.jclouds.vcloud.domain.Catalog>> catalogsByIdSupplier) {
+ this.catalogsByIdSupplier = catalogsByIdSupplier;
+ }
+
+ @Override
+ public boolean apply(ReferenceType arg0) {
+ // TODO: this is inefficient, calculating the index each time, but
+ // shouldn't be added to constructor as the supplier is an expensive
+ // call
+ Map<URI, Catalog> index = catalogsByIdSupplier.get();
+ Catalog catalog = index.get(arg0.getHref());
+ if (catalog == null) {
+ if (logger.isTraceEnabled())
+ logger.trace("didn't find catalog %s", arg0);
+ return false;
+ } else
+ return !catalog.isReadOnly();
+ }
+ }
+
+ @Provides
+ @org.jclouds.vcloud.endpoints.VDC
+ @Singleton
+ protected Supplier<ReferenceType> provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg,
+ @org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg) {
+ return Suppliers.compose(defaultVDCURIForOrg, defaultOrg);
+ }
+
+ @Provides
+ @Singleton
+ @org.jclouds.vcloud.endpoints.VDC
+ protected Predicate<ReferenceType> provideDefaultVDCSelector(Injector i) {
+ return Predicates.alwaysTrue();
+ }
+
+ @Provides
+ @org.jclouds.vcloud.endpoints.Network
+ @Singleton
+ protected Supplier<ReferenceType> provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC,
+ @org.jclouds.vcloud.endpoints.VDC Supplier<ReferenceType> defaultVDC) {
+ return Suppliers.compose(defaultNetworkURIForVDC, defaultVDC);
+ }
+
+ @Provides
+ @Singleton
+ @org.jclouds.vcloud.endpoints.Network
+ protected Predicate<ReferenceType> provideDefaultNetworkSelector(Injector i) {
+ return Predicates.alwaysTrue();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java
new file mode 100644
index 0000000..4eefd30
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.config;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.config.ValueOfConfigurationKeyOrNull;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.VDC;
+import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+
+@Singleton
+public class DefaultVDCForOrg implements Function<ReferenceType, ReferenceType> {
+ private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
+ private final Supplier<Map<String, Org>> nameToOrg;
+
+ @Inject
+ public DefaultVDCForOrg(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull,
+ @VDC Predicate<ReferenceType> defaultSelector, Supplier<Map<String, Org>> nameToOrg) {
+ this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull(
+ valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_VDC,
+ checkNotNull(defaultSelector, "defaultSelector"));
+ this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
+ }
+
+ @Override
+ public ReferenceType apply(ReferenceType defaultOrg) {
+ Org org = nameToOrg.get().get(defaultOrg.getName());
+ checkState(org != null, "could not retrieve Org at %s", defaultOrg);
+ return selector.apply(org.getVDCs().values());
+ }
+
+}
[28/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/NeutronApiMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/NeutronApiMetadata.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/NeutronApiMetadata.java
new file mode 100644
index 0000000..6327f1e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/NeutronApiMetadata.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0;
+
+import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
+import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule;
+import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule;
+import org.jclouds.openstack.neutron.v2_0.config.NeutronHttpApiModule;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+
+/**
+ * Implementation of {@link org.jclouds.apis.ApiMetadata} for Neutron 2.0 API
+ */
+@Deprecated
+public class NeutronApiMetadata extends BaseHttpApiMetadata<NeutronApi> {
+
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
+ }
+
+ public NeutronApiMetadata() {
+ this(new Builder());
+ }
+
+ protected NeutronApiMetadata(Builder builder) {
+ super(builder);
+ }
+
+ public static Properties defaultProperties() {
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
+ properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS);
+ properties.setProperty(SERVICE_TYPE, ServiceType.NETWORK);
+ return properties;
+ }
+
+ public static class Builder extends BaseHttpApiMetadata.Builder<NeutronApi, Builder> {
+
+ protected Builder() {
+ super(NeutronApi.class);
+ id("openstack-neutron-legacy")
+ .name("OpenStack Neutron API")
+ .identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant")
+ .credentialName("${password}")
+ .endpointName("KeyStone base url ending in /v2.0/")
+ .documentation(URI.create("http://docs.openstack.org/api/openstack-network/2.0/content/"))
+ .version("2.0")
+ .defaultEndpoint("http://localhost:5000/v2.0/")
+ .defaultProperties(NeutronApiMetadata.defaultProperties())
+ .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
+ .add(AuthenticationApiModule.class)
+ .add(KeystoneAuthenticationModule.class)
+ .add(ZoneModule.class)
+ .add(NeutronHttpApiModule.class).build());
+ }
+
+ @Override
+ public NeutronApiMetadata build() {
+ return new NeutronApiMetadata(this);
+ }
+
+ @Override
+ public Builder fromApiMetadata(ApiMetadata in) {
+ super.fromApiMetadata(in);
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/config/NeutronHttpApiModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/config/NeutronHttpApiModule.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/config/NeutronHttpApiModule.java
new file mode 100644
index 0000000..fe3d74c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/config/NeutronHttpApiModule.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.config;
+
+import java.net.URI;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+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.json.config.GsonModule.DateAdapter;
+import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
+import org.jclouds.openstack.neutron.v2_0.NeutronApi;
+import org.jclouds.openstack.neutron.v2_0.handlers.NeutronErrorHandler;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.openstack.v2_0.functions.PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet;
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.jclouds.rest.config.HttpApiModule;
+import org.jclouds.rest.functions.ImplicitOptionalConverter;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.Multimap;
+import com.google.inject.Provides;
+
+/**
+ * Configures the Neutron connection.
+ */
+@ConfiguresHttpApi
+public class NeutronHttpApiModule extends HttpApiModule<NeutronApi> {
+
+ @Override
+ protected void configure() {
+ bind(DateAdapter.class).to(Iso8601DateAdapter.class);
+ bind(ImplicitOptionalConverter.class).to(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class);
+ super.configure();
+ }
+
+ @Provides
+ @Singleton
+ public Multimap<URI, URI> aliases() {
+ return ImmutableMultimap.<URI, URI>builder()
+ .build();
+ }
+
+ @Provides
+ @Singleton
+ public LoadingCache<String, Set<? extends Extension>> provideExtensionsByZone(final Provider<NeutronApi> quantumApi) {
+ return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
+ .build(new CacheLoader<String, Set<? extends Extension>>() {
+ @Override
+ public Set<? extends Extension> load(String key) throws Exception {
+ return quantumApi.get().getExtensionApiForZone(key).list();
+ }
+ });
+ }
+
+ @Override
+ protected void bindErrorHandlers() {
+ bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(NeutronErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(NeutronErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(NeutronErrorHandler.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/AllocationPool.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/AllocationPool.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/AllocationPool.java
new file mode 100644
index 0000000..6e1ff7f
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/AllocationPool.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import java.beans.ConstructorProperties;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * A Neutron Subnet Allocation Pool
+ *
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api doc</a>
+ */
+public class AllocationPool {
+
+ private final String start;
+ private final String end;
+
+ @ConstructorProperties({
+ "start", "end"
+ })
+ protected AllocationPool(String start, String end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ /**
+ * @return the start ip
+ */
+ public String getStart() {
+ return start;
+ }
+
+ /**
+ * @return the end ip
+ */
+ public String getEnd() {
+ return end;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(start, end);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ AllocationPool that = AllocationPool.class.cast(obj);
+ return Objects.equal(this.start, that.start) && Objects.equal(this.end, that.end);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this).add("start", start).add("end", end);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder toBuilder() {
+ return new ConcreteBuilder().fromAllocationPool(this);
+ }
+
+ public abstract static class Builder {
+ protected abstract Builder self();
+
+ protected String start;
+ protected String end;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.AllocationPool#getStart()
+ */
+ public Builder start(String start) {
+ this.start = start;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.AllocationPool#getEnd()
+ */
+ public Builder end(String end) {
+ this.end = end;
+ return self();
+ }
+
+ public AllocationPool build() {
+ return new AllocationPool(start, end);
+ }
+
+ public Builder fromAllocationPool(AllocationPool in) {
+ return this.start(in.getStart()).end(in.getEnd());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/BulkNetwork.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/BulkNetwork.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/BulkNetwork.java
new file mode 100644
index 0000000..f2e4a0e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/BulkNetwork.java
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import com.google.common.base.Objects;
+
+import java.beans.ConstructorProperties;
+
+/**
+ * A Neutron network used for creating networks in bulk
+ * The only difference between this and the actual network are the missing fields id, tenantId, state & shared
+ */
+public class BulkNetwork {
+
+ private final String name;
+ private final Boolean adminStateUp;
+ private final Boolean external;
+ private final NetworkType networkType;
+ private final String physicalNetworkName;
+ private final Integer segmentationId;
+
+ @ConstructorProperties({
+ "name", "admin_state_up", "router:external", "provider:network_type", "provider:physical_network", "provider:segmentation_id"
+ })
+ protected BulkNetwork(String name, Boolean adminStateUp, Boolean external, String networkType, String physicalNetworkName, Integer segmentationId) {
+ this.name = name;
+ this.adminStateUp = adminStateUp;
+ this.external = external;
+ this.networkType = NetworkType.fromValue(networkType);
+ this.physicalNetworkName = physicalNetworkName;
+ this.segmentationId = segmentationId;
+ }
+
+ /**
+ * @return the name of the network
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the administrative state of network. If false, the network does not forward packets.
+ */
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return true if network is external, false if not
+ */
+ public Boolean getExternal() {
+ return external;
+ }
+
+ /**
+ * @return the type of network
+ */
+ public NetworkType getNetworkType() {
+ return networkType;
+ }
+
+ /**
+ * @return the physical network name
+ */
+ public String getPhysicalNetworkName() {
+ return physicalNetworkName;
+ }
+
+ /**
+ * @return the segmentation id of the network
+ */
+ public Integer getSegmentationId() {
+ return segmentationId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, adminStateUp, external, networkType, physicalNetworkName, segmentationId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ BulkNetwork that = BulkNetwork.class.cast(obj);
+ return Objects.equal(this.name, that.name)
+ && Objects.equal(this.adminStateUp, that.adminStateUp)
+ && Objects.equal(this.external, that.external)
+ && Objects.equal(this.networkType, that.networkType)
+ && Objects.equal(this.physicalNetworkName, that.physicalNetworkName)
+ && Objects.equal(this.segmentationId, that.segmentationId);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("name", name).add("adminStateUp", adminStateUp).add("external", external)
+ .add("networkType", networkType).add("physicalNetworkName", physicalNetworkName)
+ .add("segmentationId", segmentationId);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder toBuilder() {
+ return new ConcreteBuilder().fromBulkNetwork(this);
+ }
+
+ public abstract static class Builder {
+ protected abstract Builder self();
+
+ protected String name;
+ protected Boolean adminStateUp;
+ protected Boolean external;
+ protected NetworkType networkType;
+ protected String physcialNetworkName;
+ protected Integer segmentationId;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkNetwork#getName()
+ */
+ public Builder name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkNetwork#getAdminStateUp()
+ */
+ public Builder adminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkNetwork#getExternal()
+ */
+ public Builder external(Boolean external) {
+ this.external = external;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkNetwork#getNetworkType()
+ */
+ public Builder networkType(NetworkType networkType) {
+ this.networkType = networkType;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkNetwork#getPhysicalNetworkName()
+ */
+ public Builder physicalNetworkName(String physicalNetworkName) {
+ this.physcialNetworkName = physicalNetworkName;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkNetwork#getSegmentationId()
+ */
+ public Builder segmentationId(Integer segmentationId) {
+ this.segmentationId = segmentationId;
+ return self();
+ }
+
+ public BulkNetwork build() {
+ return new BulkNetwork(name, adminStateUp, external, networkType == null ? null : networkType.getValue(), physcialNetworkName, segmentationId);
+ }
+
+ public Builder fromBulkNetwork(BulkNetwork in) {
+ return this.name(in.getName())
+ .adminStateUp(in.getAdminStateUp())
+ .external(in.getExternal())
+ .networkType(in.getNetworkType())
+ .physicalNetworkName(in.getPhysicalNetworkName())
+ .segmentationId(in.getSegmentationId());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/BulkPort.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/BulkPort.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/BulkPort.java
new file mode 100644
index 0000000..91c2637
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/BulkPort.java
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+
+import java.beans.ConstructorProperties;
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * A Neutron port used for creating ports in bulk
+ * The only difference between this and the actual port are the missing fields id, tenantId & state
+ */
+public class BulkPort {
+
+ private final String name;
+ private final String networkId;
+ private final Boolean adminStateUp;
+ private final String deviceId;
+ private final String deviceOwner;
+ private final Set<IP> fixedIps;
+ private final String macAddress;
+
+ @ConstructorProperties({
+ "name", "network_id", "admin_state_up", "device_id", "device_owner", "fixed_ips", "mac_address"
+ })
+ protected BulkPort(String name, String networkId, Boolean adminStateUp, String deviceId, String deviceOwner, Set<IP> fixedIps, String macAddress) {
+ this.name = name;
+ this.networkId = networkId;
+ this.adminStateUp = adminStateUp;
+ this.deviceId = deviceId;
+ this.deviceOwner = deviceOwner;
+ this.fixedIps = fixedIps != null ? ImmutableSet.copyOf(fixedIps) : ImmutableSet.<IP>of();
+ this.macAddress = macAddress;
+ }
+
+ /**
+ * @return the name of the port
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the id of the network where this port is associated with
+ */
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ /**
+ * @return the administrative state of port. If false, port does not forward packets
+ */
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the id of the device (e.g. server) using this port.
+ */
+ public String getDeviceId() {
+ return deviceId;
+ }
+
+ /**
+ * @return the entity (e.g.: dhcp agent) using this port.
+ */
+ public String getDeviceOwner() {
+ return deviceOwner;
+ }
+
+ /**
+ * @return the set of fixed ips this port has been assigned
+ */
+ public Set<IP> getFixedIps() {
+ return fixedIps;
+ }
+
+ /**
+ * @return the mac address of this port
+ */
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, networkId, adminStateUp, deviceId, deviceOwner, fixedIps, macAddress);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ BulkPort that = BulkPort.class.cast(obj);
+ return Objects.equal(this.name, that.name)
+ && Objects.equal(this.networkId, that.networkId)
+ && Objects.equal(this.adminStateUp, that.adminStateUp)
+ && Objects.equal(this.deviceId, that.deviceId)
+ && Objects.equal(this.deviceOwner, that.deviceOwner)
+ && Objects.equal(this.fixedIps, that.fixedIps)
+ && Objects.equal(this.macAddress, that.macAddress);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("name", name).add("networkId", networkId).add("adminStateUp", adminStateUp)
+ .add("deviceId", deviceId).add("deviceOwner", deviceOwner).add("fixedIps", fixedIps).add("macAddress", macAddress);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder toBuilder() {
+ return new ConcreteBuilder().fromBulkPort(this);
+ }
+
+ public abstract static class Builder {
+ protected abstract Builder self();
+
+ protected String name;
+ protected String networkId;
+ protected String deviceId;
+ protected String deviceOwner;
+ protected String macAddress;
+ protected Set<IP> fixedIps;
+ protected Boolean adminStateUp;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkPort#getName()
+ */
+ public Builder name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkPort#getNetworkId()
+ */
+ public Builder networkId(String networkId) {
+ this.networkId = networkId;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkPort#getDeviceId()
+ */
+ public Builder deviceId(String deviceId) {
+ this.deviceId = deviceId;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkPort#getDeviceOwner()
+ */
+ public Builder deviceOwner(String deviceOwner) {
+ this.deviceOwner = deviceOwner;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkPort#getMacAddress()
+ */
+ public Builder macAddress(String macAddress) {
+ this.macAddress = macAddress;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkPort#getFixedIps()
+ */
+ public Builder fixedIps(Collection<IP> fixedIps) {
+ this.fixedIps = ImmutableSet.copyOf(fixedIps);
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkPort#getAdminStateUp()
+ */
+ public Builder adminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ public BulkPort build() {
+ return new BulkPort(name, networkId, adminStateUp, deviceId, deviceOwner, fixedIps, macAddress);
+ }
+
+ public Builder fromBulkPort(BulkPort in) {
+ return this.name(in.getName())
+ .networkId(in.getNetworkId())
+ .adminStateUp(in.getAdminStateUp())
+ .deviceId(in.getDeviceId())
+ .deviceOwner(in.getDeviceOwner())
+ .fixedIps(in.getFixedIps())
+ .macAddress(in.getMacAddress());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/BulkSubnet.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/BulkSubnet.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/BulkSubnet.java
new file mode 100644
index 0000000..c1eea45
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/BulkSubnet.java
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+
+import java.beans.ConstructorProperties;
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * A Neutron subnet used for creating subnets in bulk
+ * The only difference between this and the actual subnet are the missing fields id & tenantId
+ */
+public class BulkSubnet {
+
+ protected String name;
+ protected String networkId;
+ protected String gatewayIp;
+ protected Integer ipVersion;
+ protected String cidr;
+ protected Set<AllocationPool> allocationPools;
+ protected Boolean enableDhcp;
+ protected Set<String> dnsNameServers;
+ protected Set<HostRoute> hostRoutes;
+
+ @ConstructorProperties({
+ "name", "network_id", "gateway_ip", "ip_version", "cidr", "allocation_pools", "enable_dhcp", "dns_nameservers", "host_routes"
+ })
+ protected BulkSubnet(String name, String networkId, String gatewayIp, Integer ipVersion, String cidr,
+ Set<AllocationPool> allocationPools, Boolean enableDhcp, Set<String> dnsNameServers, Set<HostRoute> hostRoutes) {
+ this.name = name;
+ this.networkId = networkId;
+ this.gatewayIp = gatewayIp;
+ this.ipVersion = ipVersion;
+ this.cidr = cidr;
+ this.allocationPools = allocationPools != null ? ImmutableSet.copyOf(allocationPools) : ImmutableSet.<AllocationPool>of();
+ this.enableDhcp = enableDhcp;
+ this.dnsNameServers = dnsNameServers != null ? ImmutableSet.copyOf(dnsNameServers) : ImmutableSet.<String>of();
+ this.hostRoutes = hostRoutes != null ? ImmutableSet.copyOf(hostRoutes) : ImmutableSet.<HostRoute>of();
+ }
+
+ /**
+ * @return the name of the subnet
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the id of the network this subnet is associated with
+ */
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ /**
+ * @return the default gateway used by devices in this subnet
+ */
+ public String getGatewayIp() {
+ return gatewayIp;
+ }
+
+ /**
+ * @return the ip version used by this subnet
+ */
+ public Integer getIpVersion() {
+ return ipVersion;
+ }
+
+ /**
+ * @return the cidr representing the IP range for this subnet, based on IP version
+ */
+ public String getCidr() {
+ return cidr;
+ }
+
+ /**
+ * @return the sub-ranges of cidr available for dynamic allocation to ports
+ */
+ public Set<AllocationPool> getAllocationPools() {
+ return allocationPools;
+ }
+
+ /**
+ * @return true if DHCP is enabled for this subnet, false if not.
+ */
+ public Boolean getEnableDhcp() {
+ return enableDhcp;
+ }
+
+ /**
+ * @return the set of DNS name servers used by hosts in this subnet.
+ */
+ public Set<String> getDnsNameServers() {
+ return dnsNameServers;
+ }
+
+ /**
+ * @return the set of routes that should be used by devices with IPs from this subnet
+ */
+ public Set<HostRoute> getHostRoutes() {
+ return hostRoutes;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, networkId, gatewayIp, ipVersion, cidr,
+ allocationPools, enableDhcp, dnsNameServers, hostRoutes);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ BulkSubnet that = BulkSubnet.class.cast(obj);
+ return Objects.equal(this.name, that.name)
+ && Objects.equal(this.networkId, that.networkId)
+ && Objects.equal(this.gatewayIp, that.gatewayIp)
+ && Objects.equal(this.ipVersion, that.ipVersion)
+ && Objects.equal(this.cidr, that.cidr)
+ && Objects.equal(this.allocationPools, that.allocationPools)
+ && Objects.equal(this.enableDhcp, that.enableDhcp)
+ && Objects.equal(this.dnsNameServers, that.dnsNameServers)
+ && Objects.equal(this.hostRoutes, that.hostRoutes);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("name", name).add("networkId", networkId).add("gatewayIp", gatewayIp).add("ipVersion", ipVersion)
+ .add("cidr", cidr).add("enableDhcp", enableDhcp).add("allocationPools", allocationPools)
+ .add("dnsNameServers", dnsNameServers).add("hostRoutes", hostRoutes);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder toBuilder() {
+ return new ConcreteBuilder().fromBulkSubnet(this);
+ }
+
+ public abstract static class Builder {
+ protected abstract Builder self();
+
+ protected String name;
+ protected String networkId;
+ protected String gatewayIp;
+ protected Integer ipVersion;
+ protected String cidr;
+ protected Set<AllocationPool> allocationPools;
+ protected Boolean enableDhcp;
+ protected Set<String> dnsNameServers;
+ protected Set<HostRoute> hostRoutes;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet#getName()
+ */
+ public Builder name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet#getNetworkId()
+ */
+ public Builder networkId(String networkId) {
+ this.networkId = networkId;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet#getGatewayIp()
+ */
+ public Builder gatewayIp(String gatewayIp) {
+ this.gatewayIp = gatewayIp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet#getIpVersion()
+ */
+ public Builder ipVersion(Integer ipVersion) {
+ this.ipVersion = ipVersion;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet#getCidr()
+ */
+ public Builder cidr(String cidr) {
+ this.cidr = cidr;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet#getAllocationPools()
+ */
+ public Builder allocationPools(Collection<AllocationPool> allocationPools) {
+ this.allocationPools = ImmutableSet.copyOf(allocationPools);
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet#getEnableDhcp()
+ */
+ public Builder enableDhcp(Boolean enableDhcp) {
+ this.enableDhcp = enableDhcp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet#getDnsNameServers()
+ */
+ public Builder dnsNameServers(Collection<String> dnsNameServers) {
+ this.dnsNameServers = ImmutableSet.copyOf(dnsNameServers);
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet#getHostRoutes()
+ */
+ public Builder hostRoutes(Collection<HostRoute> hostRoutes) {
+ this.hostRoutes = ImmutableSet.copyOf(hostRoutes);
+ return self();
+ }
+
+ public BulkSubnet build() {
+ return new BulkSubnet(name, networkId, gatewayIp, ipVersion, cidr, allocationPools, enableDhcp, dnsNameServers, hostRoutes);
+ }
+
+ public Builder fromBulkSubnet(BulkSubnet in) {
+ return this.name(in.getName())
+ .networkId(in.getNetworkId())
+ .gatewayIp(in.getGatewayIp())
+ .ipVersion(in.getIpVersion())
+ .cidr(in.getCidr())
+ .allocationPools(in.getAllocationPools())
+ .enableDhcp(in.getEnableDhcp())
+ .dnsNameServers(in.getDnsNameServers())
+ .hostRoutes(in.getHostRoutes());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/ExternalGatewayInfo.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/ExternalGatewayInfo.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/ExternalGatewayInfo.java
new file mode 100644
index 0000000..f5473ed
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/ExternalGatewayInfo.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import com.google.common.base.Objects;
+
+import java.beans.ConstructorProperties;
+
+/**
+ * Information on external gateway for the router
+ */
+public class ExternalGatewayInfo {
+
+ private final String networkId;
+
+ @ConstructorProperties({"network_id"})
+ protected ExternalGatewayInfo(String networkId) {
+ this.networkId = networkId;
+ }
+
+ /**
+ * @return the id of the network which is used as external gateway for the router
+ */
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(networkId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ ExternalGatewayInfo that = ExternalGatewayInfo.class.cast(obj);
+ return Objects.equal(this.networkId, that.networkId);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this).add("networkId", networkId);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder toBuilder() {
+ return new ConcreteBuilder().fromExternalGatewayInfo(this);
+ }
+
+ public abstract static class Builder {
+ protected abstract Builder self();
+
+ protected String networkId;
+
+ /**
+ * @see ExternalGatewayInfo#getNetworkId()
+ */
+ public Builder networkId(String networkId) {
+ this.networkId = networkId;
+ return self();
+ }
+
+ public ExternalGatewayInfo build() {
+ return new ExternalGatewayInfo(networkId);
+ }
+
+ public Builder fromExternalGatewayInfo(ExternalGatewayInfo in) {
+ return this.networkId(in.getNetworkId());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/HostRoute.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/HostRoute.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/HostRoute.java
new file mode 100644
index 0000000..42c2a40
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/HostRoute.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import java.beans.ConstructorProperties;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * A Neutron Subnet Host Route
+ *
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api doc</a>
+ */
+public class HostRoute {
+
+ private final String destinationCidr;
+ private final String nextHop;
+
+ @ConstructorProperties({
+ "destination", "nexthop"
+ })
+ protected HostRoute(String destinationCidr, String nextHop) {
+ this.destinationCidr = destinationCidr;
+ this.nextHop = nextHop;
+ }
+
+ /**
+ * @return the destination cidr for this route
+ */
+ public String getDestinationCidr() {
+ return destinationCidr;
+ }
+
+ /**
+ * @return the ip of the next hop to forward traffic to
+ */
+ public String getNextHop() {
+ return nextHop;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(destinationCidr, nextHop);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ HostRoute that = HostRoute.class.cast(obj);
+ return Objects.equal(this.destinationCidr, that.destinationCidr) && Objects.equal(this.nextHop, that.nextHop);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("destinationCidr", destinationCidr).add("nextHop", nextHop);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder toBuilder() {
+ return new ConcreteBuilder().fromHostRoute(this);
+ }
+
+ public abstract static class Builder {
+ protected abstract Builder self();
+
+ protected String destinationCidr;
+ protected String nextHop;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.HostRoute#getDestinationCidr()
+ */
+ public Builder destinationCidr(String destinationCidr) {
+ this.destinationCidr = destinationCidr;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.HostRoute#getNextHop()
+ */
+ public Builder nextHop(String nextHop) {
+ this.nextHop = nextHop;
+ return self();
+ }
+
+ public HostRoute build() {
+ return new HostRoute(destinationCidr, nextHop);
+ }
+
+ public Builder fromHostRoute(HostRoute in) {
+ return this.destinationCidr(in.getDestinationCidr()).nextHop(in.getNextHop());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/IP.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/IP.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/IP.java
new file mode 100644
index 0000000..689a53e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/IP.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import com.google.common.base.Objects;
+
+import java.beans.ConstructorProperties;
+
+public class IP {
+
+ private String ipAddress;
+ private String subnetId;
+
+ @ConstructorProperties({
+ "ip_address", "subnet_id"
+ })
+ protected IP(String ipAddress, String subnetId) {
+ this.ipAddress = ipAddress;
+ this.subnetId = subnetId;
+ }
+
+ /**
+ * @return the fixed ip address
+ */
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ /**
+ * @return the id of the subnet of this ip
+ */
+ public String getSubnetId() {
+ return subnetId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(ipAddress, subnetId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ IP that = IP.class.cast(obj);
+ return Objects.equal(this.ipAddress, that.ipAddress) && Objects.equal(this.subnetId, that.subnetId);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("ipAddress", ipAddress).add("subnetId", subnetId);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder toBuilder() {
+ return new ConcreteBuilder().fromIP(this);
+ }
+
+ public abstract static class Builder {
+ protected abstract Builder self();
+
+ protected String ipAddress;
+ protected String subnetId;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.IP#getIpAddress
+ */
+ public Builder ipAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.IP#getSubnetId
+ */
+ public Builder subnetId(String subnetId) {
+ this.subnetId = subnetId;
+ return self();
+ }
+
+ public IP build() {
+ return new IP(ipAddress, subnetId);
+ }
+
+ public Builder fromIP(IP in) {
+ return this.ipAddress(in.getIpAddress()).subnetId(in.getSubnetId());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Network.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Network.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Network.java
new file mode 100644
index 0000000..3aa1804
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Network.java
@@ -0,0 +1,255 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+
+import java.beans.ConstructorProperties;
+import java.util.Set;
+
+/**
+ * A Neutron network
+ *
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/Networks.html">api doc</a>
+ */
+public class Network extends ReferenceWithName {
+
+ private final State state;
+ private final Set<String> subnets;
+ private final Boolean adminStateUp;
+ private final Boolean shared;
+ private final Boolean external;
+ private final NetworkType networkType;
+ private final String physicalNetworkName;
+ private final Integer segmentationId;
+
+ @ConstructorProperties({
+ "id", "tenant_id", "name", "status", "subnets", "admin_state_up", "shared", "router:external",
+ "provider:network_type", "provider:physical_network", "provider:segmentation_id"
+ })
+ protected Network(String id, String tenantId, String name, State state,
+ Set<String> subnets, Boolean adminStateUp, Boolean shared, Boolean external,
+ String networkType, String physicalNetworkName, Integer segmentationId) {
+ super(id, tenantId, name);
+ this.state = state;
+ this.subnets = subnets != null ? ImmutableSet.copyOf(subnets) : ImmutableSet.<String>of();
+ this.adminStateUp = adminStateUp;
+ this.shared = shared;
+ this.external = external;
+ this.networkType = networkType != null ? NetworkType.fromValue(networkType) : null;
+ this.physicalNetworkName = physicalNetworkName;
+ this.segmentationId = segmentationId;
+ }
+
+ /**
+ * @return the current state of the network
+ */
+ public State getState() {
+ return state;
+ }
+
+ /**
+ * @return set of subnet ids that are associated with this network
+ */
+ public Set<String> getSubnets() {
+ return subnets;
+ }
+
+ /**
+ * @return the administrative state of network. If false, the network does not forward packets.
+ */
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return true if the network resource can be accessed by any tenant or not, false if not
+ */
+ public Boolean getShared() {
+ return shared;
+ }
+
+ /**
+ * @return true if network is external, false if not
+ */
+ public Boolean getExternal() {
+ return external;
+ }
+
+ /**
+ * @return the type of network
+ */
+ public NetworkType getNetworkType() {
+ return networkType;
+ }
+
+ /**
+ * @return the physical network name
+ */
+ public String getPhysicalNetworkName() {
+ return physicalNetworkName;
+ }
+
+ /**
+ * @return the segmentation id of the network
+ */
+ public Integer getSegmentationId() {
+ return segmentationId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), state, subnets, adminStateUp, shared, external,
+ networkType, physicalNetworkName, segmentationId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Network that = Network.class.cast(obj);
+ return super.equals(obj)
+ && Objects.equal(this.state, that.state)
+ && Objects.equal(this.subnets, that.subnets)
+ && Objects.equal(this.adminStateUp, that.adminStateUp)
+ && Objects.equal(this.shared, that.shared)
+ && Objects.equal(this.external, that.external)
+ && Objects.equal(this.networkType, that.networkType)
+ && Objects.equal(this.physicalNetworkName, that.physicalNetworkName)
+ && Objects.equal(this.segmentationId, that.segmentationId);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("state", state).add("subnets", subnets).add("adminStateUp", adminStateUp).add("shared", shared).add("external", external)
+ .add("networkType", networkType).add("physicalNetworkName", physicalNetworkName).add("segmentationId", segmentationId);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromNetwork(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends ReferenceWithName.Builder<T> {
+ protected State state;
+ protected Set<String> subnets;
+ protected Boolean adminStateUp;
+ protected Boolean shared;
+ protected Boolean external;
+ protected NetworkType networkType;
+ protected String physicalNetworkName;
+ protected Integer segmentationId;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Network#getState()
+ */
+ public T state(State state) {
+ this.state = state;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Network#getSubnets()
+ */
+ public T subnets(Set<String> subnets) {
+ this.subnets = subnets;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Network#getAdminStateUp()
+ */
+ public T adminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Network#getShared()
+ */
+ public T shared(Boolean shared) {
+ this.shared = shared;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Network#getExternal()
+ */
+ public T external(Boolean external) {
+ this.external = external;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Network#getNetworkType()
+ */
+ public T networkType(NetworkType networkType) {
+ this.networkType = networkType;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Network#getPhysicalNetworkName()
+ */
+ public T physicalNetworkName(String physicalNetworkName) {
+ this.physicalNetworkName = physicalNetworkName;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Network#getSegmentationId()
+ */
+ public T segmentationId(Integer segmentationId) {
+ this.segmentationId = segmentationId;
+ return self();
+ }
+
+ public Network build() {
+ return new Network(id, tenantId, name, state, subnets, adminStateUp, shared, external, networkType == null ? null : networkType.getValue(), physicalNetworkName, segmentationId);
+ }
+
+ public T fromNetwork(Network in) {
+ return super.fromReference(in)
+ .state(in.getState())
+ .subnets(in.getSubnets())
+ .adminStateUp(in.getAdminStateUp())
+ .shared(in.getShared())
+ .external(in.getExternal())
+ .networkType(in.getNetworkType())
+ .physicalNetworkName(in.getPhysicalNetworkName())
+ .segmentationId(in.getSegmentationId());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/NetworkType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/NetworkType.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/NetworkType.java
new file mode 100644
index 0000000..b0f1d20
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/NetworkType.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+/**
+ * The type of Network
+ */
+public enum NetworkType {
+ LOCAL("local"), FLAT("flat"), VLAN("vlan"), GRE("gre");
+
+ private String value;
+
+ private NetworkType(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public static NetworkType fromValue(String value) {
+ return NetworkType.valueOf(value.toUpperCase());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Port.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Port.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Port.java
new file mode 100644
index 0000000..75f491f
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Port.java
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import com.google.common.base.Objects;
+
+import java.beans.ConstructorProperties;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * A Neutron port
+ *
+ * @see <a href="http://docs.openstack.org/api/openstack-network/1.0/content/Ports.html">api doc</a>
+ */
+public class Port extends ReferenceWithName {
+
+ private final State state;
+ private final Boolean adminStateUp;
+ private final String networkId;
+ private final String deviceId;
+ private final String deviceOwner;
+ private final String macAddress;
+ private final Set<IP> fixedIps;
+
+ @ConstructorProperties({
+ "id", "tenant_id", "name", "status", "network_id", "admin_state_up", "device_id", "device_owner", "fixed_ips", "mac_address"
+ })
+ protected Port(String id, String tenantId, String name, State state, String networkId, Boolean adminStateUp,
+ String deviceId, String deviceOwner, Set<IP> fixedIps, String macAddress) {
+ super(id, tenantId, name);
+ this.adminStateUp = adminStateUp;
+ this.state = state;
+ this.networkId = checkNotNull(networkId, "networkId");
+ this.deviceId = deviceId;
+ this.deviceOwner = deviceOwner;
+ this.fixedIps = fixedIps;
+ this.macAddress = macAddress;
+ }
+
+ /**
+ * @return the current state of the port
+ */
+ public State getState() {
+ return this.state;
+ }
+
+ /**
+ * @return the administrative state of port. If false, port does not forward packets.
+ */
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the id of the network where this port is associated with
+ */
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ /**
+ * @return the id of the device (e.g. server) using this port.
+ */
+ public String getDeviceId() {
+ return deviceId;
+ }
+
+ /**
+ * @return the entity (e.g.: dhcp agent) using this port.
+ */
+ public String getDeviceOwner() {
+ return deviceOwner;
+ }
+
+ /**
+ * @return the set of fixed ips this port has been assigned
+ */
+ public Set<IP> getFixedIps() {
+ return fixedIps;
+ }
+
+ /**
+ * @return the mac address of this port
+ */
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), state, adminStateUp, networkId, deviceId, deviceOwner, fixedIps, macAddress);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Port that = Port.class.cast(obj);
+ return super.equals(obj)
+ && Objects.equal(this.state, that.state)
+ && Objects.equal(this.adminStateUp, that.adminStateUp)
+ && Objects.equal(this.networkId, that.networkId)
+ && Objects.equal(this.deviceId, that.deviceId)
+ && Objects.equal(this.deviceOwner, that.deviceOwner)
+ && Objects.equal(this.fixedIps, that.fixedIps)
+ && Objects.equal(this.macAddress, that.macAddress);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("state", state).add("adminStateUp", adminStateUp).add("networkId", networkId).add("deviceId", deviceId)
+ .add("deviceOwner", deviceOwner).add("fixedIps", fixedIps).add("macAddress", macAddress);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromPort(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends ReferenceWithName.Builder<T> {
+ protected String networkId;
+ protected String deviceId;
+ protected String deviceOwner;
+ protected String macAddress;
+ protected Set<IP> fixedIps;
+ protected State state;
+ protected Boolean adminStateUp;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Port#getState()
+ */
+ public T state(State state) {
+ this.state = state;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Port#getNetworkId()
+ */
+ public T networkId(String networkId) {
+ this.networkId = networkId;
+ return self();
+ }
+
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Port#getAdminStateUp()
+ */
+ public T adminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Port#getDeviceId()
+ */
+ public T deviceId(String deviceId) {
+ this.deviceId = deviceId;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Port#getDeviceOwner()
+ */
+ public T deviceOwner(String deviceOwner) {
+ this.deviceOwner = deviceOwner;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Port#getDeviceId()
+ */
+ public T fixedIps(Set<IP> fixedIps) {
+ this.fixedIps = fixedIps;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Port#getMacAddress()
+ */
+ public T macAddress(String macAddress) {
+ this.macAddress = macAddress;
+ return self();
+ }
+
+ public Port build() {
+ return new Port(id, tenantId, name, state, networkId, adminStateUp, deviceId, deviceOwner, fixedIps, macAddress);
+ }
+
+ public T fromPort(Port in) {
+ return super.fromReference(in)
+ .state(in.getState())
+ .networkId(in.getNetworkId())
+ .adminStateUp(in.getAdminStateUp())
+ .deviceId(in.getDeviceId())
+ .deviceOwner(in.getDeviceOwner())
+ .fixedIps(in.getFixedIps())
+ .macAddress(in.getMacAddress());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Reference.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Reference.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Reference.java
new file mode 100644
index 0000000..0458118
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Reference.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import com.google.common.base.Objects;
+
+import java.beans.ConstructorProperties;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Base class for beans in the Neutron v2.0 api
+ *
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/Networks.html">api doc</a>
+ */
+public class Reference {
+
+ private final String id;
+ private final String tenantId;
+
+ @ConstructorProperties({
+ "id", "tenant_id"
+ })
+ protected Reference(String id, String tenantId) {
+ this.id = checkNotNull(id, "id");
+ this.tenantId = checkNotNull(tenantId, "tenantId");
+ }
+
+ /**
+ * @return the id of the entity
+ */
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * @return the id of the tenant where this entity is associated with
+ */
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, tenantId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Reference that = Reference.class.cast(obj);
+ return Objects.equal(this.id, that.id) && Objects.equal(this.tenantId, that.tenantId);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("id", id).add("tenantId", tenantId);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromReference(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String id;
+ protected String tenantId;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Reference#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Reference#getTenantId()
+ */
+ public T tenantId(String tenantId) {
+ this.tenantId = tenantId;
+ return self();
+ }
+
+ public Reference build() {
+ return new Reference(id, tenantId);
+ }
+
+ public T fromReference(Reference in) {
+ return this.id(in.getId()).tenantId(in.getTenantId());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/ReferenceWithName.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/ReferenceWithName.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/ReferenceWithName.java
new file mode 100644
index 0000000..f5fe4d5
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/ReferenceWithName.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Objects;
+import com.google.common.base.Strings;
+
+import java.beans.ConstructorProperties;
+
+/**
+ * Base class for beans in the Neutron v2.0 api
+ *
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/Networks.html">api doc</a>
+ */
+public class ReferenceWithName extends Reference {
+
+ private final String name;
+
+ @ConstructorProperties({
+ "id", "tenant_id", "name"
+ })
+ protected ReferenceWithName(String id, String tenantId, String name) {
+ super(id, tenantId);
+ this.name = Strings.nullToEmpty(name);
+ }
+
+ /**
+ * @return the name of the entity
+ */
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), name);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ ReferenceWithName that = ReferenceWithName.class.cast(obj);
+ return super.equals(obj) && Objects.equal(this.name, that.name);
+ }
+
+ protected ToStringHelper string() {
+ return super.string().add("name", name);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromReferenceWithName(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends Reference.Builder<T> {
+ protected abstract T self();
+
+ protected String name;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ public ReferenceWithName build() {
+ return new ReferenceWithName(id, tenantId, name);
+ }
+
+ public T fromReferenceWithName(ReferenceWithName in) {
+ return super.fromReference(in).name(in.getName());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Router.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Router.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Router.java
new file mode 100644
index 0000000..5096ed9
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Router.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import com.google.common.base.Objects;
+
+import java.beans.ConstructorProperties;
+
+/**
+ * A Neutron Router
+ *
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/router_ext_concepts.html">api doc</a>
+ */
+public class Router extends ReferenceWithName {
+
+ private final Boolean adminStateUp;
+ private final State state;
+ private final ExternalGatewayInfo externalGatewayInfo;
+
+ @ConstructorProperties({
+ "id", "tenant_id", "name", "admin_state_up", "status", "external_gateway_info"
+ })
+ protected Router(String id, String tenantId, String name, Boolean adminStateUp, State state, ExternalGatewayInfo externalGatewayInfo) {
+ super(id, tenantId, name);
+ this.adminStateUp = adminStateUp;
+ this.state = state;
+ this.externalGatewayInfo = externalGatewayInfo;
+ }
+
+ /**
+ * @return the administrative state of the router
+ */
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the current state of the router
+ */
+ public State getState() {
+ return state;
+ }
+
+ /**
+ * @return the information on external gateway for the router
+ */
+ public ExternalGatewayInfo getExternalGatewayInfo() {
+ return externalGatewayInfo;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), adminStateUp, state, externalGatewayInfo);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Router that = Router.class.cast(obj);
+ return super.equals(obj)
+ && Objects.equal(this.adminStateUp, that.adminStateUp)
+ && Objects.equal(this.state, that.state)
+ && Objects.equal(this.externalGatewayInfo, that.externalGatewayInfo);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("adminStateUp", adminStateUp).add("state", state).add("externalGatewayInfo", externalGatewayInfo != null ? externalGatewayInfo.toString() : "");
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromRouter(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends ReferenceWithName.Builder<T> {
+
+ protected Boolean adminStateUp;
+ protected State state;
+ protected ExternalGatewayInfo externalGatewayInfo;
+
+ /**
+ * @see Router#getAdminStateUp()
+ */
+ public T adminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ /**
+ * @see Router#getState()
+ */
+ public T state(State state) {
+ this.state = state;
+ return self();
+ }
+
+ /**
+ * @see Router#getExternalGatewayInfo()
+ */
+ public T externalGatewayInfo(ExternalGatewayInfo externalGatewayInfo) {
+ this.externalGatewayInfo = externalGatewayInfo;
+ return self();
+ }
+
+ public Router build() {
+ return new Router(id, tenantId, name, adminStateUp, state, externalGatewayInfo);
+ }
+
+ public T fromRouter(Router in) {
+ return super.fromReference(in)
+ .adminStateUp(in.getAdminStateUp())
+ .state(in.getState())
+ .externalGatewayInfo(in.getExternalGatewayInfo());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/RouterInterface.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/RouterInterface.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/RouterInterface.java
new file mode 100644
index 0000000..f1a9c70
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/RouterInterface.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import com.google.common.base.Objects;
+
+import java.beans.ConstructorProperties;
+
+/**
+ * A Neutron Router Interface
+ *
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/router_add_interface.html">api doc</a>
+ */
+public class RouterInterface {
+
+ private final String subnetId;
+ private final String portId;
+
+ @ConstructorProperties({
+ "subnet_id", "port_id"
+ })
+ protected RouterInterface(String subnetId, String portId) {
+ this.subnetId = subnetId;
+ this.portId = portId;
+ }
+
+ /**
+ * @return the id of the subnet this router interface is associated with
+ */
+ public String getSubnetId() {
+ return subnetId;
+ }
+
+ /**
+ * @return the id of the port this router interface is associated with
+ */
+ public String getPortId() {
+ return portId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(subnetId, portId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ RouterInterface that = RouterInterface.class.cast(obj);
+ return Objects.equal(this.subnetId, that.subnetId) && Objects.equal(this.portId, that.portId);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("subnetId", subnetId).add("portId", portId);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder toBuilder() {
+ return new ConcreteBuilder().fromRouterInterface(this);
+ }
+
+ public abstract static class Builder {
+ protected abstract Builder self();
+
+ protected String subnetId;
+ protected String portId;
+
+ /**
+ * @see RouterInterface#getSubnetId()
+ */
+ public Builder subnetId(String subnetId) {
+ this.subnetId = subnetId;
+ return self();
+ }
+
+ /**
+ * @see RouterInterface#getPortId()
+ */
+ public Builder portId(String portId) {
+ this.portId = portId;
+ return self();
+ }
+
+ public RouterInterface build() {
+ return new RouterInterface(subnetId, portId);
+ }
+
+ public Builder fromRouterInterface(RouterInterface in) {
+ return this.subnetId(in.getSubnetId()).portId(in.getPortId());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/State.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/State.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/State.java
new file mode 100644
index 0000000..e276df8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/State.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+/**
+ * The possible state of an entity
+ *
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/Concepts-d1e369.html">api doc</a>
+ */
+public enum State {
+ ACTIVE, DOWN, BUILD, ERROR
+}
[37/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
new file mode 100644
index 0000000..3f833a9
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.features.DiskApiLiveTest.TIME_WAIT;
+import static org.testng.Assert.assertEquals;
+
+import java.util.List;
+
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Disk;
+import org.jclouds.googlecomputeengine.domain.Snapshot;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+public class SnapshotApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private static final String DISK_NAME = "snapshot-api-live-test-disk";
+ private static final String SNAPSHOT_NAME = "snapshot-api-live-test-snapshot";
+
+ private Disk disk;
+ private SnapshotApi api() {
+ return api.getSnapshotApiForProject(userProject.get());
+ }
+
+ private DiskApi diskApi() {
+ return api.getDiskApiForProject(userProject.get());
+ }
+
+ @Test(groups = "live")
+ public void testCreateSnapshot() {
+ assertZoneOperationDoneSucessfully(diskApi().createInZone(DISK_NAME, 1, DEFAULT_ZONE_NAME), TIME_WAIT);
+ disk = diskApi().getInZone(DEFAULT_ZONE_NAME, DISK_NAME);
+
+ assertZoneOperationDoneSucessfully(diskApi().createSnapshotInZone(DEFAULT_ZONE_NAME, DISK_NAME, SNAPSHOT_NAME),
+ TIME_WAIT);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testCreateSnapshot")
+ public void testGetSnapshot() {
+ Snapshot snapshot = api().get(SNAPSHOT_NAME);
+
+ assertEquals(snapshot.getName(), SNAPSHOT_NAME);
+ assertSnapshotEquals(snapshot);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testGetSnapshot")
+ public void testListSnapshot() {
+
+ PagedIterable<Snapshot> snapshots = api().list(new ListOptions.Builder()
+ .filter("name eq " + SNAPSHOT_NAME));
+
+ List<Snapshot> snapshotsAsList = Lists.newArrayList(snapshots.concat());
+
+ assertEquals(snapshotsAsList.size(), 1);
+
+ assertSnapshotEquals(Iterables.getOnlyElement(snapshotsAsList));
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testListSnapshot")
+ public void testDeleteDisk() {
+
+ assertZoneOperationDoneSucessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
+ assertGlobalOperationDoneSucessfully(api().delete(SNAPSHOT_NAME), TIME_WAIT);
+ }
+
+ private void assertSnapshotEquals(Snapshot result) {
+ assertEquals(result.getName(), SNAPSHOT_NAME);
+ assertEquals(result.getSourceDisk().orNull(), disk.getSelfLink());
+ assertEquals(result.getSizeGb(), disk.getSizeGb());
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java
new file mode 100644
index 0000000..0a26bd6
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.parse.ParseZoneListTest;
+import org.jclouds.googlecomputeengine.parse.ParseZoneTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class ZoneApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ public static final String ZONES_URL_PREFIX = "https://www.googleapis.com/compute/v1/projects/myproject/zones";
+
+ public static final HttpRequest GET_ZONE_REQ = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(ZONES_URL_PREFIX + "/us-central1-a")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpRequest LIST_ZONES_REQ = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(ZONES_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse LIST_ZONES_SHORT_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/zone_list_short.json")).build();
+
+ public static final HttpResponse LIST_ZONES_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/zone_list.json")).build();
+
+ public void testGetZoneResponseIs2xx() throws Exception {
+
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_get.json")).build();
+
+ ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_ZONE_REQ, operationResponse).getZoneApiForProject("myproject");
+
+ assertEquals(api.get("us-central1-a"),
+ new ParseZoneTest().expected());
+ }
+
+ public void testGetZoneResponseIs4xx() throws Exception {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_ZONE_REQ, operationResponse).getZoneApiForProject("myproject");
+
+ assertNull(api.get("us-central1-a"));
+ }
+
+ public void testListZoneNoOptionsResponseIs2xx() throws Exception {
+
+ ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, LIST_ZONES_REQ, LIST_ZONES_RESPONSE).getZoneApiForProject("myproject");
+
+ assertEquals(api.listFirstPage().toString(),
+ new ParseZoneListTest().expected().toString());
+ }
+
+ public void testListZoneWithPaginationOptionsResponseIs4xx() {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, LIST_ZONES_REQ, operationResponse).getZoneApiForProject("myproject");
+
+ assertTrue(api.list().concat().isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java
new file mode 100644
index 0000000..934e93a
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Zone;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+public class ZoneApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private Zone zone;
+
+ private ZoneApi api() {
+ return api.getZoneApiForProject(userProject.get());
+ }
+
+ @Test(groups = "live")
+ public void testListZone() {
+
+ PagedIterable<Zone> zones = api().list(new ListOptions.Builder()
+ .maxResults(1));
+
+ Iterator<IterableWithMarker<Zone>> pageIterator = zones.iterator();
+ assertTrue(pageIterator.hasNext());
+
+ IterableWithMarker<Zone> singlePageIterator = pageIterator.next();
+ List<Zone> zoneAsList = Lists.newArrayList(singlePageIterator);
+
+ assertSame(zoneAsList.size(), 1);
+
+ this.zone = Iterables.getOnlyElement(zoneAsList);
+ }
+
+
+ @Test(groups = "live", dependsOnMethods = "testListZone")
+ public void testGetZone() {
+ Zone zone = api().get(this.zone.getName());
+ assertNotNull(zone);
+ assertZoneEquals(zone, this.zone);
+ }
+
+ private void assertZoneEquals(Zone result, Zone expected) {
+ assertEquals(result.getName(), expected.getName());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
new file mode 100644
index 0000000..fc23e1b
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.Resource;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ private static final String OPERATIONS_URL_PREFIX = "https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/operations";
+
+ public static final HttpRequest GET_ZONE_OPERATION_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX + "/operation-1354084865060-4cf88735faeb8-bbbb12cb")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse GET_ZONE_OPERATION_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/zone_operation.json")).build();
+
+ private Operation expected() {
+ SimpleDateFormatDateService dateService = new SimpleDateFormatDateService();
+ return Operation.builder().id("13053095055850848306")
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/operations/operation-1354084865060-4cf88735faeb8" +
+ "-bbbb12cb"))
+ .name("operation-1354084865060-4cf88735faeb8-bbbb12cb")
+ .targetLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/instance-api-live-test-instance"))
+ .targetId("13053094017547040099")
+ .status(Operation.Status.DONE)
+ .user("user@developer.gserviceaccount.com")
+ .progress(100)
+ .insertTime(dateService.iso8601DateParse("2012-11-28T06:41:05.060"))
+ .startTime(dateService.iso8601DateParse("2012-11-28T06:41:05.142"))
+ .endTime(dateService.iso8601DateParse("2012-11-28T06:41:06.142"))
+ .operationType("insert")
+ .zone(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"))
+ .build();
+ }
+
+ private ListPage<Operation> expectedList() {
+ return ListPage.<Operation>builder()
+ .kind(Resource.Kind.OPERATION_LIST)
+ .id("projects/myproject/zones/us-central1-a/operations")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/operations"))
+ .addItem(expected())
+ .build();
+ }
+
+ public void testGetOperationResponseIs2xx() throws Exception {
+
+ ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_ZONE_OPERATION_REQUEST, GET_ZONE_OPERATION_RESPONSE).getZoneOperationApiForProject("myproject");
+
+ assertEquals(zoneOperationApi.getInZone("us-central1-a", "operation-1354084865060-4cf88735faeb8-bbbb12cb"),
+ expected());
+ }
+
+ public void testGetOperationResponseIs4xx() throws Exception {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_ZONE_OPERATION_REQUEST, operationResponse).getZoneOperationApiForProject("myproject");
+
+ assertNull(zoneOperationApi.getInZone("us-central1-a", "operation-1354084865060-4cf88735faeb8-bbbb12cb"));
+ }
+
+ public void testDeleteOperationResponseIs2xx() throws Exception {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
+
+ ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, operationResponse).getZoneOperationApiForProject("myproject");
+
+ zoneOperationApi.deleteInZone("us-central1-a", "operation-1352178598164-4cdcc9d031510-4aa46279");
+ }
+
+ public void testDeleteOperationResponseIs4xx() throws Exception {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, operationResponse).getZoneOperationApiForProject("myproject");
+
+ zoneOperationApi.deleteInZone("us-central1-a", "operation-1352178598164-4cdcc9d031510-4aa46279");
+ }
+
+ public void testListOperationWithNoOptionsResponseIs2xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation_list.json")).build();
+
+ ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getZoneOperationApiForProject("myproject");
+
+ assertEquals(zoneOperationApi.listFirstPageInZone("us-central1-a").toString(),
+ expectedList().toString());
+ }
+
+ public void testListOperationWithPaginationOptionsResponseIs2xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX +
+ "?pageToken=CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcG" +
+ "VyYXRpb24tMTM1MjI0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz&" +
+ "filter=" +
+ "status%20eq%20done&" +
+ "maxResults=3")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation_list.json")).build();
+
+ ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getZoneOperationApiForProject("myproject");
+
+ assertEquals(zoneOperationApi.listAtMarkerInZone("us-central1-a",
+ "CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
+ "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
+ new ListOptions.Builder().filter("status eq done").maxResults(3)).toString(),
+ expectedList().toString());
+ }
+
+ public void testListOperationWithPaginationOptionsResponseIs4xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getZoneOperationApiForProject("myproject");
+
+ assertTrue(zoneOperationApi.listInZone("us-central1-a").concat().isEmpty());
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
new file mode 100644
index 0000000..4d30272
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.features.DiskApiLiveTest.TIME_WAIT;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+public class ZoneOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private static final String DISK_NAME = "zone-operations-api-live-test-disk";
+ private Operation addOperation;
+ private Operation deleteOperation;
+
+ private ZoneOperationApi api() {
+ return api.getZoneOperationApiForProject(userProject.get());
+ }
+
+ private DiskApi diskApi() {
+ return api.getDiskApiForProject(userProject.get());
+ }
+
+ @Test(groups = "live")
+ public void testCreateOperations() {
+ //create some operations by creating and deleting a disk
+ // this will make sure there is stuff to listFirstPage
+ addOperation = assertZoneOperationDoneSucessfully(diskApi().createInZone(DISK_NAME, 1, DEFAULT_ZONE_NAME), TIME_WAIT);
+ deleteOperation = assertZoneOperationDoneSucessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
+
+ assertNotNull(addOperation);
+ assertNotNull(deleteOperation);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testCreateOperations")
+ public void testGetOperation() {
+ Operation operation = api().getInZone(DEFAULT_ZONE_NAME, addOperation.getName());
+ assertNotNull(operation);
+ assertOperationEquals(operation, this.addOperation);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testCreateOperations")
+ public void testListOperationsWithFiltersAndPagination() {
+ PagedIterable<Operation> operations = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
+// .filter("operationType eq insert")
+ .maxResults(1));
+
+ // make sure that in spite of having only one result per page we get at least two results
+ final AtomicInteger counter = new AtomicInteger();
+ operations.firstMatch(new Predicate<IterableWithMarker<Operation>>() {
+
+ @Override
+ public boolean apply(IterableWithMarker<Operation> input) {
+ counter.addAndGet(Iterables.size(input));
+ return counter.get() == 2;
+ }
+ });
+ }
+
+ private void assertOperationEquals(Operation result, Operation expected) {
+ assertEquals(result.getName(), expected.getName());
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/functions/CreateNetworkIfNeededTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/functions/CreateNetworkIfNeededTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/functions/CreateNetworkIfNeededTest.java
new file mode 100644
index 0000000..292f9d4
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/functions/CreateNetworkIfNeededTest.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions;
+
+import static com.google.common.base.Optional.fromNullable;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.internal.NetworkAndAddressRange;
+import org.jclouds.googlecomputeengine.features.GlobalOperationApi;
+import org.jclouds.googlecomputeengine.features.NetworkApi;
+import org.jclouds.googlecomputeengine.predicates.GlobalOperationDonePredicate;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+
+public class CreateNetworkIfNeededTest {
+
+ @Test
+ public void testApply() {
+ final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
+ final NetworkApi nwApi = createMock(NetworkApi.class);
+ final GlobalOperationApi globalApi = createMock(GlobalOperationApi.class);
+
+ Network network = Network.builder().IPv4Range("0.0.0.0/0")
+ .id("abcd").name("this-network")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
+ .build();
+
+ Operation createOp = createMock(Operation.class);
+
+ final Supplier<String> userProject = new Supplier<String>() {
+ @Override
+ public String get() {
+ return "myproject";
+ }
+ };
+
+ expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
+ expect(api.getGlobalOperationApiForProject(userProject.get())).andReturn(globalApi).atLeastOnce();
+
+ expect(nwApi.createInIPv4Range("this-network", "0.0.0.0/0"))
+ .andReturn(createOp);
+ expect(globalApi.get("create-op")).andReturn(createOp);
+ expect(nwApi.get("this-network")).andReturn(null);
+ expect(nwApi.get("this-network")).andReturn(network);
+
+ expect(createOp.getName()).andReturn("create-op");
+ expect(createOp.getStatus()).andReturn(Operation.Status.DONE);
+ expect(createOp.getHttpError()).andReturn(fromNullable((HttpResponse)null));
+ replay(api, nwApi, createOp, globalApi);
+
+ NetworkAndAddressRange input = new NetworkAndAddressRange("this-network", "0.0.0.0/0", null);
+
+ GlobalOperationDonePredicate pred = new GlobalOperationDonePredicate(api, userProject);
+
+ CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, userProject, pred, 100l, 100l);
+
+ assertEquals(creator.apply(input), network);
+
+ verify(api, nwApi, globalApi, createOp);
+ }
+
+ @Test
+ public void testApplyWithGateway() {
+ final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
+ final NetworkApi nwApi = createMock(NetworkApi.class);
+ final GlobalOperationApi globalApi = createMock(GlobalOperationApi.class);
+
+ Network network = Network.builder().IPv4Range("0.0.0.0/0")
+ .id("abcd").name("this-network").gatewayIPv4("1.2.3.4")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
+ .build();
+
+ Operation createOp = createMock(Operation.class);
+
+ final Supplier<String> userProject = new Supplier<String>() {
+ @Override
+ public String get() {
+ return "myproject";
+ }
+ };
+
+ expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
+ expect(api.getGlobalOperationApiForProject(userProject.get())).andReturn(globalApi).atLeastOnce();
+
+ expect(nwApi.createInIPv4RangeWithGateway("this-network", "0.0.0.0/0", "1.2.3.4"))
+ .andReturn(createOp);
+ expect(globalApi.get("create-op")).andReturn(createOp);
+ expect(nwApi.get("this-network")).andReturn(null);
+ expect(nwApi.get("this-network")).andReturn(network);
+
+ expect(createOp.getName()).andReturn("create-op");
+ expect(createOp.getStatus()).andReturn(Operation.Status.DONE);
+ expect(createOp.getHttpError()).andReturn(fromNullable((HttpResponse)null));
+ replay(api, nwApi, createOp, globalApi);
+
+ NetworkAndAddressRange input = new NetworkAndAddressRange("this-network", "0.0.0.0/0", "1.2.3.4");
+
+ GlobalOperationDonePredicate pred = new GlobalOperationDonePredicate(api, userProject);
+
+ CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, userProject, pred, 100l, 100l);
+
+ assertEquals(creator.apply(input), network);
+
+ verify(api, nwApi, globalApi, createOp);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/handlers/GoogleComputeEngineErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/handlers/GoogleComputeEngineErrorHandlerTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/handlers/GoogleComputeEngineErrorHandlerTest.java
new file mode 100644
index 0000000..1d88d5a
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/handlers/GoogleComputeEngineErrorHandlerTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.handlers;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reportMatcher;
+import static org.easymock.EasyMock.verify;
+
+import java.net.URI;
+
+import org.easymock.IArgumentMatcher;
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "GoogleComputeErrorHandlerTest")
+public class GoogleComputeEngineErrorHandlerTest {
+
+ @Test
+ public void test409MakesIllegalStateException() {
+ assertCodeMakes(
+ "POST",
+ URI.create("https://www.googleapis.com/compute/v1"),
+ 409,
+ "HTTP/1.1 409 Conflict",
+ "\"{\"code\":\"InvalidState\",\"message\":\"An incompatible transition has already been queued for this" +
+ " resource\"}\"",
+ IllegalStateException.class);
+ }
+
+ private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content,
+ Class<? extends Exception> expected) {
+ assertCodeMakes(method, uri, statusCode, message, "application/json", content, expected);
+ }
+
+ private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType,
+ String content, Class<? extends Exception> expected) {
+
+ GoogleComputeEngineErrorHandler function = new GoogleComputeEngineErrorHandler();
+
+ HttpCommand command = createMock(HttpCommand.class);
+ HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build();
+ HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build();
+ response.getPayload().getContentMetadata().setContentType(contentType);
+
+ expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
+ command.setException(classEq(expected));
+
+ replay(command);
+
+ function.handleError(command, response);
+
+ verify(command);
+ }
+
+ public static Exception classEq(final Class<? extends Exception> in) {
+ reportMatcher(new IArgumentMatcher() {
+
+ @Override
+ public void appendTo(StringBuffer buffer) {
+ buffer.append("classEq(");
+ buffer.append(in);
+ buffer.append(")");
+ }
+
+ @Override
+ public boolean matches(Object arg) {
+ return arg.getClass() == in;
+ }
+
+ });
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiExpectTest.java
new file mode 100644
index 0000000..1766de8
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiExpectTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.internal;
+
+import java.util.Properties;
+
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+
+public class BaseGoogleComputeEngineApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
+
+ @Override
+ protected Properties setupProperties() {
+ Properties properties = super.setupProperties();
+ properties.put("google-compute-engine.identity", "myproject");
+ return properties;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java
new file mode 100644
index 0000000..2c018eb
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.internal;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+
+import java.net.URI;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Operation;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.util.concurrent.Atomics;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.Module;
+import com.google.inject.TypeLiteral;
+import com.google.inject.name.Names;
+
+
+public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleComputeEngineApi> {
+
+ protected static final String API_URL_PREFIX = "https://www.googleapis.com/compute/v1/projects/";
+ protected static final String ZONE_API_URL_SUFFIX = "/zones/";
+ protected static final String DEFAULT_ZONE_NAME = "us-central1-a";
+
+ protected static final String REGION_API_URL_SUFFIX = "/region/";
+ protected static final String DEFAULT_REGION_NAME = "us-central1";
+
+ protected static final String NETWORK_API_URL_SUFFIX = "/global/networks/";
+ protected static final String DEFAULT_NETWORK_NAME = "live-test-network";
+
+ protected static final String MACHINE_TYPE_API_URL_SUFFIX = "/machineTypes/";
+ protected static final String DEFAULT_MACHINE_TYPE_NAME = "n1-standard-1";
+
+ protected static final String GATEWAY_API_URL_SUFFIX = "/global/gateways/";
+ protected static final String DEFAULT_GATEWAY_NAME = "default-internet-gateway";
+
+ protected static final String GOOGLE_PROJECT = "google";
+
+ protected Supplier<String> userProject;
+ protected Predicate<AtomicReference<Operation>> globalOperationDonePredicate;
+ protected Predicate<AtomicReference<Operation>> regionOperationDonePredicate;
+ protected Predicate<AtomicReference<Operation>> zoneOperationDonePredicate;
+
+
+ public BaseGoogleComputeEngineApiLiveTest() {
+ provider = "google-compute-engine";
+ }
+
+ protected GoogleComputeEngineApi create(Properties props, Iterable<Module> modules) {
+ Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
+ userProject = injector.getInstance(Key.get(new TypeLiteral<Supplier<String>>() {
+ }, UserProject.class));
+ globalOperationDonePredicate = injector.getInstance(Key.get(new TypeLiteral<Predicate<AtomicReference<Operation>>>() {
+ }, Names.named("global")));
+ regionOperationDonePredicate = injector.getInstance(Key.get(new TypeLiteral<Predicate<AtomicReference<Operation>>>() {
+ }, Names.named("region")));
+ zoneOperationDonePredicate = injector.getInstance(Key.get(new TypeLiteral<Predicate<AtomicReference<Operation>>>() {
+ }, Names.named("zone")));
+ return injector.getInstance(GoogleComputeEngineApi.class);
+ }
+
+ protected Operation assertGlobalOperationDoneSucessfully(Operation operation, long maxWaitSeconds) {
+ operation = waitGlobalOperationDone(operation, maxWaitSeconds);
+ assertEquals(operation.getStatus(), Operation.Status.DONE);
+ assertTrue(operation.getErrors().isEmpty());
+ return operation;
+ }
+
+ protected Operation waitGlobalOperationDone(Operation operation, long maxWaitSeconds) {
+ return waitOperationDone(globalOperationDonePredicate, operation, maxWaitSeconds);
+ }
+
+ protected Operation assertRegionOperationDoneSucessfully(Operation operation, long maxWaitSeconds) {
+ operation = waitRegionOperationDone(operation, maxWaitSeconds);
+ assertEquals(operation.getStatus(), Operation.Status.DONE);
+ assertTrue(operation.getErrors().isEmpty());
+ return operation;
+ }
+
+ protected Operation waitRegionOperationDone(Operation operation, long maxWaitSeconds) {
+ return waitOperationDone(regionOperationDonePredicate, operation, maxWaitSeconds);
+ }
+
+ protected Operation assertZoneOperationDoneSucessfully(Operation operation, long maxWaitSeconds) {
+ operation = waitZoneOperationDone(operation, maxWaitSeconds);
+ assertEquals(operation.getStatus(), Operation.Status.DONE);
+ assertTrue(operation.getErrors().isEmpty());
+ return operation;
+ }
+
+ protected Operation waitZoneOperationDone(Operation operation, long maxWaitSeconds) {
+ return waitOperationDone(zoneOperationDonePredicate, operation, maxWaitSeconds);
+ }
+
+ protected URI getDefaultZoneUrl(String project) {
+ return getZoneUrl(project, DEFAULT_ZONE_NAME);
+ }
+
+ protected URI getZoneUrl(String project, String zone) {
+ return URI.create(API_URL_PREFIX + project + ZONE_API_URL_SUFFIX + zone);
+ }
+
+ protected URI getDefaultNetworkUrl(String project) {
+ return getNetworkUrl(project, DEFAULT_NETWORK_NAME);
+ }
+
+ protected URI getNetworkUrl(String project, String network) {
+ return URI.create(API_URL_PREFIX + project + NETWORK_API_URL_SUFFIX + network);
+ }
+
+ protected URI getGatewayUrl(String project, String gateway) {
+ return URI.create(API_URL_PREFIX + project + GATEWAY_API_URL_SUFFIX + gateway);
+ }
+
+ protected URI getDefaultMachineTypeUrl(String project) {
+ return getMachineTypeUrl(project, DEFAULT_MACHINE_TYPE_NAME);
+ }
+
+ protected URI getMachineTypeUrl(String project, String machineType) {
+ return URI.create(API_URL_PREFIX + project + ZONE_API_URL_SUFFIX
+ + DEFAULT_ZONE_NAME + MACHINE_TYPE_API_URL_SUFFIX + machineType);
+ }
+
+ protected URI getDiskUrl(String project, String diskName) {
+ return URI.create(API_URL_PREFIX + project + ZONE_API_URL_SUFFIX
+ + DEFAULT_ZONE_NAME + "/disks/" + diskName);
+ }
+
+ protected static Operation waitOperationDone(Predicate<AtomicReference<Operation>> operationDonePredicate,
+ Operation operation, long maxWaitSeconds) {
+ AtomicReference<Operation> operationReference = Atomics.newReference(operation);
+ retry(operationDonePredicate, maxWaitSeconds, 1, SECONDS).apply(operationReference);
+ return operationReference.get();
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineExpectTest.java
new file mode 100644
index 0000000..47a4245
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineExpectTest.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.internal;
+
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.base.Throwables.propagate;
+import static com.google.common.io.BaseEncoding.base64Url;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.jclouds.crypto.Pems.privateKeySpec;
+import static org.jclouds.crypto.Pems.publicKeySpec;
+import static org.jclouds.crypto.PemsTest.PRIVATE_KEY;
+import static org.jclouds.crypto.PemsTest.PUBLIC_KEY;
+
+import java.io.IOException;
+import java.net.URI;
+import java.security.KeyFactory;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SecureRandom;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.InvalidKeySpecException;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.collect.PagedIterables;
+import org.jclouds.crypto.Crypto;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.io.Payload;
+import org.jclouds.oauth.v2.OAuthConstants;
+import org.jclouds.oauth.v2.config.OAuthProperties;
+import org.jclouds.rest.internal.BaseRestApiExpectTest;
+import org.jclouds.ssh.SshKeys;
+import org.jclouds.util.Strings2;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.io.ByteSource;
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.TypeLiteral;
+
+public class BaseGoogleComputeEngineExpectTest<T> extends BaseRestApiExpectTest<T> {
+
+ private static final String header = "{\"alg\":\"none\",\"typ\":\"JWT\"}";
+
+ private static final String CLAIMS_TEMPLATE = "{" +
+ "\"iss\":\"myproject\"," +
+ "\"scope\":\"%s\"," +
+ "\"aud\":\"https://accounts.google.com/o/oauth2/token\"," +
+ "\"exp\":3600," +
+ "\"iat\":0}";
+
+ protected static final String TOKEN = "1/8xbJqaOZXSUZbHLl5EOtu1pxz3fmmetKx9W8CV4t79M";
+
+ protected static final HttpResponse TOKEN_RESPONSE = HttpResponse.builder().statusCode(200).payload(
+ payloadFromString("{\n" +
+ " \"access_token\" : \"" + TOKEN + "\",\n" +
+ " \"token_type\" : \"Bearer\",\n" +
+ " \"expires_in\" : 3600\n" +
+ "}")).build();
+
+ protected String openSshKey;
+
+
+ public BaseGoogleComputeEngineExpectTest() {
+ provider = "google-compute-engine";
+ }
+
+ @Override
+ protected Module createModule() {
+
+
+ return new Module() {
+ @Override
+ public void configure(Binder binder) {
+ // Predicatable time
+ binder.bind(new TypeLiteral<Supplier<Long>>() {}).toInstance(Suppliers.ofInstance(0L));
+ try {
+ KeyFactory keyfactory = KeyFactory.getInstance("RSA");
+ PrivateKey privateKey = keyfactory.generatePrivate(privateKeySpec(ByteSource.wrap(
+ PRIVATE_KEY.getBytes(UTF_8))));
+ PublicKey publicKey = keyfactory.generatePublic(publicKeySpec(ByteSource.wrap(PUBLIC_KEY.getBytes(UTF_8))));
+ KeyPair keyPair = new KeyPair(publicKey, privateKey);
+ openSshKey = SshKeys.encodeAsOpenSSH(RSAPublicKey.class.cast(publicKey));
+ final Crypto crypto = createMock(Crypto.class);
+ KeyPairGenerator rsaKeyPairGenerator = createMock(KeyPairGenerator.class);
+ final SecureRandom secureRandom = createMock(SecureRandom.class);
+ expect(crypto.rsaKeyPairGenerator()).andReturn(rsaKeyPairGenerator).anyTimes();
+ rsaKeyPairGenerator.initialize(2048, secureRandom);
+ expectLastCall().anyTimes();
+ expect(rsaKeyPairGenerator.genKeyPair()).andReturn(keyPair).anyTimes();
+ replay(crypto, rsaKeyPairGenerator, secureRandom);
+ binder.bind(Crypto.class).toInstance(crypto);
+ binder.bind(SecureRandom.class).toInstance(secureRandom);
+ } catch (NoSuchAlgorithmException e) {
+ propagate(e);
+ } catch (InvalidKeySpecException e) {
+ propagate(e);
+ } catch (IOException e) {
+ propagate(e);
+ }
+ // predictable node names
+ final AtomicInteger suffix = new AtomicInteger();
+ binder.bind(new TypeLiteral<Supplier<String>>() {
+ }).toInstance(new Supplier<String>() {
+ @Override
+ public String get() {
+ return suffix.getAndIncrement() + "";
+ }
+ });
+ }
+ };
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties props = super.setupProperties();
+ // use no sig algorithm for expect tests (means no credential is required either)
+ props.put(OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM, OAuthConstants.NO_ALGORITHM);
+ return props;
+ }
+
+ @Override
+ protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) {
+ HttpRequestComparisonType reqType = HttpRequestComparisonType.DEFAULT;
+ if (input.getPayload() != null) {
+ if (input.getPayload().getContentMetadata().getContentType().equals(MediaType.APPLICATION_JSON)) {
+ reqType = HttpRequestComparisonType.JSON;
+ }
+ }
+ return reqType;
+ }
+
+ protected HttpRequest requestForScopes(String... scopes) {
+ String claims = String.format(CLAIMS_TEMPLATE, Joiner.on(",").join(scopes));
+
+ String payload = "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&" +
+ // Base64 Encoded Header
+ "assertion=" + base64Url().omitPadding().encode(header.getBytes(UTF_8)) + "." +
+ // Base64 Encoded Claims
+ base64Url().omitPadding().encode(claims.getBytes(UTF_8)) + ".";
+
+ return HttpRequest.builder()
+ .method("POST")
+ .endpoint(URI.create("https://accounts.google.com/o/oauth2/token"))
+ .addHeader("Accept", MediaType.APPLICATION_JSON)
+ .payload(payloadFromStringWithContentType(payload, "application/x-www-form-urlencoded"))
+ .build();
+ }
+
+ /**
+ * Parse tests don't apply @Transform so we need to apply the transformation to PagedIterable on the result of
+ * expected()
+ */
+ protected <T> PagedIterable<T> toPagedIterable(ListPage<T> list) {
+ return PagedIterables.of(list);
+ }
+
+ protected static Payload staticPayloadFromResource(String resource) {
+ try {
+ return payloadFromString(Strings2.toStringAndClose(BaseGoogleComputeEngineExpectTest.class.getResourceAsStream
+ (resource)));
+ } catch (IOException e) {
+ throw propagate(e);
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineParseTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineParseTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineParseTest.java
new file mode 100644
index 0000000..aba1fc3
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineParseTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.internal;
+
+import org.jclouds.googlecomputeengine.config.GoogleComputeEngineParserModule;
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public abstract class BaseGoogleComputeEngineParseTest<T> extends BaseItemParserTest<T> {
+
+ @Override
+ protected Injector injector() {
+ return Guice.createInjector(new GsonModule(), new GoogleComputeEngineParserModule());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceContextExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceContextExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceContextExpectTest.java
new file mode 100644
index 0000000..1b65fc1
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceContextExpectTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.internal;
+
+import java.util.Properties;
+
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApiMetadata;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+
+import com.google.common.base.Function;
+import com.google.inject.Module;
+
+public abstract class BaseGoogleComputeEngineServiceContextExpectTest<T> extends BaseGoogleComputeEngineExpectTest<T> implements
+ Function<ComputeServiceContext, T> {
+
+
+ @Override
+ public T createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
+ return apply(createComputeServiceContext(fn, module, props));
+ }
+
+ private ComputeServiceContext createComputeServiceContext(Function<HttpRequest, HttpResponse> fn, Module module,
+ Properties props) {
+ return createInjector(fn, module, props).getInstance(ComputeServiceContext.class);
+ }
+
+ @Override
+ protected ApiMetadata createApiMetadata() {
+ return new GoogleComputeEngineApiMetadata();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceExpectTest.java
new file mode 100644
index 0000000..23fa49e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceExpectTest.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.internal;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.ComputeServiceContext;
+
+public class BaseGoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngineServiceContextExpectTest<ComputeService> {
+
+ @Override
+ public ComputeService apply(ComputeServiceContext input) {
+ return input.getComputeService();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressListTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressListTest.java
new file mode 100644
index 0000000..8140a18
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressListTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Address;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Resource.Kind;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "unit")
+public class ParseAddressListTest extends BaseGoogleComputeEngineParseTest<ListPage<Address>> {
+
+ @Override
+ public String resource() {
+ return "/address_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListPage<Address> expected() {
+ return ListPage.<Address>builder()
+ .kind(Kind.ADDRESS_LIST)
+ .id("projects/myproject/regions/us-central1/addresses")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses"))
+ .items(ImmutableSet.of(new ParseAddressTest().expected(),
+ Address.builder()
+ .id("4881363978908129158")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-26T14:08:21.552-07:00"))
+ .status("RESERVED")
+ .region(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1"))
+ .name("test-ip2")
+ .description("")
+ .address("173.255.118.115")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip2"))
+ .build())
+ ).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressTest.java
new file mode 100644
index 0000000..dd3c3ed
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Address;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class ParseAddressTest extends BaseGoogleComputeEngineParseTest<Address> {
+
+ @Override
+ public String resource() {
+ return "/address_get.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Address expected() {
+ return Address.builder()
+ .id("4439373783165447583")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-26T13:57:20.204-07:00"))
+ .status("RESERVED")
+ .region(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1"))
+ .name("test-ip1")
+ .description("")
+ .address("173.255.115.190")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1"))
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskListTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskListTest.java
new file mode 100644
index 0000000..4e0cd43
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskListTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Disk;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Resource;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "unit")
+public class ParseDiskListTest extends BaseGoogleComputeEngineParseTest<ListPage<Disk>> {
+
+ @Override
+ public String resource() {
+ return "/disk_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListPage<Disk> expected() {
+ return ListPage.<Disk>builder()
+ .kind(Resource.Kind.DISK_LIST)
+ .id("projects/myproject/zones/us-central1-a/disks")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"))
+ .items(ImmutableSet.of(Disk.builder()
+ .id("13050421646334304115")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306"))
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
+ .name("testimage1")
+ .sizeGb(1)
+ .zone(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a"))
+ .status("READY")
+ .build())
+ ).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTest.java
new file mode 100644
index 0000000..fe4c2bc
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Disk;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class ParseDiskTest extends BaseGoogleComputeEngineParseTest<Disk> {
+
+ @Override
+ public String resource() {
+ return "/disk_get.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Disk expected() {
+ return Disk.builder()
+ .id("13050421646334304115")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306"))
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
+ .name("testimage1")
+ .sizeGb(1)
+ .zone(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"))
+ .status("READY")
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallListTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallListTest.java
new file mode 100644
index 0000000..a1fc159
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallListTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Resource;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "unit")
+public class ParseFirewallListTest extends BaseGoogleComputeEngineParseTest<ListPage<Firewall>> {
+
+ @Override
+ public String resource() {
+ return "/firewall_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListPage<Firewall> expected() {
+ return ListPage.<Firewall>builder()
+ .kind(Resource.Kind.FIREWALL_LIST)
+ .id("projects/google/firewalls")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/google/global/firewalls"))
+ .items(ImmutableSet.of(
+ new ParseFirewallTest().expected()
+ , Firewall.builder()
+ .id("12862241067393040785")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-04-13T03:05:04.365"))
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/google/global/firewalls/default-ssh"))
+ .name("default-ssh")
+ .description("SSH allowed from anywhere")
+ .network(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/google/global/networks/default"))
+ .addSourceRange("0.0.0.0/0")
+ .addAllowed(Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.TCP)
+ .addPort(22).build())
+ .build()
+ ))
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallTest.java
new file mode 100644
index 0000000..37fc794
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class ParseFirewallTest extends BaseGoogleComputeEngineParseTest<Firewall> {
+
+ @Override
+ public String resource() {
+ return "/firewall_get.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Firewall expected() {
+ return Firewall.builder()
+ .id("12862241031274216284")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-04-13T03:05:02.855"))
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test"))
+ .name("jclouds-test")
+ .description("Internal traffic from default allowed")
+ .network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"))
+ .addSourceRange("10.0.0.0/8")
+ .addAllowed(Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.TCP)
+ .addPortRange(1, 65535).build())
+ .addAllowed(Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.UDP)
+ .addPortRange(1, 65535).build())
+ .addAllowed(Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.ICMP).build())
+ .build();
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseImageListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseImageListTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseImageListTest.java
new file mode 100644
index 0000000..1a364f6
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/parse/ParseImageListTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.Deprecated;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Resource;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "unit")
+public class ParseImageListTest extends BaseGoogleComputeEngineParseTest<ListPage<Image>> {
+
+ @Override
+ public String resource() {
+ return "/image_list.json";
+ }
+
+ @Override
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ListPage<Image> expected() {
+ return ListPage.<Image>builder()
+ .kind(Resource.Kind.IMAGE_LIST)
+ .id("projects/centos-cloud/global/images")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images"))
+ .items(ImmutableSet.of(Image.builder()
+ .id("12941197498378735318")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-07-16T22:16:13.468"))
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120326"))
+ .name("centos-6-2-v20120326")
+ .description("DEPRECATED. CentOS 6.2 image; Created Mon, 26 Mar 2012 21:19:09 +0000")
+ .sourceType("RAW")
+ .deprecated(Deprecated.builder()
+ .state("DEPRECATED")
+ .replacement(URI.create("https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20130104"))
+ .build())
+ .rawDisk(
+ Image.RawDisk.builder()
+ .source("")
+ .containerType("TAR")
+ .build()
+ ).build()
+
+ ))
+ .build();
+ }
+}
[40/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java
new file mode 100644
index 0000000..885289f
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java
@@ -0,0 +1,574 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GCE_BOOT_DISK_SUFFIX;
+import static org.jclouds.googlecomputeengine.features.GlobalOperationApiExpectTest.GET_GLOBAL_OPERATION_REQUEST;
+import static org.jclouds.googlecomputeengine.features.GlobalOperationApiExpectTest.GET_GLOBAL_OPERATION_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_DEBIAN_IMAGES_REQUEST;
+import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_DEBIAN_IMAGES_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_CENTOS_IMAGES_REQUEST;
+import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_CENTOS_IMAGES_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_PROJECT_IMAGES_REQUEST;
+import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_PROJECT_IMAGES_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.InstanceApiExpectTest.LIST_CENTRAL1B_INSTANCES_REQUEST;
+import static org.jclouds.googlecomputeengine.features.InstanceApiExpectTest.LIST_CENTRAL1B_INSTANCES_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.InstanceApiExpectTest.LIST_INSTANCES_REQUEST;
+import static org.jclouds.googlecomputeengine.features.InstanceApiExpectTest.LIST_INSTANCES_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.MachineTypeApiExpectTest.LIST_CENTRAL1B_MACHINE_TYPES_REQUEST;
+import static org.jclouds.googlecomputeengine.features.MachineTypeApiExpectTest.LIST_CENTRAL1B_MACHINE_TYPES_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.MachineTypeApiExpectTest.LIST_MACHINE_TYPES_REQUEST;
+import static org.jclouds.googlecomputeengine.features.MachineTypeApiExpectTest.LIST_MACHINE_TYPES_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.NetworkApiExpectTest.GET_NETWORK_REQUEST;
+import static org.jclouds.googlecomputeengine.features.ProjectApiExpectTest.GET_PROJECT_REQUEST;
+import static org.jclouds.googlecomputeengine.features.ProjectApiExpectTest.GET_PROJECT_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.ZoneApiExpectTest.LIST_ZONES_REQ;
+import static org.jclouds.googlecomputeengine.features.ZoneApiExpectTest.LIST_ZONES_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.ZoneApiExpectTest.LIST_ZONES_SHORT_RESPONSE;
+import static org.jclouds.googlecomputeengine.features.ZoneOperationApiExpectTest.GET_ZONE_OPERATION_REQUEST;
+import static org.jclouds.googlecomputeengine.features.ZoneOperationApiExpectTest.GET_ZONE_OPERATION_RESPONSE;
+import static org.jclouds.util.Strings2.toStringAndClose;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.RunNodesException;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.domain.Location;
+import org.jclouds.googlecomputeengine.compute.options.GoogleComputeEngineTemplateOptions;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.features.InstanceApiExpectTest;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineServiceExpectTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.util.Strings2;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+
+@Test(groups = "unit")
+public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngineServiceExpectTest {
+
+
+ private HttpRequest INSERT_NETWORK_REQUEST = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/networks")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromStringWithContentType("{\"name\":\"jclouds-test\",\"IPv4Range\":\"10.0.0.0/8\"}",
+ MediaType.APPLICATION_JSON))
+ .build();
+
+ private HttpRequest INSERT_FIREWALL_REQUEST = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromStringWithContentType("{\"name\":\"jclouds-test\",\"network\":\"https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/jclouds-test\"," +
+ "\"sourceRanges\":[\"10.0.0.0/8\",\"0.0.0.0/0\"],\"sourceTags\":[\"aTag\"],\"allowed\":[{\"IPProtocol\":\"tcp\"," +
+ "\"ports\":[\"22\"]}," +
+ "{\"IPProtocol\":\"udp\",\"ports\":[\"22\"]}]}",
+ MediaType.APPLICATION_JSON))
+ .build();
+
+ private HttpResponse GET_NETWORK_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType("{\n" +
+ " \"kind\": \"compute#network\",\n" +
+ " \"id\": \"13024414170909937976\",\n" +
+ " \"creationTimestamp\": \"2012-10-24T20:13:19.967\",\n" +
+ " \"selfLink\": \"https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/jclouds-test\",\n" +
+ " \"name\": \"jclouds-test\",\n" +
+ " \"description\": \"test network\",\n" +
+ " \"IPv4Range\": \"10.0.0.0/8\",\n" +
+ " \"gatewayIPv4\": \"10.0.0.1\"\n" +
+ "}", MediaType.APPLICATION_JSON)).build();
+
+ private HttpResponse SUCESSFULL_OPERATION_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/operation.json")).build();
+
+ private HttpRequest SET_TAGS_REQUEST = HttpRequest.builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/setTags")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromStringWithContentType("{\"items\":[\"aTag\"],\"fingerprint\":\"abcd\"}",
+ MediaType.APPLICATION_JSON))
+ .build();
+
+ private HttpResponse SET_TAGS_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/operation.json")).build();
+
+ private HttpResponse getInstanceResponseForInstanceAndNetworkAndStatus(String instanceName, String networkName,
+ String status) throws
+ IOException {
+ return HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType(
+ replaceInstanceNameNetworkAndStatusOnResource("/instance_get.json",
+ instanceName, networkName, status),
+ "application/json")).build();
+ }
+
+ private HttpResponse getListInstancesResponseForSingleInstanceAndNetworkAndStatus(String instanceName,
+ String networkName,
+ String status) {
+ return HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType(
+ replaceInstanceNameNetworkAndStatusOnResource("/instance_list.json",
+ instanceName, networkName, status),
+ "application/json")).build();
+ }
+
+ private HttpResponse getDiskResponseForInstance(String instanceName) {
+ return HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType(
+ replaceDiskNameOnResource("/disk_get.json", instanceName + "-" + GCE_BOOT_DISK_SUFFIX),
+ "application/json")).build();
+ }
+
+ private String replaceDiskNameOnResource(String resourceName, String diskName) {
+ try {
+ return Strings2.toStringAndClose(this.getClass().getResourceAsStream(resourceName))
+ .replace("testimage1", diskName);
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ private String replaceInstanceNameNetworkAndStatusOnResource(String resourceName, String instanceName,
+ String networkName, String status) {
+ try {
+ return Strings2.toStringAndClose(this.getClass().getResourceAsStream(resourceName)).replace("test-0",
+ instanceName).replace("default", networkName).replace("RUNNING", status);
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ private HttpRequest createDiskRequestForInstance(String instanceName) {
+ return HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
+ + "?sourceImage=https%3A//www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140718")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromStringWithContentType("{\"name\":\"" + instanceName + "-" + GCE_BOOT_DISK_SUFFIX + "\","
+ + "\"sizeGb\":10}",
+ MediaType.APPLICATION_JSON)).build();
+ }
+
+ private HttpRequest getDiskRequestForInstance(String instanceName) {
+ return HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/"
+ + instanceName + "-" + GCE_BOOT_DISK_SUFFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+ }
+
+
+
+ private HttpRequest createInstanceRequestForInstance(String instanceName, String groupName,
+ String networkName, String publicKey) {
+ return HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromStringWithContentType("{\"name\":\"" + instanceName + "\"," +
+ "\"machineType\":\"https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/f1-micro\"," +
+ "\"serviceAccounts\":[]," +
+ "\"networkInterfaces\":[{\"network\":\"https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/" + networkName + "\"," +
+ "\"accessConfigs\":[{\"type\":\"ONE_TO_ONE_NAT\"}]}]," +
+ "\"disks\":[{\"mode\":\"READ_WRITE\",\"source\":\"https://www.googleapis.com/" +
+ "compute/v1/projects/myproject/zones/us-central1-a/disks/" + instanceName +
+ "-" + GCE_BOOT_DISK_SUFFIX + "\",\"deleteOnTerminate\":true,\"boot\":true,\"type\":\"PERSISTENT\"}]," +
+ "\"metadata\":{\"kind\":\"compute#metadata\",\"items\":[{\"key\":\"sshKeys\"," +
+ "\"value\":\"jclouds:" +
+ publicKey + " jclouds@localhost\"},{\"key\":\"jclouds-group\"," +
+ "\"value\":\"" + groupName + "\"},{\"key\":\"jclouds-image\",\"value\":\"https://www.googleapis" +
+ ".com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140718\"}," +
+ "{\"key\":\"jclouds-delete-boot-disk\",\"value\":\"true\"}]}}",
+ MediaType.APPLICATION_JSON)).build();
+ }
+
+ private HttpRequest getInstanceRequestForInstance(String instanceName) {
+ return HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/" + instanceName)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+ }
+
+
+ @Override
+ protected Properties setupProperties() {
+ Properties overrides = super.setupProperties();
+ overrides.put("google-compute-engine.identity", "myproject");
+ try {
+ overrides.put("google-compute-engine.credential", toStringAndClose(getClass().getResourceAsStream("/testpk.pem")));
+ } catch (IOException e) {
+ Throwables.propagate(e);
+ }
+ return overrides;
+ }
+
+ @Test(enabled = false)
+ public void testThrowsAuthorizationException() throws Exception {
+
+ Properties properties = new Properties();
+ properties.setProperty("oauth.identity", "MOMMA");
+ properties.setProperty("oauth.credential", "MiA");
+
+ ComputeService client = requestsSendResponses(ImmutableMap.<HttpRequest, HttpResponse>of(), createModule(),
+ properties);
+ Template template = client.templateBuilder().build();
+ Template toMatch = client.templateBuilder().imageId(template.getImage().getId()).build();
+ assertEquals(toMatch.getImage(), template.getImage());
+ }
+
+ @Test
+ public void testTemplateMatch() throws Exception {
+ ImmutableMap<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.
+ <HttpRequest, HttpResponse>builder()
+ .put(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE)
+ .put(GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE)
+ .put(LIST_ZONES_REQ, LIST_ZONES_RESPONSE)
+ .put(LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE)
+ .put(LIST_DEBIAN_IMAGES_REQUEST, LIST_DEBIAN_IMAGES_RESPONSE)
+ .put(LIST_CENTOS_IMAGES_REQUEST, LIST_CENTOS_IMAGES_RESPONSE)
+ .put(LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE)
+ .put(LIST_CENTRAL1B_MACHINE_TYPES_REQUEST, LIST_CENTRAL1B_MACHINE_TYPES_RESPONSE)
+ .build();
+
+ ComputeService client = requestsSendResponses(requestResponseMap);
+ Template template = client.templateBuilder().build();
+ Hardware defaultSize = client.templateBuilder().build().getHardware();
+
+ Hardware smallest = client.templateBuilder().smallest().build().getHardware();
+ assertEquals(defaultSize, smallest);
+
+ Hardware fastest = client.templateBuilder().fastest().build().getHardware();
+ assertNotNull(fastest);
+
+ assertEquals(client.listHardwareProfiles().size(), 5);
+
+ Template toMatch = client.templateBuilder()
+ .imageId(template.getImage().getId())
+ .build();
+ assertEquals(toMatch.getImage(), template.getImage());
+ }
+
+ @Test
+ public void testNetworksAndFirewallDeletedWhenAllGroupNodesAreTerminated() throws IOException {
+
+ HttpRequest deleteNodeRequest = HttpRequest.builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-delete-networks")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpRequest deleteFirewallRequest = HttpRequest.builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/firewalls/jclouds-test-delete")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpRequest getNetworkRequest = HttpRequest.builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/jclouds-test-delete")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse getNetworkResponse = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/GoogleComputeEngineServiceExpectTest/network_get.json")).build();
+
+ HttpRequest listFirewallsRequest = HttpRequest.builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/firewalls")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse listFirewallsResponse = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/GoogleComputeEngineServiceExpectTest/firewall_list.json")).build();
+
+ HttpRequest deleteNetworkReqquest = HttpRequest.builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/jclouds-test-delete")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpRequest deleteDiskRequest = HttpRequest.builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/test")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ List<HttpRequest> orderedRequests = ImmutableList.<HttpRequest>builder()
+ .add(requestForScopes(COMPUTE_READONLY_SCOPE))
+ .add(GET_PROJECT_REQUEST)
+ .add(getInstanceRequestForInstance("test-delete-networks"))
+ .add(LIST_ZONES_REQ)
+ .add(LIST_MACHINE_TYPES_REQUEST)
+ .add(LIST_PROJECT_IMAGES_REQUEST)
+ .add(LIST_DEBIAN_IMAGES_REQUEST)
+ .add(LIST_CENTOS_IMAGES_REQUEST)
+ .add(getInstanceRequestForInstance("test-delete-networks"))
+ .add(requestForScopes(COMPUTE_SCOPE))
+ .add(deleteNodeRequest)
+ .add(GET_ZONE_OPERATION_REQUEST)
+ .add(deleteDiskRequest)
+ .add(GET_ZONE_OPERATION_REQUEST)
+ .add(getInstanceRequestForInstance("test-delete-networks"))
+ .add(LIST_INSTANCES_REQUEST)
+ .add(getNetworkRequest)
+ .add(listFirewallsRequest)
+ .add(deleteFirewallRequest)
+ .add(GET_GLOBAL_OPERATION_REQUEST)
+ .add(deleteNetworkReqquest)
+ .add(GET_GLOBAL_OPERATION_REQUEST)
+ .build();
+
+
+ List<HttpResponse> orderedResponses = ImmutableList.<HttpResponse>builder()
+ .add(TOKEN_RESPONSE)
+ .add(GET_PROJECT_RESPONSE)
+ .add(getInstanceResponseForInstanceAndNetworkAndStatus("test-delete-networks", "test-network", Instance
+ .Status.RUNNING.name()))
+ .add(LIST_ZONES_SHORT_RESPONSE)
+ .add(LIST_MACHINE_TYPES_RESPONSE)
+ .add(LIST_PROJECT_IMAGES_RESPONSE)
+ .add(LIST_DEBIAN_IMAGES_RESPONSE)
+ .add(LIST_CENTOS_IMAGES_RESPONSE)
+ .add(getInstanceResponseForInstanceAndNetworkAndStatus("test-delete-networks", "test-network", Instance
+ .Status.RUNNING.name()))
+ .add(TOKEN_RESPONSE)
+ .add(SUCESSFULL_OPERATION_RESPONSE)
+ .add(GET_ZONE_OPERATION_RESPONSE)
+ .add(SUCESSFULL_OPERATION_RESPONSE)
+ .add(GET_ZONE_OPERATION_RESPONSE)
+ .add(getInstanceResponseForInstanceAndNetworkAndStatus("test-delete-networks", "test-network", Instance
+ .Status.TERMINATED.name()))
+ .add(getListInstancesResponseForSingleInstanceAndNetworkAndStatus("test-delete-networks",
+ "test-network", Instance
+ .Status.TERMINATED.name()))
+ .add(getNetworkResponse)
+ .add(listFirewallsResponse)
+ .add(SUCESSFULL_OPERATION_RESPONSE)
+ .add(GET_GLOBAL_OPERATION_RESPONSE)
+ .add(SUCESSFULL_OPERATION_RESPONSE)
+ .add(GET_GLOBAL_OPERATION_RESPONSE)
+ .build();
+
+ ComputeService client = orderedRequestsSendResponses(orderedRequests, orderedResponses);
+ client.destroyNode("us-central1-a/test-delete-networks");
+
+ }
+
+ public void testListLocationsWhenResponseIs2xx() throws Exception {
+
+ ImmutableMap<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.
+ <HttpRequest, HttpResponse>builder()
+ .put(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE)
+ .put(GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE)
+ .put(LIST_ZONES_REQ, LIST_ZONES_RESPONSE)
+ .put(LIST_INSTANCES_REQUEST, LIST_INSTANCES_RESPONSE)
+ .put(LIST_CENTRAL1B_INSTANCES_REQUEST, LIST_CENTRAL1B_INSTANCES_RESPONSE)
+ .put(LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE)
+ .put(LIST_DEBIAN_IMAGES_REQUEST, LIST_DEBIAN_IMAGES_RESPONSE)
+ .put(LIST_CENTOS_IMAGES_REQUEST, LIST_CENTOS_IMAGES_RESPONSE)
+ .put(LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE)
+ .put(LIST_CENTRAL1B_MACHINE_TYPES_REQUEST, LIST_CENTRAL1B_MACHINE_TYPES_RESPONSE)
+ .build();
+
+ ComputeService apiWhenServersExist = requestsSendResponses(requestResponseMap);
+
+ Set<? extends Location> locations = apiWhenServersExist.listAssignableLocations();
+
+ assertNotNull(locations);
+ assertEquals(locations.size(), 2);
+ assertEquals(locations.iterator().next().getId(), "us-central1-a");
+
+ assertNotNull(apiWhenServersExist.listNodes());
+ assertEquals(apiWhenServersExist.listNodes().size(), 1);
+ assertEquals(apiWhenServersExist.listNodes().iterator().next().getId(), "us-central1-a/test-0");
+ assertEquals(apiWhenServersExist.listNodes().iterator().next().getName(), "test-0");
+ }
+
+ @Test(dependsOnMethods = "testListLocationsWhenResponseIs2xx")
+ public void testCreateNodeWhenNetworkNorFirewallExistDoesNotExist() throws RunNodesException, IOException {
+
+
+ String payload = Strings2.toStringAndClose(InstanceApiExpectTest.class.getResourceAsStream("/instance_get.json"));
+ payload = payload.replace("test-0", "test-1");
+
+ HttpResponse getInstanceResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType(payload, "application/json")).build();
+
+ HttpRequest getFirewallRequest = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/firewalls/jclouds-test-port-22")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpRequest insertFirewallRequest = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromStringWithContentType("{\"name\":\"jclouds-test-port-22\",\"network\":\"https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/jclouds-test\"," +
+ "\"sourceRanges\":[\"10.0.0.0/8\",\"0.0.0.0/0\"],\"sourceTags\":[\"aTag\"],\"targetTags\":[\"jclouds-test-port-22\"],\"allowed\":[{\"IPProtocol\":\"tcp\"," +
+ "\"ports\":[\"22\"]}," +
+ "{\"IPProtocol\":\"udp\",\"ports\":[\"22\"]}]}",
+ MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpRequest setTagsRequest = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/setTags")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromStringWithContentType("{\"items\":[\"jclouds-test-port-22\"],\"fingerprint\":\"abcd\"}",
+ MediaType.APPLICATION_JSON))
+ .build();
+
+ List<HttpRequest> orderedRequests = ImmutableList.<HttpRequest>builder()
+ .add(requestForScopes(COMPUTE_READONLY_SCOPE))
+ .add(GET_PROJECT_REQUEST)
+ .add(LIST_ZONES_REQ)
+ .add(LIST_PROJECT_IMAGES_REQUEST)
+ .add(LIST_DEBIAN_IMAGES_REQUEST)
+ .add(LIST_CENTOS_IMAGES_REQUEST)
+ .add(LIST_ZONES_REQ)
+ .add(LIST_MACHINE_TYPES_REQUEST)
+ .add(GET_NETWORK_REQUEST)
+ .add(GET_NETWORK_REQUEST)
+ .add(requestForScopes(COMPUTE_SCOPE))
+ .add(INSERT_NETWORK_REQUEST)
+ .add(GET_GLOBAL_OPERATION_REQUEST)
+ .add(GET_NETWORK_REQUEST)
+ .add(getFirewallRequest)
+ .add(insertFirewallRequest)
+ .add(GET_GLOBAL_OPERATION_REQUEST)
+ .add(LIST_INSTANCES_REQUEST)
+ .add(LIST_MACHINE_TYPES_REQUEST)
+ .add(LIST_PROJECT_IMAGES_REQUEST)
+ .add(LIST_DEBIAN_IMAGES_REQUEST)
+ .add(LIST_CENTOS_IMAGES_REQUEST)
+ .add(createDiskRequestForInstance("test-1"))
+ .add(GET_ZONE_OPERATION_REQUEST)
+ .add(getDiskRequestForInstance("test-1"))
+ .add(createInstanceRequestForInstance("test-1", "test", "jclouds-test", openSshKey))
+ .add(GET_ZONE_OPERATION_REQUEST)
+ .add(getInstanceRequestForInstance("test-1"))
+ .add(SET_TAGS_REQUEST)
+ .add(GET_ZONE_OPERATION_REQUEST)
+ .add(getInstanceRequestForInstance("test-1"))
+ .add(setTagsRequest)
+ .add(LIST_PROJECT_IMAGES_REQUEST)
+ .add(LIST_DEBIAN_IMAGES_REQUEST)
+ .add(LIST_CENTOS_IMAGES_REQUEST)
+ .add(setTagsRequest)
+ .build();
+
+ List<HttpResponse> orderedResponses = ImmutableList.<HttpResponse>builder()
+ .add(TOKEN_RESPONSE)
+ .add(GET_PROJECT_RESPONSE)
+ .add(LIST_ZONES_SHORT_RESPONSE)
+ .add(LIST_PROJECT_IMAGES_RESPONSE)
+ .add(LIST_DEBIAN_IMAGES_RESPONSE)
+ .add(LIST_CENTOS_IMAGES_RESPONSE)
+ .add(LIST_ZONES_SHORT_RESPONSE)
+ .add(LIST_MACHINE_TYPES_RESPONSE)
+ .add(HttpResponse.builder().statusCode(404).build())
+ .add(HttpResponse.builder().statusCode(404).build())
+ .add(TOKEN_RESPONSE)
+ .add(SUCESSFULL_OPERATION_RESPONSE)
+ .add(GET_GLOBAL_OPERATION_RESPONSE)
+ .add(GET_NETWORK_RESPONSE)
+ .add(HttpResponse.builder().statusCode(404).build())
+ .add(SUCESSFULL_OPERATION_RESPONSE)
+ .add(GET_GLOBAL_OPERATION_RESPONSE)
+ .add(LIST_INSTANCES_RESPONSE)
+ .add(LIST_MACHINE_TYPES_RESPONSE)
+ .add(LIST_PROJECT_IMAGES_RESPONSE)
+ .add(LIST_DEBIAN_IMAGES_RESPONSE)
+ .add(LIST_CENTOS_IMAGES_RESPONSE)
+ .add(SUCESSFULL_OPERATION_RESPONSE)
+ .add(GET_ZONE_OPERATION_RESPONSE)
+ .add(getDiskResponseForInstance("test-1"))
+ .add(SUCESSFULL_OPERATION_RESPONSE)
+ .add(GET_ZONE_OPERATION_RESPONSE)
+ .add(getInstanceResponse)
+ .add(SET_TAGS_RESPONSE)
+ .add(GET_ZONE_OPERATION_RESPONSE)
+ .add(getInstanceResponse)
+ .add(SUCESSFULL_OPERATION_RESPONSE)
+ .add(LIST_PROJECT_IMAGES_RESPONSE)
+ .add(LIST_DEBIAN_IMAGES_RESPONSE)
+ .add(LIST_CENTOS_IMAGES_RESPONSE)
+ .add(SUCESSFULL_OPERATION_RESPONSE)
+ .build();
+
+
+ ComputeService computeService = orderedRequestsSendResponses(orderedRequests, orderedResponses);
+
+ GoogleComputeEngineTemplateOptions options = computeService.templateOptions().as(GoogleComputeEngineTemplateOptions.class);
+ options.tags(ImmutableSet.of("aTag"));
+ NodeMetadata node = getOnlyElement(computeService.createNodesInGroup("test", 1, options));
+ assertEquals(node.getImageId(), "debian-7-wheezy-v20140718");
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
new file mode 100644
index 0000000..2011d2d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute;
+
+import static com.google.common.collect.Iterables.contains;
+import static org.jclouds.oauth.v2.OAuthTestUtils.setCredential;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import java.util.Properties;
+import java.util.Set;
+
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.MachineType;
+import org.jclouds.oauth.v2.config.CredentialType;
+import org.jclouds.oauth.v2.config.OAuthProperties;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Key;
+import com.google.inject.Module;
+import com.google.inject.TypeLiteral;
+
+@Test(groups = "live", singleThreaded = true)
+public class GoogleComputeEngineServiceLiveTest extends BaseComputeServiceLiveTest {
+
+ protected static final String DEFAULT_ZONE_NAME = "us-central1-a";
+
+ public GoogleComputeEngineServiceLiveTest() {
+ provider = "google-compute-engine";
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties props = super.setupProperties();
+ if (!System.getProperty(OAuthProperties.CREDENTIAL_TYPE, "")
+ .equalsIgnoreCase(CredentialType.BEARER_TOKEN_CREDENTIALS.toString())) {
+ setCredential(props, provider + ".credential");
+ }
+ return props;
+ }
+
+ public void testListHardwareProfiles() throws Exception {
+ GoogleComputeEngineApi api = client.getContext().unwrapApi(GoogleComputeEngineApi.class);
+ Supplier<String> userProject = context.utils().injector().getInstance(Key.get(new TypeLiteral<Supplier<String>>() {
+ }, UserProject.class));
+ ImmutableSet.Builder<String> deprecatedMachineTypes = ImmutableSet.builder();
+ for (MachineType machine : api.getMachineTypeApiForProject(userProject.get())
+ .listInZone(DEFAULT_ZONE_NAME).concat()) {
+ if (machine.getDeprecated().isPresent()) {
+ deprecatedMachineTypes.add(machine.getId());
+ }
+ }
+ ImmutableSet<String> deprecatedMachineTypeIds = deprecatedMachineTypes.build();
+ Set<? extends Hardware> hardwareProfiles = client.listHardwareProfiles();
+ System.out.println(hardwareProfiles.size());
+ for (Hardware hardwareProfile : hardwareProfiles) {
+ System.out.println(hardwareProfile);
+ assertFalse(contains(deprecatedMachineTypeIds, hardwareProfile.getId()));
+ }
+ }
+
+ /**
+ * Nodes may have additional metadata entries (particularly they may have an "sshKeys" entry)
+ */
+ protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
+ assertTrue(node.getUserMetadata().keySet().containsAll(userMetadata.keySet()));
+ }
+
+ // do not run until the auth exception problem is figured out.
+ @Test(enabled = false)
+ @Override
+ public void testCorrectAuthException() throws Exception {
+ }
+
+ // reboot is not supported by GCE
+ @Test(enabled = true, dependsOnMethods = "testGet")
+ public void testReboot() throws Exception {
+ }
+
+ // suspend/Resume is not supported by GCE
+ @Test(enabled = true, dependsOnMethods = "testReboot")
+ public void testSuspendResume() throws Exception {
+ }
+
+ @Test(enabled = true, dependsOnMethods = "testSuspendResume")
+ public void testListNodesByIds() throws Exception {
+ super.testGetNodesWithDetails();
+ }
+
+ @Test(enabled = true, dependsOnMethods = "testSuspendResume")
+ @Override
+ public void testGetNodesWithDetails() throws Exception {
+ super.testGetNodesWithDetails();
+ }
+
+ @Test(enabled = true, dependsOnMethods = "testSuspendResume")
+ @Override
+ public void testListNodes() throws Exception {
+ super.testListNodes();
+ }
+
+ @Test(enabled = true, dependsOnMethods = {"testListNodes", "testGetNodesWithDetails", "testListNodesByIds"})
+ @Override
+ public void testDestroyNodes() {
+ super.testDestroyNodes();
+ }
+
+ @Override
+ protected Module getSshModule() {
+ return new SshjSshClientModule();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtensionLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtensionLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtensionLiveTest.java
new file mode 100644
index 0000000..588ef51
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtensionLiveTest.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.extensions;
+
+import org.jclouds.compute.extensions.internal.BaseSecurityGroupExtensionLiveTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "live", singleThreaded = true, testName = "GoogleComputeEngineSecurityGroupExtensionLiveTest")
+public class GoogleComputeEngineSecurityGroupExtensionLiveTest extends BaseSecurityGroupExtensionLiveTest {
+
+ public GoogleComputeEngineSecurityGroupExtensionLiveTest() {
+ provider = "google-compute-engine";
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FirewallToIpPermissionTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FirewallToIpPermissionTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FirewallToIpPermissionTest.java
new file mode 100644
index 0000000..62f9260
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FirewallToIpPermissionTest.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.Date;
+
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+
+public class FirewallToIpPermissionTest {
+
+ @Test
+ public void testApply() {
+
+ Firewall fw = fwForTest();
+
+ FirewallToIpPermission converter = new FirewallToIpPermission();
+
+ Iterable<IpPermission> perms = converter.apply(fw);
+
+ assertEquals(Iterables.size(perms), 3, "There should be three IpPermissions but there is only " + Iterables.size(perms));
+
+ assertTrue(Iterables.any(perms, Predicates.and(hasProtocol(IpProtocol.TCP),
+ hasStartAndEndPort(1, 10))), "No permission found for TCP, ports 1-10");
+ assertTrue(Iterables.any(perms, Predicates.and(hasProtocol(IpProtocol.TCP),
+ hasStartAndEndPort(33, 33))), "No permission found for TCP, port 33");
+ assertTrue(Iterables.any(perms, hasProtocol(IpProtocol.ICMP)),
+ "No permission found for ICMP");
+ }
+
+ public static Firewall fwForTest() {
+ Firewall.Builder builder = Firewall.builder();
+
+ builder.addSourceRange("0.0.0.0/0");
+ builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.TCP)
+ .addPortRange(1, 10).build());
+ builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.TCP)
+ .addPort(33).build());
+ builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.ICMP).build());
+ builder.id("abcd");
+ builder.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test"));
+ builder.network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
+ builder.creationTimestamp(new Date());
+ builder.name("jclouds-test");
+
+ return builder.build();
+ }
+
+ public static Predicate<IpPermission> hasProtocol(final IpProtocol protocol) {
+ return new Predicate<IpPermission>() {
+
+ @Override
+ public boolean apply(IpPermission perm) {
+ return protocol.equals(perm.getIpProtocol());
+ }
+ };
+ }
+
+ public static Predicate<IpPermission> hasStartAndEndPort(final int startPort, final int endPort) {
+ return new Predicate<IpPermission>() {
+
+ @Override
+ public boolean apply(IpPermission perm) {
+ return startPort == perm.getFromPort() && endPort == perm.getToPort();
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.java
new file mode 100644
index 0000000..3bdd87e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.testng.annotations.Test;
+
+import java.net.URI;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertSame;
+
+@Test(groups = "unit")
+public class GoogleComputeEngineImageToImageTest {
+
+ Image.Builder imageBuilder = Image.builder()
+ .id("1234")
+ .selfLink(URI.create("http://test.com"))
+ .sourceType("RAW")
+ .description("")
+ .rawDisk(Image.RawDisk.builder().source("").containerType("TAR").build());
+
+ // This unit tests is failing randomly with the following error:
+ // java.lang.AssertionError: expected [linux] but found [ubuntu]
+ // Therefore commented to avoid the build failure
+
+// public void testArbitratyImageName() {
+// GoogleComputeEngineImageToImage imageToImage = new GoogleComputeEngineImageToImage();
+// Image image = imageBuilder.name("arbitratyname").build();
+// org.jclouds.compute.domain.Image transformed = imageToImage.apply(image);
+// assertEquals(transformed.getName(), image.getName());
+// assertEquals(transformed.getId(), image.getName());
+// assertEquals(transformed.getProviderId(), image.getId());
+// assertSame(transformed.getOperatingSystem().getFamily(), OsFamily.LINUX);
+// }
+
+ public void testWellFormedImageName() {
+ GoogleComputeEngineImageToImage imageToImage = new GoogleComputeEngineImageToImage();
+ Image image = imageBuilder.name("ubuntu-12-04-v123123").build();
+ org.jclouds.compute.domain.Image transformed = imageToImage.apply(image);
+ assertEquals(transformed.getName(), image.getName());
+ assertEquals(transformed.getId(), image.getName());
+ assertEquals(transformed.getProviderId(), image.getId());
+ assertSame(transformed.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
+ assertEquals(transformed.getOperatingSystem().getVersion(), "12.04");
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadataTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadataTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadataTest.java
new file mode 100644
index 0000000..040f118
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadataTest.java
@@ -0,0 +1,285 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import static org.easymock.EasyMock.createMock;
+import static org.testng.Assert.assertEquals;
+import static org.jclouds.compute.domain.Image.Status.AVAILABLE;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.HardwareBuilder;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.ImageBuilder;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.domain.Processor;
+import org.jclouds.compute.domain.Volume.Type;
+import org.jclouds.compute.domain.VolumeBuilder;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.InstanceInZone;
+import org.jclouds.googlecomputeengine.domain.Metadata;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
+
+@Test(groups = "unit", testName = "InstanceInZoneToNodeMetadataTest")
+public class InstanceInZoneToNodeMetadataTest {
+
+ /**
+ * GroupNamingConvention that always returns the same name provided in the constructor.
+ * The predicates returned always evaluate to true.
+ *
+ */
+ class FixedGroupNamingConvention implements GroupNamingConvention {
+ private final String name;
+
+ public FixedGroupNamingConvention(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String sharedNameForGroup(final String group) {
+ return name;
+ }
+
+ @Override
+ public String uniqueNameForGroup(final String group) {
+ return name;
+ }
+
+ @Override
+ public String groupInUniqueNameOrNull(final String encoded) {
+ return name;
+ }
+
+ @Override
+ public String groupInSharedNameOrNull(final String encoded) {
+ return name;
+ }
+
+ @Override
+ public Predicate<String> containsGroup(final String group) {
+ return new Predicate<String>() {
+ @Override
+ public boolean apply(final String input) {
+ return true;
+ }
+ };
+ }
+
+ @Override
+ public Predicate<String> containsAnyGroup() {
+ return new Predicate<String>() {
+ @Override
+ public boolean apply(final String input) {
+ return true;
+ }
+ };
+ }
+
+ @Override
+ public String extractGroup(final String encoded) {
+ return name;
+ }
+ }
+
+ private Instance instance;
+
+ private Set<Hardware> hardwares;
+
+ private Set<Image> images;
+
+ private Set<Location> locations;
+
+ private InstanceInZoneToNodeMetadata groupGroupNodeParser;
+ private InstanceInZoneToNodeMetadata groupNullNodeParser;
+
+ @BeforeMethod
+ public final void setup() {
+ instance = Instance.builder()
+ .id("13051190678907570425")
+ .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T23:48:20.758"))
+ .selfLink(URI.create("https://www.googleapis"
+ + ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-0"))
+ .description("desc")
+ .name("test-0")
+ .machineType(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/"
+ + "machineTypes/n1-standard-1"))
+ .status(Instance.Status.RUNNING)
+ .zone(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"))
+ .addNetworkInterface(
+ Instance.NetworkInterface.builder()
+ .name("nic0")
+ .networkIP("10.240.121.115")
+ .network(URI.create("https://www.googleapis"
+ + ".com/compute/v1/projects/myproject/global/networks/default"))
+ .build())
+ .addDisk(
+ Instance.PersistentAttachedDisk.builder()
+ .index(0)
+ .mode(Instance.PersistentAttachedDisk.Mode.READ_WRITE)
+ .deviceName("test")
+ .source(URI.create("https://www.googleapis"
+ + ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/test"))
+ .boot(true)
+ .build())
+ .tags(Instance.Tags.builder().fingerprint("abcd").addItem("aTag").addItem("Group-port-42").build())
+ .metadata(Metadata.builder()
+ .items(ImmutableMap.of("aKey", "aValue",
+ "jclouds-image",
+ "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140718",
+ "jclouds-delete-boot-disk", "true"))
+ .fingerprint("efgh")
+ .build())
+ .addServiceAccount(Instance.ServiceAccount.builder().email("default").addScopes("myscope").build())
+ .build();
+
+ images = ImmutableSet.of(new ImageBuilder()
+ .id("1")
+ .uri(URI.create("https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140718"))
+ .providerId("1")
+ .name("mock image")
+ .status(AVAILABLE)
+ .operatingSystem(
+ OperatingSystem.builder().name("Ubuntu 14.04 x86_64").description("Ubuntu").family(OsFamily.UBUNTU)
+ .version("10.04").arch("x86_64").is64Bit(true).build()).build());
+
+ hardwares = ImmutableSet.of(new HardwareBuilder().id("my_id")
+ .uri(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/"
+ + "n1-standard-1"))
+ .providerId("1")
+ .name("mock hardware").processor(new Processor(1.0, 1.0)).ram(2048)
+ .volume(new VolumeBuilder().size(20f).type(Type.LOCAL).build()).build());
+
+ locations = ImmutableSet.of(new LocationBuilder()
+ .id("id")
+ .description("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a")
+ .scope(LocationScope.REGION)
+ .parent(
+ new LocationBuilder().id("0").description("mock parent location").scope(LocationScope.PROVIDER)
+ .build()).build());
+
+ groupGroupNodeParser = createNodeParser(hardwares, images, locations, "Group");
+ groupNullNodeParser = createNodeParser(hardwares, images, locations, null);
+ }
+
+ private InstanceInZoneToNodeMetadata createNodeParser(final Set<Hardware> hardware, final Set<Image> images,
+ final Set<Location> locations, final String groupName) {
+ Supplier<Map<URI, ? extends Location>> locationSupplier = new Supplier<Map<URI, ? extends Location>>() {
+ @Override
+ public Map<URI, ? extends Location> get() {
+ return Maps.uniqueIndex(locations, new Function<Location, URI>() {
+ @Override
+ public URI apply(final Location input) {
+ return URI.create(input.getDescription());
+ }
+ });
+ }
+ };
+
+ Supplier<Map<URI, ? extends Hardware>> hardwareSupplier = new Supplier<Map<URI, ? extends Hardware>>() {
+ @Override
+ public Map<URI, ? extends Hardware> get() {
+ return Maps.uniqueIndex(hardware, new Function<Hardware, URI>() {
+ @Override
+ public URI apply(final Hardware input) {
+ return input.getUri();
+ }
+ });
+ }
+ };
+
+ Supplier<Map<URI, ? extends Image>> imageSupplier = new Supplier<Map<URI, ? extends Image>>() {
+ @Override
+ public Map<URI, ? extends Image> get() {
+ return Maps.uniqueIndex(images, new Function<Image, URI>() {
+ @Override
+ public URI apply(final Image input) {
+ return input.getUri();
+ }
+ });
+ }
+ };
+
+ Supplier<String> userProjectSupplier = new Supplier<String>() {
+ @Override
+ public String get() {
+ return "userProject";
+ }
+ };
+
+ GroupNamingConvention.Factory namingConventionFactory =
+ new GroupNamingConvention.Factory() {
+ @Override
+ public GroupNamingConvention createWithoutPrefix() {
+ return new FixedGroupNamingConvention(groupName);
+ }
+
+ @Override
+ public GroupNamingConvention create() {
+ return new FixedGroupNamingConvention(groupName);
+ }
+ };
+
+ return new InstanceInZoneToNodeMetadata(
+ ImmutableMap.<Instance.Status, NodeMetadata.Status>builder()
+ .put(Instance.Status.RUNNING, NodeMetadata.Status.PENDING).build(),
+ namingConventionFactory,
+ imageSupplier,
+ hardwareSupplier,
+ locationSupplier,
+ new FirewallTagNamingConvention.Factory(namingConventionFactory),
+ createMock(GoogleComputeEngineApi.class),
+ userProjectSupplier);
+ }
+
+ @Test
+ public final void testTagFilteringWorks() {
+ InstanceInZone instanceInZone = new InstanceInZone(instance, "zoneId");
+ NodeMetadata nodeMetadata = groupGroupNodeParser.apply(instanceInZone);
+ assertEquals(nodeMetadata.getId(), "id/test-0");
+ assertEquals(nodeMetadata.getTags(), ImmutableSet.<String>of(
+ "aTag" // "aTag" kept as a non firewall tag.
+ // "Group-port-42" filtered out as a firewall tag.
+ ));
+ }
+
+ @Test
+ public final void testInstanceWithGroupNull() {
+ InstanceInZone instanceInZone = new InstanceInZone(instance, "zoneId");
+ NodeMetadata nodeMetadata = groupNullNodeParser.apply(instanceInZone);
+ assertEquals(nodeMetadata.getId(), "id/test-0");
+ assertEquals(nodeMetadata.getTags(), ImmutableSet.<String>of("aTag", "Group-port-42"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
new file mode 100644
index 0000000..795c989
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.jclouds.googlecomputeengine.compute.functions.FirewallToIpPermissionTest.hasProtocol;
+import static org.jclouds.googlecomputeengine.compute.functions.FirewallToIpPermissionTest.hasStartAndEndPort;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.Date;
+
+import org.jclouds.collect.IterableWithMarkers;
+import org.jclouds.collect.PagedIterables;
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.features.FirewallApi;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.googlecomputeengine.options.ListOptions.Builder;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicates;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+public class NetworkToSecurityGroupTest {
+
+ @Test
+ public void testApply() {
+ Supplier<String> projectSupplier = new Supplier<String>() {
+ @Override
+ public String get() {
+ return "myproject";
+ }
+ };
+
+ FirewallToIpPermission fwToPerm = new FirewallToIpPermission();
+
+ GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
+ FirewallApi fwApi = createMock(FirewallApi.class);
+
+ ListOptions options = new Builder().filter("network eq .*/jclouds-test");
+ expect(api.getFirewallApiForProject(projectSupplier.get()))
+ .andReturn(fwApi);
+ expect(fwApi.list(options)).andReturn(PagedIterables.of(IterableWithMarkers.from(ImmutableSet.of(FirewallToIpPermissionTest.fwForTest()))));
+
+ replay(api, fwApi);
+ Network.Builder builder = Network.builder();
+
+ builder.id("abcd");
+ builder.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
+ builder.creationTimestamp(new Date());
+ builder.description("some description");
+ builder.gatewayIPv4("1.2.3.4");
+ builder.IPv4Range("0.0.0.0/0");
+ builder.name("jclouds-test");
+
+ Network network = builder.build();
+
+ NetworkToSecurityGroup netToSg = new NetworkToSecurityGroup(fwToPerm, api, projectSupplier);
+
+ SecurityGroup group = netToSg.apply(network);
+
+ assertEquals(group.getId(), "jclouds-test");
+ assertEquals(group.getUri(), URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
+ assertEquals(group.getIpPermissions().size(), 3);
+ assertTrue(Iterables.any(group.getIpPermissions(), Predicates.and(hasProtocol(IpProtocol.TCP),
+ hasStartAndEndPort(1, 10))), "No permission found for TCP, ports 1-10");
+ assertTrue(Iterables.any(group.getIpPermissions(), Predicates.and(hasProtocol(IpProtocol.TCP),
+ hasStartAndEndPort(33, 33))), "No permission found for TCP, port 33");
+ assertTrue(Iterables.any(group.getIpPermissions(), hasProtocol(IpProtocol.ICMP)),
+ "No permission found for ICMP");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java
new file mode 100644
index 0000000..cae3432
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.easymock.EasyMock;
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.domain.ComputeMetadata;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.internal.NodeMetadataImpl;
+import org.jclouds.googlecomputeengine.compute.predicates.AllNodesInGroupTerminated;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+public class OrphanedGroupsFromDeadNodesTest {
+
+ private static class IdAndGroupOnlyNodeMetadata extends NodeMetadataImpl {
+
+ public IdAndGroupOnlyNodeMetadata(String id, String group, Status status) {
+ super(null, null, id, null, null, ImmutableMap.<String, String>of(), ImmutableSet.<String>of(), group, null,
+ null, null, status, null, 0, ImmutableSet.<String>of(), ImmutableSet.<String>of(), null, null);
+ }
+ }
+
+
+ @Test
+ public void testDetectsAllOrphanedGroupsWhenAllNodesTerminated() {
+
+ Set<? extends NodeMetadata> deadNodesGroup1 = (Set) ImmutableSet.builder()
+ .add(new IdAndGroupOnlyNodeMetadata("a", "1", NodeMetadata.Status.TERMINATED)).build();
+
+ Set<? extends NodeMetadata> deadNodesGroup2 = (Set) ImmutableSet.builder()
+ .add(new IdAndGroupOnlyNodeMetadata("b", "2", NodeMetadata.Status.TERMINATED)).build();
+
+ Set<? extends NodeMetadata> allDeadNodes = Sets.union(deadNodesGroup1, deadNodesGroup2);
+
+ ComputeService mock = createMock(ComputeService.class);
+ expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
+ .andReturn((Set) deadNodesGroup1).once();
+ expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
+ .andReturn((Set) deadNodesGroup2).once();
+
+ replay(mock);
+
+ OrphanedGroupsFromDeadNodes orphanedGroupsFromDeadNodes = new OrphanedGroupsFromDeadNodes(new
+ AllNodesInGroupTerminated(mock));
+
+ Set<String> orphanedGroups = orphanedGroupsFromDeadNodes.apply(allDeadNodes);
+
+ assertSame(orphanedGroups.size(), 2);
+ assertTrue(orphanedGroups.contains("1"));
+ assertTrue(orphanedGroups.contains("2"));
+ }
+
+ @Test
+ public void testDetectsAllOrphanedGroupsWhenSomeNodesTerminatedAndOtherMissing() {
+
+ Set<? extends NodeMetadata> deadNodesGroup1 = (Set) ImmutableSet.builder()
+ .add(new IdAndGroupOnlyNodeMetadata("a", "1", NodeMetadata.Status.TERMINATED)).build();
+
+ Set<? extends NodeMetadata> deadNodesGroup2 = (Set) ImmutableSet.builder()
+ .add(new IdAndGroupOnlyNodeMetadata("b", "2", NodeMetadata.Status.TERMINATED)).build();
+
+ Set<? extends NodeMetadata> allDeadNodes = Sets.union(deadNodesGroup1, deadNodesGroup2);
+
+ ComputeService mock = createMock(ComputeService.class);
+ expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
+ .andReturn((Set) deadNodesGroup1).once();
+ expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
+ .andReturn((Set) ImmutableSet.of()).once();
+
+ replay(mock);
+
+ OrphanedGroupsFromDeadNodes orphanedGroupsFromDeadNodes = new OrphanedGroupsFromDeadNodes(new
+ AllNodesInGroupTerminated(mock));
+
+ Set<String> orphanedGroups = orphanedGroupsFromDeadNodes.apply(allDeadNodes);
+
+ assertSame(orphanedGroups.size(), 2);
+ assertTrue(orphanedGroups.contains("1"));
+ assertTrue(orphanedGroups.contains("2"));
+ }
+
+ @Test
+ public void testDetectsAllOrphanedGroupsWhenSomeNodesAreAlive() {
+
+ Set<? extends NodeMetadata> deadNodesGroup1 = (Set) ImmutableSet.builder()
+ .add(new IdAndGroupOnlyNodeMetadata("a", "1", NodeMetadata.Status.TERMINATED)).build();
+
+ Set<? extends NodeMetadata> deadNodesGroup2 = (Set) ImmutableSet.builder()
+ .add(new IdAndGroupOnlyNodeMetadata("b", "2", NodeMetadata.Status.RUNNING)).build();
+
+ Set<? extends NodeMetadata> allDeadNodes = Sets.union(deadNodesGroup1, deadNodesGroup2);
+
+ ComputeService mock = createMock(ComputeService.class);
+ expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
+ .andReturn((Set) deadNodesGroup1).once();
+ expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
+ .andReturn((Set) deadNodesGroup2).once();
+
+ replay(mock);
+
+ OrphanedGroupsFromDeadNodes orphanedGroupsFromDeadNodes = new OrphanedGroupsFromDeadNodes(new
+ AllNodesInGroupTerminated(mock));
+
+ Set<String> orphanedGroups = orphanedGroupsFromDeadNodes.apply(allDeadNodes);
+
+ assertSame(orphanedGroups.size(), 1);
+ assertTrue(orphanedGroups.contains("1"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/FindNetworkOrCreateTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/FindNetworkOrCreateTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/FindNetworkOrCreateTest.java
new file mode 100644
index 0000000..467995f
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/FindNetworkOrCreateTest.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.loaders;
+
+import static com.google.common.base.Optional.fromNullable;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.internal.NetworkAndAddressRange;
+import org.jclouds.googlecomputeengine.features.GlobalOperationApi;
+import org.jclouds.googlecomputeengine.features.NetworkApi;
+import org.jclouds.googlecomputeengine.functions.CreateNetworkIfNeeded;
+import org.jclouds.googlecomputeengine.predicates.GlobalOperationDonePredicate;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.LoadingCache;
+
+public class FindNetworkOrCreateTest {
+
+ @Test
+ public void testLoadExisting() {
+ final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
+ final NetworkApi nwApi = createMock(NetworkApi.class);
+
+ Network network = Network.builder().IPv4Range("0.0.0.0/0")
+ .id("abcd").name("this-network")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
+ .build();
+
+ final Supplier<String> userProject = new Supplier<String>() {
+ @Override
+ public String get() {
+ return "myproject";
+ }
+ };
+
+ expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
+
+ expect(nwApi.get("this-network")).andReturn(network);
+
+ replay(api, nwApi);
+
+ NetworkAndAddressRange input = new NetworkAndAddressRange("this-network", "0.0.0.0/0", null);
+
+ GlobalOperationDonePredicate pred = new GlobalOperationDonePredicate(api, userProject);
+
+ CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, userProject, pred, 100l, 100l);
+
+ FindNetworkOrCreate loader = new FindNetworkOrCreate(api, creator, userProject);
+
+ LoadingCache<NetworkAndAddressRange, Network> cache = CacheBuilder.newBuilder().build(loader);
+
+ assertEquals(cache.getUnchecked(input), network);
+
+ // Second call is to ensure we only need to make the API calls once.
+ assertEquals(cache.getUnchecked(input), network);
+
+ verify(api, nwApi);
+ }
+
+ @Test
+ public void testLoadNew() {
+ final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
+ final NetworkApi nwApi = createMock(NetworkApi.class);
+ final GlobalOperationApi globalApi = createMock(GlobalOperationApi.class);
+
+ Network network = Network.builder().IPv4Range("0.0.0.0/0")
+ .id("abcd").name("this-network")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
+ .build();
+
+ Operation createOp = createMock(Operation.class);
+
+ final Supplier<String> userProject = new Supplier<String>() {
+ @Override
+ public String get() {
+ return "myproject";
+ }
+ };
+
+ expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
+ expect(api.getGlobalOperationApiForProject(userProject.get())).andReturn(globalApi).atLeastOnce();
+
+ expect(nwApi.createInIPv4Range("this-network", "0.0.0.0/0"))
+ .andReturn(createOp);
+ expect(globalApi.get("create-op")).andReturn(createOp);
+ // pre-creation
+ expect(nwApi.get("this-network")).andReturn(null).times(2);
+ // post-creation
+ expect(nwApi.get("this-network")).andReturn(network);
+
+ expect(createOp.getName()).andReturn("create-op");
+ expect(createOp.getStatus()).andReturn(Operation.Status.DONE);
+ expect(createOp.getHttpError()).andReturn(fromNullable((HttpResponse)null));
+ replay(api, nwApi, createOp, globalApi);
+
+ NetworkAndAddressRange input = new NetworkAndAddressRange("this-network", "0.0.0.0/0", null);
+
+ GlobalOperationDonePredicate pred = new GlobalOperationDonePredicate(api, userProject);
+
+ CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, userProject, pred, 100l, 100l);
+
+ FindNetworkOrCreate loader = new FindNetworkOrCreate(api, creator, userProject);
+
+ LoadingCache<NetworkAndAddressRange, Network> cache = CacheBuilder.newBuilder().build(loader);
+
+ assertEquals(cache.getUnchecked(input), network);
+
+ // Second call is to ensure we only need to make the API calls once.
+ assertEquals(cache.getUnchecked(input), network);
+
+ verify(api, nwApi, globalApi, createOp);
+
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
new file mode 100644
index 0000000..1816b78
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.AssertJUnit.assertNull;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.parse.ParseAddressListTest;
+import org.jclouds.googlecomputeengine.parse.ParseAddressTest;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ public void testGetAddressResponseIs2xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/address_get.json")).build();
+
+ AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getAddressApiForProject("myproject");
+
+ assertEquals(api.getInRegion("us-central1", "test-ip1"),
+ new ParseAddressTest().expected());
+ }
+
+ public void testGetAddressResponseIs4xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getAddressApiForProject("myproject");
+
+ assertNull(api.getInRegion("us-central1", "test-ip1"));
+ }
+
+ public void testInsertAddressResponseIs2xx() {
+ HttpRequest insert = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/address_insert.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse insertAddressResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/region_operation.json")).build();
+
+ AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, insert,
+ insertAddressResponse).getAddressApiForProject("myproject");
+
+ assertEquals(api.createInRegion("us-central1", "test-ip1"), new ParseOperationTest().expected());
+ }
+
+ public void testDeleteAddressResponseIs2xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/region_operation.json")).build();
+
+ AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getAddressApiForProject("myproject");
+
+ assertEquals(api.deleteInRegion("us-central1", "test-ip1"),
+ new ParseOperationTest().expected());
+ }
+
+ public void testDeleteAddressResponseIs4xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
+
+ AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getAddressApiForProject("myproject");
+
+ assertNull(api.deleteInRegion("us-central1", "test-ip1"));
+ }
+
+ public void testListAddresssResponseIs2xx() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/regions/us-central1/addresses")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/address_list.json")).build();
+
+ AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getAddressApiForProject("myproject");
+
+ assertEquals(api.listFirstPageInRegion("us-central1").toString(),
+ new ParseAddressListTest().expected().toString());
+ }
+
+ public void testListAddresssResponseIs4xx() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/regions/us-central1/addresses")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getAddressApiForProject("myproject");
+
+ assertTrue(api.listInRegion("us-central1").concat().isEmpty());
+ }
+}
[26/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateNetworkOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateNetworkOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateNetworkOptions.java
new file mode 100644
index 0000000..f4237f5
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateNetworkOptions.java
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.options;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.gson.annotations.SerializedName;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.NetworkType;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import javax.inject.Inject;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class CreateNetworkOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromCreateNetworkOptions(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String name;
+ protected Boolean adminStateUp;
+ protected Boolean external;
+ protected NetworkType networkType;
+ protected String physicalNetworkName;
+ protected Integer segmentationId;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions#getAdminStateUp()
+ */
+ public T adminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions#getExternal()
+ */
+ public T external(Boolean external) {
+ this.external = external;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions#getNetworkType()
+ */
+ public T networkType(NetworkType networkType) {
+ this.networkType = networkType;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions#getPhysicalNetworkName()
+ */
+ public T physicalNetworkName(String physicalNetworkName) {
+ this.physicalNetworkName = physicalNetworkName;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions#getSegmentationId()
+ */
+ public T segmentationId(Integer segmentationId) {
+ this.segmentationId = segmentationId;
+ return self();
+ }
+
+ public CreateNetworkOptions build() {
+ return new CreateNetworkOptions(name, adminStateUp, external, networkType, physicalNetworkName, segmentationId);
+ }
+
+ public T fromCreateNetworkOptions(CreateNetworkOptions in) {
+ return this.name(in.getName())
+ .adminStateUp(in.getAdminStateUp())
+ .external(in.getExternal())
+ .networkType(in.getNetworkType())
+ .physicalNetworkName(in.getPhysicalNetworkName())
+ .segmentationId(in.getSegmentationId());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ protected static class CreateNetworkRequest {
+ protected String name;
+ protected Boolean admin_state_up;
+ @SerializedName("router:external")
+ protected Boolean external;
+ @SerializedName("provider:network_type")
+ protected String networkType;
+ @SerializedName("provider:physical_network")
+ protected String physicalNetworkName;
+ @SerializedName("provider:segmentation_id")
+ protected Integer segmentationId;
+ }
+
+ private final String name;
+ private final Boolean adminStateUp;
+ private final Boolean external;
+ private final NetworkType networkType;
+ private final String physicalNetworkName;
+ private final Integer segmentationId;
+
+ protected CreateNetworkOptions() {
+ this.name = null;
+ this.adminStateUp = null;
+ this.external = null;
+ this.networkType = null;
+ this.physicalNetworkName = null;
+ this.segmentationId = null;
+ }
+
+ public CreateNetworkOptions(String name, Boolean adminStateUp, Boolean external, NetworkType networkType, String physicalNetworkName, Integer segmentationId) {
+ this.name = name;
+ this.adminStateUp = adminStateUp;
+ this.external = external;
+ this.networkType = networkType;
+ this.physicalNetworkName = physicalNetworkName;
+ this.segmentationId = segmentationId;
+ }
+
+ /**
+ * @return the name of the network
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the administrative state of network. If false, the network does not forward packets.
+ */
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return true if network is external, false if not
+ */
+ public Boolean getExternal() {
+ return external;
+ }
+
+ /**
+ * @return the type of the network
+ */
+ public NetworkType getNetworkType() {
+ return networkType;
+ }
+
+ /**
+ * @return the physical network name
+ */
+ public String getPhysicalNetworkName() {
+ return physicalNetworkName;
+ }
+
+ /**
+ * @return the segmentation id of the network
+ */
+ public Integer getSegmentationId() {
+ return segmentationId;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ if (this.networkType != null) {
+ //Validations for each NetworkType
+ if (this.networkType == NetworkType.FLAT) {
+ checkNotNull(this.physicalNetworkName, "physicalNetworkName must be present when networkType=FLAT");
+ } else if (this.networkType == NetworkType.VLAN) {
+ checkNotNull(this.physicalNetworkName, "physicalNetworkName must be present when networkType=VLAN");
+ checkNotNull(this.segmentationId, "segmentationId must be present when networkType=VLAN");
+ } else if (this.networkType == NetworkType.GRE) {
+ checkNotNull(this.segmentationId, "segmentationId must be present when NetworkType=GRE");
+ }
+ }
+
+ CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
+ if (this.name != null)
+ createNetworkRequest.name = this.name;
+ if (this.adminStateUp != null)
+ createNetworkRequest.admin_state_up = this.adminStateUp;
+ if (this.external != null)
+ createNetworkRequest.external = this.external;
+ if (this.networkType != null)
+ createNetworkRequest.networkType = this.networkType.getValue();
+ if (this.physicalNetworkName != null && (networkType == NetworkType.FLAT || networkType == NetworkType.VLAN))
+ createNetworkRequest.physicalNetworkName = this.physicalNetworkName;
+ if (this.segmentationId != null && (networkType == NetworkType.VLAN || networkType == NetworkType.GRE))
+ createNetworkRequest.segmentationId = this.segmentationId;
+
+ return bindToRequest(request, ImmutableMap.of("network", createNetworkRequest));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreatePortBulkOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreatePortBulkOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreatePortBulkOptions.java
new file mode 100644
index 0000000..bbe473d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreatePortBulkOptions.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.options;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.BulkPort;
+import org.jclouds.openstack.neutron.v2_0.domain.IP;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import javax.inject.Inject;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class CreatePortBulkOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromCreatePortBulkOptions(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected List<BulkPort> ports;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreatePortBulkOptions#getPorts()
+ */
+ public T ports(Collection<BulkPort> ports) {
+ this.ports = ImmutableList.copyOf(ports);
+ return self();
+ }
+
+ public CreatePortBulkOptions build() {
+ return new CreatePortBulkOptions(this.ports);
+ }
+
+ public T fromCreatePortBulkOptions(CreatePortBulkOptions in) {
+ return this.ports(in.getPorts());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final List<BulkPort> ports;
+
+ protected CreatePortBulkOptions() {
+ this.ports = Lists.newArrayList();
+ }
+
+ public CreatePortBulkOptions(List<BulkPort> ports) {
+ this.ports = ports;
+ }
+
+ /**
+ * @return the list of ports to create
+ */
+ public List<BulkPort> getPorts() {
+ return ports;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ List<CreatePortOptions.CreatePortRequest> createPortRequests = Lists.newArrayList();
+
+ for (BulkPort port : this.ports) {
+ CreatePortOptions.CreatePortRequest createPortRequest = new CreatePortOptions.CreatePortRequest(checkNotNull(port.getNetworkId(), "network id parameter not present"));
+
+ if (port.getName() != null)
+ createPortRequest.name = port.getName();
+ if (port.getAdminStateUp() != null)
+ createPortRequest.admin_state_up = port.getAdminStateUp();
+ if (port.getDeviceId() != null)
+ createPortRequest.device_id = port.getDeviceId();
+ if (port.getDeviceOwner() != null)
+ createPortRequest.device_owner = port.getDeviceOwner();
+ if (port.getMacAddress() != null)
+ createPortRequest.mac_address = port.getMacAddress();
+ if (!port.getFixedIps().isEmpty()) {
+ createPortRequest.fixed_ips = Sets.newHashSet();
+ for (IP fixedIp : port.getFixedIps()) {
+ CreatePortOptions.CreatePortRequest.IP requestIp = new CreatePortOptions.CreatePortRequest.IP();
+ requestIp.subnet_id = fixedIp.getSubnetId();
+ requestIp.ip_address = fixedIp.getIpAddress();
+ createPortRequest.fixed_ips.add(requestIp);
+ }
+ }
+
+ createPortRequests.add(createPortRequest);
+ }
+
+ return bindToRequest(request, ImmutableMap.of("ports", createPortRequests));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreatePortOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreatePortOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreatePortOptions.java
new file mode 100644
index 0000000..1903da2
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreatePortOptions.java
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.options;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.IP;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import javax.inject.Inject;
+import java.util.Map;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class CreatePortOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromCreatePortOptions(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String name;
+ protected String deviceId;
+ protected String deviceOwner;
+ protected String macAddress;
+ protected Set<IP> fixedIps;
+ protected Boolean adminStateUp;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreatePortOptions#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreatePortOptions#getDeviceId()
+ */
+ public T deviceId(String deviceId) {
+ this.deviceId = deviceId;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreatePortOptions#getDeviceOwner()
+ */
+ public T deviceOwner(String deviceOwner) {
+ this.deviceOwner = deviceOwner;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreatePortOptions#getMacAddress()
+ */
+ public T macAddress(String macAddress) {
+ this.macAddress = macAddress;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreatePortOptions#getFixedIps()
+ */
+ public T fixedIps(Set<IP> fixedIps) {
+ this.fixedIps = fixedIps;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreatePortOptions#getAdminStateUp()
+ */
+ public T adminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ public CreatePortOptions build() {
+ return new CreatePortOptions(name, deviceId, deviceOwner, macAddress, fixedIps, adminStateUp);
+ }
+
+ public T fromCreatePortOptions(CreatePortOptions options) {
+ return this.name(options.getName())
+ .deviceId(options.getDeviceId())
+ .deviceOwner(options.getDeviceOwner())
+ .macAddress(options.getMacAddress())
+ .fixedIps(options.getFixedIps())
+ .adminStateUp(options.getAdminStateUp());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ protected static class CreatePortRequest {
+ protected String network_id;
+ protected String name;
+ protected String device_id;
+ protected String device_owner;
+ protected String mac_address;
+ protected Set<IP> fixed_ips;
+ protected Boolean admin_state_up;
+
+ protected CreatePortRequest(String networkId) {
+ this.network_id = networkId;
+ }
+
+ protected static final class IP {
+ protected String ip_address;
+ protected String subnet_id;
+ }
+ }
+
+ private final String name;
+ private final String deviceId;
+ private final String deviceOwner;
+ private final String macAddress;
+ private final Set<IP> fixedIps;
+ private final Boolean adminStateUp;
+
+ protected CreatePortOptions() {
+ this.name = null;
+ this.deviceId = null;
+ this.deviceOwner = null;
+ this.macAddress = null;
+ this.fixedIps = Sets.newHashSet();
+ this.adminStateUp = null;
+ }
+
+ public CreatePortOptions(String name, String deviceId, String deviceOwner, String macAddress,
+ Set<IP> fixedIps, Boolean adminStateUp) {
+ this.name = name;
+ this.deviceId = deviceId;
+ this.deviceOwner = deviceOwner;
+ this.macAddress = macAddress;
+ this.fixedIps = fixedIps != null ? ImmutableSet.copyOf(fixedIps) : Sets.<IP>newHashSet();
+ this.adminStateUp = adminStateUp;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the id of the device (e.g. server) which will use this port.
+ */
+ public String getDeviceId() {
+ return deviceId;
+ }
+
+ /**
+ * @return the entity (e.g.: dhcp agent) who will be using this port.
+ */
+ public String getDeviceOwner() {
+ return deviceOwner;
+ }
+
+ /**
+ * @return the mac address of this port
+ */
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ /**
+ * @return the set of fixed ips this port will get assigned
+ */
+ public Set<IP> getFixedIps() {
+ return fixedIps;
+ }
+
+ /**
+ * @return the administrative state of port. If false, port does not forward packets.
+ */
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ CreatePortRequest createPortRequest = new CreatePortRequest(checkNotNull(postParams.get("network_id"), "networkId not present").toString());
+
+ if (this.name != null)
+ createPortRequest.name = this.name;
+ if (this.deviceId != null)
+ createPortRequest.device_id = this.deviceId;
+ if (this.deviceOwner != null)
+ createPortRequest.device_owner = this.deviceOwner;
+ if (this.macAddress != null)
+ createPortRequest.mac_address = this.macAddress;
+ if (!this.fixedIps.isEmpty()) {
+ createPortRequest.fixed_ips = Sets.newHashSet();
+ for (IP ip : this.fixedIps) {
+ CreatePortRequest.IP requestIp = new CreatePortRequest.IP();
+ requestIp.subnet_id = ip.getSubnetId();
+ requestIp.ip_address = ip.getIpAddress();
+ createPortRequest.fixed_ips.add(requestIp);
+ }
+ }
+ if (this.adminStateUp != null)
+ createPortRequest.admin_state_up = this.adminStateUp;
+
+ return bindToRequest(request, ImmutableMap.of("port", createPortRequest));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateRouterOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateRouterOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateRouterOptions.java
new file mode 100644
index 0000000..7834953
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateRouterOptions.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.options;
+
+import com.google.common.collect.ImmutableMap;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.ExternalGatewayInfo;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import javax.inject.Inject;
+import java.util.Map;
+
+public class CreateRouterOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromCreateRouterOptions(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String name;
+ protected Boolean adminStateUp;
+ protected ExternalGatewayInfo externalGatewayInfo;
+
+ /**
+ * @see CreateRouterOptions#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see CreateRouterOptions#getAdminStateUp()
+ */
+ public T adminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ /**
+ * @see CreateRouterOptions#getExternalGatewayInfo()
+ */
+ public T externalGatewayInfo(ExternalGatewayInfo externalGatewayInfo) {
+ this.externalGatewayInfo = externalGatewayInfo;
+ return self();
+ }
+
+ public CreateRouterOptions build() {
+ return new CreateRouterOptions(name, adminStateUp, externalGatewayInfo);
+ }
+
+ public T fromCreateRouterOptions(CreateRouterOptions options) {
+ return this.name(options.getName())
+ .adminStateUp(options.getAdminStateUp())
+ .externalGatewayInfo(options.getExternalGatewayInfo());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ protected static class CreateRouterRequest {
+ protected String name;
+ protected Boolean admin_state_up;
+ protected ExternalGatewayInfo external_gateway_info;
+
+ protected CreateRouterRequest() {
+ }
+
+ protected static final class ExternalGatewayInfo {
+ protected String network_id;
+
+ protected ExternalGatewayInfo(String network_id) {
+ this.network_id = network_id;
+ }
+ }
+ }
+
+ protected String name;
+ protected Boolean adminStateUp;
+ protected ExternalGatewayInfo externalGatewayInfo;
+
+ protected CreateRouterOptions() {
+ this.name = null;
+ this.adminStateUp = null;
+ this.externalGatewayInfo = null;
+ }
+
+ public CreateRouterOptions(String name, Boolean adminStateUp, ExternalGatewayInfo externalGatewayInfo) {
+ this.name = name;
+ this.adminStateUp = adminStateUp;
+ this.externalGatewayInfo = externalGatewayInfo;
+ }
+
+ /**
+ * @return the name for the router
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the administrative state of the router
+ */
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the external gateway info for the router
+ */
+ public ExternalGatewayInfo getExternalGatewayInfo() {
+ return externalGatewayInfo;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ CreateRouterRequest createRouterRequest = new CreateRouterRequest();
+
+ if (this.name != null)
+ createRouterRequest.name = this.name;
+ if (this.adminStateUp != null)
+ createRouterRequest.admin_state_up = this.adminStateUp;
+ if (this.externalGatewayInfo != null)
+ createRouterRequest.external_gateway_info = new CreateRouterRequest.ExternalGatewayInfo(this.externalGatewayInfo.getNetworkId());
+
+ return bindToRequest(request, ImmutableMap.of("router", createRouterRequest));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateSubnetBulkOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateSubnetBulkOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateSubnetBulkOptions.java
new file mode 100644
index 0000000..ae85ad1
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateSubnetBulkOptions.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.options;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet;
+import org.jclouds.openstack.neutron.v2_0.domain.HostRoute;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import javax.inject.Inject;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class CreateSubnetBulkOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromCreateSubnetBulkOptions(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected List<BulkSubnet> subnets;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateSubnetBulkOptions#getSubnets()
+ */
+ public T subnets(Collection<BulkSubnet> subnets) {
+ this.subnets = ImmutableList.copyOf(subnets);
+ return self();
+ }
+
+ public CreateSubnetBulkOptions build() {
+ return new CreateSubnetBulkOptions(this.subnets);
+ }
+
+ public T fromCreateSubnetBulkOptions(CreateSubnetBulkOptions in) {
+ return this.subnets(in.getSubnets());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final List<BulkSubnet> subnets;
+
+ protected CreateSubnetBulkOptions() {
+ this.subnets = Lists.newArrayList();
+ }
+
+ public CreateSubnetBulkOptions(List<BulkSubnet> subnets) {
+ this.subnets = subnets != null ? ImmutableList.copyOf(subnets) : Lists.<BulkSubnet>newArrayList();
+ }
+
+ /**
+ * @return The list of subnets to create
+ */
+ public List<BulkSubnet> getSubnets() {
+ return subnets;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ List<CreateSubnetOptions.CreateSubnetRequest> createSubnetRequests = Lists.newArrayList();
+
+ for (BulkSubnet subnet : subnets) {
+ CreateSubnetOptions.CreateSubnetRequest createSubnetRequest =
+ new CreateSubnetOptions.CreateSubnetRequest(
+ checkNotNull(subnet.getNetworkId(), "network id parameter not present"),
+ checkNotNull(subnet.getIpVersion(), "ip version parameter not present"),
+ checkNotNull(subnet.getCidr(), "cidr parameter not present")
+ );
+
+ if (subnet.getName() != null)
+ createSubnetRequest.name = subnet.getName();
+ if (!subnet.getAllocationPools().isEmpty())
+ createSubnetRequest.allocation_pools = subnet.getAllocationPools();
+ if (subnet.getGatewayIp() != null)
+ createSubnetRequest.gateway_ip = subnet.getGatewayIp();
+ if (subnet.getEnableDhcp() != null)
+ createSubnetRequest.enable_dhcp = subnet.getEnableDhcp();
+ if (!subnet.getDnsNameServers().isEmpty())
+ createSubnetRequest.dns_nameservers = subnet.getDnsNameServers();
+ if (!subnet.getHostRoutes().isEmpty()) {
+ createSubnetRequest.host_routes = Sets.newHashSet();
+ for (HostRoute hostRoute : subnet.getHostRoutes()) {
+ CreateSubnetOptions.CreateSubnetRequest.HostRoute requestHostRoute = new CreateSubnetOptions.CreateSubnetRequest.HostRoute();
+ requestHostRoute.destination = hostRoute.getDestinationCidr();
+ requestHostRoute.nexthop = hostRoute.getNextHop();
+ createSubnetRequest.host_routes.add(requestHostRoute);
+ }
+ }
+
+ createSubnetRequests.add(createSubnetRequest);
+ }
+
+ return bindToRequest(request, ImmutableMap.of("subnets", createSubnetRequests));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateSubnetOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateSubnetOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateSubnetOptions.java
new file mode 100644
index 0000000..c562e06
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateSubnetOptions.java
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.options;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.AllocationPool;
+import org.jclouds.openstack.neutron.v2_0.domain.HostRoute;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import javax.inject.Inject;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class CreateSubnetOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromCreateSubnetOptions(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String name;
+ protected Set<AllocationPool> allocationPools;
+ protected String gatewayIp;
+ protected Boolean enableDhcp;
+ protected Set<String> dnsNameServers;
+ protected Set<HostRoute> hostRoutes;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateSubnetOptions#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateSubnetOptions#getAllocationPools()
+ */
+ public T allocationPools(Collection<AllocationPool> allocationPools) {
+ this.allocationPools = ImmutableSet.copyOf(allocationPools);
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateSubnetOptions#getGatewayIp()
+ */
+ public T gatewayIp(String gatewayIp) {
+ this.gatewayIp = gatewayIp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateSubnetOptions#getEnableDhcp()
+ */
+ public T enableDhcp(Boolean enableDhcp) {
+ this.enableDhcp = enableDhcp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateSubnetOptions#getDnsNameServers()
+ */
+ public T dnsNameServers(Collection<String> dnsNameServers) {
+ this.dnsNameServers = ImmutableSet.copyOf(dnsNameServers);
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateSubnetOptions#getHostRoutes()
+ */
+ public T hostRoutes(Collection<HostRoute> hostRoutes) {
+ this.hostRoutes = ImmutableSet.copyOf(hostRoutes);
+ return self();
+ }
+
+ public CreateSubnetOptions build() {
+ return new CreateSubnetOptions(name, allocationPools, gatewayIp, enableDhcp, dnsNameServers, hostRoutes);
+ }
+
+ public T fromCreateSubnetOptions(CreateSubnetOptions in) {
+ return this.name(in.getName())
+ .allocationPools(in.getAllocationPools())
+ .gatewayIp(in.getGatewayIp())
+ .enableDhcp(in.getEnableDhcp())
+ .dnsNameServers(in.getDnsNameServers())
+ .hostRoutes(in.getHostRoutes());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ protected static class CreateSubnetRequest {
+ protected String network_id;
+ protected Integer ip_version;
+ protected String cidr;
+ protected String name;
+ protected Set<AllocationPool> allocation_pools;
+ protected String gateway_ip;
+ protected Boolean enable_dhcp;
+ protected Set<String> dns_nameservers;
+ protected Set<HostRoute> host_routes;
+
+ protected CreateSubnetRequest(String networkId, Integer ipVersion, String cidr) {
+ this.network_id = networkId;
+ this.ip_version = ipVersion;
+ this.cidr = cidr;
+ }
+
+ protected static class HostRoute {
+ protected String destination;
+ protected String nexthop;
+ }
+ }
+
+ private final String name;
+ private final Set<AllocationPool> allocationPools;
+ private final String gatewayIp;
+ private final Boolean enableDhcp;
+ private final Set<String> dnsNameServers;
+ private final Set<HostRoute> hostRoutes;
+
+ protected CreateSubnetOptions() {
+ this.name = null;
+ this.allocationPools = Sets.newHashSet();
+ this.gatewayIp = null;
+ this.enableDhcp = null;
+ this.dnsNameServers = Sets.newHashSet();
+ this.hostRoutes = Sets.newHashSet();
+ }
+
+ public CreateSubnetOptions(String name, Set<AllocationPool> allocationPools, String gatewayIp,
+ Boolean enableDhcp, Set<String> dnsNameServers, Set<HostRoute> hostRoutes) {
+ this.name = name;
+ this.allocationPools = allocationPools != null ? ImmutableSet.copyOf(allocationPools) : Sets.<AllocationPool>newHashSet();
+ this.gatewayIp = gatewayIp;
+ this.enableDhcp = enableDhcp;
+ this.dnsNameServers = dnsNameServers != null ? ImmutableSet.copyOf(dnsNameServers) : Sets.<String>newHashSet();
+ this.hostRoutes = hostRoutes != null ? ImmutableSet.copyOf(hostRoutes) : Sets.<HostRoute>newHashSet();
+ }
+
+ /**
+ * @return the name for the subnet
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the sub-ranges of cidr which will be available for dynamic allocation to ports
+ */
+ public Set<AllocationPool> getAllocationPools() {
+ return allocationPools;
+ }
+
+ /**
+ * @return the default gateway which will be used by devices in this subnet
+ */
+ public String getGatewayIp() {
+ return gatewayIp;
+ }
+
+ /**
+ * @return true to enable DHCP, false to disable
+ */
+ public Boolean getEnableDhcp() {
+ return enableDhcp;
+ }
+
+ /**
+ * @return the set of DNS name servers to be used by hosts in this subnet.
+ */
+ public Set<String> getDnsNameServers() {
+ return dnsNameServers;
+ }
+
+ /**
+ * @return the set of routes that should be used by devices with IPs from this subnet
+ */
+ public Set<HostRoute> getHostRoutes() {
+ return hostRoutes;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ CreateSubnetRequest createSubnetRequest =
+ new CreateSubnetRequest(
+ checkNotNull(postParams.get("network_id"), "networkId not present").toString(),
+ Integer.parseInt(checkNotNull(postParams.get("ip_version"), "ipVersion not present").toString()),
+ checkNotNull(postParams.get("cidr"), "cidr not present").toString()
+ );
+
+ if (this.name != null)
+ createSubnetRequest.name = this.name;
+ if (!this.allocationPools.isEmpty())
+ createSubnetRequest.allocation_pools = this.allocationPools;
+ if (this.gatewayIp != null)
+ createSubnetRequest.gateway_ip = this.gatewayIp;
+ if (this.enableDhcp != null)
+ createSubnetRequest.enable_dhcp = this.enableDhcp;
+ if (!this.dnsNameServers.isEmpty())
+ createSubnetRequest.dns_nameservers = this.dnsNameServers;
+ if (!this.hostRoutes.isEmpty()) {
+ createSubnetRequest.host_routes = Sets.newHashSet();
+ for (HostRoute hostRoute : this.hostRoutes) {
+ CreateSubnetRequest.HostRoute requestHostRoute = new CreateSubnetRequest.HostRoute();
+ requestHostRoute.destination = hostRoute.getDestinationCidr();
+ requestHostRoute.nexthop = hostRoute.getNextHop();
+ createSubnetRequest.host_routes.add(requestHostRoute);
+ }
+ }
+
+ return bindToRequest(request, ImmutableMap.of("subnet", createSubnetRequest));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/EmptyOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/EmptyOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/EmptyOptions.java
new file mode 100644
index 0000000..b5a3d9d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/EmptyOptions.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.options;
+
+import com.google.inject.Inject;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import java.util.Map;
+
+/**
+ * This class is used for methods who don't need a wrapper around their JSON body
+ */
+public class EmptyOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ return bindToRequest(request, (Object) postParams);
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateNetworkOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateNetworkOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateNetworkOptions.java
new file mode 100644
index 0000000..e794acf
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateNetworkOptions.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.options;
+
+import com.google.common.collect.ImmutableMap;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import javax.inject.Inject;
+import java.util.Map;
+
+public class UpdateNetworkOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromUpdateNetworkOptions(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String name;
+ protected Boolean adminStateUp;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.UpdateNetworkOptions#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.UpdateNetworkOptions#getAdminStateUp()
+ */
+ public T adminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ public UpdateNetworkOptions build() {
+ return new UpdateNetworkOptions(name, adminStateUp);
+ }
+
+ public T fromUpdateNetworkOptions(UpdateNetworkOptions options) {
+ return this.name(options.getName()).adminStateUp(options.getAdminStateUp());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private static class UpdateNetworkRequest {
+ protected String name;
+ protected Boolean admin_state_up;
+ }
+
+ private final String name;
+ private final Boolean adminStateUp;
+
+ protected UpdateNetworkOptions() {
+ this.name = null;
+ this.adminStateUp = null;
+ }
+
+ public UpdateNetworkOptions(String name, Boolean adminStateUp) {
+ this.name = name;
+ this.adminStateUp = adminStateUp;
+ }
+
+ /**
+ * @return the new name for the network
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the new administrative state for the network. If false, the network does not forward packets.
+ */
+ public boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
+
+ if (this.name != null)
+ updateNetworkRequest.name = this.name;
+ if (this.adminStateUp != null)
+ updateNetworkRequest.admin_state_up = this.adminStateUp;
+
+ return bindToRequest(request, ImmutableMap.of("network", updateNetworkRequest));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdatePortOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdatePortOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdatePortOptions.java
new file mode 100644
index 0000000..dfbc820
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdatePortOptions.java
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.options;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.IP;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import javax.inject.Inject;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+public class UpdatePortOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromUpdatePortOptions(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String name;
+ protected Boolean adminStateUp;
+ protected String deviceId;
+ protected String deviceOwner;
+ protected Set<IP> fixedIps;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions#getAdminStateUp()
+ */
+ public T adminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions#getDeviceId()
+ */
+ public T deviceId(String deviceId) {
+ this.deviceId = deviceId;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions#getDeviceOwner()
+ */
+ public T deviceOwner(String deviceOwner) {
+ this.deviceOwner = deviceOwner;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions#getFixedIps()
+ */
+ public T fixedIps(Collection<IP> fixedIps) {
+ this.fixedIps = ImmutableSet.copyOf(fixedIps);
+ return self();
+ }
+
+ public UpdatePortOptions build() {
+ return new UpdatePortOptions(name, adminStateUp, deviceId, deviceOwner, fixedIps);
+ }
+
+ public T fromUpdatePortOptions(UpdatePortOptions options) {
+ return this.name(options.getName())
+ .adminStateUp(options.getAdminStateUp())
+ .deviceId(options.getDeviceId())
+ .deviceOwner(options.getDeviceOwner())
+ .fixedIps(options.getFixedIps());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private static class UpdatePortRequest {
+ protected String name;
+ protected Boolean admin_state_up;
+ protected String device_id;
+ protected String device_owner;
+ protected Set<IP> fixed_ips;
+
+ private static class IP {
+ protected String ip_address;
+ protected String subnet_id;
+ }
+ }
+
+ private final String name;
+ private final Boolean adminStateUp;
+ private final String deviceId;
+ private final String deviceOwner;
+ private final Set<IP> fixedIps;
+
+ protected UpdatePortOptions() {
+ this.name = null;
+ this.adminStateUp = null;
+ this.deviceId = null;
+ this.deviceOwner = null;
+ this.fixedIps = Sets.newHashSet();
+ }
+
+ public UpdatePortOptions(String name, Boolean adminStateUp, String deviceId, String deviceOwner, Set<IP> fixedIps) {
+ this.name = name;
+ this.adminStateUp = adminStateUp;
+ this.deviceId = deviceId;
+ this.deviceOwner = deviceOwner;
+ this.fixedIps = fixedIps != null ? ImmutableSet.copyOf(fixedIps) : Sets.<IP>newHashSet();
+ }
+
+ /**
+ * @return the new name for the port
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the new administrative state for the port. If false, port does not forward packets.
+ */
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the new device id for the port
+ */
+ public String getDeviceId() {
+ return deviceId;
+ }
+
+ /**
+ * @return the new device owner for the port
+ */
+ public String getDeviceOwner() {
+ return deviceOwner;
+ }
+
+ /**
+ * @return a new set of fixed ips this port will get assigned
+ */
+ public Set<IP> getFixedIps() {
+ return fixedIps;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ UpdatePortRequest updatePortRequest = new UpdatePortRequest();
+
+ if (this.name != null)
+ updatePortRequest.name = this.name;
+ if (this.adminStateUp != null)
+ updatePortRequest.admin_state_up = this.adminStateUp;
+ if (this.deviceId != null)
+ updatePortRequest.device_id = this.deviceId;
+ if (this.deviceOwner != null)
+ updatePortRequest.device_owner = this.deviceOwner;
+ if (!this.fixedIps.isEmpty()) {
+ updatePortRequest.fixed_ips = Sets.newHashSet();
+ for (IP fixedIp : this.fixedIps) {
+ UpdatePortRequest.IP requestIp = new UpdatePortRequest.IP();
+ requestIp.ip_address = fixedIp.getIpAddress();
+ requestIp.subnet_id = fixedIp.getSubnetId();
+ updatePortRequest.fixed_ips.add(requestIp);
+ }
+ }
+
+ return bindToRequest(request, ImmutableMap.of("port", updatePortRequest));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateRouterOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateRouterOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateRouterOptions.java
new file mode 100644
index 0000000..c614e91
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateRouterOptions.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.options;
+
+import com.google.common.collect.ImmutableMap;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.ExternalGatewayInfo;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import javax.inject.Inject;
+import java.util.Map;
+
+public class UpdateRouterOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromUpdateRouterOptions(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String name;
+ protected Boolean adminStateUp;
+ protected ExternalGatewayInfo externalGatewayInfo;
+
+ /**
+ * @see UpdateRouterOptions#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see UpdateRouterOptions#getAdminStateUp()
+ */
+ public T adminStateUp(Boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ return self();
+ }
+
+ /**
+ * @see UpdateRouterOptions#getExternalGatewayInfo()
+ */
+ public T externalGatewayInfo(ExternalGatewayInfo externalGatewayInfo) {
+ this.externalGatewayInfo = externalGatewayInfo;
+ return self();
+ }
+
+ public UpdateRouterOptions build() {
+ return new UpdateRouterOptions(name, adminStateUp, externalGatewayInfo);
+ }
+
+ public T fromUpdateRouterOptions(UpdateRouterOptions options) {
+ return this.name(options.getName())
+ .adminStateUp(options.getAdminStateUp())
+ .externalGatewayInfo(options.getExternalGatewayInfo());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ protected static class UpdateRouterRequest {
+ protected String name;
+ protected Boolean admin_state_up;
+ protected ExternalGatewayInfo external_gateway_info;
+
+ protected UpdateRouterRequest() {
+ }
+
+ protected static final class ExternalGatewayInfo {
+ protected String network_id;
+
+ protected ExternalGatewayInfo(String network_id) {
+ this.network_id = network_id;
+ }
+ }
+ }
+
+ protected String name;
+ protected Boolean adminStateUp;
+ protected ExternalGatewayInfo externalGatewayInfo;
+
+ protected UpdateRouterOptions() {
+ this.name = null;
+ this.adminStateUp = null;
+ this.externalGatewayInfo = null;
+ }
+
+ public UpdateRouterOptions(String name, Boolean adminStateUp, ExternalGatewayInfo externalGatewayInfo) {
+ this.name = name;
+ this.adminStateUp = adminStateUp;
+ this.externalGatewayInfo = externalGatewayInfo;
+ }
+
+ /**
+ * @return the new name for the router
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the new administrative state for the router
+ */
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the new information on external gateway for the router
+ */
+ public ExternalGatewayInfo getExternalGatewayInfo() {
+ return externalGatewayInfo;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ UpdateRouterRequest updateRouterRequest = new UpdateRouterRequest();
+
+ if (this.name != null)
+ updateRouterRequest.name = this.name;
+ if (this.adminStateUp != null)
+ updateRouterRequest.admin_state_up = this.adminStateUp;
+ if (this.externalGatewayInfo != null)
+ updateRouterRequest.external_gateway_info = new UpdateRouterRequest.ExternalGatewayInfo(this.externalGatewayInfo.getNetworkId());
+
+ return bindToRequest(request, ImmutableMap.of("router", updateRouterRequest));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateSubnetOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateSubnetOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateSubnetOptions.java
new file mode 100644
index 0000000..3f2ec26
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/UpdateSubnetOptions.java
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.options;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.HostRoute;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import javax.inject.Inject;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+public class UpdateSubnetOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromUpdateSubnetOptions(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String name;
+ protected String gatewayIp;
+ protected Boolean enableDhcp;
+ protected Set<String> dnsNameServers;
+ protected Set<HostRoute> hostRoutes;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions#getGatewayIp()
+ */
+ public T gatewayIp(String gatewayIp) {
+ this.gatewayIp = gatewayIp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions#getEnableDhcp()
+ */
+ public T enableDhcp(Boolean enableDhcp) {
+ this.enableDhcp = enableDhcp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions#getDnsNameServers()
+ */
+ public T dnsNameServers(Collection<String> dnsNameServers) {
+ this.dnsNameServers = ImmutableSet.copyOf(dnsNameServers);
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions#getHostRoutes()
+ */
+ public T hostRoutes(Collection<HostRoute> hostRoutes) {
+ this.hostRoutes = ImmutableSet.copyOf(hostRoutes);
+ return self();
+ }
+
+ public UpdateSubnetOptions build() {
+ return new UpdateSubnetOptions(name, gatewayIp, enableDhcp, dnsNameServers, hostRoutes);
+ }
+
+ public T fromUpdateSubnetOptions(UpdateSubnetOptions in) {
+ return this.name(in.getName())
+ .gatewayIp(in.getGatewayIp())
+ .enableDhcp(in.getEnableDhcp())
+ .dnsNameServers(in.getDnsNameServers())
+ .hostRoutes(in.getHostRoutes());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private static class UpdateSubnetRequest {
+ protected String name;
+ protected String gateway_ip;
+ protected Boolean enable_dhcp;
+ protected Set<String> dns_nameservers;
+ protected Set<HostRoute> host_routes;
+
+ private static class HostRoute {
+ protected String destination;
+ protected String nexthop;
+ }
+ }
+
+ private final String name;
+ private final String gatewayIp;
+ private final Boolean enableDhcp;
+ private final Set<String> dnsNameServers;
+ private final Set<HostRoute> hostRoutes;
+
+ protected UpdateSubnetOptions() {
+ this.name = null;
+ this.gatewayIp = null;
+ this.enableDhcp = null;
+ this.dnsNameServers = Sets.newHashSet();
+ this.hostRoutes = Sets.newHashSet();
+ }
+
+ public UpdateSubnetOptions(String name, String gatewayIp, Boolean enableDhcp, Set<String> dnsNameServers, Set<HostRoute> hostRoutes) {
+ this.name = name;
+ this.gatewayIp = gatewayIp;
+ this.enableDhcp = enableDhcp;
+ this.dnsNameServers = dnsNameServers != null ? ImmutableSet.copyOf(dnsNameServers) : Sets.<String>newHashSet();
+ this.hostRoutes = hostRoutes != null ? ImmutableSet.copyOf(hostRoutes) : Sets.<HostRoute>newHashSet();
+ }
+
+ /**
+ * @return the new name for the subnet
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the new default gateway used by devices in this subnet
+ */
+ public String getGatewayIp() {
+ return gatewayIp;
+ }
+
+ /**
+ * @return true if DHCP is enabled for this subnet, false if not
+ */
+ public Boolean getEnableDhcp() {
+ return enableDhcp;
+ }
+
+ /**
+ * @return the new set of DNS name servers used by hosts in this subnet
+ */
+ public Set<String> getDnsNameServers() {
+ return dnsNameServers;
+ }
+
+ /**
+ * @return the new set of routes that should be used by devices with IPs from this subnet
+ */
+ public Set<HostRoute> getHostRoutes() {
+ return hostRoutes;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ UpdateSubnetRequest updateSubnetRequest = new UpdateSubnetRequest();
+
+ if (this.name != null)
+ updateSubnetRequest.name = this.name;
+ if (this.gatewayIp != null)
+ updateSubnetRequest.gateway_ip = this.gatewayIp;
+ if (this.enableDhcp != null)
+ updateSubnetRequest.enable_dhcp = this.enableDhcp;
+ if (!this.dnsNameServers.isEmpty())
+ updateSubnetRequest.dns_nameservers = this.dnsNameServers;
+ if (!this.hostRoutes.isEmpty()) {
+ updateSubnetRequest.host_routes = Sets.newHashSet();
+ for (HostRoute hostRoute : this.hostRoutes) {
+ UpdateSubnetRequest.HostRoute requestHostRoute = new UpdateSubnetRequest.HostRoute();
+ requestHostRoute.destination = hostRoute.getDestinationCidr();
+ requestHostRoute.nexthop = hostRoute.getNextHop();
+ updateSubnetRequest.host_routes.add(requestHostRoute);
+ }
+ }
+
+ return bindToRequest(request, ImmutableMap.of("subnet", updateSubnetRequest));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
new file mode 100644
index 0000000..2365644
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.jclouds.openstack.neutron.v2_0.NeutronApiMetadata
+org.jclouds.openstack.neutron.v2.NeutronApiMetadata
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadataTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadataTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadataTest.java
new file mode 100644
index 0000000..f38136a
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/NeutronApiMetadataTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.reflect.TypeToken;
+import org.jclouds.View;
+import org.jclouds.apis.internal.BaseApiMetadataTest;
+import org.testng.annotations.Test;
+
+/**
+ * The Neutron metadata test.
+ */
+@Test(groups = "unit", testName = "NeutronApiMetadataTest")
+public class NeutronApiMetadataTest extends BaseApiMetadataTest {
+ public NeutronApiMetadataTest() {
+ super(new NeutronApiMetadata(), ImmutableSet.<TypeToken<? extends View>>of());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiLiveTest.java
new file mode 100644
index 0000000..a3d5f3d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FloatingIPApiLiveTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.neutron.v2.domain.FloatingIP;
+import org.jclouds.openstack.neutron.v2.domain.IP;
+import org.jclouds.openstack.neutron.v2.domain.Network;
+import org.jclouds.openstack.neutron.v2.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2.domain.Subnet;
+import org.jclouds.openstack.neutron.v2.features.NetworkApi;
+import org.jclouds.openstack.neutron.v2.features.SubnetApi;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests parsing and Guice wiring of RouterApi
+ */
+@Test(groups = "live", testName = "FloatingIPApiLiveTest")
+public class FloatingIPApiLiveTest extends BaseNeutronApiLiveTest {
+
+ public void testCreateUpdateAndDeleteFloatingIP() {
+ for (String region : api.getConfiguredRegions()) {
+
+ SubnetApi subnetApi = api.getSubnetApi(region);
+ FloatingIPApi floatingIPApi = api.getFloatingIPApi(region).get();
+ NetworkApi networkApi = api.getNetworkApi(region);
+
+ FloatingIP floatingIPGet = null;
+ String ipv4SubnetId = null;
+ Network network = null;
+
+ try {
+ network = networkApi.create(
+ Network.createBuilder("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build());
+ assertNotNull(network);
+
+ ipv4SubnetId = subnetApi.create(Subnet.createBuilder(network.getId(), "198.51.100.0/24").ipVersion(4)
+ .name("JClouds-Live-IPv4-Subnet").build()).getId();
+
+ floatingIPApi.create(FloatingIP.createBuilder(network.getId()).build());
+
+ /* List and Get test */
+ Set<FloatingIP> floatingIPs = floatingIPApi.list().concat().toSet();
+ FloatingIP floatingIPList = floatingIPs.iterator().next();
+ floatingIPGet = floatingIPApi.get(floatingIPList.getId());
+
+ assertNotNull(floatingIPGet);
+ assertEquals(floatingIPGet, floatingIPList);
+ }
+ finally {
+ try {
+ assertTrue(floatingIPApi.delete(floatingIPGet.getId()));
+ }
+ finally {
+ try {
+ assertTrue(subnetApi.delete(ipv4SubnetId));
+ }
+ finally {
+ assertTrue(networkApi.delete(network.getId()));
+ }
+ }
+ }
+ }
+ }
+
+ public Set<IP> getFixedAddresses(String subnetId) {
+ return ImmutableSet.of(IP.builder().subnetId(subnetId).build());
+ }
+}
[42/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java
new file mode 100644
index 0000000..28cc443
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+public class ParseZoneOperations extends ParseJson<ListPage<Operation>> {
+
+ @Inject
+ public ParseZoneOperations(Json json) {
+ super(json, new TypeLiteral<ListPage<Operation>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseWithZoneToPagedIterable<Operation, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName,
+ final String zoneName,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Operation>>() {
+
+ @Override
+ public IterableWithMarker<Operation> apply(Object input) {
+ return api.getZoneOperationApiForProject(projectName)
+ .listAtMarkerInZone(zoneName, input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java
new file mode 100644
index 0000000..f3e54ea
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Zone;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+public class ParseZones extends ParseJson<ListPage<Zone>> {
+
+ @Inject
+ public ParseZones(Json json) {
+ super(json, new TypeLiteral<ListPage<Zone>>() {
+ });
+ }
+
+ public static class ToPagedIterable extends BaseToPagedIterable<Zone, ToPagedIterable> {
+
+ private final GoogleComputeEngineApi api;
+
+ @Inject
+ protected ToPagedIterable(GoogleComputeEngineApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Zone>> fetchNextPage(final String projectName,
+ final ListOptions options) {
+ return new Function<Object, IterableWithMarker<Zone>>() {
+
+ @Override
+ public IterableWithMarker<Zone> apply(Object input) {
+ return api.getZoneApiForProject(projectName).listAtMarker(input.toString(), options);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/FirewallBinder.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/FirewallBinder.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/FirewallBinder.java
new file mode 100644
index 0000000..b5ce22e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/FirewallBinder.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.handlers;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.googlecomputeengine.options.FirewallOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+public class FirewallBinder implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ FirewallOptions options = (FirewallOptions) checkNotNull(postParams.get("options"), "firewallOptions");
+ String name = (String) checkNotNull(postParams.get("name"), "name");
+ URI network = (URI) checkNotNull(postParams.get("network"), "network");
+ options.name(name);
+ options.network(network);
+ return bindToRequest(request, options);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/GoogleComputeEngineErrorHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/GoogleComputeEngineErrorHandler.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/GoogleComputeEngineErrorHandler.java
new file mode 100644
index 0000000..109b050
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/GoogleComputeEngineErrorHandler.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.handlers;
+
+import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
+
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ResourceNotFoundException;
+
+/**
+ * This will parse and set an appropriate exception on the command object.
+ */
+@Singleton
+public class GoogleComputeEngineErrorHandler implements HttpErrorHandler {
+ public void handleError(HttpCommand command, HttpResponse response) {
+ // it is important to always read fully and close streams
+ byte[] data = closeClientButKeepContentStream(response);
+ String message = data != null ? new String(data) : null;
+
+ Exception exception = message != null ? new HttpResponseException(command, response, message)
+ : new HttpResponseException(command, response);
+ message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
+ response.getStatusLine());
+ switch (response.getStatusCode()) {
+ case 400:
+ break;
+ case 401:
+ case 403:
+ exception = new AuthorizationException(message, exception);
+ break;
+ case 404:
+ if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
+ exception = new ResourceNotFoundException(message, exception);
+ }
+ break;
+ case 409:
+ exception = new IllegalStateException(message, exception);
+ break;
+ }
+ command.setException(exception);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/InstanceBinder.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/InstanceBinder.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/InstanceBinder.java
new file mode 100644
index 0000000..2559ede
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/InstanceBinder.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.handlers;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.googlecomputeengine.domain.InstanceTemplate;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Function;
+
+public class InstanceBinder implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ @Inject
+ @Named("machineTypeToURI")
+ Function<String, URI> machineTypesToURI;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ InstanceTemplate template = (InstanceTemplate) checkNotNull(postParams.get("template"), "template");
+ template.name(checkNotNull(postParams.get("name"), "name").toString());
+
+ if (template.getMachineTypeName() != null) {
+ template.machineType(machineTypesToURI.apply(template.getMachineTypeName()));
+ }
+ template.machineType((String) null);
+ return bindToRequest(request, template);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/MetadataBinder.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/MetadataBinder.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/MetadataBinder.java
new file mode 100644
index 0000000..b96afb4
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/MetadataBinder.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.handlers;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.googlecomputeengine.domain.Metadata;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.collect.ImmutableMap;
+
+public class MetadataBinder implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Map<String, String> items =
+ ImmutableMap.copyOf((Map<String, String>) checkNotNull(postParams.get("items"), "item"));
+ String fingerprint = (String) checkNotNull(postParams.get("fingerprint"), "fingerprint");
+ Metadata metadata = Metadata.builder()
+ .fingerprint(fingerprint)
+ .items(items)
+ .build();
+ return bindToRequest(request, metadata);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/RouteBinder.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/RouteBinder.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/RouteBinder.java
new file mode 100644
index 0000000..2863b44
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/handlers/RouteBinder.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.handlers;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.googlecomputeengine.options.RouteOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+public class RouteBinder implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ RouteOptions options = (RouteOptions) checkNotNull(postParams.get("options"), "routeOptions");
+ String name = (String) checkNotNull(postParams.get("name"), "name");
+ URI network = (URI) checkNotNull(postParams.get("network"), "network");
+ options.name(name);
+ options.network(network);
+ return bindToRequest(request, options);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java
new file mode 100644
index 0000000..5ad2846
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.options;
+
+import java.net.URI;
+
+/**
+ * Options for attaching disks to instances.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/latest/instances/attachDisk"/>
+ */
+public class AttachDiskOptions {
+
+ public enum DiskType {
+ SCRATCH,
+ PERSISTENT
+ }
+
+ public enum DiskMode {
+ READ_WRITE,
+ READ_ONLY
+ }
+
+ private DiskType type;
+ private DiskMode mode;
+ private URI source;
+ private String deviceName;
+ private boolean boot;
+
+ /**
+ * The disk type
+ *
+ * @return the disk type.
+ */
+ public DiskType getType() {
+ return type;
+ }
+
+ /**
+ * The disk mode
+ *
+ * @return the disk mode
+ */
+ public DiskMode getMode() {
+ return mode;
+ }
+
+ /**
+ * The URI of the source disk - optional, if DiskType.SCRATCH is used.
+ *
+ * @return the URI
+ */
+ public URI getSource() {
+ return source;
+ }
+
+ /**
+ * The device name on the instance - optional.
+ *
+ * @return the device name
+ */
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ /**
+ * Indicates that this is a boot disk. VM will use the first partition of the disk for its root filesystem.
+ *
+ * @return true if this is a boot disk, false otherwise
+ */
+ public boolean getBoot() {
+ return boot;
+ }
+
+ /**
+ * @see AttachDiskOptions#getType()
+ */
+ public AttachDiskOptions type(DiskType type) {
+ this.type = type;
+ return this;
+ }
+
+ /**
+ * @see AttachDiskOptions#getMode()
+ */
+ public AttachDiskOptions mode(DiskMode mode) {
+ this.mode = mode;
+ return this;
+ }
+
+ /**
+ * @see AttachDiskOptions#getSource()
+ */
+ public AttachDiskOptions source(URI source) {
+ this.source = source;
+ return this;
+ }
+
+ /**
+ * @see AttachDiskOptions#getDeviceName()
+ */
+ public AttachDiskOptions deviceName(String deviceName) {
+ this.deviceName = deviceName;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.options.AttachDiskOptions#getBoot()
+ */
+ public AttachDiskOptions boot(boolean boot) {
+ this.boot = boot;
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/DeprecateOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/DeprecateOptions.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/DeprecateOptions.java
new file mode 100644
index 0000000..382bf71
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/DeprecateOptions.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.options;
+
+import java.net.URI;
+import java.util.Date;
+
+/**
+ * Options to set the deprecation status of a resource. Currently only for images.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/latest/images/deprecate" />
+ */
+public class DeprecateOptions {
+
+ public enum State {
+ DEPRECATED,
+ OBSOLETE,
+ DELETED
+ }
+
+ private State state;
+ private URI replacement;
+ private Date deprecated;
+ private Date obsolete;
+ private Date deleted;
+
+ /**
+ * The new deprecation state.
+ *
+ * @return the new deprecation state.
+ */
+ public State getState() {
+ return state;
+ }
+
+ /**
+ * Optional URL for replacement of deprecated resource.
+ *
+ * @return the URL
+ */
+ public URI getReplacement() {
+ return replacement;
+ }
+
+ /**
+ * Optional RFC3339 timestamp for when the deprecation state was changed to DEPRECATED.
+ *
+ * @return the timestamp
+ */
+ public Date getDeprecated() {
+ return deprecated;
+ }
+
+ /**
+ * Optional RFC3339 timestamp for when the deprecation state was changed to OBSOLETE.
+ *
+ * @return the timestamp
+ */
+ public Date getObsolete() {
+ return obsolete;
+ }
+
+ /**
+ * Optional RFC3339 timestamp for when the deprecation state was changed to DELETED.
+ *
+ * @return the timestamp
+ */
+ public Date getDeleted() {
+ return deleted;
+ }
+
+ /**
+ * @see DeprecateOptions#getState()
+ */
+ public DeprecateOptions state(State state) {
+ this.state = state;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.options.DeprecateOptions#getReplacement()
+ */
+ public DeprecateOptions replacement(URI replacement) {
+ this.replacement = replacement;
+ return this;
+ }
+
+ /**
+ * @see DeprecateOptions#getDeprecated()
+ */
+ public DeprecateOptions deprecated(Date deprecated) {
+ this.deprecated = deprecated;
+ return this;
+ }
+
+ /**
+ * @see DeprecateOptions#getObsolete()
+ */
+ public DeprecateOptions obsolete(Date obsolete) {
+ this.obsolete = obsolete;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.options.DeprecateOptions#getDeleted()
+ */
+ public DeprecateOptions deleted(Date deleted) {
+ this.deleted = deleted;
+ return this;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/FirewallOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/FirewallOptions.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/FirewallOptions.java
new file mode 100644
index 0000000..d70d4d0
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/FirewallOptions.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.options;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.jclouds.googlecomputeengine.domain.Firewall;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Options to create a firewall.
+ *
+ * @see Firewall
+ */
+public class FirewallOptions {
+
+ private String name;
+ private URI network;
+ private ImmutableSet.Builder<String> sourceRanges = ImmutableSet.builder();
+ private ImmutableSet.Builder<String> sourceTags = ImmutableSet.builder();
+ private ImmutableSet.Builder<String> targetTags = ImmutableSet.builder();
+ private ImmutableSet.Builder<Firewall.Rule> allowed = ImmutableSet.builder();
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getAllowed()
+ */
+ public Set<Firewall.Rule> getAllowed() {
+ return allowed.build();
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getAllowed()
+ */
+ public FirewallOptions addAllowedRule(Firewall.Rule allowedRule) {
+ this.allowed.add(allowedRule);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getAllowed()
+ */
+ public FirewallOptions allowedRules(Set<Firewall.Rule> allowedRules) {
+ this.allowed = ImmutableSet.builder();
+ this.allowed.addAll(allowedRules);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getName()
+ */
+ public FirewallOptions name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getNetwork()
+ */
+ public FirewallOptions network(URI network) {
+ this.network = network;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getNetwork()
+ */
+ public URI getNetwork() {
+ return network;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceRanges()
+ */
+ public Set<String> getSourceRanges() {
+ return sourceRanges.build();
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceRanges()
+ */
+ public FirewallOptions addSourceRange(String sourceRange) {
+ this.sourceRanges.add(sourceRange);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceRanges()
+ */
+ public FirewallOptions sourceRanges(Set<String> sourceRanges) {
+ this.sourceRanges = ImmutableSet.builder();
+ this.sourceRanges.addAll(sourceRanges);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceTags()
+ */
+ public Set<String> getSourceTags() {
+ return sourceTags.build();
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceTags()
+ */
+ public FirewallOptions addSourceTag(String sourceTag) {
+ this.sourceTags.add(sourceTag);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceTags()
+ */
+ public FirewallOptions sourceTags(Set<String> sourceTags) {
+ this.sourceTags = ImmutableSet.builder();
+ this.sourceTags.addAll(sourceTags);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getTargetTags()
+ */
+ public Set<String> getTargetTags() {
+ return targetTags.build();
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getTargetTags()
+ */
+ public FirewallOptions addTargetTag(String targetTag) {
+ this.targetTags.add(targetTag);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Firewall#getTargetTags()
+ */
+ public FirewallOptions targetTags(Set<String> targetTags) {
+ this.targetTags = ImmutableSet.builder();
+ this.targetTags.addAll(targetTags);
+ return this;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java
new file mode 100644
index 0000000..9a3e88e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.options;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.http.options.BaseHttpRequestOptions;
+
+/**
+ * Allows to optionally specify a filter, max results and a page token for <code>listFirstPage()</code> REST methods.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/operations/listFirstPage"/>
+ */
+public class ListOptions extends BaseHttpRequestOptions {
+
+ /**
+ * Optional. Filter expression for filtering listed resources, in the form filter={expression}. Your {expression}
+ * must contain the following:
+ * <p/>
+ * {@code <field_name> <comparison_string> <literal_string>}
+ * <ul>
+ * <li>{@code <field_name>}: The name of the field you want to compare. The field name must be valid for the
+ * type of resource being filtered. Only atomic field types are supported (string, number,
+ * boolean). Array and object fields are not currently supported.</li>
+ * <li>{@code <comparison_string>}: The comparison string, either eq (equals) or ne (not equals).</li>
+ * <li>{@code <literal_string>}: The literal string value to filter to. The literal value must be valid
+ * for the type of field (string, number, boolean). For string fields, the literal value is interpreted as a
+ * regular expression using RE2 syntax. The literal value must match the entire field. For example,
+ * when filtering instances, name eq my_instance won't work, but name eq .*my_instance will work.</li>
+ * </ul>
+ * <p/>
+ * For example:
+ * <p/>
+ * {@code filter=status ne RUNNING}
+ * <p/>
+ * The above filter returns only results whose status field does not equal RUNNING. You can also enclose your
+ * literal string in single, double, or no quotes. For example, all three of the following would be valid
+ * expressions:
+ * <p/>
+ * {@code filter=status ne "RUNNING"}<br/>
+ * {@code filter=status ne 'RUNNING'}<br/>
+ * {@code filter=status ne RUNNING}<br/>
+ * <p/>
+ * Complex regular expressions can also be used, like the following:
+ * {@code name eq '."my_instance_[0-9]+'}
+ */
+ public ListOptions filter(String filter) {
+ this.queryParameters.put("filter", checkNotNull(filter, "filter"));
+ return this;
+ }
+
+ /**
+ * Sets Maximum count of results to be returned. Maximum and default value is 100. Acceptable items are 0 to
+ * 100, inclusive. (Default: 100)
+ */
+ public ListOptions maxResults(Integer maxResults) {
+ this.queryParameters.put("maxResults", checkNotNull(maxResults, "maxResults") + "");
+ return this;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see ListOptions#filter(String)
+ */
+ public ListOptions filter(String filter) {
+ return new ListOptions().filter(filter);
+ }
+
+ /**
+ * @see ListOptions#maxResults(Integer)
+ */
+ public ListOptions maxResults(Integer maxResults) {
+ return new ListOptions().maxResults(maxResults);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/RouteOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/RouteOptions.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/RouteOptions.java
new file mode 100644
index 0000000..ec891ce
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/options/RouteOptions.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.options;
+
+import java.net.URI;
+import java.util.Set;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Options to create a route.
+ *
+ * @see org.jclouds.googlecomputeengine.domain.Route
+ */
+public class RouteOptions {
+
+ private String name;
+ private URI network;
+ private String destRange;
+ private URI nextHopInstance;
+ private String nextHopIp;
+ private URI nextHopNetwork;
+ private URI nextHopGateway;
+ private String description;
+ private Integer priority;
+
+ private ImmutableSet.Builder<String> tags = ImmutableSet.builder();
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getName()
+ */
+ public RouteOptions name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getDescription()
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getDescription()
+ */
+ public RouteOptions description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getDestRange()
+ */
+ public String getDestRange() {
+ return destRange;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getDestRange()
+ */
+ public RouteOptions destRange(String destRange) {
+ this.destRange = destRange;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getNextHopIp()
+ */
+ public String getNextHopIp() {
+ return nextHopIp;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getNextHopIp()
+ */
+ public RouteOptions nextHopIp(String nextHopIp) {
+ this.nextHopIp = nextHopIp;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getPriority()
+ */
+ public Integer getPriority() {
+ return priority;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getPriority()
+ */
+ public RouteOptions priority(Integer priority) {
+ this.priority = priority;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getNetwork()
+ */
+ public RouteOptions network(URI network) {
+ this.network = network;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getNetwork()
+ */
+ public URI getNetwork() {
+ return network;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getNextHopInstance()
+ */
+ public RouteOptions nextHopInstance(URI nextHopInstance) {
+ this.nextHopInstance = nextHopInstance;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getNextHopInstance()
+ */
+ public URI getNextHopInstance() {
+ return nextHopInstance;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getNextHopNetwork()
+ */
+ public RouteOptions nextHopNetwork(URI nextHopNetwork) {
+ this.nextHopNetwork = nextHopNetwork;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getNextHopNetwork()
+ */
+ public URI getNextHopNetwork() {
+ return nextHopNetwork;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getNextHopGateway()
+ */
+ public RouteOptions nextHopGateway(URI nextHopGateway) {
+ this.nextHopGateway = nextHopGateway;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getNextHopGateway()
+ */
+ public URI getNextHopGateway() {
+ return nextHopGateway;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getTags()
+ */
+ public Set<String> getTags() {
+ return tags.build();
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getTags()
+ */
+ public RouteOptions addTag(String tag) {
+ this.tags.add(tag);
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Route#getTags()
+ */
+ public RouteOptions tags(Set<String> tags) {
+ this.tags = ImmutableSet.builder();
+ this.tags.addAll(tags);
+ return this;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/GlobalOperationDonePredicate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/GlobalOperationDonePredicate.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/GlobalOperationDonePredicate.java
new file mode 100644
index 0000000..ac34bcc
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/GlobalOperationDonePredicate.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.predicates;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Operation;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.inject.Inject;
+
+/**
+ * Tests that a Global Operation is done, returning the completed Operation when it is.
+ */
+public class GlobalOperationDonePredicate implements Predicate<AtomicReference<Operation>> {
+
+ private final GoogleComputeEngineApi api;
+ private final Supplier<String> project;
+
+ @Inject
+ public GlobalOperationDonePredicate(GoogleComputeEngineApi api, @UserProject Supplier<String> project) {
+ this.api = api;
+ this.project = project;
+ }
+
+ @Override
+ public boolean apply(AtomicReference<Operation> input) {
+ checkNotNull(input, "input");
+ Operation current = api.getGlobalOperationApiForProject(project.get()).get(input.get().getName());
+ switch (current.getStatus()) {
+ case DONE:
+ input.set(current);
+ return true;
+ case PENDING:
+ case RUNNING:
+ default:
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/InstancePredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/InstancePredicates.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/InstancePredicates.java
new file mode 100644
index 0000000..8cde680
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/InstancePredicates.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.predicates;
+
+import org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk;
+
+import com.google.common.base.Predicate;
+
+public class InstancePredicates {
+
+ public static Predicate<PersistentDisk> isBootDisk() {
+ return new Predicate<PersistentDisk>() {
+ @Override
+ public boolean apply(PersistentDisk input) {
+ return input.isBoot();
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/NetworkFirewallPredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/NetworkFirewallPredicates.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/NetworkFirewallPredicates.java
new file mode 100644
index 0000000..63d2767
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/NetworkFirewallPredicates.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.predicates;
+
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.domain.Firewall.Rule;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Range;
+import com.google.common.collect.Sets;
+
+public class NetworkFirewallPredicates {
+
+ public static Predicate<Firewall> hasProtocol(final IpProtocol protocol) {
+ return new Predicate<Firewall>() {
+
+ @Override
+ public boolean apply(Firewall fw) {
+ for (Rule rule : fw.getAllowed()) {
+ if (rule.getIpProtocol().equals(protocol)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ };
+ }
+
+ public static Predicate<Firewall> hasPortRange(final Range<Integer> portRange) {
+ return new Predicate<Firewall>() {
+
+ @Override
+ public boolean apply(Firewall fw) {
+ return Iterables.any(fw.getAllowed(), new Predicate<Rule>() {
+ @Override
+ public boolean apply(Rule input) {
+ return input.getPorts().encloses(portRange);
+ }
+ });
+ }
+ };
+ }
+
+ public static Predicate<Firewall> hasSourceTag(final String sourceTag) {
+ return new Predicate<Firewall>() {
+ @Override
+ public boolean apply(Firewall input) {
+ return input.getSourceTags() != null && input.getSourceTags().contains(sourceTag);
+ }
+ };
+ }
+
+ public static Predicate<Firewall> hasSourceRange(final String sourceRange) {
+ return new Predicate<Firewall>() {
+ @Override
+ public boolean apply(Firewall input) {
+ return input.getSourceRanges() != null && input.getSourceRanges().contains(sourceRange);
+ }
+ };
+ }
+
+ public static Predicate<Firewall> equalsIpPermission(final IpPermission permission) {
+ return new Predicate<Firewall>() {
+ @Override
+ public boolean apply(Firewall input) {
+ return Iterables.elementsEqual(permission.getGroupIds(), input.getSourceTags())
+ && Iterables.elementsEqual(permission.getCidrBlocks(), input.getSourceRanges())
+ && (input.getAllowed().size() == 1
+ && ruleEqualsIpPermission(permission).apply(Iterables.getOnlyElement(input.getAllowed())));
+ }
+ };
+ }
+
+ public static Predicate<Firewall> providesIpPermission(final IpPermission permission) {
+ return new Predicate<Firewall>() {
+ @Override
+ public boolean apply(Firewall input) {
+ boolean groupsMatchTags = (permission.getGroupIds().isEmpty() && input.getSourceTags().isEmpty())
+ || !Sets.intersection(permission.getGroupIds(), input.getSourceTags()).isEmpty();
+ boolean cidrsMatchRanges = (permission.getCidrBlocks().isEmpty() && input.getSourceRanges().isEmpty())
+ || !Sets.intersection(permission.getCidrBlocks(), input.getSourceRanges()).isEmpty();
+ boolean firewallHasPorts = hasProtocol(permission.getIpProtocol()).apply(input)
+ && ((permission.getFromPort() == 0 && permission.getToPort() == 0)
+ || hasPortRange(Range.closed(permission.getFromPort(), permission.getToPort())).apply(input));
+
+ return groupsMatchTags && cidrsMatchRanges && firewallHasPorts;
+ }
+ };
+ }
+
+ private static Predicate<Firewall.Rule> ruleEqualsIpPermission(final IpPermission permission) {
+ return new Predicate<Rule>() {
+ @Override
+ public boolean apply(Firewall.Rule input) {
+ return permission.getIpProtocol().equals(input.getIpProtocol())
+ && ((input.getPorts().isEmpty() && permission.getFromPort() == 0 && permission.getToPort() == 0)
+ || (input.getPorts().asRanges().size() == 1
+ && permission.getFromPort() == Iterables.getOnlyElement(input.getPorts().asRanges()).lowerEndpoint()
+ && permission.getToPort() == Iterables.getOnlyElement(input.getPorts().asRanges()).upperEndpoint()));
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java
new file mode 100644
index 0000000..1f3dee6
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.predicates;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.Region;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.inject.Inject;
+
+/**
+ * Tests that a Global Operation is done, returning the completed Operation when it is.
+ */
+public class RegionOperationDonePredicate implements Predicate<AtomicReference<Operation>> {
+
+ private final GoogleComputeEngineApi api;
+ private final Supplier<String> project;
+ private final Supplier<Map<URI, Region>> regions;
+
+ @Inject
+ RegionOperationDonePredicate(GoogleComputeEngineApi api, @UserProject Supplier<String> project,
+ @Memoized Supplier<Map<URI, Region>> regions) {
+ this.api = api;
+ this.project = project;
+ this.regions = regions;
+ }
+
+ @Override
+ public boolean apply(AtomicReference<Operation> input) {
+ checkNotNull(input, "input");
+
+ Operation current = api.getRegionOperationApiForProject(project.get())
+ .getInRegion(regions.get().get(input.get().getRegion().get()).getName(),
+ input.get().getName());
+ switch (current.getStatus()) {
+ case DONE:
+ input.set(current);
+ return true;
+ case PENDING:
+ case RUNNING:
+ default:
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java
new file mode 100644
index 0000000..c63c6f3
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.predicates;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.domain.Location;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Operation;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.inject.Inject;
+
+/**
+ * Tests that a Zone Operation is done, returning the completed Operation when it is.
+ */
+public class ZoneOperationDonePredicate implements Predicate<AtomicReference<Operation>> {
+
+ private final GoogleComputeEngineApi api;
+ private final Supplier<String> project;
+ private final Supplier<Map<URI, ? extends Location>> zones;
+
+ @Inject
+ ZoneOperationDonePredicate(GoogleComputeEngineApi api, @UserProject Supplier<String> project,
+ @Memoized Supplier<Map<URI, ? extends Location>> zones) {
+ this.api = api;
+ this.project = project;
+ this.zones = zones;
+ }
+
+ @Override
+ public boolean apply(AtomicReference<Operation> input) {
+ checkNotNull(input, "input");
+ Operation current = api.getZoneOperationApiForProject(project.get())
+ .getInZone(zones.get().get(input.get().getZone().get()).getId(),
+ input.get().getName());
+ switch (current.getStatus()) {
+ case DONE:
+ input.set(current);
+ return true;
+ case PENDING:
+ case RUNNING:
+ default:
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/OAuthApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/OAuthApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/OAuthApi.java
new file mode 100644
index 0000000..1b20734
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/OAuthApi.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2;
+
+import java.io.Closeable;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.oauth.v2.config.Authentication;
+import org.jclouds.oauth.v2.domain.Token;
+import org.jclouds.oauth.v2.domain.TokenRequest;
+import org.jclouds.oauth.v2.handlers.OAuthTokenBinder;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Endpoint;
+
+/**
+ * Provides access to OAuth via REST api.
+ * <p/>
+ * Usually this is not directly used by a client, which instead specifies
+ * OAuthAuthenticator as a request filter, which in turn uses this class to
+ * perform token requests.
+ */
+@Endpoint(Authentication.class)
+public interface OAuthApi extends Closeable {
+
+ /**
+ * Authenticates/Authorizes access to a resource defined in TokenRequest
+ * against an OAuth v2 authentication/authorization server.
+ *
+ * @param tokenRequest
+ * specified the principal and the required permissions
+ * @return a Token object with the token required to access the resource
+ * along with its expiration time
+ * @throws AuthorizationException
+ * if the principal cannot be authenticated or has no permissions
+ * for the specifed resources.
+ */
+ @Named("authenticate")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ Token authenticate(@BinderParam(OAuthTokenBinder.class) TokenRequest tokenRequest) throws AuthorizationException;
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/OAuthApiMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/OAuthApiMetadata.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/OAuthApiMetadata.java
new file mode 100644
index 0000000..3ef26e6
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/OAuthApiMetadata.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2;
+
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
+import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.jclouds.oauth.v2.config.OAuthHttpApiModule;
+import org.jclouds.oauth.v2.config.OAuthModule;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+
+/**
+ * Implementation of {@link ApiMetadata} for OAuth 2 API
+ */
+public class OAuthApiMetadata extends BaseHttpApiMetadata<OAuthApi> {
+
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
+ }
+
+ public OAuthApiMetadata() {
+ this(new Builder());
+ }
+
+ protected OAuthApiMetadata(Builder builder) {
+ super(builder);
+ }
+
+ public static Properties defaultProperties() {
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
+ properties.put(SIGNATURE_OR_MAC_ALGORITHM, "RS256");
+ properties.put(PROPERTY_SESSION_INTERVAL, 3600);
+ return properties;
+ }
+
+ public static class Builder extends BaseHttpApiMetadata.Builder<OAuthApi, Builder> {
+
+ protected Builder() {
+ id("oauth")
+ .name("OAuth API")
+ .identityName("service_account")
+ .credentialName("service_key")
+ .documentation(URI.create("TODO"))
+ .version("2")
+ .defaultProperties(OAuthApiMetadata.defaultProperties())
+ .defaultModules(ImmutableSet.<Class<? extends Module>>of(OAuthModule.class, OAuthHttpApiModule.class));
+ }
+
+ @Override
+ public OAuthApiMetadata build() {
+ return new OAuthApiMetadata(this);
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/OAuthConstants.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/OAuthConstants.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/OAuthConstants.java
new file mode 100644
index 0000000..9b140d4
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/OAuthConstants.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2;
+
+import com.google.common.collect.ImmutableMap;
+
+import java.util.Map;
+
+/**
+ * The constants for OAuth \
+ */
+public final class OAuthConstants {
+
+ /**
+ * Selected algorithm when a signature or mac isn't required.
+ */
+ public static final String NO_ALGORITHM = "none";
+
+ /**
+ * Static mapping between the oauth algorithm name and the Crypto provider signature algorithm name.
+ *
+ * @see <a href="http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-06#section-3.1">doc</a>
+ * @see org.jclouds.oauth.v2.json.JWTTokenRequestFormat
+ */
+ public static final Map<String, String> OAUTH_ALGORITHM_NAMES_TO_SIGNATURE_ALGORITHM_NAMES = ImmutableMap
+ .<String, String>builder()
+ .put("RS256", "SHA256withRSA")
+ .put("RS384", "SHA384withRSA")
+ .put("RS512", "SHA512withRSA")
+ .put("HS256", "HmacSHA256")
+ .put("HS384", "HmacSHA384")
+ .put("HS512", "HmacSHA512")
+ .put("ES256", "SHA256withECDSA")
+ .put("ES384", "SHA384withECDSA")
+ .put("ES512", "SHA512withECDSA")
+ .put(NO_ALGORITHM, NO_ALGORITHM).build();
+
+ /**
+ * Static mapping between the oauth algorithm name and the Crypto provider KeyFactory algorithm name.
+ *
+ * @see <a href="http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-06#section-3.1">doc</a>
+ */
+ public static final Map<String, String> OAUTH_ALGORITHM_NAMES_TO_KEYFACTORY_ALGORITHM_NAMES = ImmutableMap
+ .<String, String>builder()
+ .put("RS256", "RSA")
+ .put("RS384", "RSA")
+ .put("RS512", "RSA")
+ .put("HS256", "DiffieHellman")
+ .put("HS384", "DiffieHellman")
+ .put("HS512", "DiffieHellman")
+ .put("ES256", "EC")
+ .put("ES384", "EC")
+ .put("ES512", "EC")
+ .put(NO_ALGORITHM, NO_ALGORITHM).build();
+
+ /**
+ * The (optional) set of additional claims to use, provided in Map<String,String> form
+ */
+ public static final String ADDITIONAL_CLAIMS = "jclouds.oauth.additional-claims";
+
+ private OAuthConstants() {
+ throw new AssertionError("intentionally unimplemented");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/Authentication.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/Authentication.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/Authentication.java
new file mode 100644
index 0000000..24f6851
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/Authentication.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.config;
+
+
+import javax.inject.Qualifier;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Qualifies OAuth related resources, such as Endpoint.
+ *
+ * @see org.jclouds.oauth.v2.OAuthApi
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
+@Qualifier
+public @interface Authentication {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/CredentialType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/CredentialType.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/CredentialType.java
new file mode 100644
index 0000000..24a658b
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/CredentialType.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.config;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.CaseFormat;
+
+/**
+ * Decides what type of credentials createContext is supplied with.
+ */
+public enum CredentialType {
+
+ BEARER_TOKEN_CREDENTIALS,
+
+ SERVICE_ACCOUNT_CREDENTIALS;
+
+ @Override
+ public String toString() {
+ return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
+ }
+
+ public static CredentialType fromValue(String credentialType) {
+ return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(credentialType,
+ "credentialType")));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthAuthenticationModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthAuthenticationModule.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthAuthenticationModule.java
new file mode 100644
index 0000000..fb2d413
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthAuthenticationModule.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.config;
+
+import static org.jclouds.rest.config.BinderUtils.bindHttpApi;
+
+import java.net.URI;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.oauth.v2.OAuthApi;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+
+/**
+ * An OAuth module to be used form other providers.
+ */
+public class OAuthAuthenticationModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bindHttpApi(binder(), OAuthApi.class);
+ }
+
+ /**
+ * When oauth is used as a module the oauth endpoint is a normal property
+ */
+ @Provides
+ @Singleton
+ @Authentication
+ protected Supplier<URI> provideAuthenticationEndpoint(@Named("oauth.endpoint") String endpoint) {
+ return Suppliers.ofInstance(URI.create(endpoint));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthHttpApiModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthHttpApiModule.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthHttpApiModule.java
new file mode 100644
index 0000000..6b4fdf9
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthHttpApiModule.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.config;
+
+import java.net.URI;
+
+import javax.inject.Singleton;
+
+import org.jclouds.oauth.v2.OAuthApi;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.jclouds.rest.config.HttpApiModule;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.inject.Provides;
+
+/**
+ * OAuth module to when accessing OAuth stand-alone.
+ */
+@ConfiguresHttpApi
+public class OAuthHttpApiModule extends HttpApiModule<OAuthApi> {
+
+ @Provides
+ @Singleton
+ @Authentication
+ protected Supplier<URI> provideAuthenticationEndpoint(ProviderMetadata providerMetadata) {
+ return Suppliers.ofInstance(URI.create(providerMetadata.getEndpoint()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthModule.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthModule.java
new file mode 100644
index 0000000..1041c07
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/oauth/v2/config/OAuthModule.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.oauth.v2.config;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+import com.google.inject.name.Named;
+import org.jclouds.oauth.v2.domain.ClaimSet;
+import org.jclouds.oauth.v2.domain.Header;
+import org.jclouds.oauth.v2.domain.OAuthCredentials;
+import org.jclouds.oauth.v2.domain.Token;
+import org.jclouds.oauth.v2.domain.TokenRequest;
+import org.jclouds.oauth.v2.filters.BearerTokenAuthenticator;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticator;
+import org.jclouds.oauth.v2.functions.BuildTokenRequest;
+import org.jclouds.oauth.v2.functions.FetchToken;
+import org.jclouds.oauth.v2.functions.OAuthCredentialsSupplier;
+import org.jclouds.oauth.v2.functions.SignOrProduceMacForToken;
+import org.jclouds.oauth.v2.json.ClaimSetTypeAdapter;
+import org.jclouds.oauth.v2.json.HeaderTypeAdapter;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import java.lang.reflect.Type;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
+
+/**
+ * Base OAuth module
+ */
+public class OAuthModule extends AbstractModule {
+
+
+ @Override
+ protected void configure() {
+ bind(new TypeLiteral<Function<byte[], byte[]>>() {}).to(SignOrProduceMacForToken.class);
+ bind(new TypeLiteral<Map<Type, Object>>() {}).toInstance(ImmutableMap.<Type, Object>of(
+ Header.class, new HeaderTypeAdapter(),
+ ClaimSet.class, new ClaimSetTypeAdapter()));
+ bind(CredentialType.class).toProvider(CredentialTypeFromPropertyOrDefault.class);
+ bind(new TypeLiteral<Supplier<OAuthCredentials>>() {}).to(OAuthCredentialsSupplier.class);
+ bind(new TypeLiteral<Function<GeneratedHttpRequest, TokenRequest>>() {}).to(BuildTokenRequest.class);
+ bind(new TypeLiteral<Function<TokenRequest, Token>>() {}).to(FetchToken.class);
+ }
+
+ /**
+ * Provides a cache for tokens. Cache is time based and by default expires after 59 minutes
+ * (the maximum time a token is valid is 60 minutes).
+ * This cache and expiry period is system-wide and does not attend to per-instance expiry time
+ * (e.g. "expires_in" from Google Compute -- which is set to the standard 3600 seconds).
+ */
+ // NB: If per-instance expiry time is required, significant refactoring will be needed.
+ @Provides
+ @Singleton
+ public LoadingCache<TokenRequest, Token> provideAccessCache(Function<TokenRequest, Token> getAccess,
+ @Named(PROPERTY_SESSION_INTERVAL) long
+ sessionIntervalInSeconds) {
+ // since the session interval is also the token expiration time requested to the server make the token expire a
+ // bit before the deadline to make sure there aren't session expiration exceptions
+ sessionIntervalInSeconds = sessionIntervalInSeconds > 30 ? sessionIntervalInSeconds - 30 :
+ sessionIntervalInSeconds;
+ return CacheBuilder.newBuilder().expireAfterWrite(sessionIntervalInSeconds, TimeUnit.SECONDS).build(CacheLoader
+ .from(getAccess));
+ }
+
+ @Singleton
+ public static class CredentialTypeFromPropertyOrDefault implements Provider<CredentialType> {
+ @Inject(optional = true)
+ @Named(OAuthProperties.CREDENTIAL_TYPE)
+ String credentialType = CredentialType.SERVICE_ACCOUNT_CREDENTIALS.toString();
+
+ @Override
+ public CredentialType get() {
+ return CredentialType.fromValue(credentialType);
+ }
+ }
+
+ @Provides
+ @Singleton
+ protected OAuthAuthenticationFilter authenticationFilterForCredentialType(CredentialType credentialType,
+ OAuthAuthenticator serviceAccountAuth,
+ BearerTokenAuthenticator bearerTokenAuth) {
+ switch (credentialType) {
+ case SERVICE_ACCOUNT_CREDENTIALS:
+ return serviceAccountAuth;
+ case BEARER_TOKEN_CREDENTIALS:
+ return bearerTokenAuth;
+ default:
+ throw new IllegalArgumentException("Unsupported credential type: " + credentialType);
+ }
+ }
+
+}
[02/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/taskslist.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/taskslist.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/taskslist.xml
new file mode 100644
index 0000000..fe0d8c1
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/taskslist.xml
@@ -0,0 +1,27 @@
+<TasksList
+ href="https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/1"
+ xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Task
+ href="https://services.vcloudexpress.terremark.com/api/v0.8/task/3300"
+ type="application/vnd.vmware.vcloud.task+xml" status="success"
+ startTime="2009-08-24T21:30:19.587Z" endTime="2009-08-24T21:30:32.63Z">
+ <Owner
+ href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1"
+ type="application/vnd.vmware.vcloud.vdc+xml" name="VDC Name" />
+ <Result
+ href="https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012"
+ type="application/vnd.vmware.vcloud.vApp+xml" name="Server1" />
+ </Task>
+ <Task
+ href="https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"
+ type="application/vnd.vmware.vcloud.task+xml" status="success"
+ startTime="2009-08-24T21:29:32.983Z" endTime="2009-08-24T21:29:44.65Z">
+ <Owner
+ href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1"
+ type="application/vnd.vmware.vcloud.vdc+xml" name="VDC Name" />
+ <Result
+ href="https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012"
+ type="application/vnd.vmware.vcloud.vApp+xml" name="Server1" />
+ </Task>
+</TasksList>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/template1.0-vcd15-multi-vm.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/template1.0-vcd15-multi-vm.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/template1.0-vcd15-multi-vm.xml
new file mode 100644
index 0000000..46b3c83
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/template1.0-vcd15-multi-vm.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VAppTemplate xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" ovfDescriptorUploaded="true" status="8" name="Windows Server 2008 R2" type="application/vnd.vmware.vcloud.vAppTemplate+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://www.vmware.com/vcloud/v1 http://zone.myvcloud.com/api/v1.0/schema/master.xsd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml" href="https://zone.myvcloud.com/api/v1.0/vdc/cf6a0068-b7c4-425c-9e80-46ffef58782a"/>
+ <Link rel="catalogItem" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://zone.myvcloud.com/api/v1.0/catalogItem/9c45dbbd-910d-45c8-a811-d1e0b01e9e82"/>
+ <Link rel="remove" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.vAppTemplate+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728"/>
+ <Link rel="enable" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/action/enableDownload"/>
+ <Link rel="disable" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/action/disableDownload"/>
+ <Link rel="ovf" type="text/xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/ovf"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.owner+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/owner"/>
+ <Description/>
+ <Children>
+ <Vm name="Windows Server 2008 R2" type="application/vnd.vmware.vcloud.vm+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vm-24fc1b05-10f7-423e-a644-fd3368f9d0cd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.vAppTemplate+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728"/>
+ <Description/>
+ <NetworkConnectionSection type="application/vnd.vmware.vcloud.networkConnectionSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vm-24fc1b05-10f7-423e-a644-fd3368f9d0cd/networkConnectionSection/" ovf:required="false">
+ <ovf:Info>Specifies the available VM network connections</ovf:Info>
+ <PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
+ <NetworkConnection network="none">
+ <NetworkConnectionIndex>0</NetworkConnectionIndex>
+ <IsConnected>false</IsConnected>
+ <MACAddress>00:50:56:b5:09:dc</MACAddress>
+ <IpAddressAllocationMode>NONE</IpAddressAllocationMode>
+ </NetworkConnection>
+ </NetworkConnectionSection>
+ <GuestCustomizationSection type="application/vnd.vmware.vcloud.guestCustomizationSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vm-24fc1b05-10f7-423e-a644-fd3368f9d0cd/guestCustomizationSection/" ovf:required="false">
+ <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
+ <Enabled>true</Enabled>
+ <ChangeSid>false</ChangeSid>
+ <JoinDomainEnabled>false</JoinDomainEnabled>
+ <UseOrgSettings>false</UseOrgSettings>
+ <AdminPasswordEnabled>true</AdminPasswordEnabled>
+ <AdminPasswordAuto>true</AdminPasswordAuto>
+ <ResetPasswordRequired>true</ResetPasswordRequired> <ComputerName>WindowsServ-001</ComputerName>
+ </GuestCustomizationSection>
+ <VAppScopedLocalId>Windows Server 2008 R2</VAppScopedLocalId>
+ </Vm>
+ </Children>
+ <ovf:NetworkSection xmlns:vcloud="http://www.vmware.com/vcloud/v1" vcloud:href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/networkSection/" vcloud:type="application/vnd.vmware.vcloud.networkSection+xml"> <ovf:Info>The list of logical networks</ovf:Info>
+ <ovf:Network ovf:name="none">
+ <ovf:Description>This is a special place-holder used for disconnected network interfaces.</ovf:Description>
+ </ovf:Network> </ovf:NetworkSection>
+ <NetworkConfigSection type="application/vnd.vmware.vcloud.networkConfigSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/networkConfigSection/" ovf:required="false">
+ <ovf:Info>The configuration parameters for logical networks</ovf:Info>
+ <NetworkConfig networkName="none">
+ <Description>This is a special place-holder used for disconnected network interfaces.</Description>
+ <Configuration>
+ <IpScope>
+ <IsInherited>false</IsInherited>
+ <Gateway>196.254.254.254</Gateway>
+ <Netmask>255.255.0.0</Netmask>
+ <Dns1>196.254.254.254</Dns1>
+ </IpScope>
+ <FenceMode>isolated</FenceMode>
+ </Configuration>
+ <IsDeployed>false</IsDeployed>
+ </NetworkConfig>
+ </NetworkConfigSection>
+ <LeaseSettingsSection type="application/vnd.vmware.vcloud.leaseSettingsSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/leaseSettingsSection/" ovf:required="false">
+ <ovf:Info>Lease settings section</ovf:Info> <Link rel="edit" type="application/vnd.vmware.vcloud.leaseSettingsSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/leaseSettingsSection/"/>
+ <StorageLeaseInSeconds>0</StorageLeaseInSeconds>
+ </LeaseSettingsSection>
+ <CustomizationSection type="application/vnd.vmware.vcloud.customizationSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/customizationSection/" ovf:required="false">
+ <ovf:Info>VApp template customization section</ovf:Info>
+ <CustomizeOnInstantiate>true</CustomizeOnInstantiate>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.customizationSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/customizationSection/"/>
+ </CustomizationSection>
+</VAppTemplate>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/template1.0-vcd15.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/template1.0-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/template1.0-vcd15.xml
new file mode 100644
index 0000000..35393ee
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/template1.0-vcd15.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VAppTemplate xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" ovfDescriptorUploaded="true" status="8" name="UbuntuServer-x64-2GB" type="application/vnd.vmware.vcloud.vAppTemplate+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://www.vmware.com/vcloud/v1 https://zone.myvcloud.com/api/v1.0/schema/master.xsd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml" href="https://zone.myvcloud.com/api/v1.0/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"/>
+ <Link rel="catalogItem" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://zone.myvcloud.com/api/v1.0/catalogItem/ceb369f7-1d07-4e32-9dbd-ebb5aa6ca55c"/>
+ <Link rel="remove" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.vAppTemplate+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728"/>
+ <Link rel="enable" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/action/enableDownload"/>
+ <Link rel="disable" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/action/disableDownload"/>
+ <Link rel="ovf" type="text/xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/ovf"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.owner+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/owner"/>
+ <Description/>
+ <Children>
+ <Vm name="UbuntuServer-x64-2GB" type="application/vnd.vmware.vcloud.vm+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vm-3aee3d0d-106a-4c63-8529-1edde335b212">
+ <Link rel="up" type="application/vnd.vmware.vcloud.vAppTemplate+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728"/>
+ <Description/>
+ <NetworkConnectionSection type="application/vnd.vmware.vcloud.networkConnectionSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vm-3aee3d0d-106a-4c63-8529-1edde335b212/networkConnectionSection/" ovf:required="false">
+ <ovf:Info>Specifies the available VM network connections</ovf:Info>
+ <PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
+ <NetworkConnection network="none">
+ <NetworkConnectionIndex>0</NetworkConnectionIndex>
+ <IsConnected>false</IsConnected>
+ <MACAddress>00:50:56:01:02:9f</MACAddress>
+ <IpAddressAllocationMode>NONE</IpAddressAllocationMode>
+ </NetworkConnection>
+ </NetworkConnectionSection>
+ <GuestCustomizationSection type="application/vnd.vmware.vcloud.guestCustomizationSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vm-3aee3d0d-106a-4c63-8529-1edde335b212/guestCustomizationSection/" ovf:required="false">
+ <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
+ <Enabled>true</Enabled>
+ <ChangeSid>false</ChangeSid>
+ <JoinDomainEnabled>false</JoinDomainEnabled>
+ <UseOrgSettings>false</UseOrgSettings>
+ <AdminPasswordEnabled>true</AdminPasswordEnabled>
+ <AdminPasswordAuto>true</AdminPasswordAuto>
+ <ResetPasswordRequired>false</ResetPasswordRequired>
+ <ComputerName>UbuntuServer</ComputerName>
+ </GuestCustomizationSection>
+ <VAppScopedLocalId>f114ade7-a63f-4f8b-b30b-44e9ff77e068</VAppScopedLocalId>
+ </Vm>
+ </Children>
+ <ovf:NetworkSection xmlns:vcloud="http://www.vmware.com/vcloud/v1" vcloud:href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/networkSection/" vcloud:type="application/vnd.vmware.vcloud.networkSection+xml">
+ <ovf:Info>The list of logical networks</ovf:Info>
+ <ovf:Network ovf:name="none">
+ <ovf:Description>This is a special place-holder used for disconnected network interfaces.</ovf:Description>
+ </ovf:Network>
+ </ovf:NetworkSection>
+ <NetworkConfigSection type="application/vnd.vmware.vcloud.networkConfigSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/networkConfigSection/" ovf:required="false">
+ <ovf:Info>The configuration parameters for logical networks</ovf:Info>
+ <NetworkConfig networkName="none">
+ <Description>This is a special place-holder used for disconnected network interfaces.</Description>
+ <Configuration>
+ <IpScope>
+ <IsInherited>false</IsInherited>
+ <Gateway>196.254.254.254</Gateway>
+ <Netmask>255.255.0.0</Netmask>
+ <Dns1>196.254.254.254</Dns1>
+ </IpScope>
+ <FenceMode>isolated</FenceMode>
+ </Configuration>
+ <IsDeployed>false</IsDeployed>
+ </NetworkConfig>
+ </NetworkConfigSection>
+ <LeaseSettingsSection type="application/vnd.vmware.vcloud.leaseSettingsSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/leaseSettingsSection/" ovf:required="false">
+ <ovf:Info>Lease settings section</ovf:Info>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.leaseSettingsSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/leaseSettingsSection/"/>
+ <StorageLeaseInSeconds>5184000</StorageLeaseInSeconds>
+ <StorageLeaseExpiration>2012-03-12T17:40:44.491-06:00</StorageLeaseExpiration>
+ </LeaseSettingsSection>
+ <CustomizationSection type="application/vnd.vmware.vcloud.customizationSection+xml" href="https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728/customizationSection/" ovf:required="false">
+ <ovf:Info>VApp template customization section</ovf:Info>
+ <CustomizeOnInstantiate>true</CustomizeOnInstantiate>
+ </CustomizationSection>
+</VAppTemplate>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vAppTemplate-copying.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vAppTemplate-copying.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vAppTemplate-copying.xml
new file mode 100644
index 0000000..8ffa7d7
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vAppTemplate-copying.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VAppTemplate xmlns="http://www.vmware.com/vcloud/v1"
+ xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
+ ovfDescriptorUploaded="true" status="0" name="Ubuntu10.04_v2"
+ type="application/vnd.vmware.vcloud.vAppTemplate+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vdc/105186609" />
+ <Description />
+ <Tasks>
+ <Task status="running" startTime="2010-09-17T23:20:46.039-04:00"
+ operation="Copying Virtual Application Template Ubuntu10.04_v2(699683881)"
+ expiryTime="2010-12-16T23:20:46.039-05:00" endTime="9999-12-31T23:59:59.999-05:00"
+ type="application/vnd.vmware.vcloud.task+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/task/q62gxhi32xgd9yrqvr">
+ <Owner type="application/vnd.vmware.vcloud.vAppTemplate+xml"
+ name="Ubuntu10.04_v2"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881" />
+ </Task>
+ </Tasks>
+ <Children />
+ <LeaseSettingsSection
+ type="application/vnd.vmware.vcloud.leaseSettingsSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881/leaseSettingsSection/"
+ ovf:required="false">
+ <ovf:Info>Lease settings section</ovf:Info>
+ <Link rel="edit"
+ type="application/vnd.vmware.vcloud.leaseSettingsSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881/leaseSettingsSection/" />
+ <StorageLeaseInSeconds>0</StorageLeaseInSeconds>
+ </LeaseSettingsSection>
+ <CustomizationSection
+ type="application/vnd.vmware.vcloud.customizationSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881/customizationSection/"
+ ovf:required="false">
+ <ovf:Info>VApp template customization section</ovf:Info>
+ <CustomizeOnInstantiate>true</CustomizeOnInstantiate>
+ </CustomizationSection>
+</VAppTemplate>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vAppTemplate.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vAppTemplate.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vAppTemplate.xml
new file mode 100644
index 0000000..bb5fcaf
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vAppTemplate.xml
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VAppTemplate xmlns="http://www.vmware.com/vcloud/v1"
+ xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
+ ovfDescriptorUploaded="true" status="8" name="Ubuntu Template"
+ type="application/vnd.vmware.vcloud.vAppTemplate+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439" />
+ <Link rel="catalogItem" type="application/vnd.vmware.vcloud.catalogItem+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2090447518" />
+ <Link rel="remove"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921" />
+ <Link rel="edit" type="application/vnd.vmware.vcloud.vAppTemplate+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921" />
+ <Link rel="enable"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/action/enableDownload" />
+ <Link rel="disable"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/action/disableDownload" />
+ <Link rel="ovf" type="text/xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/ovf" />
+ <Description />
+ <Children>
+ <Vm name="Ubuntu1004" type="application/vnd.vmware.vcloud.vAppTemplate+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vm-172837194">
+ <Link rel="up" type="application/vnd.vmware.vcloud.vAppTemplate+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921" />
+ <Description />
+ <NetworkConnectionSection
+ type="application/vnd.vmware.vcloud.networkConnectionSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vm-172837194/networkConnectionSection/"
+ ovf:required="false">
+ <ovf:Info>Specifies the available VM network connections</ovf:Info>
+ <PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
+ <NetworkConnection network="vAppNet-vApp Internal">
+ <NetworkConnectionIndex>0</NetworkConnectionIndex>
+ <IpAddress>192.168.2.100</IpAddress>
+ <IsConnected>true</IsConnected>
+ <MACAddress>00:50:56:8c:00:13</MACAddress>
+ <IpAddressAllocationMode>POOL</IpAddressAllocationMode>
+ </NetworkConnection>
+ </NetworkConnectionSection>
+ <GuestCustomizationSection
+ type="application/vnd.vmware.vcloud.guestCustomizationSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vm-172837194/guestCustomizationSection/"
+ ovf:required="false">
+ <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
+ <Enabled>true</Enabled>
+ <ChangeSid>false</ChangeSid>
+ <VirtualMachineId>172837194</VirtualMachineId>
+ <JoinDomainEnabled>false</JoinDomainEnabled>
+ <UseOrgSettings>false</UseOrgSettings>
+ <AdminPasswordEnabled>true</AdminPasswordEnabled>
+ <AdminPasswordAuto>true</AdminPasswordAuto>
+ <AdminPassword>%3eD%gmF</AdminPassword>
+ <ResetPasswordRequired>false</ResetPasswordRequired>
+ <CustomizationScript>#!/bin/bash if [ "$1" = "postcustomization" ]; then echo "post customization" touch /root/.postcustomization sleep 30 #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server echo "completed" fi</CustomizationScript>
+ <ComputerName>Ubuntu1004</ComputerName>
+ </GuestCustomizationSection>
+ <VAppScopedLocalId>02_ubuntu_template</VAppScopedLocalId>
+ </Vm>
+ </Children>
+ <ovf:NetworkSection xmlns:vcloud="http://www.vmware.com/vcloud/v1"
+ vcloud:href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/networkSection/"
+ vcloud:type="application/vnd.vmware.vcloud.networkSection+xml">
+ <ovf:Info>The list of logical networks</ovf:Info>
+ <ovf:Network ovf:name="vAppNet-vApp Internal">
+ <ovf:Description />
+ </ovf:Network>
+ </ovf:NetworkSection>
+ <NetworkConfigSection
+ type="application/vnd.vmware.vcloud.networkConfigSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/networkConfigSection/"
+ ovf:required="false">
+ <ovf:Info>The configuration parameters for logical networks</ovf:Info>
+ <NetworkConfig networkName="vAppNet-vApp Internal">
+ <Description />
+ <Configuration>
+ <IpScope>
+ <IsInherited>false</IsInherited>
+ <Gateway>192.168.2.1</Gateway>
+ <Netmask>255.255.255.0</Netmask>
+ <Dns1>8.8.8.8</Dns1>
+ <IpRanges>
+ <IpRange>
+ <StartAddress>192.168.2.100</StartAddress>
+ <EndAddress>192.168.2.199</EndAddress>
+ </IpRange>
+ </IpRanges>
+ <AllocatedIpAddresses>
+ <IpAddress>192.168.2.100</IpAddress>
+ </AllocatedIpAddresses>
+ </IpScope>
+ <FenceMode>isolated</FenceMode>
+ <Features>
+ <DhcpService>
+ <IsEnabled>false</IsEnabled>
+ <DefaultLeaseTime>7200</DefaultLeaseTime>
+ <MaxLeaseTime>7200</MaxLeaseTime>
+ <IpRange />
+ </DhcpService>
+ <FirewallService>
+ <IsEnabled>true</IsEnabled>
+ </FirewallService>
+ <NatService>
+ <IsEnabled>true</IsEnabled>
+ <NatType>ipTranslation</NatType>
+ <Policy>allowTraffic</Policy>
+ <NatRule>
+ <OneToOneVmRule>
+ <MappingMode>automatic</MappingMode>
+ <VAppScopedVmId>02_ubuntu_template</VAppScopedVmId>
+ <VmNicId>0</VmNicId>
+ </OneToOneVmRule>
+ </NatRule>
+ </NatService>
+ </Features>
+ </Configuration>
+ <IsDeployed>false</IsDeployed>
+ </NetworkConfig>
+ </NetworkConfigSection>
+ <LeaseSettingsSection
+ type="application/vnd.vmware.vcloud.leaseSettingsSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/leaseSettingsSection/"
+ ovf:required="false">
+ <ovf:Info>Lease settings section</ovf:Info>
+ <Link rel="edit"
+ type="application/vnd.vmware.vcloud.leaseSettingsSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/leaseSettingsSection/" />
+ <StorageLeaseInSeconds>0</StorageLeaseInSeconds>
+ </LeaseSettingsSection>
+ <CustomizationSection
+ type="application/vnd.vmware.vcloud.customizationSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/customizationSection/"
+ ovf:required="false">
+ <ovf:Info>VApp template customization section</ovf:Info>
+ <CustomizeOnInstantiate>true</CustomizeOnInstantiate>
+ <Link rel="edit"
+ type="application/vnd.vmware.vcloud.customizationSection+xml"
+ href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/customizationSection/" />
+ </CustomizationSection>
+</VAppTemplate>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vAppTemplate1.0-vcd15_withNewlines.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vAppTemplate1.0-vcd15_withNewlines.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vAppTemplate1.0-vcd15_withNewlines.xml
new file mode 100644
index 0000000..9f41d81
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vAppTemplate1.0-vcd15_withNewlines.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<vcloud:VAppTemplate xmlns:vcloud="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" ovfDescriptorUploaded="true" status="8" name="Windows 2008 R2 Standard (base) with SP1" type="application/vnd.vmware.vcloud.vAppTempla
+te+xml" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vappTemplate-f8ca27ba-c6ee-44bd-91a9-416f464cba80" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf
+/envelope/1/dsp8023_1.1.0.xsd http://www.vmware.com/vcloud/v1 http://109.233.49.135/api/v1.0/schema/master.xsd">
+ <vcloud:Link rel="catalogItem" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcd.stratogen.net/api/v1.0/catalogItem/16bdea08-f176-48ce-9fe8-fc2265fc1068"/>
+ <vcloud:Link rel="enable" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vappTemplate-f8ca27ba-c6ee-44bd-91a9-416f464cba80/action/enableDownload"/>
+ <vcloud:Link rel="disable" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vappTemplate-f8ca27ba-c6ee-44bd-91a9-416f464cba80/action/disableDownload"/>
+ <vcloud:Link rel="ovf" type="text/xml" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vappTemplate-f8ca27ba-c6ee-44bd-91a9-416f464cba80/ovf"/>
+ <vcloud:Link rel="down" type="application/vnd.vmware.vcloud.owner+xml" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vappTemplate-f8ca27ba-c6ee-44bd-91a9-416f464cba80/owner"/>
+ <vcloud:Description>Windows 2008 R2 Standard Edition
+Service Pack 1
+Internet Explorer 9</vcloud:Description>
+ <vcloud:Children>
+ <vcloud:Vm name="Windows 2008 R2 Standard (Base) with SP1" type="application/vnd.vmware.vcloud.vm+xml" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vm-2ac49c8b-5cd9-428d-86da-24cfe9144b94">
+ <vcloud:Link rel="up" type="application/vnd.vmware.vcloud.vAppTemplate+xml" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vappTemplate-f8ca27ba-c6ee-44bd-91a9-416f464cba80"/>
+ <vcloud:Description>Windows 2008 R2 Standard Edition
+Service Pack 1
+Internet Explorer 9</vcloud:Description>
+ <vcloud:NetworkConnectionSection type="application/vnd.vmware.vcloud.networkConnectionSection+xml" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vm-2ac49c8b-5cd9-428d-86da-24cfe9144b94/networkConnectionSection/" ovf:required="false">
+ <ovf:Info>Specifies the available VM network connections</ovf:Info>
+ <vcloud:PrimaryNetworkConnectionIndex>0</vcloud:PrimaryNetworkConnectionIndex>
+ <vcloud:NetworkConnection network="StratoGen Ext Net">
+ <vcloud:NetworkConnectionIndex>0</vcloud:NetworkConnectionIndex>
+ <vcloud:IpAddress>212.54.128.56</vcloud:IpAddress>
+ <vcloud:IsConnected>true</vcloud:IsConnected>
+ <vcloud:MACAddress>00:50:56:01:0d:3c</vcloud:MACAddress>
+ <vcloud:IpAddressAllocationMode>POOL</vcloud:IpAddressAllocationMode>
+ </vcloud:NetworkConnection>
+ </vcloud:NetworkConnectionSection>
+ <vcloud:GuestCustomizationSection type="application/vnd.vmware.vcloud.guestCustomizationSection+xml" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vm-2ac49c8b-5cd9-428d-86da-24cfe9144b94/guestCustomizationSection/" ovf:required="false">
+ <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
+ <vcloud:Enabled>true</vcloud:Enabled>
+ <vcloud:ChangeSid>true</vcloud:ChangeSid>
+ <vcloud:JoinDomainEnabled>false</vcloud:JoinDomainEnabled>
+ <vcloud:UseOrgSettings>false</vcloud:UseOrgSettings>
+ <vcloud:AdminPasswordEnabled>true</vcloud:AdminPasswordEnabled>
+ <vcloud:AdminPasswordAuto>true</vcloud:AdminPasswordAuto>
+ <vcloud:AdminPassword>$6fEPL93</vcloud:AdminPassword>
+ <vcloud:ResetPasswordRequired>false</vcloud:ResetPasswordRequired>
+ <vcloud:ComputerName>Win2008r2Stand</vcloud:ComputerName>
+ </vcloud:GuestCustomizationSection>
+ <vcloud:VAppScopedLocalId>ac2ce03d-0491-46f7-afc6-37ffe5b30f74</vcloud:VAppScopedLocalId>
+ </vcloud:Vm>
+ </vcloud:Children>
+ <ovf:NetworkSection vcloud:href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vappTemplate-f8ca27ba-c6ee-44bd-91a9-416f464cba80/networkSection/" vcloud:type="application/vnd.vmware.vcloud.networkSection+xml">
+ <ovf:Info>The list of logical networks</ovf:Info>
+ <ovf:Network ovf:name="StratoGen Ext Net">
+ <ovf:Description/>
+ </ovf:Network>
+ </ovf:NetworkSection>
+ <vcloud:NetworkConfigSection type="application/vnd.vmware.vcloud.networkConfigSection+xml" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vappTemplate-f8ca27ba-c6ee-44bd-91a9-416f464cba80/networkConfigSection/" ovf:required="false">
+ <ovf:Info>The configuration parameters for logical networks</ovf:Info>
+ <vcloud:NetworkConfig networkName="StratoGen Ext Net">
+ <vcloud:Description/>
+ <vcloud:Configuration>
+ <vcloud:IpScope>
+ <vcloud:IsInherited>true</vcloud:IsInherited>
+ <vcloud:Gateway>212.54.128.1</vcloud:Gateway>
+ <vcloud:Netmask>255.255.255.0</vcloud:Netmask>
+ <vcloud:Dns1>109.233.48.141</vcloud:Dns1>
+ <vcloud:Dns2>109.233.48.142</vcloud:Dns2>
+ <vcloud:IpRanges>
+ <vcloud:IpRange>
+ <vcloud:StartAddress>212.54.128.4</vcloud:StartAddress>
+ <vcloud:EndAddress>212.54.128.220</vcloud:EndAddress>
+ </vcloud:IpRange>
+ </vcloud:IpRanges>
+ </vcloud:IpScope>
+ <vcloud:FenceMode>bridged</vcloud:FenceMode>
+ <vcloud:Features>
+ <vcloud:DhcpService>
+ <vcloud:IsEnabled>false</vcloud:IsEnabled>
+ <vcloud:DefaultLeaseTime>3600</vcloud:DefaultLeaseTime>
+ <vcloud:MaxLeaseTime>7200</vcloud:MaxLeaseTime>
+ <vcloud:IpRange>
+ <vcloud:StartAddress>212.54.128.201</vcloud:StartAddress>
+ <vcloud:EndAddress>212.54.128.254</vcloud:EndAddress>
+ </vcloud:IpRange>
+ </vcloud:DhcpService>
+ <vcloud:FirewallService>
+ <vcloud:IsEnabled>true</vcloud:IsEnabled>
+ </vcloud:FirewallService>
+ <vcloud:NatService>
+ <vcloud:IsEnabled>true</vcloud:IsEnabled>
+ <vcloud:NatType>ipTranslation</vcloud:NatType>
+ <vcloud:Policy>allowTraffic</vcloud:Policy>
+ <vcloud:NatRule>
+ <vcloud:OneToOneVmRule>
+ <vcloud:MappingMode>automatic</vcloud:MappingMode>
+ <vcloud:VAppScopedVmId>ac2ce03d-0491-46f7-afc6-37ffe5b30f74</vcloud:VAppScopedVmId>
+ <vcloud:VmNicId>0</vcloud:VmNicId>
+ </vcloud:OneToOneVmRule>
+ </vcloud:NatRule>
+ </vcloud:NatService>
+ </vcloud:Features>
+ </vcloud:Configuration>
+ <vcloud:IsDeployed>false</vcloud:IsDeployed>
+ </vcloud:NetworkConfig>
+ </vcloud:NetworkConfigSection>
+ <vcloud:LeaseSettingsSection type="application/vnd.vmware.vcloud.leaseSettingsSection+xml" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vappTemplate-f8ca27ba-c6ee-44bd-91a9-416f464cba80/leaseSettingsSection/" ovf:required="false">
+ <ovf:Info>Lease settings section</ovf:Info>
+ <vcloud:Link rel="edit" type="application/vnd.vmware.vcloud.leaseSettingsSection+xml" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vappTemplate-f8ca27ba-c6ee-44bd-91a9-416f464cba80/leaseSettingsSection/"/>
+ <vcloud:StorageLeaseInSeconds>0</vcloud:StorageLeaseInSeconds>
+ </vcloud:LeaseSettingsSection>
+ <vcloud:CustomizationSection type="application/vnd.vmware.vcloud.customizationSection+xml" href="https://vcd.stratogen.net/api/v1.0/vAppTemplate/vappTemplate-f8ca27ba-c6ee-44bd-91a9-416f464cba80/customizationSection/" ovf:required="false">
+ <ovf:Info>VApp template customization section</ovf:Info>
+ <vcloud:CustomizeOnInstantiate>true</vcloud:CustomizeOnInstantiate>
+ </vcloud:CustomizationSection>
+</vcloud:VAppTemplate>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vapp-hosting.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vapp-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vapp-hosting.xml
new file mode 100644
index 0000000..c746cba
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vapp-hosting.xml
@@ -0,0 +1,235 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VApp href="https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96"
+ type="application/vnd.vmware.vcloud.vApp+xml" name="188849-96"
+ status="2" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 vapp.xsd"
+ xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns="http://www.vmware.com/vcloud/v0.8"
+ xmlns:vmw="http://www.vmware.com/schema/ovf"
+ xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
+ xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" size="20971520">
+
+ <NetworkConnectionSection>
+ <Info xmlns="http://schemas.dmtf.org/ovf/envelope/1">Network Information about the vApp</Info>
+ <NetworkConnection Network="Network 1">
+ <IpAddress>204.12.11.167</IpAddress>
+ </NetworkConnection>
+ </NetworkConnectionSection>
+
+ <VirtualHardwareSection xmlns="http://schemas.dmtf.org/ovf/envelope/1">
+ <Info>Virtual hardware</Info>
+ <System>
+ <AutomaticRecoveryAction xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <AutomaticShutdownAction xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <AutomaticStartupAction xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <AutomaticStartupActionDelay
+ xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <AutomaticStartupActionSequenceNumber
+ xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <Caption xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <ConfigurationDataRoot xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <ConfigurationFile xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <ConfigurationID xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <CreationTime xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <Description xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <ElementName
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData">Virtual Hardware Family</ElementName>
+ <InstanceID
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData">0</InstanceID>
+ <LogDataRoot xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <RecoveryFile xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <SnapshotDataRoot xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <SuspendDataRoot xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <SwapFileDataRoot xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
+ <VirtualSystemIdentifier
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData">SimpleVM</VirtualSystemIdentifier>
+ <VirtualSystemType
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData">vmx-07</VirtualSystemType>
+ </System>
+ <Item>
+ <Address xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <AddressOnParent xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <AllocationUnits
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">hertz * 10^6</AllocationUnits>
+ <AutomaticAllocation xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <AutomaticDeallocation xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Caption xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <ConsumerVisibility xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Description
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">Number of Virtual CPUs</Description>
+ <ElementName
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1 virtual CPU(s)</ElementName>
+ <InstanceID
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</InstanceID>
+ <Limit xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <MappingBehavior xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <OtherResourceType xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Parent xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <PoolID xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Reservation xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <ResourceSubType xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <ResourceType
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</ResourceType>
+ <VirtualQuantity
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</VirtualQuantity>
+ <Weight xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ </Item>
+ <Item>
+ <Address xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <AddressOnParent xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <AllocationUnits
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">byte * 2^20</AllocationUnits>
+ <AutomaticAllocation xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <AutomaticDeallocation xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Caption xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <ConsumerVisibility xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Description
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">Memory Size</Description>
+ <ElementName
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">512MB of memory</ElementName>
+ <InstanceID
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">2</InstanceID>
+ <Limit xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <MappingBehavior xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <OtherResourceType xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Parent xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <PoolID xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Reservation xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <ResourceSubType xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <ResourceType
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">4</ResourceType>
+ <VirtualQuantity
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">512</VirtualQuantity>
+ <Weight xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ </Item>
+ <Item>
+ <Address
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">0</Address>
+ <AddressOnParent xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <AllocationUnits xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <AutomaticAllocation xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <AutomaticDeallocation xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Caption xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <ConsumerVisibility xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Description
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">SCSI Controller</Description>
+ <ElementName
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">SCSI Controller 0</ElementName>
+ <InstanceID
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</InstanceID>
+ <Limit xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <MappingBehavior xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <OtherResourceType xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Parent xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <PoolID xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Reservation xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <ResourceSubType
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">lsilogic</ResourceSubType>
+ <ResourceType
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">6</ResourceType>
+ <VirtualQuantity xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Weight xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ </Item>
+ <Item>
+ <Address xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <AddressOnParent
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">0</AddressOnParent>
+ <AllocationUnits xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <AutomaticAllocation xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <AutomaticDeallocation xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Caption xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <ConsumerVisibility xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Description xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <ElementName
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">Hard Disk 1</ElementName>
+ <HostResource
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">20971520</HostResource>
+ <InstanceID
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">9</InstanceID>
+ <Limit xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <MappingBehavior xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <OtherResourceType xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Parent
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</Parent>
+ <PoolID xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <Reservation xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <ResourceSubType xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ <ResourceType
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">17</ResourceType>
+ <VirtualQuantity
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">20971520</VirtualQuantity>
+ <Weight xsi:nil="true"
+ xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
+ </Item>
+ </VirtualHardwareSection>
+</VApp>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vapp-none.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vapp-none.xml b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vapp-none.xml
new file mode 100644
index 0000000..62b4f32
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/resources/vapp-none.xml
@@ -0,0 +1,237 @@
+<VApp xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" deployed="true" status="4" name="customize-750" type="application/vnd.vmware.vcloud.vApp+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_VirtualSystemSettingData.xsd http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd http://www.vmware.com/vcloud/v1 http://1.1.1.1/api/v1.0/sch
ema/master.xsd">
+ <Link rel="power:powerOff" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/power/action/powerOff"/>
+ <Link rel="power:reboot" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/power/action/reboot"/>
+ <Link rel="power:reset" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/power/action/reset"/>
+ <Link rel="power:shutdown" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/power/action/shutdown"/>
+ <Link rel="power:suspend" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/power/action/suspend"/>
+ <Link rel="deploy" type="application/vnd.vmware.vcloud.deployVAppParams+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/action/deploy"/>
+ <Link rel="undeploy" type="application/vnd.vmware.vcloud.undeployVAppParams+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-98934665/action/undeploy"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.controlAccess+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/controlAccess/"/>
+ <Link rel="controlAccess" type="application/vnd.vmware.vcloud.controlAccess+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/action/controlAccess"/>
+ <Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml" href="https://1.1.1.1/api/v1.0/vdc/1"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.vApp+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1"/>
+ <LeaseSettingsSection type="application/vnd.vmware.vcloud.leaseSettingsSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/leaseSettingsSection/" ovf:required="false">
+ <ovf:Info>Lease settings section</ovf:Info>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.leaseSettingsSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/leaseSettingsSection/"/>
+ <DeploymentLeaseInSeconds>0</DeploymentLeaseInSeconds>
+ <StorageLeaseInSeconds>7776000</StorageLeaseInSeconds>
+ </LeaseSettingsSection>
+ <ovf:StartupSection xmlns:vcloud="http://www.vmware.com/vcloud/v1" vcloud:href="https://1.1.1.1/api/v1.0/vApp/vapp-1/startupSection/" vcloud:type="application/vnd.vmware.vcloud.startupSection+xml">
+ <ovf:Info>VApp startup section</ovf:Info>
+ <ovf:Item ovf:stopDelay="0" ovf:stopAction="powerOff" ovf:startDelay="0" ovf:startAction="powerOn" ovf:order="0" ovf:id="Centos-5.5_x64"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.startupSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/startupSection/"/>
+ </ovf:StartupSection>
+ <ovf:NetworkSection xmlns:vcloud="http://www.vmware.com/vcloud/v1" vcloud:href="https://1.1.1.1/api/v1.0/vApp/vapp-1/networkSection/" vcloud:type="application/vnd.vmware.vcloud.networkSection+xml">
+ <ovf:Info>The list of logical networks</ovf:Info>
+ <ovf:Network ovf:name="none">
+ <ovf:Description/>
+ </ovf:Network>
+ <ovf:Network ovf:name="none">
+ <ovf:Description>This is a special place-holder used for disconnected network interfaces.</ovf:Description>
+ </ovf:Network>
+ </ovf:NetworkSection>
+ <NetworkConfigSection type="application/vnd.vmware.vcloud.networkConfigSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/networkConfigSection/" ovf:required="false">
+ <ovf:Info>The configuration parameters for logical networks</ovf:Info>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.networkConfigSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1/networkConfigSection/"/>
+ <NetworkConfig networkName="none">
+ <Description/>
+ <Configuration>
+ <IpScope>
+ <IsInherited>true</IsInherited>
+ <Gateway>172.16.7.1</Gateway>
+ <Netmask>255.255.255.0</Netmask>
+ <Dns1>208.95.232.10</Dns1>
+ <Dns2>208.95.232.11</Dns2>
+ <IpRanges>
+ <IpRange>
+ <StartAddress>172.16.7.230</StartAddress>
+ <EndAddress>172.16.7.239</EndAddress>
+ </IpRange>
+ </IpRanges>
+ </IpScope>
+ <ParentNetwork type="application/vnd.vmware.vcloud.network+xml" name="Direct" href="https://1.1.1.1/api/v1.0/network/282371363"/>
+ <FenceMode>bridged</FenceMode>
+ <Features>
+ <DhcpService>
+ <IsEnabled>false</IsEnabled>
+ <DefaultLeaseTime>3600</DefaultLeaseTime>
+ <MaxLeaseTime>7200</MaxLeaseTime>
+ <IpRange>
+ <StartAddress>172.16.7.2</StartAddress>
+ <EndAddress>172.16.7.229</EndAddress>
+ </IpRange>
+ </DhcpService>
+ <FirewallService>
+ <IsEnabled>true</IsEnabled>
+ </FirewallService>
+ <NatService>
+ <IsEnabled>true</IsEnabled>
+ <NatType>ipTranslation</NatType>
+ <Policy>allowTraffic</Policy>
+ </NatService>
+ </Features>
+ </Configuration>
+ <IsDeployed>true</IsDeployed>
+ </NetworkConfig>
+ <NetworkConfig networkName="none">
+ <Description>This is a special place-holder used for disconnected network interfaces.</Description>
+ <Configuration>
+ <IpScope>
+ <IsInherited>false</IsInherited>
+ <Gateway>196.254.254.254</Gateway>
+ <Netmask>255.255.0.0</Netmask>
+ <Dns1>196.254.254.254</Dns1>
+ </IpScope>
+ <FenceMode>isolated</FenceMode>
+ </Configuration>
+ <IsDeployed>false</IsDeployed>
+ </NetworkConfig>
+ </NetworkConfigSection>
+ <Children>
+ <Vm deployed="true" status="4" name="Centos-5.5_x64" type="application/vnd.vmware.vcloud.vm+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1">
+ <Link rel="power:powerOff" href="https://1.1.1.1/api/v1.0/vApp/vm-1/power/action/powerOff"/>
+ <Link rel="power:reboot" href="https://1.1.1.1/api/v1.0/vApp/vm-1/power/action/reboot"/>
+ <Link rel="power:reset" href="https://1.1.1.1/api/v1.0/vApp/vm-1/power/action/reset"/>
+ <Link rel="power:shutdown" href="https://1.1.1.1/api/v1.0/vApp/vm-1/power/action/shutdown"/>
+ <Link rel="power:suspend" href="https://1.1.1.1/api/v1.0/vApp/vm-1/power/action/suspend"/>
+ <Link rel="undeploy" type="application/vnd.vmware.vcloud.undeployVAppParams+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/action/undeploy"/>
+ <Link rel="up" type="application/vnd.vmware.vcloud.vApp+xml" href="https://1.1.1.1/api/v1.0/vApp/vapp-1"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.vm+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1"/>
+ <Link rel="screen:thumbnail" href="https://1.1.1.1/api/v1.0/vApp/vm-1/screen"/>
+ <Link rel="screen:acquireTicket" href="https://1.1.1.1/api/v1.0/vApp/vm-1/screen/action/acquireTicket"/>
+ <Link rel="media:insertMedia" type="application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/media/action/insertMedia"/>
+ <Link rel="media:ejectMedia" type="application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/media/action/ejectMedia"/>
+ <Description/>
+ <ovf:VirtualHardwareSection xmlns:vcloud="http://www.vmware.com/vcloud/v1" vcloud:href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/" vcloud:type="application/vnd.vmware.vcloud.virtualHardwareSection+xml">
+ <ovf:Info>Virtual hardware requirements</ovf:Info>
+ <ovf:System>
+ <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
+ <vssd:InstanceID>0</vssd:InstanceID>
+ <vssd:VirtualSystemIdentifier>Centos-5.5_x64</vssd:VirtualSystemIdentifier>
+ <vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>
+ </ovf:System>
+ <ovf:Item>
+ <rasd:Address>00:50:56:01:02:38</rasd:Address>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:Connection vcloud:primaryNetworkConnection="true" vcloud:ipAddressingMode="NONE">none</rasd:Connection>
+ <rasd:Description>PCNet32 ethernet adapter</rasd:Description>
+ <rasd:ElementName>Network adapter 0</rasd:ElementName>
+ <rasd:InstanceID>1</rasd:InstanceID>
+ <rasd:ResourceSubType>PCNet32</rasd:ResourceSubType>
+ <rasd:ResourceType>10</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>SCSI Controller</rasd:Description>
+ <rasd:ElementName>SCSI Controller 0</rasd:ElementName>
+ <rasd:InstanceID>2</rasd:InstanceID>
+ <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
+ <rasd:ResourceType>6</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:Description>Hard disk</rasd:Description>
+ <rasd:ElementName>Hard disk 1</rasd:ElementName>
+ <rasd:HostResource vcloud:capacity="15360" vcloud:busType="6" vcloud:busSubType="lsilogic"/>
+ <rasd:InstanceID>2000</rasd:InstanceID>
+ <rasd:Parent>2</rasd:Parent>
+ <rasd:ResourceType>17</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>IDE Controller</rasd:Description>
+ <rasd:ElementName>IDE Controller 0</rasd:ElementName>
+ <rasd:InstanceID>3</rasd:InstanceID>
+ <rasd:ResourceType>5</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:Description>CD/DVD Drive</rasd:Description>
+ <rasd:ElementName>CD/DVD Drive 1</rasd:ElementName>
+ <rasd:HostResource/>
+ <rasd:InstanceID>3002</rasd:InstanceID>
+ <rasd:Parent>3</rasd:Parent>
+ <rasd:ResourceType>15</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:Description>Floppy Drive</rasd:Description>
+ <rasd:ElementName>Floppy Drive 1</rasd:ElementName>
+ <rasd:HostResource/>
+ <rasd:InstanceID>8000</rasd:InstanceID>
+ <rasd:ResourceType>14</rasd:ResourceType>
+ </ovf:Item>
+ <ovf:Item vcloud:href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/cpu" vcloud:type="application/vnd.vmware.vcloud.rasdItem+xml">
+ <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
+ <rasd:Description>Number of Virtual CPUs</rasd:Description>
+ <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
+ <rasd:InstanceID>4</rasd:InstanceID>
+ <rasd:Reservation>0</rasd:Reservation>
+ <rasd:ResourceType>3</rasd:ResourceType>
+ <rasd:VirtualQuantity>1</rasd:VirtualQuantity>
+ <rasd:Weight>0</rasd:Weight>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/cpu"/>
+ </ovf:Item>
+ <ovf:Item vcloud:href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/memory" vcloud:type="application/vnd.vmware.vcloud.rasdItem+xml">
+ <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
+ <rasd:Description>Memory Size</rasd:Description>
+ <rasd:ElementName>2048 MB of memory</rasd:ElementName>
+ <rasd:InstanceID>5</rasd:InstanceID>
+ <rasd:Reservation>0</rasd:Reservation>
+ <rasd:ResourceType>4</rasd:ResourceType>
+ <rasd:VirtualQuantity>2048</rasd:VirtualQuantity>
+ <rasd:Weight>0</rasd:Weight>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/memory"/>
+ </ovf:Item>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.virtualHardwareSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/cpu"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/cpu"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/memory"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/memory"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.rasdItemsList+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/disks"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItemsList+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/disks"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.rasdItemsList+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/media"/>
+ <Link rel="down" type="application/vnd.vmware.vcloud.rasdItemsList+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/networkCards"/>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItemsList+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/virtualHardwareSection/networkCards"/>
+ </ovf:VirtualHardwareSection>
+ <ovf:OperatingSystemSection xmlns:vcloud="http://www.vmware.com/vcloud/v1" xmlns:vmw="http://www.vmware.com/schema/ovf" ovf:id="80" vcloud:href="https://1.1.1.1/api/v1.0/vApp/vm-1/operatingSystemSection/" vcloud:type="application/vnd.vmware.vcloud.operatingSystemSection+xml" vmw:osType="rhel5_64Guest">
+ <ovf:Info>Specifies the operating system installed</ovf:Info>
+ <ovf:Description>Red Hat Enterprise Linux 5 (64-bit)</ovf:Description>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.operatingSystemSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/operatingSystemSection/"/>
+ </ovf:OperatingSystemSection>
+ <NetworkConnectionSection type="application/vnd.vmware.vcloud.networkConnectionSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/networkConnectionSection/" ovf:required="false">
+ <ovf:Info>Specifies the available VM network connections</ovf:Info>
+ <PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
+ <NetworkConnection network="none">
+ <NetworkConnectionIndex>0</NetworkConnectionIndex>
+ <IsConnected>false</IsConnected>
+ <MACAddress>00:50:56:01:02:38</MACAddress>
+ <IpAddressAllocationMode>NONE</IpAddressAllocationMode>
+ </NetworkConnection>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.networkConnectionSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/networkConnectionSection/"/>
+ </NetworkConnectionSection>
+ <GuestCustomizationSection type="application/vnd.vmware.vcloud.guestCustomizationSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/guestCustomizationSection/" ovf:required="false">
+ <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
+ <Enabled>true</Enabled>
+ <ChangeSid>false</ChangeSid>
+ <VirtualMachineId>1</VirtualMachineId>
+ <JoinDomainEnabled>false</JoinDomainEnabled>
+ <UseOrgSettings>false</UseOrgSettings>
+ <AdminPasswordEnabled>true</AdminPasswordEnabled>
+ <AdminPasswordAuto>true</AdminPasswordAuto>
+ <AdminPassword>secret</AdminPassword>
+ <ResetPasswordRequired>false</ResetPasswordRequired>
+ <CustomizationScript>cat > /root/foo.txt<<EOF
+I love candy
+EOF
+</CustomizationScript>
+ <ComputerName>Centos-5.5_x64</ComputerName>
+ <Link rel="edit" type="application/vnd.vmware.vcloud.guestCustomizationSection+xml" href="https://1.1.1.1/api/v1.0/vApp/vm-1/guestCustomizationSection/"/>
+ </GuestCustomizationSection>
+ <VAppScopedLocalId>Centos-5.5_x64</VAppScopedLocalId>
+ </Vm>
+ </Children>
+</VApp>
[45/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java
new file mode 100644
index 0000000..deab873
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java
@@ -0,0 +1,556 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Optional.fromNullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+import java.util.List;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Describes an operation being executed on some Resource
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
+ */
+@Beta
+public class Operation extends Resource {
+
+ public static enum Status {
+ PENDING,
+ RUNNING,
+ DONE
+ }
+
+ private final URI targetLink;
+ private final Optional<String> targetId;
+ private final Optional<String> clientOperationId;
+ private final Status status;
+ private final Optional<String> statusMessage;
+ private final String user;
+ private final Optional<Integer> progress;
+ private final Date insertTime;
+ private final Optional<Date> startTime;
+ private final Optional<Date> endTime;
+ private final Optional<HttpResponse> httpError;
+ private final String operationType;
+ private final List<Error> errors;
+ private final Optional<URI> zone;
+ private final Optional<URI> region;
+
+ protected Operation(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ URI targetLink, String targetId, String clientOperationId, Status status,
+ String statusMessage, String user, Integer progress, Date insertTime, Date startTime,
+ Date endTime, Integer httpErrorStatusCode, String httpErrorMessage, String operationType,
+ @Nullable List<Error> errors, URI region, URI zone) {
+ super(Kind.OPERATION, id, creationTimestamp, selfLink, name, description);
+ this.targetLink = checkNotNull(targetLink, "targetLink of %s", name);
+ this.targetId = fromNullable(targetId);
+ this.clientOperationId = fromNullable(clientOperationId);
+ this.status = checkNotNull(status, "status of %s", name);
+ this.statusMessage = fromNullable(statusMessage);
+ this.user = checkNotNull(user, "user of %s", name);
+ this.progress = fromNullable(progress);
+ this.insertTime = checkNotNull(insertTime, "insertTime of %s", name);
+ this.startTime = fromNullable(startTime);
+ this.endTime = fromNullable(endTime);
+ this.httpError = httpErrorStatusCode != null && httpErrorStatusCode != 0 ?
+ Optional.of(HttpResponse.builder()
+ .statusCode(httpErrorStatusCode)
+ .message(httpErrorMessage)
+ .build())
+ : Optional.<HttpResponse>absent();
+ this.operationType = checkNotNull(operationType, "insertTime of %s", name);
+ this.errors = errors == null ? ImmutableList.<Error>of() : ImmutableList.copyOf(errors);
+ this.region = fromNullable(region);
+ this.zone = fromNullable(zone);
+ }
+
+ /**
+ * @return URL of the resource the operation is mutating.
+ */
+ public URI getTargetLink() {
+ return targetLink;
+ }
+
+ /**
+ * @return An optional identifier specified by the client when the mutation was initiated. Must be unique for all
+ * operation resources in the project.
+ */
+ public Optional<String> getClientOperationId() {
+ return clientOperationId;
+ }
+
+ /**
+ * @return unique target id which identifies a particular incarnation of the target.
+ */
+ public Optional<String> getTargetId() {
+ return targetId;
+ }
+
+ /**
+ * @return region this operation is in, if any.
+ */
+ public Optional<URI> getRegion() {
+ return region;
+ }
+
+ /**
+ * @return zone this operation is in, if any.
+ */
+ public Optional<URI> getZone() {
+ return zone;
+ }
+
+ /**
+ * @return Status of the operation. Can be one of the following: PENDING, RUNNING, or DONE.
+ */
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * @return An optional textual description of the current status of the operation.
+ */
+ public Optional<String> getStatusMessage() {
+ return statusMessage;
+ }
+
+ /**
+ * @return User who requested the operation, for example "user@example.com".
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /**
+ * @return an optional progress indicator that ranges from 0 to 100. This should not be used to guess at when the
+ * operation will be complete. This number should be monotonically increasing as the operation progresses
+ * (output only).
+ */
+ public Optional<Integer> getProgress() {
+ return progress;
+ }
+
+ /**
+ * @return the time that this operation was requested.
+ */
+ public Date getInsertTime() {
+ return insertTime;
+ }
+
+ /**
+ * @return the time that this operation was started by the server.
+ */
+ public Optional<Date> getStartTime() {
+ return startTime;
+ }
+
+ /**
+ * @return the time that this operation was completed.
+ */
+ public Optional<Date> getEndTime() {
+ return endTime;
+ }
+
+ /**
+ * @return if operation fails, the HttpResponse with error status code returned and the message, e.g. NOT_FOUND.
+ */
+ public Optional<HttpResponse> getHttpError() {
+ return httpError;
+ }
+
+ /**
+ * @return type of the operation. Examples include insert, update, and delete.
+ */
+ public String getOperationType() {
+ return operationType;
+ }
+
+ /**
+ * @return if error occurred during processing of this operation, this field will be populated.
+ */
+ public List<Error> getErrors() {
+ return errors;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .omitNullValues()
+ .add("targetLink", targetLink)
+ .add("targetId", targetId.orNull())
+ .add("clientOperationId", clientOperationId.orNull())
+ .add("status", status)
+ .add("statusMessage", statusMessage.orNull())
+ .add("user", user)
+ .add("progress", progress.orNull())
+ .add("insertTime", insertTime)
+ .add("startTime", startTime.orNull())
+ .add("endTime", endTime.orNull())
+ .add("httpError", httpError.orNull())
+ .add("operationType", operationType)
+ .add("errors", errors)
+ .add("region", region.orNull())
+ .add("zone", zone.orNull());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromOperation(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private URI targetLink;
+ private String targetId;
+ private String clientOperationId;
+ private Status status;
+ private String statusMessage;
+ private String user;
+ private Integer progress;
+ private Date insertTime;
+ private Date startTime;
+ private Date endTime;
+ private Integer httpErrorStatusCode;
+ private String httpErrorMessage;
+ private String operationType;
+ private ImmutableList.Builder<Error> errors = ImmutableList.builder();
+ private URI region;
+ private URI zone;
+
+ /**
+ * @see Operation#getTargetLink()
+ */
+ public Builder targetLink(URI targetLink) {
+ this.targetLink = targetLink;
+ return self();
+ }
+
+ /**
+ * @see Operation#getRegion()
+ */
+ public Builder region(URI region) {
+ this.region = region;
+ return self();
+ }
+
+ /**
+ * @see Operation#getZone()
+ */
+ public Builder zone(URI zone) {
+ this.zone = zone;
+ return self();
+ }
+
+ /**
+ * @see Operation#getTargetId()
+ */
+ public Builder targetId(String targetId) {
+ this.targetId = targetId;
+ return self();
+ }
+
+ /**
+ * @see Operation#getClientOperationId()
+ */
+ public Builder clientOperationId(String clientOperationId) {
+ this.clientOperationId = clientOperationId;
+ return self();
+ }
+
+ /**
+ * @see Operation#getStatus()
+ */
+ public Builder status(Status status) {
+ this.status = status;
+ return self();
+ }
+
+ /**
+ * @see Operation#getStatusMessage()
+ */
+ public Builder statusMessage(String statusMessage) {
+ this.statusMessage = statusMessage;
+ return self();
+ }
+
+ /**
+ * @see Operation#getUser()
+ */
+ public Builder user(String user) {
+ this.user = user;
+ return self();
+ }
+
+ /**
+ * @see Operation#getProgress()
+ */
+ public Builder progress(Integer progress) {
+ this.progress = progress;
+ return self();
+ }
+
+ /**
+ * @see Operation#getInsertTime()
+ */
+ public Builder insertTime(Date insertTime) {
+ this.insertTime = insertTime;
+ return self();
+ }
+
+ /**
+ * @see Operation#getStartTime()
+ */
+ public Builder startTime(Date startTime) {
+ this.startTime = startTime;
+ return self();
+ }
+
+ /**
+ * @see Operation#getEndTime()
+ */
+ public Builder endTime(Date endTime) {
+ this.endTime = endTime;
+ return self();
+ }
+
+ /**
+ * @see Operation#getHttpError()
+ */
+ public Builder httpErrorStatusCode(Integer httpErrorStatusCode) {
+ this.httpErrorStatusCode = httpErrorStatusCode;
+ return self();
+ }
+
+ /**
+ * @see Operation#getHttpError()
+ */
+ public Builder httpErrorMessage(String httpErrorMessage) {
+ this.httpErrorMessage = httpErrorMessage;
+ return self();
+ }
+
+ /**
+ * @see Operation#getOperationType()
+ */
+ public Builder operationType(String operationType) {
+ this.operationType = operationType;
+ return self();
+ }
+
+ /**
+ * @see Operation#getErrors()
+ */
+ public Builder errors(Iterable<Error> errors) {
+ if (errors != null)
+ this.errors.addAll(errors);
+ return self();
+ }
+
+ /**
+ * @see Operation#getErrors()
+ */
+ public Builder addError(Error error) {
+ this.errors.add(error);
+ return self();
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Operation build() {
+ return new Operation(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, targetLink, targetId, clientOperationId, status, statusMessage, user, progress,
+ insertTime, startTime, endTime, httpErrorStatusCode, httpErrorMessage, operationType,
+ errors.build(), region, zone);
+ }
+
+ public Builder fromOperation(Operation in) {
+ return super.fromResource(in)
+ .targetLink(in.getTargetLink())
+ .targetId(in.getTargetId().orNull())
+ .clientOperationId(in.getClientOperationId().orNull())
+ .status(in.getStatus())
+ .statusMessage(in.getStatusMessage().orNull())
+ .user(in.getUser())
+ .progress(in.getProgress().get())
+ .insertTime(in.getInsertTime())
+ .startTime(in.getStartTime().orNull())
+ .endTime(in.getEndTime().orNull())
+ .httpErrorStatusCode(in.getHttpError().isPresent() ? in.getHttpError().get().getStatusCode() : null)
+ .httpErrorMessage(in.getHttpError().isPresent() ? in.getHttpError().get().getMessage() : null)
+ .operationType(in.getOperationType()).errors(in.getErrors())
+ .zone(in.getZone().orNull()).region(in.getRegion().orNull());
+ }
+ }
+
+ /**
+ * A particular error for an operation including the details.
+ */
+ public static final class Error {
+
+ private final String code;
+ private final Optional<String> location;
+ private final Optional<String> message;
+
+ @ConstructorProperties({
+ "code", "location", "message"
+ })
+ private Error(String code, String location, String message) {
+ this.code = checkNotNull(code, "code");
+ this.location = fromNullable(location);
+ this.message = fromNullable(message);
+ }
+
+ /**
+ * @return the error type identifier for this error.
+ */
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * @return indicates the field in the request which caused the error..
+ */
+ public Optional<String> getLocation() {
+ return location;
+ }
+
+ /**
+ * @return an optional, human-readable error message.
+ */
+ public Optional<String> getMessage() {
+ return message;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(code, location, message);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Error that = Error.class.cast(obj);
+ return equal(this.code, that.code)
+ && equal(this.location, that.location)
+ && equal(this.message, that.message);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("code", code)
+ .add("location", location.orNull())
+ .add("message", message.orNull());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromOperationErrorDetail(this);
+ }
+
+ public static final class Builder {
+
+ private String code;
+ private String location;
+ private String message;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Operation.Error#getCode()
+ */
+ public Builder code(String code) {
+ this.code = code;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Operation.Error#getLocation()
+ */
+ public Builder location(String location) {
+ this.location = location;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Operation.Error#getMessage()
+ */
+ public Builder message(String message) {
+ this.message = message;
+ return this;
+ }
+
+ public Error build() {
+ return new Error(code, location, message);
+ }
+
+ public Builder fromOperationErrorDetail(Error in) {
+ return new Builder().code(in.getCode()).location(in.getLocation().orNull()).message
+ (in.getMessage().orNull());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java
new file mode 100644
index 0000000..ac3867b
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Date;
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A Project resource is the root collection and settings resource for all Google Compute Engine resources.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/projects"/>
+ */
+@Beta
+public class Project extends Resource {
+
+ private final Metadata commonInstanceMetadata;
+ private final Set<Quota> quotas;
+ private final Set<String> externalIpAddresses;
+
+ protected Project(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Metadata commonInstanceMetadata, Set<Quota> quotas, Set<String> externalIpAddresses) {
+ super(Kind.PROJECT, id, creationTimestamp, selfLink, name, description);
+ this.commonInstanceMetadata = checkNotNull(commonInstanceMetadata, "commonInstanceMetadata");
+ this.quotas = quotas == null ? ImmutableSet.<Quota>of() : ImmutableSet.copyOf(quotas);
+ this.externalIpAddresses = externalIpAddresses == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf
+ (externalIpAddresses);
+ }
+
+ /**
+ * @return metadata key/value pairs available to all instances contained in this project.
+ */
+ public Metadata getCommonInstanceMetadata() {
+ return commonInstanceMetadata;
+ }
+
+ /**
+ * @return quotas assigned to this project.
+ */
+ public Set<Quota> getQuotas() {
+ return quotas;
+ }
+
+ /**
+ * @return internet available IP addresses available for use in this project.
+ */
+ @Nullable
+ public Set<String> getExternalIpAddresses() {
+ return externalIpAddresses;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("commonInstanceMetadata", commonInstanceMetadata)
+ .add("quotas", quotas)
+ .add("externalIpAddresses", externalIpAddresses);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromProject(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private Metadata commonInstanceMetadata;
+ private ImmutableSet.Builder<Quota> quotas = ImmutableSet.builder();
+ private ImmutableSet.Builder<String> externalIpAddresses = ImmutableSet.builder();
+
+ /**
+ * @see Project#getCommonInstanceMetadata()
+ */
+ public Builder commonInstanceMetadata(Metadata commonInstanceMetadata) {
+ this.commonInstanceMetadata = commonInstanceMetadata;
+ return this;
+ }
+
+ /**
+ * @see Project#getQuotas()
+ */
+ public Builder addQuota(String metric, double usage, double limit) {
+ this.quotas.add(Quota.builder().metric(metric).usage(usage).limit(limit).build());
+ return this;
+ }
+
+ /**
+ * @see Project#getQuotas()
+ */
+ public Builder quotas(Set<Quota> quotas) {
+ this.quotas.addAll(checkNotNull(quotas));
+ return this;
+ }
+
+ /**
+ * @see Project#getExternalIpAddresses()
+ */
+ public Builder addExternalIpAddress(String externalIpAddress) {
+ this.externalIpAddresses.add(checkNotNull(externalIpAddress, "externalIpAddress"));
+ return this;
+ }
+
+ /**
+ * @see Project#getExternalIpAddresses()
+ */
+ public Builder externalIpAddresses(Set<String> externalIpAddresses) {
+ this.externalIpAddresses.addAll(checkNotNull(externalIpAddresses, "externalIpAddresses"));
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Project build() {
+ return new Project(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, commonInstanceMetadata, quotas.build(), externalIpAddresses.build());
+ }
+
+ public Builder fromProject(Project in) {
+ return super.fromResource(in).commonInstanceMetadata(in.getCommonInstanceMetadata()).quotas(in.getQuotas())
+ .externalIpAddresses(in.getExternalIpAddresses());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Quota.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Quota.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Quota.java
new file mode 100644
index 0000000..3c17130
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Quota.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Quotas assigned to a given project or region.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/projects#resource"/>
+ */
+@Beta
+public class Quota {
+ private String metric;
+ private double usage;
+ private double limit;
+
+ @ConstructorProperties({
+ "metric", "usage", "limit"
+ })
+ public Quota(String metric, Double usage, Double limit) {
+ this.metric = metric != null ? metric : "undefined";
+ this.usage = checkNotNull(usage, "usage");
+ this.limit = checkNotNull(limit, "limit");
+ }
+
+ /**
+ * @return name of the quota metric.
+ */
+ public String getMetric() {
+ return metric;
+ }
+
+ /**
+ * @return current usage of this metric.
+ */
+ public Double getUsage() {
+ return usage;
+ }
+
+ /**
+ * @return quota limit for this metric.
+ */
+ public Double getLimit() {
+ return limit;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(metric);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || this.getClass() != obj.getClass()) return false;
+ Quota that = Quota.class.cast(obj);
+ return Objects.equal(this.metric, that.metric);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .omitNullValues()
+ .add("metric", metric)
+ .add("usage", usage)
+ .add("limit", limit);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromQuota(this);
+ }
+
+ public static class Builder {
+
+ private String metric;
+ private Double usage;
+ private Double limit;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Quota#getMetric()
+ */
+ public Builder metric(String metric) {
+ this.metric = checkNotNull(metric, "metric");
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Quota#getUsage()
+ */
+ public Builder usage(Double usage) {
+ this.usage = usage;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Quota#getLimit()
+ */
+ public Builder limit(Double limit) {
+ this.limit = limit;
+ return this;
+ }
+
+ public Quota build() {
+ return new Quota(metric, usage, limit);
+ }
+
+ public Builder fromQuota(Quota quota) {
+ return new Builder().metric(quota.getMetric()).usage(quota.getUsage()).limit(quota.getLimit());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java
new file mode 100644
index 0000000..aa459bf
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Represents a region resource.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/regions"/>
+ */
+@Beta
+public final class Region extends Resource {
+
+ public enum Status {
+ UP,
+ DOWN
+ }
+
+ private final Status status;
+ private final Set<URI> zones;
+ private final Set<Quota> quotas;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "status",
+ "zones", "quotas"
+ })
+ private Region(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Status status, Set<URI> zones, Set<Quota> quotas) {
+ super(Kind.REGION, id, creationTimestamp, selfLink, name, description);
+ this.status = checkNotNull(status, "status of %name", name);
+ this.zones = zones == null ? ImmutableSet.<URI>of() : ImmutableSet
+ .copyOf(zones);
+ this.quotas = quotas == null ? ImmutableSet.<Quota>of() : ImmutableSet.copyOf(quotas);
+ }
+
+ /**
+ * @return Status of the region. "UP" or "DOWN".
+ */
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * @return the zones that can be used in this region.
+ */
+ @Nullable
+ public Set<URI> getZones() {
+ return zones;
+ }
+
+ /**
+ * @return quotas assigned to this project.
+ */
+ public Set<Quota> getQuotas() {
+ return quotas;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("status", status)
+ .add("zones", zones)
+ .add("quotas", quotas);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromRegion(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private Status status;
+ private ImmutableSet.Builder<URI> zones = ImmutableSet.builder();
+ private ImmutableSet.Builder<Quota> quotas = ImmutableSet.builder();
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Region#getStatus()
+ */
+ public Builder status(Status status) {
+ this.status = status;
+ return this;
+ }
+
+ /**
+ * @see Region#getZones()
+ */
+ public Builder zone(URI zone) {
+ this.zones.add(checkNotNull(zone, "zone"));
+ return this;
+ }
+
+ /**
+ * @see Region#getZones()
+ */
+ public Builder zones(Set<URI> zones) {
+ this.zones.addAll(checkNotNull(zones, "zones"));
+ return this;
+ }
+
+ /**
+ * @see Region#getQuotas()
+ */
+ public Builder addQuota(String metric, double usage, double limit) {
+ this.quotas.add(Quota.builder().metric(metric).usage(usage).limit(limit).build());
+ return this;
+ }
+
+ /**
+ * @see Region#getQuotas()
+ */
+ public Builder quotas(Set<Quota> quotas) {
+ this.quotas.addAll(checkNotNull(quotas));
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Region build() {
+ return new Region(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, status, zones.build(), quotas.build());
+ }
+
+ public Builder fromRegion(Region in) {
+ return super.fromResource(in)
+ .status(in.getStatus())
+ .zones(in.getZones())
+ .quotas(in.getQuotas());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java
new file mode 100644
index 0000000..4d0a1c8
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java
@@ -0,0 +1,283 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.ToStringHelper;
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Optional.fromNullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.CaseFormat;
+import com.google.common.base.Joiner;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
+
+/**
+ * Base class for Google Compute Engine resources.
+ */
+@Beta
+public class Resource {
+
+ public enum Kind {
+ ADDRESS,
+ ADDRESS_LIST,
+ DISK,
+ DISK_LIST,
+ FIREWALL,
+ FIREWALL_LIST,
+ IMAGE,
+ IMAGE_LIST,
+ OPERATION,
+ OPERATION_LIST,
+ INSTANCE,
+ INSTANCE_LIST,
+ MACHINE_TYPE,
+ MACHINE_TYPE_LIST,
+ PROJECT,
+ NETWORK,
+ NETWORK_LIST,
+ REGION,
+ REGION_LIST,
+ ROUTE,
+ ROUTE_LIST,
+ SNAPSHOT,
+ SNAPSHOT_LIST,
+ ZONE,
+ ZONE_LIST;
+
+ public String value() {
+ return Joiner.on("#").join("compute", CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()));
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static Kind fromValue(String kind) {
+ return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat
+ .UPPER_UNDERSCORE,
+ Iterables.getLast(Splitter.on("#").split(checkNotNull(kind,
+ "kind")))));
+ }
+ }
+
+ protected final Kind kind;
+ protected final String id;
+ protected final Optional<Date> creationTimestamp;
+ protected final URI selfLink;
+ protected final String name;
+ protected final Optional<String> description;
+
+ @ConstructorProperties({
+ "kind", "id", "creationTimestamp", "selfLink", "name", "description"
+ })
+ protected Resource(Kind kind, String id, Date creationTimestamp, URI selfLink, String name,
+ String description) {
+ this.kind = checkNotNull(kind, "kind");
+ this.id = checkNotNull(id, "id");
+ this.creationTimestamp = fromNullable(creationTimestamp);
+ this.selfLink = checkNotNull(selfLink, "selfLink");
+ this.name = checkNotNull(name, "name");
+ this.description = fromNullable(description);
+ }
+
+ /**
+ * @return the Type of the resource
+ */
+ public Kind getKind() {
+ return kind;
+ }
+
+ /**
+ * @return unique identifier for the resource; defined by the server.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return creation timestamp in RFC3339 text format.
+ */
+ public Optional<Date> getCreationTimestamp() {
+ return creationTimestamp;
+ }
+
+ /**
+ * @return server defined URL for the resource.
+ */
+ public URI getSelfLink() {
+ return selfLink;
+ }
+
+ /**
+ * @return name of the resource.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return an optional textual description of the resource.
+ */
+ @Nullable
+ public Optional<String> getDescription() {
+ return description;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(kind, name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Resource that = Resource.class.cast(obj);
+ return equal(this.kind, that.kind)
+ && equal(this.name, that.name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected ToStringHelper string() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("kind", kind)
+ .add("id", id)
+ .add("name", name)
+ .add("creationTimestamp", creationTimestamp.orNull())
+ .add("selfLink", selfLink)
+ .add("name", name)
+ .add("description", description.orNull());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromResource(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+
+ protected abstract T self();
+
+ protected Kind kind;
+ protected String id;
+ protected Date creationTimestamp;
+ protected URI selfLink;
+ protected String name;
+ protected String description;
+
+ /**
+ * @see Resource#getKind()
+ */
+ protected T kind(Kind kind) {
+ this.kind = kind;
+ return self();
+ }
+
+ /**
+ * @see Resource#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see Resource#getCreationTimestamp()
+ */
+ public T creationTimestamp(Date creationTimestamp) {
+ this.creationTimestamp = creationTimestamp;
+ return self();
+ }
+
+ /**
+ * @see Resource#getSelfLink()
+ */
+ public T selfLink(URI selfLink) {
+ this.selfLink = selfLink;
+ return self();
+ }
+
+ /**
+ * @see Resource#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see Resource#getDescription()
+ */
+ public T description(String description) {
+ this.description = description;
+ return self();
+ }
+
+ public Resource build() {
+ return new Resource(kind, id, creationTimestamp, selfLink, name, description);
+ }
+
+ public T fromResource(Resource in) {
+ return this
+ .kind(in.getKind())
+ .id(in.getId())
+ .creationTimestamp(in.getCreationTimestamp().orNull())
+ .selfLink(in.getSelfLink())
+ .name(in.getName())
+ .description(in.getDescription().orNull());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java
new file mode 100644
index 0000000..df5bb1d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java
@@ -0,0 +1,433 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Optional.fromNullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Represents a route resource.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/routes"/>
+ */
+@Beta
+public final class Route extends Resource {
+
+ private final URI network;
+ private final Set<String> tags;
+ private final String destRange;
+ private final Integer priority;
+ private final Optional<URI> nextHopInstance;
+ private final Optional<String> nextHopIp;
+ private final Optional<URI> nextHopNetwork;
+ private final Optional<URI> nextHopGateway;
+ private final Set<Warning> warnings;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "network", "tags",
+ "destRange", "priority", "nextHopInstance", "nextHopIp", "nextHopNetwork",
+ "nextHopGateway", "warnings"
+ })
+ private Route(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ URI network, Set<String> tags, String destRange, Integer priority,
+ URI nextHopInstance, String nextHopIp, URI nextHopNetwork,
+ URI nextHopGateway, Set<Warning> warnings) {
+ super(Kind.ROUTE, id, creationTimestamp, selfLink, name, description);
+ this.network = checkNotNull(network, "network for %name", name);
+ this.tags = tags == null ? ImmutableSet.<String>of() : tags;
+ this.destRange = checkNotNull(destRange, "destination range for %name", name);
+ this.priority = checkNotNull(priority, "priority of %name", name);
+ this.nextHopInstance = fromNullable(nextHopInstance);
+ this.nextHopIp = fromNullable(nextHopIp);
+ this.nextHopNetwork = fromNullable(nextHopNetwork);
+ this.nextHopGateway = fromNullable(nextHopGateway);
+ this.warnings = warnings == null ? ImmutableSet.<Warning>of() : warnings;
+ }
+
+ /**
+ * @return Network for this Route.
+ */
+ public URI getNetwork() {
+ return network;
+ }
+
+ /**
+ * @return The set of instance items to which this route applies.
+ */
+ public Set<String> getTags() {
+ return tags;
+ }
+
+ /**
+ * @return The destination range of outgoing packets that this route applies to.
+ */
+ public String getDestRange() {
+ return destRange;
+ }
+
+ /**
+ * @return The priority of this route. Priority is used to break ties in the case
+ * where there is more than one matching route of maximum length. A lower value
+ * is higher priority; a priority of 100 is higher than 200.
+ */
+ public Integer getPriority() {
+ return priority;
+ }
+
+ /**
+ * @return The fully-qualified URL to an instance that should handle matching packets.
+ */
+ public Optional<URI> getNextHopInstance() {
+ return nextHopInstance;
+ }
+
+ /**
+ * @return The network IP address of an instance that should handle matching packets.
+ */
+ public Optional<String> getNextHopIp() {
+ return nextHopIp;
+ }
+
+ /**
+ * @return The URL of the local network if it should handle matching packets.
+ */
+ public Optional<URI> getNextHopNetwork() {
+ return nextHopNetwork;
+ }
+
+ /**
+ * @return The URL to a gateway that should handle matching packets. Currently, this is only the internet gateway.
+ */
+ public Optional<URI> getNextHopGateway() {
+ return nextHopGateway;
+ }
+
+ /**
+ * @return If potential misconfigurations are detected for this route, this field will be populated with warning messages.
+ */
+ public Set<Warning> getWarnings() {
+ return warnings;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("network", network)
+ .add("tags", tags)
+ .add("destRange", destRange)
+ .add("priority", priority)
+ .add("nextHopInstance", nextHopInstance.orNull())
+ .add("nextHopIp", nextHopIp.orNull())
+ .add("nextHopNetwork", nextHopNetwork.orNull())
+ .add("nextHopGateway", nextHopGateway.orNull())
+ .add("warnings", warnings);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromRoute(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private URI network;
+ private ImmutableSet.Builder<String> tags = ImmutableSet.builder();
+ private String destRange;
+ private Integer priority;
+ private URI nextHopInstance;
+ private String nextHopIp;
+ private URI nextHopNetwork;
+ private URI nextHopGateway;
+ private ImmutableSet.Builder<Warning> warnings = ImmutableSet.builder();
+
+
+ /**
+ * @see Route#getNetwork()
+ */
+ public Builder network(URI network) {
+ this.network = network;
+ return this;
+ }
+
+ /**
+ * @see Route#getTags()
+ */
+ public Builder addTag(String tag) {
+ this.tags.add(tag);
+ return this;
+ }
+
+ /**
+ * @see Route#getTags()
+ */
+ public Builder tags(Set<String> tags) {
+ this.tags.addAll(tags);
+ return this;
+ }
+
+ /**
+ * @see Route#getDestRange()
+ */
+ public Builder destRange(String destRange) {
+ this.destRange = destRange;
+ return this;
+ }
+
+ /**
+ * @see Route#getPriority()
+ */
+ public Builder priority(Integer priority) {
+ this.priority = priority;
+ return this;
+ }
+
+ /**
+ * @see Route#getNextHopInstance()
+ */
+ public Builder nextHopInstance(URI nextHopInstance) {
+ this.nextHopInstance = nextHopInstance;
+ return this;
+ }
+
+ /**
+ * @see Route#getNextHopIp()
+ */
+ public Builder nextHopIp(String nextHopIp) {
+ this.nextHopIp = nextHopIp;
+ return this;
+ }
+
+ /**
+ * @see Route#getNextHopNetwork()
+ */
+ public Builder nextHopNetwork(URI nextHopNetwork) {
+ this.nextHopNetwork = nextHopNetwork;
+ return this;
+ }
+
+ /**
+ * @see Route#getNextHopGateway()
+ */
+ public Builder nextHopGateway(URI nextHopGateway) {
+ this.nextHopGateway = nextHopGateway;
+ return this;
+ }
+
+ /**
+ * @see Route#getWarnings()
+ */
+ public Builder addWarning(Warning warning) {
+ this.warnings.add(warning);
+ return this;
+ }
+
+ /**
+ * @see Route#getWarnings()
+ */
+ public Builder warnings(Set<Warning> warnings) {
+ this.warnings.addAll(warnings);
+ return this;
+ }
+
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Route build() {
+ return new Route(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, network, tags.build(), destRange, priority,
+ nextHopInstance, nextHopIp, nextHopNetwork, nextHopGateway,
+ warnings.build());
+ }
+
+ public Builder fromRoute(Route in) {
+ return super.fromResource(in)
+ .network(in.getNetwork())
+ .tags(in.getTags())
+ .destRange(in.getDestRange())
+ .priority(in.getPriority())
+ .nextHopInstance(in.getNextHopInstance().orNull())
+ .nextHopIp(in.getNextHopIp().orNull())
+ .nextHopNetwork(in.getNextHopNetwork().orNull())
+ .nextHopGateway(in.getNextHopGateway().orNull())
+ .warnings(in.getWarnings());
+ }
+ }
+
+ /**
+ * If potential misconfigurations are detected for this route, this field will be populated with warning messages.
+ */
+ public static class Warning {
+ private final String code;
+ private final Optional<String> message;
+ private final Map<String, String> data;
+
+ @ConstructorProperties({
+ "code", "message", "data"
+ })
+ public Warning(String code, String message, Map<String, String> data) {
+ this.code = checkNotNull(code, "code");
+ this.message = fromNullable(message);
+ this.data = data == null ? ImmutableMap.<String, String>of() : data;
+ }
+
+ /**
+ * @return The warning type identifier for this warning.
+ */
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * @return Optional human-readable details for this warning.
+ */
+ public Optional<String> getMessage() {
+ return message;
+ }
+
+ /**
+ * @return Metadata for this warning
+ */
+ public Map<String, String> getData() {
+ return data;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(code, message, data);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Warning that = Warning.class.cast(obj);
+ return equal(this.code, that.code)
+ && equal(this.message, that.message)
+ && equal(this.data, that.data);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .add("code", code)
+ .add("message", message)
+ .add("data", data);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromWarning(this);
+ }
+
+ public static final class Builder {
+ private String code;
+ private String message;
+ private ImmutableMap.Builder<String, String> data = ImmutableMap.builder();
+
+ /**
+ * @see Warning#getCode()
+ */
+ public Builder code(String code) {
+ this.code = code;
+ return this;
+ }
+
+ /**
+ * @see Warning#getMessage()
+ */
+ public Builder message(String message) {
+ this.message = message;
+ return this;
+ }
+
+ /**
+ * @see Warning#getData()
+ */
+ public Builder data(Map<String, String> data) {
+ this.data = new ImmutableMap.Builder<String, String>().putAll(data);
+ return this;
+ }
+
+ /**
+ * @see Warning#getData()
+ */
+ public Builder addData(String key, String value) {
+ this.data.put(checkNotNull(key, "key"), checkNotNull(value, "value of %s", key));
+ return this;
+ }
+
+ public Warning build() {
+ return new Warning(code, message, data.build());
+ }
+
+ public Builder fromWarning(Warning in) {
+ return this.code(in.getCode())
+ .message(in.getMessage().orNull())
+ .data(in.getData());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/SlashEncodedIds.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/SlashEncodedIds.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/SlashEncodedIds.java
new file mode 100644
index 0000000..0080b29
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/SlashEncodedIds.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
+
+public class SlashEncodedIds {
+ public static SlashEncodedIds fromSlashEncoded(String id) {
+ Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id"));
+ checkArgument(Iterables.size(parts) == 2, "id must be in format firstId/secondId");
+ return new SlashEncodedIds(Iterables.get(parts, 0), Iterables.get(parts, 1));
+ }
+
+ public static SlashEncodedIds fromTwoIds(String firstId, String secondId) {
+ return new SlashEncodedIds(firstId, secondId);
+ }
+
+ private static String slashEncodeTwoIds(String firstId, String secondId) {
+ return checkNotNull(firstId, "firstId") + "/" + checkNotNull(secondId, "secondId");
+ }
+
+ public String slashEncode() {
+ return slashEncodeTwoIds(firstId, secondId);
+ }
+
+ protected final String firstId;
+ protected final String secondId;
+
+ protected SlashEncodedIds(String firstId, String secondId) {
+ this.firstId = checkNotNull(firstId, "firstId");
+ this.secondId = checkNotNull(secondId, "secondId");
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(firstId, secondId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SlashEncodedIds other = (SlashEncodedIds) obj;
+ return Objects.equal(firstId, other.firstId) && Objects.equal(secondId, other.secondId);
+ }
+
+ public String getFirstId() {
+ return firstId;
+ }
+
+ public String getSecondId() {
+ return secondId;
+ }
+
+ @Override
+ public String toString() {
+ return "[firstId=" + firstId + ", secondId=" + secondId + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Snapshot.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Snapshot.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Snapshot.java
new file mode 100644
index 0000000..69af275
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Snapshot.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Optional.fromNullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+
+/**
+ * A Persistent Disk Snapshot resource.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/snapshots"/>
+ */
+@Beta
+public final class Snapshot extends AbstractDisk {
+
+ private final Optional<URI> sourceDisk;
+ private final String sourceDiskId;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "diskSizeGb",
+ "status", "sourceDisk", "sourceDiskId"
+ })
+ private Snapshot(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Integer sizeGb, String status, URI sourceDisk, String sourceDiskId) {
+ super(Kind.SNAPSHOT, id, creationTimestamp, selfLink, name, description, sizeGb, status);
+ this.sourceDisk = fromNullable(sourceDisk);
+ this.sourceDiskId = checkNotNull(sourceDiskId, "sourceDiskId of %s", name);
+ }
+
+ /**
+ * @return The source disk used to create this snapshot. Once the source disk
+ * has been deleted from the system, this field will be cleared, and will
+ * not be set even if a disk with the same name has been re-created (output only).
+ */
+ public Optional<URI> getSourceDisk() {
+ return sourceDisk;
+ }
+
+ /**
+ * @return The ID value of the disk used to create this snapshot. This value
+ * may be used to determine whether the snapshot was taken from the current
+ * or a previous instance of a given disk name.
+ */
+ public String getSourceDiskId() {
+ return sourceDiskId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .omitNullValues()
+ .add("sourceDisk", sourceDisk.orNull())
+ .add("sourceDiskId", sourceDiskId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromSnapshot(this);
+ }
+
+ public static final class Builder extends AbstractDisk.Builder<Builder> {
+
+ private URI sourceDisk;
+ private String sourceDiskId;
+
+ /**
+ * @see Snapshot#getSourceDisk()
+ */
+ public Builder sourceDisk(URI sourceDisk) {
+ this.sourceDisk = sourceDisk;
+ return this;
+ }
+
+ /**
+ * @see Snapshot#getSourceDiskId()
+ */
+ public Builder sourceDiskId(String sourceDiskId) {
+ this.sourceDiskId = sourceDiskId;
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Snapshot build() {
+ return new Snapshot(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, super.sizeGb, super.status, sourceDisk, sourceDiskId);
+ }
+
+ public Builder fromSnapshot(Snapshot in) {
+ return super.fromAbstractDisk(in)
+ .sourceDisk(in.getSourceDisk().orNull())
+ .sourceDiskId(in.getSourceDiskId());
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java
new file mode 100644
index 0000000..232386c
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Optional.fromNullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.net.URI;
+import java.util.Date;
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Represents a zone resource.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/zones"/>
+ */
+@Beta
+public final class Zone extends Resource {
+
+ public enum Status {
+ UP,
+ DOWN
+ }
+
+ private final Status status;
+ private final Set<MaintenanceWindow> maintenanceWindows;
+ private final Set<String> availableMachineTypes;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "status", "maintenanceWindows",
+ "availableMachineTypes"
+ })
+ private Zone(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Status status, Set<MaintenanceWindow> maintenanceWindows, Set<String> availableMachineTypes) {
+ super(Kind.ZONE, id, creationTimestamp, selfLink, name, description);
+ this.status = checkNotNull(status, "status of %name", name);
+ this.maintenanceWindows = maintenanceWindows == null ? ImmutableSet.<MaintenanceWindow>of() : ImmutableSet
+ .copyOf(maintenanceWindows);
+ this.availableMachineTypes = availableMachineTypes == null ? ImmutableSet.<String>of() : ImmutableSet
+ .copyOf(availableMachineTypes);
+ }
+
+ /**
+ * @return Status of the zone. "UP" or "DOWN".
+ */
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * @return scheduled maintenance windows for the zone. When the zone is in a maintenance window,
+ * all resources which reside in the zone will be unavailable.
+ */
+ public Set<MaintenanceWindow> getMaintenanceWindows() {
+ return maintenanceWindows;
+ }
+
+ /**
+ * @return the machine types that can be used in this zone.
+ */
+ @Nullable
+ public Set<String> getAvailableMachineTypes() {
+ return availableMachineTypes;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("status", status)
+ .add("maintenanceWindows", maintenanceWindows)
+ .add("availableMachineTypes", availableMachineTypes);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromZone(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private Status status;
+ private ImmutableSet.Builder<MaintenanceWindow> maintenanceWindows = ImmutableSet.builder();
+ private ImmutableSet.Builder<String> availableMachineTypes = ImmutableSet.builder();
+
+ /**
+ * @see Zone#getStatus()
+ */
+ public Builder status(Status status) {
+ this.status = status;
+ return this;
+ }
+
+ /**
+ * @see Zone#getMaintenanceWindows()
+ */
+ public Builder addMaintenanceWindow(MaintenanceWindow maintenanceWindow) {
+ this.maintenanceWindows.add(checkNotNull(maintenanceWindow, "maintenanceWindow"));
+ return this;
+ }
+
+ /**
+ * @see Zone#getMaintenanceWindows()
+ */
+ public Builder maintenanceWindows(Set<MaintenanceWindow> maintenanceWindows) {
+ this.maintenanceWindows.addAll(checkNotNull(maintenanceWindows, "maintenanceWindows"));
+ return this;
+ }
+
+ /**
+ * @see Zone#getAvailableMachineTypes()
+ */
+ public Builder addAvailableMachineType(String availableMachineType) {
+ this.availableMachineTypes.add(checkNotNull(availableMachineType, "availableMachineType"));
+ return this;
+ }
+
+ /**
+ * @see Zone#getAvailableMachineTypes()
+ */
+ public Builder availableMachineTypes(Set<String> availableMachineTypes) {
+ this.availableMachineTypes.addAll(checkNotNull(availableMachineTypes, "availableMachineTypes"));
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Zone build() {
+ return new Zone(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, status, maintenanceWindows.build(), availableMachineTypes.build());
+ }
+
+ public Builder fromZone(Zone in) {
+ return super.fromResource(in)
+ .status(in.getStatus())
+ .maintenanceWindows(in.getMaintenanceWindows())
+ .availableMachineTypes(in.getAvailableMachineTypes());
+ }
+ }
+
+ /**
+ * Scheduled maintenance windows for the zone. When the zone is in a maintenance window,
+ * all resources which reside in the zone will be unavailable.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/zones"/>
+ */
+ public static final class MaintenanceWindow {
+
+ private final String name;
+ private final Optional<String> description;
+ private final Date beginTime;
+ private final Date endTime;
+
+ @ConstructorProperties({
+ "name", "description", "beginTime", "endTime"
+ })
+ private MaintenanceWindow(String name, String description, Date beginTime, Date endTime) {
+ this.name = checkNotNull(name, "name");
+ this.description = fromNullable(description);
+ this.beginTime = checkNotNull(beginTime, "beginTime of %name", name);
+ this.endTime = checkNotNull(endTime, "endTime of %name", name);
+ }
+
+ /**
+ * @return name of the maintenance window.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return textual description of the maintenance window.
+ */
+ public Optional<String> getDescription() {
+ return description;
+ }
+
+ /**
+ * @return begin time of the maintenance window.
+ */
+ public Date getBeginTime() {
+ return beginTime;
+ }
+
+ /**
+ * @return end time of the maintenance window.
+ */
+ public Date getEndTime() {
+ return endTime;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, description, beginTime, endTime);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ MaintenanceWindow that = MaintenanceWindow.class.cast(obj);
+ return equal(this.name, that.name)
+ && equal(this.beginTime, that.beginTime)
+ && equal(this.endTime, that.endTime);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("name", name)
+ .add("description", description.orNull())
+ .add("beginTime", beginTime)
+ .add("endTime", endTime);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromZoneMaintenanceWindow(this);
+ }
+
+ public static final class Builder {
+
+ private String name;
+ private String description;
+ private Date beginTime;
+ private Date endTime;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Zone.MaintenanceWindow#getName()
+ */
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Zone.MaintenanceWindow#getDescription()
+ */
+ public Builder description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Zone.MaintenanceWindow#getBeginTime()
+ */
+ public Builder beginTime(Date beginTime) {
+ this.beginTime = beginTime;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Zone.MaintenanceWindow#getEndTime()
+ */
+ public Builder endTime(Date endTime) {
+ this.endTime = endTime;
+ return this;
+ }
+
+
+ public MaintenanceWindow build() {
+ return new MaintenanceWindow(name, description, beginTime, endTime);
+ }
+
+ public Builder fromZoneMaintenanceWindow(MaintenanceWindow in) {
+ return new Builder()
+ .name(in.getName())
+ .description(in.getDescription().orNull())
+ .beginTime(in.getBeginTime())
+ .endTime(in.getEndTime());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/internal/NetworkAndAddressRange.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/internal/NetworkAndAddressRange.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/internal/NetworkAndAddressRange.java
new file mode 100644
index 0000000..66fbd66
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/internal/NetworkAndAddressRange.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.domain.internal;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Optional.fromNullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+
+/**
+ * Container for network, IPv4 range and optional gateway, for creation caching
+ */
+public class NetworkAndAddressRange {
+ protected final String name;
+ protected final String ipV4Range;
+ protected final Optional<String> gateway;
+
+ @ConstructorProperties({
+ "name", "ipV4Range", "gateway"
+ })
+ public NetworkAndAddressRange(String name, String ipV4Range, @Nullable String gateway) {
+ this.name = checkNotNull(name, "name");
+ this.ipV4Range = checkNotNull(ipV4Range, "ipV4Range");
+ this.gateway = fromNullable(gateway);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIpV4Range() {
+ return ipV4Range;
+ }
+
+ @Nullable
+ public Optional<String> getGateway() {
+ return gateway;
+ }
+
+ @Override
+ public int hashCode() {
+ // We only do hashcode/equals on name.
+ // the ip v4 range and gateway are included for creation rather than caching.
+ return Objects.hashCode(name);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ NetworkAndAddressRange that = NetworkAndAddressRange.class.cast(obj);
+ return equal(this.name, that.name);
+ }
+
+ protected ToStringHelper string() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("name", name)
+ .add("ipV4Range", ipV4Range)
+ .add("gateway", gateway.orNull());
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
new file mode 100644
index 0000000..d363715
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Address;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.functions.internal.ParseAddresses;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+/**
+ * Provides access to Addresses via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/addresses"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+public interface AddressApi {
+
+ /**
+ * Returns the specified address resource.
+ *
+ * @param region Name of the region the address is in.
+ * @param addressName name of the address resource to return.
+ * @return a Address resource.
+ */
+ @Named("Addresss:get")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses/{address}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Address getInRegion(@PathParam("region") String region, @PathParam("address") String addressName);
+
+ /**
+ * Creates a address resource in the specified project specifying the size of the address.
+ *
+ *
+ * @param region the name of the region where the address is to be created.
+ * @param addressName the name of address.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Addresss:insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses")
+ @OAuthScopes({COMPUTE_SCOPE})
+ @MapBinder(BindToJsonPayload.class)
+ Operation createInRegion(@PathParam("region") String region, @PayloadParam("name") String addressName);
+
+ /**
+ * Deletes the specified address resource.
+ *
+ * @param region the region the address is in.
+ * @param addressName name of the address resource to delete.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Addresss:delete")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses/{address}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Operation deleteInRegion(@PathParam("region") String region, @PathParam("address") String addressName);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.AddressApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Addresss:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseAddresses.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Address> listFirstPageInRegion(@PathParam("region") String region);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.AddressApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Addresss:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseAddresses.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Address> listAtMarkerInRegion(@PathParam("region") String region, @QueryParam("pageToken") @Nullable String marker);
+
+ /**
+ * Retrieves the listPage of address resources contained within the specified project and region.
+ * By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has
+ * not been set.
+ *
+ * @param region the region to search in
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the listPage
+ * @see org.jclouds.googlecomputeengine.options.ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("Addresss:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseAddresses.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Address> listAtMarkerInRegion(@PathParam("region") String region, @QueryParam("pageToken") @Nullable String marker, ListOptions listOptions);
+
+ /**
+ * A paged version of AddressApi#listPageInRegion(String)
+ *
+ * @param region the region to list in
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see org.jclouds.collect.PagedIterable
+ * @see org.jclouds.googlecomputeengine.features.AddressApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Addresss:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseAddresses.class)
+ @Transform(ParseAddresses.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Address> listInRegion(@PathParam("region") String region);
+
+ @Named("Addresss:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseAddresses.class)
+ @Transform(ParseAddresses.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Address> listInRegion(@PathParam("region") String region, ListOptions options);
+
+}
[17/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudMediaType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudMediaType.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudMediaType.java
new file mode 100644
index 0000000..7126701
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudMediaType.java
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+
+import javax.ws.rs.core.MediaType;
+
+/**
+ * Resource Types used in VCloud
+ *
+ * @see MediaType
+ */
+public interface VCloudMediaType {
+ /**
+ * "application/vnd.vmware.vcloud.error+xml"
+ */
+ public static final String ERROR_XML = "application/vnd.vmware.vcloud.error+xml";
+
+ /**
+ * "application/vnd.vmware.vcloud.error+xml"
+ */
+ public static final MediaType ERROR_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.error+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.vcloud+xml"
+ */
+ public static final String VCLOUD_XML = "application/vnd.vmware.vcloud.vcloud+xml";
+
+ /**
+ * "application/vnd.vmware.vcloud.vcloud+xml"
+ */
+ public static final MediaType VCLOUD_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vcloud+xml");
+ /**
+ * "application/vnd.vmware.vcloud.orgList+xml"
+ */
+ public static final String ORGLIST_XML = "application/vnd.vmware.vcloud.orgList+xml";
+
+ /**
+ * "application/vnd.vmware.vcloud.orgList+xml"
+ */
+ public static final MediaType ORGLIST_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.orgList+xml");
+ /**
+ * "application/vnd.vmware.vcloud.org+xml"
+ */
+ public static final String ORG_XML = "application/vnd.vmware.vcloud.org+xml";
+ /**
+ * "application/vnd.vmware.vcloud.org+xml"
+ */
+ public static final MediaType ORG_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.org+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.vdc+xml"
+ */
+ public static final String VDC_XML = "application/vnd.vmware.vcloud.vdc+xml";
+ /**
+ * "application/vnd.vmware.vcloud.vdc+xml"
+ */
+ public static final MediaType VDC_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vdc+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.catalog+xml"
+ */
+ public static final String CATALOG_XML = "application/vnd.vmware.vcloud.catalog+xml";
+ /**
+ * "application/vnd.vmware.vcloud.catalog+xml"
+ */
+ public static final MediaType CATALOG_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.catalog+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.tasksList+xml"
+ */
+ public static final String TASKSLIST_XML = "application/vnd.vmware.vcloud.tasksList+xml";
+ /**
+ * "application/vnd.vmware.vcloud.tasksList+xml"
+ */
+ public static final MediaType TASKSLIST_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.tasksList+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.catalogItem+xml"
+ */
+ public static final String CATALOGITEM_XML = "application/vnd.vmware.vcloud.catalogItem+xml";
+ /**
+ * "application/vnd.vmware.vcloud.catalogItem+xml"
+ */
+ public static final MediaType CATALOGITEM_XML_TYPE = new MediaType("application",
+ "vnd.vmware.vcloud.catalogItem+xml");
+ /**
+ * "application/vnd.vmware.vcloud.networkConnectionSection+xml"
+ */
+ public static final String NETWORKCONNECTIONSECTION_XML = "application/vnd.vmware.vcloud.networkConnectionSection+xml";
+ /**
+ * "application/vnd.vmware.vcloud.networkConnectionSection+xml"
+ */
+ public static final MediaType NETWORKCONNECTIONSECTION_XML_TYPE = new MediaType("application",
+ "vnd.vmware.vcloud.networkConnectionSection+xml");
+ /**
+ * "application/vnd.vmware.vcloud.virtualHardwareSection+xml"
+ */
+ public static final String VIRTUALHARDWARESECTION_XML = "application/vnd.vmware.vcloud.virtualHardwareSection+xml";
+ /**
+ * "application/vnd.vmware.vcloud.virtualHardwareSection+xml"
+ */
+ public static final MediaType VIRTUALHARDWARESECTION_XML_TYPE = new MediaType("application",
+ "vnd.vmware.vcloud.virtualHardwareSection+xml");
+ /**
+ * "application/vnd.vmware.vcloud.guestCustomizationSection+xml"
+ */
+ public static final String GUESTCUSTOMIZATIONSECTION_XML = "application/vnd.vmware.vcloud.guestCustomizationSection+xml";
+ /**
+ * "application/vnd.vmware.vcloud.guestCustomizationSection+xml"
+ */
+ public static final MediaType GUESTCUSTOMIZATIONSECTION_XML_TYPE = new MediaType("application",
+ "vnd.vmware.vcloud.guestCustomizationSection+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.networkSection+xml"
+ */
+ public static final String NETWORKSECTION_XML = "application/vnd.vmware.vcloud.networkSection+xml";
+ /**
+ * "application/vnd.vmware.vcloud.networkSection+xml"
+ */
+ public static final MediaType NETWORKSECTION_XML_TYPE = new MediaType("application",
+ "vnd.vmware.vcloud.networkSection+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.task+xml"
+ */
+ public static final String TASK_XML = "application/vnd.vmware.vcloud.task+xml";
+ /**
+ * "application/vnd.vmware.vcloud.task+xml"
+ */
+ public static final MediaType TASK_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.task+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.undeployVAppParams+xml"
+ */
+ public static final String UNDEPLOYVAPPPARAMS_XML = "application/vnd.vmware.vcloud.undeployVAppParams+xml";
+ /**
+ * "application/vnd.vmware.vcloud.undeployVAppParams+xml"
+ */
+ public static final MediaType UNDEPLOYVAPPPARAMS_XML_TYPE = new MediaType("application",
+ "vnd.vmware.vcloud.undeployVAppParams+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.deployVAppParams+xml"
+ */
+ public static final String DEPLOYVAPPPARAMS_XML = "application/vnd.vmware.vcloud.deployVAppParams+xml";
+ /**
+ * "application/vnd.vmware.vcloud.deployVAppParams+xml"
+ */
+ public static final MediaType DEPLOYVAPPPARAMS_XML_TYPE = new MediaType("application",
+ "vnd.vmware.vcloud.deployVAppParams+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.vApp+xml"
+ */
+ public static final String VAPP_XML = "application/vnd.vmware.vcloud.vApp+xml";
+ /**
+ * "application/vnd.vmware.vcloud.vApp+xml"
+ */
+ public static final MediaType VAPP_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vApp+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.vm+xml"
+ */
+ public static final String VM_XML = "application/vnd.vmware.vcloud.vm+xml";
+ /**
+ * "application/vnd.vmware.vcloud.vm+xml"
+ */
+ public static final MediaType VM_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vm+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.vAppTemplate+xml"
+ */
+ public static final String VAPPTEMPLATE_XML = "application/vnd.vmware.vcloud.vAppTemplate+xml";
+ /**
+ * "application/vnd.vmware.vcloud.vAppTemplate+xml"
+ */
+ public static final MediaType VAPPTEMPLATE_XML_TYPE = new MediaType("application",
+ "vnd.vmware.vcloud.vAppTemplate+xml");
+ /**
+ * "application/vnd.vmware.vcloud.network+xml"
+ */
+ public static final String NETWORK_XML = "application/vnd.vmware.vcloud.network+xml";
+ /**
+ * "application/vnd.vmware.vcloud.network+xml"
+ */
+ public static final MediaType NETWORK_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.network+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.rasdItem+xml"
+ */
+ public static final String RASDITEM_XML = "application/vnd.vmware.vcloud.rasdItem+xml";
+ /**
+ * "application/vnd.vmware.vcloud.rasdItemsList+xml"
+ */
+ public static final String RASDITEMLIST_XML = "application/vnd.vmware.vcloud.rasdItemsList+xml";
+ /**
+ * "application/vnd.vmware.vcloud.rasdItem+xml"
+ */
+ public static final MediaType RASDITEM_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.rasdItem+xml");
+
+ /**
+ * "application/vnd.vmware.vcloud.session+xml"
+ */
+ public static final String SESSION_XML = "application/vnd.vmware.vcloud.session+xml";
+
+ /**
+ * "application/vnd.vmware.vcloud.session+xml"
+ */
+ public static final MediaType SESSION_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.session+xml");
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudResponseException.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudResponseException.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudResponseException.java
new file mode 100644
index 0000000..ea8d7f8
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudResponseException.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.vcloud.domain.VCloudError;
+
+/**
+ * Encapsulates an VCloud Error.
+ */
+public class VCloudResponseException extends HttpResponseException {
+
+ private org.jclouds.vcloud.domain.VCloudError error;
+
+ public VCloudResponseException(HttpCommand command, HttpResponse response, VCloudError error) {
+ super(String.format("request %s failed with code %s, error: %s", command.getCurrentRequest().getRequestLine(), response
+ .getStatusCode(), error.toString()), command, response);
+ this.setError(error);
+
+ }
+
+ public VCloudResponseException(HttpCommand command, HttpResponse response, VCloudError error, Throwable cause) {
+ super(String.format("request %1$s failed with error: %2$s", command.getCurrentRequest().getRequestLine(), error
+ .toString()), command, response, cause);
+ this.setError(error);
+
+ }
+
+ public VCloudResponseException(String message, HttpCommand command, HttpResponse response, VCloudError error) {
+ super(message, command, response);
+ this.setError(error);
+
+ }
+
+ public VCloudResponseException(String message, HttpCommand command, HttpResponse response, VCloudError error,
+ Throwable cause) {
+ super(message, command, response, cause);
+ this.setError(error);
+
+ }
+
+ public void setError(VCloudError error) {
+ this.error = error;
+ }
+
+ public VCloudError getError() {
+ return error;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudToken.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudToken.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudToken.java
new file mode 100644
index 0000000..2aca7bd
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudToken.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * A VCloud Session Token
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
+@Qualifier
+public @interface VCloudToken {
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java
new file mode 100644
index 0000000..b6c46f9
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+
+import java.io.Closeable;
+import java.net.URI;
+import java.util.SortedMap;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.vcloud.http.filters.VCloudSupportedVersions;
+import org.jclouds.vcloud.xml.SupportedVersionsHandler;
+
+@RequestFilters(VCloudSupportedVersions.class)
+public interface VCloudVersionsApi extends Closeable {
+
+ @GET
+ @XMLResponseParser(SupportedVersionsHandler.class)
+ @Path("/versions")
+ SortedMap<String, URI> getSupportedVersions();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java
new file mode 100644
index 0000000..fc757a1
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+import java.util.Properties;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.binders.BindToStringPayload;
+
+import com.google.common.base.Throwables;
+import com.google.inject.Inject;
+import com.jamesmurty.utils.XMLBuilder;
+
+@Singleton
+public class BindCPUCountToXmlPayload extends BindToStringPayload {
+ protected final String ns;
+ protected final String schema;
+
+ @Inject
+ public BindCPUCountToXmlPayload(BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
+ @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
+ this.ns = ns;
+ this.schema = schema;
+ }
+
+ private static final String RESOURCE_ALLOCATION_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData";
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
+ checkArgument(checkNotNull(payload, "cpuCount") instanceof Integer, "this binder is only valid for Integers!");
+ Integer cpuCount = Integer.class.cast(payload);
+ XMLBuilder cpuItem;
+ try {
+ cpuItem = XMLBuilder.create("Item").a("xmlns", ns).a("xmlns:rasd", RESOURCE_ALLOCATION_NS);
+ cpuItem.e("rasd:AllocationUnits").t("hertz * 10^6");
+ cpuItem.e("rasd:Description").t("Number of Virtual CPUs");
+ cpuItem.e("rasd:ElementName").t(cpuCount.toString() + " virtual CPU(s)");
+ cpuItem.e("rasd:InstanceID").t("4");
+ cpuItem.e("rasd:ResourceType").t(ResourceType.PROCESSOR.value());
+ cpuItem.e("rasd:VirtualQuantity").t(cpuCount.toString());
+ cpuItem.e("rasd:Weight").t("0");
+ Properties outputProperties = new Properties();
+ outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+ request = super.bindToRequest(request, cpuItem.asString(outputProperties));
+ } catch (Exception e) {
+ Throwables.propagate(e);
+ }
+ return request;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java
new file mode 100644
index 0000000..8a556be
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+import java.util.Map;
+import java.util.Properties;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToStringPayload;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.options.CaptureVAppOptions;
+
+import com.google.inject.Inject;
+import com.jamesmurty.utils.XMLBuilder;
+
+@Singleton
+public class BindCaptureVAppParamsToXmlPayload implements MapBinder {
+
+ protected final String ns;
+ protected final String schema;
+ private final BindToStringPayload stringBinder;
+
+ @Inject
+ public BindCaptureVAppParamsToXmlPayload(BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
+ this.ns = ns;
+ this.schema = schema;
+ this.stringBinder = stringBinder;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
+ "this binder is only valid for GeneratedHttpRequests!");
+ GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
+ String templateName = checkNotNull(postParams.remove("templateName"), "templateName").toString();
+ String vApp = checkNotNull(postParams.remove("vApp"), "vApp").toString();
+
+ CaptureVAppOptions options = findOptionsInArgsOrNull(gRequest);
+ if (options == null) {
+ options = new CaptureVAppOptions();
+ }
+ try {
+ return stringBinder.bindToRequest(request, generateXml(templateName, vApp, options));
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ } catch (FactoryConfigurationError e) {
+ throw new RuntimeException(e);
+ } catch (TransformerException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ protected String generateXml(String templateName, String vApp, CaptureVAppOptions options)
+ throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
+ XMLBuilder rootBuilder = buildRoot(templateName);
+ if (options.getDescription() != null)
+ rootBuilder.e("Description").text(options.getDescription());
+ rootBuilder.e("Source").a("href", vApp).a("type", VCloudMediaType.VAPP_XML);
+ Properties outputProperties = new Properties();
+ outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+ return rootBuilder.asString(outputProperties);
+ }
+
+ protected XMLBuilder buildRoot(String name) throws ParserConfigurationException, FactoryConfigurationError {
+ XMLBuilder rootBuilder = XMLBuilder.create("CaptureVAppParams").a("name", name).a("xmlns", ns)
+ .a("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema);
+ return rootBuilder;
+ }
+
+ protected CaptureVAppOptions findOptionsInArgsOrNull(GeneratedHttpRequest gRequest) {
+ for (Object arg : gRequest.getInvocation().getArgs()) {
+ if (arg instanceof CaptureVAppOptions) {
+ return (CaptureVAppOptions) arg;
+ } else if (arg instanceof CaptureVAppOptions[]) {
+ CaptureVAppOptions[] options = (CaptureVAppOptions[]) arg;
+ return (options.length > 0) ? options[0] : null;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ throw new IllegalStateException("CaptureVAppParams is needs parameters");
+ }
+
+ protected String ifNullDefaultTo(String value, String defaultValue) {
+ return value != null ? value : checkNotNull(defaultValue, "defaultValue");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java
new file mode 100644
index 0000000..98c4e3a
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToStringPayload;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.options.CatalogItemOptions;
+
+import com.google.inject.Inject;
+import com.jamesmurty.utils.XMLBuilder;
+
+@Singleton
+public class BindCatalogItemToXmlPayload implements MapBinder {
+
+ protected final String ns;
+ protected final String schema;
+ private final BindToStringPayload stringBinder;
+
+ @Inject
+ public BindCatalogItemToXmlPayload(BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
+ this.ns = ns;
+ this.schema = schema;
+ this.stringBinder = stringBinder;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
+ "this binder is only valid for GeneratedHttpRequests!");
+ GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
+ String name = checkNotNull(postParams.get("name"), "name").toString();
+ URI entity = URI.create(checkNotNull(postParams.get("Entity"), "Entity").toString());
+
+ CatalogItemOptions options = findOptionsInArgsOrNew(gRequest);
+ try {
+ return stringBinder.bindToRequest(request, generateXml(name, entity, options));
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ } catch (FactoryConfigurationError e) {
+ throw new RuntimeException(e);
+ } catch (TransformerException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ protected String generateXml(String templateName, URI entity, CatalogItemOptions options)
+ throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
+ XMLBuilder rootBuilder = buildRoot(templateName);
+ if (options.getDescription() != null)
+ rootBuilder.e("Description").t(options.getDescription());
+ rootBuilder.e("Entity").a("href", entity.toASCIIString());
+ for (Entry<String, String> entry : options.getProperties().entrySet()) {
+ rootBuilder.e("Property").a("key", entry.getKey()).t(entry.getValue());
+ }
+ Properties outputProperties = new Properties();
+ outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+ return rootBuilder.asString(outputProperties);
+ }
+
+ protected XMLBuilder buildRoot(String name) throws ParserConfigurationException, FactoryConfigurationError {
+ XMLBuilder rootBuilder = XMLBuilder.create("CatalogItem").a("name", name).a("xmlns", ns).a("xmlns:xsi",
+ "http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema);
+ return rootBuilder;
+ }
+
+ protected CatalogItemOptions findOptionsInArgsOrNew(GeneratedHttpRequest gRequest) {
+ for (Object arg : gRequest.getInvocation().getArgs()) {
+ if (arg instanceof CatalogItemOptions) {
+ return CatalogItemOptions.class.cast(arg);
+ } else if (arg.getClass().isArray()) {
+ Object[] array = (Object[]) arg;
+ if (array.length > 0 && array[0] instanceof CatalogItemOptions)
+ return CatalogItemOptions.class.cast(array[0]);
+ }
+ }
+ return new CatalogItemOptions();
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ throw new IllegalStateException("CatalogItem is needs parameters");
+ }
+
+ protected String ifNullDefaultTo(String value, String defaultValue) {
+ return value != null ? value : checkNotNull(defaultValue, "defaultValue");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java
new file mode 100644
index 0000000..71617bc
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+import java.util.Map;
+import java.util.Properties;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToStringPayload;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.options.CloneOptions;
+
+import com.google.common.base.Throwables;
+import com.google.inject.Inject;
+import com.jamesmurty.utils.XMLBuilder;
+
+@Singleton
+public abstract class BindCloneParamsToXmlPayload<O extends CloneOptions> implements MapBinder {
+
+ protected final String ns;
+ protected final String schema;
+ private final BindToStringPayload stringBinder;
+
+ protected abstract String getRootElement();
+ protected abstract String getSourceMediaType();
+ protected abstract Class<O> getOptionClass();
+
+ @Inject
+ public BindCloneParamsToXmlPayload(BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
+ this.ns = ns;
+ this.schema = schema;
+ this.stringBinder = stringBinder;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
+ "this binder is only valid for GeneratedHttpRequests!");
+ GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
+ String name = checkNotNull(postParams.get("name"), "name").toString();
+ String source = checkNotNull(postParams.get("Source"), "Source").toString();
+ boolean isSourceDelete = Boolean.parseBoolean((String) postParams.get("IsSourceDelete"));
+
+ O options = findOptionsInArgsOrNew(gRequest);
+ return stringBinder.bindToRequest(request, generateXml(name, source, isSourceDelete, options));
+ }
+
+ protected String generateXml(String name, String source, boolean isSourceDelete, O options) {
+ XMLBuilder rootBuilder = buildRoot(name, options);
+ addElementsUnderRoot(rootBuilder, source, options, isSourceDelete);
+ Properties outputProperties = new Properties();
+ outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+ try {
+ return rootBuilder.asString(outputProperties);
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ protected void addElementsUnderRoot(XMLBuilder rootBuilder, String source, O options, boolean isSourceDelete) {
+ if (options.getDescription() != null)
+ rootBuilder.e("Description").text(options.getDescription());
+ rootBuilder.e("Source").a("href", source).a("type", getSourceMediaType());
+ if (isSourceDelete)
+ rootBuilder.e("IsSourceDelete").t("true");
+ }
+
+ protected XMLBuilder buildRoot(String name, O options) {
+ try {
+ return XMLBuilder.create(getRootElement()).a("xmlns", ns).a("xmlns:xsi",
+ "http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema).a("name",
+ name);
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected O findOptionsInArgsOrNew(GeneratedHttpRequest gRequest) {
+ for (Object arg : gRequest.getInvocation().getArgs()) {
+ if (getOptionClass().isInstance(arg)) {
+ return (O) arg;
+ } else if (arg.getClass().isArray()) {
+ Object[] array = (Object[]) arg;
+ if (array.length > 0 && getOptionClass().isInstance(array[0]))
+ return (O) array[0];
+ }
+ }
+ try {
+ return getOptionClass().newInstance();
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ throw new IllegalStateException("CloneParams is needs parameters");
+ }
+
+ protected String ifNullDefaultTo(String value, String defaultValue) {
+ return value != null ? value : checkNotNull(defaultValue, "defaultValue");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java
new file mode 100644
index 0000000..50c3b83
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.rest.binders.BindToStringPayload;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.options.CloneVAppOptions;
+
+import com.google.inject.Inject;
+import com.jamesmurty.utils.XMLBuilder;
+
+@Singleton
+public class BindCloneVAppParamsToXmlPayload extends BindCloneParamsToXmlPayload<CloneVAppOptions> {
+
+ @Inject
+ public BindCloneVAppParamsToXmlPayload(BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
+ super(stringBinder, ns, schema);
+ }
+
+ @Override
+ protected Class<CloneVAppOptions> getOptionClass() {
+ return CloneVAppOptions.class;
+ }
+
+ @Override
+ protected String getRootElement() {
+ return "CloneVAppParams";
+ }
+
+ @Override
+ protected String getSourceMediaType() {
+ return VCloudMediaType.VAPP_XML;
+ }
+
+ protected XMLBuilder buildRoot(String name, CloneVAppOptions options) {
+ return super.buildRoot(name, options).a("deploy", options.isDeploy() + "").a("powerOn", options.isPowerOn() + "");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java
new file mode 100644
index 0000000..2323c94
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.rest.binders.BindToStringPayload;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.options.CloneVAppTemplateOptions;
+
+import com.google.inject.Inject;
+
+@Singleton
+public class BindCloneVAppTemplateParamsToXmlPayload extends BindCloneParamsToXmlPayload<CloneVAppTemplateOptions> {
+
+ @Inject
+ public BindCloneVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
+ super(stringBinder, schema, schema);
+ }
+
+ @Override
+ protected Class<CloneVAppTemplateOptions> getOptionClass() {
+ return CloneVAppTemplateOptions.class;
+ }
+
+ @Override
+ protected String getRootElement() {
+ return "CloneVAppTemplateParams";
+ }
+
+ @Override
+ protected String getSourceMediaType() {
+ return VCloudMediaType.VAPPTEMPLATE_XML;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java
new file mode 100644
index 0000000..d376222
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.rest.binders.BindToStringPayload;
+
+import com.google.inject.Inject;
+
+@Singleton
+public class BindDeployVAppParamsToXmlPayload extends BindParamsToXmlPayload {
+
+ @Inject
+ public BindDeployVAppParamsToXmlPayload(BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns) {
+ super("DeployVAppParams", stringBinder, ns);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindDiskAttachOrDetachParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindDiskAttachOrDetachParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindDiskAttachOrDetachParamsToXmlPayload.java
new file mode 100644
index 0000000..7e198aa
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindDiskAttachOrDetachParamsToXmlPayload.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import com.google.common.base.Throwables;
+import com.google.inject.Inject;
+import com.jamesmurty.utils.XMLBuilder;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToStringPayload;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.domain.DiskAttachOrDetachParams;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+import java.util.Map;
+import java.util.Properties;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+/**
+ * Created by mblokzij on 29/10/2014.
+ */
+@Singleton
+public class BindDiskAttachOrDetachParamsToXmlPayload implements MapBinder {
+
+ protected final String ns;
+ protected final String schema;
+
+ protected final BindToStringPayload stringBinder;
+
+ @Inject
+ public BindDiskAttachOrDetachParamsToXmlPayload(BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
+ this.ns = ns;
+ this.schema = schema;
+ this.stringBinder = stringBinder;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
+ "this binder is only valid for GeneratedHttpRequests!");
+ DiskAttachOrDetachParams params = (DiskAttachOrDetachParams) checkNotNull(postParams.remove("params"), "params");
+ XMLBuilder diskAttachOrDetachParams;
+ String xml = null;
+ try {
+ diskAttachOrDetachParams = XMLBuilder.create("DiskAttachOrDetachParams").a("xmlns", ns);
+ XMLBuilder disk = diskAttachOrDetachParams.e("Disk");
+ if (params.getHref() != null) {
+ disk.a("href", params.getHref().toString());
+ }
+ if (params.getId() != null) {
+ disk.a("id", params.getId().toString());
+ }
+ if (params.getName() != null) {
+ disk.a("name", params.getName());
+ }
+ if (params.getType() != null) {
+ disk.a("type", params.getType());
+ }
+ if (params.getBusNumber() != null) {
+ diskAttachOrDetachParams.e("BusNumber").t(params.getBusNumber().toString());
+ }
+ if (params.getUnitNumber() != null) {
+ diskAttachOrDetachParams.e("UnitNumber").t(params.getUnitNumber().toString());
+ }
+
+ xml = diskAttachOrDetachParams.asString();
+ } catch (Exception e) {
+ Throwables.propagate(e);
+ }
+ return stringBinder.bindToRequest(request, xml);
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object postParams) {
+ throw new IllegalStateException("BindDiskAttachOrDetachParamsToXmlPayload needs parameters");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java
new file mode 100644
index 0000000..3ba51d1
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+import java.util.Properties;
+
+import javax.annotation.Resource;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.logging.Logger;
+import org.jclouds.rest.binders.BindToStringPayload;
+import org.jclouds.vcloud.domain.GuestCustomizationSection;
+
+import com.google.common.base.Throwables;
+import com.google.inject.Inject;
+import com.jamesmurty.utils.XMLBuilder;
+
+@Singleton
+public class BindGuestCustomizationSectionToXmlPayload extends BindToStringPayload {
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ protected final String ns;
+ protected final String schema;
+
+ @Inject
+ public BindGuestCustomizationSectionToXmlPayload(BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
+ this.ns = ns;
+ this.schema = schema;
+ }
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
+ checkArgument(checkNotNull(payload, "GuestCustomizationSection") instanceof GuestCustomizationSection,
+ "this binder is only valid for GuestCustomizationSection!");
+ GuestCustomizationSection guest = GuestCustomizationSection.class.cast(payload);
+ XMLBuilder guestCustomizationSection;
+ try {
+ guestCustomizationSection = XMLBuilder.create("GuestCustomizationSection").a("xmlns", ns).a("xmlns:ovf",
+ "http://schemas.dmtf.org/ovf/envelope/1").a("type", guest.getType()).a("href",
+ guest.getHref().toASCIIString()).a("ovf:required", "false");
+ guestCustomizationSection.e("ovf:Info").t(guest.getInfo());
+
+ if (guest.isEnabled() != null)
+ guestCustomizationSection.e("Enabled").t(guest.isEnabled().toString());
+ if (guest.shouldChangeSid() != null)
+ guestCustomizationSection.e("ChangeSid").t(guest.shouldChangeSid().toString());
+ if (guest.getVirtualMachineId() != null)
+ guestCustomizationSection.e("VirtualMachineId").t(guest.getVirtualMachineId().toString());
+ if (guest.isJoinDomainEnabled() != null)
+ guestCustomizationSection.e("JoinDomainEnabled").t(guest.isJoinDomainEnabled().toString());
+ if (guest.shouldUseOrgSettings() != null)
+ guestCustomizationSection.e("UseOrgSettings").t(guest.shouldUseOrgSettings().toString());
+ if (guest.getDomainName() != null)
+ guestCustomizationSection.e("DomainName").t(guest.getDomainName().toString());
+ if (guest.getDomainUserName() != null)
+ guestCustomizationSection.e("DomainUserName").t(guest.getDomainUserName().toString());
+ if (guest.getDomainUserPassword() != null)
+ guestCustomizationSection.e("DomainUserPassword").t(guest.getDomainUserPassword().toString());
+ if (guest.isAdminPasswordEnabled() != null)
+ guestCustomizationSection.e("AdminPasswordEnabled").t(guest.isAdminPasswordEnabled().toString());
+ if (guest.isAdminPasswordAuto() != null)
+ guestCustomizationSection.e("AdminPasswordAuto").t(guest.isAdminPasswordAuto().toString());
+ // if (guest.getAdminPassword() != null)
+ // guestCustomizationSection.e("AdminPassword").t(guest.getAdminPassword().toString());
+ if (guest.isResetPasswordRequired() != null)
+ guestCustomizationSection.e("ResetPasswordRequired").t(guest.isResetPasswordRequired().toString());
+ if (guest.getCustomizationScript() != null)
+ guestCustomizationSection.e("CustomizationScript").t(guest.getCustomizationScript());
+ if (guest.getComputerName() != null)
+ guestCustomizationSection.e("ComputerName").t(guest.getComputerName().toString());
+ if (guest.getEdit() != null)
+ guestCustomizationSection.e("Link").a("rel", "edit").a("type", guest.getType()).a("href",
+ guest.getHref().toASCIIString());
+
+ Properties outputProperties = new Properties();
+ outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+ request = super.bindToRequest(request, guestCustomizationSection.asString(outputProperties));
+ request.getPayload().getContentMetadata().setContentType(guest.getType());
+ } catch (Exception e) {
+ Throwables.propagate(e);
+ }
+ return request;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java
new file mode 100644
index 0000000..08e5443
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.transform;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToStringPayload;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.jclouds.vcloud.domain.network.NetworkConfig;
+import org.jclouds.vcloud.endpoints.Network;
+import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableSet;
+import com.jamesmurty.utils.XMLBuilder;
+
+@Singleton
+public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder {
+
+ protected final String ns;
+ protected final String schema;
+ protected final BindToStringPayload stringBinder;
+ protected final Supplier<ReferenceType> defaultNetwork;
+ protected final FenceMode defaultFenceMode;
+ protected final LoadingCache<URI, VAppTemplate> templateCache;
+ protected final Function<VAppTemplate, String> defaultNetworkNameInTemplate;
+
+ @Inject
+ public BindInstantiateVAppTemplateParamsToXmlPayload(LoadingCache<URI, VAppTemplate> templateCache,
+ @Network Function<VAppTemplate, String> defaultNetworkNameInTemplate, BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema,
+ @Network Supplier<ReferenceType> network, FenceMode fenceMode) {
+ this.templateCache = templateCache;
+ this.defaultNetworkNameInTemplate = defaultNetworkNameInTemplate;
+ this.ns = ns;
+ this.schema = schema;
+ this.stringBinder = stringBinder;
+ this.defaultNetwork = network;
+ this.defaultFenceMode = fenceMode;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
+ "this binder is only valid for GeneratedHttpRequests!");
+ GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
+ String name = checkNotNull(postParams.remove("name"), "name").toString();
+ URI template = URI.create(checkNotNull(postParams.remove("template"), "template").toString());
+
+ Set<NetworkConfig> networkConfig = null;
+
+ NetworkConfigDecorator networkConfigDecorator = new NetworkConfigDecorator(templateCache.getUnchecked(template),
+ defaultNetwork.get().getHref(), defaultFenceMode, defaultNetworkNameInTemplate);
+
+ InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest);
+
+ if (options != null) {
+ if (options.getNetworkConfig().size() > 0)
+ networkConfig = ImmutableSet
+ .copyOf(transform(options.getNetworkConfig(), networkConfigDecorator));
+ } else {
+ options = new InstantiateVAppTemplateOptions();
+ }
+
+ if (networkConfig == null)
+ networkConfig = ImmutableSet.of(networkConfigDecorator.apply(null));
+
+ try {
+ return stringBinder.bindToRequest(request, generateXml(name, options.getDescription(), options.shouldDeploy(),
+ options.shouldPowerOn(), template, networkConfig));
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ } catch (FactoryConfigurationError e) {
+ throw new RuntimeException(e);
+ } catch (TransformerException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ @VisibleForTesting
+ Set<Vm> ifCustomizationScriptIsSetGetVmsInTemplate(String customizationScript, final URI template) {
+ Set<Vm> vms = ImmutableSet.of();
+ if (customizationScript != null) {
+ VAppTemplate vAppTemplate = templateCache.getUnchecked(template);
+ checkArgument(vAppTemplate != null, "vAppTemplate %s not found!", template);
+ vms = vAppTemplate.getChildren();
+ checkArgument(vms.size() > 0, "no vms found in vAppTemplate %s", vAppTemplate);
+ }
+ return vms;
+ }
+
+ protected static final class NetworkConfigDecorator implements Function<NetworkConfig, NetworkConfig> {
+ private final VAppTemplate template;
+ private final URI defaultNetwork;
+ private final FenceMode defaultFenceMode;
+ private final Function<VAppTemplate, String> defaultNetworkNameInTemplate;
+
+ protected NetworkConfigDecorator(VAppTemplate template, URI defaultNetwork, FenceMode defaultFenceMode,
+ Function<VAppTemplate, String> defaultNetworkNameInTemplate) {
+ this.template = checkNotNull(template, "template");
+ this.defaultNetwork = checkNotNull(defaultNetwork, "defaultNetwork");
+ this.defaultFenceMode = checkNotNull(defaultFenceMode, "defaultFenceMode");
+ this.defaultNetworkNameInTemplate = checkNotNull(defaultNetworkNameInTemplate, "defaultNetworkNameInTemplate");
+ }
+
+ @Override
+ public NetworkConfig apply(NetworkConfig from) {
+ if (from == null)
+ return new NetworkConfig(defaultNetworkNameInTemplate.apply(template), defaultNetwork, defaultFenceMode);
+ URI network = ifNullDefaultTo(from.getParentNetwork(), defaultNetwork);
+ FenceMode fenceMode = ifNullDefaultTo(from.getFenceMode(), defaultFenceMode);
+ // using conditional statement instead of ifNullDefaultTo so that we lazy invoke the
+ // function, as it is an expensive one.
+ String networkName = from.getNetworkName() != null ? from.getNetworkName() : defaultNetworkNameInTemplate
+ .apply(template);
+ return new NetworkConfig(networkName, network, fenceMode);
+ }
+ }
+
+ protected String generateXml(String name, @Nullable String description, boolean deploy, boolean powerOn,
+ URI template, Iterable<NetworkConfig> networkConfig)
+ throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
+ XMLBuilder rootBuilder = buildRoot(name).a("deploy", deploy + "").a("powerOn", powerOn + "");
+ if (description != null)
+ rootBuilder.e("Description").t(description);
+ XMLBuilder instantiationParamsBuilder = rootBuilder.e("InstantiationParams");
+ addNetworkConfig(instantiationParamsBuilder, networkConfig);
+ rootBuilder.e("Source").a("href", template.toASCIIString());
+ rootBuilder.e("AllEULAsAccepted").t("true");
+
+ Properties outputProperties = new Properties();
+ outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+ return rootBuilder.asString(outputProperties);
+ }
+
+ protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder,
+ Iterable<NetworkConfig> networkConfig) {
+ XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection");
+ networkConfigBuilder.e("ovf:Info").t("Configuration parameters for logical networks");
+ for (NetworkConfig n : networkConfig) {
+ XMLBuilder configurationBuilder = networkConfigBuilder.e("NetworkConfig").a("networkName", n.getNetworkName())
+ .e("Configuration");
+ configurationBuilder.e("ParentNetwork").a("href", n.getParentNetwork().toASCIIString());
+ if (n.getFenceMode() != null) {
+ configurationBuilder.e("FenceMode").t(n.getFenceMode().toString());
+ }
+ }
+ }
+
+ protected XMLBuilder buildRoot(String name) throws ParserConfigurationException, FactoryConfigurationError {
+ return XMLBuilder.create("InstantiateVAppTemplateParams").a("name", name).a("xmlns", ns)
+ .a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1");
+ }
+
+ protected InstantiateVAppTemplateOptions findOptionsInArgsOrNull(GeneratedHttpRequest gRequest) {
+ for (Object arg : gRequest.getInvocation().getArgs()) {
+ if (arg instanceof InstantiateVAppTemplateOptions) {
+ return (InstantiateVAppTemplateOptions) arg;
+ } else if (arg instanceof InstantiateVAppTemplateOptions[]) {
+ InstantiateVAppTemplateOptions[] options = (InstantiateVAppTemplateOptions[]) arg;
+ return (options.length > 0) ? options[0] : null;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ throw new IllegalStateException("InstantiateVAppTemplateParams is needs parameters");
+ }
+
+ public static <T> T ifNullDefaultTo(T value, T defaultValue) {
+ return value != null ? value : checkNotNull(defaultValue, "defaultValue");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java
new file mode 100644
index 0000000..e6a1cd4
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+import java.util.Properties;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.binders.BindToStringPayload;
+
+import com.google.common.base.Throwables;
+import com.google.inject.Inject;
+import com.jamesmurty.utils.XMLBuilder;
+
+@Singleton
+public class BindMemoryToXmlPayload extends BindToStringPayload {
+ protected final String ns;
+ protected final String schema;
+
+ @Inject
+ public BindMemoryToXmlPayload(BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
+ @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
+ this.ns = ns;
+ this.schema = schema;
+ }
+
+ private static final String RESOURCE_ALLOCATION_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData";
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
+ checkArgument(checkNotNull(payload, "memoryInMB") instanceof Integer, "this binder is only valid for Integers!");
+ Integer memoryInMB = Integer.class.cast(payload);
+ XMLBuilder cpuItem;
+ try {
+ cpuItem = XMLBuilder.create("Item").a("xmlns", ns).a("xmlns:rasd", RESOURCE_ALLOCATION_NS);
+ cpuItem.e("rasd:AllocationUnits").t("byte * 2^20");
+ cpuItem.e("rasd:Description").t("Memory Size");
+ cpuItem.e("rasd:ElementName").t(memoryInMB.toString() + " MB of memory");
+ cpuItem.e("rasd:InstanceID").t("5");
+ cpuItem.e("rasd:Reservation").t("0");
+ cpuItem.e("rasd:ResourceType").t(ResourceType.MEMORY.value());
+ cpuItem.e("rasd:VirtualQuantity").t(memoryInMB.toString());
+ cpuItem.e("rasd:Weight").t("0");
+ Properties outputProperties = new Properties();
+ outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+ request = super.bindToRequest(request, cpuItem.asString(outputProperties));
+ } catch (Exception e) {
+ Throwables.propagate(e);
+ }
+ return request;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java
new file mode 100644
index 0000000..6a27725
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
+
+import java.util.Properties;
+
+import javax.annotation.Resource;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.logging.Logger;
+import org.jclouds.rest.binders.BindToStringPayload;
+import org.jclouds.vcloud.domain.NetworkConnection;
+import org.jclouds.vcloud.domain.NetworkConnectionSection;
+
+import com.google.common.base.Throwables;
+import com.google.inject.Inject;
+import com.jamesmurty.utils.XMLBuilder;
+
+@Singleton
+public class BindNetworkConnectionSectionToXmlPayload extends BindToStringPayload {
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ protected final String ns;
+ protected final String schema;
+
+ @Inject
+ public BindNetworkConnectionSectionToXmlPayload(BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
+ this.ns = ns;
+ this.schema = schema;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
+ checkArgument(checkNotNull(payload, "NetworkConnectionSection") instanceof NetworkConnectionSection,
+ "this binder is only valid for NetworkConnectionSection!");
+ NetworkConnectionSection net = NetworkConnectionSection.class.cast(payload);
+ XMLBuilder networkConnectionSection;
+ try {
+ networkConnectionSection = XMLBuilder.create("NetworkConnectionSection").a("xmlns", ns)
+ .a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1").a("type", net.getType())
+ .a("href", net.getHref().toASCIIString()).a("ovf:required", "false");
+ networkConnectionSection.e("ovf:Info").t(net.getInfo());
+
+ if (net.getPrimaryNetworkConnectionIndex() != null)
+ networkConnectionSection.e("PrimaryNetworkConnectionIndex").t(
+ net.getPrimaryNetworkConnectionIndex().toString());
+ for (NetworkConnection networkConnection : net.getConnections()) {
+ XMLBuilder networkConnectionSectionChild = networkConnectionSection.e("NetworkConnection").a("network",
+ networkConnection.getNetwork());
+ networkConnectionSectionChild.e("NetworkConnectionIndex").t(
+ networkConnection.getNetworkConnectionIndex() + "");
+ if (networkConnection.getExternalIpAddress() != null)
+ networkConnectionSectionChild.e("ExternalIpAddress").t(networkConnection.getExternalIpAddress());
+ if (networkConnection.getIpAddress() != null)
+ networkConnectionSectionChild.e("IpAddress").t(networkConnection.getIpAddress());
+ networkConnectionSectionChild.e("IsConnected").t(networkConnection.isConnected() + "");
+ if (networkConnection.getMACAddress() != null)
+ networkConnectionSectionChild.e("MACAddress").t(networkConnection.getMACAddress());
+ if (networkConnection.getIpAddressAllocationMode() != null)
+ networkConnectionSectionChild.e("IpAddressAllocationMode").t(
+ networkConnection.getIpAddressAllocationMode().toString());
+ }
+
+ if (net.getEdit() != null)
+ networkConnectionSection.e("Link").a("rel", "edit").a("type", net.getType())
+ .a("href", net.getHref().toASCIIString());
+
+ Properties outputProperties = new Properties();
+ outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+ request = super.bindToRequest(request, networkConnectionSection.asString(outputProperties));
+ request.getPayload().getContentMetadata().setContentType(net.getType());
+ } catch (Exception e) {
+ Throwables.propagate(e);
+ }
+ return request;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java
new file mode 100644
index 0000000..f613c1b
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToStringPayload;
+
+import com.google.inject.Inject;
+import com.jamesmurty.utils.XMLBuilder;
+
+@Singleton
+public class BindParamsToXmlPayload implements MapBinder {
+
+ protected final String ns;
+ protected final BindToStringPayload stringBinder;
+ protected final String element;
+
+ @Inject
+ public BindParamsToXmlPayload(String element, BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns) {
+ this.element = element;
+ this.ns = ns;
+ this.stringBinder = stringBinder;
+ }
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ try {
+ return stringBinder.bindToRequest(request, generateXml(postParams));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private String generateXml(Map<String, Object> postParams) throws ParserConfigurationException,
+ FactoryConfigurationError, TransformerException {
+ XMLBuilder rootBuilder = XMLBuilder.create(element);
+ for (Entry<String, Object> entry : postParams.entrySet())
+ rootBuilder.a(entry.getKey(), (String) entry.getValue());
+ rootBuilder.a("xmlns", ns);
+ Properties outputProperties = new Properties();
+ outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+ return rootBuilder.asString(outputProperties);
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ throw new IllegalArgumentException("incorrect usage");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java
new file mode 100644
index 0000000..d95846e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.rest.binders.BindToStringPayload;
+
+import com.google.inject.Inject;
+
+@Singleton
+public class BindUndeployVAppParamsToXmlPayload extends BindParamsToXmlPayload {
+
+ @Inject
+ public BindUndeployVAppParamsToXmlPayload(BindToStringPayload stringBinder,
+ @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns) {
+ super("UndeployVAppParams", stringBinder, ns);
+ }
+
+}
[34/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_multiple_page_1.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_multiple_page_1.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_multiple_page_1.json
new file mode 100644
index 0000000..3ffcfd5
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_multiple_page_1.json
@@ -0,0 +1,55 @@
+{
+ "kind": "compute#imageList",
+ "id": "projects/centos-cloud/global/images",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images",
+ "nextPageToken": "CgVJTUFHRRIbZ29vZ2xlLmNlbnRvcy02LTItdjIwMTIwNjIx",
+ "items": [
+ {
+ "kind": "compute#image",
+ "id": "12941197498378735318",
+ "creationTimestamp": "2012-07-16T15:16:13.468-07:00",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120326",
+ "name": "centos-6-2-v20120326",
+ "description": "DEPRECATED. CentOS 6.2 image; Created Mon, 26 Mar 2012 21:19:09 +0000",
+ "sourceType": "RAW",
+ "deprecated": {
+ "state": "DELETED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20130104"
+ },
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ }
+ },
+ {
+ "kind": "compute#image",
+ "id": "12894486577628239762",
+ "creationTimestamp": "2012-05-21T13:15:37.215-07:00",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120503",
+ "name": "centos-6-2-v20120503",
+ "description": "CentOS 6.2; Created Wed, 09 May 2012 11:55:54 +0000",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ }
+ },
+ {
+ "kind": "compute#image",
+ "id": "12917726455664967299",
+ "creationTimestamp": "2012-06-18T11:05:30.664-07:00",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120611",
+ "name": "centos-6-2-v20120611",
+ "description": "CentOS 6.2; Created Mon, 11 Jun 2012 13:15:44 +0000",
+ "sourceType": "RAW",
+ "deprecated": {
+ "state": "DEPRECATED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-20130509"
+ },
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ }
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_multiple_page_2.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_multiple_page_2.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_multiple_page_2.json
new file mode 100644
index 0000000..b7b736a
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_multiple_page_2.json
@@ -0,0 +1,47 @@
+{
+ "kind": "compute#imageList",
+ "id": "projects/centos-cloud/global/images",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images",
+ "nextPageToken": "CgVJTUFHRRIbZ29vZ2xlLmdjZWwtMTAtMDQtdjIwMTIxMTA2",
+ "items": [
+ {
+ "kind": "compute#image",
+ "id": "12920641029336858796",
+ "creationTimestamp": "2012-06-21T22:59:56.392-07:00",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120621",
+ "name": "centos-6-2-v20120621",
+ "description": "CentOS 6.2; Created Thu, 21 Jun 2012 14:22:21 +0000",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ }
+ },
+ {
+ "kind": "compute#image",
+ "id": "12994279803511049620",
+ "creationTimestamp": "2012-09-18T08:52:47.584-07:00",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20120912",
+ "name": "centos-6-v20120912",
+ "description": "CentOS 6; Created Wed, 12 Sep 2012 00:00:00 +0000",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ }
+ },
+ {
+ "kind": "compute#image",
+ "id": "13037720516378381209",
+ "creationTimestamp": "2012-11-09T11:40:41.079-08:00",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20121106",
+ "name": "centos-6-v20121106",
+ "description": "SCSI-enabled CentOS 6; Created Tue, 06 Nov 2012 00:00:00 +0000",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ }
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_single_page.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_single_page.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_single_page.json
new file mode 100644
index 0000000..a9e0ffa
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/image_list_single_page.json
@@ -0,0 +1,50 @@
+{
+ "kind": "compute#imageList",
+ "id": "projects/centos-cloud/global/images",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images",
+ "items": [
+ {
+ "kind": "compute#image",
+ "id": "13037722963789596520",
+ "creationTimestamp": "2012-11-09T11:43:28.749-08:00",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/gcel-10-04-v20121106",
+ "name": "gcel-10-04-v20121106",
+ "description": "SCSI-enabled GCEL 10.04 LTS; Created Tue, 06 Nov 2012 00:00:00 +0000",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ }
+ },
+ {
+ "kind": "compute#image",
+ "id": "13037721421359523565",
+ "creationTimestamp": "2012-11-09T11:40:51.994-08:00",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140718",
+ "name": "debian-7-wheezy-v20140718",
+ "description": "SCSI-enabled GCEL 12.04 LTS; Created Tue, 06 Nov 2012 00:00:00 +0000",
+ "sourceType": "RAW",
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ }
+ },
+ {
+ "kind": "compute#image",
+ "id": "12941198995845323366",
+ "creationTimestamp": "2012-07-16T15:18:50.405-07:00",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/ubuntu-10-04-v20110728",
+ "name": "ubuntu-10-04-v20110728",
+ "description": "DEPRECATED. GCEL 10.04 LTS; Created Thu, 28 Jul 2011 16:45:51 +0000",
+ "sourceType": "RAW",
+ "deprecated": {
+ "state": "DELETED",
+ "replacement": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/gcel-10-04-v20130104"
+ },
+ "rawDisk": {
+ "source": "",
+ "containerType": "TAR"
+ }
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_add_access_config.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_add_access_config.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_add_access_config.json
new file mode 100644
index 0000000..fe4fcf0
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_add_access_config.json
@@ -0,0 +1,11 @@
+POST https://www.googleapis.com/compute/v1/projects/jclouds-gce/zones/us-central1-a/instances/test-instance/addAccessConfig?network_interface=nic0&key={YOUR_API_KEY}
+
+Content-Type: application/json
+Authorization: Bearer ya29.AHES6ZRyNKVHwnMPUvZitAuA8mR8b0lcWh1bMI5UQ5bgsJ4j
+X-JavaScript-User-Agent: Google APIs Explorer
+
+{
+"name": "config1",
+"natIP": "10.0.1.1",
+"type": "ONE_TO_ONE_NAT"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_attach_disk.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_attach_disk.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_attach_disk.json
new file mode 100644
index 0000000..8fc35bc
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_attach_disk.json
@@ -0,0 +1,6 @@
+{
+ "type": "PERSISTENT",
+ "mode": "READ_ONLY",
+ "source": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1",
+ "boot": false
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_get.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_get.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_get.json
new file mode 100644
index 0000000..ca591c9
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_get.json
@@ -0,0 +1,62 @@
+{
+ "kind": "compute#instance",
+ "id": "13051190678907570425",
+ "description": "desc",
+ "creationTimestamp": "2012-11-25T23:48:20.758",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-0",
+ "name": "test-0",
+ "machineType": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1",
+ "status": "RUNNING",
+ "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a",
+ "networkInterfaces": [
+ {
+ "kind": "compute#instanceNetworkInterface",
+ "name": "nic0",
+ "networkIP": "10.240.121.115",
+ "network": "https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"
+ }
+ ],
+ "disks": [
+ {
+ "kind": "compute#instanceDisk",
+ "type": "PERSISTENT",
+ "mode": "READ_WRITE",
+ "deviceName": "test",
+ "source": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/test",
+ "index": 0,
+ "boot": true
+ }
+ ],
+ "serviceAccounts": [
+ {
+ "kind": "compute#serviceAccount",
+ "email": "default",
+ "scopes": [
+ "myscope"
+ ]
+ }
+ ],
+ "metadata": {
+ "items": [
+ {
+ "key": "aKey",
+ "value": "aValue"
+ },
+ {
+ "key": "jclouds-image",
+ "value": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140718"
+ },
+ {
+ "key": "jclouds-delete-boot-disk",
+ "value": "true"
+ }
+ ],
+ "fingerprint": "efgh"
+ },
+ "tags": {
+ "items": [
+ "aTag"
+ ],
+ "fingerprint": "abcd"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_insert.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_insert.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_insert.json
new file mode 100644
index 0000000..0ce3c53
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_insert.json
@@ -0,0 +1 @@
+{"name":"test-0","description":"desc","machineType":"https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1","serviceAccounts":[{"email":"default","scopes":["myscope"]}],"networkInterfaces":[{"network":"https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default","accessConfigs":[{"type":"ONE_TO_ONE_NAT"}]}],"disks":[{"mode":"READ_WRITE","source":"https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/test","deleteOnTerminate":true,"boot":false,"type":"PERSISTENT"}],"metadata":{"kind":"compute#metadata","items":[{"key":"aKey","value":"aValue"}]}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_insert_simple.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_insert_simple.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_insert_simple.json
new file mode 100644
index 0000000..038e7f8
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_insert_simple.json
@@ -0,0 +1 @@
+{"name":"test-1","machineType":"https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1","serviceAccounts":[],"networkInterfaces":[{"network":"https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default","accessConfigs":[]}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_list.json
new file mode 100644
index 0000000..c8ed3be
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_list.json
@@ -0,0 +1,69 @@
+{
+ "kind": "compute#instanceList",
+ "id": "projects/myproject/zones/us-central1-a/instances",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances",
+ "items": [
+ {
+ "kind": "compute#instance",
+ "id": "13051190678907570425",
+ "description": "desc",
+ "creationTimestamp": "2012-11-25T23:48:20.758",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-0",
+ "name": "test-0",
+ "machineType": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1",
+ "status": "RUNNING",
+ "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a",
+ "networkInterfaces": [
+ {
+ "kind": "compute#instanceNetworkInterface",
+ "name": "nic0",
+ "networkIP": "10.240.121.115",
+ "network": "https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"
+ }
+ ],
+ "disks": [
+ {
+ "kind": "compute#instanceDisk",
+ "type": "PERSISTENT",
+ "mode": "READ_WRITE",
+ "deviceName": "test",
+ "source": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/test",
+ "index": 0,
+ "boot": true
+ }
+ ],
+ "serviceAccounts": [
+ {
+ "kind": "compute#serviceAccount",
+ "email": "default",
+ "scopes": [
+ "myscope"
+ ]
+ }
+ ],
+ "metadata": {
+ "items": [
+ {
+ "key": "aKey",
+ "value": "aValue"
+ },
+ {
+ "key": "jclouds-image",
+ "value": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140718"
+ },
+ {
+ "key": "jclouds-delete-boot-disk",
+ "value": "true"
+ }
+ ],
+ "fingerprint": "efgh"
+ },
+ "tags": {
+ "items": [
+ "aTag"
+ ],
+ "fingerprint": "abcd"
+ }
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_list_central1b_empty.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_list_central1b_empty.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_list_central1b_empty.json
new file mode 100644
index 0000000..51c8793
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_list_central1b_empty.json
@@ -0,0 +1,6 @@
+{
+ "kind": "compute#instanceList",
+ "id": "projects/myproject/zones/us-central1-b/instances",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-b/instances",
+ "items": [ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_serial_port.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_serial_port.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_serial_port.json
new file mode 100644
index 0000000..03280cc
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_serial_port.json
@@ -0,0 +1,4 @@
+{
+ "kind": "compute#serialPortOutput",
+ "contents": "console output"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_set_metadata.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_set_metadata.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_set_metadata.json
new file mode 100644
index 0000000..b39e983
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/instance_set_metadata.json
@@ -0,0 +1,10 @@
+{
+ "items": [
+ {
+ "key": "foo",
+ "value": "bar"
+ }
+ ],
+ "fingerprint": "efgh",
+ "kind": "compute#metadata"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/logback.xml b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/logback.xml
new file mode 100644
index 0000000..864a5a5
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/logback.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<configuration scan="false">
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>target/test-data/jclouds.log</file>
+
+ <encoder>
+ <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+ </encoder>
+ </appender>
+
+ <appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
+ <file>target/test-data/jclouds-wire.log</file>
+
+ <encoder>
+ <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+ </encoder>
+ </appender>
+
+ <appender name="COMPUTEFILE" class="ch.qos.logback.core.FileAppender">
+ <file>target/test-data/jclouds-compute.log</file>
+
+ <encoder>
+ <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+ </encoder>
+ </appender>
+
+ <appender name="SSHFILE" class="ch.qos.logback.core.FileAppender">
+ <file>target/test-data/jclouds-ssh.log</file>
+
+ <encoder>
+ <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root>
+ <level value="warn" />
+ </root>
+
+ <logger name="org.jclouds">
+ <level value="TRACE" />
+ <appender-ref ref="FILE" />
+ </logger>
+
+ <logger name="jclouds.wire">
+ <level value="TRACE" />
+ <appender-ref ref="WIREFILE" />
+ </logger>
+
+ <logger name="jclouds.headers">
+ <level value="TRACE" />
+ <appender-ref ref="WIREFILE" />
+ </logger>
+
+ <logger name="jclouds.compute">
+ <level value="TRACE" />
+ <appender-ref ref="COMPUTEFILE" />
+ </logger>
+
+ <logger name="jclouds.ssh">
+ <level value="TRACE" />
+ <appender-ref ref="SSHFILE" />
+ </logger>
+
+</configuration>
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype.json
new file mode 100644
index 0000000..f02f334
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype.json
@@ -0,0 +1,21 @@
+{
+ "kind": "compute#machineType",
+ "id": "12907738072351752276",
+ "creationTimestamp": "2012-06-07T20:48:14.670",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1",
+ "name": "n1-standard-1",
+ "description": "1 vCPU, 3.75 GB RAM, and a 10 GB ephemeral root disk",
+ "guestCpus": 1,
+ "memoryMb": 3840,
+ "scratchDisks": [
+ {
+ "diskGb": 1770
+ },
+ {
+ "diskGb": 1770
+ }
+ ],
+ "maximumPersistentDisks": 16,
+ "maximumPersistentDisksSizeGb": "128",
+ "zone": "us-central1-a"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype_list.json
new file mode 100644
index 0000000..cb20853
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype_list.json
@@ -0,0 +1,54 @@
+{
+ "kind": "compute#machineTypeList",
+ "id": "projects/myproject/machineTypes",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes",
+ "items": [
+ {
+ "kind": "compute#machineType",
+ "id": "4618642685664990776",
+ "creationTimestamp": "2013-04-25T13:32:49.088-07:00",
+ "name": "f1-micro",
+ "description": "1 vCPU (shared physical core) and 0.6 GB RAM",
+ "guestCpus": 1,
+ "memoryMb": 614,
+ "maximumPersistentDisks": 4,
+ "maximumPersistentDisksSizeGb": "3072",
+ "zone": "us-central1-a",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/f1-micro"
+ },
+ {
+ "kind": "compute#machineType",
+ "id": "12907738072351752276",
+ "creationTimestamp": "2012-06-07T20:48:14.670",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1",
+ "name": "n1-standard-1",
+ "description": "1 vCPU, 3.75 GB RAM, and a 10 GB ephemeral root disk",
+ "guestCpus": 1,
+ "memoryMb": 3840,
+ "maximumPersistentDisks": 16,
+ "maximumPersistentDisksSizeGb": "128",
+ "zone": "us-central1-a"
+ },
+ {
+ "kind": "compute#machineType",
+ "id": "12908560709887590691",
+ "creationTimestamp": "2012-06-07T20:51:19.936",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-8-d",
+ "name": "n1-standard-8-d",
+ "description": "8 vCPUs, 30 GB RAM, a 10 GB ephemeral root disk, and 2 extra 1770 GB ephemeral disks",
+ "guestCpus": 8,
+ "memoryMb": 30720,
+ "scratchDisks": [
+ {
+ "diskGb": 1770
+ },
+ {
+ "diskGb": 1770
+ }
+ ],
+ "maximumPersistentDisks": 16,
+ "maximumPersistentDisksSizeGb": "1024",
+ "zone": "us-central1-a"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype_list_central1b.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype_list_central1b.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype_list_central1b.json
new file mode 100644
index 0000000..8cbbc48
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype_list_central1b.json
@@ -0,0 +1,41 @@
+{
+ "kind": "compute#machineTypeList",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/abayer-jclouds-test1/zones/us-central1-b/machineTypes",
+ "id": "projects/abayer-jclouds-test1/zones/us-central1-b/machineTypes",
+ "items": [
+ {
+ "kind": "compute#machineType",
+ "id": "12907738072351752276",
+ "creationTimestamp": "2012-06-07T20:48:14.670",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-b/machineTypes/n1-standard-0",
+ "name": "n1-standard-0",
+ "description": "1 vCPU, 3.75 GB RAM, and a 10 GB ephemeral root disk",
+ "guestCpus": 1,
+ "memoryMb": 3840,
+ "maximumPersistentDisks": 16,
+ "maximumPersistentDisksSizeGb": "128",
+ "zone": "us-central1-b"
+ },
+ {
+ "kind": "compute#machineType",
+ "id": "12908560709887590691",
+ "creationTimestamp": "2012-06-07T20:51:19.936",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-b/machineTypes/n1-standard-8-d",
+ "name": "n1-standard-8-d",
+ "description": "8 vCPUs, 30 GB RAM, a 10 GB ephemeral root disk, and 2 extra 1770 GB ephemeral disks",
+ "guestCpus": 8,
+ "memoryMb": 30720,
+ "scratchDisks": [
+ {
+ "diskGb": 1770
+ },
+ {
+ "diskGb": 1770
+ }
+ ],
+ "maximumPersistentDisks": 16,
+ "maximumPersistentDisksSizeGb": "1024",
+ "zone": "us-central1-b"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype_list_central1b_empty.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype_list_central1b_empty.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype_list_central1b_empty.json
new file mode 100644
index 0000000..73fe582
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/machinetype_list_central1b_empty.json
@@ -0,0 +1,6 @@
+{
+ "kind": "compute#machineTypeList",
+ "id": "projects/myproject/zones/us-central1-b/machineTypes",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-b/machineTypes",
+ "items": []
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/metadata.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/metadata.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/metadata.json
new file mode 100644
index 0000000..5014270
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/metadata.json
@@ -0,0 +1 @@
+{"kind":"compute#metadata","items":[{"key":"propA","value":"valueA"},{"key":"propB","value":"valueB"}],"fingerprint":"efgh"}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/network_get.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/network_get.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/network_get.json
new file mode 100644
index 0000000..4a7a9cc
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/network_get.json
@@ -0,0 +1,10 @@
+{
+ "kind": "compute#network",
+ "id": "13024414170909937976",
+ "creationTimestamp": "2012-10-24T20:13:19.967",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/networks/jclouds-test",
+ "name": "default",
+ "description": "Default network for the project",
+ "IPv4Range": "10.0.0.0/8",
+ "gatewayIPv4": "10.0.0.1"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/network_insert.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/network_insert.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/network_insert.json
new file mode 100644
index 0000000..55e8331
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/network_insert.json
@@ -0,0 +1 @@
+{"name":"test-network","IPv4Range":"10.0.0.0/8"}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/network_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/network_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/network_list.json
new file mode 100644
index 0000000..1d15f6e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/network_list.json
@@ -0,0 +1,18 @@
+{
+ "kind": "compute#networkList",
+ "id": "projects/myproject/networks",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/networks",
+ "items": [
+ {
+
+ "kind": "compute#network",
+ "id": "13024414170909937976",
+ "creationTimestamp": "2012-10-24T20:13:19.967",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/networks/jclouds-test",
+ "name": "default",
+ "description": "Default network for the project",
+ "IPv4Range": "10.0.0.0/8",
+ "gatewayIPv4": "10.0.0.1"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/operation.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/operation.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/operation.json
new file mode 100644
index 0000000..7ca83c8
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/operation.json
@@ -0,0 +1,17 @@
+{
+ "kind": "compute#operation",
+ "id": "13053095055850848306",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "targetLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/instance-api-live-test-instance",
+ "targetId": "13053094017547040099",
+ "status": "DONE",
+ "user": "user@developer.gserviceaccount.com",
+ "progress": 100,
+ "insertTime": "2012-11-28T06:41:05.060",
+ "startTime": "2012-11-28T06:41:05.142",
+ "endTime": "2012-11-28T06:41:06.142",
+ "operationType": "insert",
+ "region": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1",
+ "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/operation_error.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/operation_error.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/operation_error.json
new file mode 100644
index 0000000..157f786
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/operation_error.json
@@ -0,0 +1,26 @@
+{
+ "kind": "compute#operation",
+ "id": "13053095055850848306",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "targetLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/instance-api-live-test-instance",
+ "targetId": "13053094017547040099",
+ "status": "DONE",
+ "user": "user@developer.gserviceaccount.com",
+ "progress": 100,
+ "insertTime": "2012-11-28T06:41:05.060",
+ "startTime": "2012-11-28T06:41:05.142",
+ "httpErrorStatusCode": 400,
+ "httpErrorMessage": "BAD REQUEST",
+ "error": {
+ "errors": [
+ {
+ "code": "RESOURCE_ALREADY_EXISTS",
+ "message": "The resource 'projects/myproject/zones/us-central1-a/instances/instance-api-live-test-instance' already exists"
+ }
+ ]
+ },
+ "operationType": "insert",
+ "region": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1",
+ "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/operation_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/operation_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/operation_list.json
new file mode 100644
index 0000000..c83980d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/operation_list.json
@@ -0,0 +1,24 @@
+{
+ "kind": "compute#operationList",
+ "id": "projects/myproject/operations",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/operations",
+ "items": [
+ {
+ "kind": "compute#operation",
+ "id": "13053095055850848306",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "targetLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/instance-api-live-test-instance",
+ "targetId": "13053094017547040099",
+ "status": "DONE",
+ "user": "user@developer.gserviceaccount.com",
+ "progress": 100,
+ "insertTime": "2012-11-28T06:41:05.060",
+ "startTime": "2012-11-28T06:41:05.142",
+ "endTime": "2012-11-28T06:41:06.142",
+ "operationType": "insert",
+ "region": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1",
+ "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/project.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/project.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/project.json
new file mode 100644
index 0000000..c195062
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/project.json
@@ -0,0 +1,69 @@
+{
+ "kind": "compute#project",
+ "id": "13024414184846275913",
+ "creationTimestamp": "2012-10-24T20:13:16.252",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject",
+ "name": "myproject",
+ "description": "",
+ "commonInstanceMetadata": {
+ "kind": "compute#metadata",
+ "items": [
+ {
+ "key": "propA",
+ "value": "valueA"
+ },
+ {
+ "key": "propB",
+ "value": "valueB"
+ }
+ ],
+ "fingerprint": "efgh"
+ },
+ "quotas": [
+ {
+ "metric": "INSTANCES",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "CPUS",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "EPHEMERAL_ADDRESSES",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "DISKS",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "DISKS_TOTAL_GB",
+ "usage": 0,
+ "limit": 100
+ },
+ {
+ "metric": "SNAPSHOTS",
+ "usage": 0,
+ "limit": 1000
+ },
+ {
+ "metric": "NETWORKS",
+ "usage": 1,
+ "limit": 5
+ },
+ {
+ "metric": "FIREWALLS",
+ "usage": 2,
+ "limit": 100
+ },
+ {
+ "metric": "IMAGES",
+ "usage": 0,
+ "limit": 100
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/quota.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/quota.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/quota.json
new file mode 100644
index 0000000..b631ab3
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/quota.json
@@ -0,0 +1,5 @@
+{
+ "metric": "INSTANCES",
+ "usage": 0,
+ "limit": 8
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_get.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_get.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_get.json
new file mode 100644
index 0000000..069865d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_get.json
@@ -0,0 +1,60 @@
+{
+ "kind": "compute#region",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1",
+ "id": "12912210600542709766",
+ "creationTimestamp": "2013-07-08T14:40:37.939-07:00",
+ "name": "us-central1",
+ "description": "us-central1",
+ "status": "UP",
+ "zones": [
+ "https://www.googleapis.com/compute/v1/zones/us-central1-a",
+ "https://www.googleapis.com/compute/v1/zones/us-central1-b"
+ ],
+ "quotas": [
+ {
+ "metric": "INSTANCES",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "CPUS",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "EPHEMERAL_ADDRESSES",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "DISKS",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "DISKS_TOTAL_GB",
+ "usage": 0,
+ "limit": 100
+ },
+ {
+ "metric": "SNAPSHOTS",
+ "usage": 0,
+ "limit": 1000
+ },
+ {
+ "metric": "NETWORKS",
+ "usage": 1,
+ "limit": 5
+ },
+ {
+ "metric": "FIREWALLS",
+ "usage": 2,
+ "limit": 100
+ },
+ {
+ "metric": "IMAGES",
+ "usage": 0,
+ "limit": 100
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_list.json
new file mode 100644
index 0000000..ae0673e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_list.json
@@ -0,0 +1,126 @@
+{
+ "kind": "compute#regionList",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions",
+ "id": "projects/myproject/regions",
+ "items": [
+ {
+ "kind": "compute#region",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1",
+ "id": "12912210600542709766",
+ "creationTimestamp": "2013-07-08T14:40:37.939-07:00",
+ "name": "us-central1",
+ "description": "us-central1",
+ "status": "UP",
+ "zones": [
+ "https://www.googleapis.com/compute/v1/zones/us-central1-a",
+ "https://www.googleapis.com/compute/v1/zones/us-central1-b"
+ ],
+ "quotas": [
+ {
+ "metric": "INSTANCES",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "CPUS",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "EPHEMERAL_ADDRESSES",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "DISKS",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "DISKS_TOTAL_GB",
+ "usage": 0,
+ "limit": 100
+ },
+ {
+ "metric": "SNAPSHOTS",
+ "usage": 0,
+ "limit": 1000
+ },
+ {
+ "metric": "NETWORKS",
+ "usage": 1,
+ "limit": 5
+ },
+ {
+ "metric": "FIREWALLS",
+ "usage": 2,
+ "limit": 100
+ },
+ {
+ "metric": "IMAGES",
+ "usage": 0,
+ "limit": 100
+ }
+ ]
+ },
+ {
+ "kind": "compute#region",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central2",
+ "id": "6396763663251190992",
+ "creationTimestamp": "2013-07-08T14:40:37.939-07:00",
+ "name": "us-central2",
+ "description": "us-central2",
+ "status": "UP",
+ "zones": [
+ "https://www.googleapis.com/compute/v1/zones/us-central2-a"
+ ],
+ "quotas": [
+ {
+ "metric": "INSTANCES",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "CPUS",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "EPHEMERAL_ADDRESSES",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "DISKS",
+ "usage": 0,
+ "limit": 8
+ },
+ {
+ "metric": "DISKS_TOTAL_GB",
+ "usage": 0,
+ "limit": 100
+ },
+ {
+ "metric": "SNAPSHOTS",
+ "usage": 0,
+ "limit": 1000
+ },
+ {
+ "metric": "NETWORKS",
+ "usage": 1,
+ "limit": 5
+ },
+ {
+ "metric": "FIREWALLS",
+ "usage": 2,
+ "limit": 100
+ },
+ {
+ "metric": "IMAGES",
+ "usage": 0,
+ "limit": 100
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_operation.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_operation.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_operation.json
new file mode 100644
index 0000000..67ac27d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_operation.json
@@ -0,0 +1,16 @@
+{
+ "kind": "compute#operation",
+ "id": "13053095055850848306",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "targetLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-address",
+ "targetId": "13053094017547040099",
+ "status": "DONE",
+ "user": "user@developer.gserviceaccount.com",
+ "progress": 100,
+ "insertTime": "2012-11-28T06:41:05.060",
+ "startTime": "2012-11-28T06:41:05.142",
+ "endTime": "2012-11-28T06:41:06.142",
+ "operationType": "insert",
+ "region": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_operation_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_operation_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_operation_list.json
new file mode 100644
index 0000000..8a6d619
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/region_operation_list.json
@@ -0,0 +1,23 @@
+{
+ "kind": "compute#operationList",
+ "id": "projects/myproject/regions/us-central1/operations",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/operations",
+ "items": [
+ {
+ "kind": "compute#operation",
+ "id": "13053095055850848306",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "targetLink": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-address",
+ "targetId": "13053094017547040099",
+ "status": "DONE",
+ "user": "user@developer.gserviceaccount.com",
+ "progress": 100,
+ "insertTime": "2012-11-28T06:41:05.060",
+ "startTime": "2012-11-28T06:41:05.142",
+ "endTime": "2012-11-28T06:41:06.142",
+ "operationType": "insert",
+ "region": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/route_get.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/route_get.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/route_get.json
new file mode 100644
index 0000000..be544f2
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/route_get.json
@@ -0,0 +1,14 @@
+{
+
+ "kind": "compute#route",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/routes/default-route-c99ebfbed0e1f375",
+ "id": "7241926205630356071",
+ "creationTimestamp": "2013-07-08T14:40:38.502-07:00",
+ "name": "default-route-c99ebfbed0e1f375",
+ "description": "Default route to the virtual network.",
+ "network": "https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default",
+ "destRange": "10.240.0.0/16",
+ "priority": 1000,
+ "nextHopNetwork": "https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default",
+ "tags": [ "fooTag", "barTag" ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/route_insert.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/route_insert.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/route_insert.json
new file mode 100644
index 0000000..68fff7d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/route_insert.json
@@ -0,0 +1 @@
+{"name":"default-route-c99ebfbed0e1f375","description":"Default route to the virtual network.","network":"https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default","destRange":"10.240.0.0/16","priority":1000,"nextHopNetwork":"https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default","tags":["fooTag","barTag"]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/route_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/route_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/route_list.json
new file mode 100644
index 0000000..5126ff1
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/route_list.json
@@ -0,0 +1,34 @@
+{
+ "kind": "compute#routeList",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/routes",
+ "id": "projects/myproject/global/routes",
+ "items": [
+ {
+
+ "kind": "compute#route",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/routes/default-route-c99ebfbed0e1f375",
+ "id": "7241926205630356071",
+ "creationTimestamp": "2013-07-08T14:40:38.502-07:00",
+ "name": "default-route-c99ebfbed0e1f375",
+ "description": "Default route to the virtual network.",
+ "network": "https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default",
+ "destRange": "10.240.0.0/16",
+ "priority": 1000,
+ "nextHopNetwork": "https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default",
+ "tags": [ "fooTag", "barTag" ]
+ },
+ {
+
+ "kind": "compute#route",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/routes/default-route-fc92a41ecb5a8d17",
+ "id": "507025480040058551",
+ "creationTimestamp": "2013-07-08T14:40:38.502-07:00",
+ "name": "default-route-fc92a41ecb5a8d17",
+ "description": "Default route to the Internet.",
+ "network": "https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default",
+ "destRange": "0.0.0.0/0",
+ "priority": 1000,
+ "nextHopGateway": "https://www.googleapis.com/compute/v1/projects/myproject/global/gateways/default-internet-gateway"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/snapshot_get.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/snapshot_get.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/snapshot_get.json
new file mode 100644
index 0000000..3ba287f
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/snapshot_get.json
@@ -0,0 +1,13 @@
+{
+
+ "kind": "compute#snapshot",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots/test-snap",
+ "id": "9734455566806191190",
+ "creationTimestamp": "2013-07-26T12:54:23.173-07:00",
+ "status": "READY",
+ "diskSizeGb": "10",
+ "sourceDisk": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1",
+ "name": "test-snap",
+ "description": "",
+ "sourceDiskId": "8243603669926824540"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/snapshot_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/snapshot_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/snapshot_list.json
new file mode 100644
index 0000000..431460f
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/snapshot_list.json
@@ -0,0 +1,33 @@
+{
+ "kind": "compute#snapshotList",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots",
+ "id": "projects/myproject/global/snapshots",
+ "items": [
+ {
+
+ "kind": "compute#snapshot",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots/test-snap",
+ "id": "9734455566806191190",
+ "creationTimestamp": "2013-07-26T12:54:23.173-07:00",
+ "status": "READY",
+ "diskSizeGb": "10",
+ "sourceDisk": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1",
+ "name": "test-snap",
+ "description": "",
+ "sourceDiskId": "8243603669926824540"
+ },
+ {
+
+ "kind": "compute#snapshot",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots/test-snap2",
+ "id": "13895715048576107883",
+ "creationTimestamp": "2013-07-26T12:57:01.927-07:00",
+ "status": "READY",
+ "diskSizeGb": "10",
+ "sourceDisk": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1",
+ "name": "test-snap2",
+ "description": "",
+ "sourceDiskId": "8243603669926824540"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/tag_insert.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/tag_insert.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/tag_insert.json
new file mode 100644
index 0000000..61ade71
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/tag_insert.json
@@ -0,0 +1 @@
+{"items":["aTag"],"fingerprint":"abcd"}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/testpk.pem
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/testpk.pem b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/testpk.pem
new file mode 100644
index 0000000..1443074
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/testpk.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXgIBAAKBgQCwqwzakEPP+U9vx9JCuMHebFIVQZ4Sjaj2RU9dJ6YT2s3u7dC6
+/0fGM5xm4fXmSHqyGC6PC8weQSkxnSpbU+R4jMWPM8ML4TIr5wP0avbg+wy3+WWI
+of0MN7YHkCfqpaaiKiMw7niK1y07YvxJN8LX1xLpE7aXgIpn6L/qtJdHnQIDAQAB
+AoGBAIAHlcsW3W3smPrC7sdXqXeNPHcXFH0RmC7Qz9EMmLiuyqqqQagitFsYr/GH
+M3Ltd611BNi5jfUm97ly0m1ZAKp/nkTMVhfKfRIVsBDHtjQHcUOR9tr0LslptmaN
+TG0bovbUohe5KwOqMK4YOjUQbInChVBrf7VrNQtv8e0eShdpAkEA3lzLP9QYfP1i
+C4iYXqS7cgMDrs3qujC7PoyB54maen+Uvgyau1ZJpKMzXYkORPcYk+b71bl9jF80
+U+7LDnJjPwJBAMtksvL1V8DC5DYL43497JW4KBN4YZ3K7YWx/9gkvc3Q9VdXiUGu
+6WKjmcbmsPI/jFdeO71uy934N8qEXLJcyiMCQQCTNKcxWD3l8PCJZiJI9ZFKBwjX
+Hmb4X+51mBsfpw7nbbKQplOBFbynC4ujrmoN6e8RaubpNGUTGqvPrNQsejmNAkEA
+lUDEAH4BczaQ+QgoXI9ceVG2NvNzzrMHMcC5Ggd8MPhR0VIvKsAMC5I6WjcXSe1Q
+Mxy3gf84Ix7u8fHHhCuLOQJAQRhrlXiQUk4cJumNhjza5/+KtaV4FPbEQi+qcWE6
+tGoHPEBfbXyUdcUD4ae8X1W0yri0BuyVNaOCpGCBRIhPZA==
+-----END RSA PRIVATE KEY-----
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/tokenResponse.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/tokenResponse.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/tokenResponse.json
new file mode 100644
index 0000000..6717a55
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/tokenResponse.json
@@ -0,0 +1,5 @@
+{
+ "access_token" : "1/8xbJqaOZXSUZbHLl5EOtu1pxz3fmmetKx9W8CV4t79M",
+ "token_type" : "Bearer",
+ "expires_in" : 3600
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_get.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_get.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_get.json
new file mode 100644
index 0000000..50cb375
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_get.json
@@ -0,0 +1,17 @@
+{
+ "kind": "compute#zone",
+ "id": "13020128040171887099",
+ "creationTimestamp": "2012-10-19T16:42:54.131",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a",
+ "name": "us-central1-a",
+ "description": "us-central1-a",
+ "status": "DOWN",
+ "maintenanceWindows": [
+ {
+ "name": "2012-11-10-planned-outage",
+ "description": "maintenance zone",
+ "beginTime": "2012-11-10T20:00:00.000",
+ "endTime": "2012-12-02T20:00:00.000"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_list.json
new file mode 100644
index 0000000..ee4e17b
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_list.json
@@ -0,0 +1,41 @@
+{
+ "kind": "compute#zoneList",
+ "id": "projects/myproject/zones",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones",
+ "items": [
+ {
+ "kind": "compute#zone",
+ "id": "13020128040171887099",
+ "creationTimestamp": "2012-10-19T16:42:54.131",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a",
+ "name": "us-central1-a",
+ "description": "us-central1-a",
+ "status": "DOWN",
+ "maintenanceWindows": [
+ {
+ "name": "2012-11-10-planned-outage",
+ "description": "maintenance zone",
+ "beginTime": "2012-11-10T20:00:00.000",
+ "endTime": "2012-12-02T20:00:00.000"
+ }
+ ]
+ },
+ {
+ "kind": "compute#zone",
+ "id": "13024414164050619686",
+ "creationTimestamp": "2012-10-24T20:13:19.271",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-b",
+ "name": "us-central1-b",
+ "description": "us-central1-b",
+ "status": "UP",
+ "maintenanceWindows": [
+ {
+ "name": "2013-02-17-planned-outage",
+ "description": "maintenance zone",
+ "beginTime": "2013-02-17T08:00:00.000",
+ "endTime": "2013-03-03T08:00:00.000"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_list_short.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_list_short.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_list_short.json
new file mode 100644
index 0000000..711af99
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_list_short.json
@@ -0,0 +1,24 @@
+{
+ "kind": "compute#zoneList",
+ "id": "projects/myproject/zones",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones",
+ "items": [
+ {
+ "kind": "compute#zone",
+ "id": "13020128040171887099",
+ "creationTimestamp": "2012-10-19T16:42:54.131",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a",
+ "name": "us-central1-a",
+ "description": "us-central1-a",
+ "status": "DOWN",
+ "maintenanceWindows": [
+ {
+ "name": "2012-11-10-planned-outage",
+ "description": "maintenance zone",
+ "beginTime": "2012-11-10T20:00:00.000",
+ "endTime": "2012-12-02T20:00:00.000"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_operation.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_operation.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_operation.json
new file mode 100644
index 0000000..c0c5b56
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_operation.json
@@ -0,0 +1,16 @@
+{
+ "kind": "compute#operation",
+ "id": "13053095055850848306",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "targetLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/instance-api-live-test-instance",
+ "targetId": "13053094017547040099",
+ "status": "DONE",
+ "user": "user@developer.gserviceaccount.com",
+ "progress": 100,
+ "insertTime": "2012-11-28T06:41:05.060",
+ "startTime": "2012-11-28T06:41:05.142",
+ "endTime": "2012-11-28T06:41:06.142",
+ "operationType": "insert",
+ "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_operation_error.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_operation_error.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_operation_error.json
new file mode 100644
index 0000000..d6d054a
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_operation_error.json
@@ -0,0 +1,25 @@
+{
+ "kind": "compute#operation",
+ "id": "13053095055850848306",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "targetLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/instance-api-live-test-instance",
+ "targetId": "13053094017547040099",
+ "status": "DONE",
+ "user": "user@developer.gserviceaccount.com",
+ "progress": 100,
+ "insertTime": "2012-11-28T06:41:05.060",
+ "startTime": "2012-11-28T06:41:05.142",
+ "httpErrorStatusCode": 400,
+ "httpErrorMessage": "BAD REQUEST",
+ "error": {
+ "errors": [
+ {
+ "code": "RESOURCE_ALREADY_EXISTS",
+ "message": "The resource 'projects/myproject/zones/us-central1-a/instances/instance-api-live-test-instance' already exists"
+ }
+ ]
+ },
+ "operationType": "insert",
+ "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_operation_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_operation_list.json b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_operation_list.json
new file mode 100644
index 0000000..77f1656
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/resources/zone_operation_list.json
@@ -0,0 +1,23 @@
+{
+ "kind": "compute#operationList",
+ "id": "projects/myproject/zones/us-central1-a/operations",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/operations",
+ "items": [
+ {
+ "kind": "compute#operation",
+ "id": "13053095055850848306",
+ "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb",
+ "targetLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/instance-api-live-test-instance",
+ "targetId": "13053094017547040099",
+ "status": "DONE",
+ "user": "user@developer.gserviceaccount.com",
+ "progress": 100,
+ "insertTime": "2012-11-28T06:41:05.060",
+ "startTime": "2012-11-28T06:41:05.142",
+ "endTime": "2012-11-28T06:41:06.142",
+ "operationType": "insert",
+ "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/README.md
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/README.md b/dependencies/jclouds/apis/gce/README.md
new file mode 100644
index 0000000..feadecc
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/README.md
@@ -0,0 +1,87 @@
+Why oauth & google-compute-engine forked?
+=========================================
+
+This code in Stratos is copied from Jclouds GCE [1]
+The jclouds GCE code has 2 directories oauth & google-compute-engine
+In Stratos, these two directories are mered into one.
+
+[1] https://github.com/jclouds/jclouds-labs-google/tree/jclouds-labs-google-1.8.1
+
+Custom changes
+==============
+
+1) rawDisk can be null for user created private images, hence changing the validation
+
+
+diff --git a/home/rajkumar/workspace/apache/jclouds-labs/jclouds-labs-google-jclouds-labs-google-1.8.1/google-compute-engine/src/main/java/org
+index 9ee7ea9..424aaa1 100644
+--- a/home/rajkumar/workspace/apache/jclouds-labs/jclouds-labs-google-jclouds-labs-google-1.8.1/google-compute-engine/src/main/java/org/jcloud
++++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Image.java
+@@ -49,7 +49,8 @@ public final class Image extends Resource {
+ String sourceType, RawDisk rawDisk, Deprecated deprecated) {
+ super(Kind.IMAGE, id, creationTimestamp, selfLink, name, description);
+ this.sourceType = checkNotNull(sourceType, "sourceType of %s", name);
+- this.rawDisk = checkNotNull(rawDisk, "rawDisk of %s", name);
++ // rawDisk may be null for user created private images
++ this.rawDisk = rawDisk; // checkNotNull(rawDisk, "rawDisk of %s", name);
+ this.deprecated = fromNullable(deprecated);
+ }
+
+2) merging google-compute-engine/pom.xml and oauth/pom.xml
+
+diff --git a/home/rajkumar/workspace/apache/jclouds-labs/jclouds-labs-google-jclouds-labs-google-1.8.1/google-compute-engine/pom.xml b/dependencies/jclouds/apis/gce/1.8.1-stratos/pom.xml
+index c1231f1..34f8bc7 100644
+--- a/home/rajkumar/workspace/apache/jclouds-labs/jclouds-labs-google-jclouds-labs-google-1.8.1/google-compute-engine/pom.xml
++++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/pom.xml
+@@ -26,12 +26,15 @@
+ </parent>
+
+ <!-- TODO: when out of labs, switch to org.jclouds.provider -->
+- <groupId>org.apache.jclouds.labs</groupId>
+- <artifactId>google-compute-engine</artifactId>
++ <groupId>org.apache.stratos</groupId>
++ <artifactId>gce</artifactId>
++ <version>1.8.1-stratos</version>
+ <name>jclouds Google Compute Engine provider</name>
+ <description>jclouds components to access GoogleCompute</description>
++ <packaging>bundle</packaging>
+
+ <properties>
++ <jclouds.version>1.8.1</jclouds.version>
+ <test.google-compute-engine.identity>Email associated with the Google API client_id
+ </test.google-compute-engine.identity>
+ <test.google-compute-engine.credential>Private key (PKCS12 file) associated with the Google API client_id
+@@ -39,6 +42,13 @@
+ <test.google-compute-engine.api-version>v1</test.google-compute-engine.api-version>
+ <test.google-compute-engine.build-version />
+ <test.google-compute-engine.template>imageId=debian-7-wheezy-v20131120,locationId=us-central1-a,minRam=2048</test.google-compute-engine.template>
++ <jclouds.osgi.export>org.jclouds.googlecomputeengine*;version="${project.version}"</jclouds.osgi.export>
++ <jclouds.osgi.import>
++ org.jclouds.compute.internal;version="${jclouds.version}",
++ org.jclouds.rest.internal;version="${jclouds.version}",
++ org.jclouds*;version="${jclouds.version}",
++ *
++ </jclouds.osgi.import>
+ </properties>
+
+ <dependencies>
+@@ -48,19 +58,6 @@
+ <version>${jclouds.version}</version>
+ </dependency>
+ <dependency>
+- <groupId>org.apache.jclouds.labs</groupId>
+- <artifactId>oauth</artifactId>
+- <version>${project.version}</version>
+- <type>jar</type>
+- </dependency>
+- <dependency>
+- <groupId>org.apache.jclouds.labs</groupId>
+- <artifactId>oauth</artifactId>
+- <version>${project.version}</version>
+- <type>test-jar</type>
+- <scope>test</scope>
+- </dependency>
+- <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-compute</artifactId>
+ <version>${jclouds.version}</version>
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/README.md
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/README.md b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/README.md
new file mode 100644
index 0000000..b3a1c1a
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/README.md
@@ -0,0 +1,7 @@
+OpenStack Neutron
+=================
+
+Neutron is a virtual network service for Openstack.
+
+Production ready?
+Yes
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/pom.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/pom.xml b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/pom.xml
new file mode 100644
index 0000000..675323a
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/pom.xml
@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-project</artifactId>
+ <version>1.8.1</version>
+ </parent>
+
+ <!-- TODO: when out of labs, switch to org.jclouds.api -->
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>openstack-neutron</artifactId>
+ <version>1.8.1-stratosv1</version>
+ <name>jclouds openstack-neutron api</name>
+ <description>jclouds components to access an implementation of OpenStack Neutron</description>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <jclouds.version>1.8.1</jclouds.version>
+ <!-- keystone endpoint -->
+ <test.openstack-neutron.endpoint>http://localhost:5000/v2.0/</test.openstack-neutron.endpoint>
+ <!-- keystone version -->
+ <test.openstack-neutron.api-version>2.0</test.openstack-neutron.api-version>
+ <test.openstack-neutron.build-version/>
+ <test.openstack-neutron.identity>FIXME_IDENTITY</test.openstack-neutron.identity>
+ <test.openstack-neutron.credential>FIXME_CREDENTIALS</test.openstack-neutron.credential>
+ <test.jclouds.keystone.credential-type>passwordCredentials</test.jclouds.keystone.credential-type>
+ <jclouds.osgi.export>org.jclouds.openstack.neutron.v2*;version="${project.version}"</jclouds.osgi.export>
+ <jclouds.osgi.import>org.jclouds*;version="${jclouds.version}",*</jclouds.osgi.import>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>apache-snapshots</id>
+ <url>https://repository.apache.org/content/repositories/snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <!-- For modernizer, which depends on jclouds-resources snapshot. -->
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-snapshots</id>
+ <url>https://repository.apache.org/content/repositories/snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.jclouds.api</groupId>
+ <artifactId>openstack-keystone</artifactId>
+ <version>${jclouds.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-core</artifactId>
+ <version>${jclouds.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-core</artifactId>
+ <version>${jclouds.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds.api</groupId>
+ <artifactId>openstack-keystone</artifactId>
+ <version>${jclouds.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-slf4j</artifactId>
+ <version>${jclouds.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp</groupId>
+ <artifactId>mockwebserver</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>live</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>integration</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+ <test.openstack-neutron.endpoint>${test.openstack-neutron.endpoint}
+ </test.openstack-neutron.endpoint>
+ <test.openstack-neutron.api-version>${test.openstack-neutron.api-version}
+ </test.openstack-neutron.api-version>
+ <test.openstack-neutron.build-version>${test.openstack-neutron.build-version}
+ </test.openstack-neutron.build-version>
+ <test.openstack-neutron.identity>${test.openstack-neutron.identity}
+ </test.openstack-neutron.identity>
+ <test.openstack-neutron.credential>${test.openstack-neutron.credential}
+ </test.openstack-neutron.credential>
+ <test.jclouds.keystone.credential-type>
+ ${test.jclouds.keystone.credential-type}
+ </test.jclouds.keystone.credential-type>
+ </systemPropertyVariables>
+ <parallel>classes</parallel>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java
new file mode 100644
index 0000000..983fe94
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2;
+
+import java.io.Closeable;
+import java.util.Set;
+
+import javax.ws.rs.Path;
+
+import org.jclouds.Constants;
+import org.jclouds.location.Region;
+import org.jclouds.location.functions.RegionToEndpoint;
+import org.jclouds.openstack.neutron.v2.extensions.FloatingIPApi;
+import org.jclouds.openstack.neutron.v2.extensions.RouterApi;
+import org.jclouds.openstack.neutron.v2.extensions.SecurityGroupApi;
+import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi;
+import org.jclouds.openstack.neutron.v2.features.NetworkApi;
+import org.jclouds.openstack.neutron.v2.features.PortApi;
+import org.jclouds.openstack.neutron.v2.features.SubnetApi;
+import org.jclouds.openstack.v2_0.features.ExtensionApi;
+import org.jclouds.rest.annotations.Delegate;
+import org.jclouds.rest.annotations.EndpointParam;
+
+import com.google.common.base.Optional;
+import com.google.inject.Provides;
+
+/**
+ * Provides access to the OpenStack Networking (Neutron) v2 API.
+ */
+@Path("{" + Constants.PROPERTY_API_VERSION + "}")
+public interface NeutronApi extends Closeable {
+ /**
+ * @return the Region codes configured
+ */
+ @Provides
+ @Region
+ Set<String> getConfiguredRegions();
+
+ /**
+ * Provides access to Extension features.
+ */
+ @Delegate
+ ExtensionApi getExtensionApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+
+ /**
+ * Provides access to Network features.
+ */
+ @Delegate
+ NetworkApi getNetworkApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+
+ /**
+ * Provides access to Subnet features.
+ */
+ @Delegate
+ SubnetApi getSubnetApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+
+ /**
+ * Provides access to Port features.
+ */
+ @Delegate
+ PortApi getPortApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+
+ /**
+ * Provides access to Router features.
+ *
+ * <h3>NOTE</h3>
+ * This API is an extension that may or may not be present in your OpenStack cloud. Use the Optional return type
+ * to determine if it is present.
+ */
+ @Delegate
+ Optional<RouterApi> getRouterApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+
+ /**
+ * Provides access to Floating IP features.
+ *
+ * <h3>NOTE</h3>
+ * This API is an extension that may or may not be present in your OpenStack cloud. Use the Optional return type
+ * to determine if it is present.
+ */
+ @Delegate
+ Optional<FloatingIPApi> getFloatingIPApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+
+ /**
+ * Provides access to SecurityGroup features.
+ *
+ * <h3>NOTE</h3>
+ * This API is an extension that may or may not be present in your OpenStack cloud. Use the Optional return type
+ * to determine if it is present.
+ */
+ @Delegate
+ Optional<SecurityGroupApi> getSecurityGroupApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+
+ /**
+ * Provides access to LBaaS features.
+ *
+ * <h3>NOTE</h3>
+ * This API is an extension that may or may not be present in your OpenStack cloud. Use the Optional return type
+ * to determine if it is present.
+ */
+ @Delegate
+ Optional<LBaaSApi> getLBaaSApi(@EndpointParam(parser = RegionToEndpoint.class) String region);
+}
[50/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/ec2/EC2Iaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/ec2/EC2Iaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/ec2/EC2Iaas.java
index ccd6d58..0ef92f4 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/ec2/EC2Iaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/ec2/EC2Iaas.java
@@ -97,7 +97,7 @@ public class EC2Iaas extends JcloudsIaas {
if (location.getScope().toString().equalsIgnoreCase(CloudControllerConstants.ZONE_ELEMENT) &&
location.getId().equals(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE))) {
templateBuilder.locationId(location.getId());
- log.info("zone has been set as " + iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE)
+ log.info("ZONE has been set as " + iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE)
+ " with id: " + location.getId());
break;
}
@@ -114,7 +114,7 @@ public class EC2Iaas extends JcloudsIaas {
if (iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) != null) {
if (!template.getLocation().getId().equals(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE))) {
- log.warn("couldn't find assignable zone of id :" +
+ log.warn("couldn't find assignable ZONE of id :" +
iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) + " in the IaaS. " +
"Hence using the default location as " + template.getLocation().getScope().toString() +
" with the id " + template.getLocation().getId());
@@ -374,7 +374,7 @@ public class EC2Iaas extends JcloudsIaas {
if (region == null || iaasInfo == null) {
String msg =
- "Region or IaaSProvider is null. [region] " + region + ", [IaaSProvider] " +
+ "Region or IaaSProvider is null: region: " + region + " - IaaSProvider: " +
iaasInfo;
log.error(msg);
throw new InvalidRegionException(msg);
@@ -402,7 +402,7 @@ public class EC2Iaas extends JcloudsIaas {
if (zone == null || iaasInfo == null) {
String msg =
- "Zone or IaaSProvider is null. [zone] " + zone + ", [IaaSProvider] " +
+ "Zone or IaaSProvider is null: zone: " + zone + " - IaaSProvider: " +
iaasInfo;
log.error(msg);
throw new InvalidZoneException(msg);
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/ec2/EC2PartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/ec2/EC2PartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/ec2/EC2PartitionValidator.java
index 8fbeabc..03f57df 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/ec2/EC2PartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/ec2/EC2PartitionValidator.java
@@ -28,7 +28,7 @@ import org.apache.stratos.cloud.controller.iaases.Iaas;
import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
import org.apache.stratos.cloud.controller.services.impl.CloudControllerServiceUtil;
import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
-import org.apache.stratos.cloud.controller.util.Scope;
+import org.apache.stratos.messaging.domain.topology.Scope;
import java.util.Properties;
@@ -46,13 +46,13 @@ public class EC2PartitionValidator implements PartitionValidator {
public IaasProvider validate(Partition partition, Properties properties) throws InvalidPartitionException {
// validate the existence of the region and zone properties.
try {
- if (properties.containsKey(Scope.REGION.toString())) {
- String region = properties.getProperty(Scope.REGION.toString());
+ if (properties.containsKey(Scope.region.toString())) {
+ String region = properties.getProperty(Scope.region.toString());
if (iaasProvider.getImage() != null && !iaasProvider.getImage().contains(region)) {
- String message = "Invalid partition detected, invalid region. [partition-id] " + partition.getId() +
- ", [region] " + region;
+ String message = "Invalid partition detected, invalid region: [partition-id] " + partition.getId() +
+ " [region] " + region;
log.error(message);
throw new InvalidPartitionException(message);
}
@@ -63,8 +63,8 @@ public class EC2PartitionValidator implements PartitionValidator {
Iaas updatedIaas = CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
updatedIaas.setIaasProvider(updatedIaasProvider);
- if (properties.containsKey(Scope.ZONE.toString())) {
- String zone = properties.getProperty(Scope.ZONE.toString());
+ if (properties.containsKey(Scope.zone.toString())) {
+ String zone = properties.getProperty(Scope.zone.toString());
iaas.isValidZone(region, zone);
updatedIaasProvider.setProperty(CloudControllerConstants.AVAILABILITY_ZONE, zone);
updatedIaas = CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
@@ -80,6 +80,7 @@ public class EC2PartitionValidator implements PartitionValidator {
}
} catch (Exception ex) {
String message = "Invalid partition detected: [partition-id] " + partition.getId();
+ log.error(message, ex);
throw new InvalidPartitionException(message, ex);
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/gce/GCEIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/gce/GCEIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/gce/GCEIaas.java
index 141e266..975fe0c 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/gce/GCEIaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/gce/GCEIaas.java
@@ -37,23 +37,23 @@ import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
import org.apache.stratos.cloud.controller.util.ComputeServiceBuilderUtil;
import org.jclouds.ContextBuilder;
+import org.jclouds.collect.IterableWithMarker;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.domain.Location;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.compute.options.GoogleComputeEngineTemplateOptions;
-import org.jclouds.googlecomputeengine.domain.AttachDisk;
-import org.jclouds.googlecomputeengine.domain.Disk;
-import org.jclouds.googlecomputeengine.domain.Instance;
-import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.*;
import org.jclouds.googlecomputeengine.features.DiskApi;
import org.jclouds.googlecomputeengine.features.InstanceApi;
-import org.jclouds.googlecomputeengine.options.DiskCreationOptions;
+import org.jclouds.googlecomputeengine.features.RegionApi;
+import org.jclouds.googlecomputeengine.features.ZoneApi;
+import org.jclouds.googlecomputeengine.options.AttachDiskOptions;
+import org.jclouds.googlecomputeengine.options.AttachDiskOptions.DiskType;
-import java.net.URI;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
@@ -61,8 +61,11 @@ import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jclouds.util.Predicates2.retry;
public class GCEIaas extends JcloudsIaas {
+
+
private static final Log log = LogFactory.getLog(GCEIaas.class);
- public static final int MAX_WAIT_TIME = 60; // seconds
+
+ private static final String PROJECTNAME = "projectName";
public GCEIaas(IaasProvider iaasProvider) {
super(iaasProvider);
@@ -88,10 +91,10 @@ public class GCEIaas extends JcloudsIaas {
throw new CloudControllerException(msg);
}
- if (log.isDebugEnabled()) {
- log.debug("Building template for Google Compute Engine IaaS");
- }
- TemplateBuilder templateBuilder = iaasInfo.getComputeService().templateBuilder();
+ log.info("gce buildTemplate");
+
+ TemplateBuilder templateBuilder = iaasInfo.getComputeService()
+ .templateBuilder();
// set image id specified
templateBuilder.imageId(iaasInfo.getImage());
@@ -103,7 +106,7 @@ public class GCEIaas extends JcloudsIaas {
if (location.getScope().toString().equalsIgnoreCase(CloudControllerConstants.ZONE_ELEMENT) &&
location.getId().equals(zone)) {
templateBuilder.locationId(location.getId());
- log.info("zone has been set as " + zone
+ log.info("ZONE has been set as " + zone
+ " with id: " + location.getId());
break;
}
@@ -114,14 +117,14 @@ public class GCEIaas extends JcloudsIaas {
// set instance type eg: m1.large
templateBuilder.hardwareId(iaasInfo.getProperty(CloudControllerConstants.INSTANCE_TYPE));
}
+
// build the Template
Template template = templateBuilder.build();
if (zone != null) {
if (!template.getLocation().getId().equals(zone)) {
- log.warn("couldn't find assignable zone of id :" + zone +
- " in the IaaS. Hence using the default location as " +
- template.getLocation().getScope().toString() +
+ log.warn("couldn't find assignable ZONE of id :" + zone +
+ " in the IaaS. Hence using the default location as " + template.getLocation().getScope().toString() +
" with the id " + template.getLocation().getId());
}
}
@@ -131,11 +134,15 @@ public class GCEIaas extends JcloudsIaas {
// wish to assign IPs manually, it can be non-blocking.
// is auto-assign-ip mode or manual-assign-ip mode? - default mode is
// non-blocking
- boolean blockUntilRunning = Boolean.parseBoolean(iaasInfo.getProperty("autoAssignIp"));
- template.getOptions().as(GoogleComputeEngineTemplateOptions.class).blockUntilRunning(blockUntilRunning);
+ boolean blockUntilRunning = Boolean.parseBoolean(iaasInfo
+ .getProperty("autoAssignIp"));
+ template.getOptions().as(TemplateOptions.class)
+ .blockUntilRunning(blockUntilRunning);
- // this is required in order to avoid creation of additional security groups by Jclouds.
- template.getOptions().as(GoogleComputeEngineTemplateOptions.class).inboundPorts(22, 80, 8080, 443, 8243);
+ // this is required in order to avoid creation of additional security
+ // groups by Jclouds.
+ template.getOptions().as(TemplateOptions.class)
+ .inboundPorts(22, 80, 8080, 443, 8243);
if (zone != null) {
templateBuilder.locationId(zone);
@@ -147,9 +154,8 @@ public class GCEIaas extends JcloudsIaas {
for (String propertyKey : iaasInfo.getProperties().keySet()) {
if (propertyKey.startsWith(CloudControllerConstants.TAGS_AS_KEY_VALUE_PAIRS_PREFIX)) {
- keyValuePairTagsMap
- .put(propertyKey.substring(CloudControllerConstants.TAGS_AS_KEY_VALUE_PAIRS_PREFIX.length()),
- iaasInfo.getProperties().get(propertyKey));
+ keyValuePairTagsMap.put(propertyKey.substring(CloudControllerConstants.TAGS_AS_KEY_VALUE_PAIRS_PREFIX.length()),
+ iaasInfo.getProperties().get(propertyKey));
template.getOptions()
.userMetadata(keyValuePairTagsMap);
}
@@ -162,7 +168,7 @@ public class GCEIaas extends JcloudsIaas {
networks.add(ni.getNetworkUuid());
log.info("using network interface " + ni.getNetworkUuid());
}
- template.getOptions().as(GoogleComputeEngineTemplateOptions.class).networks(networks);
+ template.getOptions().as(TemplateOptions.class).networks(networks);
log.info("using network interface " + networks);
}
@@ -220,15 +226,25 @@ public class GCEIaas extends JcloudsIaas {
@Override
public boolean isValidRegion(String region) throws InvalidRegionException {
IaasProvider iaasInfo = getIaasProvider();
+
if (region == null || iaasInfo == null) {
String msg = "Region or IaaSProvider is null: region: " + region + " - IaaSProvider: " + iaasInfo;
log.error(msg);
throw new InvalidRegionException(msg);
}
+
GoogleComputeEngineApi api = getGCEApi();
- if (api.regions().get(region) != null) {
- return true;
+ RegionApi regionApi = api.getRegionApiForProject(iaasInfo.getProperty(PROJECTNAME));
+
+ for (IterableWithMarker<Region> page : regionApi.list()) {
+ for (Region r : page) {
+ if (region.equalsIgnoreCase(r.getName())) {
+ log.debug("Found a matching region: " + region);
+ return true;
+ }
+ }
}
+
String msg = "Invalid region: " + region + " in the iaas: " + iaasInfo.getType();
log.error(msg);
throw new InvalidRegionException(msg);
@@ -239,16 +255,24 @@ public class GCEIaas extends JcloudsIaas {
IaasProvider iaasInfo = getIaasProvider();
if (zone == null || iaasInfo == null) {
- String msg = "Zone or IaaSProvider is null. [region] " + region + ", [zone] " + zone + ", [IaaSProvider] "
- + iaasInfo;
+ String msg = "Zone or IaaSProvider is null: region: " + region +
+ " zone: " + zone + " - IaaSProvider: " + iaasInfo;
log.error(msg);
throw new InvalidZoneException(msg);
}
GoogleComputeEngineApi api = getGCEApi();
- if (api.zones().get(zone) != null) {
- return true;
+ ZoneApi zoneApi = api.getZoneApiForProject(iaasInfo.getProperty(PROJECTNAME));
+
+ for (IterableWithMarker<Zone> page : zoneApi.list()) {
+ for (Zone z : page) {
+ if (zone.equalsIgnoreCase(z.getName())) {
+ log.debug("Found a matching zone: " + zone);
+ return true;
+ }
+ }
}
+
String msg = "Invalid zone: " + zone + " in the region: " + region + " and of the iaas: " + iaasInfo.getType();
log.error(msg);
throw new InvalidZoneException(msg);
@@ -278,23 +302,19 @@ public class GCEIaas extends JcloudsIaas {
String diskName = "stratos-disk-" + rand.nextInt(100000);
DiskApi diskApi = getGCEDiskApi();
String zone = getZone();
- log.info("Creating volume: " + diskName + " in zone: " + zone + " of size: " + sizeGB);
- try {
- DiskCreationOptions diskCreationOptions = new DiskCreationOptions.Builder().sizeGb(sizeGB).sourceSnapshot
- (new URI(snapshotId)).build();
- Operation oper = diskApi.create(diskName, diskCreationOptions);
- oper = waitGCEOperationDone(oper);
- if (!oper.status().equals(Operation.Status.DONE)) {
- log.error("Failed to create volume: " + diskName + " of size: " + sizeGB +
- " in zone: " + zone + " operation: " + oper);
- return null;
- }
- return diskName;
- }
- catch (Exception e) {
- log.error("Error creating volume", e);
+
+ log.debug("Creating volume: " + diskName + " in zone: " + zone + " of size: " + sizeGB);
+
+ Operation oper = diskApi.createInZone(diskName, sizeGB, zone);
+
+ oper = waitGCEOperationDone(oper);
+ if (oper.getStatus() != Operation.Status.DONE) {
+ log.error("Failed to create volume: " + diskName + " of size: " + sizeGB +
+ " in zone: " + zone + " operation: " + oper);
+ return null;
}
- return null;
+
+ return diskName;
}
@Override
@@ -303,55 +323,64 @@ public class GCEIaas extends JcloudsIaas {
InstanceApi instApi = getGCEInstanceApi();
String zone = getZone();
- log.info("Trying to attach volume: " + volumeId + " to instance: " + instanceId +
+ log.debug("Trying to attach volume: " + volumeId + " to instance: " + instanceId +
" in zone: " + zone + " at devicename: " + deviceName);
- Disk disk = diskApi.get(volumeId);
+ Disk disk = diskApi.getInZone(zone, volumeId);
if (disk == null) {
log.error("Failed to get volume: " + volumeId + " in zone: " + zone);
return null;
}
+
log.debug("Found volumeId: " + volumeId + " volume: " + disk);
- try {
- Operation oper =
- instApi.attachDisk(instanceId, AttachDisk.create(AttachDisk.Type.PERSISTENT, AttachDisk.Mode
- .READ_WRITE, disk.selfLink(), deviceName, true, null, false, null, null));
- oper = waitGCEOperationDone(oper);
- if (!oper.status().equals(Operation.Status.DONE)) {
- log.error("Failed to attach volume: " + volumeId + " to instance: " + instanceId +
- " in zone: " + zone + " at device: " + deviceName + " operation: " + oper);
- return null;
- }
- return volumeId;
- }
- catch (Exception e) {
- log.error("Error attaching volume", e);
+
+ Operation oper = instApi.attachDiskInZone(zone, instanceId,
+ new AttachDiskOptions().type(DiskType.PERSISTENT)
+ .source(disk.getSelfLink())
+ .mode(AttachDiskOptions.DiskMode.READ_WRITE)
+ .deviceName(deviceName));
+ oper = waitGCEOperationDone(oper);
+ if (oper.getStatus() != Operation.Status.DONE) {
+ log.error("Failed to attach volume: " + volumeId + " to instance: " + instanceId +
+ " in zone: " + zone + " at device: " + deviceName + " operation: " + oper);
+ return null;
}
- return null;
+
+ return volumeId;
}
@Override
public void detachVolume(String instanceId, String volumeId) {
InstanceApi instApi = getGCEInstanceApi();
String zone = getZone();
- Instance inst = instApi.get(instanceId);
- log.info("Trying to detach volume: " + volumeId + " from instance: " + instanceId + " in zone: " + zone);
+ Instance inst = instApi.getInZone(zone, instanceId);
+
+ log.debug("Trying to detach volume: " + volumeId + " from instance: " + instanceId +
+ " " + inst + " in zone: " + zone);
+
if (inst == null) {
log.error("Failed to find instance: " + instanceId + " in zone: " + zone);
return;
}
- for (Instance.AttachedDisk disk : inst.disks()) {
- if (disk.deviceName().equals(volumeId)) {
- log.info("Found disk to be detached. Source: " + disk.source() + " devicename: " + disk.deviceName());
- Operation oper = instApi.detachDisk(instanceId, disk.deviceName());
+
+ for (Instance.AttachedDisk disk : inst.getDisks()) {
+ Instance.PersistentAttachedDisk persistentDisk = (Instance.PersistentAttachedDisk) disk;
+
+ log.debug("Found disk - src: " + persistentDisk.getSourceDiskName() +
+ " devicename: " + persistentDisk.getDeviceName());
+
+ if (persistentDisk.getSourceDiskName().equals(volumeId)) {
+ Operation oper = instApi.detachDiskInZone(zone, instanceId, persistentDisk.getDeviceName().get());
oper = waitGCEOperationDone(oper);
- if (!oper.status().equals(Operation.Status.DONE)) {
+ if (oper.getStatus() != Operation.Status.DONE) {
log.error("Failed to detach volume: " + volumeId + " to instance: " + instanceId +
- " in zone: " + zone + " at device: " + disk.deviceName() + " result operation: " + oper);
+ " in zone: " + zone + " at device: " + persistentDisk.getDeviceName() +
+ " result operation: " + oper);
}
return;
}
}
+
log.error("Cannot find volume: " + volumeId + " in instance: " + instanceId);
}
@@ -359,11 +388,13 @@ public class GCEIaas extends JcloudsIaas {
public void deleteVolume(String volumeId) {
DiskApi diskApi = getGCEDiskApi();
String zone = getZone();
- log.info("Deleting volume: " + volumeId + " in zone: " + zone);
- Operation oper = diskApi.delete(volumeId);
+
+ log.debug("Deleting volume: " + volumeId + " in zone: " + zone);
+
+ Operation oper = diskApi.deleteInZone(zone, volumeId);
oper = waitGCEOperationDone(oper);
- if (!oper.status().equals(Operation.Status.DONE)) {
+ if (oper.getStatus() != Operation.Status.DONE) {
log.error("Failed to delete volume: " + volumeId + " in zone: " + zone +
" operation: " + oper);
}
@@ -388,14 +419,19 @@ public class GCEIaas extends JcloudsIaas {
}
private DiskApi getGCEDiskApi() {
- return getGCEApi().disksInZone(getZone());
+ IaasProvider iaasInfo = getIaasProvider();
+ String projectName = iaasInfo.getProperty(PROJECTNAME);
+ return getGCEApi().getDiskApiForProject(projectName);
}
private InstanceApi getGCEInstanceApi() {
- return getGCEApi().instancesInZone(getZone());
+ IaasProvider iaasInfo = getIaasProvider();
+ String projectName = iaasInfo.getProperty(PROJECTNAME);
+ return getGCEApi().getInstanceApiForProject(projectName);
}
private Operation waitGCEOperationDone(Operation operation) {
+ int maxWaitTime = 15; // 15 seconds
IaasProvider iaasInfo = getIaasProvider();
Injector injector = ContextBuilder.newBuilder(iaasInfo.getProvider())
.credentials(iaasInfo.getIdentity(), iaasInfo.getCredential())
@@ -404,8 +440,9 @@ public class GCEIaas extends JcloudsIaas {
injector.getInstance(Key.get(new TypeLiteral<Predicate<AtomicReference<Operation>>>() {
}, Names.named("zone")));
AtomicReference<Operation> operationReference = Atomics.newReference(operation);
- retry(zoneOperationDonePredicate, MAX_WAIT_TIME, 1, SECONDS).apply(operationReference);
+ retry(zoneOperationDonePredicate, maxWaitTime, 1, SECONDS).apply(operationReference);
return operationReference.get();
}
-}
\ No newline at end of file
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/gce/GCEPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/gce/GCEPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/gce/GCEPartitionValidator.java
index 2b0db62..71d7aa3 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/gce/GCEPartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/gce/GCEPartitionValidator.java
@@ -22,13 +22,9 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.cloud.controller.domain.IaasProvider;
import org.apache.stratos.cloud.controller.domain.Partition;
-import org.apache.stratos.cloud.controller.exception.InvalidIaasProviderException;
import org.apache.stratos.cloud.controller.exception.InvalidPartitionException;
-import org.apache.stratos.cloud.controller.iaases.Iaas;
import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
-import org.apache.stratos.cloud.controller.services.impl.CloudControllerServiceUtil;
-import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
-import org.apache.stratos.cloud.controller.util.Scope;
+import org.apache.stratos.cloud.controller.iaases.vcloud.VCloudPartitionValidator;
import java.util.Properties;
@@ -38,75 +34,17 @@ import java.util.Properties;
*/
public class GCEPartitionValidator implements PartitionValidator {
- private static final Log log = LogFactory.getLog(GCEPartitionValidator.class);
+ private static final Log log = LogFactory.getLog(VCloudPartitionValidator.class);
+
private IaasProvider iaasProvider;
- private Iaas iaas;
@Override
public IaasProvider validate(Partition partition, Properties properties) throws InvalidPartitionException {
- try {
- if (properties.containsKey(Scope.REGION.toString())) {
- String region = properties.getProperty(Scope.REGION.toString());
-
- if (iaasProvider.getImage() != null && !iaasProvider.getImage().contains(region)) {
-
- String message = "Invalid partition detected, invalid region. [partition-id] " + partition.getId() +
- ", [region] " + region;
- log.error(message);
- throw new InvalidPartitionException(message);
- }
-
- iaas.isValidRegion(region);
-
- IaasProvider updatedIaasProvider = new IaasProvider(iaasProvider);
- Iaas updatedIaas = CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
- updatedIaas.setIaasProvider(updatedIaasProvider);
-
- if (properties.containsKey(Scope.ZONE.toString())) {
- String zone = properties.getProperty(Scope.ZONE.toString());
- iaas.isValidZone(region, zone);
- updatedIaasProvider.setProperty(CloudControllerConstants.AVAILABILITY_ZONE, zone);
- updatedIaas = CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
- updatedIaas.setIaasProvider(updatedIaasProvider);
- }
-
- updateOtherProperties(updatedIaasProvider, properties);
- return updatedIaasProvider;
- } else {
- return iaasProvider;
- }
- }
- catch (Exception ex) {
- String message = "Invalid partition detected: [partition-id] " + partition.getId();
- throw new InvalidPartitionException(message, ex);
- }
- }
-
- private void updateOtherProperties(IaasProvider updatedIaasProvider, Properties properties) {
- Iaas updatedIaas;
- try {
- updatedIaas = CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
-
- for (Object property : properties.keySet()) {
- if (property instanceof String) {
- String key = (String) property;
- updatedIaasProvider.setProperty(key, properties.getProperty(key));
- if (log.isDebugEnabled()) {
- log.debug("Added property " + key + " to the IaasProvider.");
- }
- }
- }
- updatedIaas = CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
- updatedIaas.setIaasProvider(updatedIaasProvider);
- }
- catch (InvalidIaasProviderException ignore) {
- }
-
+ return iaasProvider;
}
@Override
public void setIaasProvider(IaasProvider iaasProvider) {
this.iaasProvider = iaasProvider;
- this.iaas = iaasProvider.getIaas();
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackIaas.java
index 9b0e21f..bcd10b1 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackIaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackIaas.java
@@ -266,8 +266,8 @@ public class OpenstackIaas extends JcloudsIaas {
// jclouds availability zone = stratos zone
if (region == null || zone == null || iaasInfo == null) {
- String msg = "Host or Zone or IaaSProvider is null. [region] " + region + ", [zone] " +
- zone + ", [IaaSProvider] " + iaasInfo;
+ String msg = "Host or Zone or IaaSProvider is null: region: " + region + " - zone: " +
+ zone + " - IaaSProvider: " + iaasInfo;
log.error(msg);
throw new InvalidZoneException(msg);
}
@@ -295,8 +295,7 @@ public class OpenstackIaas extends JcloudsIaas {
IaasProvider iaasInfo = getIaasProvider();
if (host == null || zone == null || iaasInfo == null) {
- String msg = String.format("Host or Zone or IaaSProvider is null. [host] %s, [zone] %s, [IaaSProvider] %s",
- host, zone, iaasInfo);
+ String msg = String.format("Host or Zone or IaaSProvider is null: host: %s - zone: %s - IaaSProvider: %s", host, zone, iaasInfo);
log.error(msg);
throw new InvalidHostException(msg);
}
@@ -314,8 +313,7 @@ public class OpenstackIaas extends JcloudsIaas {
}
}
- String msg = String.format("Invalid host: %s in the zone: %s and of the iaas: %s", host, zone, iaasInfo.getType
- ());
+ String msg = String.format("Invalid host: %s in the zone: %s and of the iaas: %s", host, zone, iaasInfo.getType());
log.error(msg);
throw new InvalidHostException(msg);
}
@@ -359,8 +357,7 @@ public class OpenstackIaas extends JcloudsIaas {
}
if (volume == null) {
- log.fatal(String.format("Volume creation was unsuccessful. [region] %s, [zone] %s, [Iaas] %s", region,
- zone, iaasInfo));
+ log.fatal(String.format("Volume creation was unsuccessful. [region] : %s [zone] : %s of Iaas : %s", region, zone, iaasInfo));
return null;
}
@@ -381,8 +378,7 @@ public class OpenstackIaas extends JcloudsIaas {
return volumeId;
}
*/
- log.info(String.format("Successfully created a new volume [id]: %s in [region] : %s [zone] : %s of Iaas : %s " +
- "[Volume ID]%s", volume.getId(), region, zone, iaasInfo, volume.getId()));
+ log.info(String.format("Successfully created a new volume [id]: %s in [region] : %s [zone] : %s of Iaas : %s [Volume ID]%s", volume.getId(), region, zone, iaasInfo, volume.getId()));
return volumeId;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackPartitionValidator.java
index 6a77421..24f8e01 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackPartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackPartitionValidator.java
@@ -28,7 +28,7 @@ import org.apache.stratos.cloud.controller.iaases.Iaas;
import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
import org.apache.stratos.cloud.controller.services.impl.CloudControllerServiceUtil;
import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
-import org.apache.stratos.cloud.controller.util.Scope;
+import org.apache.stratos.messaging.domain.topology.Scope;
import java.util.Properties;
@@ -47,13 +47,13 @@ public class OpenstackPartitionValidator implements PartitionValidator {
public IaasProvider validate(Partition partition, Properties properties) throws InvalidPartitionException {
try {
// validate the existence of the zone and hosts properties.
- if (properties.containsKey(Scope.REGION.toString())) {
- String region = properties.getProperty(Scope.REGION.toString());
+ if (properties.containsKey(Scope.region.toString())) {
+ String region = properties.getProperty(Scope.region.toString());
if (iaasProvider.getImage() != null && !iaasProvider.getImage().contains(region)) {
- String msg = "Invalid partition detected, invalid region. [partition-id] " + partition.getId() +
- ", [region] " + region;
+ String msg = "Invalid partition detected, invalid region: [partition-id] " + partition.getId() +
+ " [region] " + region;
log.error(msg);
throw new InvalidPartitionException(msg);
}
@@ -64,8 +64,8 @@ public class OpenstackPartitionValidator implements PartitionValidator {
Iaas updatedIaas = CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
updatedIaas.setIaasProvider(updatedIaasProvider);
- if (properties.containsKey(Scope.ZONE.toString())) {
- String zone = properties.getProperty(Scope.ZONE.toString());
+ if (properties.containsKey(Scope.zone.toString())) {
+ String zone = properties.getProperty(Scope.zone.toString());
iaas.isValidZone(region, zone);
updatedIaasProvider.setProperty(CloudControllerConstants.AVAILABILITY_ZONE, zone);
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/networking/NeutronNetworkingApi.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/networking/NeutronNetworkingApi.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/networking/NeutronNetworkingApi.java
index 2bf9130..1a90386 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/networking/NeutronNetworkingApi.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/networking/NeutronNetworkingApi.java
@@ -526,13 +526,11 @@ public class NeutronNetworkingApi implements OpenstackNetworkingApi {
}
this.portApi = neutronApi.getPortApi(region);
- String portApiNullOrEmptyErrorMessage = String.format("Unable to get port Api from neutron Api for region: %s",
- region);
+ String portApiNullOrEmptyErrorMessage = String.format("Unable to get port Api from neutron Api for region ", region);
assertNotNull(portApi, portApiNullOrEmptyErrorMessage);
this.floatingIPApi = neutronApi.getFloatingIPApi(region).get();
- String floatingIPApiNullOrEmptyErrorMessage = String.format("Unable to get floatingIP Api from neutron Api " +
- "for region: %s", region);
+ String floatingIPApiNullOrEmptyErrorMessage = String.format("Unable to get floatingIP Api from neutron Api for region ", region);
assertNotNull(floatingIPApi, floatingIPApiNullOrEmptyErrorMessage);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/vcloud/VCloudIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/vcloud/VCloudIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/vcloud/VCloudIaas.java
new file mode 100644
index 0000000..d87e04d
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/vcloud/VCloudIaas.java
@@ -0,0 +1,392 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.cloud.controller.iaases.vcloud;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cloud.controller.domain.IaasProvider;
+import org.apache.stratos.cloud.controller.domain.NetworkInterface;
+import org.apache.stratos.cloud.controller.exception.CloudControllerException;
+import org.apache.stratos.cloud.controller.iaases.JcloudsIaas;
+import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
+import org.apache.stratos.cloud.controller.util.ComputeServiceBuilderUtil;
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
+import org.jclouds.vcloud.domain.DiskAttachOrDetachParams;
+import org.jclouds.vcloud.domain.NetworkConnection;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
+import org.jclouds.vcloud.domain.network.OrgNetwork;
+import org.jclouds.vcloud.features.VAppApi;
+import org.jclouds.vcloud.features.VmApi;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Hashtable;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+
+public class VCloudIaas extends JcloudsIaas {
+
+
+ private static final Log log = LogFactory.getLog(VCloudIaas.class);
+
+ private static final String SHELL_TYPE = "shellType";
+ private static final String SCRIPTS_PATH = "scripts";
+ private static final String CUSTOMIZATION_SCRIPT = "customization";
+ private static final String PAYLOAD = "PAYLOAD";
+
+ public VCloudIaas(IaasProvider iaasProvider) {
+ super(iaasProvider);
+ }
+
+ @Override
+ public void buildComputeServiceAndTemplate() {
+ // builds and sets Compute Service
+ ComputeService computeService = ComputeServiceBuilderUtil.buildDefaultComputeService(getIaasProvider());
+ getIaasProvider().setComputeService(computeService);
+
+ // builds and sets Template
+ buildTemplate();
+
+ }
+
+ public void buildTemplate() {
+ IaasProvider iaasInfo = getIaasProvider();
+
+ if (iaasInfo.getComputeService() == null) {
+ String msg = "Compute service is null for IaaS provider: "
+ + iaasInfo.getName();
+ log.fatal(msg);
+ throw new CloudControllerException(msg);
+ }
+
+ //get 'native' version of jclouds' vCloud API.
+ ComputeServiceContext context = iaasInfo.getComputeService().getContext();
+ VCloudApi api = context.unwrapApi(VCloudApi.class);
+
+
+ TemplateBuilder templateBuilder = iaasInfo.getComputeService()
+ .templateBuilder();
+
+ // set image id specified
+ templateBuilder.imageId(iaasInfo.getImage());
+
+ // build the Template
+ Template template = templateBuilder.build();
+
+ // if you wish to auto assign IPs, instance spawning call should be
+ // blocking, but if you
+ // wish to assign IPs manually, it can be non-blocking.
+ // is auto-assign-ip mode or manual-assign-ip mode? - default mode is
+ // non-blocking
+ boolean blockUntilRunning = Boolean.parseBoolean(iaasInfo
+ .getProperty("autoAssignIp"));
+ template.getOptions().as(TemplateOptions.class)
+ .blockUntilRunning(blockUntilRunning);
+
+ // this is required in order to avoid creation of additional security
+ // groups by Jclouds.
+ template.getOptions().as(TemplateOptions.class)
+ .inboundPorts(22, 80, 8080, 443, 8243);
+
+ if (iaasInfo.getNetworkInterfaces() != null) {
+ Set<String> networksSet = new LinkedHashSet<String>(iaasInfo.getNetworkInterfaces().length);
+ Hashtable<String, NetworkConnection> vcloudNetworkOptions = new Hashtable<String, NetworkConnection>(iaasInfo.getNetworkInterfaces().length);
+
+ int i = 0;
+ for (NetworkInterface ni : iaasInfo.getNetworkInterfaces()) {
+
+ String networkUuid = ni.getNetworkUuid();
+ String networkName = null;
+ IpAddressAllocationMode ipAllocMode = IpAddressAllocationMode.NONE;
+ if (ni.getFixedIp() != null && !ni.getFixedIp().equals("")) {
+ ipAllocMode = IpAddressAllocationMode.MANUAL;
+ } else {
+ ipAllocMode = IpAddressAllocationMode.POOL;
+ }
+
+ //fetch network name.
+ try {
+ OrgNetwork orgNet = api.getNetworkApi().getNetwork(new URI(networkUuid));
+ networkName = orgNet.getName();
+ } catch (URISyntaxException e) {
+ log.error("Network UUID '" + networkUuid + "' is not a URI/href.");
+ }
+ NetworkConnection nc = new NetworkConnection(networkName, i, ni.getFixedIp(), null, true,
+ null, //TODO: support fixed Mac addrs.
+ ipAllocMode);
+ networksSet.add(networkUuid);
+ vcloudNetworkOptions.put(networkUuid, nc);
+
+ i++;
+ }
+ //new NetworkConnectionSection()
+
+ //VmApi vmApi = api.getVmApi();
+ //vmApi.updateNetworkConnectionOfVm();
+
+ template.getOptions().networks(networksSet);
+ template.getOptions().as(VCloudTemplateOptions.class).networkConnections(vcloudNetworkOptions);
+ }
+
+ //template.getOptions().as(VCloudTemplateOptions.class)
+ // .ipAddressAllocationMode(IpAddressAllocationMode.POOL);
+
+ // set Template
+ iaasInfo.setTemplate(template);
+ }
+
+ @Override
+ public void setDynamicPayload(byte[] payload) {
+ // in vCloud case we need to run a script
+ IaasProvider iaasProvider = getIaasProvider();
+
+ if (iaasProvider.getTemplate() == null || payload == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Payload for vCloud not found");
+ }
+ return;
+ }
+
+ String shellType = iaasProvider.getProperty(SHELL_TYPE);
+
+ if (shellType == null || shellType.isEmpty()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Shell Type for vCloud Customization script not found from properties");
+ }
+ return;
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Shell Type '%s' will be used for vCloud Customization script", shellType));
+ }
+
+ // Payload is a String value
+ String payloadStr = new String(payload);
+
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Payload '%s' will be used for vCloud Customization script", payload));
+ }
+
+ Template template = iaasProvider.getTemplate();
+
+ File scriptPath = new File(CarbonUtils.getCarbonConfigDirPath(), SCRIPTS_PATH);
+
+ File customizationScriptFile = new File(new File(scriptPath, shellType), CUSTOMIZATION_SCRIPT);
+
+ if (!customizationScriptFile.exists()) {
+ if (log.isWarnEnabled()) {
+ log.warn(String.format("The vCloud Customization script '%s' does not exist",
+ customizationScriptFile.getAbsolutePath()));
+ }
+ return;
+ }
+
+ String customizationScript = null;
+
+ try {
+ customizationScript = FileUtils.readFileToString(customizationScriptFile);
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error(
+ String.format("Error reading the vCloud Customization script '%s'",
+ customizationScriptFile.getAbsolutePath()), e);
+ }
+ }
+
+ if (StringUtils.isEmpty(customizationScript)) {
+ if (log.isDebugEnabled()) {
+ log.debug("No content vCloud Customization script not found from properties");
+ }
+ return;
+ }
+
+ // Set payload
+ customizationScript = customizationScript.replaceAll(PAYLOAD, payloadStr);
+
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("The vCloud Customization script\n%s", customizationScript));
+ }
+
+ // Ensure the script is run.
+ if (customizationScript.length() >= 49000) {
+ log.warn("The vCloud customization script is >=49000 bytes in size; uploading dummy script and running real script via ssh.");
+ String dummyCustomizationScript = "#!/bin/sh\n"
+ + "#STRATOS: the real customization script will be invoked via ssh, since it exceeds the 49000 byte limit "
+ + "imposed by vCloud;\n"
+ + "#see "
+ + "http://pubs.vmware.com/vcd-55/topic/com.vmware.vcloud.api.doc_55/GUID-1BA3B7C5-B46C-48F7-8704-945BC47A940D.html\n";
+ template.getOptions().as(VCloudTemplateOptions.class).customizationScript(dummyCustomizationScript);
+ template.getOptions().runScript(customizationScript);
+ } else {
+ template.getOptions().as(VCloudTemplateOptions.class).customizationScript(customizationScript);
+ }
+
+ // Run the script
+ //template.getOptions().runScript(customizationScript);
+ }
+
+ @Override
+ public boolean createKeyPairFromPublicKey(String region, String keyPairName, String publicKey) {
+
+ // TODO
+ return false;
+ }
+
+ @Override
+ public List<String> associateAddresses(NodeMetadata node) {
+
+ // TODO
+ return null;
+
+ }
+
+ @Override
+ public String associatePredefinedAddress(NodeMetadata node, String ip) {
+ return "";
+ }
+
+ @Override
+ public void releaseAddress(String ip) {
+ // TODO
+ }
+
+ @Override
+ public boolean isValidRegion(String region) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isValidZone(String region, String zone) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ @Override
+ public boolean isValidHost(String zone, String host) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ @Override
+ public PartitionValidator getPartitionValidator() {
+ return new VCloudPartitionValidator();
+ }
+
+ @Override
+ public String createVolume(int sizeGB, String snapshotId) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String attachVolume(String instanceId, String volumeId, String deviceName) {
+ IaasProvider iaasInfo = getIaasProvider();
+
+ if (StringUtils.isEmpty(volumeId)) {
+ log.error("Volume provided to attach can not be null");
+ }
+
+ if (StringUtils.isEmpty(instanceId)) {
+ log.error("Instance provided to attach can not be null");
+ }
+
+ URI instanceIdHref = null;
+ URI volumeIdHref = null;
+ try {
+ //the instanceId format is a bit silly for vCloud.
+ instanceIdHref = new URI("https:/" + instanceId);
+ } catch (URISyntaxException e) {
+ log.error("Failed to attach volume, because the instance id cannot be converted into a url by concatenating "
+ + "'https:/' with " + instanceId + ". Full stacktrace: " + e.toString());
+ return null;
+ }
+ try {
+ volumeIdHref = new URI(volumeId);
+ } catch (URISyntaxException e) {
+ log.error("Failed to attach voluume, because the volume id '" + volumeId + "' is not a valid href (URI))"
+ + e.toString());
+ }
+
+ //get 'native' version of jclouds' vCloud API.
+ ComputeServiceContext context = iaasInfo.getComputeService()
+ .getContext();
+
+ VCloudApi api = context.unwrapApi(VCloudApi.class);
+
+ //Disks need to be attached to individual VMs, not vApps. The instanceId is the VApp.
+ VAppApi vAppApi = api.getVAppApi();
+ Set<Vm> vmsInVapp = vAppApi.getVApp(instanceIdHref).getChildren();
+ //Each vApp today has just 1 VM in it. Validate assumption.
+ assert (vmsInVapp.size() == 1);
+ Vm vm = vmsInVapp.iterator().next();
+ URI vmHref = vm.getHref();
+ VmApi vmApi = api.getVmApi();
+
+ // invest
+ /*
+ VCloudHardDisk.Builder hardDiskBuilder = new VCloudHardDisk.Builder();
+ VCloudHardDisk hardDisk = hardDiskBuilder.instanceID(volumeId).build();
+ VCloudVirtualHardwareSection vvhs = vm.getVirtualHardwareSection();
+ VCloudHardDisk.Builder Vchd = new VCloudHardDisk.Builder();
+ vvhs.toBuilder().item(Vchd.capacity(3).instanceID("hgfhgf").build()).build();
+ VApp va = vAppApi.getVApp(instanceIdHref);
+
+ */ //EO invest
+ DiskAttachOrDetachParams params = new DiskAttachOrDetachParams(volumeIdHref);
+ Task t = vmApi.attachDisk(vmHref, params);
+
+ log.info(String.format("Volume [id]: %s attachment for instance [id]: %s was successful [status]: Attaching. Iaas : %s, Task: %s", volumeId, instanceId, iaasInfo, t));
+ return "Attaching";
+ }
+
+ @Override
+ public void detachVolume(String instanceId, String volumeId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteVolume(String volumeId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getIaasDevice(String device) {
+ return device;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/vcloud/VCloudPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/vcloud/VCloudPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/vcloud/VCloudPartitionValidator.java
new file mode 100644
index 0000000..5a19741
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/vcloud/VCloudPartitionValidator.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.cloud.controller.iaases.vcloud;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cloud.controller.domain.IaasProvider;
+import org.apache.stratos.cloud.controller.domain.Partition;
+import org.apache.stratos.cloud.controller.exception.InvalidPartitionException;
+import org.apache.stratos.cloud.controller.iaases.Iaas;
+import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
+
+import java.util.Properties;
+
+
+/**
+ * The VCloud {@link org.apache.stratos.cloud.controller.iaases.PartitionValidator} implementation.
+ */
+public class VCloudPartitionValidator implements PartitionValidator {
+
+ @SuppressWarnings("unused")
+ private static final Log log = LogFactory.getLog(VCloudPartitionValidator.class);
+ private IaasProvider iaasProvider;
+ @SuppressWarnings("unused")
+ private Iaas iaas;
+
+ @Override
+ public IaasProvider validate(Partition partition, Properties properties) throws InvalidPartitionException {
+ //TODO: implement real validation logic
+ return iaasProvider;
+
+ }
+
+ @Override
+ public void setIaasProvider(IaasProvider iaas) {
+ this.iaasProvider = iaas;
+ this.iaas = iaas.getIaas();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/ComputeServiceBuilderUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/ComputeServiceBuilderUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/ComputeServiceBuilderUtil.java
index 19098cf..ee9d57b 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/ComputeServiceBuilderUtil.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/ComputeServiceBuilderUtil.java
@@ -92,7 +92,7 @@ public class ComputeServiceBuilderUtil {
// try to find region
if ((region = iaas.getProperty(CloudControllerConstants.REGION_PROPERTY)) == null) {
// if the property, isn't specified, try to obtain from the image id
- // image id can be in following format - {REGION}/{UUID}
+ // image id can be in following format - {region}/{UUID}
region = (iaas.getImage() != null) && (iaas.getImage().contains("/"))
? iaas.getImage().split("/")[0] : null;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Scope.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Scope.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Scope.java
deleted file mode 100644
index 984494e..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Scope.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.stratos.cloud.controller.util;
-
-/**
- * represents the scope of each partition which can be configured in stratos.
- */
-public enum Scope {
- PROVIDER, REGION, ZONE, HOST
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-1.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-1.xml b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-1.xml
index 24445d8..2d31871 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-1.xml
+++ b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-1.xml
@@ -33,7 +33,7 @@
<deployment baseDir="xyz">
<dir>abc</dir>
</deployment>
- <!-- A cartridge element should add a reference to an existing IaaS PROVIDER (specified
+ <!-- A cartridge element should add a reference to an existing IaaS provider (specified
in the above <iaasProviders> section) or it can create a completely new IaaS
Provider (which should have a unique "type" attribute. -->
<iaasProvider type="openstack">
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-2.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-2.xml b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-2.xml
index 2d7386f..ac89e87 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-2.xml
+++ b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-2.xml
@@ -26,7 +26,7 @@
specified under iaasProvider child elements of cartridge element. -->
<property name="ss" value="slsls"/>
- <!-- A cartridge element should add a reference to an existing IaaS PROVIDER (specified
+ <!-- A cartridge element should add a reference to an existing IaaS provider (specified
in the above <iaasProviders> section) or it can create a completely new IaaS
Provider (which should have a unique "type" attribute. -->
<iaasProvider type="openstack">
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-4.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-4.xml b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-4.xml
index bc78906..496e373 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-4.xml
+++ b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-4.xml
@@ -28,7 +28,7 @@
<!-- cartridge element can have 0..n properties, and they'll be overwritten by the properties
specified under iaasProvider child elements of cartridge element. -->
<property name="ss" value="slsls"/>
- <!-- A cartridge element should add a reference to an existing IaaS PROVIDER (specified
+ <!-- A cartridge element should add a reference to an existing IaaS provider (specified
in the above <iaasProviders> section) or it can create a completely new IaaS
Provider (which should have a unique "type" attribute. -->
<iaasProvider type="openstack">
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-5.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-5.xml b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-5.xml
index b4a3ee7..65dadaa 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-5.xml
+++ b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-5.xml
@@ -26,7 +26,7 @@
<!-- You can have 1..n cartridge elements. -->
<cartridge type="php">
- <!-- A cartridge element should add a reference to an existing IaaS PROVIDER (specified
+ <!-- A cartridge element should add a reference to an existing IaaS provider (specified
in the above <iaasProviders> section) or it can create a completely new IaaS
Provider (which should have a unique "type" attribute. -->
<iaasProvider type="openstack">
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-6.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-6.xml b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-6.xml
index 37c9b9d..6f42c4e 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-6.xml
+++ b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-6.xml
@@ -26,7 +26,7 @@
<!-- You can have 1..n cartridge elements. -->
<cartridge type="php">
- <!-- A cartridge element should add a reference to an existing IaaS PROVIDER (specified
+ <!-- A cartridge element should add a reference to an existing IaaS provider (specified
in the above <iaasProviders> section) or it can create a completely new IaaS
Provider (which should have a unique "type" attribute. -->
<iaasProvider type="openstack">
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-7.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-7.xml b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-7.xml
index 214e68f..993e3cd 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-7.xml
+++ b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-7.xml
@@ -27,7 +27,7 @@
<cartridge type="php" version="5.1">
<!-- Display name of this cartridge -->
<displayName>PHP</displayName>
- <!-- A cartridge element should add a reference to an existing IaaS PROVIDER (specified
+ <!-- A cartridge element should add a reference to an existing IaaS provider (specified
in the above <iaasProviders> section) or it can create a completely new IaaS
Provider (which should have a unique "type" attribute. -->
<iaasProvider type="openstack">
@@ -47,7 +47,7 @@
<cartridge type="php" version="5.1">
<!-- Display name of this cartridge -->
<displayName>PHP</displayName>
- <!-- A cartridge element should add a reference to an existing IaaS PROVIDER (specified
+ <!-- A cartridge element should add a reference to an existing IaaS provider (specified
in the above <iaasProviders> section) or it can create a completely new IaaS
Provider (which should have a unique "type" attribute. -->
<iaasProvider type="openstack">
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-8.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-8.xml b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-8.xml
index e0aa4d9..1bc3cd4 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-8.xml
+++ b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-8.xml
@@ -28,7 +28,7 @@
specified under iaasProvider child elements of cartridge element. -->
<property name="ss" value="slsls"/>
- <!-- A cartridge element should add a reference to an existing IaaS PROVIDER (specified
+ <!-- A cartridge element should add a reference to an existing IaaS provider (specified
in the above <iaasProviders> section) or it can create a completely new IaaS
Provider (which should have a unique "type" attribute. -->
<iaasProvider type="openstack">
@@ -85,7 +85,7 @@
specified under iaasProvider child elements of cartridge element. -->
<property name="ss" value="slsls"/>
-<!-- A cartridge element should add a reference to an existing IaaS PROVIDER (specified
+<!-- A cartridge element should add a reference to an existing IaaS provider (specified
in the above <iaasProviders> section) or it can create a completely new IaaS
Provider (which should have a unique "type" attribute. -->
<iaasProvider type="openstack">
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-9.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-9.xml b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-9.xml
index 5f42a36..9d2070d 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-9.xml
+++ b/components/org.apache.stratos.cloud.controller/src/test/resources/cartridges-9.xml
@@ -33,7 +33,7 @@
<deployment baseDir="xyz">
<dir>abc</dir>
</deployment>
- <!-- A cartridge element should add a reference to an existing IaaS PROVIDER (specified
+ <!-- A cartridge element should add a reference to an existing IaaS provider (specified
in the above <iaasProviders> section) or it can create a completely new IaaS
Provider (which should have a unique "type" attribute. -->
<iaasProvider type="openstack">
@@ -66,7 +66,7 @@
<deployment baseDir="xyz">
<dir>abc</dir>
</deployment>
- <!-- A cartridge element should add a reference to an existing IaaS PROVIDER (specified
+ <!-- A cartridge element should add a reference to an existing IaaS provider (specified
in the above <iaasProviders> section) or it can create a completely new IaaS
Provider (which should have a unique "type" attribute. -->
<iaasProvider type="openstack">
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller.xml b/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller.xml
index 8305ad9..677b020 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller.xml
+++ b/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller.xml
@@ -49,7 +49,7 @@
is not necessary [0..1]. But you can use this section to avoid specifying
same property over and over again. -->
<iaasProviders>
- <!--<iaasProvider type="ec2" name="EC2 specific details"> <PROVIDER>aws-ec2</PROVIDER>
+ <!--<iaasProvider type="ec2" name="EC2 specific details"> <provider>aws-ec2</provider>
<identity svns:secretAlias="elastic.scaler.ec2.identity">cdcd</identity>
<credential svns:secretAlias="elastic.scaler.ec2.credential">cdccdc</credential>
<scaleUpOrder>2</scaleUpOrder> <scaleDownOrder>1</scaleDownOrder> <property
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer1.conf
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer1.conf b/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer1.conf
index 11c2a92..8bdced5 100755
--- a/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer1.conf
+++ b/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer1.conf
@@ -106,7 +106,7 @@ loadbalancer {
# Rewrite location header
# If this property is set to true, load balancer will rewrite HTTP Location header values found in response
- # messages if the HOST is set to an ip address of a known member. The resulting Location header HOST will be
+ # messages if the host is set to an ip address of a known member. The resulting Location header host will be
# set to corresponding cluster hostname and the port will be set to corresponding transport proxy port.
rewrite-location-header: true;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer2.conf
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer2.conf b/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer2.conf
index 5680eca..5d4e950 100755
--- a/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer2.conf
+++ b/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer2.conf
@@ -106,7 +106,7 @@ loadbalancer {
# Rewrite location header
# If this property is set to true, load balancer will rewrite HTTP Location header values found in response
- # messages if the HOST is set to an ip address of a known member. The resulting Location header HOST will be
+ # messages if the host is set to an ip address of a known member. The resulting Location header host will be
# set to corresponding cluster hostname and the port will be set to corresponding transport proxy port.
rewrite-location-header: false;
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer3.conf
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer3.conf b/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer3.conf
index a82397d..2f723e8 100755
--- a/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer3.conf
+++ b/components/org.apache.stratos.load.balancer/src/test/resources/sample/configuration/loadbalancer3.conf
@@ -106,7 +106,7 @@ loadbalancer {
# Rewrite location header
# If this property is set to true, load balancer will rewrite HTTP Location header values found in response
- # messages if the HOST is set to an ip address of a known member. The resulting Location header HOST will be
+ # messages if the host is set to an ip address of a known member. The resulting Location header host will be
# set to corresponding cluster hostname and the port will be set to corresponding transport proxy port.
rewrite-location-header: true;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.manager/src/scripts/append_zone_file.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/scripts/append_zone_file.sh b/components/org.apache.stratos.manager/src/scripts/append_zone_file.sh
index aff5ee1..007cc58 100644
--- a/components/org.apache.stratos.manager/src/scripts/append_zone_file.sh
+++ b/components/org.apache.stratos.manager/src/scripts/append_zone_file.sh
@@ -24,7 +24,7 @@ appending_file=$3
subdomain=$1
ip=$2
-#appending the ZONE file
+#appending the zone file
echo $subdomain'\t'IN'\t'A'\t'$ip>> $appending_file
#increasing the count
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scope.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scope.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scope.java
new file mode 100644
index 0000000..4c228b3
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scope.java
@@ -0,0 +1,26 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.stratos.messaging.domain.topology;
+
+/**
+ * represents the scope of each partition which can be configured in stratos.
+ */
+public enum Scope {
+ provider, region, zone, host
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.metadata.service/src/main/resources/axis2_client.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.service/src/main/resources/axis2_client.xml b/components/org.apache.stratos.metadata.service/src/main/resources/axis2_client.xml
index 707e241..b9f2eb6 100644
--- a/components/org.apache.stratos.metadata.service/src/main/resources/axis2_client.xml
+++ b/components/org.apache.stratos.metadata.service/src/main/resources/axis2_client.xml
@@ -73,7 +73,7 @@
<!--POJO deployer , this will alow users to drop .class file and make that into a service-->
<deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/>
- <!-- Following parameter will set the HOST name for the epr-->
+ <!-- Following parameter will set the host name for the epr-->
<!--<parameter name="hostname" locked="true">myhost.com</parameter>-->
<!-- ================================================= -->
@@ -159,7 +159,7 @@
<transportReceiver name="http"
class="org.apache.axis2.transport.http.SimpleHTTPServer">
<parameter name="port">6071</parameter>
- <!--If you want to give your own HOST address for EPR generation-->
+ <!--If you want to give your own host address for EPR generation-->
<!--uncomment following parameter , and set as you required.-->
<!--<parameter name="hostname">http://myApp.com/ws</parameter>-->
</transportReceiver>
@@ -168,7 +168,7 @@
<!--<transportReceiver name="tcp"
class="org.apache.axis2.transport.tcp.TCPServer">
<parameter name="port">6061</parameter>-->
- <!--If you want to give your own HOST address for EPR generation-->
+ <!--If you want to give your own host address for EPR generation-->
<!--uncomment following parameter , and set as you required.-->
<!--<parameter name="hostname">tcp://myApp.com/ws</parameter>-->
<!--</transportReceiver>-->
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/THttpClient.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/THttpClient.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/THttpClient.py
index 5288bf7..9ef9535 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/THttpClient.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/THttpClient.py
@@ -34,14 +34,14 @@ class THttpClient(TTransportBase):
def __init__(self, uri_or_host, port=None, path=None):
"""THttpClient supports two different types constructor parameters.
- THttpClient(HOST, port, path) - deprecated
+ THttpClient(host, port, path) - deprecated
THttpClient(uri)
Only the second supports https.
"""
if port is not None:
warnings.warn(
- "Please use the THttpClient('http://HOST:port/path') syntax",
+ "Please use the THttpClient('http://host:port/path') syntax",
DeprecationWarning,
stacklevel=2)
self.host = uri_or_host
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py
index 9166a0a..df35be4 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py
@@ -152,7 +152,7 @@ class TSSLSocket(TSocket.TSocket):
raise TTransportException(
type=TTransportException.UNKNOWN,
message='Could not validate SSL certificate from '
- 'HOST "%s". Cert=%s' % (self.host, cert))
+ 'host "%s". Cert=%s' % (self.host, cert))
class TSSLServerSocket(TSocket.TServerSocket):
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/TSocket.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/TSocket.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/TSocket.py
index 1a7d2af..9e2b384 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/TSocket.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/databridge/thrift/thrift/transport/TSocket.py
@@ -50,10 +50,10 @@ class TSocket(TSocketBase):
def __init__(self, host='localhost', port=9090, unix_socket=None):
"""Initialize a TSocket
- @param host(str) The HOST to connect to.
+ @param host(str) The host to connect to.
@param port(int) The (TCP) port to connect to.
@param unix_socket(str) The filename of a unix socket to connect to.
- (HOST and port will be ignored.)
+ (host and port will be ignored.)
"""
self.host = host
self.port = port
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index afd40d6..148a3e6 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -418,8 +418,8 @@ public class StratosApiV41Utils {
throw new RestAPIException(errorMsg, axisFault);
} catch (RemoteException e) {
String errorMsg =
- String.format("Error while getting cartridge information for [provider] %s, [cause] %s ",
- provider, e.getMessage());
+ String.format("Error while getting cartridge information for provider %s Cause: %s ", provider,
+ e.getMessage());
log.error(errorMsg, e);
throw new RestAPIException(errorMsg, e);
}
[51/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
Revert "Upgrading to jclouds 1.9.1"
This reverts commit 295c545c4647b4ab075ca0414ad456a645b5e9f0.
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/b45ae00e
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b45ae00e
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b45ae00e
Branch: refs/heads/master
Commit: b45ae00e317c466c2a646c2a9cb5f8a0c38d9be2
Parents: f0dc4dd
Author: Imesh Gunaratne <im...@apache.org>
Authored: Thu Aug 20 14:51:53 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu Aug 20 15:04:56 2015 +0530
----------------------------------------------------------------------
.../agent/util/CartridgeAgentConstants.java | 2 +-
.../stratos/cli/RestCommandLineService.java | 3 +-
.../src/test/python/test_common.py | 8 +-
.../org.apache.stratos.cloud.controller/pom.xml | 32 +-
.../cloud/controller/iaases/JcloudsIaas.java | 2 +-
.../CloudStackPartitionValidator.java | 6 +-
.../cloud/controller/iaases/ec2/EC2Iaas.java | 8 +-
.../iaases/ec2/EC2PartitionValidator.java | 15 +-
.../cloud/controller/iaases/gce/GCEIaas.java | 193 +-
.../iaases/gce/GCEPartitionValidator.java | 70 +-
.../iaases/openstack/OpenstackIaas.java | 16 +-
.../openstack/OpenstackPartitionValidator.java | 14 +-
.../networking/NeutronNetworkingApi.java | 6 +-
.../controller/iaases/vcloud/VCloudIaas.java | 392 ++++
.../iaases/vcloud/VCloudPartitionValidator.java | 56 +
.../util/ComputeServiceBuilderUtil.java | 2 +-
.../stratos/cloud/controller/util/Scope.java | 26 -
.../src/test/resources/cartridges-1.xml | 2 +-
.../src/test/resources/cartridges-2.xml | 2 +-
.../src/test/resources/cartridges-4.xml | 2 +-
.../src/test/resources/cartridges-5.xml | 2 +-
.../src/test/resources/cartridges-6.xml | 2 +-
.../src/test/resources/cartridges-7.xml | 4 +-
.../src/test/resources/cartridges-8.xml | 4 +-
.../src/test/resources/cartridges-9.xml | 4 +-
.../src/test/resources/cloud-controller.xml | 2 +-
.../sample/configuration/loadbalancer1.conf | 2 +-
.../sample/configuration/loadbalancer2.conf | 2 +-
.../sample/configuration/loadbalancer3.conf | 2 +-
.../src/scripts/append_zone_file.sh | 2 +-
.../messaging/domain/topology/Scope.java | 26 +
.../src/main/resources/axis2_client.xml | 6 +-
.../thrift/thrift/transport/THttpClient.py | 4 +-
.../thrift/thrift/transport/TSSLSocket.py | 2 +-
.../thrift/thrift/transport/TSocket.py | 4 +-
.../rest/endpoint/api/StratosApiV41Utils.java | 4 +-
.../jclouds/apis/gce/1.8.1-stratos/README.txt | 77 +
.../jclouds/apis/gce/1.8.1-stratos/pom.xml | 144 ++
.../GoogleComputeEngineApi.java | 185 ++
.../GoogleComputeEngineApiMetadata.java | 103 +
.../GoogleComputeEngineConstants.java | 81 +
.../compute/GoogleComputeEngineService.java | 200 ++
.../GoogleComputeEngineServiceAdapter.java | 439 +++++
...GoogleComputeEngineServiceContextModule.java | 283 +++
...ogleComputeEngineSecurityGroupExtension.java | 342 ++++
.../functions/BuildInstanceMetadata.java | 46 +
.../functions/FirewallTagNamingConvention.java | 62 +
.../functions/FirewallToIpPermission.java | 87 +
.../GoogleComputeEngineImageToImage.java | 80 +
.../functions/InstanceInZoneToNodeMetadata.java | 150 ++
.../functions/MachineTypeInZoneToHardware.java | 95 +
.../functions/NetworkToSecurityGroup.java | 82 +
.../functions/OrphanedGroupsFromDeadNodes.java | 57 +
.../compute/functions/RegionToLocation.java | 45 +
.../compute/functions/ZoneToLocation.java | 45 +
.../compute/loaders/FindNetworkOrCreate.java | 62 +
.../GoogleComputeEngineTemplateOptions.java | 382 ++++
.../predicates/AllNodesInGroupTerminated.java | 48 +
...desWithGroupEncodedIntoNameThenAddToSet.java | 183 ++
...DefaultLoginCredentialsForImageStrategy.java | 69 +
...eNodeCredentialsButOverrideFromTemplate.java | 57 +
.../GoogleComputeEngineHttpApiModule.java | 177 ++
.../config/GoogleComputeEngineParserModule.java | 413 ++++
.../config/OAuthModuleWithoutTypeAdapters.java | 53 +
.../googlecomputeengine/config/UserProject.java | 33 +
.../domain/AbstractDisk.java | 121 ++
.../googlecomputeengine/domain/Address.java | 177 ++
.../googlecomputeengine/domain/Deprecated.java | 195 ++
.../googlecomputeengine/domain/Disk.java | 123 ++
.../googlecomputeengine/domain/Firewall.java | 379 ++++
.../googlecomputeengine/domain/Image.java | 286 +++
.../googlecomputeengine/domain/Instance.java | 1187 ++++++++++++
.../domain/InstanceInZone.java | 52 +
.../domain/InstanceTemplate.java | 445 +++++
.../googlecomputeengine/domain/ListPage.java | 179 ++
.../googlecomputeengine/domain/MachineType.java | 348 ++++
.../domain/MachineTypeInZone.java | 52 +
.../googlecomputeengine/domain/Metadata.java | 139 ++
.../googlecomputeengine/domain/Network.java | 133 ++
.../googlecomputeengine/domain/Operation.java | 556 ++++++
.../googlecomputeengine/domain/Project.java | 162 ++
.../googlecomputeengine/domain/Quota.java | 152 ++
.../googlecomputeengine/domain/Region.java | 175 ++
.../googlecomputeengine/domain/Resource.java | 283 +++
.../googlecomputeengine/domain/Route.java | 433 +++++
.../domain/SlashEncodedIds.java | 83 +
.../googlecomputeengine/domain/Snapshot.java | 135 ++
.../googlecomputeengine/domain/Zone.java | 334 ++++
.../domain/internal/NetworkAndAddressRange.java | 91 +
.../features/AddressApi.java | 187 ++
.../googlecomputeengine/features/DiskApi.java | 255 +++
.../features/FirewallApi.java | 227 +++
.../features/GlobalOperationApi.java | 158 ++
.../googlecomputeengine/features/ImageApi.java | 167 ++
.../features/InstanceApi.java | 381 ++++
.../features/MachineTypeApi.java | 143 ++
.../features/NetworkApi.java | 204 ++
.../features/ProjectApi.java | 96 +
.../googlecomputeengine/features/RegionApi.java | 135 ++
.../features/RegionOperationApi.java | 163 ++
.../googlecomputeengine/features/RouteApi.java | 184 ++
.../features/SnapshotApi.java | 160 ++
.../googlecomputeengine/features/ZoneApi.java | 135 ++
.../features/ZoneOperationApi.java | 163 ++
.../functions/CreateNetworkIfNeeded.java | 100 +
.../functions/internal/BaseToPagedIterable.java | 66 +
.../internal/BaseWithRegionToPagedIterable.java | 72 +
.../internal/BaseWithZoneToPagedIterable.java | 72 +
.../functions/internal/PATCH.java | 35 +
.../functions/internal/ParseAddresses.java | 67 +
.../functions/internal/ParseDisks.java | 67 +
.../functions/internal/ParseFirewalls.java | 63 +
.../internal/ParseGlobalOperations.java | 63 +
.../functions/internal/ParseImages.java | 63 +
.../functions/internal/ParseInstances.java | 65 +
.../functions/internal/ParseMachineTypes.java | 64 +
.../functions/internal/ParseNetworks.java | 63 +
.../internal/ParseRegionOperations.java | 65 +
.../functions/internal/ParseRegions.java | 63 +
.../functions/internal/ParseRoutes.java | 63 +
.../functions/internal/ParseSnapshots.java | 66 +
.../functions/internal/ParseZoneOperations.java | 65 +
.../functions/internal/ParseZones.java | 63 +
.../handlers/FirewallBinder.java | 56 +
.../GoogleComputeEngineErrorHandler.java | 62 +
.../handlers/InstanceBinder.java | 65 +
.../handlers/MetadataBinder.java | 60 +
.../handlers/RouteBinder.java | 56 +
.../options/AttachDiskOptions.java | 128 ++
.../options/DeprecateOptions.java | 126 ++
.../options/FirewallOptions.java | 166 ++
.../options/ListOptions.java | 91 +
.../options/RouteOptions.java | 202 ++
.../GlobalOperationDonePredicate.java | 59 +
.../predicates/InstancePredicates.java | 33 +
.../predicates/NetworkFirewallPredicates.java | 121 ++
.../RegionOperationDonePredicate.java | 69 +
.../predicates/ZoneOperationDonePredicate.java | 68 +
.../java/org/jclouds/oauth/v2/OAuthApi.java | 61 +
.../org/jclouds/oauth/v2/OAuthApiMetadata.java | 80 +
.../org/jclouds/oauth/v2/OAuthConstants.java | 78 +
.../jclouds/oauth/v2/config/Authentication.java | 35 +
.../jclouds/oauth/v2/config/CredentialType.java | 42 +
.../v2/config/OAuthAuthenticationModule.java | 52 +
.../oauth/v2/config/OAuthHttpApiModule.java | 45 +
.../jclouds/oauth/v2/config/OAuthModule.java | 119 ++
.../oauth/v2/config/OAuthProperties.java | 51 +
.../jclouds/oauth/v2/config/OAuthScopes.java | 40 +
.../org/jclouds/oauth/v2/domain/ClaimSet.java | 191 ++
.../org/jclouds/oauth/v2/domain/Header.java | 128 ++
.../oauth/v2/domain/OAuthCredentials.java | 129 ++
.../java/org/jclouds/oauth/v2/domain/Token.java | 149 ++
.../jclouds/oauth/v2/domain/TokenRequest.java | 131 ++
.../oauth/v2/domain/TokenRequestFormat.java | 45 +
.../v2/filters/BearerTokenAuthenticator.java | 41 +
.../v2/filters/OAuthAuthenticationFilter.java | 27 +
.../oauth/v2/filters/OAuthAuthenticator.java | 62 +
.../oauth/v2/functions/BuildTokenRequest.java | 135 ++
.../jclouds/oauth/v2/functions/FetchToken.java | 41 +
.../v2/functions/OAuthCredentialsSupplier.java | 125 ++
.../v2/functions/SignOrProduceMacForToken.java | 119 ++
.../oauth/v2/handlers/OAuthErrorHandler.java | 64 +
.../oauth/v2/handlers/OAuthTokenBinder.java | 45 +
.../oauth/v2/json/ClaimSetTypeAdapter.java | 59 +
.../oauth/v2/json/HeaderTypeAdapter.java | 52 +
.../oauth/v2/json/JWTTokenRequestFormat.java | 96 +
.../services/org.jclouds.apis.ApiMetadata | 19 +
.../GoogleComputeEngineApiMetadataTest.java | 38 +
...eEngineAuthenticatedRestContextLiveTest.java | 33 +
.../PageSystemExpectTest.java | 114 ++
.../GoogleComputeEngineServiceExpectTest.java | 574 ++++++
.../GoogleComputeEngineServiceLiveTest.java | 133 ++
...uteEngineSecurityGroupExtensionLiveTest.java | 28 +
.../functions/FirewallToIpPermissionTest.java | 93 +
.../GoogleComputeEngineImageToImageTest.java | 64 +
.../InstanceInZoneToNodeMetadataTest.java | 285 +++
.../functions/NetworkToSecurityGroupTest.java | 94 +
.../OrphanedGroupsFromDeadNodesTest.java | 136 ++
.../loaders/FindNetworkOrCreateTest.java | 141 ++
.../features/AddressApiExpectTest.java | 163 ++
.../features/AddressApiLiveTest.java | 71 +
.../features/DiskApiExpectTest.java | 226 +++
.../features/DiskApiLiveTest.java | 85 +
.../features/FirewallApiExpectTest.java | 301 +++
.../features/FirewallApiLiveTest.java | 164 ++
.../features/GlobalOperationApiExpectTest.java | 158 ++
.../features/GlobalOperationApiLiveTest.java | 91 +
.../features/ImageApiExpectTest.java | 159 ++
.../features/ImageApiLiveTest.java | 74 +
.../features/InstanceApiExpectTest.java | 410 ++++
.../features/InstanceApiLiveTest.java | 241 +++
.../features/MachineTypeApiExpectTest.java | 113 ++
.../features/MachineTypeApiLiveTest.java | 73 +
.../features/NetworkApiExpectTest.java | 164 ++
.../features/NetworkApiLiveTest.java | 84 +
.../features/ProjectApiExpectTest.java | 96 +
.../features/ProjectApiLiveTest.java | 123 ++
.../features/RegionApiExpectTest.java | 94 +
.../features/RegionApiLiveTest.java | 74 +
.../features/RegionOperationApiExpectTest.java | 195 ++
.../features/RegionOperationApiLiveTest.java | 91 +
.../features/RouteApiExpectTest.java | 175 ++
.../features/RouteApiLiveTest.java | 97 +
.../features/SnapshotApiExpectTest.java | 94 +
.../features/SnapshotApiLiveTest.java | 92 +
.../features/ZoneApiExpectTest.java | 97 +
.../features/ZoneApiLiveTest.java | 74 +
.../features/ZoneOperationApiExpectTest.java | 193 ++
.../features/ZoneOperationApiLiveTest.java | 90 +
.../functions/CreateNetworkIfNeededTest.java | 132 ++
.../GoogleComputeEngineErrorHandlerTest.java | 92 +
.../BaseGoogleComputeEngineApiExpectTest.java | 31 +
.../BaseGoogleComputeEngineApiLiveTest.java | 160 ++
.../BaseGoogleComputeEngineExpectTest.java | 195 ++
.../BaseGoogleComputeEngineParseTest.java | 33 +
...leComputeEngineServiceContextExpectTest.java | 49 +
...aseGoogleComputeEngineServiceExpectTest.java | 28 +
.../parse/ParseAddressListTest.java | 61 +
.../parse/ParseAddressTest.java | 51 +
.../parse/ParseDiskListTest.java | 61 +
.../parse/ParseDiskTest.java | 50 +
.../parse/ParseFirewallListTest.java | 68 +
.../parse/ParseFirewallTest.java | 60 +
.../parse/ParseImageListTest.java | 71 +
.../parse/ParseImageTest.java | 55 +
.../parse/ParseInstanceListTest.java | 48 +
.../parse/ParseInstanceSerialOutputTest.java | 38 +
.../parse/ParseInstanceTest.java | 81 +
.../parse/ParseMachineTypeListTest.java | 91 +
.../parse/ParseMachineTypeTest.java | 56 +
.../parse/ParseMetadataTest.java | 45 +
.../parse/ParseNetworkListTest.java | 49 +
.../parse/ParseNetworkTest.java | 48 +
.../parse/ParseOperationListTest.java | 46 +
.../parse/ParseOperationTest.java | 58 +
.../parse/ParseProjectTest.java | 67 +
.../parse/ParseQuotaTest.java | 39 +
.../parse/ParseRegionListTest.java | 72 +
.../parse/ParseRegionTest.java | 62 +
.../parse/ParseRouteListTest.java | 62 +
.../parse/ParseRouteTest.java | 56 +
.../parse/ParseSnapshotListTest.java | 64 +
.../parse/ParseSnapshotTest.java | 52 +
.../parse/ParseZoneListTest.java | 70 +
.../parse/ParseZoneTest.java | 55 +
.../NetworkFirewallPredicatesTest.java | 162 ++
.../jclouds/oauth/v2/OAuthApiMetadataTest.java | 38 +
.../org/jclouds/oauth/v2/OAuthTestUtils.java | 91 +
.../oauth/v2/features/OAuthApiExpectTest.java | 99 +
.../oauth/v2/features/OAuthApiLiveTest.java | 80 +
.../functions/OAuthCredentialsFromPKTest.java | 61 +
.../functions/OAuthCredentialsSupplierTest.java | 55 +
.../oauth/v2/functions/SignerFunctionTest.java | 61 +
.../v2/handlers/OAuthErrorHandlerTest.java | 92 +
.../oauth/v2/internal/Base64UrlSafeTest.java | 40 +
.../v2/internal/BaseOAuthApiExpectTest.java | 23 +
.../oauth/v2/internal/BaseOAuthApiLiveTest.java | 56 +
.../BaseOAuthAuthenticatedApiLiveTest.java | 110 ++
.../oauth/v2/internal/BaseOAuthExpectTest.java | 26 +
.../v2/json/JWTTokenRequestFormatTest.java | 69 +
.../jclouds/oauth/v2/parse/ParseTokenTest.java | 40 +
.../firewall_list.json | 37 +
.../network_get.json | 10 +
.../src/test/resources/address_get.json | 12 +
.../src/test/resources/address_insert.json | 1 +
.../src/test/resources/address_list.json | 31 +
.../test/resources/disk_create_snapshot.json | 1 +
.../src/test/resources/disk_get.json | 10 +
.../src/test/resources/disk_insert.json | 1 +
.../src/test/resources/disk_list.json | 17 +
.../src/test/resources/firewall_get.json | 30 +
.../src/test/resources/firewall_insert.json | 1 +
.../src/test/resources/firewall_list.json | 58 +
.../src/test/resources/global_operation.json | 15 +
.../test/resources/global_operation_list.json | 22 +
.../src/test/resources/image_get.json | 13 +
.../src/test/resources/image_insert.json | 4 +
.../src/test/resources/image_list.json | 24 +
.../src/test/resources/image_list_centos.json | 183 ++
.../src/test/resources/image_list_debian.json | 400 ++++
.../src/test/resources/image_list_empty.json | 6 +
.../resources/image_list_multiple_page_1.json | 55 +
.../resources/image_list_multiple_page_2.json | 47 +
.../test/resources/image_list_single_page.json | 50 +
.../resources/instance_add_access_config.json | 11 +
.../test/resources/instance_attach_disk.json | 6 +
.../src/test/resources/instance_get.json | 62 +
.../src/test/resources/instance_insert.json | 1 +
.../test/resources/instance_insert_simple.json | 1 +
.../src/test/resources/instance_list.json | 69 +
.../instance_list_central1b_empty.json | 6 +
.../test/resources/instance_serial_port.json | 4 +
.../test/resources/instance_set_metadata.json | 10 +
.../src/test/resources/logback.xml | 83 +
.../src/test/resources/machinetype.json | 21 +
.../src/test/resources/machinetype_list.json | 54 +
.../resources/machinetype_list_central1b.json | 41 +
.../machinetype_list_central1b_empty.json | 6 +
.../src/test/resources/metadata.json | 1 +
.../src/test/resources/network_get.json | 10 +
.../src/test/resources/network_insert.json | 1 +
.../src/test/resources/network_list.json | 18 +
.../src/test/resources/operation.json | 17 +
.../src/test/resources/operation_error.json | 26 +
.../src/test/resources/operation_list.json | 24 +
.../src/test/resources/project.json | 69 +
.../1.8.1-stratos/src/test/resources/quota.json | 5 +
.../src/test/resources/region_get.json | 60 +
.../src/test/resources/region_list.json | 126 ++
.../src/test/resources/region_operation.json | 16 +
.../test/resources/region_operation_list.json | 23 +
.../src/test/resources/route_get.json | 14 +
.../src/test/resources/route_insert.json | 1 +
.../src/test/resources/route_list.json | 34 +
.../src/test/resources/snapshot_get.json | 13 +
.../src/test/resources/snapshot_list.json | 33 +
.../src/test/resources/tag_insert.json | 1 +
.../1.8.1-stratos/src/test/resources/testpk.pem | 15 +
.../src/test/resources/tokenResponse.json | 5 +
.../src/test/resources/zone_get.json | 17 +
.../src/test/resources/zone_list.json | 41 +
.../src/test/resources/zone_list_short.json | 24 +
.../src/test/resources/zone_operation.json | 16 +
.../test/resources/zone_operation_error.json | 25 +
.../src/test/resources/zone_operation_list.json | 23 +
dependencies/jclouds/apis/gce/README.md | 87 +
.../openstack-neutron/1.8.1-stratos/README.md | 7 +
.../openstack-neutron/1.8.1-stratos/pom.xml | 161 ++
.../openstack/neutron/v2/NeutronApi.java | 116 ++
.../neutron/v2/NeutronApiMetadata.java | 100 +
.../neutron/v2/config/NeutronHttpApiModule.java | 91 +
.../neutron/v2/domain/AddressPair.java | 176 ++
.../neutron/v2/domain/AllocationPool.java | 138 ++
.../neutron/v2/domain/ExternalGatewayInfo.java | 137 ++
.../neutron/v2/domain/ExtraDhcpOption.java | 165 ++
.../openstack/neutron/v2/domain/FloatingIP.java | 315 +++
.../neutron/v2/domain/FloatingIPs.java | 36 +
.../openstack/neutron/v2/domain/HostRoute.java | 123 ++
.../jclouds/openstack/neutron/v2/domain/IP.java | 135 ++
.../neutron/v2/domain/IPv6DHCPMode.java | 57 +
.../openstack/neutron/v2/domain/Network.java | 646 +++++++
.../neutron/v2/domain/NetworkSegment.java | 167 ++
.../neutron/v2/domain/NetworkStatus.java | 60 +
.../neutron/v2/domain/NetworkType.java | 81 +
.../openstack/neutron/v2/domain/Networks.java | 36 +
.../openstack/neutron/v2/domain/Port.java | 763 ++++++++
.../openstack/neutron/v2/domain/Ports.java | 36 +
.../openstack/neutron/v2/domain/Router.java | 285 +++
.../neutron/v2/domain/RouterInterface.java | 139 ++
.../openstack/neutron/v2/domain/Routers.java | 36 +
.../openstack/neutron/v2/domain/Rule.java | 376 ++++
.../neutron/v2/domain/RuleDirection.java | 61 +
.../neutron/v2/domain/RuleEthertype.java | 61 +
.../neutron/v2/domain/RuleProtocol.java | 65 +
.../openstack/neutron/v2/domain/Rules.java | 35 +
.../neutron/v2/domain/SecurityGroup.java | 218 +++
.../neutron/v2/domain/SecurityGroups.java | 36 +
.../openstack/neutron/v2/domain/Subnet.java | 466 +++++
.../openstack/neutron/v2/domain/Subnets.java | 36 +
.../openstack/neutron/v2/domain/VIFType.java | 62 +
.../openstack/neutron/v2/domain/VNICType.java | 56 +
.../v2/domain/lbaas/v1/HealthMonitor.java | 450 +++++
.../v2/domain/lbaas/v1/HealthMonitorStatus.java | 100 +
.../v2/domain/lbaas/v1/HealthMonitors.java | 37 +
.../neutron/v2/domain/lbaas/v1/HttpMethod.java | 75 +
.../neutron/v2/domain/lbaas/v1/LBaaSStatus.java | 78 +
.../neutron/v2/domain/lbaas/v1/Member.java | 367 ++++
.../neutron/v2/domain/lbaas/v1/Members.java | 36 +
.../neutron/v2/domain/lbaas/v1/Pool.java | 481 +++++
.../neutron/v2/domain/lbaas/v1/PoolStatus.java | 100 +
.../neutron/v2/domain/lbaas/v1/Pools.java | 36 +
.../neutron/v2/domain/lbaas/v1/ProbeType.java | 70 +
.../neutron/v2/domain/lbaas/v1/Protocol.java | 67 +
.../v2/domain/lbaas/v1/SessionPersistence.java | 182 ++
.../neutron/v2/domain/lbaas/v1/VIP.java | 492 +++++
.../neutron/v2/domain/lbaas/v1/VIPs.java | 36 +
.../v2/extensions/ExtensionNamespaces.java | 39 +
.../neutron/v2/extensions/FloatingIPApi.java | 138 ++
.../neutron/v2/extensions/RouterApi.java | 198 ++
.../neutron/v2/extensions/SecurityGroupApi.java | 186 ++
.../v2/extensions/lbaas/v1/LBaaSApi.java | 426 +++++
.../v2/fallbacks/EmptyFloatingIPsFallback.java | 38 +
.../v2/fallbacks/EmptyNetworksFallback.java | 38 +
.../v2/fallbacks/EmptyPortsFallback.java | 38 +
.../v2/fallbacks/EmptyRoutersFallback.java | 38 +
.../v2/fallbacks/EmptyRulesFallback.java | 38 +
.../fallbacks/EmptySecurityGroupsFallback.java | 38 +
.../v2/fallbacks/EmptySubnetsFallback.java | 38 +
.../lbaas/v1/EmptyHealthMonitorsFallback.java | 38 +
.../lbaas/v1/EmptyMembersFallback.java | 38 +
.../fallbacks/lbaas/v1/EmptyPoolsFallback.java | 38 +
.../fallbacks/lbaas/v1/EmptyVIPsFallback.java | 38 +
.../neutron/v2/features/NetworkApi.java | 151 ++
.../openstack/neutron/v2/features/PortApi.java | 148 ++
.../neutron/v2/features/SubnetApi.java | 144 ++
.../functions/FloatingIPsToPagedIterable.java | 64 +
.../v2/functions/NetworksToPagedIterable.java | 64 +
.../neutron/v2/functions/ParseFloatingIPs.java | 37 +
.../neutron/v2/functions/ParseNetworks.java | 38 +
.../neutron/v2/functions/ParsePorts.java | 37 +
.../neutron/v2/functions/ParseRouters.java | 37 +
.../neutron/v2/functions/ParseRules.java | 38 +
.../v2/functions/ParseSecurityGroups.java | 38 +
.../neutron/v2/functions/ParseSubnets.java | 37 +
.../v2/functions/PortsToPagedIterable.java | 64 +
.../v2/functions/RouterToPagedIterable.java | 65 +
.../v2/functions/RulesToPagedIterable.java | 66 +
.../SecurityGroupsToPagedIterable.java | 66 +
.../v2/functions/SubnetsToPagedIterable.java | 64 +
.../lbaas/v1/HealthMonitorsToPagedIterable.java | 66 +
.../lbaas/v1/MembersToPagedIterable.java | 65 +
.../functions/lbaas/v1/ParseHealthMonitors.java | 38 +
.../v2/functions/lbaas/v1/ParseMembers.java | 38 +
.../v2/functions/lbaas/v1/ParsePools.java | 38 +
.../v2/functions/lbaas/v1/ParseVIPs.java | 38 +
.../lbaas/v1/PoolsToPagedIterable.java | 65 +
.../functions/lbaas/v1/VIPsToPagedIterable.java | 65 +
.../v2/handlers/NeutronErrorHandler.java | 62 +
.../neutron/v2/options/EmptyOptions.java | 45 +
.../openstack/neutron/v2_0/NeutronApi.java | 134 ++
.../neutron/v2_0/NeutronApiMetadata.java | 101 +
.../v2_0/config/NeutronHttpApiModule.java | 82 +
.../neutron/v2_0/domain/AllocationPool.java | 125 ++
.../neutron/v2_0/domain/BulkNetwork.java | 208 ++
.../openstack/neutron/v2_0/domain/BulkPort.java | 230 +++
.../neutron/v2_0/domain/BulkSubnet.java | 273 +++
.../v2_0/domain/ExternalGatewayInfo.java | 102 +
.../neutron/v2_0/domain/HostRoute.java | 126 ++
.../openstack/neutron/v2_0/domain/IP.java | 120 ++
.../openstack/neutron/v2_0/domain/Network.java | 255 +++
.../neutron/v2_0/domain/NetworkType.java | 39 +
.../openstack/neutron/v2_0/domain/Port.java | 234 +++
.../neutron/v2_0/domain/Reference.java | 127 ++
.../neutron/v2_0/domain/ReferenceWithName.java | 109 ++
.../openstack/neutron/v2_0/domain/Router.java | 149 ++
.../neutron/v2_0/domain/RouterInterface.java | 125 ++
.../openstack/neutron/v2_0/domain/State.java | 27 +
.../openstack/neutron/v2_0/domain/Subnet.java | 264 +++
.../neutron/v2_0/extensions/RouterApi.java | 215 +++
.../neutron/v2_0/features/NetworkApi.java | 178 ++
.../neutron/v2_0/features/PortApi.java | 182 ++
.../neutron/v2_0/features/SubnetApi.java | 181 ++
.../v2_0/functions/ParseNetworkDetails.java | 93 +
.../neutron/v2_0/functions/ParseNetworks.java | 93 +
.../v2_0/functions/ParsePortDetails.java | 94 +
.../neutron/v2_0/functions/ParsePorts.java | 93 +
.../v2_0/functions/ParseRouterDetails.java | 93 +
.../neutron/v2_0/functions/ParseRouters.java | 93 +
.../v2_0/functions/ParseSubnetDetails.java | 93 +
.../neutron/v2_0/functions/ParseSubnets.java | 93 +
.../v2_0/handlers/NeutronErrorHandler.java | 59 +
.../v2_0/options/CreateNetworkBulkOptions.java | 138 ++
.../v2_0/options/CreateNetworkOptions.java | 240 +++
.../v2_0/options/CreatePortBulkOptions.java | 133 ++
.../neutron/v2_0/options/CreatePortOptions.java | 241 +++
.../v2_0/options/CreateRouterOptions.java | 164 ++
.../v2_0/options/CreateSubnetBulkOptions.java | 139 ++
.../v2_0/options/CreateSubnetOptions.java | 256 +++
.../neutron/v2_0/options/EmptyOptions.java | 45 +
.../v2_0/options/UpdateNetworkOptions.java | 128 ++
.../neutron/v2_0/options/UpdatePortOptions.java | 215 +++
.../v2_0/options/UpdateRouterOptions.java | 164 ++
.../v2_0/options/UpdateSubnetOptions.java | 215 +++
.../services/org.jclouds.apis.ApiMetadata | 19 +
.../neutron/v2/NeutronApiMetadataTest.java | 33 +
.../v2/extensions/FloatingIPApiLiveTest.java | 92 +
.../v2/extensions/FloatingIPApiMockTest.java | 436 +++++
.../v2/extensions/RouterApiLiveTest.java | 173 ++
.../v2/extensions/RouterApiMockTest.java | 631 +++++++
.../v2/extensions/SecurityGroupApiLiveTest.java | 99 +
.../v2/extensions/SecurityGroupApiMockTest.java | 659 +++++++
.../extensions/lbaas/v1/LBaaSApiLiveTest.java | 637 +++++++
.../extensions/lbaas/v1/LBaaSApiMockTest.java | 1787 ++++++++++++++++++
.../v2/features/ExtensionApiLiveTest.java | 83 +
.../v2/features/ExtensionApiMockTest.java | 152 ++
.../neutron/v2/features/NetworkApiLiveTest.java | 100 +
.../neutron/v2/features/NetworkApiMockTest.java | 464 +++++
.../neutron/v2/features/PortApiLiveTest.java | 149 ++
.../neutron/v2/features/PortApiMockTest.java | 492 +++++
.../neutron/v2/features/SubnetApiLiveTest.java | 118 ++
.../neutron/v2/features/SubnetApiMockTest.java | 472 +++++
.../v2/internal/BaseNeutronApiLiveTest.java | 44 +
.../v2/internal/BaseNeutronApiMockTest.java | 41 +
.../openstack/neutron/v2/util/ClassUtil.java | 39 +
.../neutron/v2/util/PredicateUtil.java | 47 +
.../neutron/v2_0/NeutronApiMetadataTest.java | 31 +
.../v2_0/extensions/RouterApiExpectTest.java | 295 +++
.../v2_0/extensions/RouterApiLiveTest.java | 190 ++
.../v2_0/features/NetworkApiExpectTest.java | 245 +++
.../v2_0/features/NetworkApiLiveTest.java | 121 ++
.../v2_0/features/PortApiExpectTest.java | 245 +++
.../neutron/v2_0/features/PortApiLiveTest.java | 157 ++
.../v2_0/features/SubnetApiExpectTest.java | 252 +++
.../v2_0/features/SubnetApiLiveTest.java | 139 ++
.../v2_0/internal/BaseNeutronApiExpectTest.java | 66 +
.../v2_0/internal/BaseNeutronApiLiveTest.java | 44 +
.../v2_0/internal/BaseNeutronExpectTest.java | 64 +
.../neutron/v2_0/parse/ParseNetworkTest.java | 50 +
.../neutron/v2_0/parse/ParsePortTest.java | 49 +
.../neutron/v2_0/parse/ParseRouterTest.java | 51 +
.../neutron/v2_0/parse/ParseSubnetTest.java | 49 +
.../openstack/neutron/v2_0/util/ClassUtil.java | 39 +
.../neutron/v2_0/util/PredicateUtil.java | 47 +
.../src/test/resources/access.json | 228 +++
.../src/test/resources/extension_details.json | 10 +
.../src/test/resources/extension_list.json | 140 ++
.../extension_list_with_lbaas_v1_response.json | 140 ++
...xtension_list_without_lbaas_v1_response.json | 132 ++
.../resources/floatingip_create_request.json | 6 +
.../resources/floatingip_create_response.json | 11 +
.../test/resources/floatingip_get_response.json | 11 +
.../resources/floatingip_list_response.json | 22 +
.../floatingip_list_response_paged1.json | 32 +
.../floatingip_list_response_paged2.json | 28 +
.../floatingip_update_dissociate_request.json | 5 +
.../floatingip_update_dissociate_response.json | 11 +
.../resources/floatingip_update_request.json | 5 +
.../resources/floatingip_update_response.json | 11 +
.../lbaas/v1/health_monitor_create_request.json | 8 +
.../v1/health_monitor_create_response.json | 16 +
.../lbaas/v1/health_monitor_get_response.json | 16 +
.../v1/health_monitor_list_response_paged1.json | 20 +
.../v1/health_monitor_list_response_paged2.json | 23 +
.../lbaas/v1/health_monitor_update_request.json | 11 +
.../v1/health_monitor_update_response.json | 16 +
.../lbaas/v1/member_create_request.json | 6 +
.../lbaas/v1/member_create_response.json | 12 +
.../resources/lbaas/v1/member_get_response.json | 12 +
.../lbaas/v1/member_list_response_paged1.json | 20 +
.../lbaas/v1/member_list_response_paged2.json | 20 +
.../lbaas/v1/member_update_request.json | 7 +
.../lbaas/v1/member_update_response.json | 12 +
.../pool_associate_health_monitor_request.json | 5 +
.../pool_associate_health_monitor_response.json | 4 +
.../resources/lbaas/v1/pool_create_request.json | 8 +
.../lbaas/v1/pool_create_response.json | 18 +
.../resources/lbaas/v1/pool_get_response.json | 35 +
.../lbaas/v1/pool_list_response_paged1.json | 46 +
.../lbaas/v1/pool_list_response_paged2.json | 42 +
.../resources/lbaas/v1/pool_update_request.json | 11 +
.../lbaas/v1/pool_update_response.json | 29 +
.../resources/lbaas/v1/vip_create_request.json | 9 +
.../resources/lbaas/v1/vip_create_response.json | 17 +
.../resources/lbaas/v1/vip_get_response.json | 21 +
.../lbaas/v1/vip_list_response_paged1.json | 29 +
.../lbaas/v1/vip_list_response_paged2.json | 29 +
.../resources/lbaas/v1/vip_update_request.json | 13 +
.../resources/lbaas/v1/vip_update_response.json | 21 +
.../src/test/resources/list_networks.json | 62 +
.../src/test/resources/list_ports.json | 86 +
.../src/test/resources/list_routers.json | 74 +
.../src/test/resources/list_subnets.json | 98 +
.../src/test/resources/logback.xml | 69 +
.../src/test/resources/network.json | 7 +
.../resources/network_bulk_create_request.json | 12 +
.../resources/network_bulk_create_response.json | 18 +
.../test/resources/network_create_request.json | 4 +
.../test/resources/network_create_response.json | 7 +
.../test/resources/network_get_response.json | 7 +
.../test/resources/network_list_response.json | 62 +
.../resources/network_list_response_paged1.json | 40 +
.../resources/network_list_response_paged2.json | 36 +
.../test/resources/network_update_request.json | 4 +
.../test/resources/network_update_response.json | 11 +
.../1.8.1-stratos/src/test/resources/port.json | 7 +
.../resources/port_create_bulk_request.json | 22 +
.../resources/port_create_bulk_response.json | 47 +
.../src/test/resources/port_create_request.json | 14 +
.../test/resources/port_create_response.json | 29 +
.../src/test/resources/port_get_response.json | 10 +
.../src/test/resources/port_list_response.json | 86 +
.../resources/port_list_response_paged1.json | 48 +
.../resources/port_list_response_paged2.json | 44 +
.../src/test/resources/port_update_request.json | 8 +
.../test/resources/port_update_response.json | 23 +
.../src/test/resources/router.json | 9 +
.../router_add_interface_port_request.json | 3 +
.../resources/router_add_interface_request.json | 3 +
.../router_add_interface_response.json | 4 +
.../test/resources/router_create_request.json | 9 +
.../test/resources/router_create_response.json | 12 +
.../src/test/resources/router_get_response.json | 12 +
.../test/resources/router_list_response.json | 74 +
.../resources/router_list_response_paged1.json | 34 +
.../resources/router_list_response_paged2.json | 30 +
.../router_remove_interface_port_request.json | 3 +
.../router_remove_interface_subnet_request.json | 3 +
.../test/resources/router_update_request.json | 7 +
.../test/resources/router_update_response.json | 12 +
.../security_group_create_request.json | 6 +
.../security_group_create_response.json | 34 +
.../resources/security_group_get_response.json | 58 +
.../resources/security_group_list_response.json | 116 ++
.../security_group_list_response_paged1.json | 126 ++
.../security_group_list_response_paged2.json | 122 ++
.../security_group_rule_create_request.json | 11 +
.../security_group_rule_create_response.json | 15 +
.../security_group_rule_get_response.json | 14 +
.../security_group_rule_list_response.json | 52 +
...ecurity_group_rule_list_response_paged1.json | 62 +
...ecurity_group_rule_list_response_paged2.json | 58 +
.../src/test/resources/subnet.json | 8 +
.../resources/subnet_bulk_create_request.json | 14 +
.../resources/subnet_bulk_create_response.json | 48 +
.../test/resources/subnet_create_request.json | 6 +
.../test/resources/subnet_create_response.json | 8 +
.../src/test/resources/subnet_get_response.json | 9 +
.../test/resources/subnet_list_response.json | 98 +
.../resources/subnet_list_response_pages1.json | 30 +
.../resources/subnet_list_response_pages2.json | 26 +
.../test/resources/subnet_update_request.json | 6 +
.../test/resources/subnet_update_response.json | 18 +
.../jclouds/apis/openstack-neutron/README.md | 23 +
.../apis/vcloud/1.8.1-stratos/README.txt | 6 +
.../jclouds/apis/vcloud/1.8.1-stratos/pom.xml | 129 ++
.../vcloud/TaskInErrorStateException.java | 34 +
.../vcloud/TaskStillRunningException.java | 34 +
.../main/java/org/jclouds/vcloud/VCloudApi.java | 90 +
.../org/jclouds/vcloud/VCloudApiMetadata.java | 101 +
.../org/jclouds/vcloud/VCloudMediaType.java | 226 +++
.../jclouds/vcloud/VCloudResponseException.java | 66 +
.../java/org/jclouds/vcloud/VCloudToken.java | 34 +
.../org/jclouds/vcloud/VCloudVersionsApi.java | 38 +
.../binders/BindCPUCountToXmlPayload.java | 74 +
.../BindCaptureVAppParamsToXmlPayload.java | 119 ++
.../binders/BindCatalogItemToXmlPayload.java | 121 ++
.../binders/BindCloneParamsToXmlPayload.java | 128 ++
.../BindCloneVAppParamsToXmlPayload.java | 60 +
...BindCloneVAppTemplateParamsToXmlPayload.java | 55 +
.../BindDeployVAppParamsToXmlPayload.java | 37 +
...indDiskAttachOrDetachParamsToXmlPayload.java | 100 +
...ndGuestCustomizationSectionToXmlPayload.java | 107 ++
...stantiateVAppTemplateParamsToXmlPayload.java | 216 +++
.../vcloud/binders/BindMemoryToXmlPayload.java | 75 +
...indNetworkConnectionSectionToXmlPayload.java | 101 +
.../vcloud/binders/BindParamsToXmlPayload.java | 76 +
.../BindUndeployVAppParamsToXmlPayload.java | 37 +
.../BindVCloudNetworkAdapterToXmlPayload.java | 141 ++
.../OrgNameAndCatalogNameToEndpoint.java | 75 +
.../binders/OrgNameAndVDCNameToEndpoint.java | 74 +
.../OrgNameCatalogNameItemNameToEndpoint.java | 73 +
...meCatalogNameVAppTemplateNameToEndpoint.java | 86 +
.../OrgNameVDCNameNetworkNameToEndpoint.java | 50 +
...NameVDCNameResourceEntityNameToEndpoint.java | 50 +
.../OrgNameVDCNameResourceNameToEndpoint.java | 77 +
.../VCloudComputeServiceContextModule.java | 37 +
.../VCloudComputeServiceDependenciesModule.java | 150 ++
.../functions/FindLocationForResource.java | 66 +
.../compute/functions/HardwareForVApp.java | 68 +
.../functions/HardwareForVAppTemplate.java | 81 +
.../compute/functions/ImageForVAppTemplate.java | 79 +
.../compute/functions/VAppToNodeMetadata.java | 111 ++
...dHardwareBuilderFromResourceAllocations.java | 40 +
...EnvelopeOrThrowIllegalArgumentException.java | 71 +
.../internal/VCloudTemplateBuilderImpl.java | 45 +
.../compute/options/VCloudTemplateOptions.java | 349 ++++
...edIntoNameThenCustomizeDeployAndPowerOn.java | 497 +++++
...etworkConfigurationForNetworkAndOptions.java | 76 +
.../strategy/VCloudComputeServiceAdapter.java | 262 +++
.../vcloud/compute/util/VCloudComputeUtils.java | 112 ++
.../vcloud/config/DefaultCatalogForOrg.java | 59 +
.../vcloud/config/DefaultNetworkForVDC.java | 61 +
.../vcloud/config/DefaultOrgForUser.java | 54 +
.../vcloud/config/DefaultTasksListForOrg.java | 49 +
.../config/DefaultVCloudReferencesModule.java | 161 ++
.../jclouds/vcloud/config/DefaultVDCForOrg.java | 59 +
.../vcloud/config/VCloudHttpApiModule.java | 536 ++++++
.../jclouds/vcloud/domain/AllocationModel.java | 70 +
.../org/jclouds/vcloud/domain/Capacity.java | 106 ++
.../java/org/jclouds/vcloud/domain/Catalog.java | 66 +
.../org/jclouds/vcloud/domain/CatalogItem.java | 34 +
.../vcloud/domain/DiskAttachOrDetachParams.java | 173 ++
.../domain/GuestCustomizationSection.java | 440 +++++
.../domain/InstantiateVAppTemplateParams.java | 96 +
.../vcloud/domain/NetworkConnection.java | 231 +++
.../vcloud/domain/NetworkConnectionSection.java | 218 +++
.../java/org/jclouds/vcloud/domain/Org.java | 84 +
.../jclouds/vcloud/domain/ReferenceType.java | 52 +
.../java/org/jclouds/vcloud/domain/Status.java | 244 +++
.../java/org/jclouds/vcloud/domain/Task.java | 72 +
.../org/jclouds/vcloud/domain/TaskStatus.java | 68 +
.../org/jclouds/vcloud/domain/TasksList.java | 34 +
.../java/org/jclouds/vcloud/domain/VApp.java | 85 +
.../org/jclouds/vcloud/domain/VAppTemplate.java | 95 +
.../org/jclouds/vcloud/domain/VCloudError.java | 118 ++
.../jclouds/vcloud/domain/VCloudSession.java | 25 +
.../java/org/jclouds/vcloud/domain/VDC.java | 144 ++
.../org/jclouds/vcloud/domain/VDCStatus.java | 57 +
.../main/java/org/jclouds/vcloud/domain/Vm.java | 106 ++
.../vcloud/domain/internal/CatalogImpl.java | 189 ++
.../vcloud/domain/internal/CatalogItemImpl.java | 106 ++
.../vcloud/domain/internal/ErrorImpl.java | 114 ++
.../jclouds/vcloud/domain/internal/OrgImpl.java | 168 ++
.../domain/internal/ReferenceTypeImpl.java | 99 +
.../vcloud/domain/internal/TaskImpl.java | 160 ++
.../vcloud/domain/internal/TasksListImpl.java | 78 +
.../vcloud/domain/internal/VAppImpl.java | 163 ++
.../domain/internal/VAppTemplateImpl.java | 202 ++
.../jclouds/vcloud/domain/internal/VDCImpl.java | 289 +++
.../jclouds/vcloud/domain/internal/VmImpl.java | 214 +++
.../vcloud/domain/network/DhcpService.java | 106 ++
.../jclouds/vcloud/domain/network/Features.java | 95 +
.../vcloud/domain/network/FenceMode.java | 68 +
.../vcloud/domain/network/FirewallService.java | 86 +
.../domain/network/IpAddressAllocationMode.java | 50 +
.../jclouds/vcloud/domain/network/IpRange.java | 75 +
.../jclouds/vcloud/domain/network/IpScope.java | 169 ++
.../vcloud/domain/network/NatService.java | 115 ++
.../vcloud/domain/network/NetworkConfig.java | 163 ++
.../vcloud/domain/network/OrgNetwork.java | 119 ++
.../domain/network/firewall/FirewallPolicy.java | 53 +
.../network/firewall/FirewallProtocols.java | 71 +
.../domain/network/firewall/FirewallRule.java | 124 ++
.../domain/network/internal/OrgNetworkImpl.java | 198 ++
.../vcloud/domain/network/nat/NatPolicy.java | 53 +
.../vcloud/domain/network/nat/NatProtocol.java | 46 +
.../vcloud/domain/network/nat/NatRule.java | 33 +
.../vcloud/domain/network/nat/NatType.java | 59 +
.../domain/network/nat/rules/MappingMode.java | 53 +
.../network/nat/rules/OneToOneVmRule.java | 109 ++
.../network/nat/rules/PortForwardingRule.java | 110 ++
.../vcloud/domain/network/nat/rules/VmRule.java | 127 ++
.../EditableResourceAllocationSettingData.java | 298 +++
.../vcloud/domain/ovf/VCloudHardDisk.java | 326 ++++
.../vcloud/domain/ovf/VCloudNetworkAdapter.java | 328 ++++
.../vcloud/domain/ovf/VCloudNetworkSection.java | 80 +
.../ovf/VCloudOperatingSystemSection.java | 118 ++
.../ovf/VCloudVirtualHardwareSection.java | 179 ++
.../org/jclouds/vcloud/endpoints/Catalog.java | 34 +
.../org/jclouds/vcloud/endpoints/Network.java | 34 +
.../java/org/jclouds/vcloud/endpoints/Org.java | 34 +
.../org/jclouds/vcloud/endpoints/OrgList.java | 34 +
.../org/jclouds/vcloud/endpoints/TasksList.java | 34 +
.../jclouds/vcloud/endpoints/VCloudLogin.java | 36 +
.../java/org/jclouds/vcloud/endpoints/VDC.java | 34 +
.../org/jclouds/vcloud/features/CatalogApi.java | 143 ++
.../org/jclouds/vcloud/features/NetworkApi.java | 60 +
.../org/jclouds/vcloud/features/OrgApi.java | 84 +
.../org/jclouds/vcloud/features/TaskApi.java | 80 +
.../org/jclouds/vcloud/features/VAppApi.java | 260 +++
.../vcloud/features/VAppTemplateApi.java | 179 ++
.../org/jclouds/vcloud/features/VDCApi.java | 71 +
.../java/org/jclouds/vcloud/features/VmApi.java | 326 ++++
...ddVCloudAuthorizationAndCookieToRequest.java | 60 +
.../vcloud/functions/CatalogItemsInCatalog.java | 61 +
.../vcloud/functions/CatalogItemsInOrg.java | 54 +
.../jclouds/vcloud/functions/CatalogsInOrg.java | 69 +
.../functions/DefaultNetworkNameInTemplate.java | 47 +
.../jclouds/vcloud/functions/NetworksInOrg.java | 54 +
.../vcloud/functions/OrgNameToEndpoint.java | 53 +
.../functions/OrgNameToTasksListEndpoint.java | 58 +
.../vcloud/functions/OrgsForLocations.java | 70 +
.../jclouds/vcloud/functions/OrgsForNames.java | 53 +
.../ParseLoginResponseFromHeaders.java | 103 +
.../functions/VAppTemplatesForCatalogItems.java | 63 +
.../vcloud/functions/VAppTemplatesInOrg.java | 62 +
.../org/jclouds/vcloud/functions/VDCsInOrg.java | 54 +
.../ParseVCloudErrorFromHttpResponse.java | 118 ++
.../http/filters/VCloudBasicAuthentication.java | 58 +
.../http/filters/VCloudSupportedVersions.java | 35 +
.../jclouds/vcloud/internal/VCloudLoginApi.java | 45 +
.../org/jclouds/vcloud/loaders/OVFLoader.java | 47 +
.../vcloud/loaders/VAppTemplateLoader.java | 47 +
.../org/jclouds/vcloud/location/DefaultVDC.java | 74 +
.../location/OrgAndVDCToLocationSupplier.java | 90 +
.../vcloud/options/CaptureVAppOptions.java | 46 +
.../vcloud/options/CatalogItemOptions.java | 72 +
.../jclouds/vcloud/options/CloneOptions.java | 48 +
.../vcloud/options/CloneVAppOptions.java | 83 +
.../options/CloneVAppTemplateOptions.java | 37 +
.../options/InstantiateVAppTemplateOptions.java | 173 ++
.../jclouds/vcloud/predicates/TaskSuccess.java | 63 +
.../vcloud/reference/VCloudConstants.java | 52 +
.../jclouds/vcloud/reference/package-info.java | 20 +
...thNameMatchingConfigurationKeyOrDefault.java | 95 +
.../vcloud/suppliers/VAppTemplatesSupplier.java | 83 +
.../java/org/jclouds/vcloud/util/Utils.java | 67 +
.../org/jclouds/vcloud/util/VCloudUtils.java | 65 +
.../org/jclouds/vcloud/xml/CatalogHandler.java | 101 +
.../jclouds/vcloud/xml/CatalogItemHandler.java | 78 +
.../org/jclouds/vcloud/xml/ErrorHandler.java | 42 +
.../xml/GuestCustomizationSectionHandler.java | 134 ++
.../vcloud/xml/NetworkConnectionHandler.java | 84 +
.../xml/NetworkConnectionSectionHandler.java | 100 +
.../java/org/jclouds/vcloud/xml/OrgHandler.java | 109 ++
.../org/jclouds/vcloud/xml/OrgListHandler.java | 51 +
.../jclouds/vcloud/xml/OrgNetworkHandler.java | 322 ++++
.../vcloud/xml/SupportedVersionsHandler.java | 57 +
.../org/jclouds/vcloud/xml/TaskHandler.java | 125 ++
.../jclouds/vcloud/xml/TasksListHandler.java | 71 +
.../org/jclouds/vcloud/xml/VAppHandler.java | 148 ++
.../jclouds/vcloud/xml/VAppTemplateHandler.java | 149 ++
.../xml/VCloudVirtualHardwareHandler.java | 69 +
.../java/org/jclouds/vcloud/xml/VDCHandler.java | 164 ++
.../java/org/jclouds/vcloud/xml/VmHandler.java | 175 ++
.../xml/ovf/VCloudNetworkSectionHandler.java | 66 +
.../xml/ovf/VCloudOperatingSystemHandler.java | 78 +
...oudResourceAllocationSettingDataHandler.java | 86 +
.../services/org.jclouds.apis.ApiMetadata | 1 +
.../jclouds/vcloud/VCloudApiMetadataTest.java | 28 +
.../java/org/jclouds/vcloud/VCloudApiTest.java | 62 +
.../vcloud/VCloudSessionRefreshLiveTest.java | 39 +
.../jclouds/vcloud/VCloudVersionsApiTest.java | 68 +
.../BindCatalogItemToXmlPayloadTest.java | 51 +
.../BindCloneVAppParamsToXmlPayloadTest.java | 79 +
...CloneVAppTemplateParamsToXmlPayloadTest.java | 87 +
.../BindDeployVAppParamsToXmlPayloadTest.java | 59 +
...tiateVAppTemplateParamsToXmlPayloadTest.java | 177 ++
...etworkConnectionSectionToXmlPayloadTest.java | 66 +
.../BindUndeployVAppParamsToXmlPayloadTest.java | 59 +
.../BaseVCloudComputeServiceExpectTest.java | 158 ++
.../compute/VCloudComputeServiceLiveTest.java | 49 +
.../functions/FindLocationForResourceTest.java | 62 +
.../functions/ListImagesInVCloudExpectTest.java | 85 +
.../functions/VAppToNodeMetadataTest.java | 226 +++
.../options/VCloudTemplateOptionsTest.java | 195 ++
...ThenCustomizeDeployAndPowerOnExpectTest.java | 169 ++
.../VCloudComputeServiceAdapterTest.java | 89 +
.../vcloud/features/CatalogApiLiveTest.java | 50 +
.../jclouds/vcloud/features/CatalogApiTest.java | 129 ++
.../vcloud/features/NetworkApiLiveTest.java | 26 +
.../jclouds/vcloud/features/NetworkApiTest.java | 73 +
.../jclouds/vcloud/features/OrgApiLiveTest.java | 39 +
.../org/jclouds/vcloud/features/OrgApiTest.java | 89 +
.../vcloud/features/TaskApiLiveTest.java | 26 +
.../jclouds/vcloud/features/TaskApiTest.java | 106 ++
.../vcloud/features/VAppApiLiveTest.java | 49 +
.../jclouds/vcloud/features/VAppApiTest.java | 313 +++
.../features/VAppTemplateApiLiveTest.java | 164 ++
.../vcloud/features/VAppTemplateApiTest.java | 236 +++
.../jclouds/vcloud/features/VDCApiLiveTest.java | 26 +
.../org/jclouds/vcloud/features/VDCApiTest.java | 100 +
.../jclouds/vcloud/features/VmApiLiveTest.java | 161 ++
.../org/jclouds/vcloud/features/VmApiTest.java | 318 ++++
...loudAuthorizationAndCookieToRequestTest.java | 51 +
.../ParseLoginResponseFromHeadersTest.java | 145 ++
.../ParseVCloudErrorFromHttpResponseTest.java | 92 +
.../vcloud/internal/BasePayloadTest.java | 51 +
.../vcloud/internal/BaseVCloudApiLiveTest.java | 55 +
.../vcloud/internal/BaseVCloudApiTest.java | 270 +++
.../vcloud/internal/VCloudLoginApiTest.java | 95 +
.../InstantiateVAppTemplateOptionsTest.java | 72 +
...meMatchingConfigurationKeyOrDefaultTest.java | 113 ++
.../org/jclouds/vcloud/utils/TestUtils.java | 30 +
.../jclouds/vcloud/xml/CatalogHandlerTest.java | 133 ++
.../vcloud/xml/CatalogItemHandlerTest.java | 84 +
.../GuestCustomizationSectionHandlerTest.java | 73 +
.../xml/NetworkConnectionHandlerTest.java | 55 +
.../NetworkConnectionSectionHandlerTest.java | 61 +
.../org/jclouds/vcloud/xml/OrgHandlerTest.java | 122 ++
.../jclouds/vcloud/xml/OrgListHandlerTest.java | 55 +
.../vcloud/xml/OrgNetworkHandlerTest.java | 102 +
.../xml/SupportedVersionsHandlerTest.java | 51 +
.../org/jclouds/vcloud/xml/TaskHandlerTest.java | 133 ++
.../vcloud/xml/TasksListHandlerTest.java | 80 +
.../org/jclouds/vcloud/xml/VAppHandlerTest.java | 75 +
.../vcloud/xml/VAppTemplateHandlerTest.java | 162 ++
.../org/jclouds/vcloud/xml/VDCHandlerTest.java | 134 ++
.../org/jclouds/vcloud/xml/VmHandlerTest.java | 77 +
...VCloudOperatingSystemSectionHandlerTest.java | 59 +
...VCloudVirtualHardwareSectionHandlerTest.java | 151 ++
.../src/test/resources/captureVApp-default.xml | 1 +
.../src/test/resources/captureVApp.xml | 1 +
.../src/test/resources/catalog-blank.xml | 7 +
.../src/test/resources/catalog-hosting.xml | 25 +
.../src/test/resources/catalog.xml | 27 +
.../src/test/resources/catalog1.0-vcd15.xml | 9 +
...alogItem-carrenza-with-default-namespace.xml | 8 +
...talogItem-carrenza-with-vcloud-namespace.xml | 8 +
.../src/test/resources/catalogItem-hosting.xml | 14 +
.../test/resources/catalogItem-terremark.xml | 16 +
.../src/test/resources/catalogItem1.0-vcd15.xml | 8 +
.../src/test/resources/copyVApp-default.xml | 1 +
.../src/test/resources/copyVApp.xml | 1 +
.../test/resources/copyVAppTemplate-default.xml | 1 +
.../src/test/resources/copyVAppTemplate.xml | 1 +
.../src/test/resources/cpuItem.xml | 1 +
.../src/test/resources/guestCustomization.xml | 23 +
.../resources/guestCustomizationSection.xml | 3 +
.../src/test/resources/instantiatedvapp.xml | 13 +
.../instantiationparams-description.xml | 1 +
.../resources/instantiationparams-network.xml | 1 +
.../src/test/resources/instantiationparams.xml | 1 +
.../1.8.1-stratos/src/test/resources/log4j.xml | 151 ++
.../src/test/resources/memoryItem.xml | 1 +
.../src/test/resources/moveVApp.xml | 1 +
.../src/test/resources/moveVAppTemplate.xml | 1 +
.../src/test/resources/networkconnection.xml | 7 +
.../test/resources/networkconnectionsection.xml | 18 +
.../src/test/resources/org-1.0.xml | 24 +
.../src/test/resources/org-hosting.xml | 12 +
.../src/test/resources/org-savvis.xml | 13 +
.../1.8.1-stratos/src/test/resources/org.xml | 5 +
.../src/test/resources/org1.0-vcd15.xml | 11 +
.../src/test/resources/orgList1.0-vcd15.xml | 4 +
.../src/test/resources/orglist-savvis.xml | 3 +
.../src/test/resources/orglist.xml | 3 +
.../src/test/resources/orgnetwork-bridged.xml | 20 +
.../src/test/resources/orgnetwork-isolated.xml | 31 +
.../1.8.1-stratos/src/test/resources/os.xml | 11 +
.../src/test/resources/ovf-multi-vm.xml | 285 +++
.../src/test/resources/ovf-ubuntu64.xml | 148 ++
.../src/test/resources/task-1.0.xml | 9 +
.../src/test/resources/task-error.xml | 9 +
.../src/test/resources/task-hosting.xml | 12 +
.../src/test/resources/task-self.xml | 11 +
.../src/test/resources/task-vcd15.xml | 5 +
.../1.8.1-stratos/src/test/resources/task.xml | 8 +
.../src/test/resources/taskslist-hosting.xml | 14 +
.../src/test/resources/taskslist.xml | 27 +
.../resources/template1.0-vcd15-multi-vm.xml | 68 +
.../src/test/resources/template1.0-vcd15.xml | 72 +
.../src/test/resources/vAppTemplate-copying.xml | 41 +
.../src/test/resources/vAppTemplate.xml | 143 ++
.../vAppTemplate1.0-vcd15_withNewlines.xml | 109 ++
.../src/test/resources/vapp-hosting.xml | 235 +++
.../src/test/resources/vapp-none.xml | 237 +++
.../src/test/resources/vapp-pool.xml | 227 +++
.../src/test/resources/vapp-rhel-off-static.xml | 325 ++++
.../src/test/resources/vapp-ubuntu-off-dhcp.xml | 213 +++
.../src/test/resources/vapp-unresolved.xml | 21 +
.../src/test/resources/vapp-win-off-static.xml | 219 +++
.../src/test/resources/vdc-1.0.xml | 49 +
.../src/test/resources/vdc-hosting.xml | 60 +
.../src/test/resources/vdc-nonet.xml | 22 +
.../1.8.1-stratos/src/test/resources/vdc.xml | 36 +
.../src/test/resources/vdc1.0-vcd15.xml | 47 +
.../src/test/resources/versions-vcd15.xml | 906 +++++++++
.../src/test/resources/versions.xml | 7 +
.../test/resources/virtualhardwaresection.xml | 118 ++
.../src/test/resources/vm-rhel-off-static.xml | 197 ++
dependencies/jclouds/apis/vcloud/Readme.md | 636 +++++++
.../provider/aws-ec2/1.8.1-stratos/README.txt | 8 +
.../provider/aws-ec2/1.8.1-stratos/pom.xml | 154 ++
.../src/main/clojure/org/jclouds/aws/ec2.clj | 62 +
.../java/org/jclouds/aws/ec2/AWSEC2Api.java | 117 ++
.../org/jclouds/aws/ec2/AWSEC2ApiMetadata.java | 83 +
.../jclouds/aws/ec2/AWSEC2ProviderMetadata.java | 101 +
.../BindLaunchSpecificationToFormParams.java | 97 +
...otInstanceRequestIdsToIndexedFormParams.java | 35 +
.../BindTagFiltersToIndexedFormParams.java | 34 +
.../binders/BindTagsToIndexedFormParams.java | 34 +
.../aws/ec2/compute/AWSEC2ComputeService.java | 157 ++
.../compute/AWSEC2ComputeServiceContext.java | 28 +
.../ec2/compute/AWSEC2TemplateBuilderImpl.java | 50 +
.../aws/ec2/compute/AWSEC2TemplateOptions.java | 819 ++++++++
.../AWSEC2BindComputeSuppliersByClass.java | 31 +
.../AWSEC2ComputeServiceContextModule.java | 178 ++
.../AWSEC2ComputeServiceDependenciesModule.java | 175 ++
.../aws/ec2/compute/config/ClusterCompute.java | 34 +
.../aws/ec2/compute/config/ImageQuery.java | 34 +
.../AWSEC2SecurityGroupExtension.java | 216 +++
.../AWSEC2SecurityGroupToSecurityGroup.java | 48 +
.../AWSRunningInstanceToNodeMetadata.java | 78 +
.../PresentSpotRequestsAndInstances.java | 93 +
.../AWSEC2ComputeServiceContextImpl.java | 45 +
.../AWSEC2CreateSecurityGroupIfNeeded.java | 135 ++
.../AWSEC2CreateNodesInGroupThenAddToSet.java | 113 ++
.../strategy/AWSEC2DestroyNodeStrategy.java | 71 +
.../strategy/AWSEC2GetNodeMetadataStrategy.java | 61 +
.../strategy/AWSEC2ListNodesStrategy.java | 103 +
.../strategy/AWSEC2ReviseParsedImage.java | 116 ++
...curityGroupsAsNeededAndReturnRunOptions.java | 197 ++
.../suppliers/AWSEC2HardwareSupplier.java | 107 ++
.../compute/suppliers/AWSEC2ImageSupplier.java | 158 ++
.../ec2/compute/suppliers/CallForImages.java | 90 +
.../aws/ec2/config/AWSEC2HttpApiModule.java | 80 +
.../aws/ec2/domain/AWSRunningInstance.java | 343 ++++
.../aws/ec2/domain/LaunchSpecification.java | 580 ++++++
.../jclouds/aws/ec2/domain/MonitoringState.java | 49 +
.../jclouds/aws/ec2/domain/PlacementGroup.java | 156 ++
.../domain/RegionNameAndPublicKeyMaterial.java | 36 +
.../java/org/jclouds/aws/ec2/domain/Spot.java | 198 ++
.../aws/ec2/domain/SpotInstanceRequest.java | 470 +++++
.../org/jclouds/aws/ec2/features/AWSAMIApi.java | 124 ++
.../aws/ec2/features/AWSInstanceApi.java | 92 +
.../jclouds/aws/ec2/features/AWSKeyPairApi.java | 85 +
.../aws/ec2/features/AWSSecurityGroupApi.java | 145 ++
.../jclouds/aws/ec2/features/MonitoringApi.java | 95 +
.../aws/ec2/features/PlacementGroupApi.java | 160 ++
.../aws/ec2/features/SpotInstanceApi.java | 245 +++
.../functions/CreatePlacementGroupIfNeeded.java | 77 +
.../ImportOrReturnExistingKeypair.java | 86 +
...SpotInstanceRequestToAWSRunningInstance.java | 60 +
.../ec2/options/AWSDescribeImagesOptions.java | 151 ++
.../aws/ec2/options/AWSRunInstancesOptions.java | 307 +++
.../ec2/options/CreateSecurityGroupOptions.java | 62 +
.../DescribeSpotPriceHistoryOptions.java | 114 ++
.../options/RequestSpotInstancesOptions.java | 138 ++
.../ec2/predicates/PlacementGroupAvailable.java | 64 +
.../ec2/predicates/PlacementGroupDeleted.java | 61 +
.../predicates/SpotInstanceRequestActive.java | 70 +
.../aws/ec2/reference/AWSEC2Constants.java | 40 +
.../AWSDescribeInstancesResponseHandler.java | 109 ++
...C2DescribeSecurityGroupsResponseHandler.java | 124 ++
.../aws/ec2/xml/AWSEC2IpPermissionHandler.java | 90 +
.../aws/ec2/xml/AWSEC2SecurityGroupHandler.java | 139 ++
.../ec2/xml/AWSRunInstancesResponseHandler.java | 50 +
.../aws/ec2/xml/BaseAWSReservationHandler.java | 247 +++
.../xml/CreateSecurityGroupResponseHandler.java | 40 +
.../DescribePlacementGroupsResponseHandler.java | 72 +
...eservedInstancesOfferingResponseHandler.java | 71 +
...DescribeSpotPriceHistoryResponseHandler.java | 73 +
.../aws/ec2/xml/LaunchSpecificationHandler.java | 147 ++
.../aws/ec2/xml/MonitoringStateHandler.java | 54 +
.../aws/ec2/xml/PlacementGroupHandler.java | 66 +
.../aws/ec2/xml/ProductCodesHandler.java | 50 +
.../xml/ReservedInstancesOfferingHandler.java | 89 +
.../org/jclouds/aws/ec2/xml/SpotHandler.java | 73 +
.../aws/ec2/xml/SpotInstanceHandler.java | 148 ++
.../aws/ec2/xml/SpotInstancesHandler.java | 78 +
.../org.jclouds.providers.ProviderMetadata | 1 +
.../test/clojure/org/jclouds/aws/ec2_test.clj | 32 +
.../aws/ec2/AWSEC2ContextBuilderTest.java | 76 +
.../org/jclouds/aws/ec2/AWSEC2ProviderTest.java | 31 +
...BindLaunchSpecificationToFormParamsTest.java | 95 +
.../BindTagsToIndexedFormParamsTest.java | 61 +
.../compute/AWSEC2ComputeServiceExpectTest.java | 278 +++
.../compute/AWSEC2ComputeServiceLiveTest.java | 192 ++
.../compute/AWSEC2TemplateBuilderLiveTest.java | 363 ++++
.../AWSEC2ComputeServiceContextModuleTest.java | 62 +
.../AWSEC2ImageExtensionLiveTest.java | 59 +
.../AWSEC2SecurityGroupExtensionExpectTest.java | 414 ++++
.../AWSEC2SecurityGroupExtensionLiveTest.java | 33 +
.../AWSEC2SecurityGroupToSecurityGroupTest.java | 80 +
.../AWSRunningInstanceToNodeMetadataTest.java | 217 +++
.../PresentSpotRequestsAndInstancesTest.java | 97 +
.../BaseAWSEC2ComputeServiceExpectTest.java | 151 ++
.../AWSEC2CreateSecurityGroupIfNeededTest.java | 99 +
.../options/AWSEC2TemplateOptionsTest.java | 416 ++++
.../compute/strategy/AWSEC2ImageParserTest.java | 239 +++
.../strategy/AWSEC2ReviseParsedImageTest.java | 111 ++
...tyGroupsAsNeededAndReturnRunOptionsTest.java | 954 ++++++++++
.../aws/ec2/features/AWSAMIApiLiveTest.java | 129 ++
.../jclouds/aws/ec2/features/AWSAMIApiTest.java | 496 +++++
.../AWSElasticBlockStoreApiLiveTest.java | 68 +
.../ec2/features/AWSInstanceApiLiveTest.java | 58 +
.../aws/ec2/features/AWSInstanceApiTest.java | 537 ++++++
.../aws/ec2/features/AWSKeyPairApiLiveTest.java | 206 ++
.../aws/ec2/features/AWSKeyPairApiTest.java | 132 ++
.../features/AWSSecurityGroupApiLiveTest.java | 119 ++
.../ec2/features/AWSSecurityGroupApiTest.java | 205 ++
.../aws/ec2/features/AWSSubnetApiLiveTest.java | 27 +
.../aws/ec2/features/BaseAWSEC2ApiTest.java | 132 ++
.../aws/ec2/features/MonitoringApiLiveTest.java | 63 +
.../aws/ec2/features/MonitoringApiTest.java | 71 +
.../features/PlacementGroupApiExpectTest.java | 75 +
.../ec2/features/PlacementGroupApiLiveTest.java | 219 +++
.../aws/ec2/features/PlacementGroupApiTest.java | 134 ++
.../ec2/features/SpotInstanceApiExpectTest.java | 75 +
.../ec2/features/SpotInstanceApiLiveTest.java | 213 +++
.../aws/ec2/features/SpotInstanceApiTest.java | 98 +
.../ec2/features/TagSecurityGroupLiveTest.java | 52 +
.../ImportOrReturnExistingKeypairTest.java | 112 ++
...InstanceRequestToAWSRunningInstanceTest.java | 89 +
.../options/AWSDescribeImagesOptionsTest.java | 175 ++
.../ec2/options/AWSRunInstancesOptionsTest.java | 374 ++++
.../DescribeSpotPriceHistoryOptionsTest.java | 117 ++
.../RequestSpotInstancesOptionsTest.java | 141 ++
.../parse/DescribeInstancesResponseTest.java | 110 ++
.../DescribeSecurityGroupsResponseTest.java | 73 +
...AWSDescribeInstancesResponseHandlerTest.java | 165 ++
.../xml/AWSRunInstancesResponseHandlerTest.java | 112 ++
...cribePlacementGroupsResponseHandlerTest.java | 51 +
...vedInstancesOfferingResponseHandlerTest.java | 53 +
...ribeSpotPriceHistoryResponseHandlerTest.java | 70 +
.../aws/ec2/xml/MonitoringStateHandlerTest.java | 48 +
.../aws/ec2/xml/ProductCodesHandlerTest.java | 47 +
.../aws/ec2/xml/SpotInstanceHandlerTest.java | 136 ++
.../aws/ec2/xml/SpotInstancesHandlerTest.java | 115 ++
.../src/test/resources/alestic_canonical.xml | 119 ++
.../src/test/resources/amzn_images.xml | 86 +
.../describe_image_attribute_productCodes.xml | 9 +
.../src/test/resources/describe_images_cc.xml | 31 +
.../src/test/resources/describe_instances_1.xml | 55 +
.../src/test/resources/describe_instances_2.xml | 986 ++++++++++
.../src/test/resources/describe_instances_3.xml | 5 +
.../resources/describe_instances_latest.xml | 132 ++
.../resources/describe_instances_pending.xml | 82 +
.../resources/describe_placement_groups.xml | 10 +
.../describe_reserved_instances_offerings.xml | 15 +
.../resources/describe_security_groups_vpc.xml | 35 +
.../test/resources/describe_spot_instance.xml | 45 +
.../describe_spot_instance_requests.xml | 425 +++++
.../resources/describe_spot_instance_tags.xml | 115 ++
.../resources/describe_spot_instances_1.xml | 207 ++
.../resources/describe_spot_price_history.xml | 27 +
.../src/test/resources/monitoring.xml | 16 +
.../resources/request_spot_instances-ebs.xml | 52 +
.../test/resources/request_spot_instances.xml | 93 +
.../src/test/resources/rightscale_images.xml | 94 +
.../src/test/resources/run_instances_1.xml | 54 +
.../1.8.1-stratos/src/test/resources/vostok.xml | 19 +
dependencies/jclouds/provider/aws-ec2/Readme.md | 684 +++++++
.../jclouds/providers/aws-ec2/README.txt | 8 -
dependencies/jclouds/providers/aws-ec2/pom.xml | 174 --
.../src/main/clojure/org/jclouds/aws/ec2.clj | 62 -
.../java/org/jclouds/aws/ec2/AWSEC2Api.java | 117 --
.../org/jclouds/aws/ec2/AWSEC2ApiMetadata.java | 82 -
.../jclouds/aws/ec2/AWSEC2ProviderMetadata.java | 104 -
.../BindLaunchSpecificationToFormParams.java | 97 -
...otInstanceRequestIdsToIndexedFormParams.java | 35 -
.../BindTagFiltersToIndexedFormParams.java | 34 -
.../binders/BindTagsToIndexedFormParams.java | 34 -
.../aws/ec2/compute/AWSEC2ComputeService.java | 157 --
.../compute/AWSEC2ComputeServiceContext.java | 28 -
.../ec2/compute/AWSEC2TemplateBuilderImpl.java | 50 -
.../aws/ec2/compute/AWSEC2TemplateOptions.java | 844 ---------
.../AWSEC2BindComputeSuppliersByClass.java | 31 -
.../AWSEC2ComputeServiceContextModule.java | 178 --
.../AWSEC2ComputeServiceDependenciesModule.java | 175 --
.../aws/ec2/compute/config/ClusterCompute.java | 34 -
.../aws/ec2/compute/config/ImageQuery.java | 34 -
.../AWSEC2SecurityGroupExtension.java | 216 ---
.../AWSEC2SecurityGroupToSecurityGroup.java | 48 -
.../AWSRunningInstanceToNodeMetadata.java | 78 -
.../PresentSpotRequestsAndInstances.java | 93 -
.../AWSEC2ComputeServiceContextImpl.java | 45 -
.../AWSEC2CreateSecurityGroupIfNeeded.java | 135 --
.../AWSEC2CreateNodesInGroupThenAddToSet.java | 111 --
.../strategy/AWSEC2DestroyNodeStrategy.java | 71 -
.../strategy/AWSEC2GetNodeMetadataStrategy.java | 61 -
.../strategy/AWSEC2ListNodesStrategy.java | 103 -
.../strategy/AWSEC2ReviseParsedImage.java | 116 --
...curityGroupsAsNeededAndReturnRunOptions.java | 197 --
.../suppliers/AWSEC2HardwareSupplier.java | 151 --
.../compute/suppliers/AWSEC2ImageSupplier.java | 159 --
.../ec2/compute/suppliers/CallForImages.java | 88 -
.../aws/ec2/config/AWSEC2HttpApiModule.java | 95 -
.../aws/ec2/domain/AWSRunningInstance.java | 345 ----
.../aws/ec2/domain/LaunchSpecification.java | 581 ------
.../jclouds/aws/ec2/domain/MonitoringState.java | 49 -
.../jclouds/aws/ec2/domain/PlacementGroup.java | 156 --
.../domain/RegionNameAndPublicKeyMaterial.java | 36 -
.../java/org/jclouds/aws/ec2/domain/Spot.java | 198 --
.../aws/ec2/domain/SpotInstanceRequest.java | 528 ------
.../org/jclouds/aws/ec2/features/AWSAMIApi.java | 124 --
.../aws/ec2/features/AWSInstanceApi.java | 92 -
.../jclouds/aws/ec2/features/AWSKeyPairApi.java | 85 -
.../aws/ec2/features/AWSSecurityGroupApi.java | 145 --
.../jclouds/aws/ec2/features/MonitoringApi.java | 95 -
.../aws/ec2/features/PlacementGroupApi.java | 160 --
.../aws/ec2/features/SpotInstanceApi.java | 245 ---
.../functions/CreatePlacementGroupIfNeeded.java | 77 -
.../ImportOrReturnExistingKeypair.java | 86 -
...SpotInstanceRequestToAWSRunningInstance.java | 60 -
.../ec2/options/AWSDescribeImagesOptions.java | 151 --
.../aws/ec2/options/AWSRunInstancesOptions.java | 325 ----
.../ec2/options/CreateSecurityGroupOptions.java | 62 -
.../DescribeSpotPriceHistoryOptions.java | 114 --
.../options/RequestSpotInstancesOptions.java | 138 --
.../ec2/predicates/PlacementGroupAvailable.java | 64 -
.../ec2/predicates/PlacementGroupDeleted.java | 61 -
.../predicates/SpotInstanceRequestActive.java | 70 -
.../aws/ec2/reference/AWSEC2Constants.java | 40 -
.../AWSDescribeInstancesResponseHandler.java | 109 --
...C2DescribeSecurityGroupsResponseHandler.java | 124 --
.../aws/ec2/xml/AWSEC2IpPermissionHandler.java | 90 -
.../aws/ec2/xml/AWSEC2SecurityGroupHandler.java | 139 --
.../ec2/xml/AWSRunInstancesResponseHandler.java | 50 -
.../aws/ec2/xml/BaseAWSReservationHandler.java | 247 ---
.../xml/CreateSecurityGroupResponseHandler.java | 40 -
.../DescribePlacementGroupsResponseHandler.java | 72 -
...eservedInstancesOfferingResponseHandler.java | 71 -
...DescribeSpotPriceHistoryResponseHandler.java | 73 -
.../aws/ec2/xml/LaunchSpecificationHandler.java | 147 --
.../aws/ec2/xml/MonitoringStateHandler.java | 54 -
.../aws/ec2/xml/PlacementGroupHandler.java | 66 -
.../aws/ec2/xml/ProductCodesHandler.java | 50 -
.../xml/ReservedInstancesOfferingHandler.java | 89 -
.../org/jclouds/aws/ec2/xml/SpotHandler.java | 73 -
.../aws/ec2/xml/SpotInstanceHandler.java | 182 --
.../aws/ec2/xml/SpotInstancesHandler.java | 78 -
.../test/clojure/org/jclouds/aws/ec2_test.clj | 32 -
.../aws/ec2/AWSEC2ContextBuilderTest.java | 76 -
.../org/jclouds/aws/ec2/AWSEC2ProviderTest.java | 31 -
...BindLaunchSpecificationToFormParamsTest.java | 95 -
.../BindTagsToIndexedFormParamsTest.java | 61 -
.../AWSEC2ComputeServiceApiMockTest.java | 308 ---
.../compute/AWSEC2ComputeServiceLiveTest.java | 215 ---
.../compute/AWSEC2TemplateBuilderLiveTest.java | 362 ----
.../AWSEC2ComputeServiceContextModuleTest.java | 62 -
.../AWSEC2ImageExtensionLiveTest.java | 59 -
...AWSEC2SecurityGroupExtensionApiMockTest.java | 167 --
.../AWSEC2SecurityGroupExtensionLiveTest.java | 33 -
.../AWSEC2SecurityGroupToSecurityGroupTest.java | 80 -
.../AWSRunningInstanceToNodeMetadataTest.java | 217 ---
.../PresentSpotRequestsAndInstancesTest.java | 97 -
.../AWSEC2CreateSecurityGroupIfNeededTest.java | 99 -
.../options/AWSEC2TemplateOptionsTest.java | 428 -----
.../compute/strategy/AWSEC2ImageParserTest.java | 247 ---
.../strategy/AWSEC2ReviseParsedImageTest.java | 111 --
...tyGroupsAsNeededAndReturnRunOptionsTest.java | 952 ----------
.../aws/ec2/features/AWSAMIApiLiveTest.java | 129 --
.../aws/ec2/features/AWSAMIApiMockTest.java | 254 ---
.../AWSElasticBlockStoreApiLiveTest.java | 68 -
.../ec2/features/AWSInstanceApiLiveTest.java | 58 -
.../aws/ec2/features/AWSInstanceApiTest.java | 537 ------
.../aws/ec2/features/AWSKeyPairApiLiveTest.java | 206 --
.../aws/ec2/features/AWSKeyPairApiTest.java | 132 --
.../features/AWSSecurityGroupApiLiveTest.java | 119 --
.../ec2/features/AWSSecurityGroupApiTest.java | 196 --
.../aws/ec2/features/AWSSubnetApiLiveTest.java | 27 -
.../aws/ec2/features/BaseAWSEC2ApiTest.java | 166 --
.../aws/ec2/features/MonitoringApiLiveTest.java | 63 -
.../aws/ec2/features/MonitoringApiMockTest.java | 58 -
.../ec2/features/PlacementGroupApiLiveTest.java | 215 ---
.../ec2/features/PlacementGroupApiMockTest.java | 100 -
.../ec2/features/SpotInstanceApiLiveTest.java | 213 ---
.../ec2/features/SpotInstanceApiMockTest.java | 127 --
.../ec2/features/TagSecurityGroupLiveTest.java | 52 -
.../ImportOrReturnExistingKeypairTest.java | 112 --
...InstanceRequestToAWSRunningInstanceTest.java | 89 -
.../aws/ec2/internal/BaseAWSEC2ApiMockTest.java | 183 --
.../options/AWSDescribeImagesOptionsTest.java | 175 --
.../ec2/options/AWSRunInstancesOptionsTest.java | 386 ----
.../DescribeSpotPriceHistoryOptionsTest.java | 117 --
.../RequestSpotInstancesOptionsTest.java | 141 --
.../parse/DescribeInstancesResponseTest.java | 110 --
.../DescribeSecurityGroupsResponseTest.java | 73 -
...AWSDescribeInstancesResponseHandlerTest.java | 165 --
.../xml/AWSRunInstancesResponseHandlerTest.java | 112 --
...cribePlacementGroupsResponseHandlerTest.java | 51 -
...vedInstancesOfferingResponseHandlerTest.java | 53 -
...ribeSpotPriceHistoryResponseHandlerTest.java | 70 -
.../aws/ec2/xml/MonitoringStateHandlerTest.java | 48 -
.../aws/ec2/xml/ProductCodesHandlerTest.java | 47 -
.../aws/ec2/xml/SpotInstanceHandlerTest.java | 146 --
.../aws/ec2/xml/SpotInstancesHandlerTest.java | 115 --
.../src/test/resources/alestic_canonical.xml | 119 --
.../aws-ec2/src/test/resources/amzn_images.xml | 86 -
.../describe_image_attribute_productCodes.xml | 9 -
.../src/test/resources/describe_images_cc.xml | 31 -
.../src/test/resources/describe_instances_1.xml | 55 -
.../src/test/resources/describe_instances_2.xml | 986 ----------
.../src/test/resources/describe_instances_3.xml | 5 -
.../resources/describe_instances_latest.xml | 132 --
.../resources/describe_instances_pending.xml | 82 -
.../resources/describe_placement_groups.xml | 10 -
.../describe_placement_groups_empty.xml | 5 -
.../describe_reserved_instances_offerings.xml | 15 -
.../resources/describe_security_groups_vpc.xml | 35 -
.../test/resources/describe_spot_instance.xml | 52 -
.../describe_spot_instance_requests.xml | 425 -----
.../resources/describe_spot_instance_tags.xml | 115 --
.../resources/describe_spot_instances_1.xml | 207 --
.../resources/describe_spot_price_history.xml | 27 -
.../aws-ec2/src/test/resources/monitoring.xml | 16 -
.../resources/request_spot_instances-ebs.xml | 59 -
.../test/resources/request_spot_instances.xml | 93 -
.../src/test/resources/rightscale_images.xml | 146 --
.../src/test/resources/run_instances_1.xml | 54 -
.../aws-ec2/src/test/resources/vostok.xml | 19 -
.../providers/google-compute-engine/pom.xml | 120 --
dependencies/org.wso2.carbon.ui/pom.xml | 1 -
dependencies/pom.xml | 13 +-
.../pom.xml | 297 ++-
.../pom.xml | 4 +-
.../pom.xml | 4 +-
features/pom.xml | 2 +-
pom.xml | 3 +-
products/stratos/modules/distribution/pom.xml | 2 +-
.../distribution/src/bin/add_entry_zone_file.sh | 2 +-
.../modules/distribution/src/bin/stratos.sh | 2 +-
.../distribution/src/main/conf/axis2.xml | 22 +-
.../src/main/conf/axis2/tenant-axis2.xml | 2 +-
.../src/main/partitions/partitions.xml | 8 +-
.../src/test/resources/JMSOutputAdaptor.xml | 2 +-
1268 files changed, 113349 insertions(+), 21766 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
index a196334..0c81f60 100644
--- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
+++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
@@ -60,7 +60,7 @@ public class CartridgeAgentConstants implements Serializable {
public static final String AUTO_COMMIT = "auto.commit";
public static final String AUTO_CHECKOUT = "auto.checkout";
public static final String LISTEN_ADDRESS = "listen.address";
- public static final String PROVIDER = "provider";
+ public static final String PROVIDER = "PROVIDER";
public static final String INTERNAL = "internal";
public static final String LB_PRIVATE_IP = "lb.private.ip";
public static final String LB_PUBLIC_IP = "lb.public.ip";
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
index 3d33df2..a06cb3b 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
@@ -1374,8 +1374,7 @@ public class RestCommandLineService {
* @throws CommandException
*/
public void undeployKubernetesHost(String clusterId, String hostId) throws CommandException {
- restClient.undeployEntity(ENDPOINT_UNDEPLOY_KUBERNETES_HOST.replace("{kubernetesClusterId}", clusterId),
- "kubernetes host", hostId);
+ restClient.undeployEntity(ENDPOINT_UNDEPLOY_KUBERNETES_HOST.replace("{kubernetesClusterId}", clusterId), "kubernetes host", hostId);
}
/**
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cli/src/test/python/test_common.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/test/python/test_common.py b/components/org.apache.stratos.cli/src/test/python/test_common.py
index 4a09538..822e7f1 100755
--- a/components/org.apache.stratos.cli/src/test/python/test_common.py
+++ b/components/org.apache.stratos.cli/src/test/python/test_common.py
@@ -61,7 +61,7 @@ class TestCommon(unittest.TestCase):
child = pexpect.spawn(TestCommon.cli_cmd, timeout=10)
child.expect ('The "STRATOS_URL" variable in your environment is not a valid URL. You have provided "https://localhost"')
child.expect ('Please provide the Stratos Controller URL as follows')
- child.expect ('https://<HOST>:<port>')
+ child.expect ('https://<host>:<port>')
child.expect (pexpect.EOF)
def test_error_if_context_path_is_provided_in_stratos_url(self):
@@ -69,7 +69,7 @@ class TestCommon(unittest.TestCase):
child = pexpect.spawn(TestCommon.cli_cmd, timeout=10)
child.expect ('The "STRATOS_URL" variable in your environment is not a valid URL. You have provided "https://localhost:1234/somecontext/"')
child.expect ('Please provide the Stratos Controller URL as follows')
- child.expect ('https://<HOST>:<port>')
+ child.expect ('https://<host>:<port>')
child.expect (pexpect.EOF)
def test_error_if_non_https_scheme_is_provided_in_stratos_url(self):
@@ -77,7 +77,7 @@ class TestCommon(unittest.TestCase):
child = pexpect.spawn(TestCommon.cli_cmd, timeout=10)
child.expect ('The "STRATOS_URL" variable in your environment is not a valid URL. You have provided "http://localhost:1234"')
child.expect ('Please provide the Stratos Controller URL as follows')
- child.expect ('https://<HOST>:<port>')
+ child.expect ('https://<host>:<port>')
child.expect (pexpect.EOF)
def test_error_if_invalid_format_is_given_for_stratos_url(self):
@@ -86,7 +86,7 @@ class TestCommon(unittest.TestCase):
child = pexpect.spawn(TestCommon.cli_cmd, timeout=10)
child.expect ('The "STRATOS_URL" variable in your environment is not a valid URL. You have provided ":://"')
child.expect ('Please provide the Stratos Controller URL as follows')
- child.expect ('https://<HOST>:<port>')
+ child.expect ('https://<host>:<port>')
child.expect (pexpect.EOF)
if __name__ == '__main__':
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/pom.xml b/components/org.apache.stratos.cloud.controller/pom.xml
index 2d5dbf9..2b75e3d 100644
--- a/components/org.apache.stratos.cloud.controller/pom.xml
+++ b/components/org.apache.stratos.cloud.controller/pom.xml
@@ -19,6 +19,7 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
<parent>
<groupId>org.apache.stratos</groupId>
<artifactId>stratos-components-parent</artifactId>
@@ -37,6 +38,7 @@
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
+
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
@@ -60,10 +62,8 @@
org.wso2.carbon.utils.*,
org.apache.stratos.kubernetes.client,
org.apache.stratos.kubernetes.client.exceptions,
- org.jclouds.aws.ec2.*,
- org.jclouds.ec2.*,
- org.jclouds.compute.*,
- org.jclouds.domain.*,
+ <!--org.jclouds.compute*;version="${jclouds.version}";resolution:=optional,
+ org.jclouds*;version="${jclouds.version}",-->
*; resolution:=optional
</Import-Package>
<DynamicImport-Package>*</DynamicImport-Package>
@@ -119,7 +119,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>16.0.1</version>
+ <version>17.0</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
@@ -220,9 +220,9 @@
<version>${jclouds.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.stratos.jclouds</groupId>
+ <groupId>org.apache.stratos</groupId>
<artifactId>aws-ec2</artifactId>
- <version>${jclouds.version}</version>
+ <version>${project.jclouds.stratos.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
@@ -230,9 +230,9 @@
<version>${jclouds.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.jclouds.labs</groupId>
+ <groupId>org.apache.stratos</groupId>
<artifactId>openstack-neutron</artifactId>
- <version>${jclouds.version}</version>
+ <version>${project.jclouds.stratos.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
@@ -245,9 +245,14 @@
<version>${jclouds.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.jclouds.labs</groupId>
- <artifactId>google-compute-engine</artifactId>
- <version>${jclouds.version}</version>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>vcloud</artifactId>
+ <version>${project.jclouds.stratos.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>gce</artifactId>
+ <version>${project.jclouds.stratos.version}</version>
</dependency>
<dependency>
<groupId>com.jamesmurty.utils.wso2</groupId>
@@ -320,4 +325,5 @@
<com.google.guice.assistedinject.wso2.version>3.0.wso2v1</com.google.guice.assistedinject.wso2.version>
<sun.jersey.version>1.12</sun.jersey.version>
</properties>
-</project>
\ No newline at end of file
+</project>
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/JcloudsIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/JcloudsIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/JcloudsIaas.java
index 1815327..942fe9e 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/JcloudsIaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/JcloudsIaas.java
@@ -119,7 +119,7 @@ public abstract class JcloudsIaas extends Iaas {
Template template = getIaasProvider().getTemplate();
if (template == null) {
- String msg = "Could not start an instance, jclouds template is null for iaas provider. [type] " +
+ String msg = "Could not start an instance, jclouds template is null for iaas provider [type]: " +
getIaasProvider().getType();
log.error(msg);
throw new InvalidIaasProviderException(msg);
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/cloudstack/CloudStackPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/cloudstack/CloudStackPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/cloudstack/CloudStackPartitionValidator.java
index 579da5b..e487f6d 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/cloudstack/CloudStackPartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/cloudstack/CloudStackPartitionValidator.java
@@ -28,7 +28,7 @@ import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
import org.apache.stratos.cloud.controller.iaases.ec2.EC2PartitionValidator;
import org.apache.stratos.cloud.controller.services.impl.CloudControllerServiceUtil;
import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
-import org.apache.stratos.cloud.controller.util.Scope;
+import org.apache.stratos.messaging.domain.topology.Scope;
import java.util.Properties;
@@ -54,8 +54,8 @@ public class CloudStackPartitionValidator implements PartitionValidator {
Iaas updatedIaas = CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
updatedIaas.setIaasProvider(updatedIaasProvider);
- if (properties.containsKey(Scope.ZONE.toString())) {
- String zone = properties.getProperty(Scope.ZONE.toString());
+ if (properties.containsKey(Scope.zone.toString())) {
+ String zone = properties.getProperty(Scope.zone.toString());
iaas.isValidZone(null, zone);
updatedIaasProvider.setProperty(CloudControllerConstants.AVAILABILITY_ZONE, zone);
updatedIaas = CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
[13/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Task.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Task.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Task.java
new file mode 100644
index 0000000..82585d6
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Task.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.util.Date;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.internal.TaskImpl;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * Whenever the result of a request cannot be returned immediately, the server creates a Task
+ * object. Tasks owned by an object such as a vApp or vDC are contained in the Tasks element of the
+ * object’s XML representation. This element is read‐only.
+ */
+@ImplementedBy(TaskImpl.class)
+public interface Task extends ReferenceType {
+ /**
+ * The current status of the task.
+ */
+ String getOperation();
+
+ /**
+ * The current status of the task.
+ */
+ TaskStatus getStatus();
+
+ /**
+ * date and time when the task was started.
+ */
+ Date getStartTime();
+
+ /**
+ * date and time when the task completed. Does not appear for running tasks.
+ */
+ Date getEndTime();
+
+ /**
+ * date and time at which the task expires. By default, tasks expire 24 hours after their start
+ * time. Expired tasks cannot be queried.
+ */
+ Date getExpiryTime();
+
+ /**
+ * A link to the object that owns the task. For copy operations, the owner is the copy that is
+ * being created. For delete operations, the owner is the deleted object, so this element is not
+ * included. For all other operations, the owner is the object to which the request was made.
+ */
+ ReferenceType getOwner();
+
+ /**
+ * error message or related information returned by the task
+ */
+ @Nullable
+ VCloudError getError();
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java
new file mode 100644
index 0000000..68ee690
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public enum TaskStatus {
+ /**
+ * The task has completed and returned a value indicating success.
+ */
+ SUCCESS,
+ /**
+ * The task is running.
+ */
+ RUNNING,
+
+ /**
+ * The task has been queued for execution.
+ */
+ QUEUED,
+ /**
+ * The task has completed and returned a value indicating an error.
+ */
+ ERROR,
+ /**
+ * not an official status, temporarily in.
+ */
+ CANCELLED, UNRECOGNIZED;
+ public String value() {
+ return name().toLowerCase();
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static TaskStatus fromValue(String status) {
+ if ("CANCELED".equals(status.toUpperCase())) {
+ // TODO: ecloud hack
+ status = "CANCELLED";
+ } else if ("FAILED".equals(status.toUpperCase())) {
+ status = "ERROR";
+ } else if ("COMPLETED".equals(status.toUpperCase())) {
+ status = "SUCCESS";
+ }
+ try {
+ return valueOf(checkNotNull(status, "status").toUpperCase());
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/TasksList.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/TasksList.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/TasksList.java
new file mode 100644
index 0000000..6405054
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/TasksList.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.net.URI;
+import java.util.SortedSet;
+
+import org.jclouds.vcloud.domain.internal.TasksListImpl;
+
+import com.google.inject.ImplementedBy;
+
+@org.jclouds.vcloud.endpoints.TasksList
+@ImplementedBy(TasksListImpl.class)
+public interface TasksList {
+
+ URI getLocation();
+
+ SortedSet<Task> getTasks();
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VApp.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VApp.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VApp.java
new file mode 100644
index 0000000..98efea2
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VApp.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
+
+/**
+ * A VApp is the result of instantiation of a {@link VAppTemplate}. <h2>note</h2>
+ * <p/>
+ * When the {@link #getStatus} is {@link Status#UNRESOLVED}, there will be a task present for the
+ * instantiation of the VApp.
+ */
+public interface VApp extends ReferenceType {
+ /**
+ * Reference to the vdc containing this vApp.
+ *
+ * @since vcloud api 1.0
+ * @return vdc, or null if this is a version before 1.0 where the org isn't present
+ */
+ ReferenceType getVDC();
+
+ /**
+ * The creation status of the vDC
+ *
+ * @since vcloud api 1.0
+ */
+ Status getStatus();
+
+ /**
+ * optional description
+ *
+ * @since vcloud api 0.8
+ */
+ @Nullable
+ String getDescription();
+
+ /**
+ *
+ * @return true if the OVF descriptor for the template has been uploaded to the containing vDC.
+ * @since vcloud api 1.0
+ */
+ boolean isOvfDescriptorUploaded();
+
+ /**
+ * read‐only container for Task elements. Each element in the container represents a queued,
+ * running, or failed task owned by this object.
+ *
+ * @since vcloud api 1.0
+ */
+ List<Task> getTasks();
+
+ /**
+ * container for Vm elements representing virtual machines
+ *
+ * @since vcloud api 1.0
+ */
+ Set<Vm> getChildren();
+
+ /**
+ * description of the predefined vApp internal networks in this template
+ *
+ * @return null if the vApp is not yet instantiated
+ * @since vcloud api 1.0
+ */
+ @Nullable
+ VCloudNetworkSection getNetworkSection();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java
new file mode 100644
index 0000000..8fdd6fb
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.internal.VAppTemplateImpl;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * A VAppTemplate is an abstract description of a vApp. It is created when you upload an OVF package
+ * to a vDC.
+ */
+@ImplementedBy(VAppTemplateImpl.class)
+public interface VAppTemplate extends ReferenceType {
+ /**
+ * Reference to the VDC containing this template.
+ *
+ * @since vcloud api 1.0
+ * @return org, or null if this is a version before 1.0 where the vdc isn't present
+ */
+ ReferenceType getVDC();
+
+ /**
+ * @return creation status of the VAppTemplate.
+ *
+ * @since vcloud api 1.0
+ */
+ Status getStatus();
+
+ /**
+ * optional description
+ *
+ * @since vcloud api 1.0
+ */
+ @Nullable
+ String getDescription();
+
+ /**
+ * read-only container for Task elements. Each element in the container represents a queued,
+ * running, or failed task owned by this object.
+ *
+ * @since vcloud api 1.0
+ */
+ List<Task> getTasks();
+
+ /**
+ *
+ * @return true if the OVF descriptor for the template has been uploaded to the containing vDC.
+ * @since vcloud api 1.0
+ */
+ boolean isOvfDescriptorUploaded();
+
+ /**
+ * read-only identifier created on import
+ *
+ * @since vcloud api 1.0
+ */
+ @Nullable
+ String getVAppScopedLocalId();
+
+ /**
+ * container for Vm elements representing virtual machines
+ *
+ * @since vcloud api 1.0
+ */
+ Set<Vm> getChildren();
+
+ /**
+ * description of the predefined vApp internal networks in this template
+ *
+ * @return null if the vAppTemplate is still copying
+ * @since vcloud api 1.0
+ */
+ @Nullable
+ VCloudNetworkSection getNetworkSection();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudError.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudError.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudError.java
new file mode 100644
index 0000000..3fa88b6
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudError.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.internal.ErrorImpl;
+
+import com.google.inject.ImplementedBy;
+
+@ImplementedBy(ErrorImpl.class)
+public interface VCloudError {
+ public static enum MinorCode {
+ /**
+ * The request was made by a user who had insufficient rights to the object or operation.
+ */
+ ACCESS_TO_RESOURCE_IS_FORBIDDEN,
+ /**
+ * The request could not be validated or contained invalid XML.
+ */
+ BAD_REQUEST,
+ /**
+ * A conflict was detected between sections of an OVF descriptor.
+ */
+ CONFLICT,
+ /**
+ * The entity is busy
+ */
+ BUSY_ENTITY,
+ /**
+ * An attempt to instantiate a vAppTemplate or use a vAppTemplate or a Vm in a composition did
+ * not include an AllEULAsAccepted element with a value of true.
+ */
+ EULA_NOT_ACCEPTED,
+ /**
+ * Returned for any failure that cannot be matched to another minor error code.
+ */
+ INTERNAL_SERVER_ERROR,
+ /**
+ * One or more references (href attribute values) supplied in the request could not be
+ * resolved to an object.
+ */
+ INVALID_REFERENCE,
+ /**
+ * The HTTP method (GET, PUT, POST, DELETE) is not allowed for the request.
+ */
+ METHOD_NOT_ALLOWED,
+ /**
+ * One or more references (href attribute values) supplied in the request could not be
+ * resolved to an object, or the Content‐type of the request was incorrect.
+ */
+ RESOURCE_NOT_FOUND,
+ /**
+ * The request raised an exception that did not match any HTTP status code.
+ */
+ UNKNOWN,
+ /**
+ * The wrong content type was specified for the request.
+ */
+ UNSUPPORTED_MEDIA_TYPE, UNRECOGNIZED;
+
+ public static MinorCode fromValue(String minorCode) {
+ try {
+ return valueOf(checkNotNull(minorCode, "minorCode"));
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+ }
+
+ /**
+ *
+ * @return message describing the error
+ */
+ String getMessage();
+
+ /**
+ *
+ * @return matches the HTTP status code
+ */
+ int getMajorErrorCode();
+
+ /**
+ *
+ * @return error code specific to the failed operation or null if vcloud <0.9
+ */
+ @Nullable
+ MinorCode getMinorErrorCode();
+
+ /**
+ *
+ * @return optional additional information about the source of the error
+ */
+ @Nullable
+ String getVendorSpecificErrorCode();
+
+ /**
+ *
+ * @return stack trace of the error, if available. This attribute is returned only when a request
+ * is made by the system administrator.
+ */
+ String getStackTrace();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java
new file mode 100644
index 0000000..01acd91
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.util.Map;
+
+public interface VCloudSession {
+ String getVCloudToken();
+
+ Map<String, ReferenceType> getOrgs();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDC.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDC.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDC.java
new file mode 100644
index 0000000..c741d26
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDC.java
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.internal.VDCImpl;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * A vDC is a deployment environment for vApps. A Vdc element provides a user view of a vDC.
+ */
+@org.jclouds.vcloud.endpoints.VDC
+@ImplementedBy(VDCImpl.class)
+public interface VDC extends ReferenceType {
+ /**
+ * Reference to the org containing this vDC.
+ *
+ * @since vcloud api 1.0
+ * @return org, or null if this is a version before 1.0 where the org isn't present
+ */
+ ReferenceType getOrg();
+
+ /**
+ * The creation status of the vDC
+ *
+ * @since vcloud api 1.0
+ */
+ VDCStatus getStatus();
+
+ /**
+ * optional description
+ *
+ * @since vcloud api 0.8
+ */
+ @Nullable
+ String getDescription();
+
+ /**
+ * read‐only container for Task elements. Each element in the container represents a queued,
+ * running, or failed task owned by this object.
+ *
+ * @since vcloud api 1.0
+ */
+ List<Task> getTasks();
+
+ /**
+ * defines how resources are allocated by the vDC. The value of this element is set by the
+ * administrator who created the vDC. It is read‐only to users.
+ *
+ * @since vcloud api 1.0
+ */
+ AllocationModel getAllocationModel();
+
+ /**
+ * defines the storage capacity available in the vDC
+ *
+ * @since vcloud api 0.8
+ * @return null if the provider doesn't support storage capacity
+ */
+ @Nullable
+ Capacity getStorageCapacity();
+
+ /**
+ * reports CPU resource consumption in a vDC
+ *
+ * @since vcloud api 0.8
+ * @return null if the provider doesn't support cpu capacity
+ */
+ @Nullable
+ Capacity getCpuCapacity();
+
+ /**
+ * reports memory resource consumption in a vDC
+ *
+ * @since vcloud api 0.8
+ * @return null if the provider doesn't support memory capacity
+ */
+ @Nullable
+ Capacity getMemoryCapacity();
+
+ /**
+ * container for ResourceEntity elements
+ *
+ * @since vcloud api 0.8
+ */
+ Map<String, ReferenceType> getResourceEntities();
+
+ /**
+ * container for OrgNetwork elements that represent organization networks contained by the vDC
+ *
+ * @since vcloud api 0.8
+ */
+ Map<String, ReferenceType> getAvailableNetworks();
+
+ /**
+ * maximum number of virtual NICs allowed in this vDC. Defaults to 0, which specifies an
+ * unlimited number.
+ *
+ * @since vcloud api 1.0
+ */
+ int getNicQuota();
+
+ /**
+ * maximum number of OrgNetwork objects that can be deployed in this vDC. Defaults to 0, which
+ * specifies an unlimited number.
+ *
+ * @since vcloud api 1.0
+ */
+ int getNetworkQuota();
+
+ /**
+ * maximum number of virtual machines that can be deployed in this vDC. Defaults to 0, which
+ * specifies an unlimited number.
+ *
+ * @since vcloud api 0.8
+ */
+ int getVmQuota();
+
+ /**
+ * true if this vDC is enabled
+ *
+ * @since vcloud api 1.0
+ */
+ boolean isEnabled();
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDCStatus.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDCStatus.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDCStatus.java
new file mode 100644
index 0000000..81b25d9
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDCStatus.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+/**
+ * The creation status of the vDC
+ *
+ * @see VDC#getStatus
+ */
+public enum VDCStatus {
+
+ CREATION_FAILED, NOT_READY, READY, UNKNOWN, UNRECOGNIZED;
+
+ public int value() {
+ switch (this) {
+ case CREATION_FAILED:
+ return -1;
+ case NOT_READY:
+ return 0;
+ case READY:
+ return 1;
+ case UNKNOWN:
+ return 2;
+ default:
+ return 3;
+ }
+ }
+
+ public static VDCStatus fromValue(int status) {
+ switch (status) {
+ case -1:
+ return CREATION_FAILED;
+ case 0:
+ return NOT_READY;
+ case 1:
+ return READY;
+ case 2:
+ return UNKNOWN;
+ default:
+ return UNRECOGNIZED;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Vm.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Vm.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Vm.java
new file mode 100644
index 0000000..79657b1
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Vm.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.util.List;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.internal.VmImpl;
+import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
+import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * A Vm represents a virtual machine, a member of a vApp’s Children container. <h2>note</h2>
+ * <p/>
+ * When the {@link #getStatus} is {@link Status#UNRESOLVED}, there will be a task present for the
+ * instantiation of the VApp.
+ */
+@ImplementedBy(VmImpl.class)
+public interface Vm extends ReferenceType {
+ /**
+ * Reference to the {@link VApp} or {@link VAppTemplate} containing this vm.
+ *
+ * @since vcloud api 1.0
+ */
+ ReferenceType getParent();
+
+ /**
+ * @return creation status of the Vm or null, if a part of a VAppTemplate
+ *
+ * @since vcloud api 1.0
+ */
+ @Nullable
+ Status getStatus();
+
+ /**
+ * optional description
+ *
+ * @since vcloud api 0.8
+ */
+ @Nullable
+ String getDescription();
+
+ /**
+ * read‐only container for Task elements. Each element in the container represents a queued,
+ * running, or failed task owned by this object.
+ *
+ * @since vcloud api 1.0
+ */
+ List<Task> getTasks();
+
+ /**
+ * @return virtual hardware that comprises this VM, or null, if part of a vApp template
+ *
+ * @since vcloud api 1.0
+ */
+ @Nullable
+ VCloudVirtualHardwareSection getVirtualHardwareSection();
+
+ /**
+ * @return operating system on this VM, or null, if part of a vApp template
+ *
+ * @since vcloud api 1.0
+ */
+ @Nullable
+ VCloudOperatingSystemSection getOperatingSystemSection();
+
+ /**
+ * @return network connections for this VM, or null if it doesn't exist
+ *
+ * @since vcloud api 1.0
+ */
+ @Nullable
+ NetworkConnectionSection getNetworkConnectionSection();
+
+ /**
+ * @return guest customization section for this VM, or null if it doesn't exist
+ *
+ * @since vcloud api 1.0
+ */
+ @Nullable
+ GuestCustomizationSection getGuestCustomizationSection();
+
+ /**
+ * read-only identifier created on import
+ *
+ * @since vcloud api 1.0
+ */
+ @Nullable
+ String getVAppScopedLocalId();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java
new file mode 100644
index 0000000..03d1532
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * Locations of resources in vCloud
+ */
+public class CatalogImpl extends LinkedHashMap<String, ReferenceType> implements Catalog {
+
+ private final String name;
+ private final String type;
+ private final URI href;
+ private final ReferenceType org;
+ @Nullable
+ private final String description;
+ private final List<Task> tasks = Lists.newArrayList();
+ private final boolean published;
+ private final boolean readOnly;
+
+ public CatalogImpl(String name, String type, URI href, ReferenceType org, @Nullable String description,
+ Map<String, ReferenceType> contents, Iterable<Task> tasks, boolean published, boolean readOnly) {
+ this.name = checkNotNull(name, "name");
+ this.type = checkNotNull(type, "type");
+ this.org = org;// TODO: once <1.0 is killed check not null
+ this.description = description;
+ this.href = checkNotNull(href, "href");
+ putAll(checkNotNull(contents, "contents"));
+ Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
+ this.published = published;
+ this.readOnly = readOnly;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public URI getHref() {
+ return href;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ReferenceType getOrg() {
+ return org;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<Task> getTasks() {
+ return tasks;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isPublished() {
+ return published;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((href == null) ? 0 : href.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((org == null) ? 0 : org.hashCode());
+ result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.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;
+ CatalogImpl other = (CatalogImpl) obj;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (href == null) {
+ if (other.href != null)
+ return false;
+ } else if (!href.equals(other.href))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (org == null) {
+ if (other.org != null)
+ return false;
+ } else if (!org.equals(other.org))
+ return false;
+ if (tasks == null) {
+ if (other.tasks != null)
+ return false;
+ } else if (!tasks.equals(other.tasks))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ return true;
+ }
+
+ @Override
+ public int compareTo(ReferenceType o) {
+ return (this == o) ? 0 : getHref().compareTo(o.getHref());
+ }
+
+ @Override
+ public String getRelationship() {
+ throw new UnsupportedOperationException();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java
new file mode 100644
index 0000000..5cac6ab
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.ReferenceType;
+
+import com.google.common.collect.Maps;
+
+public class CatalogItemImpl extends ReferenceTypeImpl implements CatalogItem {
+
+ private final String description;
+ private final ReferenceType entity;
+ private final Map<String, String> properties = Maps.newLinkedHashMap();
+
+ public CatalogItemImpl(String name, URI id, @Nullable String description, ReferenceType entity,
+ Map<String, String> properties) {
+ super(name, VCloudMediaType.CATALOGITEM_XML, id);
+ this.description = description;
+ this.entity = checkNotNull(entity, "entity");
+ this.properties.putAll(checkNotNull(properties, "properties"));
+ }
+
+ @Override
+ public String getType() {
+ return VCloudMediaType.CATALOGITEM_XML;
+ }
+
+ public ReferenceType getEntity() {
+ return entity;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public String toString() {
+ return "CatalogItemImpl [id=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", description="
+ + getDescription() + ", entity=" + entity + ", properties=" + properties + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((entity == null) ? 0 : entity.hashCode());
+ result = prime * result + ((properties == null) ? 0 : properties.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;
+ CatalogItemImpl other = (CatalogItemImpl) obj;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (entity == null) {
+ if (other.entity != null)
+ return false;
+ } else if (!entity.equals(other.entity))
+ return false;
+ if (properties == null) {
+ if (other.properties != null)
+ return false;
+ } else if (!properties.equals(other.properties))
+ return false;
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java
new file mode 100644
index 0000000..2550f1b
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.VCloudError;
+
+public class ErrorImpl implements VCloudError {
+ private final String message;
+ private final int majorErrorCode;
+ private final MinorCode minorErrorCode;
+ @Nullable
+ private final String vendorSpecificErrorCode;
+ @Nullable
+ private final String stackTrace;
+
+ public ErrorImpl(String message, int majorErrorCode, @Nullable MinorCode minorErrorCode,
+ @Nullable String vendorSpecificErrorCode, @Nullable String stackTrace) {
+ this.message = checkNotNull(message, "message");
+ this.majorErrorCode = majorErrorCode;
+ this.minorErrorCode = minorErrorCode; // check null after 0.8 is gone
+ this.vendorSpecificErrorCode = vendorSpecificErrorCode;
+ this.stackTrace = stackTrace;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public int getMajorErrorCode() {
+ return majorErrorCode;
+ }
+
+ public MinorCode getMinorErrorCode() {
+ return minorErrorCode;
+ }
+
+ public String getVendorSpecificErrorCode() {
+ return vendorSpecificErrorCode;
+ }
+
+ public String getStackTrace() {
+ return stackTrace;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + majorErrorCode;
+ result = prime * result + ((message == null) ? 0 : message.hashCode());
+ result = prime * result + ((minorErrorCode == null) ? 0 : minorErrorCode.hashCode());
+ result = prime * result + ((stackTrace == null) ? 0 : stackTrace.hashCode());
+ result = prime * result + ((vendorSpecificErrorCode == null) ? 0 : vendorSpecificErrorCode.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ErrorImpl other = (ErrorImpl) obj;
+ if (majorErrorCode != other.majorErrorCode)
+ return false;
+ if (message == null) {
+ if (other.message != null)
+ return false;
+ } else if (!message.equals(other.message))
+ return false;
+ if (minorErrorCode == null) {
+ if (other.minorErrorCode != null)
+ return false;
+ } else if (!minorErrorCode.equals(other.minorErrorCode))
+ return false;
+ if (stackTrace == null) {
+ if (other.stackTrace != null)
+ return false;
+ } else if (!stackTrace.equals(other.stackTrace))
+ return false;
+ if (vendorSpecificErrorCode == null) {
+ if (other.vendorSpecificErrorCode != null)
+ return false;
+ } else if (!vendorSpecificErrorCode.equals(other.vendorSpecificErrorCode))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[majorErrorCode=" + majorErrorCode + ", message=" + message + ", minorErrorCode=" + minorErrorCode
+ + ", stackTrace=" + stackTrace + ", vendorSpecificErrorCode=" + vendorSpecificErrorCode + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java
new file mode 100644
index 0000000..87327d1
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+/**
+ * Locations of resources in vCloud
+ */
+public class OrgImpl extends ReferenceTypeImpl implements Org {
+ private final String fullName;
+ @Nullable
+ private final String description;
+ private final Map<String, ReferenceType> catalogs = Maps.newLinkedHashMap();
+ private final Map<String, ReferenceType> vdcs = Maps.newLinkedHashMap();
+ private final Map<String, ReferenceType> networks = Maps.newLinkedHashMap();
+ private final ReferenceType tasksList;
+ private final List<Task> tasks = Lists.newArrayList();
+
+ public OrgImpl(String name, String type, URI id, String fullName, String description,
+ Map<String, ReferenceType> catalogs, Map<String, ReferenceType> vdcs, Map<String, ReferenceType> networks,
+ @Nullable ReferenceType tasksList, Iterable<Task> tasks) {
+ super(name, type, id);
+ this.fullName = checkNotNull(fullName, "fullName");
+ this.description = description;
+ this.catalogs.putAll(checkNotNull(catalogs, "catalogs"));
+ this.vdcs.putAll(checkNotNull(vdcs, "vdcs"));
+ this.networks.putAll(checkNotNull(networks, "networks"));
+ this.tasksList = tasksList;
+ Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
+ }
+
+ @Override
+ public String getFullName() {
+ return fullName;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public Map<String, ReferenceType> getCatalogs() {
+ return catalogs;
+ }
+
+ @Override
+ public Map<String, ReferenceType> getVDCs() {
+ return vdcs;
+ }
+
+ @Override
+ public Map<String, ReferenceType> getNetworks() {
+ return networks;
+ }
+
+ @Override
+ public ReferenceType getTasksList() {
+ return tasksList;
+ }
+
+ @Override
+ public List<Task> getTasks() {
+ return tasks;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((catalogs == null) ? 0 : catalogs.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((fullName == null) ? 0 : fullName.hashCode());
+ result = prime * result + ((networks == null) ? 0 : networks.hashCode());
+ result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
+ result = prime * result + ((tasksList == null) ? 0 : tasksList.hashCode());
+ result = prime * result + ((vdcs == null) ? 0 : vdcs.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;
+ OrgImpl other = (OrgImpl) obj;
+ if (catalogs == null) {
+ if (other.catalogs != null)
+ return false;
+ } else if (!catalogs.equals(other.catalogs))
+ return false;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (fullName == null) {
+ if (other.fullName != null)
+ return false;
+ } else if (!fullName.equals(other.fullName))
+ return false;
+ if (networks == null) {
+ if (other.networks != null)
+ return false;
+ } else if (!networks.equals(other.networks))
+ return false;
+ if (tasks == null) {
+ if (other.tasks != null)
+ return false;
+ } else if (!tasks.equals(other.tasks))
+ return false;
+ if (tasksList == null) {
+ if (other.tasksList != null)
+ return false;
+ } else if (!tasksList.equals(other.tasksList))
+ return false;
+ if (vdcs == null) {
+ if (other.vdcs != null)
+ return false;
+ } else if (!vdcs.equals(other.vdcs))
+ return false;
+ return true;
+ }
+
+ @Override
+ public int compareTo(ReferenceType o) {
+ return (this == o) ? 0 : getHref().compareTo(o.getHref());
+ }
+
+ @Override
+ public String toString() {
+ return "[href=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", fullName=" + fullName
+ + ", description=" + description + ", catalogs=" + catalogs + ", networks=" + networks + ", tasksList="
+ + tasksList + ", vdcs=" + vdcs + ", tasks=" + tasks + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java
new file mode 100644
index 0000000..fa128f9
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.internal;
+
+import static com.google.common.base.Objects.equal;
+
+import java.net.URI;
+
+import org.jclouds.vcloud.domain.ReferenceType;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Location of a Rest resource
+ */
+public class ReferenceTypeImpl implements ReferenceType {
+ private final String name;
+ private final String type;
+ private final URI href;
+ private final String relationship;
+
+ public ReferenceTypeImpl(String name, String type, URI href) {
+ this.name = name;
+ this.type = type;
+ this.href = href;
+ this.relationship = null;
+ }
+
+ public ReferenceTypeImpl(String name, String type, URI href, String relationship) {
+ this.name = name;
+ this.type = type;
+ this.href = href;
+ this.relationship = relationship;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public URI getHref() {
+ return href;
+ }
+
+ @Override
+ public int compareTo(ReferenceType that) {
+ return (this == that) ? 0 : getHref().compareTo(that.getHref());
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ ReferenceTypeImpl that = ReferenceTypeImpl.class.cast(o);
+ return equal(this.href, that.href);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(href);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper("").omitNullValues().add("href", href).add("name", name).add("type", type).add("relationship", relationship);
+ }
+
+ @Override
+ public String getRelationship() {
+ return relationship;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java
new file mode 100644
index 0000000..70815a1
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Date;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.TaskStatus;
+import org.jclouds.vcloud.domain.VCloudError;
+
+import com.google.common.base.Objects;
+
+public class TaskImpl extends ReferenceTypeImpl implements Task {
+
+ private final String operation;
+ private final TaskStatus status;
+ private final Date startTime;
+ @Nullable
+ private final Date endTime;
+ @Nullable
+ private final Date expiryTime;
+ private final ReferenceType owner;
+ @Nullable
+ private final VCloudError error;
+
+ public TaskImpl(URI id, String operation, TaskStatus status, Date startTime, @Nullable Date endTime,
+ @Nullable Date expiryTime, ReferenceType owner, VCloudError error) {
+ super(null, VCloudMediaType.TASK_XML, id);
+ this.operation = operation;
+ this.status = checkNotNull(status, "status");
+ this.startTime = startTime;
+ this.endTime = endTime;
+ this.expiryTime = expiryTime;
+ this.owner = owner;
+ this.error = error;
+ }
+
+ @Override
+ public TaskStatus getStatus() {
+ return status;
+ }
+
+ @Override
+ public Date getStartTime() {
+ return startTime;
+ }
+
+ @Override
+ public ReferenceType getOwner() {
+ return owner;
+ }
+
+ @Override
+ public Date getEndTime() {
+ return endTime;
+ }
+
+ @Override
+ public VCloudError getError() {
+ return error;
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper("").omitNullValues().add("href", getHref()).add("name", getName())
+ .add("owner", owner).add("operation", operation).add("startTime", startTime).add("endTime", endTime)
+ .add("expiryTime", expiryTime).add("error", error).toString();
+ }
+
+ public Date getExpiryTime() {
+ return expiryTime;
+ }
+
+ @Override
+ public String getOperation() {
+ return operation;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
+ result = prime * result + ((error == null) ? 0 : error.hashCode());
+ result = prime * result + ((expiryTime == null) ? 0 : expiryTime.hashCode());
+ result = prime * result + ((operation == null) ? 0 : operation.hashCode());
+ result = prime * result + ((owner == null) ? 0 : owner.hashCode());
+ result = prime * result + ((startTime == null) ? 0 : startTime.hashCode());
+ result = prime * result + ((status == null) ? 0 : status.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;
+ TaskImpl other = (TaskImpl) obj;
+ if (endTime == null) {
+ if (other.endTime != null)
+ return false;
+ } else if (!endTime.equals(other.endTime))
+ return false;
+ if (error == null) {
+ if (other.error != null)
+ return false;
+ } else if (!error.equals(other.error))
+ return false;
+ if (expiryTime == null) {
+ if (other.expiryTime != null)
+ return false;
+ } else if (!expiryTime.equals(other.expiryTime))
+ return false;
+ if (operation == null) {
+ if (other.operation != null)
+ return false;
+ } else if (!operation.equals(other.operation))
+ return false;
+ if (owner == null) {
+ if (other.owner != null)
+ return false;
+ } else if (!owner.equals(other.owner))
+ return false;
+ if (startTime == null) {
+ if (other.startTime != null)
+ return false;
+ } else if (!startTime.equals(other.startTime))
+ return false;
+ if (status == null) {
+ if (other.status != null)
+ return false;
+ } else if (!status.equals(other.status))
+ return false;
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java
new file mode 100644
index 0000000..4c8b2c8
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.internal;
+
+import java.net.URI;
+import java.util.SortedSet;
+
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.TasksList;
+
+/**
+ * Locations of resources in vCloud
+ */
+public class TasksListImpl implements TasksList {
+ private final SortedSet<Task> tasks;
+ private final URI id;
+
+ public TasksListImpl(URI id, SortedSet<Task> tasks) {
+ this.id = id;
+ this.tasks = tasks;
+ }
+
+ @Override
+ public SortedSet<Task> getTasks() {
+ return tasks;
+ }
+
+ @Override
+ public URI getLocation() {
+ return id;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TasksListImpl other = (TasksListImpl) obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ if (tasks == null) {
+ if (other.tasks != null)
+ return false;
+ } else if (!tasks.equals(other.tasks))
+ return false;
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java
new file mode 100644
index 0000000..7b032bc
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+/**
+ * Locations of resources in vCloud
+ */
+public class VAppImpl extends ReferenceTypeImpl implements VApp {
+
+ private final Status status;
+ private final ReferenceType vdc;
+ @Nullable
+ private final String description;
+ private final List<Task> tasks = Lists.newArrayList();
+ private final boolean ovfDescriptorUploaded;
+ private final Set<Vm> children = Sets.newLinkedHashSet();
+ @Nullable
+ private final VCloudNetworkSection networkSection;
+
+ public VAppImpl(String name, String type, URI id, Status status, ReferenceType vdc, @Nullable String description,
+ Iterable<Task> tasks, boolean ovfDescriptorUploaded, Iterable<Vm> children,
+ @Nullable VCloudNetworkSection networkSection) {
+ super(name, type, id);
+ this.status = checkNotNull(status, "status");
+ this.vdc = vdc;// TODO: once <1.0 is killed check not null
+ this.description = description;
+ Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
+ this.ovfDescriptorUploaded = ovfDescriptorUploaded;
+ Iterables.addAll(this.children, checkNotNull(children, "children"));
+ this.networkSection = networkSection; // can be null when copying
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ReferenceType getVDC() {
+ return vdc;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<Task> getTasks() {
+ return tasks;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isOvfDescriptorUploaded() {
+ return ovfDescriptorUploaded;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<Vm> getChildren() {
+ return children;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public VCloudNetworkSection getNetworkSection() {
+ return networkSection;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + (ovfDescriptorUploaded ? 1231 : 1237);
+ result = prime * result + ((status == null) ? 0 : status.hashCode());
+ result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
+ result = prime * result + ((vdc == null) ? 0 : vdc.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;
+ VAppImpl other = (VAppImpl) obj;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (ovfDescriptorUploaded != other.ovfDescriptorUploaded)
+ return false;
+ if (vdc == null) {
+ if (other.vdc != null)
+ return false;
+ } else if (!vdc.equals(other.vdc))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[id=" + getHref() + ", name=" + getName() + ", vdc=" + vdc + ", description=" + description + ", status="
+ + status + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java
new file mode 100644
index 0000000..fa480c7
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+/**
+ * Locations of resources in vCloud
+ */
+public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate {
+
+ private final Status status;
+ private final ReferenceType vdc;
+ @Nullable
+ private final String description;
+ private final List<Task> tasks = Lists.newArrayList();
+ private final boolean ovfDescriptorUploaded;
+ private final String vAppScopedLocalId;
+ private final Set<Vm> children = Sets.newLinkedHashSet();
+ @Nullable
+ private final VCloudNetworkSection networkSection;
+
+ public VAppTemplateImpl(String name, String type, URI id, Status status, ReferenceType vdc,
+ @Nullable String description, Iterable<Task> tasks, boolean ovfDescriptorUploaded,
+ @Nullable String vAppScopedLocalId, Iterable<Vm> children,
+ @Nullable VCloudNetworkSection networkSection) {
+ super(name, type, id);
+ this.status = checkNotNull(status, "status");
+ this.vdc = vdc;// TODO: once <1.0 is killed check not null
+ this.description = description;
+ Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
+ this.vAppScopedLocalId = vAppScopedLocalId;
+ this.ovfDescriptorUploaded = ovfDescriptorUploaded;
+ Iterables.addAll(this.children, checkNotNull(children, "children"));
+ this.networkSection = networkSection; // can be null when copying
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ReferenceType getVDC() {
+ return vdc;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<Task> getTasks() {
+ return tasks;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getVAppScopedLocalId() {
+ return vAppScopedLocalId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isOvfDescriptorUploaded() {
+ return ovfDescriptorUploaded;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<Vm> getChildren() {
+ return children;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public VCloudNetworkSection getNetworkSection() {
+ return networkSection;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((children == null) ? 0 : children.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((networkSection == null) ? 0 : networkSection.hashCode());
+ result = prime * result + (ovfDescriptorUploaded ? 1231 : 1237);
+ result = prime * result + ((status == null) ? 0 : status.hashCode());
+ result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
+ result = prime * result + ((vAppScopedLocalId == null) ? 0 : vAppScopedLocalId.hashCode());
+ result = prime * result + ((vdc == null) ? 0 : vdc.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;
+ VAppTemplateImpl other = (VAppTemplateImpl) obj;
+ if (children == null) {
+ if (other.children != null)
+ return false;
+ } else if (!children.equals(other.children))
+ return false;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (networkSection == null) {
+ if (other.networkSection != null)
+ return false;
+ } else if (!networkSection.equals(other.networkSection))
+ return false;
+ if (ovfDescriptorUploaded != other.ovfDescriptorUploaded)
+ return false;
+ if (status == null) {
+ if (other.status != null)
+ return false;
+ } else if (!status.equals(other.status))
+ return false;
+ if (tasks == null) {
+ if (other.tasks != null)
+ return false;
+ } else if (!tasks.equals(other.tasks))
+ return false;
+ if (vAppScopedLocalId == null) {
+ if (other.vAppScopedLocalId != null)
+ return false;
+ } else if (!vAppScopedLocalId.equals(other.vAppScopedLocalId))
+ return false;
+ if (vdc == null) {
+ if (other.vdc != null)
+ return false;
+ } else if (!vdc.equals(other.vdc))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[id=" + getHref() + ", name=" + getName() + ", vdc=" + vdc + ", description=" + description + ", status="
+ + status + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java
new file mode 100644
index 0000000..740df72
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java
@@ -0,0 +1,289 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.AllocationModel;
+import org.jclouds.vcloud.domain.Capacity;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.domain.VDCStatus;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+/**
+ * Locations of resources in vCloud
+ */
+public class VDCImpl extends ReferenceTypeImpl implements VDC {
+
+ private final VDCStatus status;
+ private final ReferenceType org;
+ @Nullable
+ private final String description;
+ private final List<Task> tasks = Lists.newArrayList();
+ private final AllocationModel allocationModel;
+ private final Capacity storageCapacity;
+ private final Capacity cpuCapacity;
+ private final Capacity memoryCapacity;
+ private final Map<String, ReferenceType> resourceEntities = Maps.newLinkedHashMap();
+ private final Map<String, ReferenceType> availableNetworks = Maps.newLinkedHashMap();
+ private final int nicQuota;
+ private final int networkQuota;
+ private final int vmQuota;
+ private final boolean isEnabled;
+
+ public VDCImpl(String name, String type, URI id, VDCStatus status, ReferenceType org, @Nullable String description,
+ Iterable<Task> tasks, AllocationModel allocationModel, @Nullable Capacity storageCapacity,
+ @Nullable Capacity cpuCapacity, @Nullable Capacity memoryCapacity,
+ Map<String, ReferenceType> resourceEntities, Map<String, ReferenceType> availableNetworks, int nicQuota,
+ int networkQuota, int vmQuota, boolean isEnabled) {
+ super(name, type, id);
+ this.status = checkNotNull(status, "status");
+ this.org = org;// TODO: once <1.0 is killed check not null
+ this.description = description;
+ Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
+ this.allocationModel = checkNotNull(allocationModel, "allocationModel");
+ this.storageCapacity = storageCapacity;// TODO: once <1.0 is killed check not null
+ this.cpuCapacity = cpuCapacity;// TODO: once <1.0 is killed check not null
+ this.memoryCapacity = memoryCapacity;// TODO: once <1.0 is killed check not null
+ this.resourceEntities.putAll(checkNotNull(resourceEntities, "resourceEntities"));
+ this.availableNetworks.putAll(checkNotNull(availableNetworks, "availableNetworks"));
+ this.nicQuota = nicQuota;
+ this.networkQuota = networkQuota;
+ this.vmQuota = vmQuota;
+ this.isEnabled = isEnabled;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public VDCStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ReferenceType getOrg() {
+ return org;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<Task> getTasks() {
+ return tasks;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AllocationModel getAllocationModel() {
+ return allocationModel;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Capacity getStorageCapacity() {
+ return storageCapacity;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Capacity getCpuCapacity() {
+ return cpuCapacity;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Capacity getMemoryCapacity() {
+ return memoryCapacity;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map<String, ReferenceType> getResourceEntities() {
+ return resourceEntities;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map<String, ReferenceType> getAvailableNetworks() {
+ return availableNetworks;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getNicQuota() {
+ return nicQuota;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getNetworkQuota() {
+ return networkQuota;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getVmQuota() {
+ return vmQuota;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isEnabled() {
+ return isEnabled;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((allocationModel == null) ? 0 : allocationModel.hashCode());
+ result = prime * result + ((availableNetworks == null) ? 0 : availableNetworks.hashCode());
+ result = prime * result + ((cpuCapacity == null) ? 0 : cpuCapacity.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + (isEnabled ? 1231 : 1237);
+ result = prime * result + ((memoryCapacity == null) ? 0 : memoryCapacity.hashCode());
+ result = prime * result + networkQuota;
+ result = prime * result + nicQuota;
+ result = prime * result + ((org == null) ? 0 : org.hashCode());
+ result = prime * result + ((resourceEntities == null) ? 0 : resourceEntities.hashCode());
+ result = prime * result + ((status == null) ? 0 : status.hashCode());
+ result = prime * result + ((storageCapacity == null) ? 0 : storageCapacity.hashCode());
+ result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
+ result = prime * result + vmQuota;
+ 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;
+ VDCImpl other = (VDCImpl) obj;
+ if (allocationModel == null) {
+ if (other.allocationModel != null)
+ return false;
+ } else if (!allocationModel.equals(other.allocationModel))
+ return false;
+ if (availableNetworks == null) {
+ if (other.availableNetworks != null)
+ return false;
+ } else if (!availableNetworks.equals(other.availableNetworks))
+ return false;
+ if (cpuCapacity == null) {
+ if (other.cpuCapacity != null)
+ return false;
+ } else if (!cpuCapacity.equals(other.cpuCapacity))
+ return false;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (isEnabled != other.isEnabled)
+ return false;
+ if (memoryCapacity == null) {
+ if (other.memoryCapacity != null)
+ return false;
+ } else if (!memoryCapacity.equals(other.memoryCapacity))
+ return false;
+ if (networkQuota != other.networkQuota)
+ return false;
+ if (nicQuota != other.nicQuota)
+ return false;
+ if (org == null) {
+ if (other.org != null)
+ return false;
+ } else if (!org.equals(other.org))
+ return false;
+ if (resourceEntities == null) {
+ if (other.resourceEntities != null)
+ return false;
+ } else if (!resourceEntities.equals(other.resourceEntities))
+ return false;
+ if (status == null) {
+ if (other.status != null)
+ return false;
+ } else if (!status.equals(other.status))
+ return false;
+ if (storageCapacity == null) {
+ if (other.storageCapacity != null)
+ return false;
+ } else if (!storageCapacity.equals(other.storageCapacity))
+ return false;
+ if (tasks == null) {
+ if (other.tasks != null)
+ return false;
+ } else if (!tasks.equals(other.tasks))
+ return false;
+ if (vmQuota != other.vmQuota)
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[id=" + getHref() + ", name=" + getName() + ", org=" + org + ", description=" + description + ", status="
+ + status + ", isEnabled=" + isEnabled + "]";
+ }
+
+}
[49/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/README.txt
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/README.txt b/dependencies/jclouds/apis/gce/1.8.1-stratos/README.txt
new file mode 100644
index 0000000..0801104
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/README.txt
@@ -0,0 +1,77 @@
+======
+Stratos GCE provider 1.8.1
+======
+
+This code in Stratos is copied from Jclouds GCE [1]
+The jclouds GCE code has 2 directories oauth & google-compute-engine
+In Stratos, these two directories are mered into one.
+
+[1] https://github.com/jclouds/jclouds-labs-google/tree/jclouds-labs-google-1.8.1
+
+
+
+
+======
+jclouds Google Compute Engine Provider
+======
+
+
+Authenticating into the instances:
+--------
+
+User:
+If no user is provided in GoogleComputeEngineTemplateOptions when launching an instance by default "jclouds" is used.
+
+Credential:
+
+GCE uses exclusively ssh keys to login into instances.
+In order for an instance to be sshable a public key must be installed. Public keys are installed if they are present in the project or instance's metatada.
+
+For an instance to be ssable one of the following must happen:
+1 - the project's metadata has an adequately built "sshKeys" entry and a corresponding private key is provided in GoogleComputeEngineTemplateOptions when createNodesInGroup is called.
+2 - an instance of GoogleComputeEngineTemplateOptions with an adequate public and private key is provided.
+
+NOTE: if methods 2 is chosen the global project keys will not be installed in the instance.
+
+Please refer to Google's documentation on how to form valid project wide ssh keys metadata entries.
+
+FAQ:
+--------
+
+* Q. What is the identity for GCE?
+
+A. the identity is the developer email which can be obtained from the admin GUI. Its usually something in the form: <my account id>@developer.gserviceaccount.com
+
+* Q. What is the credential for GCE
+
+A. the credential is a private key, in pem format. It can be extracted from the p12 keystore that is obtained when creating a "Service Account" (in the GUI: Google apis console > Api Access > Create another client ID > "Service Account"
+
+* Q. How to convert a p12 keystore into a pem format jclouds Google Compute Engine can handle:
+
+A.
+
+1. Convert the p12 file into pem format (it will ask for the keystore password, which is usually "notasecret"):
+ openssl pkcs12 -in <my_keystore>.p12 -out <my_keystore>.pem -nodes
+
+2. Extract only the pk and remove passphrase
+ openssl rsa -in <my_keystore>.pem -out <my_key>.pem
+
+The last file (<my_key>.pem) should contain the pk that needs to be passed to `ContextBuilder.credential()` for the provider `google-compute-engine`.
+
+
+Running the live tests:
+--------
+
+1. Place the following in your ~/.m2/settings.xml in a profile enabled when live:
+```
+ <test.google-compute-engine.identity>YOUR_ACCOUNT_NUMBER@developer.gserviceaccount.com</test.google-compute-engine.identity>
+ <test.google-compute-engine.credential>-----BEGIN RSA PRIVATE KEY-----
+MIICXgIBAAKBgQRRbRqVDtJLN1MO/xJoKqZuphDeBh5jIKueW3aNIiWs1XFcct+h
+-- this text is literally from your <my_key>.pem
+aH7xmpHSTbbXmQkuuv+z8EKijigprd/FoJpTX1f5/R+4wQ==
+-----END RSA PRIVATE KEY-----</test.google-compute-engine.credential>
+ </properties>
+```
+
+2. mvn clean install -Plive
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/pom.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/pom.xml b/dependencies/jclouds/apis/gce/1.8.1-stratos/pom.xml
new file mode 100644
index 0000000..c1a7b9d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/pom.xml
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.jclouds.labs</groupId>
+ <artifactId>jclouds-labs-google</artifactId>
+ <version>1.8.1</version>
+ </parent>
+
+ <!-- TODO: when out of labs, switch to org.jclouds.provider -->
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>gce</artifactId>
+ <version>1.8.1-stratosv1</version>
+ <name>jclouds Google Compute Engine provider</name>
+ <description>jclouds components to access GoogleCompute</description>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <jclouds.version>1.8.1</jclouds.version>
+ <test.google-compute-engine.identity>Email associated with the Google API client_id
+ </test.google-compute-engine.identity>
+ <test.google-compute-engine.credential>Private key (PKCS12 file) associated with the Google API client_id
+ </test.google-compute-engine.credential>
+ <test.google-compute-engine.api-version>v1</test.google-compute-engine.api-version>
+ <test.google-compute-engine.build-version/>
+ <test.google-compute-engine.template>imageId=debian-7-wheezy-v20131120,locationId=us-central1-a,minRam=2048
+ </test.google-compute-engine.template>
+ <jclouds.osgi.export>org.jclouds.googlecomputeengine*;version="${project.version}"</jclouds.osgi.export>
+ <jclouds.osgi.import>
+ org.jclouds.compute.internal;version="${jclouds.version}",
+ org.jclouds.rest.internal;version="${jclouds.version}",
+ org.jclouds*;version="${jclouds.version}",
+ *
+ </jclouds.osgi.import>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-core</artifactId>
+ <version>${jclouds.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-compute</artifactId>
+ <version>${jclouds.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-compute</artifactId>
+ <version>${jclouds.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-core</artifactId>
+ <version>${jclouds.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-slf4j</artifactId>
+ <version>${jclouds.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-sshj</artifactId>
+ <version>${jclouds.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <profiles>
+ <profile>
+ <id>live</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </execution>
+ <execution>
+ <id>integration</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+ <test.google-compute-engine.identity>${test.google-compute-engine.identity}
+ </test.google-compute-engine.identity>
+ <test.google-compute-engine.credential>
+ ${test.google-compute-engine.credential}
+ </test.google-compute-engine.credential>
+ <test.google-compute-engine.api-version>
+ ${test.google-compute-engine.api-version}
+ </test.google-compute-engine.api-version>
+ <test.google-compute-engine.build-version>
+ ${test.google-compute-engine.build-version}
+ </test.google-compute-engine.build-version>
+ <test.google-compute-engine.template>${test.google-compute-engine.template}
+ </test.google-compute-engine.template>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java
new file mode 100644
index 0000000..6440d91
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine;
+
+import java.io.Closeable;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+import org.jclouds.googlecomputeengine.features.AddressApi;
+import org.jclouds.googlecomputeengine.features.DiskApi;
+import org.jclouds.googlecomputeengine.features.FirewallApi;
+import org.jclouds.googlecomputeengine.features.GlobalOperationApi;
+import org.jclouds.googlecomputeengine.features.ImageApi;
+import org.jclouds.googlecomputeengine.features.InstanceApi;
+import org.jclouds.googlecomputeengine.features.MachineTypeApi;
+import org.jclouds.googlecomputeengine.features.NetworkApi;
+import org.jclouds.googlecomputeengine.features.ProjectApi;
+import org.jclouds.googlecomputeengine.features.RegionApi;
+import org.jclouds.googlecomputeengine.features.RegionOperationApi;
+import org.jclouds.googlecomputeengine.features.RouteApi;
+import org.jclouds.googlecomputeengine.features.SnapshotApi;
+import org.jclouds.googlecomputeengine.features.ZoneApi;
+import org.jclouds.googlecomputeengine.features.ZoneOperationApi;
+import org.jclouds.rest.annotations.Delegate;
+
+import com.google.common.annotations.Beta;
+
+
+/**
+ * Provides access to GoogleCompute.
+ * <p/>
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1">api doc</a>
+ */
+@Beta
+public interface GoogleComputeEngineApi extends Closeable {
+
+ /**
+ * Provides access to Address features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ AddressApi getAddressApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to Disk features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ DiskApi getDiskApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to Firewall features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ FirewallApi getFirewallApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to Global Operation features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ GlobalOperationApi getGlobalOperationApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to Image features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ ImageApi getImageApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to Instance features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ InstanceApi getInstanceApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to MachineType features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ MachineTypeApi getMachineTypeApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to Network features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ NetworkApi getNetworkApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to Project features
+ */
+ @Delegate
+ ProjectApi getProjectApi();
+
+ /**
+ * Provides access to Region features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ RegionApi getRegionApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to Region Operation features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ RegionOperationApi getRegionOperationApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to Route features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ RouteApi getRouteApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to Snapshot features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ SnapshotApi getSnapshotApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to Zone features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ ZoneApi getZoneApiForProject(@PathParam("project") String projectName);
+
+ /**
+ * Provides access to Zone Operation features
+ *
+ * @param projectName the name of the project
+ */
+ @Delegate
+ @Path("/projects/{project}")
+ ZoneOperationApi getZoneOperationApiForProject(@PathParam("project") String projectName);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadata.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadata.java
new file mode 100644
index 0000000..544a851
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadata.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine;
+
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
+import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GCE_PROVIDER_NAME;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_INTERVAL;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_TIMEOUT;
+import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE;
+import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM;
+import static org.jclouds.reflect.Reflection2.typeToken;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.googlecomputeengine.compute.config.GoogleComputeEngineServiceContextModule;
+import org.jclouds.googlecomputeengine.config.GoogleComputeEngineHttpApiModule;
+import org.jclouds.googlecomputeengine.config.GoogleComputeEngineParserModule;
+import org.jclouds.googlecomputeengine.config.OAuthModuleWithoutTypeAdapters;
+import org.jclouds.oauth.v2.config.OAuthAuthenticationModule;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+
+/**
+ * Implementation of {@link ApiMetadata} for GoogleCompute v1 API
+ */
+public class GoogleComputeEngineApiMetadata extends BaseHttpApiMetadata<GoogleComputeEngineApi> {
+
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
+ }
+
+ public GoogleComputeEngineApiMetadata() {
+ this(new Builder());
+ }
+
+ protected GoogleComputeEngineApiMetadata(Builder builder) {
+ super(builder);
+ }
+
+ public static Properties defaultProperties() {
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
+ properties.put("oauth.endpoint", "https://accounts.google.com/o/oauth2/token");
+ properties.put(AUDIENCE, "https://accounts.google.com/o/oauth2/token");
+ properties.put(SIGNATURE_OR_MAC_ALGORITHM, "RS256");
+ properties.put(PROPERTY_SESSION_INTERVAL, 3600);
+ properties.setProperty(TEMPLATE, "osFamily=DEBIAN,osVersionMatches=7\\..*,locationId=us-central1-a,loginUser=jclouds");
+ properties.put(OPERATION_COMPLETE_INTERVAL, 500);
+ properties.put(OPERATION_COMPLETE_TIMEOUT, 600000);
+ return properties;
+ }
+
+ public static class Builder extends BaseHttpApiMetadata.Builder<GoogleComputeEngineApi, Builder> {
+
+ protected Builder() {
+ id(GCE_PROVIDER_NAME)
+ .name("Google Compute Engine Api")
+ .identityName("Email associated with the Google API client_id")
+ .credentialName("Private key literal associated with the Google API client_id")
+ .documentation(URI.create("https://developers.google.com/compute/docs"))
+ .version("v1")
+ .defaultEndpoint("https://www.googleapis.com/compute/v1")
+ .defaultProperties(GoogleComputeEngineApiMetadata.defaultProperties())
+ .view(typeToken(ComputeServiceContext.class))
+ .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
+ .add(GoogleComputeEngineHttpApiModule.class)
+ .add(GoogleComputeEngineParserModule.class)
+ .add(OAuthAuthenticationModule.class)
+ .add(OAuthModuleWithoutTypeAdapters.class)
+ .add(GoogleComputeEngineServiceContextModule.class)
+ .build());
+ }
+
+ @Override
+ public GoogleComputeEngineApiMetadata build() {
+ return new GoogleComputeEngineApiMetadata(this);
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineConstants.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineConstants.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineConstants.java
new file mode 100644
index 0000000..d20ff98
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineConstants.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine;
+
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+
+import com.google.common.annotations.Beta;
+
+public final class GoogleComputeEngineConstants {
+
+ public static final String GCE_PROVIDER_NAME = "google-compute-engine";
+
+ /**
+ * The name of the project that keeps public resources.
+ */
+ public static final String GOOGLE_PROJECT = "google";
+
+ public static final String CENTOS_PROJECT = "centos-cloud";
+
+ public static final String DEBIAN_PROJECT = "debian-cloud";
+
+ public static final String COMPUTE_SCOPE = "https://www.googleapis.com/auth/compute";
+
+ public static final String COMPUTE_READONLY_SCOPE = "https://www.googleapis.com/auth/compute.readonly";
+
+ public static final String STORAGE_READONLY_SCOPE = "https://www.googleapis.com/auth/devstorage.read_only";
+
+ public static final String STORAGE_WRITEONLY_SCOPE = "https://www.googleapis.com/auth/devstorage.write_only";
+
+
+ /**
+ * The total time, in msecs, to wait for an operation to complete.
+ */
+ @Beta
+ public static final String OPERATION_COMPLETE_TIMEOUT = "jclouds.google-compute-engine.operation-complete-timeout";
+
+ /**
+ * The interval, in msecs, between calls to check whether an operation has completed.
+ */
+ @Beta
+ public static final String OPERATION_COMPLETE_INTERVAL = "jclouds.google-compute-engine.operation-complete-interval";
+
+ public static final Location GOOGLE_PROVIDER_LOCATION = new LocationBuilder().scope(LocationScope.PROVIDER).id
+ (GCE_PROVIDER_NAME).description(GCE_PROVIDER_NAME).build();
+
+
+ /**
+ * The key we look for in instance metadata for the URI for the image the instance was created from.
+ */
+ public static final String GCE_IMAGE_METADATA_KEY = "jclouds-image";
+
+ /**
+ * Metadata key to check for whether we should delete an instance's boot disk when we delete the instance.
+ */
+ public static final String GCE_DELETE_BOOT_DISK_METADATA_KEY = "jclouds-delete-boot-disk";
+
+ /**
+ * The suffix we append to auto-created boot disk names.
+ */
+ public static final String GCE_BOOT_DISK_SUFFIX = "boot-disk";
+
+ private GoogleComputeEngineConstants() {
+ throw new AssertionError("intentionally unimplemented");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java
new file mode 100644
index 0000000..3c140eb
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_INTERVAL;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_TIMEOUT;
+import static org.jclouds.util.Predicates2.retry;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+
+import org.jclouds.Constants;
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.callables.RunScriptOnNode;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.extensions.ImageExtension;
+import org.jclouds.compute.extensions.SecurityGroupExtension;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.compute.internal.BaseComputeService;
+import org.jclouds.compute.internal.PersistNodeCredentials;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
+import org.jclouds.compute.strategy.DestroyNodeStrategy;
+import org.jclouds.compute.strategy.GetImageStrategy;
+import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
+import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap;
+import org.jclouds.compute.strategy.ListNodesStrategy;
+import org.jclouds.compute.strategy.RebootNodeStrategy;
+import org.jclouds.compute.strategy.ResumeNodeStrategy;
+import org.jclouds.compute.strategy.SuspendNodeStrategy;
+import org.jclouds.domain.Credentials;
+import org.jclouds.domain.Location;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.compute.options.GoogleComputeEngineTemplateOptions;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.features.FirewallApi;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.scriptbuilder.functions.InitAdminAccess;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.Atomics;
+import com.google.common.util.concurrent.ListeningExecutorService;
+
+public class GoogleComputeEngineService extends BaseComputeService {
+
+ private final Function<Set<? extends NodeMetadata>, Set<String>> findOrphanedGroups;
+ private final GroupNamingConvention.Factory namingConvention;
+ private final GoogleComputeEngineApi api;
+ private final Supplier<String> project;
+ private final Predicate<AtomicReference<Operation>> operationDonePredicate;
+ private final long operationCompleteCheckInterval;
+ private final long operationCompleteCheckTimeout;
+
+ @Inject
+ protected GoogleComputeEngineService(ComputeServiceContext context,
+ Map<String, Credentials> credentialStore,
+ @Memoized Supplier<Set<? extends Image>> images,
+ @Memoized Supplier<Set<? extends Hardware>> hardwareProfiles,
+ @Memoized Supplier<Set<? extends Location>> locations,
+ ListNodesStrategy listNodesStrategy,
+ GetImageStrategy getImageStrategy,
+ GetNodeMetadataStrategy getNodeMetadataStrategy,
+ CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
+ RebootNodeStrategy rebootNodeStrategy,
+ DestroyNodeStrategy destroyNodeStrategy,
+ ResumeNodeStrategy resumeNodeStrategy,
+ SuspendNodeStrategy suspendNodeStrategy,
+ Provider<TemplateBuilder> templateBuilderProvider,
+ @Named("DEFAULT") Provider<TemplateOptions> templateOptionsProvider,
+ @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>>
+ nodeRunning,
+ @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>>
+ nodeTerminated,
+ @Named(TIMEOUT_NODE_SUSPENDED)
+ Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
+ InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
+ InitAdminAccess initAdminAccess,
+ RunScriptOnNode.Factory runScriptOnNodeFactory,
+ PersistNodeCredentials persistNodeCredentials,
+ ComputeServiceConstants.Timeouts timeouts,
+ @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
+ Optional<ImageExtension> imageExtension,
+ Optional<SecurityGroupExtension> securityGroupExtension,
+ Function<Set<? extends NodeMetadata>, Set<String>> findOrphanedGroups,
+ GroupNamingConvention.Factory namingConvention,
+ GoogleComputeEngineApi api,
+ @UserProject Supplier<String> project,
+ @Named("global") Predicate<AtomicReference<Operation>> operationDonePredicate,
+ @Named(OPERATION_COMPLETE_INTERVAL) Long operationCompleteCheckInterval,
+ @Named(OPERATION_COMPLETE_TIMEOUT) Long operationCompleteCheckTimeout) {
+
+ super(context, credentialStore, images, hardwareProfiles, locations, listNodesStrategy, getImageStrategy,
+ getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
+ resumeNodeStrategy, suspendNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
+ nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory,
+ persistNodeCredentials, timeouts, userExecutor, imageExtension, securityGroupExtension);
+ this.findOrphanedGroups = checkNotNull(findOrphanedGroups, "find orphaned groups function");
+ this.namingConvention = checkNotNull(namingConvention, "naming convention factory");
+ this.api = checkNotNull(api, "google compute api");
+ this.project = checkNotNull(project, "user project name");
+ this.operationDonePredicate = checkNotNull(operationDonePredicate, "operation completed predicate");
+ this.operationCompleteCheckInterval = checkNotNull(operationCompleteCheckInterval,
+ "operation completed check interval");
+ this.operationCompleteCheckTimeout = checkNotNull(operationCompleteCheckTimeout,
+ "operation completed check timeout");
+ }
+
+ @Override
+ protected synchronized void cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes) {
+ Set<String> orphanedGroups = findOrphanedGroups.apply(deadNodes);
+ for (String orphanedGroup : orphanedGroups) {
+ cleanUpNetworksAndFirewallsForGroup(orphanedGroup);
+ }
+ }
+
+
+ protected void cleanUpNetworksAndFirewallsForGroup(final String groupName) {
+ String resourceName = namingConvention.create().sharedNameForGroup(groupName);
+ final Network network = api.getNetworkApiForProject(project.get()).get(resourceName);
+ FirewallApi firewallApi = api.getFirewallApiForProject(project.get());
+ Predicate<Firewall> firewallBelongsToNetwork = new Predicate<Firewall>() {
+ @Override
+ public boolean apply(Firewall input) {
+ return input != null && input.getNetwork().equals(network.getSelfLink());
+ }
+ };
+
+ Set<AtomicReference<Operation>> operations = Sets.newHashSet();
+ for (Firewall firewall : firewallApi.list().concat().filter(firewallBelongsToNetwork)) {
+ operations.add(new AtomicReference<Operation>(firewallApi.delete(firewall.getName())));
+ }
+
+ for (AtomicReference<Operation> operation : operations) {
+ retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
+ MILLISECONDS).apply(operation);
+
+ if (operation.get().getHttpError().isPresent()) {
+ HttpResponse response = operation.get().getHttpError().get();
+ logger.warn("delete orphaned firewall %s failed. Http Error Code: %d HttpError: %s",
+ operation.get().getTargetId(), response.getStatusCode(), response.getMessage());
+ }
+ }
+
+ AtomicReference<Operation> operation = Atomics.newReference(api.getNetworkApiForProject(project.get()).delete(resourceName));
+
+ retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
+ MILLISECONDS).apply(operation);
+
+ if (operation.get().getHttpError().isPresent()) {
+ HttpResponse response = operation.get().getHttpError().get();
+ logger.warn("delete orphaned network failed. Http Error Code: " + response.getStatusCode() +
+ " HttpError: " + response.getMessage());
+ }
+ }
+
+
+ /**
+ * returns template options, except of type {@link org.jclouds.googlecomputeengine.compute.options.GoogleComputeEngineTemplateOptions}.
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions templateOptions() {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.templateOptions());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java
new file mode 100644
index 0000000..3a26d34
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java
@@ -0,0 +1,439 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.Iterables.contains;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.tryFind;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.CENTOS_PROJECT;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.DEBIAN_PROJECT;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GCE_BOOT_DISK_SUFFIX;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GCE_DELETE_BOOT_DISK_METADATA_KEY;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GCE_IMAGE_METADATA_KEY;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_INTERVAL;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_TIMEOUT;
+import static org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig.Type;
+import static org.jclouds.googlecomputeengine.predicates.InstancePredicates.isBootDisk;
+import static org.jclouds.util.Predicates2.retry;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.annotation.Resource;
+import javax.inject.Named;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.ComputeServiceAdapter;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.compute.functions.FirewallTagNamingConvention;
+import org.jclouds.googlecomputeengine.compute.options.GoogleComputeEngineTemplateOptions;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Disk;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.Instance.AttachedDisk;
+import org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk;
+import org.jclouds.googlecomputeengine.domain.InstanceInZone;
+import org.jclouds.googlecomputeengine.domain.InstanceTemplate;
+import org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk;
+import org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk.Mode;
+import org.jclouds.googlecomputeengine.domain.MachineType;
+import org.jclouds.googlecomputeengine.domain.MachineTypeInZone;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.SlashEncodedIds;
+import org.jclouds.googlecomputeengine.domain.Zone;
+import org.jclouds.googlecomputeengine.features.InstanceApi;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.logging.Logger;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.primitives.Ints;
+import com.google.common.util.concurrent.Atomics;
+import com.google.common.util.concurrent.UncheckedTimeoutException;
+import com.google.inject.Inject;
+
+public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<InstanceInZone, MachineTypeInZone, Image, Zone> {
+
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ private final GoogleComputeEngineApi api;
+ private final Supplier<String> userProject;
+ private final Supplier<Map<URI, ? extends Location>> zones;
+ private final Function<TemplateOptions, ImmutableMap.Builder<String, String>> metatadaFromTemplateOptions;
+ private final Predicate<AtomicReference<Operation>> retryOperationDonePredicate;
+ private final long operationCompleteCheckInterval;
+ private final long operationCompleteCheckTimeout;
+ private final FirewallTagNamingConvention.Factory firewallTagNamingConvention;
+
+ @Inject
+ public GoogleComputeEngineServiceAdapter(GoogleComputeEngineApi api,
+ @UserProject Supplier<String> userProject,
+ Function<TemplateOptions,
+ ImmutableMap.Builder<String, String>> metatadaFromTemplateOptions,
+ @Named("zone") Predicate<AtomicReference<Operation>> operationDonePredicate,
+ @Named(OPERATION_COMPLETE_INTERVAL) Long operationCompleteCheckInterval,
+ @Named(OPERATION_COMPLETE_TIMEOUT) Long operationCompleteCheckTimeout,
+ @Memoized Supplier<Map<URI, ? extends Location>> zones,
+ FirewallTagNamingConvention.Factory firewallTagNamingConvention) {
+ this.api = checkNotNull(api, "google compute api");
+ this.userProject = checkNotNull(userProject, "user project name");
+ this.metatadaFromTemplateOptions = checkNotNull(metatadaFromTemplateOptions,
+ "metadata from template options function");
+ this.operationCompleteCheckInterval = checkNotNull(operationCompleteCheckInterval,
+ "operation completed check interval");
+ this.operationCompleteCheckTimeout = checkNotNull(operationCompleteCheckTimeout,
+ "operation completed check timeout");
+ this.retryOperationDonePredicate = retry(operationDonePredicate, operationCompleteCheckTimeout,
+ operationCompleteCheckInterval, TimeUnit.MILLISECONDS);
+ this.zones = checkNotNull(zones, "zones");
+ this.firewallTagNamingConvention = checkNotNull(firewallTagNamingConvention, "firewallTagNamingConvention");
+ }
+
+ @Override
+ public NodeAndInitialCredentials<InstanceInZone> createNodeWithGroupEncodedIntoName(
+ final String group, final String name, final Template template) {
+
+ checkNotNull(template, "template");
+
+ GoogleComputeEngineTemplateOptions options = GoogleComputeEngineTemplateOptions.class.cast(template.getOptions()).clone();
+ checkState(options.getNetwork().isPresent(), "network was not present in template options");
+ Hardware hardware = checkNotNull(template.getHardware(), "hardware must be set");
+
+ checkNotNull(hardware.getUri(), "hardware must have a URI");
+ checkNotNull(template.getImage().getUri(), "image URI is null");
+
+ // Note that the ordering is significant here - the first disk must be the boot disk.
+ List<PersistentDisk> disks = Lists.newArrayList();
+
+ if (!tryFind(options.getDisks(), isBootDisk()).isPresent()) {
+ Disk bootDisk = createBootDisk(template, name);
+
+ disks.add(new PersistentDisk(Mode.READ_WRITE,
+ bootDisk.getSelfLink(),
+ null,
+ true,
+ true));
+ }
+
+ disks.addAll(options.getDisks());
+
+ InstanceTemplate instanceTemplate = InstanceTemplate.builder()
+ .forMachineType(hardware.getUri());
+
+ if (options.isEnableNat()) {
+ instanceTemplate.addNetworkInterface(options.getNetwork().get(), Type.ONE_TO_ONE_NAT);
+ } else {
+ instanceTemplate.addNetworkInterface(options.getNetwork().get());
+ }
+
+ instanceTemplate.disks(disks);
+
+ LoginCredentials credentials = getFromImageAndOverrideIfRequired(template.getImage(), options);
+
+ ImmutableMap.Builder<String, String> metadataBuilder = metatadaFromTemplateOptions.apply(options);
+
+ metadataBuilder.put(GCE_IMAGE_METADATA_KEY, template.getImage().getUri().toString());
+
+ if (!options.shouldKeepBootDisk()) {
+ metadataBuilder.put(GCE_DELETE_BOOT_DISK_METADATA_KEY, Boolean.TRUE.toString());
+ }
+
+ instanceTemplate.metadata(metadataBuilder.build());
+ instanceTemplate.serviceAccounts(options.getServiceAccounts());
+
+ final InstanceApi instanceApi = api.getInstanceApiForProject(userProject.get());
+ final String zone = template.getLocation().getId();
+ Operation operation = instanceApi.createInZone(name, zone, instanceTemplate);
+
+ if (options.shouldBlockUntilRunning()) {
+ waitOperationDone(operation);
+ }
+
+ // some times the newly created instances are not immediately returned
+ AtomicReference<Instance> instance = Atomics.newReference();
+
+ retry(new Predicate<AtomicReference<Instance>>() {
+ @Override
+ public boolean apply(AtomicReference<Instance> input) {
+ input.set(instanceApi.getInZone(zone, name));
+ return input.get() != null;
+ }
+ }, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(instance);
+
+ if (!options.getTags().isEmpty()) {
+ Operation tagsOperation = instanceApi.setTagsInZone(zone,
+ name, options.getTags(), instance.get().getTags().getFingerprint());
+
+ waitOperationDone(tagsOperation);
+
+ retry(new Predicate<AtomicReference<Instance>>() {
+ @Override
+ public boolean apply(AtomicReference<Instance> input) {
+ input.set(instanceApi.getInZone(zone, name));
+ return input.get() != null;
+ }
+ }, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(instance);
+ }
+
+ // Add tags for security groups
+ final FirewallTagNamingConvention naming = firewallTagNamingConvention.get(group);
+ Set<String> tags = FluentIterable.from(Ints.asList(options.getInboundPorts()))
+ .transform(new Function<Integer, String>(){
+ @Override
+ public String apply(Integer input) {
+ return input != null
+ ? naming.name(input)
+ : null;
+ }
+ })
+ .toSet();
+ instanceApi.setTagsInZone(zone, instance.get().getName(), tags, instance.get().getTags().getFingerprint());
+
+ InstanceInZone instanceInZone = new InstanceInZone(instance.get(), zone);
+
+ return new NodeAndInitialCredentials<InstanceInZone>(instanceInZone, instanceInZone.slashEncode(), credentials);
+ }
+
+ private Disk createBootDisk(Template template, String instanceName) {
+ URI imageUri = template.getImage().getUri();
+
+ GoogleComputeEngineTemplateOptions options = GoogleComputeEngineTemplateOptions.class.cast(template.getOptions()).clone();
+
+ int diskSize = options.getBootDiskSize().or(10l).intValue();
+
+ String diskName = instanceName + "-" + GCE_BOOT_DISK_SUFFIX;
+
+ Operation diskOperation = api.getDiskApiForProject(userProject.get())
+ .createFromImageWithSizeInZone(imageUri.toString(),
+ diskName,
+ diskSize,
+ template.getLocation().getId());
+
+ waitOperationDone(diskOperation);
+
+ return api.getDiskApiForProject(userProject.get()).getInZone(template.getLocation().getId(),
+ diskName);
+ }
+
+ @Override
+ public Iterable<MachineTypeInZone> listHardwareProfiles() {
+ ImmutableSet.Builder<MachineTypeInZone> builder = ImmutableSet.builder();
+
+ for (final Location zone : zones.get().values()) {
+ builder.addAll(api.getMachineTypeApiForProject(userProject.get())
+ .listInZone(zone.getId())
+ .concat()
+ .filter(new Predicate<MachineType>() {
+ @Override
+ public boolean apply(MachineType input) {
+ return !input.getDeprecated().isPresent();
+ }
+ })
+ .transform(new Function<MachineType, MachineTypeInZone>() {
+
+ @Override
+ public MachineTypeInZone apply(MachineType arg0) {
+ return new MachineTypeInZone(arg0, arg0.getZone());
+ }
+ }));
+ }
+
+ return builder.build();
+ }
+
+ @Override
+ public Iterable<Image> listImages() {
+ return ImmutableSet.<Image>builder()
+ .addAll(api.getImageApiForProject(userProject.get()).list().concat())
+ .addAll(api.getImageApiForProject(DEBIAN_PROJECT).list().concat())
+ .addAll(api.getImageApiForProject(CENTOS_PROJECT).list().concat())
+ .build();
+ }
+
+ @Override
+ public Image getImage(String id) {
+ return Objects.firstNonNull(api.getImageApiForProject(userProject.get()).get(id),
+ Objects.firstNonNull(api.getImageApiForProject(DEBIAN_PROJECT).get(id),
+ api.getImageApiForProject(CENTOS_PROJECT).get(id)));
+
+ }
+
+ @Override
+ public Iterable<Zone> listLocations() {
+ return api.getZoneApiForProject(userProject.get()).list().concat();
+ }
+
+ @Override
+ public InstanceInZone getNode(String name) {
+ SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(name);
+
+ Instance instance = api.getInstanceApiForProject(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
+ slashEncodedIds.getSecondId());
+
+ return instance == null ? null : new InstanceInZone(instance, slashEncodedIds.getFirstId());
+ }
+
+ @Override
+ public Iterable<InstanceInZone> listNodes() {
+ return FluentIterable.from(zones.get().values()).transformAndConcat(new Function<Location, ImmutableSet<InstanceInZone>>() {
+ @Override
+ public ImmutableSet<InstanceInZone> apply(final Location input) {
+ return api.getInstanceApiForProject(userProject.get()).listInZone(input.getId()).concat()
+ .transform(new Function<Instance, InstanceInZone>() {
+
+ @Override
+ public InstanceInZone apply(Instance arg0) {
+ return new InstanceInZone(arg0, input.getId());
+ }
+ }).toSet();
+ }
+ }).toSet();
+ }
+
+ @Override
+ public Iterable<InstanceInZone> listNodesByIds(final Iterable<String> ids) {
+ return filter(listNodes(), new Predicate<InstanceInZone>() {
+
+ @Override
+ public boolean apply(InstanceInZone instanceInZone) {
+ return contains(ids, instanceInZone.getInstance().getName());
+ }
+ });
+ }
+
+ @Override
+ public void destroyNode(final String name) {
+ SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(name);
+ String diskName = null;
+ try {
+ Instance instance = api.getInstanceApiForProject(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
+ slashEncodedIds.getSecondId());
+ if (instance.getMetadata().getItems().get(GCE_DELETE_BOOT_DISK_METADATA_KEY).equals("true")) {
+ Optional<AttachedDisk> disk = tryFind(instance.getDisks(), new Predicate<AttachedDisk>() {
+ @Override
+ public boolean apply(AttachedDisk input) {
+ return PersistentAttachedDisk.class.isInstance(input) &&
+ PersistentAttachedDisk.class.cast(input).isBoot();
+ }
+ });
+ if (disk.isPresent()) {
+ diskName = PersistentAttachedDisk.class.cast(disk.get()).getSourceDiskName();
+ }
+ }
+ } catch (Exception e) {
+ // TODO: what exception actually gets thrown here if the instance doesn't really exist?
+ }
+ waitOperationDone(api.getInstanceApiForProject(userProject.get()).deleteInZone(slashEncodedIds.getFirstId(),
+ slashEncodedIds.getSecondId()));
+
+ if (diskName != null) {
+ waitOperationDone(api.getDiskApiForProject(userProject.get()).deleteInZone(slashEncodedIds.getFirstId(),
+ diskName));
+ }
+
+ }
+
+ @Override
+ public void rebootNode(final String name) {
+ SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(name);
+
+ waitOperationDone(api.getInstanceApiForProject(userProject.get()).resetInZone(slashEncodedIds.getFirstId(),
+ slashEncodedIds.getSecondId()));
+ }
+
+ @Override
+ public void resumeNode(String name) {
+ throw new UnsupportedOperationException("resume is not supported by GCE");
+ }
+
+ @Override
+ public void suspendNode(String name) {
+ throw new UnsupportedOperationException("suspend is not supported by GCE");
+ }
+
+ private LoginCredentials getFromImageAndOverrideIfRequired(org.jclouds.compute.domain.Image image,
+ GoogleComputeEngineTemplateOptions options) {
+ LoginCredentials defaultCredentials = image.getDefaultCredentials();
+ String[] keys = defaultCredentials.getPrivateKey().split(":");
+ String publicKey = keys[0];
+ String privateKey = keys[1];
+
+ LoginCredentials.Builder credentialsBuilder = defaultCredentials.toBuilder();
+ credentialsBuilder.privateKey(privateKey);
+
+ // LoginCredentials from image stores the public key along with the private key in the privateKey field
+ // @see GoogleComputePopulateDefaultLoginCredentialsForImageStrategy
+ // so if options doesn't have a public key set we set it from the default
+ if (options.getPublicKey() == null) {
+ options.authorizePublicKey(publicKey);
+ }
+ if (options.hasLoginPrivateKeyOption()) {
+ credentialsBuilder.privateKey(options.getPrivateKey());
+ }
+ if (options.getLoginUser() != null) {
+ credentialsBuilder.identity(options.getLoginUser());
+ }
+ if (options.hasLoginPasswordOption()) {
+ credentialsBuilder.password(options.getLoginPassword());
+ }
+ if (options.shouldAuthenticateSudo() != null) {
+ credentialsBuilder.authenticateSudo(options.shouldAuthenticateSudo());
+ }
+ LoginCredentials credentials = credentialsBuilder.build();
+ options.overrideLoginCredentials(credentials);
+ return credentials;
+ }
+
+ private void waitOperationDone(Operation operation) {
+ AtomicReference<Operation> operationRef = Atomics.newReference(operation);
+
+ // wait for the operation to complete
+ if (!retryOperationDonePredicate.apply(operationRef)) {
+ throw new UncheckedTimeoutException("operation did not reach DONE state" + operationRef.get());
+ }
+
+ // check if the operation failed
+ if (operationRef.get().getHttpError().isPresent()) {
+ HttpResponse response = operationRef.get().getHttpError().get();
+ throw new IllegalStateException("operation failed. Http Error Code: " + response.getStatusCode() +
+ " HttpError: " + response.getMessage());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/config/GoogleComputeEngineServiceContextModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/config/GoogleComputeEngineServiceContextModule.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/config/GoogleComputeEngineServiceContextModule.java
new file mode 100644
index 0000000..730c515
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/config/GoogleComputeEngineServiceContextModule.java
@@ -0,0 +1,283 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.config;
+
+import static com.google.common.collect.Iterables.transform;
+import static com.google.common.collect.Maps.uniqueIndex;
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import com.google.inject.Scopes;
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.ComputeServiceAdapter;
+import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.compute.extensions.ImageExtension;
+import org.jclouds.compute.extensions.SecurityGroupExtension;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate;
+import org.jclouds.domain.Location;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.compute.GoogleComputeEngineService;
+import org.jclouds.googlecomputeengine.compute.GoogleComputeEngineServiceAdapter;
+import org.jclouds.googlecomputeengine.compute.extensions.GoogleComputeEngineSecurityGroupExtension;
+import org.jclouds.googlecomputeengine.compute.functions.BuildInstanceMetadata;
+import org.jclouds.googlecomputeengine.compute.functions.FirewallTagNamingConvention;
+import org.jclouds.googlecomputeengine.compute.functions.FirewallToIpPermission;
+import org.jclouds.googlecomputeengine.compute.functions.GoogleComputeEngineImageToImage;
+import org.jclouds.googlecomputeengine.compute.functions.InstanceInZoneToNodeMetadata;
+import org.jclouds.googlecomputeengine.compute.functions.MachineTypeInZoneToHardware;
+import org.jclouds.googlecomputeengine.compute.functions.NetworkToSecurityGroup;
+import org.jclouds.googlecomputeengine.compute.functions.OrphanedGroupsFromDeadNodes;
+import org.jclouds.googlecomputeengine.compute.functions.RegionToLocation;
+import org.jclouds.googlecomputeengine.compute.functions.ZoneToLocation;
+import org.jclouds.googlecomputeengine.compute.loaders.FindNetworkOrCreate;
+import org.jclouds.googlecomputeengine.compute.options.GoogleComputeEngineTemplateOptions;
+import org.jclouds.googlecomputeengine.compute.predicates.AllNodesInGroupTerminated;
+import org.jclouds.googlecomputeengine.compute.strategy.CreateNodesWithGroupEncodedIntoNameThenAddToSet;
+import org.jclouds.googlecomputeengine.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
+import org.jclouds.googlecomputeengine.compute.strategy.UseNodeCredentialsButOverrideFromTemplate;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.InstanceInZone;
+import org.jclouds.googlecomputeengine.domain.MachineTypeInZone;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.domain.Region;
+import org.jclouds.googlecomputeengine.domain.Zone;
+import org.jclouds.googlecomputeengine.domain.internal.NetworkAndAddressRange;
+import org.jclouds.googlecomputeengine.functions.CreateNetworkIfNeeded;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.Injector;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+
+public class GoogleComputeEngineServiceContextModule
+ extends ComputeServiceAdapterContextModule<InstanceInZone, MachineTypeInZone, Image, Zone> {
+
+ @Override
+ protected void configure() {
+ super.configure();
+
+ bind(ComputeService.class).to(GoogleComputeEngineService.class);
+
+ bind(new TypeLiteral<ComputeServiceAdapter<InstanceInZone, MachineTypeInZone, Image, Zone>>() {})
+ .to(GoogleComputeEngineServiceAdapter.class);
+
+ bind(new TypeLiteral<Function<InstanceInZone, NodeMetadata>>() {})
+ .to(InstanceInZoneToNodeMetadata.class);
+
+ bind(new TypeLiteral<Function<MachineTypeInZone, Hardware>>() {})
+ .to(MachineTypeInZoneToHardware.class);
+
+ bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {})
+ .to(GoogleComputeEngineImageToImage.class);
+
+ bind(new TypeLiteral<Function<Region, Location>>() {
+ })
+ .to(RegionToLocation.class);
+
+ bind(new TypeLiteral<Function<Zone, Location>>() {})
+ .to(ZoneToLocation.class);
+
+ bind(new TypeLiteral<Function<Firewall, Iterable<IpPermission>>>() {})
+ .to(FirewallToIpPermission.class);
+
+ bind(new TypeLiteral<Function<Network, SecurityGroup>>() {})
+ .to(NetworkToSecurityGroup.class);
+
+ bind(new TypeLiteral<Function<TemplateOptions, ImmutableMap.Builder<String, String>>>() {})
+ .to(BuildInstanceMetadata.class);
+
+ bind(org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy.class)
+ .to(PopulateDefaultLoginCredentialsForImageStrategy.class);
+
+ bind(org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.class).to(
+ CreateNodesWithGroupEncodedIntoNameThenAddToSet.class);
+
+ bind(TemplateOptions.class).to(GoogleComputeEngineTemplateOptions.class);
+
+ bind(new TypeLiteral<Function<Set<? extends NodeMetadata>, Set<String>>>() {})
+ .to(OrphanedGroupsFromDeadNodes.class);
+
+ bind(new TypeLiteral<Predicate<String>>() {}).to(AllNodesInGroupTerminated.class);
+
+ bind(new TypeLiteral<Function<NetworkAndAddressRange, Network>>() {})
+ .to(CreateNetworkIfNeeded.class);
+
+ bind(new TypeLiteral<CacheLoader<NetworkAndAddressRange, Network>>() {})
+ .to(FindNetworkOrCreate.class);
+
+ bind(new TypeLiteral<SecurityGroupExtension>() {})
+ .to(GoogleComputeEngineSecurityGroupExtension.class);
+
+ bind(PrioritizeCredentialsFromTemplate.class).to(UseNodeCredentialsButOverrideFromTemplate.class);
+
+ install(new LocationsFromComputeServiceAdapterModule<InstanceInZone, MachineTypeInZone, Image, Zone>() {});
+
+ bind(FirewallTagNamingConvention.Factory.class).in(Scopes.SINGLETON);
+ }
+
+ @Provides
+ @Singleton
+ @Memoized
+ public Supplier<Map<URI, ? extends org.jclouds.compute.domain.Image>> provideImagesMap(
+ AtomicReference<AuthorizationException> authException,
+ final Supplier<Set<? extends org.jclouds.compute.domain.Image>> images,
+ @Named(PROPERTY_SESSION_INTERVAL) long seconds) {
+ return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
+ new Supplier<Map<URI, ? extends org.jclouds.compute.domain.Image>>() {
+ @Override
+ public Map<URI, ? extends org.jclouds.compute.domain.Image> get() {
+ return uniqueIndex(images.get(), new Function<org.jclouds.compute.domain.Image, URI>() {
+ @Override
+ public URI apply(org.jclouds.compute.domain.Image input) {
+ return input.getUri();
+ }
+ });
+ }
+ },
+ seconds, TimeUnit.SECONDS);
+ }
+
+ @Provides
+ @Singleton
+ @Memoized
+ public Supplier<Map<URI, ? extends Hardware>> provideHardwaresMap(
+ AtomicReference<AuthorizationException> authException,
+ final Supplier<Set<? extends Hardware>> hardwares,
+ @Named(PROPERTY_SESSION_INTERVAL) long seconds) {
+ return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
+ new Supplier<Map<URI, ? extends Hardware>>() {
+ @Override
+ public Map<URI, ? extends Hardware> get() {
+ return uniqueIndex(hardwares.get(), new Function<Hardware, URI>() {
+ @Override
+ public URI apply(Hardware input) {
+ return input.getUri();
+ }
+ });
+ }
+ },
+ seconds, TimeUnit.SECONDS);
+ }
+
+ @Provides
+ @Singleton
+ @Memoized
+ public Supplier<Map<URI, ? extends Location>> provideZones(
+ AtomicReference<AuthorizationException> authException,
+ final GoogleComputeEngineApi api, final Function<Zone, Location> zoneToLocation,
+ @UserProject final Supplier<String> userProject,
+ @Named(PROPERTY_SESSION_INTERVAL) long seconds) {
+ return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
+ new Supplier<Map<URI, ? extends Location>>() {
+ @Override
+ public Map<URI, ? extends Location> get() {
+ return uniqueIndex(transform(api.getZoneApiForProject(userProject.get()).list().concat(), zoneToLocation),
+ new Function<Location, URI>() {
+ @Override
+ public URI apply(Location input) {
+ return (URI) input.getMetadata().get("selfLink");
+ }
+ });
+ }
+ },
+ seconds, TimeUnit.SECONDS);
+ }
+
+ @Provides
+ @Singleton
+ @Memoized
+ public Supplier<Map<URI, Region>> provideRegions(
+ AtomicReference<AuthorizationException> authException,
+ final GoogleComputeEngineApi api,
+ @UserProject final Supplier<String> userProject,
+ @Named(PROPERTY_SESSION_INTERVAL) long seconds) {
+ return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
+ new Supplier<Map<URI, Region>>() {
+ @Override
+ public Map<URI, Region> get() {
+ return uniqueIndex(api.getRegionApiForProject(userProject.get()).list().concat(),
+ new Function<Region, URI>() {
+ @Override
+ public URI apply(Region input) {
+ return input.getSelfLink();
+ }
+ });
+ }
+ },
+ seconds, TimeUnit.SECONDS);
+ }
+
+ @Provides
+ @Singleton
+ protected LoadingCache<NetworkAndAddressRange, Network> networkMap(
+ CacheLoader<NetworkAndAddressRange, Network> in) {
+ return CacheBuilder.newBuilder().build(in);
+ }
+
+ @Override
+ protected Optional<ImageExtension> provideImageExtension(Injector i) {
+ return Optional.absent();
+ }
+
+ @Override
+ protected Optional<SecurityGroupExtension> provideSecurityGroupExtension(Injector i) {
+ return Optional.of(i.getInstance(SecurityGroupExtension.class));
+ }
+
+ @VisibleForTesting
+ public static final Map<Instance.Status, NodeMetadata.Status> toPortableNodeStatus =
+ ImmutableMap.<Instance.Status, NodeMetadata.Status>builder()
+ .put(Instance.Status.PROVISIONING, NodeMetadata.Status.PENDING)
+ .put(Instance.Status.STAGING, NodeMetadata.Status.PENDING)
+ .put(Instance.Status.RUNNING, NodeMetadata.Status.RUNNING)
+ .put(Instance.Status.STOPPING, NodeMetadata.Status.PENDING)
+ .put(Instance.Status.STOPPED, NodeMetadata.Status.SUSPENDED)
+ .put(Instance.Status.TERMINATED, NodeMetadata.Status.TERMINATED).build();
+
+ @Singleton
+ @Provides
+ protected Map<Instance.Status, NodeMetadata.Status> toPortableNodeStatus() {
+ return toPortableNodeStatus;
+ }
+}
[38/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
new file mode 100644
index 0000000..871f136
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Properties;
+
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.Instance.AttachedDisk;
+import org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk;
+import org.jclouds.googlecomputeengine.domain.InstanceTemplate;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.AttachDiskOptions;
+import org.jclouds.googlecomputeengine.options.AttachDiskOptions.DiskMode;
+import org.jclouds.googlecomputeengine.options.AttachDiskOptions.DiskType;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.inject.Module;
+
+@Test(groups = "live", testName = "InstanceApiLiveTest")
+public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private static final String INSTANCE_NETWORK_NAME = "instance-api-live-test-network";
+ private static final String INSTANCE_NAME = "instance-api-live-test-instance";
+ private static final String BOOT_DISK_NAME = INSTANCE_NAME + "-boot-disk";
+ private static final String DISK_NAME = "instance-live-test-disk";
+ private static final String IPV4_RANGE = "10.0.0.0/8";
+ private static final String METADATA_ITEM_KEY = "instanceLiveTestTestProp";
+ private static final String METADATA_ITEM_VALUE = "instanceLiveTestTestValue";
+ private static final String ATTACH_DISK_NAME = "instance-api-live-test-attach-disk";
+ private static final String ATTACH_DISK_DEVICE_NAME = "attach-disk-1";
+
+ private static final int TIME_WAIT = 600;
+
+ private InstanceTemplate instance;
+
+ @Override
+ protected GoogleComputeEngineApi create(Properties props, Iterable<Module> modules) {
+ GoogleComputeEngineApi api = super.create(props, modules);
+ URI imageUri = api.getImageApiForProject("centos-cloud")
+ .list(new ListOptions.Builder().filter("name eq centos.*"))
+ .concat()
+ .filter(new Predicate<Image>() {
+ @Override
+ public boolean apply(Image input) {
+ // filter out all deprecated images
+ return !(input.getDeprecated().isPresent() && input.getDeprecated().get().getState().isPresent());
+ }
+ })
+ .first()
+ .get()
+ .getSelfLink();
+ instance = InstanceTemplate.builder()
+ .forMachineType(getDefaultMachineTypeUrl(userProject.get()))
+ .addNetworkInterface(getNetworkUrl(userProject.get(), INSTANCE_NETWORK_NAME),
+ Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT)
+ .addMetadata("mykey", "myvalue")
+ .description("a description")
+ .addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE, getDiskUrl(userProject.get(), BOOT_DISK_NAME),
+ null, true, true)
+ .addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE, getDiskUrl(userProject.get(), DISK_NAME))
+ .image(imageUri);
+
+ return api;
+ }
+
+ private InstanceApi api() {
+ return api.getInstanceApiForProject(userProject.get());
+ }
+
+ private DiskApi diskApi() {
+ return api.getDiskApiForProject(userProject.get());
+ }
+
+ @Test(groups = "live")
+ public void testInsertInstance() {
+
+ // need to create the network first
+ assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).createInIPv4Range
+ (INSTANCE_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
+
+
+ assertZoneOperationDoneSucessfully(api.getDiskApiForProject(userProject.get())
+ .createFromImageInZone(instance.getImage().toString(),
+ BOOT_DISK_NAME,
+ DEFAULT_ZONE_NAME),
+ TIME_WAIT);
+
+
+ assertZoneOperationDoneSucessfully(diskApi().createInZone
+ ("instance-live-test-disk", 10, DEFAULT_ZONE_NAME), TIME_WAIT);
+
+ assertZoneOperationDoneSucessfully(api().createInZone(INSTANCE_NAME, DEFAULT_ZONE_NAME, instance), TIME_WAIT);
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testInsertInstance")
+ public void testGetInstance() {
+
+ Instance instance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
+ assertNotNull(instance);
+ assertInstanceEquals(instance, this.instance);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testListInstance")
+ public void testSetMetadataForInstance() {
+ Instance originalInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
+ assertZoneOperationDoneSucessfully(api().setMetadataInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME,
+ ImmutableMap.of(METADATA_ITEM_KEY, METADATA_ITEM_VALUE),
+ originalInstance.getMetadata().getFingerprint()),
+ TIME_WAIT);
+
+ Instance modifiedInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
+
+ assertTrue(modifiedInstance.getMetadata().getItems().containsKey(METADATA_ITEM_KEY));
+ assertEquals(modifiedInstance.getMetadata().getItems().get(METADATA_ITEM_KEY),
+ METADATA_ITEM_VALUE);
+ assertNotNull(modifiedInstance.getMetadata().getFingerprint());
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testSetMetadataForInstance")
+ public void testAttachDiskToInstance() {
+ assertZoneOperationDoneSucessfully(diskApi().createInZone(ATTACH_DISK_NAME, 1, DEFAULT_ZONE_NAME), TIME_WAIT);
+
+ Instance originalInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
+ assertZoneOperationDoneSucessfully(api().attachDiskInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME,
+ new AttachDiskOptions().type(DiskType.PERSISTENT)
+ .source(getDiskUrl(userProject.get(), ATTACH_DISK_NAME))
+ .mode(DiskMode.READ_ONLY)
+ .deviceName(ATTACH_DISK_DEVICE_NAME)),
+ TIME_WAIT);
+
+ Instance modifiedInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
+
+ assertTrue(modifiedInstance.getDisks().size() > originalInstance.getDisks().size());
+ assertTrue(Iterables.any(modifiedInstance.getDisks(), new Predicate<AttachedDisk>() {
+
+ @Override
+ public boolean apply(AttachedDisk disk) {
+ return disk instanceof PersistentAttachedDisk &&
+ ((PersistentAttachedDisk) disk).getDeviceName().isPresent() &&
+ ((PersistentAttachedDisk) disk).getDeviceName().get().equals(ATTACH_DISK_DEVICE_NAME);
+ }
+ }));
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testAttachDiskToInstance")
+ public void testDetachDiskFromInstance() {
+ Instance originalInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
+ assertZoneOperationDoneSucessfully(api().detachDiskInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME,
+ ATTACH_DISK_DEVICE_NAME), TIME_WAIT);
+
+ Instance modifiedInstance = api().getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME);
+
+ assertTrue(modifiedInstance.getDisks().size() < originalInstance.getDisks().size());
+
+ assertZoneOperationDoneSucessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, ATTACH_DISK_NAME), TIME_WAIT);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testInsertInstance")
+ public void testListInstance() {
+
+ PagedIterable<Instance> instances = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
+ .filter("name eq " + INSTANCE_NAME));
+
+ List<Instance> instancesAsList = Lists.newArrayList(instances.concat());
+
+ assertEquals(instancesAsList.size(), 1);
+
+ assertInstanceEquals(Iterables.getOnlyElement(instancesAsList), instance);
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testDetachDiskFromInstance")
+ public void testResetInstance() {
+ assertZoneOperationDoneSucessfully(api().resetInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME),
+ TIME_WAIT);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testResetInstance")
+ public void testDeleteInstance() {
+
+ assertZoneOperationDoneSucessfully(api().deleteInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME), TIME_WAIT);
+ assertZoneOperationDoneSucessfully(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME),
+ TIME_WAIT);
+ assertZoneOperationDoneSucessfully(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME),
+ TIME_WAIT);
+ assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).delete
+ (INSTANCE_NETWORK_NAME), TIME_WAIT);
+ }
+
+ private void assertInstanceEquals(Instance result, InstanceTemplate expected) {
+ assertEquals(result.getName(), expected.getName());
+ assertEquals(result.getMetadata().getItems(), expected.getMetadata());
+ }
+
+ @AfterClass(groups = { "integration", "live" })
+ protected void tearDownContext() {
+ try {
+ waitZoneOperationDone(api().deleteInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME), TIME_WAIT);
+ waitZoneOperationDone(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME),
+ TIME_WAIT);
+ waitZoneOperationDone(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME),
+ TIME_WAIT);
+ waitGlobalOperationDone(api.getNetworkApiForProject(userProject.get()).delete
+ (INSTANCE_NETWORK_NAME), TIME_WAIT);
+ } catch (Exception e) {
+ // we don't really care about any exception here, so just delete away.
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java
new file mode 100644
index 0000000..35dec08
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.parse.ParseMachineTypeListTest;
+import org.jclouds.googlecomputeengine.parse.ParseMachineTypeTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ public static final HttpRequest LIST_MACHINE_TYPES_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse LIST_MACHINE_TYPES_RESPONSE = HttpResponse.builder()
+ .statusCode(200)
+ .payload(staticPayloadFromResource("/machinetype_list.json"))
+ .build();
+
+ public static final HttpRequest LIST_CENTRAL1B_MACHINE_TYPES_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-b/machineTypes")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse LIST_CENTRAL1B_MACHINE_TYPES_RESPONSE = HttpResponse.builder()
+ .statusCode(200)
+ .payload(staticPayloadFromResource("/machinetype_list_central1b.json"))
+ .build();
+
+ public void testGetMachineTypeResponseIs2xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/machinetype.json")).build();
+
+ MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getMachineTypeApiForProject("myproject");
+
+ assertEquals(machineTypeApi.getInZone("us-central1-a", "n1-standard-1"),
+ new ParseMachineTypeTest().expected());
+ }
+
+ public void testGetMachineTypeResponseIs4xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getMachineTypeApiForProject("myproject");
+
+ assertNull(machineTypeApi.getInZone("us-central1-a", "n1-standard-1"));
+ }
+
+ public void testListMachineTypeNoOptionsResponseIs2xx() throws Exception {
+
+ MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE).getMachineTypeApiForProject
+ ("myproject");
+
+ assertEquals(machineTypeApi.listFirstPageInZone("us-central1-a").toString(),
+ new ParseMachineTypeListTest().expected().toString());
+ }
+
+ public void testLisOperationWithPaginationOptionsResponseIs4xx() {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, operationResponse).getMachineTypeApiForProject("myproject");
+
+ assertTrue(machineTypeApi.listInZone("us-central1-a").concat().isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java
new file mode 100644
index 0000000..d9d00a1
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.MachineType;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+public class MachineTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private MachineType machineType;
+
+ private MachineTypeApi api() {
+ return api.getMachineTypeApiForProject(userProject.get());
+ }
+
+ @Test(groups = "live")
+ public void testListMachineType() {
+
+ PagedIterable<MachineType> machineTypes = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
+ .maxResults(1));
+
+ Iterator<IterableWithMarker<MachineType>> pageIterator = machineTypes.iterator();
+ assertTrue(pageIterator.hasNext());
+
+ IterableWithMarker<MachineType> singlePageIterator = pageIterator.next();
+ List<MachineType> machineTypeAsList = Lists.newArrayList(singlePageIterator);
+
+ assertSame(machineTypeAsList.size(), 1);
+
+ this.machineType = Iterables.getOnlyElement(machineTypeAsList);
+ }
+
+
+ @Test(groups = "live", dependsOnMethods = "testListMachineType")
+ public void testGetMachineType() {
+ MachineType machineType = api().getInZone(DEFAULT_ZONE_NAME, this.machineType.getName());
+ assertNotNull(machineType);
+ assertMachineTypeEquals(machineType, this.machineType);
+ }
+
+ private void assertMachineTypeEquals(MachineType result, MachineType expected) {
+ assertEquals(result.getName(), expected.getName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java
new file mode 100644
index 0000000..1b2d73b
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.AssertJUnit.assertNull;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.parse.ParseNetworkListTest;
+import org.jclouds.googlecomputeengine.parse.ParseNetworkTest;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ public static final HttpRequest GET_NETWORK_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse GET_NETWORK_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/network_get.json")).build();
+
+ public void testGetNetworkResponseIs2xx() throws Exception {
+
+ NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_NETWORK_REQUEST, GET_NETWORK_RESPONSE).getNetworkApiForProject("myproject");
+
+ assertEquals(api.get("jclouds-test"),
+ new ParseNetworkTest().expected());
+ }
+
+ public void testGetNetworkResponseIs4xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getNetworkApiForProject("myproject");
+
+ assertNull(api.get("jclouds-test"));
+ }
+
+ public void testInsertNetworkResponseIs2xx() {
+ HttpRequest insert = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/networks")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/network_insert.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse insertNetworkResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/operation.json")).build();
+
+ NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, insert,
+ insertNetworkResponse).getNetworkApiForProject("myproject");
+
+ assertEquals(api.createInIPv4Range("test-network", "10.0.0.0/8"), new ParseOperationTest().expected());
+ }
+
+ public void testDeleteNetworkResponseIs2xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/jclouds-test")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/operation.json")).build();
+
+ NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getNetworkApiForProject("myproject");
+
+ assertEquals(api.delete("jclouds-test"),
+ new ParseOperationTest().expected());
+ }
+
+ public void testDeleteNetworkResponseIs4xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/jclouds-test")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
+
+ NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getNetworkApiForProject("myproject");
+
+ assertNull(api.delete("jclouds-test"));
+ }
+
+ public void testListNetworksResponseIs2xx() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/network_list.json")).build();
+
+ NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getNetworkApiForProject("myproject");
+
+ assertEquals(api.listFirstPage().toString(),
+ new ParseNetworkListTest().expected().toString());
+ }
+
+ public void testListNetworksResponseIs4xx() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getNetworkApiForProject("myproject");
+
+ assertTrue(api.list().concat().isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
new file mode 100644
index 0000000..208ec1b
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+@Test(groups = "live", testName = "NetworkApiLiveTest")
+public class NetworkApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private static final String NETWORK_NAME = "network-api-live-test-network";
+ private static final String IPV4_RANGE = "10.0.0.0/8";
+ private static final int TIME_WAIT = 10;
+
+ private NetworkApi api() {
+ return api.getNetworkApiForProject(userProject.get());
+ }
+
+ @Test(groups = "live")
+ public void testInsertNetwork() {
+
+ assertGlobalOperationDoneSucessfully(api().createInIPv4Range(NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testInsertNetwork")
+ public void testGetNetwork() {
+
+ Network network = api().get(NETWORK_NAME);
+ assertNotNull(network);
+ assertNetworkEquals(network);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testGetNetwork")
+ public void testListNetwork() {
+
+ PagedIterable<Network> networks = api().list(new ListOptions.Builder()
+ .filter("name eq " + NETWORK_NAME));
+
+ List<Network> networksAsList = Lists.newArrayList(networks.concat());
+
+ assertEquals(networksAsList.size(), 1);
+
+ assertNetworkEquals(Iterables.getOnlyElement(networksAsList));
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testListNetwork")
+ public void testDeleteNetwork() {
+
+ assertGlobalOperationDoneSucessfully(api().delete(NETWORK_NAME), TIME_WAIT);
+ }
+
+ private void assertNetworkEquals(Network result) {
+ assertEquals(result.getName(), NETWORK_NAME);
+ assertEquals(result.getIPv4Range(), IPV4_RANGE);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiExpectTest.java
new file mode 100644
index 0000000..45e9f6c
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiExpectTest.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.GoogleComputeEngineConstants;
+import org.jclouds.googlecomputeengine.domain.Metadata;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.parse.ParseMetadataTest;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.jclouds.googlecomputeengine.parse.ParseProjectTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+
+@Test(groups = "unit")
+public class ProjectApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ public static final String PROJECTS_URL_PREFIX = "https://www.googleapis.com/compute/v1/projects";
+
+ public static final HttpRequest GET_PROJECT_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(PROJECTS_URL_PREFIX + "/myproject")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse GET_PROJECT_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/project.json")).build();
+
+ public void testGetProjectResponseIs2xx() throws Exception {
+ ProjectApi api = requestsSendResponses(requestForScopes(GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_PROJECT_REQUEST,
+ GET_PROJECT_RESPONSE).getProjectApi();
+
+ assertEquals(api.get("myproject"), new ParseProjectTest().expected());
+ }
+
+ public void testGetProjectResponseIs4xx() throws Exception {
+ HttpRequest getProjectRequest = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(PROJECTS_URL_PREFIX + "/myproject")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse getProjectResponse = HttpResponse.builder().statusCode(404).build();
+
+ ProjectApi api = requestsSendResponses(requestForScopes(GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, getProjectRequest,
+ getProjectResponse).getProjectApi();
+
+ assertNull(api.get("myproject"));
+ }
+
+ public void testSetCommonInstanceMetadata() {
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint(PROJECTS_URL_PREFIX + "/myproject/setCommonInstanceMetadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/metadata.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/global_operation.json")).build();
+
+ ProjectApi api = requestsSendResponses(requestForScopes(GoogleComputeEngineConstants.COMPUTE_SCOPE),
+ TOKEN_RESPONSE, setMetadata,
+ setMetadataResponse).getProjectApi();
+ Metadata expected = new ParseMetadataTest().expected();
+ assertEquals(api.setCommonInstanceMetadata("myproject", expected.getItems(), expected.getFingerprint()),
+ new ParseOperationTest().expected());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiLiveTest.java
new file mode 100644
index 0000000..150b58c
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ProjectApiLiveTest.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+
+import static com.google.common.base.Predicates.equalTo;
+import static com.google.common.base.Predicates.not;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.Project;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+/**
+ */
+public class ProjectApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private static final String METADATA_ITEM_KEY = "projectLiveTestTestProp";
+ private static final String METADATA_ITEM_VALUE = "projectLiveTestTestValue";
+
+ private ProjectApi projectApi() {
+ return api.getProjectApi();
+ }
+
+ private Project project;
+ private int initialMetadataSize;
+ private String initialFingerprint;
+
+ @Test(groups = "live")
+ public void testGetProjectWhenExists() {
+ this.project = projectApi().get(userProject.get());
+ assertNotNull(project);
+ assertNotNull(project.getId());
+ assertNotNull(project.getName());
+ }
+
+ @Test(groups = "live")
+ public void testGetProjectWhenNotExists() {
+ Project project = projectApi().get("momma");
+ assertNull(project);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testGetProjectWhenExists")
+ public void addItemToMetadata() {
+ this.initialMetadataSize = project.getCommonInstanceMetadata().getItems().size();
+ this.initialFingerprint = this.project.getCommonInstanceMetadata().getFingerprint();
+ assertGlobalOperationDoneSucessfully(addItemToMetadata(projectApi(), userProject.get(), METADATA_ITEM_KEY,
+ METADATA_ITEM_VALUE), 20);
+ this.project = projectApi().get(userProject.get());
+ assertNotNull(project);
+ assertTrue(this.project.getCommonInstanceMetadata().getItems().containsKey(METADATA_ITEM_KEY),
+ this.project.toString());
+ assertEquals(this.project.getCommonInstanceMetadata().getItems().get(METADATA_ITEM_KEY),
+ METADATA_ITEM_VALUE);
+ assertNotNull(this.project.getCommonInstanceMetadata().getFingerprint());
+ }
+
+ @Test(groups = "live", dependsOnMethods = "addItemToMetadata")
+ public void testDeleteItemFromMetadata() {
+ assertGlobalOperationDoneSucessfully(deleteItemFromMetadata(projectApi(), userProject.get(), METADATA_ITEM_KEY), 20);
+ this.project = projectApi().get(userProject.get());
+ assertNotNull(project);
+ assertFalse(project.getCommonInstanceMetadata().getItems().containsKey(METADATA_ITEM_KEY));
+ assertSame(this.project.getCommonInstanceMetadata().getItems().size(), initialMetadataSize);
+ assertEquals(this.project.getCommonInstanceMetadata().getFingerprint(), initialFingerprint);
+ }
+
+ /**
+ * Adds an item to the Project's metadata
+ * <p/>
+ * Beyond it's use here it is also used as a cheap way of generating Operations to both test the OperationApi and
+ * the pagination system.
+ */
+ public static Operation addItemToMetadata(ProjectApi projectApi, String projectName, String key, String value) {
+ Project project = projectApi.get(projectName);
+ assertNotNull(project);
+ ImmutableMap.Builder<String, String> metadataBuilder = ImmutableMap.builder();
+ metadataBuilder.putAll(project.getCommonInstanceMetadata().getItems());
+ metadataBuilder.put(key, value);
+ return projectApi.setCommonInstanceMetadata(projectName, metadataBuilder.build(),
+ project.getCommonInstanceMetadata().getFingerprint());
+ }
+
+ /**
+ * Deletes an item from the Project's metadata
+ * <p/>
+ * Beyond it's use here it is also used as a cheap way of generating Operation's to both test the OperationApi and
+ * the pagination system.
+ */
+ public static Operation deleteItemFromMetadata(ProjectApi projectApi, String projectName, String key) {
+ Project project = projectApi.get(projectName);
+ assertNotNull(project);
+ ImmutableMap.Builder<String, String> metadataBuilder = ImmutableMap.builder();
+ metadataBuilder.putAll(Maps.filterKeys(project.getCommonInstanceMetadata().getItems(), not(equalTo(key))));
+ return projectApi.setCommonInstanceMetadata(projectName, metadataBuilder.build(),
+ project.getCommonInstanceMetadata().getFingerprint());
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java
new file mode 100644
index 0000000..f4e32cb
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.parse.ParseRegionListTest;
+import org.jclouds.googlecomputeengine.parse.ParseRegionTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class RegionApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ public static final String REGIONS_URL_PREFIX = "https://www.googleapis.com/compute/v1/projects/myproject/regions";
+
+ public static final HttpRequest GET_REGION_REQ = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(REGIONS_URL_PREFIX + "/us-central1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpRequest LIST_REGIONS_REQ = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(REGIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse LIST_REGIONS_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/region_list.json")).build();
+
+ public void testGetRegionResponseIs2xx() throws Exception {
+
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/region_get.json")).build();
+
+ RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_REGION_REQ, operationResponse).getRegionApiForProject("myproject");
+
+ assertEquals(api.get("us-central1"),
+ new ParseRegionTest().expected());
+ }
+
+ public void testGetRegionResponseIs4xx() throws Exception {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_REGION_REQ, operationResponse).getRegionApiForProject("myproject");
+
+ assertNull(api.get("us-central1"));
+ }
+
+ public void testListRegionNoOptionsResponseIs2xx() throws Exception {
+
+ RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, LIST_REGIONS_REQ, LIST_REGIONS_RESPONSE).getRegionApiForProject("myproject");
+
+ assertEquals(api.listFirstPage().toString(),
+ new ParseRegionListTest().expected().toString());
+ }
+
+ public void testListRegionWithPaginationOptionsResponseIs4xx() {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, LIST_REGIONS_REQ, operationResponse).getRegionApiForProject("myproject");
+
+ assertTrue(api.list().concat().isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java
new file mode 100644
index 0000000..6558f36
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Region;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+public class RegionApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private Region region;
+
+ private RegionApi api() {
+ return api.getRegionApiForProject(userProject.get());
+ }
+
+ @Test(groups = "live")
+ public void testListRegion() {
+
+ PagedIterable<Region> regions = api().list(new ListOptions.Builder()
+ .maxResults(1));
+
+ Iterator<IterableWithMarker<Region>> pageIterator = regions.iterator();
+ assertTrue(pageIterator.hasNext());
+
+ IterableWithMarker<Region> singlePageIterator = pageIterator.next();
+ List<Region> regionAsList = Lists.newArrayList(singlePageIterator);
+
+ assertSame(regionAsList.size(), 1);
+
+ this.region = Iterables.getOnlyElement(regionAsList);
+ }
+
+
+ @Test(groups = "live", dependsOnMethods = "testListRegion")
+ public void testGetRegion() {
+ Region region = api().get(this.region.getName());
+ assertNotNull(region);
+ assertRegionEquals(region, this.region);
+ }
+
+ private void assertRegionEquals(Region result, Region expected) {
+ assertEquals(result.getName(), expected.getName());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
new file mode 100644
index 0000000..70b9eda
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.Resource;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ private static final String OPERATIONS_URL_PREFIX = "https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/regions/us-central1/operations";
+
+ private static final String DELETE_OPERATIONS_URL_PREFIX = "https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/regions/us-central1/operations";
+
+ public static final HttpRequest GET_OPERATION_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX + "/operation-1354084865060-4cf88735faeb8-bbbb12cb")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse GET_OPERATION_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/region_operation.json")).build();
+
+ private Operation expected() {
+ SimpleDateFormatDateService dateService = new SimpleDateFormatDateService();
+ return Operation.builder().id("13053095055850848306")
+ .selfLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/regions/us-central1/operations/operation-1354084865060-4cf88735faeb8" +
+ "-bbbb12cb"))
+ .name("operation-1354084865060-4cf88735faeb8-bbbb12cb")
+ .targetLink(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/regions/us-central1/addresses/test-address"))
+ .targetId("13053094017547040099")
+ .status(Operation.Status.DONE)
+ .user("user@developer.gserviceaccount.com")
+ .progress(100)
+ .insertTime(dateService.iso8601DateParse("2012-11-28T06:41:05.060"))
+ .startTime(dateService.iso8601DateParse("2012-11-28T06:41:05.142"))
+ .endTime(dateService.iso8601DateParse("2012-11-28T06:41:06.142"))
+ .operationType("insert")
+ .region(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1"))
+ .build();
+ }
+
+ private ListPage<Operation> expectedList() {
+ return ListPage.<Operation>builder()
+ .kind(Resource.Kind.OPERATION_LIST)
+ .id("projects/myproject/regions/us-central1/operations")
+ .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/operations"))
+ .addItem(expected())
+ .build();
+ }
+
+ public void testGetOperationResponseIs2xx() throws Exception {
+
+ RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_OPERATION_REQUEST, GET_OPERATION_RESPONSE).getRegionOperationApiForProject("myproject");
+
+ assertEquals(regionOperationApi.getInRegion("us-central1", "operation-1354084865060-4cf88735faeb8-bbbb12cb"),
+ expected());
+ }
+
+ public void testGetOperationResponseIs4xx() throws Exception {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_OPERATION_REQUEST, operationResponse).getRegionOperationApiForProject("myproject");
+
+ assertNull(regionOperationApi.getInRegion("us-central1", "operation-1354084865060-4cf88735faeb8-bbbb12cb"));
+ }
+
+ public void testDeleteOperationResponseIs2xx() throws Exception {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint(DELETE_OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
+
+ RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, operationResponse).getRegionOperationApiForProject("myproject");
+
+ regionOperationApi.deleteInRegion("us-central1", "operation-1352178598164-4cdcc9d031510-4aa46279");
+ }
+
+ public void testDeleteOperationResponseIs4xx() throws Exception {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint(DELETE_OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, operationResponse).getRegionOperationApiForProject("myproject");
+
+ regionOperationApi.deleteInRegion("us-central1", "operation-1352178598164-4cdcc9d031510-4aa46279");
+ }
+
+ public void testLisOperationWithNoOptionsResponseIs2xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/region_operation_list.json")).build();
+
+ RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getRegionOperationApiForProject("myproject");
+
+ assertEquals(regionOperationApi.listFirstPageInRegion("us-central1").toString(),
+ expectedList().toString());
+ }
+
+ public void testListOperationWithPaginationOptionsResponseIs2xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX +
+ "?pageToken=CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcG" +
+ "VyYXRpb24tMTM1MjI0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz&" +
+ "filter=" +
+ "status%20eq%20done&" +
+ "maxResults=3")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/region_operation_list.json")).build();
+
+ RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getRegionOperationApiForProject("myproject");
+
+ assertEquals(regionOperationApi.listAtMarkerInRegion("us-central1", "CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
+ "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
+ new ListOptions.Builder().filter("status eq done").maxResults(3)).toString(),
+ expectedList().toString());
+ }
+
+ public void testListOperationWithPaginationOptionsResponseIs4xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getRegionOperationApiForProject("myproject");
+
+ assertTrue(regionOperationApi.listInRegion("us-central1").concat().isEmpty());
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
new file mode 100644
index 0000000..118d879
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+public class RegionOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private static final String ADDRESS_NAME = "region-operations-api-live-test-address";
+ private Operation addOperation;
+ private Operation deleteOperation;
+
+ private RegionOperationApi api() {
+ return api.getRegionOperationApiForProject(userProject.get());
+ }
+
+ private AddressApi addressApi() {
+ return api.getAddressApiForProject(userProject.get());
+ }
+
+ @Test(groups = "live")
+ public void testCreateOperations() {
+ //create some operations by adding and deleting metadata items
+ // this will make sure there is stuff to listFirstPage
+ addOperation = assertRegionOperationDoneSucessfully(addressApi().createInRegion(DEFAULT_REGION_NAME,
+ ADDRESS_NAME), 20);
+ deleteOperation = assertRegionOperationDoneSucessfully(addressApi().deleteInRegion(DEFAULT_REGION_NAME,
+ ADDRESS_NAME), 20);
+
+ assertNotNull(addOperation);
+ assertNotNull(deleteOperation);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testCreateOperations")
+ public void testGetOperation() {
+ Operation operation = api().getInRegion(DEFAULT_REGION_NAME, addOperation.getName());
+ assertNotNull(operation);
+ assertOperationEquals(operation, this.addOperation);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testCreateOperations")
+ public void testListOperationsWithFiltersAndPagination() {
+ PagedIterable<Operation> operations = api().listInRegion(DEFAULT_REGION_NAME, new ListOptions.Builder()
+// .filter("operationType eq insert")
+ .maxResults(1));
+
+ // make sure that in spite of having only one result per page we get at least two results
+ final AtomicInteger counter = new AtomicInteger();
+ operations.firstMatch(new Predicate<IterableWithMarker<Operation>>() {
+
+ @Override
+ public boolean apply(IterableWithMarker<Operation> input) {
+ counter.addAndGet(Iterables.size(input));
+ return counter.get() == 2;
+ }
+ });
+ }
+
+ private void assertOperationEquals(Operation result, Operation expected) {
+ assertEquals(result.getName(), expected.getName());
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiExpectTest.java
new file mode 100644
index 0000000..6e9fa6e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiExpectTest.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.AssertJUnit.assertNull;
+
+import java.net.URI;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.options.RouteOptions;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.jclouds.googlecomputeengine.parse.ParseRouteListTest;
+import org.jclouds.googlecomputeengine.parse.ParseRouteTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ public void testGetRouteResponseIs2xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/routes/default-route-c99ebfbed0e1f375")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/route_get.json")).build();
+
+ RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getRouteApiForProject("myproject");
+
+ assertEquals(api.get("default-route-c99ebfbed0e1f375"),
+ new ParseRouteTest().expected());
+ }
+
+ public void testGetRouteResponseIs4xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/routes/default-route-c99ebfbed0e1f375")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getRouteApiForProject("myproject");
+
+ assertNull(api.get("default-route-c99ebfbed0e1f375"));
+ }
+
+ public void testInsertRouteResponseIs2xx() {
+ HttpRequest insert = HttpRequest
+ .builder()
+
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/routes")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/route_insert.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse insertRouteResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/global_operation.json")).build();
+
+ RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, insert,
+ insertRouteResponse).getRouteApiForProject("myproject");
+
+ assertEquals(api.createInNetwork("default-route-c99ebfbed0e1f375",
+ URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"),
+ new RouteOptions().addTag("fooTag")
+ .addTag("barTag")
+ .description("Default route to the virtual network.")
+ .destRange("10.240.0.0/16")
+ .priority(1000)
+ .nextHopNetwork(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"))
+ ), new ParseOperationTest().expected());
+ }
+
+ public void testDeleteRouteResponseIs2xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/routes/default-route-c99ebfbed0e1f375")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/global_operation.json")).build();
+
+ RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getRouteApiForProject("myproject");
+
+ assertEquals(api.delete("default-route-c99ebfbed0e1f375"),
+ new ParseOperationTest().expected());
+ }
+
+ public void testDeleteRouteResponseIs4xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/routes/default-route-c99ebfbed0e1f375")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
+
+ RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getRouteApiForProject("myproject");
+
+ assertNull(api.delete("default-route-c99ebfbed0e1f375"));
+ }
+
+ public void testListRoutesResponseIs2xx() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/routes")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/route_list.json")).build();
+
+ RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getRouteApiForProject("myproject");
+
+ assertEquals(api.listFirstPage().toString(),
+ new ParseRouteListTest().expected().toString());
+ }
+
+ public void testListRoutesResponseIs4xx() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/routes")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getRouteApiForProject("myproject");
+
+ assertTrue(api.list().concat().isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java
new file mode 100644
index 0000000..8269ec8
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/RouteApiLiveTest.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Route;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.googlecomputeengine.options.RouteOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+@Test(groups = "live", testName = "RouteApiLiveTest")
+public class RouteApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private static final String DEST_RANGE = "20.10.0.0/16";
+ private static final String IPV4_RANGE = "10.0.0.0/8";
+ private static final String ROUTE_NAME = "route-api-live-test-route";
+ private static final String ROUTE_NETWORK_NAME = "route-api-live-test-network";
+ public static final int TIME_WAIT = 30;
+
+ private RouteApi api() {
+ return api.getRouteApiForProject(userProject.get());
+ }
+
+ @Test(groups = "live")
+ public void testInsertRoute() {
+ assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).createInIPv4Range
+ (ROUTE_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
+ assertGlobalOperationDoneSucessfully(api().createInNetwork(ROUTE_NAME,
+ getNetworkUrl(userProject.get(), ROUTE_NETWORK_NAME),
+ new RouteOptions().addTag("footag")
+ .addTag("bartag")
+ .description("RouteApi Live Test")
+ .destRange(DEST_RANGE)
+ .priority(1000)
+ .nextHopGateway(getGatewayUrl(userProject.get(), DEFAULT_GATEWAY_NAME))),
+ TIME_WAIT);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testInsertRoute")
+ public void testGetRoute() {
+ Route route = api().get(ROUTE_NAME);
+
+ assertNotNull(route);
+ assertRouteEquals(route);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testGetRoute")
+ public void testListRoute() {
+
+ PagedIterable<Route> routes = api().list(new ListOptions()
+ .filter("name eq " + ROUTE_NAME));
+
+ List<Route> routesAsList = Lists.newArrayList(routes.concat());
+
+ assertEquals(routesAsList.size(), 1);
+
+ assertRouteEquals(Iterables.getOnlyElement(routesAsList));
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testListRoute")
+ public void testDeleteRoute() {
+ assertGlobalOperationDoneSucessfully(api().delete(ROUTE_NAME), TIME_WAIT);
+ assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get())
+ .delete(ROUTE_NETWORK_NAME), TIME_WAIT);
+ }
+
+ private void assertRouteEquals(Route result) {
+ assertEquals(result.getName(), ROUTE_NAME);
+ assertEquals(result.getDestRange(), DEST_RANGE);
+ assertEquals(result.getNextHopGateway().orNull(), getGatewayUrl(userProject.get(), DEFAULT_GATEWAY_NAME));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiExpectTest.java
new file mode 100644
index 0000000..4caedc5
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiExpectTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.parse.ParseSnapshotListTest;
+import org.jclouds.googlecomputeengine.parse.ParseSnapshotTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class SnapshotApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ public static final String SNAPSHOT_URL_PREFIX = "https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots";
+
+ public static final HttpRequest GET_SNAPSHOT_REQ = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(SNAPSHOT_URL_PREFIX + "/test-snap")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpRequest LIST_SNAPSHOTS_REQ = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(SNAPSHOT_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse LIST_SNAPSHOTS_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/snapshot_list.json")).build();
+
+ public void testGetSnapshotResponseIs2xx() throws Exception {
+
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/snapshot_get.json")).build();
+
+ SnapshotApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_SNAPSHOT_REQ, operationResponse).getSnapshotApiForProject("myproject");
+
+ assertEquals(api.get("test-snap"),
+ new ParseSnapshotTest().expected());
+ }
+
+ public void testGetSnapshotResponseIs4xx() throws Exception {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ SnapshotApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_SNAPSHOT_REQ, operationResponse).getSnapshotApiForProject("myproject");
+
+ assertNull(api.get("test-snap"));
+ }
+
+ public void testListSnapshotNoOptionsResponseIs2xx() throws Exception {
+
+ SnapshotApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, LIST_SNAPSHOTS_REQ, LIST_SNAPSHOTS_RESPONSE).getSnapshotApiForProject("myproject");
+
+ assertEquals(api.listFirstPage().toString(),
+ new ParseSnapshotListTest().expected().toString());
+ }
+
+ public void testListSnapshotWithPaginationOptionsResponseIs4xx() {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ SnapshotApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, LIST_SNAPSHOTS_REQ, operationResponse).getSnapshotApiForProject("myproject");
+
+ assertTrue(api.list().concat().isEmpty());
+ }
+}
[14/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java
new file mode 100644
index 0000000..5cc6d67
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java
@@ -0,0 +1,536 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.config;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Predicates.notNull;
+import static com.google.common.collect.Iterables.concat;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.getLast;
+import static com.google.common.collect.Iterables.transform;
+import static com.google.common.collect.Maps.transformValues;
+import static com.google.common.collect.Maps.uniqueIndex;
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
+import static org.jclouds.rest.config.BinderUtils.bindHttpApi;
+import static org.jclouds.util.Predicates2.retry;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.SortedMap;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
+import org.jclouds.domain.Location;
+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.location.suppliers.ImplicitLocationSupplier;
+import org.jclouds.location.suppliers.LocationsSupplier;
+import org.jclouds.ovf.Envelope;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.jclouds.rest.annotations.ApiVersion;
+import org.jclouds.rest.config.HttpApiModule;
+import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.VCloudToken;
+import org.jclouds.vcloud.VCloudVersionsApi;
+import org.jclouds.vcloud.compute.functions.FindLocationForResource;
+import org.jclouds.vcloud.compute.functions.ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException;
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.domain.VCloudSession;
+import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.jclouds.vcloud.endpoints.Network;
+import org.jclouds.vcloud.endpoints.OrgList;
+import org.jclouds.vcloud.functions.CatalogItemsInCatalog;
+import org.jclouds.vcloud.functions.CatalogItemsInOrg;
+import org.jclouds.vcloud.functions.CatalogsInOrg;
+import org.jclouds.vcloud.functions.DefaultNetworkNameInTemplate;
+import org.jclouds.vcloud.functions.OrgsForLocations;
+import org.jclouds.vcloud.functions.OrgsForNames;
+import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems;
+import org.jclouds.vcloud.functions.VDCsInOrg;
+import org.jclouds.vcloud.handlers.ParseVCloudErrorFromHttpResponse;
+import org.jclouds.vcloud.internal.VCloudLoginApi;
+import org.jclouds.vcloud.loaders.OVFLoader;
+import org.jclouds.vcloud.loaders.VAppTemplateLoader;
+import org.jclouds.vcloud.location.DefaultVDC;
+import org.jclouds.vcloud.location.OrgAndVDCToLocationSupplier;
+import org.jclouds.vcloud.predicates.TaskSuccess;
+import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Lists;
+import com.google.inject.Injector;
+import com.google.inject.Provides;
+import com.google.inject.Scopes;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Configures the VCloud authentication service connection, including logging and http transport.
+ */
+@ConfiguresHttpApi
+public class VCloudHttpApiModule extends HttpApiModule<VCloudApi> {
+
+
+ @Provides
+ @Singleton
+ protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
+ AtomicReference<AuthorizationException> authException, final VCloudLoginApi login) {
+ return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
+ new Supplier<VCloudSession>() {
+
+ @Override
+ public VCloudSession get() {
+ return login.login();
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(login).add("method", "login").toString();
+ }
+ }, seconds, TimeUnit.SECONDS);
+ }
+
+ @Override
+ protected void configure() {
+ super.configure();
+ bind(new TypeLiteral<Function<Iterable<CatalogItem>, Iterable<VAppTemplate>>>() {
+ }).to(new TypeLiteral<VAppTemplatesForCatalogItems>() {
+ });
+ bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
+ installDefaultVCloudEndpointsModule();
+ bind(new TypeLiteral<Function<ReferenceType, Location>>() {
+ }).to(new TypeLiteral<FindLocationForResource>() {
+ });
+ bind(new TypeLiteral<Function<Org, Iterable<Catalog>>>() {
+ }).to(new TypeLiteral<CatalogsInOrg>() {
+ });
+ bind(new TypeLiteral<Function<Org, Iterable<VDC>>>() {
+ }).to(new TypeLiteral<VDCsInOrg>() {
+ });
+ bind(new TypeLiteral<Function<Iterable<String>, Iterable<Org>>>() {
+ }).to(new TypeLiteral<OrgsForNames>() {
+ });
+ bind(new TypeLiteral<Function<Iterable<Location>, Iterable<Org>>>() {
+ }).to(new TypeLiteral<OrgsForLocations>() {
+ });
+ bind(new TypeLiteral<Function<Catalog, Iterable<CatalogItem>>>() {
+ }).to(new TypeLiteral<CatalogItemsInCatalog>() {
+ });
+ bind(new TypeLiteral<Function<Org, Iterable<CatalogItem>>>() {
+ }).to(new TypeLiteral<CatalogItemsInOrg>() {
+ });
+
+ bindCacheLoaders();
+
+ bind(new TypeLiteral<Function<VAppTemplate, String>>() {
+ }).annotatedWith(Network.class).to(new TypeLiteral<DefaultNetworkNameInTemplate>() {
+ });
+
+ bind(new TypeLiteral<Function<VAppTemplate, Envelope>>() {
+ }).to(new TypeLiteral<ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException>() {
+ });
+ bindHttpApi(binder(), VCloudApi.class);
+ bindHttpApi(binder(), VCloudVersionsApi.class);
+ bindHttpApi(binder(), VCloudLoginApi.class);
+ }
+
+ protected void bindCacheLoaders() {
+ bind(new TypeLiteral<CacheLoader<URI, VAppTemplate>>() {
+ }).to(new TypeLiteral<VAppTemplateLoader>() {
+ });
+
+ bind(new TypeLiteral<CacheLoader<URI, Envelope>>() {
+ }).to(new TypeLiteral<OVFLoader>() {
+ });
+ }
+
+ @Provides
+ @Singleton
+ @org.jclouds.vcloud.endpoints.VDC
+ protected Supplier<Map<String, String>> provideVDCtoORG(Supplier<Map<String, Org>> orgNameToOrgSupplier) {
+ return Suppliers.compose(new Function<Map<String, Org>, Map<String, String>>() {
+
+ @Override
+ public Map<String, String> apply(Map<String, Org> arg0) {
+ Builder<String, String> returnVal = ImmutableMap.builder();
+ for (Entry<String, Org> orgr : arg0.entrySet()) {
+ for (String vdc : orgr.getValue().getVDCs().keySet()) {
+ returnVal.put(vdc, orgr.getKey());
+ }
+ }
+ return returnVal.build();
+ }
+ }, orgNameToOrgSupplier);
+
+ }
+
+ @Provides
+ @Singleton
+ protected Supplier<Map<String, Org>> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
+ AtomicReference<AuthorizationException> authException, OrgMapSupplier supplier) {
+ return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds,
+ TimeUnit.SECONDS);
+ }
+
+ @Provides
+ @Singleton
+ @OrgList
+ protected Supplier<URI> provideOrgListURI(Supplier<VCloudSession> sessionSupplier) {
+ return Suppliers.compose(new Function<VCloudSession, URI>() {
+
+ @Override
+ public URI apply(VCloudSession arg0) {
+ return URI.create(getLast(arg0.getOrgs().values()).getHref().toASCIIString().replaceAll("org/.*", "org"));
+ }
+
+ @Override
+ public String toString() {
+ return "orgListURI()";
+ }
+
+ }, sessionSupplier);
+ }
+
+ @Singleton
+ public static class OrgMapSupplier implements Supplier<Map<String, Org>> {
+ protected final Supplier<VCloudSession> sessionSupplier;
+ protected final Function<Iterable<String>, Iterable<Org>> organizationsForNames;
+
+ @Inject
+ protected OrgMapSupplier(Supplier<VCloudSession> sessionSupplier,
+ Function<Iterable<String>, Iterable<Org>> organizationsForNames) {
+ this.sessionSupplier = sessionSupplier;
+ this.organizationsForNames = organizationsForNames;
+ }
+
+ @Override
+ public Map<String, Org> get() {
+ return uniqueIndex(organizationsForNames.apply(sessionSupplier.get().getOrgs().keySet()), name);
+ }
+ }
+
+ protected void installDefaultVCloudEndpointsModule() {
+ install(new DefaultVCloudReferencesModule());
+ }
+
+ @Singleton
+ public static class OrgCatalogSupplier implements
+ Supplier<Map<String, Map<String, Catalog>>> {
+ protected final Supplier<Map<String, Org>> orgSupplier;
+ protected final Function<Org, Iterable<Catalog>> allCatalogsInOrg;
+
+ @Inject
+ protected OrgCatalogSupplier(Supplier<Map<String, Org>> orgSupplier,
+ Function<Org, Iterable<Catalog>> allCatalogsInOrg) {
+ this.orgSupplier = orgSupplier;
+ this.allCatalogsInOrg = allCatalogsInOrg;
+ }
+
+ @Override
+ public Map<String, Map<String, Catalog>> get() {
+ return transformValues(transformValues(orgSupplier.get(), allCatalogsInOrg),
+ new Function<Iterable<? extends Catalog>, Map<String, Catalog>>() {
+
+ @Override
+ public Map<String, Catalog> apply(Iterable<? extends Catalog> from) {
+ return ImmutableMap.copyOf(uniqueIndex(from, name));
+ }
+
+ });
+ }
+ }
+
+ @VCloudToken
+ @Provides
+ @Singleton
+ Supplier<String> provideVCloudToken(Supplier<VCloudSession> cache) {
+ return Suppliers.compose(new Function<VCloudSession, String>() {
+
+ @Override
+ public String apply(VCloudSession input) {
+ return checkNotNull(input.getVCloudToken(), "No token present in session");
+ }
+ }, cache);
+ }
+
+ @Provides
+ @org.jclouds.vcloud.endpoints.Org
+ @Singleton
+ protected Supplier<Map<String, ReferenceType>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
+ AtomicReference<AuthorizationException> authException, OrgNameToOrgSupplier supplier) {
+ return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds,
+ TimeUnit.SECONDS);
+ }
+
+ @Provides
+ @Singleton
+ protected Supplier<Map<URI, VDC>> provideURIToVDC(
+ @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
+ URItoVDC supplier) {
+ return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds,
+ TimeUnit.SECONDS);
+ }
+
+ @Singleton
+ public static class URItoVDC implements Supplier<Map<URI, VDC>> {
+ private final Supplier<Map<String, Map<String, VDC>>> orgVDCMap;
+
+ @Inject
+ URItoVDC(Supplier<Map<String, Map<String, VDC>>> orgVDCMap) {
+ this.orgVDCMap = orgVDCMap;
+ }
+
+ @Override
+ public Map<URI, VDC> get() {
+ return uniqueIndex(concat(transform(orgVDCMap.get().values(),
+ new Function<Map<String, VDC>, Iterable<VDC>>() {
+
+ @Override
+ public Iterable<VDC> apply(
+ Map<String, VDC> from) {
+ return from.values();
+ }
+
+ })), new Function<VDC, URI>() {
+
+ @Override
+ public URI apply(VDC from) {
+ return from.getHref();
+ }
+
+ });
+ }
+
+ }
+
+ static final Function<ReferenceType, String> name = new Function<ReferenceType, String>() {
+
+ @Override
+ public String apply(ReferenceType from) {
+ return from.getName();
+ }
+
+ };
+
+ @Provides
+ @Singleton
+ @org.jclouds.vcloud.endpoints.VCloudLogin
+ protected Supplier<URI> provideAuthenticationURI(final VCloudVersionsApi versionService,
+ @ApiVersion final String version) {
+ return new Supplier<URI>() {
+
+ @Override
+ public URI get() {
+ SortedMap<String, URI> versions = versionService.getSupportedVersions();
+ checkState(versions.size() > 0, "No versions present");
+ checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
+ return versions.get(version);
+ }
+
+ public String toString() {
+ return "login()";
+ }
+ };
+ }
+
+ @Singleton
+ private static class OrgNameToOrgSupplier implements Supplier<Map<String, ReferenceType>> {
+ private final Supplier<VCloudSession> sessionSupplier;
+
+ @Inject
+ OrgNameToOrgSupplier(Supplier<VCloudSession> sessionSupplier) {
+ this.sessionSupplier = sessionSupplier;
+ }
+
+ @Override
+ public Map<String, ReferenceType> get() {
+ return sessionSupplier.get().getOrgs();
+ }
+
+ }
+
+ @Provides
+ @Singleton
+ protected Supplier<Org> provideOrg(final Supplier<Map<String, Org>> orgSupplier,
+ @org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg) {
+ return Suppliers.compose(new Function<ReferenceType, Org>() {
+
+ @Override
+ public Org apply(ReferenceType input) {
+ return orgSupplier.get().get(input.getName());
+
+ }
+ }, defaultOrg);
+ }
+
+ @Provides
+ @Singleton
+ protected Predicate<URI> successTester(Injector injector,
+ @Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
+ return retry(injector.getInstance(TaskSuccess.class), completed);
+ }
+
+ @Provides
+ @Singleton
+ protected Supplier<Map<String, Map<String, Catalog>>> provideOrgCatalogItemMapSupplierCache(
+ @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
+ OrgCatalogSupplier supplier) {
+ return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds,
+ TimeUnit.SECONDS);
+ }
+
+ @Provides
+ @Singleton
+ protected Supplier<Map<String, Map<String, VDC>>> provideOrgVDCSupplierCache(
+ @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
+ OrgVDCSupplier supplier) {
+ return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds,
+ TimeUnit.SECONDS);
+ }
+
+ @Singleton
+ public static class OrgVDCSupplier implements Supplier<Map<String, Map<String, VDC>>> {
+ protected final Supplier<Map<String, Org>> orgSupplier;
+ private final Function<Org, Iterable<VDC>> allVDCsInOrg;
+
+ @Inject
+ protected OrgVDCSupplier(Supplier<Map<String, Org>> orgSupplier,
+ Function<Org, Iterable<VDC>> allVDCsInOrg) {
+ this.orgSupplier = orgSupplier;
+ this.allVDCsInOrg = allVDCsInOrg;
+ }
+
+ @Override
+ public Map<String, Map<String, VDC>> get() {
+ return transformValues(transformValues(orgSupplier.get(), allVDCsInOrg),
+ new Function<Iterable<? extends VDC>, Map<String, VDC>>() {
+
+ @Override
+ public Map<String, VDC> apply(
+ Iterable<? extends VDC> from) {
+ return uniqueIndex(Lists.newArrayList(from), name);
+ }
+
+ });
+ }
+ }
+
+ @Singleton
+ public static class OrgCatalogItemSupplier implements
+ Supplier<Map<String, Map<String, Map<String, CatalogItem>>>> {
+ protected final Supplier<Map<String, Map<String, Catalog>>> catalogSupplier;
+ protected final Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog;
+
+ @Inject
+ protected OrgCatalogItemSupplier(
+ Supplier<Map<String, Map<String, Catalog>>> catalogSupplier,
+ Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog) {
+ this.catalogSupplier = catalogSupplier;
+ this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
+ }
+
+ @Override
+ public Map<String, Map<String, Map<String, CatalogItem>>> get() {
+ return transformValues(
+ catalogSupplier.get(),
+ new Function<Map<String, Catalog>, Map<String, Map<String, CatalogItem>>>() {
+
+ @Override
+ public Map<String, Map<String, CatalogItem>> apply(
+ Map<String, Catalog> from) {
+ return transformValues(
+ from,
+ new Function<Catalog, Map<String, CatalogItem>>() {
+
+ @Override
+ public Map<String, CatalogItem> apply(Catalog from) {
+ return uniqueIndex(filter(allCatalogItemsInCatalog.apply(from), notNull()), name);
+ }
+ });
+
+ }
+ });
+ }
+ }
+
+ @Provides
+ @Singleton
+ protected Supplier<Map<String, Map<String, Map<String, CatalogItem>>>> provideOrgCatalogItemSupplierCache(
+ @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
+ OrgCatalogItemSupplier supplier) {
+ return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds,
+ TimeUnit.SECONDS);
+ }
+
+ @Provides
+ @Singleton
+ protected FenceMode defaultFenceMode(@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) {
+ return FenceMode.fromValue(fenceMode);
+ }
+
+ @Provides
+ @Singleton
+ protected LoadingCache<URI, VAppTemplate> vAppTemplates(CacheLoader<URI, VAppTemplate> vAppTemplates) {
+ return CacheBuilder.newBuilder().build(vAppTemplates);
+ }
+
+ @Provides
+ @Singleton
+ protected LoadingCache<URI, Envelope> envelopes(CacheLoader<URI, Envelope> envelopes) {
+ return CacheBuilder.newBuilder().build(envelopes);
+ }
+
+ @Override
+ protected void bindErrorHandlers() {
+ bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseVCloudErrorFromHttpResponse.class);
+ bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseVCloudErrorFromHttpResponse.class);
+ bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseVCloudErrorFromHttpResponse.class);
+ }
+
+ @Override
+ protected void installLocations() {
+ super.installLocations();
+ bind(ImplicitLocationSupplier.class).to(DefaultVDC.class).in(Scopes.SINGLETON);
+ bind(LocationsSupplier.class).to(OrgAndVDCToLocationSupplier.class).in(Scopes.SINGLETON);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/AllocationModel.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/AllocationModel.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/AllocationModel.java
new file mode 100644
index 0000000..aadb475
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/AllocationModel.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.CaseFormat;
+
+/**
+ * The AllocationModel element defines how resources are allocated in a vDC.
+ */
+public enum AllocationModel {
+ /**
+ * Resources are committed to a vDC only when vApps are created in it
+ */
+ ALLOCATION_VAPP,
+ /**
+ * Only a percentage of the resources you allocate are committed to the organization vDC.
+ */
+ ALLOCATION_POOL,
+ /**
+ * All the resources you allocate are committed as a pool to the organization vDC. vApps in vDCs
+ * that support this allocation model can specify values for resource and limit.
+ */
+ RESERVATION_POOL,
+ /**
+ * The VCloud API returned a model unsupported in the version 1.0 spec.
+ */
+ UNRECOGNIZED;
+
+ public String value() {
+ switch (this) {
+ case ALLOCATION_VAPP:
+ return "AllocationVApp";
+ case ALLOCATION_POOL:
+ return "AllocationPool";
+ case RESERVATION_POOL:
+ return "ReservationPool";
+ default:
+ return "UnrecognizedModel";
+ }
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static AllocationModel fromValue(String model) {
+ try {
+ return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(model, "model")));
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Capacity.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Capacity.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Capacity.java
new file mode 100644
index 0000000..73dd761
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Capacity.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+/**
+ * reports storage resource consumption in a vDC.
+ */
+public class Capacity {
+
+ private final String units;
+ private final long allocated;
+ private final long limit;
+ private final int used;
+ private final long overhead;
+
+ public Capacity(String units, long allocated, long limit, int used, long overhead) {
+ this.units = units;
+ this.limit = limit;
+ this.allocated = allocated;
+ this.used = used;
+ this.overhead = overhead;
+ }
+
+ public String getUnits() {
+ return units;
+ }
+
+ public long getAllocated() {
+ return allocated;
+ }
+
+ public long getLimit() {
+ return limit;
+ }
+
+ /**
+ * percentage of the allocation in use.
+ */
+ public int getUsed() {
+ return used;
+ }
+
+ /**
+ * number of Units allocated to vShield Manager virtual machines provisioned from this vDC.
+ */
+ public long getOverhead() {
+ return overhead;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (allocated ^ (allocated >>> 32));
+ result = prime * result + (int) (limit ^ (limit >>> 32));
+ result = prime * result + (int) (overhead ^ (overhead >>> 32));
+ result = prime * result + ((units == null) ? 0 : units.hashCode());
+ result = prime * result + used;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Capacity other = (Capacity) obj;
+ if (allocated != other.allocated)
+ return false;
+ if (limit != other.limit)
+ return false;
+ if (overhead != other.overhead)
+ return false;
+ if (units == null) {
+ if (other.units != null)
+ return false;
+ } else if (!units.equals(other.units))
+ return false;
+ if (used != other.used)
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[allocated=" + allocated + ", limit=" + limit + ", overhead=" + overhead + ", units=" + units + ", used="
+ + used + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Catalog.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Catalog.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Catalog.java
new file mode 100644
index 0000000..5e29851
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Catalog.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.internal.CatalogImpl;
+
+import com.google.inject.ImplementedBy;
+
+@org.jclouds.vcloud.endpoints.Catalog
+@ImplementedBy(CatalogImpl.class)
+public interface Catalog extends ReferenceType, Map<String, ReferenceType> {
+ /**
+ * Reference to the org containing this vDC.
+ *
+ * @since vcloud api 1.0
+ * @return org, or null if this is a version before 1.0 where the org isn't present
+ */
+ ReferenceType getOrg();
+
+ /**
+ * optional description
+ *
+ * @since vcloud api 0.8
+ */
+ @Nullable
+ String getDescription();
+
+ /**
+ * read‐only element, true if the catalog is published
+ *
+ * @since vcloud api 1.0
+ */
+ boolean isPublished();
+
+ /**
+ * @return true, if the current user cannot modify the catalog
+ * @since vcloud api 1.0
+ */
+ boolean isReadOnly();
+
+ /**
+ * read‐only container for Task elements. Each element in the container represents a queued,
+ * running, or failed task owned by this object.
+ *
+ * @since vcloud api 1.0
+ */
+ List<Task> getTasks();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java
new file mode 100644
index 0000000..dc94dbd
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.util.Map;
+
+import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
+
+import com.google.inject.ImplementedBy;
+
+@ImplementedBy(CatalogItemImpl.class)
+public interface CatalogItem extends ReferenceType {
+
+ String getDescription();
+
+ ReferenceType getEntity();
+
+ Map<String, String> getProperties();
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/DiskAttachOrDetachParams.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/DiskAttachOrDetachParams.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/DiskAttachOrDetachParams.java
new file mode 100644
index 0000000..f3403d9
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/DiskAttachOrDetachParams.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.net.URI;
+
+/**
+ * The DiskAttachOrDetachParams element forms the body of a disk attach/detach request
+ * see http://pubs.vmware.com/vchs/index.jsp?topic=%2Fcom.vmware.vcloud.api.reference.doc_56%2Fdoc%2Ftypes%2FDiskAttachOrDetachParamsType.html
+ */
+public class DiskAttachOrDetachParams {
+ protected final URI href;
+ protected final String type;
+ protected final String id;
+ protected final String name;
+ protected final Integer BusNumber;
+ protected final Integer UnitNumber;
+
+ /**
+ * "application/vnd.vmware.vcloud.disk+xml"
+ */
+ //TODO: is this the right place?
+ public static final String DISK_XML = "application/vnd.vmware.vcloud.disk+xml";
+
+ public DiskAttachOrDetachParams(URI href) {
+ this.href = href;
+ this.type = DISK_XML;
+ this.id = null;
+ this.name = null;
+ this.BusNumber = null;
+ this.UnitNumber = null;
+ }
+
+ public DiskAttachOrDetachParams(URI href, String name,
+ String id, Integer BusNumber, Integer UnitNumber) {
+ this.href = href;
+ this.type = DISK_XML;
+ this.id = id;
+ this.name = name;
+ this.BusNumber = BusNumber;
+ this.UnitNumber = UnitNumber;
+ }
+
+ /**
+ * get href
+ * @return href
+ */
+ public URI getHref() {
+ return href;
+ }
+
+ /**
+ * get type
+ * @return type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * get id
+ * @return id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * get name
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * get bus nr
+ * @return bus nr
+ */
+ public Integer getBusNumber() {
+ return BusNumber;
+ }
+
+ /**
+ * get unit number
+ * @return unit number
+ */
+ public Integer getUnitNumber() {
+ return UnitNumber;
+ }
+
+ @Override
+ public String toString() {
+ return "[href=" + getHref() + ", type=" + getType() + ", id=" + getId() + ", name=" + getName()
+ + ", BusNumber=" + getBusNumber() + ", UnitNumber=" + getUnitNumber() + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ int prime = 31;
+ int result = 1;
+ result = prime * result + ((href == null) ? 0 : href.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((BusNumber == null) ? 0 : BusNumber.hashCode());
+ result = prime * result + ((UnitNumber == null) ? 0 : UnitNumber.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DiskAttachOrDetachParams other = (DiskAttachOrDetachParams)obj;
+
+ if (href == null) {
+ if (other.href != null)
+ return false;
+ } else if (!href.equals(other.href)) {
+ return false;
+ }
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type)) {
+ return false;
+ }
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id)) {
+ return false;
+ }
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ if (BusNumber == null) {
+ if (other.BusNumber != null)
+ return false;
+ } else if (!BusNumber.equals(other.BusNumber)) {
+ return false;
+ }
+ if (UnitNumber == null) {
+ if (other.UnitNumber != null)
+ return false;
+ } else if (!UnitNumber.equals(other.UnitNumber)) {
+ return false;
+ }
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/GuestCustomizationSection.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/GuestCustomizationSection.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/GuestCustomizationSection.java
new file mode 100644
index 0000000..b72c8ca
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/GuestCustomizationSection.java
@@ -0,0 +1,440 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.net.URI;
+
+import org.jclouds.vcloud.VCloudMediaType;
+
+/**
+ * The GuestCustomization of a Vm contains customization parameters for the guest operating system
+ * of the virtual machine.
+ */
+public class GuestCustomizationSection {
+ protected final String type;
+ protected final URI href;
+ protected String info;
+ protected Boolean enabled;
+ protected Boolean changeSid;
+ protected String virtualMachineId;
+ protected Boolean joinDomainEnabled;
+ protected Boolean useOrgSettings;
+ protected String domainName;
+ protected String domainUserName;
+ protected String domainUserPassword;
+ protected Boolean adminPasswordEnabled;
+ protected Boolean adminPasswordAuto;
+ protected String adminPassword;
+ protected Boolean resetPasswordRequired;
+ protected String customizationScript;
+ protected String computerName;
+ protected final ReferenceType edit;
+
+ public GuestCustomizationSection(URI href) {
+ this.href = href;
+ this.type = VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML;
+ this.info = "Specifies Guest OS Customization Settings";
+ this.edit = null;
+ }
+
+ public GuestCustomizationSection(String type, URI href, String info, Boolean enabled, Boolean changeSid,
+ String virtualMachineId, Boolean joinDomainEnabled, Boolean useOrgSettings, String domainName,
+ String domainUserName, String domainUserPassword, Boolean adminPasswordEnabled, Boolean adminPasswordAuto,
+ String adminPassword, Boolean resetPasswordRequired, String customizationScript, String computerName,
+ ReferenceType edit) {
+ this.type = type;
+ this.href = href;
+ this.info = info;
+ this.enabled = enabled;
+ this.changeSid = changeSid;
+ this.virtualMachineId = virtualMachineId;
+ this.joinDomainEnabled = joinDomainEnabled;
+ this.useOrgSettings = useOrgSettings;
+ this.domainName = domainName;
+ this.domainUserName = domainUserName;
+ this.domainUserPassword = domainUserPassword;
+ this.adminPasswordEnabled = adminPasswordEnabled;
+ this.adminPasswordAuto = adminPasswordAuto;
+ this.adminPassword = adminPassword;
+ this.resetPasswordRequired = resetPasswordRequired;
+ this.customizationScript = customizationScript;
+ this.computerName = computerName;
+ this.edit = edit;
+ }
+
+ /**
+ *
+ * @return media type of this section
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ *
+ * @return URL to access this section
+ */
+ public URI getHref() {
+ return href;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getInfo() {
+ return info;
+ }
+
+ /**
+ *
+ * @return if true, to enable guest customization at power on
+ */
+ public Boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ *
+ * @return if true, customization will run sysprep to change the Windows SID for this virtual
+ * machine
+ */
+ public Boolean shouldChangeSid() {
+ return changeSid;
+ }
+
+ /**
+ *
+ * @return unique identifier for this virtual machine
+ */
+ public String getVirtualMachineId() {
+ return virtualMachineId;
+ }
+
+ /**
+ *
+ * @return if true, this virtual machine can join a Windows domain
+ */
+ public Boolean isJoinDomainEnabled() {
+ return joinDomainEnabled;
+ }
+
+ /**
+ *
+ * @return if true, this virtual machine uses the containing organization’s default values for
+ * Windows domain name, domain user name, and domain user password
+ */
+ public Boolean useOrgSettings() {
+ return useOrgSettings;
+ }
+
+ /**
+ *
+ * @return if UseOrgSettings is false, specifies the Windows domain to join
+ */
+ public String getDomainName() {
+ return domainName;
+ }
+
+ /**
+ *
+ * @return if UseOrgSettings is false, specifies the Windows domain user name
+ */
+ public String getDomainUserName() {
+ return domainUserName;
+ }
+
+ /**
+ *
+ * @return if UseOrgSettings is false, specifies the Windows domain user’s password
+ */
+ public String getDomainUserPassword() {
+ return domainUserPassword;
+ }
+
+ /**
+ *
+ * @return true if the guest OS allows use of a local administrator password
+ */
+ public Boolean isAdminPasswordEnabled() {
+ return adminPasswordEnabled;
+ }
+
+ /**
+ *
+ * @return true if the local administrator password should be automatically generated
+ */
+ public Boolean isAdminPasswordAuto() {
+ return adminPasswordAuto;
+ }
+
+ /**
+ *
+ * @return local administrator password for this virtual machine
+ */
+ public String getAdminPassword() {
+ return adminPassword;
+ }
+
+ /**
+ *
+ * @return if true, the local administrator must reset his password on first use
+ */
+ public Boolean isResetPasswordRequired() {
+ return resetPasswordRequired;
+ }
+
+ /**
+ *
+ * @return the customization script to run
+ */
+ public String getCustomizationScript() {
+ return customizationScript;
+ }
+
+ /**
+ *
+ * @return name of this virtual machine in DNS or Windows domain
+ */
+ public String getComputerName() {
+ return computerName;
+ }
+
+ /**
+ *
+ * @return edit link
+ */
+ public ReferenceType getEdit() {
+ return edit;
+ }
+
+ @Override
+ public String toString() {
+ return "[href=" + getHref() + ", type=" + getType() + ", info=" + getInfo() + ", enabled=" + isEnabled() + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ int prime = 31;
+ int result = 1;
+ result = prime * result + ((adminPassword == null) ? 0 : adminPassword.hashCode());
+ result = prime * result + ((adminPasswordAuto == null) ? 0 : adminPasswordAuto.hashCode());
+ result = prime * result + ((adminPasswordEnabled == null) ? 0 : adminPasswordEnabled.hashCode());
+ result = prime * result + ((changeSid == null) ? 0 : changeSid.hashCode());
+ result = prime * result + ((computerName == null) ? 0 : computerName.hashCode());
+ result = prime * result + ((customizationScript == null) ? 0 : customizationScript.hashCode());
+ result = prime * result + ((domainName == null) ? 0 : domainName.hashCode());
+ result = prime * result + ((domainUserName == null) ? 0 : domainUserName.hashCode());
+ result = prime * result + ((domainUserPassword == null) ? 0 : domainUserPassword.hashCode());
+ result = prime * result + ((edit == null) ? 0 : edit.hashCode());
+ result = prime * result + ((enabled == null) ? 0 : enabled.hashCode());
+ result = prime * result + ((href == null) ? 0 : href.hashCode());
+ result = prime * result + ((info == null) ? 0 : info.hashCode());
+ result = prime * result + ((joinDomainEnabled == null) ? 0 : joinDomainEnabled.hashCode());
+ result = prime * result + ((resetPasswordRequired == null) ? 0 : resetPasswordRequired.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ result = prime * result + ((useOrgSettings == null) ? 0 : useOrgSettings.hashCode());
+ result = prime * result + ((virtualMachineId == null) ? 0 : virtualMachineId.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ GuestCustomizationSection other = (GuestCustomizationSection) obj;
+ if (adminPassword == null) {
+ if (other.adminPassword != null)
+ return false;
+ } else if (!adminPassword.equals(other.adminPassword))
+ return false;
+ if (adminPasswordAuto == null) {
+ if (other.adminPasswordAuto != null)
+ return false;
+ } else if (!adminPasswordAuto.equals(other.adminPasswordAuto))
+ return false;
+ if (adminPasswordEnabled == null) {
+ if (other.adminPasswordEnabled != null)
+ return false;
+ } else if (!adminPasswordEnabled.equals(other.adminPasswordEnabled))
+ return false;
+ if (changeSid == null) {
+ if (other.changeSid != null)
+ return false;
+ } else if (!changeSid.equals(other.changeSid))
+ return false;
+ if (computerName == null) {
+ if (other.computerName != null)
+ return false;
+ } else if (!computerName.equals(other.computerName))
+ return false;
+ if (customizationScript == null) {
+ if (other.customizationScript != null)
+ return false;
+ } else if (!customizationScript.equals(other.customizationScript))
+ return false;
+ if (domainName == null) {
+ if (other.domainName != null)
+ return false;
+ } else if (!domainName.equals(other.domainName))
+ return false;
+ if (domainUserName == null) {
+ if (other.domainUserName != null)
+ return false;
+ } else if (!domainUserName.equals(other.domainUserName))
+ return false;
+ if (domainUserPassword == null) {
+ if (other.domainUserPassword != null)
+ return false;
+ } else if (!domainUserPassword.equals(other.domainUserPassword))
+ return false;
+ if (edit == null) {
+ if (other.edit != null)
+ return false;
+ } else if (!edit.equals(other.edit))
+ return false;
+ if (enabled == null) {
+ if (other.enabled != null)
+ return false;
+ } else if (!enabled.equals(other.enabled))
+ return false;
+ if (href == null) {
+ if (other.href != null)
+ return false;
+ } else if (!href.equals(other.href))
+ return false;
+ if (info == null) {
+ if (other.info != null)
+ return false;
+ } else if (!info.equals(other.info))
+ return false;
+ if (joinDomainEnabled == null) {
+ if (other.joinDomainEnabled != null)
+ return false;
+ } else if (!joinDomainEnabled.equals(other.joinDomainEnabled))
+ return false;
+ if (resetPasswordRequired == null) {
+ if (other.resetPasswordRequired != null)
+ return false;
+ } else if (!resetPasswordRequired.equals(other.resetPasswordRequired))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ if (useOrgSettings == null) {
+ if (other.useOrgSettings != null)
+ return false;
+ } else if (!useOrgSettings.equals(other.useOrgSettings))
+ return false;
+ if (virtualMachineId == null) {
+ if (other.virtualMachineId != null)
+ return false;
+ } else if (!virtualMachineId.equals(other.virtualMachineId))
+ return false;
+ return true;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Boolean getChangeSid() {
+ return changeSid;
+ }
+
+ public void setChangeSid(Boolean changeSid) {
+ this.changeSid = changeSid;
+ }
+
+ public Boolean getJoinDomainEnabled() {
+ return joinDomainEnabled;
+ }
+
+ public void setJoinDomainEnabled(Boolean joinDomainEnabled) {
+ this.joinDomainEnabled = joinDomainEnabled;
+ }
+
+ public Boolean shouldUseOrgSettings() {
+ return useOrgSettings;
+ }
+
+ public void setUseOrgSettings(Boolean useOrgSettings) {
+ this.useOrgSettings = useOrgSettings;
+ }
+
+ public Boolean getAdminPasswordEnabled() {
+ return adminPasswordEnabled;
+ }
+
+ public void setAdminPasswordEnabled(Boolean adminPasswordEnabled) {
+ this.adminPasswordEnabled = adminPasswordEnabled;
+ }
+
+ public Boolean getAdminPasswordAuto() {
+ return adminPasswordAuto;
+ }
+
+ public void setAdminPasswordAuto(Boolean adminPasswordAuto) {
+ this.adminPasswordAuto = adminPasswordAuto;
+ }
+
+ public Boolean getResetPasswordRequired() {
+ return resetPasswordRequired;
+ }
+
+ public void setResetPasswordRequired(Boolean resetPasswordRequired) {
+ this.resetPasswordRequired = resetPasswordRequired;
+ }
+
+ public void setInfo(String info) {
+ this.info = info;
+ }
+
+ public void setVirtualMachineId(String virtualMachineId) {
+ this.virtualMachineId = virtualMachineId;
+ }
+
+ public void setDomainName(String domainName) {
+ this.domainName = domainName;
+ }
+
+ public void setDomainUserName(String domainUserName) {
+ this.domainUserName = domainUserName;
+ }
+
+ public void setDomainUserPassword(String domainUserPassword) {
+ this.domainUserPassword = domainUserPassword;
+ }
+
+ public void setAdminPassword(String adminPassword) {
+ this.adminPassword = adminPassword;
+ }
+
+ public void setCustomizationScript(String customizationScript) {
+ this.customizationScript = customizationScript;
+ }
+
+ public void setComputerName(String computerName) {
+ this.computerName = computerName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java
new file mode 100644
index 0000000..4b024df
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.util.Set;
+
+import org.jclouds.cim.ResourceAllocationSettingData;
+import org.jclouds.cim.VirtualSystemSettingData;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+
+/**
+ * The InstantiateVAppTemplateParams element forms the body of an instantiateVappTemplate request.
+ */
+public class InstantiateVAppTemplateParams {
+
+ protected final String info;
+ protected final VirtualSystemSettingData virtualSystem;
+ protected final Set<ResourceAllocationSettingData> resourceAllocations = Sets.newLinkedHashSet();
+
+ public InstantiateVAppTemplateParams(String info, VirtualSystemSettingData virtualSystem, Iterable<ResourceAllocationSettingData> resourceAllocations) {
+ this.info = info;
+ this.virtualSystem = virtualSystem;
+ Iterables.addAll(this.resourceAllocations, resourceAllocations);
+ }
+
+ public String getInfo() {
+ return info;
+ }
+
+ public VirtualSystemSettingData getSystem() {
+ return virtualSystem;
+ }
+
+ public Set<ResourceAllocationSettingData> getResourceAllocationSettingDatas() {
+ return resourceAllocations;
+ }
+
+ @Override
+ public String toString() {
+ return "[info=" + getInfo() + ", virtualSystem=" + getSystem() + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((info == null) ? 0 : info.hashCode());
+ result = prime * result + ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode());
+ result = prime * result + ((virtualSystem == null) ? 0 : virtualSystem.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ InstantiateVAppTemplateParams other = (InstantiateVAppTemplateParams) obj;
+ if (info == null) {
+ if (other.info != null)
+ return false;
+ } else if (!info.equals(other.info))
+ return false;
+ if (resourceAllocations == null) {
+ if (other.resourceAllocations != null)
+ return false;
+ } else if (!resourceAllocations.equals(other.resourceAllocations))
+ return false;
+ if (virtualSystem == null) {
+ if (other.virtualSystem != null)
+ return false;
+ } else if (!virtualSystem.equals(other.virtualSystem))
+ return false;
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java
new file mode 100644
index 0000000..34aa342
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
+
+/**
+ * describes a single network connection.
+ */
+public class NetworkConnection {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+
+ private String network;
+ private int networkConnectionIndex;
+ private String ipAddress;
+ private String externalIpAddress;
+ private boolean connected;
+ private String MACAddress;
+ private IpAddressAllocationMode ipAddressAllocationMode;
+
+ public Builder network(String network) {
+ this.network = network;
+ return this;
+ }
+
+ public Builder networkConnectionIndex(int networkConnectionIndex) {
+ this.networkConnectionIndex = networkConnectionIndex;
+ return this;
+ }
+
+ public Builder ipAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ return this;
+ }
+
+ public Builder externalIpAddress(String externalIpAddress) {
+ this.externalIpAddress = externalIpAddress;
+ return this;
+ }
+
+ public Builder connected(boolean connected) {
+ this.connected = connected;
+ return this;
+ }
+
+ public Builder MACAddress(String MACAddress) {
+ this.MACAddress = MACAddress;
+ return this;
+ }
+
+ public Builder ipAddressAllocationMode(IpAddressAllocationMode ipAddressAllocationMode) {
+ this.ipAddressAllocationMode = ipAddressAllocationMode;
+ return this;
+ }
+
+ public NetworkConnection build() {
+ return new NetworkConnection(network, networkConnectionIndex, ipAddress, externalIpAddress, connected,
+ MACAddress, ipAddressAllocationMode);
+ }
+
+ public static Builder fromNetworkConnection(NetworkConnection in) {
+ return new Builder().network(in.getNetwork()).networkConnectionIndex(in.getNetworkConnectionIndex())
+ .ipAddress(in.getIpAddress()).externalIpAddress(in.getExternalIpAddress()).connected(in.isConnected())
+ .MACAddress(in.getMACAddress()).ipAddressAllocationMode(in.getIpAddressAllocationMode());
+ }
+ }
+
+ private final String network;
+ private final int networkConnectionIndex;
+ @Nullable
+ private final String ipAddress;
+ @Nullable
+ private final String externalIpAddress;
+ private final boolean connected;
+ @Nullable
+ private final String MACAddress;
+ private final IpAddressAllocationMode ipAddressAllocationMode;
+
+ public NetworkConnection(String network, int networkConnectionIndex, @Nullable String ipAddress,
+ @Nullable String externalIpAddress, boolean connected, @Nullable String MACAddress,
+ IpAddressAllocationMode ipAddressAllocationMode) {
+ this.network = network;
+ this.networkConnectionIndex = networkConnectionIndex;
+ this.ipAddress = ipAddress;
+ this.externalIpAddress = externalIpAddress;
+ this.connected = connected;
+ this.MACAddress = MACAddress;
+ this.ipAddressAllocationMode = ipAddressAllocationMode;
+ }
+
+ /**
+ * @return The name of the network to which this connection connects.
+ */
+ public String getNetwork() {
+ return network;
+ }
+
+ /**
+ * @return The value in the rasd:AddressOnParent element of the device supporting this
+ * connection.
+ */
+ public int getNetworkConnectionIndex() {
+ return networkConnectionIndex;
+ }
+
+ /**
+ * @return IP address of this connection
+ */
+ @Nullable
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ /**
+ * @return If the network that the NIC is connected to has NAT or port mapping, the external
+ * address is populated in this element.
+ */
+ @Nullable
+ public String getExternalIpAddress() {
+ return externalIpAddress;
+ }
+
+ /**
+ * @return If the vApp is deployed, specifies the current state of its connection. If the vApp is
+ * undeployed, specifies whether this connection should be connected at deployment time.
+ */
+ public boolean isConnected() {
+ return connected;
+ }
+
+ /**
+ * @return MAC address of this connection
+ */
+ @Nullable
+ public String getMACAddress() {
+ return MACAddress;
+ }
+
+ /**
+ * @return specifies how an IP address is allocated to this connection
+ */
+ public IpAddressAllocationMode getIpAddressAllocationMode() {
+ return ipAddressAllocationMode;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((MACAddress == null) ? 0 : MACAddress.hashCode());
+ result = prime * result + (connected ? 1231 : 1237);
+ result = prime * result + ((externalIpAddress == null) ? 0 : externalIpAddress.hashCode());
+ result = prime * result + ((ipAddress == null) ? 0 : ipAddress.hashCode());
+ result = prime * result + ((ipAddressAllocationMode == null) ? 0 : ipAddressAllocationMode.hashCode());
+ result = prime * result + ((network == null) ? 0 : network.hashCode());
+ result = prime * result + networkConnectionIndex;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ NetworkConnection other = (NetworkConnection) obj;
+ if (MACAddress == null) {
+ if (other.MACAddress != null)
+ return false;
+ } else if (!MACAddress.equals(other.MACAddress))
+ return false;
+ if (connected != other.connected)
+ return false;
+ if (externalIpAddress == null) {
+ if (other.externalIpAddress != null)
+ return false;
+ } else if (!externalIpAddress.equals(other.externalIpAddress))
+ return false;
+ if (ipAddress == null) {
+ if (other.ipAddress != null)
+ return false;
+ } else if (!ipAddress.equals(other.ipAddress))
+ return false;
+ if (ipAddressAllocationMode == null) {
+ if (other.ipAddressAllocationMode != null)
+ return false;
+ } else if (!ipAddressAllocationMode.equals(other.ipAddressAllocationMode))
+ return false;
+ if (network == null) {
+ if (other.network != null)
+ return false;
+ } else if (!network.equals(other.network))
+ return false;
+ if (networkConnectionIndex != other.networkConnectionIndex)
+ return false;
+ return true;
+ }
+
+ public Builder toBuilder() {
+ return Builder.fromNetworkConnection(this);
+ }
+
+ @Override
+ public String toString() {
+ return "[network=" + network + ", connected=" + connected + ", ipAddress=" + ipAddress + ", externalIpAddress="
+ + externalIpAddress + ", networkConnectionIndex=" + networkConnectionIndex + ", ipAddressAllocationMode="
+ + ipAddressAllocationMode + ", MACAddress=" + MACAddress + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnectionSection.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnectionSection.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnectionSection.java
new file mode 100644
index 0000000..c6f5f37
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnectionSection.java
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Set;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * The NetworkConnectionSection element specifies how a Vm is connected to a vApp network. It
+ * extends the ovf:NetworkConnection element.
+ * <p/>
+ * NOTE The OVF NetworkSection element and the vCloud API NetworkConnectionSection element specify
+ * many of the same parameters for a network connection. If both are present in a Vm body, the
+ * values specified in the NetworkConnectionSection override those specified in the NetworkSection.
+ */
+public class NetworkConnectionSection {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ protected String type;
+ protected URI href;
+ protected String info;
+ protected Integer primaryNetworkConnectionIndex;
+ protected Set<NetworkConnection> connections = ImmutableSet.of();
+ protected ReferenceType edit;
+
+ public Builder type(String type) {
+ this.type = type;
+ return this;
+ }
+
+ public Builder href(URI href) {
+ this.href = href;
+ return this;
+ }
+
+ public Builder info(String info) {
+ this.info = info;
+ return this;
+ }
+
+ public Builder primaryNetworkConnectionIndex(Integer primaryNetworkConnectionIndex) {
+ this.primaryNetworkConnectionIndex = primaryNetworkConnectionIndex;
+ return this;
+ }
+
+ public Builder connections(Iterable<NetworkConnection> connections) {
+ this.connections = ImmutableSet.copyOf(checkNotNull(connections, "connections"));
+ return this;
+ }
+
+ public Builder edit(ReferenceType edit) {
+ this.edit = edit;
+ return this;
+ }
+
+ public NetworkConnectionSection build() {
+ return new NetworkConnectionSection(type, href, info, primaryNetworkConnectionIndex, connections, edit);
+ }
+
+ public static Builder fromNetworkConnectionSection(NetworkConnectionSection in) {
+ return new Builder().type(in.getType()).href(in.getHref()).info(in.getInfo())
+ .primaryNetworkConnectionIndex(in.getPrimaryNetworkConnectionIndex()).connections(in.getConnections())
+ .edit(in.getEdit());
+ }
+ }
+
+ protected final String type;
+ protected final URI href;
+ protected final String info;
+ protected final Integer primaryNetworkConnectionIndex;
+ protected final Set<NetworkConnection> connections;
+ protected final ReferenceType edit;
+
+ public NetworkConnectionSection(String type, URI href, String info, Integer primaryNetworkConnectionIndex,
+ Iterable<NetworkConnection> connections, ReferenceType edit) {
+ this.type = type;
+ this.href = href;
+ this.info = info;
+ this.primaryNetworkConnectionIndex = primaryNetworkConnectionIndex;
+ this.connections = ImmutableSet.copyOf(checkNotNull(connections, "connections"));
+ this.edit = edit;
+ }
+
+ /**
+ *
+ * @return media type of this section
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ *
+ * @return URL to access this section
+ */
+ public URI getHref() {
+ return href;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getInfo() {
+ return info;
+ }
+
+ /**
+ *
+ * @return The value of the rasd:AddressOnParent element of the device (NIC) supporting the
+ * primary network connection to the containing virtual machine.
+ */
+ public Integer getPrimaryNetworkConnectionIndex() {
+ return primaryNetworkConnectionIndex;
+ }
+
+ /**
+ *
+ */
+ public Set<NetworkConnection> getConnections() {
+ return connections;
+ }
+
+ /**
+ *
+ */
+ public ReferenceType getEdit() {
+ return edit;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((connections == null) ? 0 : connections.hashCode());
+ result = prime * result + ((edit == null) ? 0 : edit.hashCode());
+ result = prime * result + ((href == null) ? 0 : href.hashCode());
+ result = prime * result + ((info == null) ? 0 : info.hashCode());
+ result = prime * result
+ + ((primaryNetworkConnectionIndex == null) ? 0 : primaryNetworkConnectionIndex.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ NetworkConnectionSection other = (NetworkConnectionSection) obj;
+ if (connections == null) {
+ if (other.connections != null)
+ return false;
+ } else if (!connections.equals(other.connections))
+ return false;
+ if (edit == null) {
+ if (other.edit != null)
+ return false;
+ } else if (!edit.equals(other.edit))
+ return false;
+ if (href == null) {
+ if (other.href != null)
+ return false;
+ } else if (!href.equals(other.href))
+ return false;
+ if (info == null) {
+ if (other.info != null)
+ return false;
+ } else if (!info.equals(other.info))
+ return false;
+ if (primaryNetworkConnectionIndex == null) {
+ if (other.primaryNetworkConnectionIndex != null)
+ return false;
+ } else if (!primaryNetworkConnectionIndex.equals(other.primaryNetworkConnectionIndex))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ return true;
+ }
+
+ public Builder toBuilder() {
+ return Builder.fromNetworkConnectionSection(this);
+ }
+
+ @Override
+ public String toString() {
+ return "[href=" + href + ", connections=" + connections + ", primaryNetworkConnectionIndex="
+ + primaryNetworkConnectionIndex + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Org.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Org.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Org.java
new file mode 100644
index 0000000..7f4ede9
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Org.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.internal.OrgImpl;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * A vCloud organization is a high-level abstraction that provides a unit of administration for
+ * objects and resources. As viewed by a user, an organization (represented by an Org element) can
+ * contain Catalog, Network, and vDC elements. If there are any queued, running, or recently
+ * completed tasks owned by a member of the organization, it also contains a TasksList element. As
+ * viewed by an administrator, an organization also contains users, groups, and other information
+ */
+@ImplementedBy(OrgImpl.class)
+public interface Org extends ReferenceType {
+ /**
+ * optional description
+ *
+ * @since vcloud api 0.8
+ */
+ @Nullable
+ String getDescription();
+
+ /**
+ * full name of the organization
+ *
+ * @since vcloud api 1.0
+ */
+ @Nullable
+ String getFullName();
+
+ /**
+ * @since vcloud api 0.8
+ */
+ Map<String, ReferenceType> getCatalogs();
+
+ /**
+ * @since vcloud api 0.8
+ */
+ Map<String, ReferenceType> getVDCs();
+
+ /**
+ * If there are any queued, running, or recently completed tasks owned by a member of the
+ * organization, it also contains a TasksList.
+ *
+ * @since vcloud api 0.8
+ */
+ @Nullable
+ ReferenceType getTasksList();
+
+ /**
+ * @since vcloud api 1.0
+ */
+ Map<String, ReferenceType> getNetworks();
+
+ /**
+ * read‐only container for Task elements. Each element in the container represents a queued,
+ * running, or failed task owned by this object.
+ *
+ * @since vcloud api 1.0
+ */
+ List<Task> getTasks();
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java
new file mode 100644
index 0000000..d36343d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import java.net.URI;
+
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * Many container elements are populated with references to contained objects. Each reference
+ * consists of a hyperlink, an optional media type, and a name.
+ */
+@ImplementedBy(ReferenceTypeImpl.class)
+public interface ReferenceType extends Comparable<ReferenceType> {
+ /**
+ * @return hyperlink to the referenced object
+ */
+ URI getHref();
+
+ /**
+ * @return name of the referenced object.
+ *
+ */
+ String getName();
+
+ /**
+ * @return object type, expressed as the media type of the XML representing of the object
+ * @see VCloudMediaType
+ */
+ String getType();
+
+ /**
+ * @return relationship to the referenced object.
+ */
+ String getRelationship();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Status.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Status.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Status.java
new file mode 100644
index 0000000..748099b
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/Status.java
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Objects such as vAppTemplate, vApp, and Vm have a status attribute whose value indicates the
+ * state of the object. Status for an object, such as a vAppTemplate or vApp, whose Children (Vm
+ * objects) each have a status of their own, is computed from the status of the Children.
+ *
+ * <h2>NOTE</h2>
+ * <p/>
+ * The deployment status of an object is indicated by the value of its deployed attribute.
+ *
+ * @since vcloud api 0.8
+ */
+public enum Status {
+ /**
+ * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} could not be created.
+ *
+ * @since vcloud api 1.0
+ */
+ ERROR,
+ /**
+ * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is unresolved.
+ *
+ * @since vcloud api 0.8
+ */
+ UNRESOLVED,
+ /**
+ * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is resolved.
+ *
+ * @since vcloud api 0.8
+ */
+ RESOLVED,
+ /**
+ * The object is deployed.
+ * <p/>
+ * note that the documentation does not reference use of this.
+ *
+ * @since vcloud api 1.0
+ */
+ DEPLOYED,
+ /**
+ * The {@link VApp} or {@link Vm} is suspended.
+ *
+ * @since vcloud api 0.8
+ */
+ SUSPENDED,
+ /**
+ * The {@link VApp} or {@link Vm} is powered on
+ *
+ * @since vcloud api 0.8
+ */
+ ON,
+ /**
+ * The {@link VApp} or {@link Vm} waiting for user input.
+ *
+ * @since vcloud api 1.0
+ */
+ WAITING_FOR_INPUT,
+ /**
+ * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is in an unknown state.
+ *
+ * @since vcloud api 1.0
+ */
+ UNKNOWN,
+ /**
+ * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is in an unrecognized state.
+ *
+ * @since vcloud api 1.0
+ */
+ UNRECOGNIZED,
+ /**
+ * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is off.
+ *
+ * @since vcloud api 0.8
+ */
+ OFF,
+ /**
+ * The {@link VApp} or {@link Vm} is in an inconsistent state.
+ *
+ * @since vcloud api 1.0
+ */
+ INCONSISTENT,
+ /**
+ * The {@link VAppTemplate} or {@link VApp} have children do not all have the same status.
+ *
+ * @since vcloud api 1.0
+ */
+ MIXED,
+ /**
+ * The {@link VAppTemplate} Upload initiated, OVF descriptor pending
+ *
+ * @since vcloud api 1.0
+ */
+ PENDING_DESCRIPTOR,
+ /**
+ * The {@link VAppTemplate} Upload initiated, copying contents
+ *
+ * @since vcloud api 1.0
+ */
+ COPYING,
+ /**
+ * The {@link VAppTemplate} Upload initiated, disk contents pending
+ *
+ * @since vcloud api 1.0
+ */
+ PENDING_CONTENTS,
+ /**
+ * The {@link VAppTemplate} Upload has been quarantined
+ *
+ * @since vcloud api 1.0
+ */
+ QUARANTINED,
+ /**
+ * The {@link VAppTemplate} Upload quarantine period has expired
+ *
+ * @since vcloud api 1.0
+ */
+ QUARANTINE_EXPIRED,
+ /**
+ * The {@link VAppTemplate} rejected
+ *
+ * @since vcloud api 1.0
+ */
+ REJECTED,
+ /**
+ * The {@link VAppTemplate} transfer timeout
+ *
+ * @since vcloud api 1.0
+ */
+ TRANSFER_TIMEOUT;
+
+ public String value() {
+ switch (this) {
+ case UNRESOLVED:
+ return "0";
+ case RESOLVED:
+ return "1";
+ case DEPLOYED:
+ return "2";
+ case SUSPENDED:
+ return "3";
+ case ON:
+ return "4";
+ case WAITING_FOR_INPUT:
+ return "5";
+ case UNKNOWN:
+ return "6";
+ case UNRECOGNIZED:
+ return "7";
+ case OFF:
+ return "8";
+ case INCONSISTENT:
+ return "9";
+ case MIXED:
+ return "10";
+ case PENDING_DESCRIPTOR:
+ return "11";
+ case COPYING:
+ return "12";
+ case PENDING_CONTENTS:
+ return "13";
+ case QUARANTINED:
+ return "14";
+ case QUARANTINE_EXPIRED:
+ return "15";
+ case REJECTED:
+ return "16";
+ case TRANSFER_TIMEOUT:
+ return "17";
+ default:
+ return "7";
+ }
+ }
+
+ public static Status fromValue(String status) {
+ try {
+ return fromValue(Integer.parseInt(checkNotNull(status, "status")));
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+
+ public static Status fromValue(int v) {
+ switch (v) {
+ case 0:
+ return UNRESOLVED;
+ case 1:
+ return RESOLVED;
+ case 2:
+ return DEPLOYED;
+ case 3:
+ return SUSPENDED;
+ case 4:
+ return ON;
+ case 5:
+ return WAITING_FOR_INPUT;
+ case 6:
+ return UNKNOWN;
+ case 7:
+ return UNRECOGNIZED;
+ case 8:
+ return OFF;
+ case 9:
+ return INCONSISTENT;
+ case 10:
+ return MIXED;
+ case 11:
+ return PENDING_DESCRIPTOR;
+ case 12:
+ return COPYING;
+ case 13:
+ return PENDING_CONTENTS;
+ case 14:
+ return QUARANTINED;
+ case 15:
+ return QUARANTINE_EXPIRED;
+ case 16:
+ return REJECTED;
+ case 17:
+ return TRANSFER_TIMEOUT;
+ default:
+ return UNRECOGNIZED;
+ }
+ }
+
+}
[44/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java
new file mode 100644
index 0000000..dcb1942
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java
@@ -0,0 +1,255 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Disk;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.functions.internal.ParseDisks;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+/**
+ * Provides access to Disks via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/disks"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+public interface DiskApi {
+
+ /**
+ * Returns the specified persistent disk resource.
+ *
+ * @param zone Name of the zone the disk is in.
+ * @param diskName name of the persistent disk resource to return.
+ * @return a Disk resource.
+ */
+ @Named("Disks:get")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/disks/{disk}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Disk getInZone(@PathParam("zone") String zone, @PathParam("disk") String diskName);
+
+ /**
+ * Creates a persistent disk resource in the specified project specifying the size of the disk.
+ *
+ * @param diskName the name of disk.
+ * @param sizeGb the size of the disk
+ * @param zone the name of the zone where the disk is to be created.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Disks:insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/disks")
+ @OAuthScopes({COMPUTE_SCOPE})
+ @MapBinder(BindToJsonPayload.class)
+ Operation createInZone(@PayloadParam("name") String diskName,
+ @PayloadParam("sizeGb") int sizeGb,
+ @PathParam("zone") String zone);
+
+ /**
+ * Creates a persistent disk resource from the specified image, in the specified project,
+ * specifying the size of the disk.
+ *
+ * @param sourceImage fully qualified URL for the image to be copied.
+ * @param diskName the name of disk.
+ * @param sizeGb the size of the disk
+ * @param zone the name of the zone where the disk is to be created.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Disks:insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/disks")
+ @OAuthScopes({COMPUTE_SCOPE})
+ @MapBinder(BindToJsonPayload.class)
+ Operation createFromImageWithSizeInZone(@QueryParam("sourceImage") String sourceImage,
+ @PayloadParam("name") String diskName,
+ @PayloadParam("sizeGb") int sizeGb,
+ @PathParam("zone") String zone);
+
+ /**
+ * Creates a persistent disk resource from the specified image, in the specified project,
+ * with the default disk size.
+ *
+ * @param sourceImage fully qualified URL for the image to be copied.
+ * @param diskName the name of disk.
+ * @param zone the name of the zone where the disk is to be created.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Disks:insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/disks")
+ @OAuthScopes({COMPUTE_SCOPE})
+ @MapBinder(BindToJsonPayload.class)
+ Operation createFromImageInZone(@QueryParam("sourceImage") String sourceImage,
+ @PayloadParam("name") String diskName,
+ @PathParam("zone") String zone);
+
+ /**
+ * Deletes the specified persistent disk resource.
+ *
+ * @param zone the zone the disk is in.
+ * @param diskName name of the persistent disk resource to delete.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Disks:delete")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/disks/{disk}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Operation deleteInZone(@PathParam("zone") String zone, @PathParam("disk") String diskName);
+
+ /**
+ * @see DiskApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Disks:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/disks")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseDisks.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Disk> listFirstPageInZone(@PathParam("zone") String zone);
+
+ /**
+ * @see DiskApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Disks:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/disks")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseDisks.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Disk> listAtMarkerInZone(@PathParam("zone") String zone, @QueryParam("pageToken") @Nullable String marker);
+
+ /**
+ * Retrieves the listPage of persistent disk resources contained within the specified project and zone.
+ * By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has
+ * not been set.
+ *
+ * @param zone the zone to search in
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the listPage
+ * @see ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("Disks:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/disks")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseDisks.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Disk> listAtMarkerInZone(@PathParam("zone") String zone, @QueryParam("pageToken") @Nullable String marker, ListOptions listOptions);
+
+ /**
+ * A paged version of DiskApi#listPageInZone(String)
+ *
+ * @param zone the zone to list in
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see PagedIterable
+ * @see DiskApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Disks:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/disks")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseDisks.class)
+ @Transform(ParseDisks.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Disk> listInZone(@PathParam("zone") String zone);
+
+ @Named("Disks:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/disks")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseDisks.class)
+ @Transform(ParseDisks.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Disk> listInZone(@PathParam("zone") String zone, ListOptions options);
+
+ /**
+ * Create a snapshot of a given disk in a zone.
+ *
+ * @param zone the zone the disk is in.
+ * @param diskName the name of the disk.
+ * @param snapshotName the name for the snapshot to be craeted.
+ *
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Disks:createSnapshot")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/disks/{disk}/createSnapshot")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ @Nullable
+ Operation createSnapshotInZone(@PathParam("zone") String zone,
+ @PathParam("disk") String diskName,
+ @PayloadParam("name") String snapshotName);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java
new file mode 100644
index 0000000..79b2ec0
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import java.net.URI;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.functions.internal.PATCH;
+import org.jclouds.googlecomputeengine.functions.internal.ParseFirewalls;
+import org.jclouds.googlecomputeengine.handlers.FirewallBinder;
+import org.jclouds.googlecomputeengine.options.FirewallOptions;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+/**
+ * Provides access to Firewalls via their REST API.
+ * <p/>
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/firewalls"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+public interface FirewallApi {
+ /**
+ * Returns the specified image resource.
+ *
+ * @param firewallName name of the firewall resource to return.
+ * @return an Firewall resource
+ */
+ @Named("Firewalls:get")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/firewalls/{firewall}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Firewall get(@PathParam("firewall") String firewallName);
+
+ /**
+ * Creates a firewall resource in the specified project using the data included in the request.
+ *
+ * @param name the name of the firewall to be inserted.
+ * @param network the network to which to add the firewall
+ * @param firewallOptions the options of the firewall to add
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Firewalls:insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/global/firewalls")
+ @OAuthScopes({COMPUTE_SCOPE})
+ @MapBinder(FirewallBinder.class)
+ Operation createInNetwork(@PayloadParam("name") String name,
+ @PayloadParam("network") URI network,
+ @PayloadParam("options") FirewallOptions firewallOptions);
+
+ /**
+ * Updates the specified firewall resource with the data included in the request.
+ *
+ * @param firewallName the name firewall to be updated.
+ * @param firewallOptions the new firewall.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Firewalls:update")
+ @PUT
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/global/firewalls/{firewall}")
+ @OAuthScopes({COMPUTE_SCOPE})
+ Operation update(@PathParam("firewall") String firewallName,
+ @BinderParam(BindToJsonPayload.class) FirewallOptions firewallOptions);
+
+ /**
+ * Updates the specified firewall resource, with patch semantics, with the data included in the request.
+ *
+ * @param firewallName the name firewall to be updated.
+ * @param firewallOptions the new firewall.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Firewalls:patch")
+ @PATCH
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/global/firewalls/{firewall}")
+ @OAuthScopes({COMPUTE_SCOPE})
+ Operation patch(@PathParam("firewall") String firewallName,
+ @BinderParam(BindToJsonPayload.class) FirewallOptions firewallOptions);
+
+ /**
+ * Deletes the specified image resource.
+ *
+ * @param firewallName name of the firewall resource to delete.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field. If the image did not exist the result is null.
+ */
+ @Named("Firewalls:delete")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/firewalls/{firewall}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ Operation delete(@PathParam("firewall") String firewallName);
+
+ /**
+ * @see FirewallApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Firewalls:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/firewalls")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseFirewalls.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Firewall> listFirstPage();
+
+ /**
+ * @see FirewallApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Firewalls:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/firewalls")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseFirewalls.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Firewall> listAtMarker(@QueryParam("pageToken") @Nullable String marker);
+
+ /**
+ * Retrieves the list of firewall resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
+ *
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the list
+ * @see ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("Firewalls:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/firewalls")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseFirewalls.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Firewall> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions options);
+
+ /**
+ * @see FirewallApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Firewalls:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/firewalls")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseFirewalls.class)
+ @Transform(ParseFirewalls.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Firewall> list();
+
+ /**
+ * A paged version of FirewallApi#list()
+ *
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see PagedIterable
+ * @see FirewallApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Firewalls:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/firewalls")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseFirewalls.class)
+ @Transform(ParseFirewalls.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Firewall> list(ListOptions options);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java
new file mode 100644
index 0000000..818ae86
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.functions.internal.ParseGlobalOperations;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+
+/**
+ * Provides access to Global Operations via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/globalOperations"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+public interface GlobalOperationApi {
+
+ /**
+ * Retrieves the specified operation resource.
+ *
+ * @param operationName name of the operation resource to return.
+ * @return If successful, this method returns an Operation resource
+ */
+ @Named("GlobalOperations:get")
+ @GET
+ @Path("/global/operations/{operation}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ Operation get(@PathParam("operation") String operationName);
+
+ /**
+ * Deletes the specified operation resource.
+ *
+ * @param operationName name of the operation resource to delete.
+ */
+ @Named("GlobalOperations:delete")
+ @DELETE
+ @Path("/global/operations/{operation}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ void delete(@PathParam("operation") String operationName);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.GlobalOperationApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("GlobalOperations:list")
+ @GET
+ @Path("/global/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseGlobalOperations.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Operation> listFirstPage();
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.GlobalOperationApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("GlobalOperations:list")
+ @GET
+ @Path("/global/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseGlobalOperations.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Operation> listAtMarker(@QueryParam("pageToken") @Nullable String marker);
+
+ /**
+ * Retrieves the listFirstPage of operation resources contained within the specified project.
+ * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
+ * has not been set.
+ *
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the list, starting at marker
+ * @see org.jclouds.googlecomputeengine.options.ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("GlobalOperations:list")
+ @GET
+ @Path("/global/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseGlobalOperations.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Operation> listAtMarker(@QueryParam("pageToken") @Nullable String marker,
+ ListOptions listOptions);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.GlobalOperationApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("GlobalOperations:list")
+ @GET
+ @Path("/global/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseGlobalOperations.class)
+ @Transform(ParseGlobalOperations.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Operation> list();
+
+ /**
+ * A paged version of GlobalOperationApi#listFirstPage()
+ *
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see org.jclouds.collect.PagedIterable
+ * @see org.jclouds.googlecomputeengine.features.GlobalOperationApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("GlobalOperations:list")
+ @GET
+ @Path("/global/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseGlobalOperations.class)
+ @Transform(ParseGlobalOperations.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Operation> list(ListOptions listOptions);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java
new file mode 100644
index 0000000..d5755f2
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.functions.internal.ParseImages;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+
+/**
+ * Provides access to Images via their REST API.
+ * <p/>
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/images"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+public interface ImageApi {
+ /**
+ * Returns the specified image resource.
+ *
+ * @param imageName name of the image resource to return.
+ * @return an Image resource
+ */
+ @Named("Images:get")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/images/{image}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Image get(@PathParam("image") String imageName);
+
+ /**
+ * Deletes the specified image resource.
+ *
+ * @param imageName name of the image resource to delete.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field. If the image did not exist the result is null.
+ */
+ @Named("Images:delete")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/images/{image}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Operation delete(@PathParam("image") String imageName);
+
+ /**
+ * @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Images:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/images")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseImages.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Image> listFirstPage();
+
+ /**
+ * @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Images:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/images")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseImages.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Image> listAtMarker(@QueryParam("pageToken") @Nullable String marker);
+
+ /**
+ * Retrieves the list of image resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
+ *
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the list
+ * @see ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("Images:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/images")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseImages.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Image> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions listOptions);
+
+ /**
+ * A paged version of ImageApi#list()
+ *
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see PagedIterable
+ * @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Images:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/images")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseImages.class)
+ @Transform(ParseImages.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Image> list();
+
+ /**
+ * A paged version of ImageApi#list()
+ *
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see PagedIterable
+ * @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Images:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/images")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseImages.class)
+ @Transform(ParseImages.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Image> list(ListOptions options);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java
new file mode 100644
index 0000000..2a88a79
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java
@@ -0,0 +1,381 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.InstanceTemplate;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.functions.internal.ParseInstances;
+import org.jclouds.googlecomputeengine.handlers.InstanceBinder;
+import org.jclouds.googlecomputeengine.handlers.MetadataBinder;
+import org.jclouds.googlecomputeengine.options.AttachDiskOptions;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+/**
+ * Provides access to Instances via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/>
+ * @see InstanceApi
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+public interface InstanceApi {
+
+ /**
+ * Returns the specified instance resource.
+ *
+ * @param zone zone the instance is in.
+ * @param instanceName name of the instance resource to return.
+ * @return an Instance resource
+ */
+ @Named("Instances:get")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances/{instance}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Instance getInZone(@PathParam("zone") String zone, @PathParam("instance") String instanceName);
+
+ /**
+ * Creates a instance resource in the specified project using the data included in the request.
+ *
+ *
+ * @param instanceName this name of the instance to be created
+ * @param zone the name of the zone where the instance will be created
+ * @param template the instance template
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Instances:insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances")
+ @OAuthScopes({COMPUTE_SCOPE})
+ @MapBinder(InstanceBinder.class)
+ Operation createInZone(@PayloadParam("name") String instanceName, @PathParam("zone") String zone,
+ @PayloadParam("template") InstanceTemplate template);
+
+
+ /**
+ * Deletes the specified instance resource.
+ *
+ * @param zone the instance is in.
+ * @param instanceName name of the instance resource to delete.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field. If the instance did not exist the result is null.
+ */
+ @Named("Instances:delete")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances/{instance}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Operation deleteInZone(@PathParam("zone") String zone, @PathParam("instance") String instanceName);
+
+ /**
+ * A paged version of InstanceApi#listInZone()
+ *
+ * @param zone zone instances are in
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see PagedIterable
+ * @see InstanceApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Instances:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseInstances.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Instance> listFirstPageInZone(@PathParam("zone") String zone);
+
+ /**
+ * Retrieves the list of instance resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
+ *
+ * @param zone zone instances are in
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the list
+ * @see ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("Instances:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseInstances.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Instance> listAtMarkerInZone(@PathParam("zone") String zone, @Nullable String marker,
+ ListOptions listOptions);
+
+ /**
+ * @see InstanceApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Instances:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseInstances.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Instance> listAtMarkerInZone(@PathParam("zone") String zone,
+ @Nullable String marker);
+
+ /**
+ * @see InstanceApi#listInZone(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Instances:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseInstances.class)
+ @Transform(ParseInstances.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Instance> listInZone(@PathParam("zone") String zone);
+
+ /**
+ * @see InstanceApi#listInZone(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Instances:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseInstances.class)
+ @Transform(ParseInstances.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Instance> listInZone(@PathParam("zone") String zone, ListOptions options);
+
+ /**
+ * Adds an access config to an instance's network interface.
+ *
+ * @param zone zone instance is in
+ * @param instanceName the instance name.
+ * @param accessConfig the AccessConfig to add.
+ * @param networkInterfaceName network interface name.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Instances:addAccessConfig")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances/{instance}/addAccessConfig")
+ @OAuthScopes({COMPUTE_SCOPE})
+ Operation addAccessConfigToNicInZone(@PathParam("zone") String zone,
+ @PathParam("instance") String instanceName,
+ @BinderParam(BindToJsonPayload.class)
+ Instance.NetworkInterface.AccessConfig accessConfig,
+ @QueryParam("network_interface") String networkInterfaceName);
+
+ /**
+ * Deletes an access config from an instance's network interface.
+ *
+ * @param zone zone instance is in
+ * @param instanceName the instance name.
+ * @param accessConfigName the name of the access config to delete
+ * @param networkInterfaceName network interface name.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Instances:deleteAccessConfig")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances/{instance}/deleteAccessConfig")
+ @OAuthScopes(COMPUTE_SCOPE)
+ Operation deleteAccessConfigFromNicInZone(@PathParam("zone") String zone,
+ @PathParam("instance") String instanceName,
+ @QueryParam("access_config") String accessConfigName,
+ @QueryParam("network_interface") String networkInterfaceName);
+
+ /**
+ * Returns the specified instance's serial port output.
+ *
+ * @param zone zone instance is in
+ * @param instanceName the instance name.
+ * @return if successful, this method returns a SerialPortOutput containing the instance's serial output.
+ */
+ @Named("Instances:serialPort")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances/{instance}/serialPort")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ Instance.SerialPortOutput getSerialPortOutputInZone(@PathParam("zone") String zone,
+ @PathParam("instance") String instanceName);
+
+ /**
+ * Hard-resets the instance.
+ *
+ * @param zone the zone the instance is in
+ * @param instanceName the instance name
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field. If the instance did not exist the result is null.
+ */
+ @Named("Instances:reset")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances/{instance}/reset")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Operation resetInZone(@PathParam("zone") String zone,
+ @PathParam("instance") String instanceName);
+
+ /**
+ * Attaches a disk to an instance
+ *
+ * @param zone The zone the instance is in.
+ * @param instanceName The instance name to attach to
+ * @param attachDiskOptions The options for attaching the disk.
+ *
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Instances:attachDisk")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances/{instance}/attachDisk")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Operation attachDiskInZone(@PathParam("zone") String zone,
+ @PathParam("instance") String instanceName,
+ @BinderParam(BindToJsonPayload.class) AttachDiskOptions attachDiskOptions);
+
+ /**
+ * Detaches an attached disk from an instance
+ *
+ * @param zone The zone the instance is in.
+ * @param instanceName The instance name to attach to
+ * @param deviceName The device name of the disk to detach.
+ *
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Instances:detachDisk")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/zones/{zone}/instances/{instance}/detachDisk")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Operation detachDiskInZone(@PathParam("zone") String zone,
+ @PathParam("instance") String instanceName,
+ @QueryParam("deviceName") String deviceName);
+
+ /**
+ * Sets metadata for an instance using the data included in the request.
+ * <p/>
+ * NOTE: This *sets* metadata items on the project (vs *adding* items to metadata),
+ * if there are pre-existing metadata items that must be kept these must be fetched first and then re-set on the
+ * new Metadata, e.g.
+ * <pre><tt>
+ * Metadata.Builder current = instanceApi.getInZone("us-central1-a", "myInstance").getMetadata().toBuilder();
+ * current.addItem("newItem","newItemValue");
+ * instanceApi.setMetadataInZone("us-central1-a", "myInstance", current.build());
+ * </tt></pre>
+ *
+ * @param zone The zone the instance is in
+ * @param instanceName The name of the instance
+ * @param metadata the metadata to set
+ * @param fingerprint The current fingerprint for the items
+ *
+ * @return an Operations resource. To check on the status of an operation, poll the Operations resource returned
+ * to you, and look for the status field.
+ */
+ @Named("Instances:setMetadata")
+ @POST
+ @Path("/zones/{zone}/instances/{instance}/setMetadata")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ @MapBinder(MetadataBinder.class)
+ @Nullable
+ Operation setMetadataInZone(@PathParam("zone") String zone,
+ @PathParam("instance") String instanceName,
+ @PayloadParam("items") Map<String, String> metadata,
+ @PayloadParam("fingerprint") String fingerprint);
+
+ /**
+ * Sets items for an instance
+ *
+ * @param zone The zone the instance is in
+ * @param instanceName the name of the instance
+ * @param items A set of items
+ * @param fingerprint The current fingerprint for the items
+ * @return an Operations resource. To check on the status of an operation, poll the Operations resource returned
+ * to you, and look for the status field.
+ */
+ @Named("Instances:setTags")
+ @POST
+ @Path("/zones/{zone}/instances/{instance}/setTags")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ @Nullable
+ Operation setTagsInZone(@PathParam("zone") String zone,
+ @PathParam("instance") String instanceName,
+ @PayloadParam("items") Set<String> items,
+ @PayloadParam("fingerprint") String fingerprint);
+
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java
new file mode 100644
index 0000000..9c0e411
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.MachineType;
+import org.jclouds.googlecomputeengine.functions.internal.ParseMachineTypes;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+
+/**
+ * Provides access to MachineTypes via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/machineTypes"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface MachineTypeApi {
+
+ /**
+ * Returns the specified machine type resource
+ *
+ * @param zone the name of the zone the machine type is in
+ * @param machineTypeName name of the machine type resource to return.
+ * @return If successful, this method returns a MachineType resource
+ */
+ @Named("MachineTypes:get")
+ @GET
+ @Path("/zones/{zone}/machineTypes/{machineType}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ MachineType getInZone(@PathParam("zone") String zone, @PathParam("machineType") String machineTypeName);
+
+ /**
+ * @see MachineTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("MachineTypes:list")
+ @GET
+ @Path("/zones/{zone}/machineTypes")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseMachineTypes.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<MachineType> listFirstPageInZone(@PathParam("zone") String zone);
+
+ /**
+ * @see MachineTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("MachineTypes:list")
+ @GET
+ @Path("/zones/{zone}/machineTypes")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseMachineTypes.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<MachineType> listAtMarkerInZone(@PathParam("zone") String zone, @QueryParam("pageToken") @Nullable String marker);
+
+ /**
+ * Retrieves the list of machine type resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
+ *
+ * @param zone The name of the zone to list in.
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the list
+ * @see ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("MachineTypes:list")
+ @GET
+ @Path("/zones/{zone}/machineTypes")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseMachineTypes.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<MachineType> listAtMarkerInZone(@PathParam("zone") String zone,
+ @QueryParam("pageToken") @Nullable String marker,
+ ListOptions listOptions);
+
+ /**
+ * @see MachineTypeApi#listInZone(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("MachineTypes:list")
+ @GET
+ @Path("/zones/{zone}/machineTypes")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseMachineTypes.class)
+ @Transform(ParseMachineTypes.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<MachineType> listInZone(@PathParam("zone") String zone);
+
+ /**
+ * A paged version of MachineTypeApi#listInZone(String)
+ *
+ * @param zone the zone to list in
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see PagedIterable
+ * @see MachineTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("MachineTypes:list")
+ @GET
+ @Path("/zones/{zone}/machineTypes")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseMachineTypes.class)
+ @Transform(ParseMachineTypes.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<MachineType> listInZone(@PathParam("zone") String zone, ListOptions listOptions);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java
new file mode 100644
index 0000000..8f21287
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.functions.internal.ParseNetworks;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+/**
+ * Provides access to Networks via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/networks"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+public interface NetworkApi {
+
+ /**
+ * Returns the specified persistent network resource.
+ *
+ * @param networkName name of the persistent network resource to return.
+ * @return a Network resource.
+ */
+ @Named("Networks:get")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/networks/{network}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ Network get(@PathParam("network") String networkName);
+
+ /**
+ * Creates a persistent network resource in the specified project with the specified range.
+ *
+ * @param networkName the network name
+ * @param IPv4Range the range of the network to be inserted.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Networks:insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/global/networks")
+ @OAuthScopes({COMPUTE_SCOPE})
+ @MapBinder(BindToJsonPayload.class)
+ Operation createInIPv4Range(@PayloadParam("name") String networkName,
+ @PayloadParam("IPv4Range") String IPv4Range);
+
+ /**
+ * Creates a persistent network resource in the specified project with the specified range and specified gateway.
+ *
+ * @param networkName the network name
+ * @param IPv4Range the range of the network to be inserted.
+ * @param gatewayIPv4 the range of the network to be inserted.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Networks:insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/global/networks")
+ @OAuthScopes({COMPUTE_SCOPE})
+ @MapBinder(BindToJsonPayload.class)
+ Operation createInIPv4RangeWithGateway(@PayloadParam("name") String networkName,
+ @PayloadParam("IPv4Range") String IPv4Range,
+ @PayloadParam("gatewayIPv4") String gatewayIPv4);
+
+ /**
+ * Deletes the specified persistent network resource.
+ *
+ * @param networkName name of the persistent network resource to delete.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Networks:delete")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/networks/{network}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ Operation delete(@PathParam("network") String networkName);
+
+ /**
+ * @see NetworkApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Networks:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/networks")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseNetworks.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Network> listFirstPage();
+
+ /**
+ * @see NetworkApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Networks:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/networks")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseNetworks.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Network> listAtMarker(@QueryParam("pageToken") @Nullable String marker);
+
+ /**
+ * Retrieves the list of persistent network resources contained within the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
+ *
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the list
+ * @see ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("Networks:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/networks")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseNetworks.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Network> listAtMarker(@QueryParam("pageToken") @Nullable String marker,
+ ListOptions options);
+
+ /**
+ * @see NetworkApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Networks:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/networks")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseNetworks.class)
+ @Transform(ParseNetworks.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Network> list();
+
+ /**
+ * A paged version of NetworkApi#list()
+ *
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see PagedIterable
+ * @see NetworkApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Networks:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/global/networks")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseNetworks.class)
+ @Transform(ParseNetworks.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Network> list(ListOptions options);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ProjectApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ProjectApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ProjectApi.java
new file mode 100644
index 0000000..8871593
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ProjectApi.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import java.util.Map;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.Project;
+import org.jclouds.googlecomputeengine.handlers.MetadataBinder;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SkipEncoding;
+
+/**
+ * Provides access to Projects via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/projects"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+public interface ProjectApi {
+
+ /**
+ * Returns the specified project resource.
+ *
+ * @param projectName name of the project to return
+ * @return if successful, this method returns a Project resource
+ */
+ @Named("Projects:get")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Path("/projects/{project}")
+ Project get(@PathParam("project") String projectName);
+
+ /**
+ * Sets metadata common to all instances within the specified project using the data included in the request.
+ * <p/>
+ * NOTE: This *sets* metadata items on the project (vs *adding* items to metadata),
+ * if there are pre-existing metadata items that must be kept these must be fetched first and then re-set on the
+ * new Metadata, e.g.
+ * <pre><tt>
+ * Metadata.Builder current = projectApi.get("myProject").getCommonInstanceMetadata().toBuilder();
+ * current.addItem("newItem","newItemValue");
+ * projectApi.setCommonInstanceMetadata(current.build());
+ * </tt></pre>
+ *
+ * @param projectName name of the project to return
+ * @param metadata the metadata to set
+ * @param fingerprint The current fingerprint for the metadata
+ * @return an Operations resource. To check on the status of an operation, poll the Operations resource returned
+ * to you, and look for the status field.
+ */
+ @Named("Projects:setCommonInstanceMetadata")
+ @POST
+ @Path("/projects/{project}/setCommonInstanceMetadata")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @MapBinder(MetadataBinder.class)
+ Operation setCommonInstanceMetadata(@PathParam("project") String projectName,
+ @PayloadParam("items") Map<String, String> metadata,
+ @PayloadParam("fingerprint") String fingerprint);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java
new file mode 100644
index 0000000..608a614
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Region;
+import org.jclouds.googlecomputeengine.functions.internal.ParseRegions;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+
+/**
+ * Provides access to Regions via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/regions"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface RegionApi {
+
+ /**
+ * Returns the specified region resource
+ *
+ * @param regionName name of the region resource to return.
+ * @return If successful, this method returns a Region resource
+ */
+ @Named("Regions:get")
+ @GET
+ @Path("/regions/{region}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ Region get(@PathParam("region") String regionName);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.RegionApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Regions:list")
+ @GET
+ @Path("/regions")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseRegions.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Region> listFirstPage();
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.RegionApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Regions:list")
+ @GET
+ @Path("/regions")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseRegions.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Region> listAtMarker(String marker);
+
+ /**
+ * Retrieves the listFirstPage of region resources available to the specified project.
+ * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
+ * has not been set.
+ *
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the listFirstPage
+ * @see org.jclouds.googlecomputeengine.options.ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("Regions:list")
+ @GET
+ @Path("/regions")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseRegions.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Region> listAtMarker(String marker, ListOptions listOptions);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.RegionApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Regions:list")
+ @GET
+ @Path("/regions")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseRegions.class)
+ @Transform(ParseRegions.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Region> list();
+
+ /**
+ * A paged version of RegionApi#listFirstPage()
+ *
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see org.jclouds.googlecomputeengine.features.RegionApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see org.jclouds.collect.PagedIterable
+ */
+ @Named("Regions:list")
+ @GET
+ @Path("/regions")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseRegions.class)
+ @Transform(ParseRegions.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Region> list(ListOptions listOptions);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java
new file mode 100644
index 0000000..4afab63
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.functions.internal.ParseRegionOperations;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+
+/**
+ * Provides access to Operations via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+public interface RegionOperationApi {
+
+ /**
+ * Retrieves the specified operation resource.
+ *
+ * @param region the region the operation is in
+ * @param operationName name of the operation resource to return.
+ * @return If successful, this method returns an Operation resource
+ */
+ @Named("RegionOperations:get")
+ @GET
+ @Path("/regions/{region}/operations/{operation}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ Operation getInRegion(@PathParam("region") String region, @PathParam("operation") String operationName);
+
+ /**
+ * Deletes the specified operation resource.
+ *
+ * @param region the region the operation is in
+ * @param operationName name of the operation resource to delete.
+ */
+ @Named("RegionOperations:delete")
+ @DELETE
+ @Path("/regions/{region}/operations/{operation}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ void deleteInRegion(@PathParam("region") String region, @PathParam("operation") String operationName);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.RegionOperationApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("RegionOperations:list")
+ @GET
+ @Path("/regions/{region}/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseRegionOperations.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Operation> listFirstPageInRegion(@PathParam("region") String region);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.RegionOperationApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("RegionOperations:list")
+ @GET
+ @Path("/regions/{region}/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseRegionOperations.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Operation> listAtMarkerInRegion(@PathParam("region") String region,
+ @QueryParam("pageToken") @Nullable String marker);
+
+ /**
+ * Retrieves the listFirstPage of operation resources contained within the specified project.
+ * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
+ * has not been set.
+ *
+ * @param region the region to list in
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the list, starting at marker
+ * @see org.jclouds.googlecomputeengine.options.ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("RegionOperations:list")
+ @GET
+ @Path("/regions/{region}/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseRegionOperations.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Operation> listAtMarkerInRegion(@PathParam("region") String region,
+ @QueryParam("pageToken") @Nullable String marker,
+ ListOptions listOptions);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.RegionOperationApi#listInRegion(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("RegionOperations:list")
+ @GET
+ @Path("/regions/{region}/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseRegionOperations.class)
+ @Transform(ParseRegionOperations.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Operation> listInRegion(@PathParam("region") String region);
+
+ /**
+ * A paged version of RegionOperationApi#listFirstPageInRegion(String)
+ *
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see org.jclouds.collect.PagedIterable
+ * @see org.jclouds.googlecomputeengine.features.RegionOperationApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("RegionOperations:list")
+ @GET
+ @Path("/regions/{region}/operations")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(ParseRegionOperations.class)
+ @Transform(ParseRegionOperations.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Operation> listInRegion(@PathParam("region") String region, ListOptions listOptions);
+
+}
[23/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiMockTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiMockTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiMockTest.java
new file mode 100644
index 0000000..31a7ecf
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiMockTest.java
@@ -0,0 +1,1787 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.extensions.lbaas.v1;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitor;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HttpMethod;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.LBaaSStatus;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Member;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pool;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.ProbeType;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Protocol;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.SessionPersistence;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIP;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiMockTest;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableSet;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+
+@Test
+public class LBaaSApiMockTest extends BaseNeutronApiMockTest {
+
+ public void testWhenNamespaceInExtensionsLBaaSPresent() throws IOException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ Optional<LBaaSApi> lbaasApiExtension = neutronApi.getLBaaSApi("RegionOne");
+
+ assertAuthentication(server);
+
+ /*
+ * Check response
+ */
+ assertNotNull(lbaasApiExtension);
+ assertEquals(lbaasApiExtension.isPresent(), true, "LBaaS API Version 1 is expected to be available");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testWhenNamespaceNotInExtensionsListLBaaSNotPresent() throws IOException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_without_lbaas_v1_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ Optional<LBaaSApi> lbaasApiExtension = neutronApi.getLBaaSApi("RegionOne");
+
+ assertAuthentication(server);
+
+ /*
+ * Check response
+ */
+ assertNotNull(lbaasApiExtension);
+ assertEquals(lbaasApiExtension.isPresent(), false, "LBaaS API Version 1 is expected to be unavailable");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreatePool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/pool_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pool.CreatePool createPool = Pool.createBuilder("8032909d-47a1-4715-90af-5153ffe39861", Protocol.TCP, Pool.ROUND_ROBIN)
+ .name("NewPool").description(null).healthMonitors(null).provider(null).adminStateUp(null).build();
+
+ Pool pool = lbaasApi.createPool(createPool);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "POST", "/v2.0/lb/pools", "/lbaas/v1/pool_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pool);
+ assertNotNull(pool.getId());
+ assertEquals(pool.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertNull(pool.getVIPId());
+ assertEquals(pool.getName(), "NewPool");
+ assertEquals(pool.getDescription(), "");
+ assertEquals(pool.getSubnetId(), "8032909d-47a1-4715-90af-5153ffe39861");
+ assertEquals(pool.getProtocol(), Protocol.TCP);
+ assertEquals(pool.getProvider(), "HAPROXY");
+ assertEquals(pool.getLBMethod(), Pool.ROUND_ROBIN);
+ assertNotNull(pool.getMembers());
+ assertTrue(pool.getMembers().isEmpty());
+ assertNotNull(pool.getHealthMonitors());
+ assertTrue(pool.getHealthMonitors().isEmpty());
+ assertNotNull(pool.getHealthMonitorsStatus());
+ assertTrue(pool.getHealthMonitorsStatus().isEmpty());
+ assertEquals(pool.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(pool.getStatus(), LBaaSStatus.PENDING_CREATE);
+ assertNull(pool.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreatePoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pool.CreatePool createPool = Pool.createBuilder("8032909d-47a1-4715-90af-5153ffe39861", Protocol.TCP, Pool.ROUND_ROBIN)
+ .name("NewPool").description(null).healthMonitors(null).provider(null).adminStateUp(null).build();
+
+ lbaasApi.createPool(createPool);
+
+ fail("Should have failed with not found exception");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPagePool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/pool_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pools pools = lbaasApi.listPools(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pools);
+ assertEquals(pools.size(), 1);
+ assertEquals(pools.first().get().getId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPagePoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pools pools = lbaasApi.listPools(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pools);
+ assertTrue(pools.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedPool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/pool_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/pool_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Pool> pools = lbaasApi.listPools().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 4);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pools);
+ assertEquals(pools.size(), 2);
+ assertEquals(pools.get(0).getId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ assertEquals(pools.get(1).getId(), "72741b06-df4d-4715-b142-276b6bce75ab_2");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedPoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Pool> pools = lbaasApi.listPools().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pools);
+ assertTrue(pools.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetPool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/pool_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pool pool = lbaasApi.getPool("72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pool);
+ assertEquals(pool.getId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ assertEquals(pool.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertNotNull(pool.getVIPId());
+ assertEquals(pool.getName(), "app_pool");
+ assertEquals(pool.getDescription(), "");
+ assertEquals(pool.getSubnetId(), "8032909d-47a1-4715-90af-5153ffe39861");
+ assertEquals(pool.getProtocol(), Protocol.HTTP);
+ assertEquals(pool.getProvider(), "HAPROXY");
+ assertEquals(pool.getLBMethod(), Pool.ROUND_ROBIN);
+ assertNotNull(pool.getMembers());
+ assertEquals(pool.getMembers().size(), 2);
+ assertNotNull(pool.getHealthMonitors());
+ assertEquals(pool.getHealthMonitors().size(), 2);
+ assertNotNull(pool.getHealthMonitorsStatus());
+ assertEquals(pool.getHealthMonitorsStatus().size(), 2);
+ assertEquals(pool.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(pool.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(pool.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetPoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pool pool = lbaasApi.getPool("72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check response
+ */
+ assertNull(pool);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdatePool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/pool_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pool.UpdatePool updatePool = Pool.updateBuilder().name("new_name").description("new description").lbMethod("NEW_LB_METHOD")
+ .healthMonitors(ImmutableSet.of("5d4b5228-33b0-4e60-b225-9b727c1a20e7")).adminStateUp(Boolean.FALSE).build();
+
+ Pool pool = lbaasApi.updatePool("72741b06-df4d-4715-b142-276b6bce75ab", updatePool);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab", "/lbaas/v1/pool_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pool);
+ assertEquals(pool.getId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ assertEquals(pool.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertNotNull(pool.getVIPId());
+ assertEquals(pool.getName(), "new_name");
+ assertEquals(pool.getDescription(), "new description");
+ assertEquals(pool.getSubnetId(), "8032909d-47a1-4715-90af-5153ffe39861");
+ assertEquals(pool.getProtocol(), Protocol.HTTP);
+ assertEquals(pool.getProvider(), "HAPROXY");
+ assertEquals(pool.getLBMethod(), "NEW_LB_METHOD");
+ assertNotNull(pool.getMembers());
+ assertEquals(pool.getMembers().size(), 2);
+ assertNotNull(pool.getHealthMonitors());
+ assertEquals(pool.getHealthMonitors().size(), 1);
+ assertEquals(pool.getHealthMonitors().iterator().next(), "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+ assertNotNull(pool.getHealthMonitorsStatus());
+ assertEquals(pool.getHealthMonitorsStatus().size(), 1);
+ assertEquals(pool.getHealthMonitorsStatus().iterator().next().getId(), "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+ assertEquals(pool.getAdminStateUp(), Boolean.FALSE);
+ assertEquals(pool.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(pool.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdatePoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pool.UpdatePool updatePool = Pool.updateBuilder().name("new_name").description("new description").lbMethod("NEW_LB_METHOD")
+ .healthMonitors(ImmutableSet.of("5d4b5228-33b0-4e60-b225-9b727c1a20e7")).adminStateUp(Boolean.FALSE).build();
+
+ Pool pool = lbaasApi.updatePool("72741b06-df4d-4715-b142-276b6bce75ab", updatePool);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab", "/lbaas/v1/pool_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(pool);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeletePool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deletePool("72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeletePoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deletePool("72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateMember() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/member_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Member.CreateMember createMember = Member.createBuilder("72741b06-df4d-4715-b142-276b6bce75ab", null, 80)
+ .weight(null).adminStateUp(null).build();
+
+ Member member = lbaasApi.createMember(createMember);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "POST", "/v2.0/lb/members", "/lbaas/v1/member_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(member);
+ assertNotNull(member.getId());
+ assertEquals(member.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertEquals(member.getPoolId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ assertNotNull(member.getAddress());
+ assertEquals(member.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(member.getWeight(), Integer.valueOf(1));
+ assertEquals(member.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(member.getStatus(), LBaaSStatus.PENDING_CREATE);
+ assertNull(member.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateMemberFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Member.CreateMember createMember = Member.createBuilder("72741b06-df4d-4715-b142-276b6bce75ab", null, 80)
+ .weight(null).adminStateUp(null).build();
+
+ lbaasApi.createMember(createMember);
+
+ fail("Should have failed with not found exception");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageMember() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/member_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Members members = lbaasApi.listMembers(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(members);
+ assertEquals(members.size(), 1);
+ assertEquals(members.first().get().getId(), "48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageMemberFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Members members = lbaasApi.listMembers(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(members);
+ assertTrue(members.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedMember() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/member_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/member_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Member> members = lbaasApi.listMembers().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 4);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members?marker=396f12f8-521e-4b91-8e21-2e003500433a");
+
+ /*
+ * Check response
+ */
+ assertNotNull(members);
+ assertEquals(members.size(), 2);
+ assertEquals(members.get(0).getId(), "48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+ assertEquals(members.get(1).getId(), "701b531b-111a-4f21-ad85-4795b7b12af6");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedMemberFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Member> members = lbaasApi.listMembers().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members");
+
+ /*
+ * Check response
+ */
+ assertNotNull(members);
+ assertTrue(members.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetMember() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/member_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Member member = lbaasApi.getMember("48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members/48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check response
+ */
+ assertNotNull(member);
+ assertEquals(member.getId(), "48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+ assertEquals(member.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertEquals(member.getPoolId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ assertEquals(member.getAddress(), "10.0.0.5");
+ assertEquals(member.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(member.getWeight(), Integer.valueOf(1));
+ assertEquals(member.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(member.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(member.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetMemberFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Member member = lbaasApi.getMember("48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members/48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check response
+ */
+ assertNull(member);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateMember() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/member_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Member.UpdateMember updateMember = Member.updateBuilder().poolId("new_pool_id").weight(2)
+ .adminStateUp(Boolean.FALSE).build();
+
+ Member member = lbaasApi.updateMember("48a471ea-64f1-4eb6-9be7-dae6bbe40a0f", updateMember);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/members/48a471ea-64f1-4eb6-9be7-dae6bbe40a0f", "/lbaas/v1/member_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(member);
+ assertEquals(member.getId(), "48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+ assertEquals(member.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertEquals(member.getPoolId(), "new_pool_id");
+ assertEquals(member.getAddress(), "10.0.0.5");
+ assertEquals(member.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(member.getWeight(), Integer.valueOf(2));
+ assertEquals(member.getAdminStateUp(), Boolean.FALSE);
+ assertEquals(member.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(member.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateMemberFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Member.UpdateMember updateMember = Member.updateBuilder().poolId("new_pool_id").weight(2)
+ .adminStateUp(Boolean.FALSE).build();
+
+ Member member = lbaasApi.updateMember("48a471ea-64f1-4eb6-9be7-dae6bbe40a0f", updateMember);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/members/48a471ea-64f1-4eb6-9be7-dae6bbe40a0f", "/lbaas/v1/member_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(member);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteMember() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deleteMember("48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/members/48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteMemberFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deleteMember("48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/members/48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateVIP() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/vip_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ VIP.CreateVIP createVIP = VIP.createBuilder("8032909d-47a1-4715-90af-5153ffe39861", Protocol.HTTP, 80, "61b1f87a-7a21-4ad3-9dda-7f81d249944f")
+ .name("NewVip").description(null).address(null).sessionPersistence(null).connectionLimit(null).build();
+
+ VIP vip = lbaasApi.createVIP(createVIP);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "POST", "/v2.0/lb/vips", "/lbaas/v1/vip_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vip);
+ assertNotNull(vip.getId());
+ assertEquals(vip.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertEquals(vip.getName(), "NewVip");
+ assertEquals(vip.getDescription(), "");
+ assertEquals(vip.getSubnetId(), "8032909d-47a1-4715-90af-5153ffe39861");
+ assertEquals(vip.getAddress(), "10.0.0.11");
+ assertEquals(vip.getPortId(), "f7e6fe6a-b8b5-43a8-8215-73456b32e0f5");
+ assertEquals(vip.getProtocol(), Protocol.HTTP);
+ assertEquals(vip.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(vip.getPoolId(), "61b1f87a-7a21-4ad3-9dda-7f81d249944f");
+ assertNull(vip.getSessionPersistence());
+ assertEquals(vip.getConnectionLimit(), Integer.valueOf(-1));
+ assertEquals(vip.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(vip.getStatus(), LBaaSStatus.PENDING_CREATE);
+ assertNull(vip.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateVIPFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ VIP.CreateVIP createVIP = VIP.createBuilder("8032909d-47a1-4715-90af-5153ffe39861", Protocol.HTTP, 80, "61b1f87a-7a21-4ad3-9dda-7f81d249944f")
+ .name("NewVip").description(null).address(null).sessionPersistence(null).connectionLimit(null).build();
+
+ lbaasApi.createVIP(createVIP);
+
+ fail("Should have failed with not found exception");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageVIP() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/vip_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ VIPs vips = lbaasApi.listVIPs(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vips);
+ assertEquals(vips.size(), 1);
+ assertEquals(vips.first().get().getId(), "4ec89087-d057-4e2c-911f-60a3b47ee304");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageVIPFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ VIPs vips = lbaasApi.listVIPs(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vips);
+ assertTrue(vips.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedVIP() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/vip_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/vip_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<VIP> vips = lbaasApi.listVIPs().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 4);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips?marker=396f12f8-521e-4b91-8e21-2e003500433a");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vips);
+ assertEquals(vips.size(), 2);
+ assertEquals(vips.get(0).getId(), "4ec89087-d057-4e2c-911f-60a3b47ee304");
+ assertEquals(vips.get(1).getId(), "c987d2be-9a3c-4ac9-a046-e8716b1350e2");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedVIPFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<VIP> vips = lbaasApi.listVIPs().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vips);
+ assertTrue(vips.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetVIP() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/vip_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ VIP vip = lbaasApi.getVIP("4ec89087-d057-4e2c-911f-60a3b47ee304");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips/4ec89087-d057-4e2c-911f-60a3b47ee304");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vip);
+ assertNotNull(vip.getId());
+ assertEquals(vip.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertEquals(vip.getName(), "my-vip");
+ assertEquals(vip.getDescription(), "");
+ assertEquals(vip.getSubnetId(), "8032909d-47a1-4715-90af-5153ffe39861");
+ assertEquals(vip.getAddress(), "10.0.0.10");
+ assertEquals(vip.getPortId(), "b5a743d6-056b-468b-862d-fb13a9aa694e");
+ assertEquals(vip.getProtocol(), Protocol.HTTP);
+ assertEquals(vip.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(vip.getPoolId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ SessionPersistence sessionPersistence = SessionPersistence.builder().type(SessionPersistence.Type.APP_COOKIE).cookieName("MyAppCookie").build();
+ assertEquals(vip.getSessionPersistence(), sessionPersistence);
+ assertEquals(vip.getConnectionLimit(), Integer.valueOf(1000));
+ assertEquals(vip.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(vip.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(vip.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetVIPFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ VIP vip = lbaasApi.getVIP("4ec89087-d057-4e2c-911f-60a3b47ee304");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips/4ec89087-d057-4e2c-911f-60a3b47ee304");
+
+ /*
+ * Check response
+ */
+ assertNull(vip);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateVIP() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/vip_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ SessionPersistence sessionPersistence = SessionPersistence.builder().type(SessionPersistence.Type.APP_COOKIE).cookieName("MyNewAppCookie").build();
+ VIP.UpdateVIP updateVIP = VIP.updateBuilder().name("new-name").description("new description").poolId("61b1f87a-7a21-4ad3-9dda-7f81d249944f")
+ .sessionPersistence(sessionPersistence).connectionLimit(50).adminStateUp(Boolean.FALSE).build();
+
+ VIP vip = lbaasApi.updateVIP("c987d2be-9a3c-4ac9-a046-e8716b1350e2", updateVIP);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/vips/c987d2be-9a3c-4ac9-a046-e8716b1350e2", "/lbaas/v1/vip_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vip);
+ assertNotNull(vip.getId());
+ assertEquals(vip.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertEquals(vip.getName(), "new-name");
+ assertEquals(vip.getDescription(), "new description");
+ assertEquals(vip.getSubnetId(), "8032909d-47a1-4715-90af-5153ffe39861");
+ assertEquals(vip.getAddress(), "10.0.0.11");
+ assertEquals(vip.getPortId(), "f7e6fe6a-b8b5-43a8-8215-73456b32e0f5");
+ assertEquals(vip.getProtocol(), Protocol.HTTP);
+ assertEquals(vip.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(vip.getPoolId(), "61b1f87a-7a21-4ad3-9dda-7f81d249944f");
+ assertEquals(vip.getSessionPersistence(), sessionPersistence);
+ assertEquals(vip.getConnectionLimit(), Integer.valueOf(50));
+ assertEquals(vip.getAdminStateUp(), Boolean.FALSE);
+ assertEquals(vip.getStatus(), LBaaSStatus.PENDING_UPDATE);
+ assertNull(vip.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateVIPFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ SessionPersistence sessionPersistence = SessionPersistence.builder().type(SessionPersistence.Type.APP_COOKIE).cookieName("MyNewAppCookie").build();
+ VIP.UpdateVIP updateVIP = VIP.updateBuilder().name("new-name").description("new description").poolId("61b1f87a-7a21-4ad3-9dda-7f81d249944f")
+ .sessionPersistence(sessionPersistence).connectionLimit(50).adminStateUp(Boolean.FALSE).build();
+
+ VIP vip = lbaasApi.updateVIP("c987d2be-9a3c-4ac9-a046-e8716b1350e2", updateVIP);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/vips/c987d2be-9a3c-4ac9-a046-e8716b1350e2", "/lbaas/v1/vip_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(vip);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteVIP() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deleteVIP("c987d2be-9a3c-4ac9-a046-e8716b1350e2");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/vips/c987d2be-9a3c-4ac9-a046-e8716b1350e2");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteVIPFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deleteVIP("c987d2be-9a3c-4ac9-a046-e8716b1350e2");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/vips/c987d2be-9a3c-4ac9-a046-e8716b1350e2");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateHealthMonitor() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/health_monitor_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor.CreateHealthMonitor createHealthMonitor = HealthMonitor.createBuilder(ProbeType.HTTP, Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1))
+ .httpMethod(null).urlPath(null).expectedCodes(null).adminStateUp(null).build();
+
+ HealthMonitor healthMonitor = lbaasApi.createHealthMonitor(createHealthMonitor);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "POST", "/v2.0/lb/health_monitors", "/lbaas/v1/health_monitor_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitor);
+ assertNotNull(healthMonitor.getId());
+ assertEquals(healthMonitor.getTenantId(), "4fd44f30292945e481c7b8a0c8908869");
+ assertEquals(healthMonitor.getType(), ProbeType.HTTP);
+ assertEquals(healthMonitor.getDelay(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getTimeout(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getMaxRetries(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getHttpMethod(), HttpMethod.GET);
+ assertEquals(healthMonitor.getUrlPath(), "/");
+ assertEquals(healthMonitor.getExpectedCodes(), "200");
+ assertNotNull(healthMonitor.getPools());
+ assertTrue(healthMonitor.getPools().isEmpty());
+ assertEquals(healthMonitor.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(healthMonitor.getStatus(), LBaaSStatus.PENDING_CREATE);
+ assertNull(healthMonitor.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateHealthMonitorFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor.CreateHealthMonitor createHealthMonitor = HealthMonitor.createBuilder(ProbeType.HTTP, Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1))
+ .httpMethod(null).urlPath(null).expectedCodes(null).adminStateUp(null).build();
+
+ lbaasApi.createHealthMonitor(createHealthMonitor);
+
+ fail("Should have failed with not found exception");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageHealthMonitor() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/health_monitor_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitors healthMonitors = lbaasApi.listHealthMonitors(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitors);
+ assertEquals(healthMonitors.size(), 1);
+ assertEquals(healthMonitors.first().get().getId(), "466c8345-28d8-4f84-a246-e04380b0461d");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageHealthMonitorFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitors healthMonitors = lbaasApi.listHealthMonitors(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitors);
+ assertTrue(healthMonitors.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedHealthMonitor() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/health_monitor_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/health_monitor_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<HealthMonitor> healthMonitors = lbaasApi.listHealthMonitors().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 4);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors?marker=396f12f8-521e-4b91-8e21-2e003500433a");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitors);
+ assertEquals(healthMonitors.size(), 2);
+ assertEquals(healthMonitors.get(0).getId(), "466c8345-28d8-4f84-a246-e04380b0461d");
+ assertEquals(healthMonitors.get(1).getId(), "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedHealthMonitorFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<HealthMonitor> healthMonitors = lbaasApi.listHealthMonitors().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitors);
+ assertTrue(healthMonitors.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetHealthMonitor() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/health_monitor_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor healthMonitor = lbaasApi.getHealthMonitor("5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors/5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitor);
+ assertEquals(healthMonitor.getId(), "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+ assertEquals(healthMonitor.getTenantId(), "4fd44f30292945e481c7b8a0c8908869");
+ assertEquals(healthMonitor.getType(), ProbeType.HTTP);
+ assertEquals(healthMonitor.getDelay(), Integer.valueOf(5));
+ assertEquals(healthMonitor.getTimeout(), Integer.valueOf(2));
+ assertEquals(healthMonitor.getMaxRetries(), Integer.valueOf(2));
+ assertEquals(healthMonitor.getHttpMethod(), HttpMethod.GET);
+ assertEquals(healthMonitor.getUrlPath(), "/");
+ assertEquals(healthMonitor.getExpectedCodes(), "200");
+ assertNotNull(healthMonitor.getPools());
+ assertTrue(healthMonitor.getPools().isEmpty());
+ assertEquals(healthMonitor.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(healthMonitor.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(healthMonitor.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetHealthMonitorFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor healthMonitor = lbaasApi.getHealthMonitor("5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors/5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check response
+ */
+ assertNull(healthMonitor);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateHealthMonitor() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/health_monitor_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor.UpdateHealthMonitor updateHealthMonitor = HealthMonitor.updateBuilder().delay(Integer.valueOf(1)).timeout(Integer.valueOf(1)).maxRetries(Integer.valueOf(1))
+ .httpMethod(HttpMethod.HEAD).urlPath("/index.html").expectedCodes("201").adminStateUp(Boolean.FALSE).build();
+
+ HealthMonitor healthMonitor = lbaasApi.updateHealthMonitor("466c8345-28d8-4f84-a246-e04380b0461d", updateHealthMonitor);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/health_monitors/466c8345-28d8-4f84-a246-e04380b0461d", "/lbaas/v1/health_monitor_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitor);
+ assertEquals(healthMonitor.getId(), "466c8345-28d8-4f84-a246-e04380b0461d");
+ assertEquals(healthMonitor.getTenantId(), "4fd44f30292945e481c7b8a0c8908869");
+ assertEquals(healthMonitor.getType(), ProbeType.HTTP);
+ assertEquals(healthMonitor.getDelay(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getTimeout(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getMaxRetries(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getHttpMethod(), HttpMethod.HEAD);
+ assertEquals(healthMonitor.getUrlPath(), "/index.html");
+ assertEquals(healthMonitor.getExpectedCodes(), "201");
+ assertNotNull(healthMonitor.getPools());
+ assertTrue(healthMonitor.getPools().isEmpty());
+ assertEquals(healthMonitor.getAdminStateUp(), Boolean.FALSE);
+ assertEquals(healthMonitor.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(healthMonitor.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateHealthMonitorFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor.UpdateHealthMonitor updateHealthMonitor = HealthMonitor.updateBuilder().delay(Integer.valueOf(1)).timeout(Integer.valueOf(1)).maxRetries(Integer.valueOf(1))
+ .httpMethod(HttpMethod.HEAD).urlPath("/index.html").expectedCodes("201").adminStateUp(Boolean.FALSE).build();
+
+ HealthMonitor healthMonitor = lbaasApi.updateHealthMonitor("466c8345-28d8-4f84-a246-e04380b0461d", updateHealthMonitor);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/health_monitors/466c8345-28d8-4f84-a246-e04380b0461d", "/lbaas/v1/health_monitor_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(healthMonitor);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteHealthMonitor() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deleteHealthMonitor("466c8345-28d8-4f84-a246-e04380b0461d");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/health_monitors/466c8345-28d8-4f84-a246-e04380b0461d");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteHealthMonitorFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deleteHealthMonitor("466c8345-28d8-4f84-a246-e04380b0461d");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/health_monitors/466c8345-28d8-4f84-a246-e04380b0461d");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testAssociateHealthMonitorWithPool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/pool_associate_health_monitor_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor healthMonitor = lbaasApi.associateHealthMonitor("72741b06-df4d-4715-b142-276b6bce75ab", "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "POST", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab/health_monitors", "/lbaas/v1/pool_associate_health_monitor_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitor);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testAssociateHealthMonitorWithPoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ lbaasApi.associateHealthMonitor("72741b06-df4d-4715-b142-276b6bce75ab", "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ fail("Should have failed with not found exception");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDisassociateHealthMonitorFromPool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.disassociateHealthMonitor("72741b06-df4d-4715-b142-276b6bce75ab", "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab/health_monitors/5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDisassociateHealthMonitorFromPoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.disassociateHealthMonitor("72741b06-df4d-4715-b142-276b6bce75ab", "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab/health_monitors/5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/ExtensionApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/ExtensionApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/ExtensionApiLiveTest.java
new file mode 100644
index 0000000..6dd729a
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/features/ExtensionApiLiveTest.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Set;
+
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiLiveTest;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.openstack.v2_0.features.ExtensionApi;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@link ExtensionApi}
+ */
+@Test(groups = "live", testName = "ExtensionApiLiveTest")
+public class ExtensionApiLiveTest extends BaseNeutronApiLiveTest {
+
+ /**
+ * Tests the listing of Neutron Extensions.
+ *
+ * @throws Exception
+ */
+ public void testListExtensions() throws Exception {
+ for (String regionId : api.getConfiguredRegions()) {
+ ExtensionApi extensionApi = api.getExtensionApi(regionId);
+ Set<Extension> response = extensionApi.list();
+ assertNotNull(response);
+ assertFalse(response.isEmpty());
+
+ for (Extension extension : response) {
+ assertNotNull(extension.getId());
+ assertNotNull(extension.getName());
+ assertNotNull(extension.getDescription());
+ assertNotNull(extension.getNamespace());
+ assertNotNull(extension.getUpdated());
+ assertNotNull(extension.getLinks());
+ }
+ }
+ }
+
+ /**
+ * Tests retrieval of Neutron Extensions by their alias.
+ *
+ * @throws Exception
+ */
+ public void testGetExtensionByAlias() throws Exception {
+ for (String regionId : api.getConfiguredRegions()) {
+ ExtensionApi extensionApi = api.getExtensionApi(regionId);
+ Set<Extension> response = extensionApi.list();
+ assertNotNull(response);
+
+ for (Extension extension : response) {
+ Extension details = extensionApi.get(extension.getId());
+ assertNotNull(details);
+ assertEquals(details.getId(), extension.getId());
+ assertEquals(details.getName(), extension.getName());
+ assertEquals(details.getDescription(), extension.getDescription());
+ assertEquals(details.getNamespace(), extension.getNamespace());
+ assertEquals(details.getUpdated(), extension.getUpdated());
+ assertEquals(details.getLinks(), extension.getLinks());
+ }
+ }
+ }
+
+}
[21/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/internal/BaseNeutronApiMockTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/internal/BaseNeutronApiMockTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/internal/BaseNeutronApiMockTest.java
new file mode 100644
index 0000000..fd4a50e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/internal/BaseNeutronApiMockTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2.internal;
+
+import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
+
+import java.util.Properties;
+
+import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest;
+
+/**
+ * Base class for writing Neutron Mock tests
+ *
+ */
+public class BaseNeutronApiMockTest extends BaseOpenStackMockTest<NeutronApi> {
+ protected Properties overrides;
+ /**
+ * Base Mock Test
+ */
+ public BaseNeutronApiMockTest() {
+ overrides = new Properties();
+ //overrides.setProperty(SERVICE_TYPE, "neutron");
+ overrides.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/util/ClassUtil.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/util/ClassUtil.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/util/ClassUtil.java
new file mode 100644
index 0000000..b9ba915
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/util/ClassUtil.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.util;
+
+import java.lang.reflect.Field;
+
+public class ClassUtil {
+
+ public static Field findField(Class clazz, String fieldName) {
+ Field fieldToFind = null;
+ if (clazz.getSuperclass() != null)
+ fieldToFind = findField(clazz.getSuperclass(), fieldName);
+
+ if (fieldToFind != null)
+ return fieldToFind;
+
+ for (Field field : clazz.getDeclaredFields()) {
+ if (field.getName().equals(fieldName))
+ return field;
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/util/PredicateUtil.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/util/PredicateUtil.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/util/PredicateUtil.java
new file mode 100644
index 0000000..a3c39ce
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2/util/PredicateUtil.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2.util;
+
+import com.google.common.base.Predicate;
+import org.jclouds.javax.annotation.Nullable;
+
+import java.lang.reflect.Field;
+
+public class PredicateUtil {
+
+ public static <T> Predicate<T> createIdEqualsPredicate(final String id) {
+ return new Predicate<T>() {
+ @Override
+ public boolean apply(@Nullable T input) {
+ if (input == null) return false;
+
+ try {
+ Class clazz = input.getClass();
+ Field field = ClassUtil.findField(clazz, "id");
+ field.setAccessible(true);
+ String value = (String) field.get(input);
+ field.setAccessible(false);
+ return value != null && value.equals(id);
+ } catch (IllegalAccessException iae) {
+ return false;
+ }
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/NeutronApiMetadataTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/NeutronApiMetadataTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/NeutronApiMetadataTest.java
new file mode 100644
index 0000000..db3019c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/NeutronApiMetadataTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.reflect.TypeToken;
+import org.jclouds.View;
+import org.jclouds.apis.internal.BaseApiMetadataTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "NeutronApiMetadataTest")
+public class NeutronApiMetadataTest extends BaseApiMetadataTest {
+ public NeutronApiMetadataTest() {
+ super(new NeutronApiMetadata(), ImmutableSet.<TypeToken<? extends View>>of());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/extensions/RouterApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/extensions/RouterApiExpectTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/extensions/RouterApiExpectTest.java
new file mode 100644
index 0000000..c3f04cc
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/extensions/RouterApiExpectTest.java
@@ -0,0 +1,295 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.extensions;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.neutron.v2_0.domain.ExternalGatewayInfo;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.domain.Router;
+import org.jclouds.openstack.neutron.v2_0.domain.RouterInterface;
+import org.jclouds.openstack.neutron.v2_0.domain.State;
+import org.jclouds.openstack.neutron.v2_0.internal.BaseNeutronApiExpectTest;
+import org.jclouds.openstack.neutron.v2_0.options.CreateRouterOptions;
+import org.jclouds.openstack.neutron.v2_0.options.UpdateRouterOptions;
+import org.jclouds.openstack.neutron.v2_0.parse.ParseRouterTest;
+import org.jclouds.rest.AuthorizationException;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests parsing and Guice wiring of RouterApi
+ *
+ */
+@Test(groups = "unit", testName = "RouterApiExpectTest")
+public class RouterApiExpectTest extends BaseNeutronApiExpectTest {
+
+ private static final String ZONE = "region-a.geo-1";
+
+ public void testListReferencesReturns2xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers").addQueryParam("fields", "id", "tenant_id", "name").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/list_routers.json", APPLICATION_JSON)).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ Set<? extends ReferenceWithName> references = api.list().concat().toSet();
+ assertEquals(references, listOfReferencesWithNames());
+ }
+
+ public void testListReferencesReturns4xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers").addQueryParam("fields", "id", "tenant_id", "name").build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ assertTrue(api.list().concat().isEmpty());
+ }
+
+ public void testListReturns2xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/list_routers.json", APPLICATION_JSON)).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ Set<? extends Router> routers = api.listInDetail().concat().toSet();
+ assertEquals(routers, listOfRouters());
+ }
+
+ public void testListReturns4xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers").build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ assertTrue(api.listInDetail().concat().isEmpty());
+ }
+
+ public void testGetReturns2xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/16dba3bc-f3fa-4775-afdc-237e12c72f6a").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/router.json", APPLICATION_JSON)).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ Router router = api.get("16dba3bc-f3fa-4775-afdc-237e12c72f6a");
+ assertEquals(router, new ParseRouterTest().expected());
+ }
+
+ public void testGetReturns4xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/16dba3bc-f3fa-4775-afdc-237e12c72f6a").build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ assertNull(api.get("16dba3bc-f3fa-4775-afdc-237e12c72f6a"));
+ }
+
+ public void testCreateReturns2xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers").method("POST")
+ .payload(payloadFromStringWithContentType("{\"router\":{\"name\":\"test\",\"external_gateway_info\":{\"network_id\":\"1234567890\"}}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromStringWithContentType("{\"router\":{\"id\":\"12345\",\"tenant_id\":\"6789\",\"external_gateway_info\":{\"network_id\":\"1234567890\"}}}", APPLICATION_JSON)).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ Router router = api.create(CreateRouterOptions.builder().name("test").externalGatewayInfo(ExternalGatewayInfo.builder().networkId("1234567890").build()).build());
+ assertEquals(router, Router.builder().id("12345").tenantId("6789").externalGatewayInfo(ExternalGatewayInfo.builder().networkId("1234567890").build()).build());
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testCreateReturns4xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers").method("POST")
+ .payload(payloadFromStringWithContentType("{\"router\":{\"name\":\"another-test\",\"external_gateway_info\":{\"network_id\":\"1234567890\"}}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(401).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ api.create(CreateRouterOptions.builder().name("another-test").externalGatewayInfo(ExternalGatewayInfo.builder().networkId("1234567890").build()).build());
+ }
+
+ public void testUpdateReturns2xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/12345").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"router\":{\"name\":\"another-test\",\"admin_state_up\":true}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ assertTrue(api.update("12345", UpdateRouterOptions.builder().name("another-test").adminStateUp(true).build()));
+ }
+
+ public void testUpdateReturns4xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/12345").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"router\":{\"name\":\"another-test\",\"admin_state_up\":true}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ assertFalse(api.update("12345", UpdateRouterOptions.builder().name("another-test").adminStateUp(true).build()));
+ }
+
+ public void testDeleteReturns2xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/12345").method("DELETE").build(),
+ HttpResponse.builder().statusCode(200).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ assertTrue(api.delete("12345"));
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testDeleteReturns4xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/12345").method("DELETE").build(),
+ HttpResponse.builder().statusCode(403).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ api.delete("12345");
+ }
+
+ public void testAddInterfaceForSubnetReturns2xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/12345/add_router_interface").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"subnet_id\":\"1234567890\"}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromStringWithContentType("{\"subnet_id\":\"1234567890\",\"port_id\":\"987654321\"}", MediaType.APPLICATION_JSON)).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ RouterInterface routerInterface = api.addInterfaceForSubnet("12345", "1234567890");
+ assertEquals(routerInterface, RouterInterface.builder().subnetId("1234567890").portId("987654321").build());
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testAddInterfaceForSubnetReturns4xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/12345/add_router_interface").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"subnet_id\":\"1234567890\"}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(403).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ api.addInterfaceForSubnet("12345", "1234567890");
+ }
+
+ public void testAddInterfaceForPortReturns2xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/12345/add_router_interface").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"port_id\":\"987654321\"}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromStringWithContentType("{\"subnet_id\":\"1234567890\",\"port_id\":\"987654321\"}", MediaType.APPLICATION_JSON)).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ RouterInterface routerInterface = api.addInterfaceForPort("12345", "987654321");
+ assertEquals(routerInterface, RouterInterface.builder().subnetId("1234567890").portId("987654321").build());
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testAddInterfaceForPortReturns4xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/12345/add_router_interface").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"port_id\":\"1234567890\"}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(403).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ api.addInterfaceForPort("12345", "1234567890");
+ }
+
+ public void testRemoveInterfaceForSubnetReturns2xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/12345/remove_router_interface").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"subnet_id\":\"1234567890\"}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ api.removeInterfaceForSubnet("12345", "1234567890");
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testRemoveInterfaceForSubnetReturns4xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/12345/remove_router_interface").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"subnet_id\":\"1234567890\"}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(403).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ api.removeInterfaceForSubnet("12345", "1234567890");
+ }
+
+ public void testRemoveInterfaceForPortReturns2xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/12345/remove_router_interface").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"port_id\":\"1234567890\"}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ api.removeInterfaceForPort("12345", "1234567890");
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testRemoveInterfaceForPortReturns4xx() {
+ RouterApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/routers/12345/remove_router_interface").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"port_id\":\"1234567890\"}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(403).build())
+ .getRouterExtensionForZone(ZONE).get();
+
+ api.removeInterfaceForPort("12345", "1234567890");
+ }
+
+ protected Set<Router> listOfRouters() {
+ return ImmutableSet.of(
+ Router.builder().state(State.ACTIVE).name("jclouds-test").tenantId("1234567890").id("16dba3bc-f3fa-4775-afdc-237e12c72f6a").build(),
+ Router.builder().state(State.ACTIVE).name("wibble").tenantId("1234567890").id("1a104cf5-cb18-4d35-9407-2fd2646d9d0b").build(),
+ Router.builder().state(State.ACTIVE).name("jclouds-test").tenantId("1234567890").id("31083ae2-420d-48b2-ac98-9f7a4fd8dbdc").build(),
+ Router.builder().state(State.ACTIVE).name("jclouds-test").tenantId("1234567890").id("49c6d6fa-ff2a-459d-b975-75a8d31c9a89").build(),
+ Router.builder().state(State.ACTIVE).name("wibble").tenantId("1234567890").id("5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e").build(),
+ Router.builder().state(State.ACTIVE).name("jclouds-test").tenantId("1234567890").id("5d51d012-3491-4db7-b1b5-6f254015015d").build(),
+ Router.builder().state(State.ACTIVE).name("wibble").tenantId("1234567890").id("5f9cf7dc-22ca-4097-8e49-1cc8b23faf17").build(),
+ Router.builder().state(State.ACTIVE).name("jclouds-test").tenantId("1234567890").id("6319ecad-6bff-48b2-9b53-02ede8cb7588").build(),
+ Router.builder().state(State.ACTIVE).name("jclouds-test").tenantId("1234567890").id("6ba4c788-661f-49ab-9bf8-5f10cbbb2f57").build(),
+ Router.builder().state(State.ACTIVE).name("jclouds-test").tenantId("1234567890").id("74ed170b-5069-4353-ab38-9719766dc57e").build(),
+ Router.builder().state(State.ACTIVE).name("wibble").tenantId("1234567890").id("b71fcac1-e864-4031-8c5b-edbecd9ece36").build(),
+ Router.builder().state(State.ACTIVE).name("jclouds-test").tenantId("1234567890").id("c7681895-d84d-4650-9ca0-82c72036b855").build()
+ );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/extensions/RouterApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/extensions/RouterApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/extensions/RouterApiLiveTest.java
new file mode 100644
index 0000000..e51a8c4
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/extensions/RouterApiLiveTest.java
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.neutron.v2_0.domain.ExternalGatewayInfo;
+import org.jclouds.openstack.neutron.v2_0.domain.Network;
+import org.jclouds.openstack.neutron.v2_0.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2_0.domain.Port;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.domain.Router;
+import org.jclouds.openstack.neutron.v2_0.domain.RouterInterface;
+import org.jclouds.openstack.neutron.v2_0.domain.Subnet;
+import org.jclouds.openstack.neutron.v2_0.features.NetworkApi;
+import org.jclouds.openstack.neutron.v2_0.features.PortApi;
+import org.jclouds.openstack.neutron.v2_0.features.SubnetApi;
+import org.jclouds.openstack.neutron.v2_0.internal.BaseNeutronApiLiveTest;
+import org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreateRouterOptions;
+import org.jclouds.openstack.neutron.v2_0.options.UpdateRouterOptions;
+import org.testng.annotations.Test;
+
+/**
+ * Tests parsing and Guice wiring of RouterApi
+ *
+ */
+@Test(groups = "live", testName = "RouterApiLiveTest")
+public class RouterApiLiveTest extends BaseNeutronApiLiveTest {
+
+ public void testGetAndListRouters() {
+ for (String zone : api.getConfiguredZones()) {
+ Set<? extends ReferenceWithName> references = api.getRouterExtensionForZone(zone).get().list().concat().toSet();
+ Set<? extends Router> routers = api.getRouterExtensionForZone(zone).get().listInDetail().concat().toSet();
+
+ assertNotNull(references);
+ assertNotNull(routers);
+ assertEquals(references.size(), routers.size());
+
+ for (Router router : routers) {
+ assertNotNull(router.getName());
+ assertTrue(references.contains(ReferenceWithName.builder().id(router.getId()).tenantId(router.getTenantId()).name(router.getName()).build()));
+
+ Router retrievedRouter = api.getRouterExtensionForZone(zone).get().get(router.getId());
+ assertEquals(router, retrievedRouter);
+ }
+ }
+ }
+
+ public void testCreateUpdateAndDeleteRouter() {
+ for (String zone : api.getConfiguredZones()) {
+ RouterApi routerApi = api.getRouterExtensionForZone(zone).get();
+ NetworkApi networkApi = api.getNetworkApiForZone(zone);
+ SubnetApi subnetApi = api.getSubnetApiForZone(zone);
+
+ Network network = networkApi.create(CreateNetworkOptions.builder().name("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build());
+ assertNotNull(network);
+
+ Subnet subnet = subnetApi.create(network.getId(), 4, "192.168.0.0/16");
+ assertNotNull(subnet);
+
+ Router ref = routerApi.create(CreateRouterOptions.builder().name("jclouds-router-test")
+ .externalGatewayInfo(ExternalGatewayInfo.builder().networkId(network.getId()).build()).build());
+ assertNotNull(ref);
+
+ Router router = routerApi.get(ref.getId());
+
+ assertEquals(router.getId(), ref.getId());
+ assertEquals(router.getName(), "jclouds-router-test");
+ assertEquals(router.getExternalGatewayInfo().getNetworkId(), network.getId());
+ assertTrue(routerApi.update(router.getId(), UpdateRouterOptions.builder().name("jclouds-router-test-rename").build()));
+
+ router = routerApi.get(ref.getId());
+
+ assertEquals(router.getId(), ref.getId());
+ assertEquals(router.getName(), "jclouds-router-test-rename");
+
+ ReferenceWithName ref2 = routerApi.create(CreateRouterOptions.builder().name("jclouds-router-test2")
+ .externalGatewayInfo(ExternalGatewayInfo.builder().networkId(network.getId()).build()).build());
+ assertNotNull(ref2);
+
+ assertTrue(routerApi.delete(ref.getId()));
+ assertTrue(routerApi.delete(ref2.getId()));
+ assertTrue(subnetApi.delete(subnet.getId()));
+ assertTrue(networkApi.delete(network.getId()));
+ }
+ }
+
+ public void testCreateAndDeleteRouterInterfaceForSubnet() {
+ for (String zone : api.getConfiguredZones()) {
+ RouterApi routerApi = api.getRouterExtensionForZone(zone).get();
+ NetworkApi networkApi = api.getNetworkApiForZone(zone);
+ SubnetApi subnetApi = api.getSubnetApiForZone(zone);
+
+ Network network = networkApi.create(CreateNetworkOptions.builder().name("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build());
+ assertNotNull(network);
+
+ Subnet subnet = subnetApi.create(network.getId(), 4, "192.168.0.0/16");
+ assertNotNull(subnet);
+
+ Network network2 = networkApi.create(CreateNetworkOptions.builder().name("jclouds-network-test2").external(true).networkType(NetworkType.LOCAL).build());
+ assertNotNull(network2);
+
+ Subnet subnet2 = subnetApi.create(network2.getId(), 4, "192.169.0.0/16");
+ assertNotNull(subnet2);
+
+ Router router = routerApi.create(CreateRouterOptions.builder().name("jclouds-router-test").build());
+ assertNotNull(router);
+
+ RouterInterface routerInterface = routerApi.addInterfaceForSubnet(router.getId(), subnet.getId());
+ assertNotNull(routerInterface);
+
+ RouterInterface routerInterface2 = routerApi.addInterfaceForSubnet(router.getId(), subnet2.getId());
+ assertNotNull(routerInterface2);
+
+ assertTrue(routerApi.removeInterfaceForSubnet(router.getId(), subnet.getId()));
+ assertTrue(routerApi.removeInterfaceForSubnet(router.getId(), subnet2.getId()));
+ assertTrue(routerApi.delete(router.getId()));
+ assertTrue(subnetApi.delete(subnet.getId()));
+ assertTrue(networkApi.delete(network.getId()));
+ assertTrue(subnetApi.delete(subnet2.getId()));
+ assertTrue(networkApi.delete(network2.getId()));
+ }
+ }
+
+ public void testCreateAndDeleteRouterInterfaceForPort() {
+ for (String zone : api.getConfiguredZones()) {
+ RouterApi routerApi = api.getRouterExtensionForZone(zone).get();
+ NetworkApi networkApi = api.getNetworkApiForZone(zone);
+ SubnetApi subnetApi = api.getSubnetApiForZone(zone);
+ PortApi portApi = api.getPortApiForZone(zone);
+
+ Network network = networkApi.create(CreateNetworkOptions.builder().name("jclouds-network-test").external(true).networkType(NetworkType.LOCAL).build());
+ assertNotNull(network);
+
+ Subnet subnet = subnetApi.create(network.getId(), 4, "192.168.0.0/16");
+ assertNotNull(subnet);
+
+ Network network2 = networkApi.create(CreateNetworkOptions.builder().name("jclouds-network-test2").external(true).networkType(NetworkType.LOCAL).build());
+ assertNotNull(network2);
+
+ Subnet subnet2 = subnetApi.create(network2.getId(), 4, "192.169.0.0/16");
+ assertNotNull(subnet2);
+
+ Port port = portApi.create(network.getId());
+ assertNotNull(port);
+
+ Port port2 = portApi.create(network2.getId());
+ assertNotNull(port2);
+
+ Router router = routerApi.create(CreateRouterOptions.builder().name("jclouds-router-test").build());
+ assertNotNull(router);
+
+ RouterInterface routerInterface = routerApi.addInterfaceForPort(router.getId(), port.getId());
+ assertNotNull(routerInterface);
+
+ RouterInterface routerInterface2 = routerApi.addInterfaceForPort(router.getId(), port2.getId());
+ assertNotNull(routerInterface2);
+
+ assertTrue(routerApi.removeInterfaceForPort(router.getId(), port.getId()));
+ assertTrue(routerApi.removeInterfaceForPort(router.getId(), port2.getId()));
+ assertTrue(routerApi.delete(router.getId()));
+ assertTrue(subnetApi.delete(subnet.getId()));
+ assertTrue(networkApi.delete(network.getId()));
+ assertTrue(subnetApi.delete(subnet2.getId()));
+ assertTrue(networkApi.delete(network2.getId()));
+
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/NetworkApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/NetworkApiExpectTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/NetworkApiExpectTest.java
new file mode 100644
index 0000000..2d2b09c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/NetworkApiExpectTest.java
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.features;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.neutron.v2_0.domain.BulkNetwork;
+import org.jclouds.openstack.neutron.v2_0.domain.Network;
+import org.jclouds.openstack.neutron.v2_0.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.internal.BaseNeutronApiExpectTest;
+import org.jclouds.openstack.neutron.v2_0.options.CreateNetworkBulkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.UpdateNetworkOptions;
+import org.jclouds.openstack.neutron.v2_0.parse.ParseNetworkTest;
+import org.jclouds.rest.AuthorizationException;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests parsing and Guice wiring of NetworkApi
+ *
+ */
+@Test(groups = "unit", testName = "NetworkApiExpectTest")
+public class NetworkApiExpectTest extends BaseNeutronApiExpectTest {
+
+ private static final String ZONE = "region-a.geo-1";
+
+ public void testListReferencesReturns2xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks").addQueryParam("fields", "id", "tenant_id", "name").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/list_networks.json", APPLICATION_JSON)).build())
+ .getNetworkApiForZone(ZONE);
+
+ Set<? extends ReferenceWithName> references = api.list().concat().toSet();
+ assertEquals(references, listOfReferencesWithNames());
+ }
+
+ public void testListReferencesReturns4xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks").addQueryParam("fields", "id", "tenant_id", "name").build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getNetworkApiForZone(ZONE);
+
+ assertTrue(api.list().concat().isEmpty());
+ }
+
+ public void testListReturns2xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/list_networks.json", APPLICATION_JSON)).build())
+ .getNetworkApiForZone(ZONE);
+
+ Set<? extends Network> nets = api.listInDetail().concat().toSet();
+ assertEquals(nets, listOfNetworks());
+ }
+
+ public void testListReturns4xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks").build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getNetworkApiForZone(ZONE);
+
+ assertTrue(api.listInDetail().concat().isEmpty());
+ }
+
+ public void testGetReturns2xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/network.json", APPLICATION_JSON)).build())
+ .getNetworkApiForZone(ZONE);
+
+ Network net = api.get("16dba3bc-f3fa-4775-afdc-237e12c72f6a");
+ assertEquals(net, new ParseNetworkTest().expected());
+ }
+
+ public void testGetReturns4xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a").build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getNetworkApiForZone(ZONE);
+
+ assertNull(api.get("16dba3bc-f3fa-4775-afdc-237e12c72f6a"));
+ }
+
+ public void testCreateReturns2xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks").method("POST")
+ .payload(payloadFromStringWithContentType("{\"network\":{\"name\":\"another-test\",\"router:external\":true,\"provider:network_type\":\"local\"}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromStringWithContentType("{\"network\":{\"id\":\"12345\",\"tenant_id\":\"6789\",\"router:external\":true,\"provider:network_type\":\"local\"}}", APPLICATION_JSON)).build())
+ .getNetworkApiForZone(ZONE);
+
+ Network net = api.create(CreateNetworkOptions.builder().name("another-test").external(true).networkType(NetworkType.LOCAL).build());
+ assertEquals(net, Network.builder().id("12345").tenantId("6789").external(true).networkType(NetworkType.LOCAL).build());
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testCreateReturns4xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks").method("POST")
+ .payload(payloadFromStringWithContentType("{\"network\":{\"name\":\"another-test\",\"provider:network_type\":\"local\"}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(401).build())
+ .getNetworkApiForZone(ZONE);
+
+ api.create(CreateNetworkOptions.builder().name("another-test").networkType(NetworkType.LOCAL).build());
+ }
+
+ public void testCreateBulkReturns2xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks").method("POST")
+ .payload(payloadFromStringWithContentType("{\"networks\":[{\"name\":\"test\",\"provider:network_type\":\"local\"},{\"name\":\"test-2\",\"provider:network_type\":\"local\"}]}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromStringWithContentType("{\"networks\":[{\"id\":\"1\",\"tenant_id\":\"1\",\"name\":\"test\",\"provider:network_type\":\"local\"},{\"id\":\"2\",\"tenant_id\":\"1\",\"name\":\"test-2\",\"provider:network_type\":\"local\"}]}", APPLICATION_JSON)).build())
+ .getNetworkApiForZone(ZONE);
+
+ Set<? extends ReferenceWithName> nets = api.createBulk(
+ CreateNetworkBulkOptions.builder().networks(
+ ImmutableList.of(
+ BulkNetwork.builder().networkType(NetworkType.LOCAL).name("test").build(),
+ BulkNetwork.builder().networkType(NetworkType.LOCAL).name("test-2").build()
+ )
+ ).build()
+ ).toSet();
+ assertEquals(nets, createBulkReturns2xxResponse());
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testCreateBulkReturns4xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks").method("POST")
+ .payload(payloadFromStringWithContentType("{\"networks\":[{\"name\":\"test\",\"provider:network_type\":\"local\"},{\"name\":\"test-2\",\"provider:network_type\":\"local\"}]}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(401).build())
+ .getNetworkApiForZone(ZONE);
+
+ api.createBulk(
+ CreateNetworkBulkOptions.builder().networks(
+ ImmutableList.of(
+ BulkNetwork.builder().networkType(NetworkType.LOCAL).name("test").build(),
+ BulkNetwork.builder().networkType(NetworkType.LOCAL).name("test-2").build()
+ )
+ ).build()
+ );
+ }
+
+ public void testUpdateReturns2xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks/12345").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"network\":{\"name\":\"another-test\",\"admin_state_up\":true}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).build())
+ .getNetworkApiForZone(ZONE);
+
+ assertTrue(api.update("12345", UpdateNetworkOptions.builder().name("another-test").adminStateUp(true).build()));
+ }
+
+ public void testUpdateReturns4xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks/12345").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"network\":{\"name\":\"another-test\",\"admin_state_up\":true}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getNetworkApiForZone(ZONE);
+
+ assertFalse(api.update("12345", UpdateNetworkOptions.builder().name("another-test").adminStateUp(true).build()));
+ }
+
+ public void testDeleteReturns2xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks/12345").method("DELETE").build(),
+ HttpResponse.builder().statusCode(200).build())
+ .getNetworkApiForZone(ZONE);
+
+ assertTrue(api.delete("12345"));
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testDeleteReturns4xx() {
+ NetworkApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/networks/12345").method("DELETE").build(),
+ HttpResponse.builder().statusCode(403).build())
+ .getNetworkApiForZone(ZONE);
+
+ api.delete("12345");
+ }
+
+ protected Set<Network> listOfNetworks() {
+ return ImmutableSet.of(
+ Network.builder().name("jclouds-test").tenantId("1234567890").id("16dba3bc-f3fa-4775-afdc-237e12c72f6a").build(),
+ Network.builder().name("wibble").tenantId("1234567890").id("1a104cf5-cb18-4d35-9407-2fd2646d9d0b").build(),
+ Network.builder().name("jclouds-test").tenantId("1234567890").id("31083ae2-420d-48b2-ac98-9f7a4fd8dbdc").build(),
+ Network.builder().name("jclouds-test").tenantId("1234567890").id("49c6d6fa-ff2a-459d-b975-75a8d31c9a89").build(),
+ Network.builder().name("wibble").tenantId("1234567890").id("5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e").build(),
+ Network.builder().name("jclouds-test").tenantId("1234567890").id("5d51d012-3491-4db7-b1b5-6f254015015d").build(),
+ Network.builder().name("wibble").tenantId("1234567890").id("5f9cf7dc-22ca-4097-8e49-1cc8b23faf17").build(),
+ Network.builder().name("jclouds-test").tenantId("1234567890").id("6319ecad-6bff-48b2-9b53-02ede8cb7588").build(),
+ Network.builder().name("jclouds-test").tenantId("1234567890").id("6ba4c788-661f-49ab-9bf8-5f10cbbb2f57").build(),
+ Network.builder().name("jclouds-test").tenantId("1234567890").id("74ed170b-5069-4353-ab38-9719766dc57e").build(),
+ Network.builder().name("wibble").tenantId("1234567890").id("b71fcac1-e864-4031-8c5b-edbecd9ece36").build(),
+ Network.builder().name("jclouds-test").tenantId("1234567890").id("c7681895-d84d-4650-9ca0-82c72036b855").build()
+ );
+ }
+
+ protected Set<Network> createBulkReturns2xxResponse() {
+ return ImmutableSet.of(
+ Network.builder().id("1").tenantId("1").name("test").networkType(NetworkType.LOCAL).build(),
+ Network.builder().id("2").tenantId("1").name("test-2").networkType(NetworkType.LOCAL).build()
+ );
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/NetworkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/NetworkApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/NetworkApiLiveTest.java
new file mode 100644
index 0000000..cc72b1c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/NetworkApiLiveTest.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.neutron.v2_0.domain.BulkNetwork;
+import org.jclouds.openstack.neutron.v2_0.domain.Network;
+import org.jclouds.openstack.neutron.v2_0.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.internal.BaseNeutronApiLiveTest;
+import org.jclouds.openstack.neutron.v2_0.options.CreateNetworkBulkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.UpdateNetworkOptions;
+import org.jclouds.openstack.neutron.v2_0.util.PredicateUtil;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Sets;
+
+/**
+ * Tests parsing and Guice wiring of NetworkApi
+ *
+ */
+@Test(groups = "live", testName = "NetworkApiLiveTest")
+public class NetworkApiLiveTest extends BaseNeutronApiLiveTest {
+
+ public void testGetAndListNetworks() {
+ for (String zone : api.getConfiguredZones()) {
+ Set<? extends ReferenceWithName> references = api.getNetworkApiForZone(zone).list().concat().toSet();
+ Set<? extends Network> networks = api.getNetworkApiForZone(zone).listInDetail().concat().toSet();
+
+ assertNotNull(references);
+ assertNotNull(networks);
+ assertEquals(references.size(), networks.size());
+
+ for (Network network : networks) {
+ assertNotNull(network.getName());
+ assertTrue(references.contains(ReferenceWithName.builder().id(network.getId()).tenantId(network.getTenantId()).name(network.getName()).build()));
+
+ Network retrievedNetwork = api.getNetworkApiForZone(zone).get(network.getId());
+ assertEquals(network, retrievedNetwork);
+ }
+ }
+ }
+
+ public void testCreateUpdateAndDeleteNetwork() {
+ for (String zone : api.getConfiguredZones()) {
+ NetworkApi networkApi = api.getNetworkApiForZone(zone);
+ Network net = networkApi.create(CreateNetworkOptions.builder().name("jclouds-test").networkType(NetworkType.LOCAL).build());
+ Network test = networkApi.create();
+ assertNotNull(net);
+
+ Network network = networkApi.get(net.getId());
+
+ assertEquals(network.getId(), net.getId());
+ assertEquals(network.getName(), "jclouds-test");
+ assertEquals(network.getNetworkType(), NetworkType.LOCAL);
+ assertTrue(network.getSubnets().isEmpty());
+ assertTrue(networkApi.update(net.getId(), UpdateNetworkOptions.builder().name("jclouds-live-test").build()));
+
+ network = networkApi.get(net.getId());
+
+ assertEquals(network.getId(), net.getId());
+ assertEquals(network.getName(), "jclouds-live-test");
+ assertTrue(network.getSubnets().isEmpty());
+
+ Network net2 = networkApi.create(CreateNetworkOptions.builder().name("jclouds-test2").networkType(NetworkType.LOCAL).build());
+ assertNotNull(net2);
+
+ assertTrue(networkApi.delete(net.getId()));
+ assertTrue(networkApi.delete(net2.getId()));
+ assertTrue(networkApi.delete(test.getId()));
+ }
+ }
+
+ public void testBulkCreateNetwork() {
+ for (String zone : api.getConfiguredZones()) {
+ NetworkApi networkApi = api.getNetworkApiForZone(zone);
+ Set<? extends Network> nets = networkApi.createBulk(
+ CreateNetworkBulkOptions.builder().networks(
+ ImmutableList.of(
+ BulkNetwork.builder().networkType(NetworkType.LOCAL).name("jclouds-live-test-1").adminStateUp(true).build(),
+ BulkNetwork.builder().networkType(NetworkType.LOCAL).name("jclouds-live-test-2").adminStateUp(false).build(),
+ BulkNetwork.builder().networkType(NetworkType.LOCAL).name("jclouds-live-test-3").adminStateUp(false).build()
+ )
+ ).build()
+ ).toSet();
+ Set<? extends Network> existingNets = networkApi.listInDetail().concat().toSet();
+
+ assertNotNull(nets);
+ assertTrue(!nets.isEmpty());
+ assertEquals(nets.size(), 3);
+
+ for (Network net : nets) {
+ Predicate<Network> idEqualsPredicate = PredicateUtil.createIdEqualsPredicate(net.getId());
+ assertEquals(1, Sets.filter(existingNets, idEqualsPredicate).size());
+ assertTrue(networkApi.delete(net.getId()));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/PortApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/PortApiExpectTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/PortApiExpectTest.java
new file mode 100644
index 0000000..7f5338d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/PortApiExpectTest.java
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.features;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.neutron.v2_0.domain.BulkPort;
+import org.jclouds.openstack.neutron.v2_0.domain.Port;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.domain.State;
+import org.jclouds.openstack.neutron.v2_0.internal.BaseNeutronApiExpectTest;
+import org.jclouds.openstack.neutron.v2_0.options.CreatePortBulkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreatePortOptions;
+import org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions;
+import org.jclouds.openstack.neutron.v2_0.parse.ParsePortTest;
+import org.jclouds.rest.AuthorizationException;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests parsing and Guice wiring of PortApi
+ *
+ */
+@Test(groups = "unit", testName = "PortApiExpectTest")
+public class PortApiExpectTest extends BaseNeutronApiExpectTest {
+
+ private static final String ZONE = "region-a.geo-1";
+
+ public void testListReferencesReturns2xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports").addQueryParam("fields", "id", "tenant_id", "name").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/list_ports.json", APPLICATION_JSON)).build())
+ .getPortApiForZone(ZONE);
+
+ Set<? extends ReferenceWithName> references = api.list().concat().toSet();
+ assertEquals(references, listOfReferencesWithNames());
+ }
+
+ public void testListReferencesReturns4xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports").addQueryParam("fields", "id", "tenant_id", "name").build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getPortApiForZone(ZONE);
+
+ assertTrue(api.list().concat().isEmpty());
+ }
+
+ public void testListReturns2xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/list_ports.json", APPLICATION_JSON)).build())
+ .getPortApiForZone(ZONE);
+
+ Set<? extends Port> ports = api.listInDetail().concat().toSet();
+ assertEquals(ports, listOfPorts());
+ }
+
+ public void testListReturns4xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports").build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getPortApiForZone(ZONE);
+
+ assertTrue(api.listInDetail().concat().isEmpty());
+ }
+
+ public void testGetReturns2xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports/624312ff-d14b-4ba3-9834-1c78d23d574d").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/port.json", APPLICATION_JSON)).build())
+ .getPortApiForZone(ZONE);
+
+ Port port = api.get("624312ff-d14b-4ba3-9834-1c78d23d574d");
+ assertEquals(port, new ParsePortTest().expected());
+ }
+
+ public void testGetReturns4xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports/624312ff-d14b-4ba3-9834-1c78d23d574d").build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getPortApiForZone(ZONE);
+
+ assertNull(api.get("624312ff-d14b-4ba3-9834-1c78d23d574d"));
+ }
+
+ public void testCreateReturns2xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports").method("POST")
+ .payload(payloadFromStringWithContentType("{\"port\":{\"network_id\":\"1\",\"name\":\"test-port\"}}", APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromStringWithContentType("{\"port\":{\"id\":\"1\",\"tenant_id\":\"1\",\"network_id\":\"1\",\"name\":\"test-port\"}}", APPLICATION_JSON)).build())
+ .getPortApiForZone(ZONE);
+
+ Port port = api.create("1", CreatePortOptions.builder().name("test-port").build());
+ assertEquals(port, Port.builder().id("1").tenantId("1").name("test-port").networkId("1").build());
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testCreateReturns4xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports").method("POST")
+ .payload(payloadFromStringWithContentType("{\"port\":{\"network_id\":\"1\",\"name\":\"test-port\"}}", APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(401).build())
+ .getPortApiForZone(ZONE);
+
+ api.create("1", CreatePortOptions.builder().name("test-port").build());
+ }
+
+ public void testCreateBulkReturns2xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports").method("POST")
+ .payload(payloadFromStringWithContentType("{\"ports\":[{\"network_id\":\"1\",\"name\":\"test-port-1\"},{\"network_id\":\"2\",\"name\":\"test-port-2\"}]}", APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType("{\"ports\":[{\"id\":\"1\",\"tenant_id\":\"1\",\"network_id\":\"1\",\"name\":\"test-port-1\"},{\"id\":\"2\",\"tenant_id\":\"1\",\"network_id\":\"2\",\"name\":\"test-port-2\"}]}", APPLICATION_JSON)).build())
+ .getPortApiForZone(ZONE);
+
+ Set<? extends ReferenceWithName> ports = api.createBulk(
+ CreatePortBulkOptions.builder().ports(
+ ImmutableList.of(
+ BulkPort.builder().networkId("1").name("test-port-1").build(),
+ BulkPort.builder().networkId("2").name("test-port-2").build()
+ )
+ ).build()
+ ).toSet();
+ assertEquals(ports, createBulkReturns2xxResponse());
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testCreateBulkReturns4xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports").method("POST")
+ .payload(payloadFromStringWithContentType("{\"ports\":[{\"network_id\":\"1\",\"name\":\"test-port-1\"},{\"network_id\":\"2\",\"name\":\"test-port-2\"}]}", APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(401).build())
+ .getPortApiForZone(ZONE);
+
+ api.createBulk(
+ CreatePortBulkOptions.builder().ports(
+ ImmutableList.of(
+ BulkPort.builder().networkId("1").name("test-port-1").build(),
+ BulkPort.builder().networkId("2").name("test-port-2").build()
+ )
+ ).build()
+ );
+ }
+
+ public void testUpdateReturns2xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports/12345").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"port\":{\"name\":\"another-test\",\"admin_state_up\":true}}", APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).build())
+ .getPortApiForZone(ZONE);
+
+ assertTrue(api.update("12345", UpdatePortOptions.builder().name("another-test").adminStateUp(true).build()));
+ }
+
+ public void testUpdateReturns4xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports/12345").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"port\":{\"name\":\"another-test\",\"admin_state_up\":true}}", APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getPortApiForZone(ZONE);
+
+ assertFalse(api.update("12345", UpdatePortOptions.builder().name("another-test").adminStateUp(true).build()));
+ }
+
+ public void testDeleteReturns2xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports/12345").method("DELETE").build(),
+ HttpResponse.builder().statusCode(200).build())
+ .getPortApiForZone(ZONE);
+
+ assertTrue(api.delete("12345"));
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testDeleteReturns4xx() {
+ PortApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/ports/12345").method("DELETE").build(),
+ HttpResponse.builder().statusCode(403).build())
+ .getPortApiForZone(ZONE);
+
+ api.delete("12345");
+ }
+
+ protected Set<Port> listOfPorts() {
+ return ImmutableSet.of(
+ Port.builder().state(State.ACTIVE).networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("16dba3bc-f3fa-4775-afdc-237e12c72f6a").build(),
+ Port.builder().state(State.ACTIVE).networkId("1234567890").name("wibble").tenantId("1234567890").id("1a104cf5-cb18-4d35-9407-2fd2646d9d0b").build(),
+ Port.builder().state(State.ACTIVE).networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("31083ae2-420d-48b2-ac98-9f7a4fd8dbdc").build(),
+ Port.builder().state(State.ACTIVE).networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("49c6d6fa-ff2a-459d-b975-75a8d31c9a89").build(),
+ Port.builder().state(State.ACTIVE).networkId("1234567890").name("wibble").tenantId("1234567890").id("5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e").build(),
+ Port.builder().state(State.ACTIVE).networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("5d51d012-3491-4db7-b1b5-6f254015015d").build(),
+ Port.builder().state(State.ACTIVE).networkId("1234567890").name("wibble").tenantId("1234567890").id("5f9cf7dc-22ca-4097-8e49-1cc8b23faf17").build(),
+ Port.builder().state(State.ACTIVE).networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("6319ecad-6bff-48b2-9b53-02ede8cb7588").build(),
+ Port.builder().state(State.ACTIVE).networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("6ba4c788-661f-49ab-9bf8-5f10cbbb2f57").build(),
+ Port.builder().state(State.ACTIVE).networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("74ed170b-5069-4353-ab38-9719766dc57e").build(),
+ Port.builder().state(State.ACTIVE).networkId("1234567890").name("wibble").tenantId("1234567890").id("b71fcac1-e864-4031-8c5b-edbecd9ece36").build(),
+ Port.builder().state(State.ACTIVE).networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("c7681895-d84d-4650-9ca0-82c72036b855").build()
+ );
+ }
+
+ protected Set<Port> createBulkReturns2xxResponse() {
+ return ImmutableSet.of(
+ Port.builder().id("1").tenantId("1").name("test-port-1").networkId("1").build(),
+ Port.builder().id("2").tenantId("1").name("test-port-2").networkId("2").build()
+ );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/PortApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/PortApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/PortApiLiveTest.java
new file mode 100644
index 0000000..76f3734
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/PortApiLiveTest.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.neutron.v2_0.domain.BulkPort;
+import org.jclouds.openstack.neutron.v2_0.domain.IP;
+import org.jclouds.openstack.neutron.v2_0.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2_0.domain.Port;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.internal.BaseNeutronApiLiveTest;
+import org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreatePortBulkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreatePortOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreateSubnetOptions;
+import org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions;
+import org.jclouds.openstack.neutron.v2_0.util.PredicateUtil;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+/**
+ * Tests PortApi in combination with the Network & SubnetApi
+ *
+ */
+@Test(groups = "live", testName = "PortApiLiveTest")
+public class PortApiLiveTest extends BaseNeutronApiLiveTest {
+
+ public void testGetAndListPorts() {
+ for (String zone : api.getConfiguredZones()) {
+ Set<? extends ReferenceWithName> references = api.getPortApiForZone(zone).list().concat().toSet();
+ Set<? extends Port> ports = api.getPortApiForZone(zone).listInDetail().concat().toSet();
+
+ assertNotNull(references);
+ assertNotNull(ports);
+ assertEquals(references.size(), ports.size());
+
+ for (Port port : ports) {
+ assertNotNull(port.getName());
+ assertTrue(references.contains(ReferenceWithName.builder().id(port.getId()).tenantId(port.getTenantId()).name(port.getName()).build()));
+
+ Port retrievedPort = api.getPortApiForZone(zone).get(port.getId());
+ assertEquals(port, retrievedPort);
+ }
+ }
+ }
+
+ public void testCreateUpdateAndDeletePort() {
+ for (String zone : api.getConfiguredZones()) {
+ NetworkApi networkApi = api.getNetworkApiForZone(zone);
+ SubnetApi subnetApi = api.getSubnetApiForZone(zone);
+ PortApi portApi = api.getPortApiForZone(zone);
+ String networkId = networkApi.create(CreateNetworkOptions.builder().name("JClouds-Live-Network").networkType(NetworkType.LOCAL).build()).getId();
+ String ipv4SubnetId = subnetApi.create(networkId, 4, "198.51.100.0/24", CreateSubnetOptions.builder().name("JClouds-Live-IPv4-Subnet").build()).getId();
+ String ipv6SubnetId = subnetApi.create(networkId, 6, "a1ca:1e1:c:107d::/96", CreateSubnetOptions.builder().name("JClouds-Live-IPv6-Subnet").build()).getId();
+
+ assertNotNull(networkId);
+ assertNotNull(ipv4SubnetId);
+ assertNotNull(ipv6SubnetId);
+
+ String ipv4PortId = portApi.create(networkId, CreatePortOptions.builder().name("JClouds-Live-IPv4-Port").fixedIps(getFixedAddresses(ipv4SubnetId)).build()).getId();
+ String ipv6PortId = portApi.create(networkId, CreatePortOptions.builder().name("JClouds-Live-IPv6-Port").fixedIps(getFixedAddresses(ipv6SubnetId)).build()).getId();
+
+ assertNotNull(ipv4PortId);
+ assertNotNull(ipv6PortId);
+
+ Port ipv4Port = portApi.get(ipv4PortId);
+ assertNotNull(ipv4Port);
+ assertEquals(ipv4Port.getId(), ipv4PortId);
+ assertEquals(ipv4Port.getName(), "JClouds-Live-IPv4-Port");
+
+ Port ipv6Port = portApi.get(ipv6PortId);
+ assertNotNull(ipv6Port);
+ assertEquals(ipv6Port.getId(), ipv6PortId);
+ assertEquals(ipv6Port.getName(), "JClouds-Live-IPv6-Port");
+
+ assertTrue(portApi.update(ipv4PortId, UpdatePortOptions.builder().name("Updated").build()));
+ Port updatedIpv4Port = portApi.get(ipv4PortId);
+ assertEquals(updatedIpv4Port.getName(), "Updated");
+
+ assertTrue(portApi.delete(ipv4PortId));
+ assertTrue(portApi.delete(ipv6PortId));
+ assertTrue(subnetApi.delete(ipv4SubnetId));
+ assertTrue(subnetApi.delete(ipv6SubnetId));
+ assertTrue(networkApi.delete(networkId));
+ }
+ }
+
+ public void testBulkCreatePort() {
+ for (String zone : api.getConfiguredZones()) {
+ NetworkApi networkApi = api.getNetworkApiForZone(zone);
+ SubnetApi subnetApi = api.getSubnetApiForZone(zone);
+ PortApi portApi = api.getPortApiForZone(zone);
+
+ String networkId = networkApi.create(CreateNetworkOptions.builder().name("JClouds-Live-Network").networkType(NetworkType.LOCAL).build()).getId();
+ String ipv4SubnetId = subnetApi.create(networkId, 4, "198.51.100.0/24", CreateSubnetOptions.builder().name("JClouds-Live-IPv4-Subnet").build()).getId();
+ String ipv6SubnetId = subnetApi.create(networkId, 6, "a1ca:1e1:c:107d::/96", CreateSubnetOptions.builder().name("JClouds-Live-IPv6-Subnet").build()).getId();
+
+ assertNotNull(networkId);
+ assertNotNull(ipv4SubnetId);
+ assertNotNull(ipv6SubnetId);
+
+ Set<? extends Port> ports = portApi.createBulk(
+ CreatePortBulkOptions.builder().ports(
+ ImmutableSet.of(
+ BulkPort.builder().networkId(networkId).name("JClouds-Live-IPv4-Subnet-1").fixedIps(getFixedAddresses(ipv4SubnetId)).build(),
+ BulkPort.builder().networkId(networkId).name("JClouds-Live-IPv4-Subnet-2").fixedIps(getFixedAddresses(ipv4SubnetId)).build(),
+ BulkPort.builder().networkId(networkId).name("JClouds-Live-IPv6-Subnet-1").fixedIps(getFixedAddresses(ipv6SubnetId)).build(),
+ BulkPort.builder().networkId(networkId).name("JClouds-Live-IPv6-Subnet-2").fixedIps(getFixedAddresses(ipv6SubnetId)).build()
+ )
+ ).build()
+ ).toSet();
+ Set<? extends Port> existingPorts = portApi.listInDetail().concat().toSet();
+
+ assertNotNull(ports);
+ assertFalse(ports.isEmpty());
+ assertEquals(ports.size(), 4);
+
+ for (Port port : ports) {
+ Predicate<Port> idEqualsPredicate = PredicateUtil.createIdEqualsPredicate(port.getId());
+ assertEquals(1, Sets.filter(existingPorts, idEqualsPredicate).size());
+ assertTrue(portApi.delete(port.getId()));
+ }
+ assertTrue(subnetApi.delete(ipv4SubnetId));
+ assertTrue(subnetApi.delete(ipv6SubnetId));
+ assertTrue(networkApi.delete(networkId));
+ }
+ }
+
+ public Set<IP> getFixedAddresses(String subnetId) {
+ return ImmutableSet.of(
+ IP.builder().subnetId(subnetId).build()
+ );
+ }
+}
[39/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
new file mode 100644
index 0000000..c11d04e
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Address;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Lists;
+
+public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private static final String ADDRESS_NAME = "address-api-live-test-address";
+ private static final int TIME_WAIT = 30;
+
+ private AddressApi api() {
+ return api.getAddressApiForProject(userProject.get());
+ }
+
+ @Test(groups = "live")
+ public void testInsertAddress() {
+
+ assertRegionOperationDoneSucessfully(api().createInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testInsertAddress")
+ public void testGetAddress() {
+ Address address = api().getInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME);
+ assertNotNull(address);
+ assertEquals(address.getName(), ADDRESS_NAME);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testGetAddress")
+ public void testListAddress() {
+
+ PagedIterable<Address> addresss = api().listInRegion(DEFAULT_REGION_NAME, new ListOptions.Builder()
+ .filter("name eq " + ADDRESS_NAME));
+
+ List<Address> addresssAsList = Lists.newArrayList(addresss.concat());
+
+ assertEquals(addresssAsList.size(), 1);
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testListAddress")
+ public void testDeleteAddress() {
+
+ assertRegionOperationDoneSucessfully(api().deleteInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
new file mode 100644
index 0000000..6aaf8fa
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.AssertJUnit.assertNull;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.parse.ParseDiskListTest;
+import org.jclouds.googlecomputeengine.parse.ParseDiskTest;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+ public static final String IMAGE_URL = "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/images/foo";
+
+ public void testGetDiskResponseIs2xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/disk_get.json")).build();
+
+ DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject");
+
+ assertEquals(api.getInZone("us-central1-a", "testimage1"),
+ new ParseDiskTest().expected());
+ }
+
+ public void testGetDiskResponseIs4xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject");
+
+ assertNull(api.getInZone("us-central1-a", "testimage1"));
+ }
+
+ public void testInsertDiskResponseIs2xx() {
+ HttpRequest insert = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/disk_insert.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse insertDiskResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation.json")).build();
+
+ DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, insert,
+ insertDiskResponse).getDiskApiForProject("myproject");
+
+ assertEquals(api.createInZone("testimage1", 1, "us-central1-a"), new ParseOperationTest().expected());
+ }
+
+ public void testInsertDiskFromImageResponseIs2xx() {
+ HttpRequest insert = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
+ + "?sourceImage=" + IMAGE_URL.replaceAll(":", "%3A"))
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/disk_insert.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse insertDiskResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation.json")).build();
+
+ DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, insert,
+ insertDiskResponse).getDiskApiForProject("myproject");
+
+ assertEquals(api.createFromImageWithSizeInZone(IMAGE_URL, "testimage1", 1, "us-central1-a"), new ParseOperationTest().expected());
+ }
+
+ public void testCreateSnapshotResponseIs2xx() {
+ HttpRequest createSnapshotRequest = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
+ + "/testimage1/createSnapshot")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/disk_create_snapshot.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse createSnapshotResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation.json")).build();
+
+ DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, createSnapshotRequest,
+ createSnapshotResponse).getDiskApiForProject("myproject");
+
+ assertEquals(api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap"), new ParseOperationTest().expected());
+ }
+
+ public void testCreateSnapshotResponseIs4xx() {
+ HttpRequest createSnapshotRequest = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
+ + "/testimage1/createSnapshot")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/disk_create_snapshot.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse createSnapshotResponse = HttpResponse.builder().statusCode(404).build();
+
+ DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, createSnapshotRequest,
+ createSnapshotResponse).getDiskApiForProject("myproject");
+
+ assertNull(api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap"));
+ }
+
+ public void testDeleteDiskResponseIs2xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation.json")).build();
+
+ DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject");
+
+ assertEquals(api.deleteInZone("us-central1-a", "testimage1"),
+ new ParseOperationTest().expected());
+ }
+
+ public void testDeleteDiskResponseIs4xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
+
+ DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject");
+
+ assertNull(api.deleteInZone("us-central1-a", "testimage1"));
+ }
+
+ public void testListDisksResponseIs2xx() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/disks")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/disk_list.json")).build();
+
+ DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject");
+
+ assertEquals(api.listFirstPageInZone("us-central1-a").toString(),
+ new ParseDiskListTest().expected().toString());
+ }
+
+ public void testListDisksResponseIs4xx() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/disks")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject");
+
+ assertTrue(api.listInZone("us-central1-a").concat().isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
new file mode 100644
index 0000000..bd26621
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Disk;
+import org.jclouds.googlecomputeengine.domain.Project;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ public static final String DISK_NAME = "disk-api-live-test-disk";
+ public static final int TIME_WAIT = 30;
+ public static final int sizeGb = 1;
+
+ private DiskApi api() {
+ return api.getDiskApiForProject(userProject.get());
+ }
+
+ @Test(groups = "live")
+ public void testInsertDisk() {
+ Project project = api.getProjectApi().get(userProject.get());
+ assertZoneOperationDoneSucessfully(api().createInZone(DISK_NAME, sizeGb, DEFAULT_ZONE_NAME), TIME_WAIT);
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testInsertDisk")
+ public void testGetDisk() {
+
+ Disk disk = api().getInZone(DEFAULT_ZONE_NAME, DISK_NAME);
+ assertNotNull(disk);
+ assertDiskEquals(disk);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testGetDisk")
+ public void testListDisk() {
+
+ PagedIterable<Disk> disks = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
+ .filter("name eq " + DISK_NAME));
+
+ List<Disk> disksAsList = Lists.newArrayList(disks.concat());
+
+ assertEquals(disksAsList.size(), 1);
+
+ assertDiskEquals(Iterables.getOnlyElement(disksAsList));
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testListDisk")
+ public void testDeleteDisk() {
+
+ assertZoneOperationDoneSucessfully(api().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
+ }
+
+ private void assertDiskEquals(Disk result) {
+ assertEquals(result.getName(), DISK_NAME);
+ assertEquals(result.getSizeGb(), sizeGb);
+ assertEquals(result.getZone(), getDefaultZoneUrl(userProject.get()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
new file mode 100644
index 0000000..7a5759b
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
@@ -0,0 +1,301 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static com.google.common.base.Joiner.on;
+import static com.google.common.collect.Iterables.transform;
+import static java.lang.String.format;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.jclouds.io.Payloads.newStringPayload;
+import static org.jclouds.util.Strings2.toStringAndClose;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.AssertJUnit.assertNull;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.options.FirewallOptions;
+import org.jclouds.googlecomputeengine.parse.ParseFirewallListTest;
+import org.jclouds.googlecomputeengine.parse.ParseFirewallTest;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.io.Payload;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "unit")
+public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ public static final HttpRequest GET_FIREWALL_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/firewalls/jclouds-test")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static HttpResponse GET_FIREWALL_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/firewall_get.json")).build();
+
+ public void testGetFirewallResponseIs2xx() throws Exception {
+
+ FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_FIREWALL_REQUEST, GET_FIREWALL_RESPONSE).getFirewallApiForProject("myproject");
+
+ assertEquals(api.get("jclouds-test"), new ParseFirewallTest().expected());
+ }
+
+
+ public static Payload firewallPayloadFirewallOfName(String firewallName,
+ String networkName,
+ Set<String> sourceRanges,
+ Set<String> sourceTags,
+ Set<String> targetTags,
+ Set<String> portRanges) throws IOException {
+ Function<String, String> addQuotes = new Function<String, String>() {
+ @Override
+ public String apply(String input) {
+ return "\"" + input + "\"";
+ }
+ };
+
+ String ports = on(",").skipNulls().join(transform(portRanges, addQuotes));
+
+ Payload payload = newStringPayload(
+ format(toStringAndClose(FirewallApiExpectTest.class.getResourceAsStream("/firewall_insert.json")),
+ firewallName,
+ networkName,
+ on(",").skipNulls().join(transform(sourceRanges, addQuotes)),
+ on(",").skipNulls().join(transform(sourceTags, addQuotes)),
+ on(",").skipNulls().join(transform(targetTags, addQuotes)),
+ ports,
+ ports));
+ payload.getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
+ return payload;
+ }
+
+
+ public void testGetFirewallResponseIs4xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/firewalls/jclouds-test")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getFirewallApiForProject("myproject");
+
+ assertNull(api.get("jclouds-test"));
+ }
+
+ public void testInsertFirewallResponseIs2xx() throws IOException {
+
+ HttpRequest request = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(firewallPayloadFirewallOfName(
+ "myfw",
+ "default",
+ ImmutableSet.<String>of("10.0.1.0/32"),
+ ImmutableSet.<String>of("tag1"),
+ ImmutableSet.<String>of("tag2"),
+ ImmutableSet.<String>of("22", "23-24")))
+ .build();
+
+ HttpResponse insertFirewallResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/operation.json")).build();
+
+ FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, request, insertFirewallResponse).getFirewallApiForProject("myproject");
+
+ assertEquals(api.createInNetwork("myfw", URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/default"),
+ new FirewallOptions()
+ .addAllowedRule(Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.TCP)
+ .addPort(22)
+ .addPortRange(23, 24).build())
+ .addSourceTag("tag1")
+ .addSourceRange("10.0.1.0/32")
+ .addTargetTag("tag2")), new ParseOperationTest().expected());
+
+ }
+
+ public void testUpdateFirewallResponseIs2xx() throws IOException {
+ HttpRequest update = HttpRequest
+ .builder()
+ .method("PUT")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/myfw")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(firewallPayloadFirewallOfName(
+ "myfw",
+ "default",
+ ImmutableSet.<String>of("10.0.1.0/32"),
+ ImmutableSet.<String>of("tag1"),
+ ImmutableSet.<String>of("tag2"),
+ ImmutableSet.<String>of("22", "23-24")))
+ .build();
+
+ HttpResponse updateFirewallResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/operation.json")).build();
+
+ FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, update,
+ updateFirewallResponse).getFirewallApiForProject("myproject");
+
+ assertEquals(api.update("myfw",
+ new FirewallOptions()
+ .name("myfw")
+ .network(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/default"))
+ .addAllowedRule(Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.TCP)
+ .addPort(22)
+ .addPortRange(23, 24).build())
+ .addSourceTag("tag1")
+ .addSourceRange("10.0.1.0/32")
+ .addTargetTag("tag2")), new ParseOperationTest().expected());
+ }
+
+ public void testPatchFirewallResponseIs2xx() throws IOException {
+ HttpRequest update = HttpRequest
+ .builder()
+ .method("PATCH")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/myfw")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(firewallPayloadFirewallOfName(
+ "myfw",
+ "default",
+ ImmutableSet.<String>of("10.0.1.0/32"),
+ ImmutableSet.<String>of("tag1"),
+ ImmutableSet.<String>of("tag2"),
+ ImmutableSet.<String>of("22", "23-24")))
+ .build();
+
+ HttpResponse updateFirewallResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/operation.json")).build();
+
+ FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, update,
+ updateFirewallResponse).getFirewallApiForProject("myproject");
+
+ assertEquals(api.patch("myfw",
+ new FirewallOptions()
+ .name("myfw")
+ .network(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/default"))
+ .addAllowedRule(Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.TCP)
+ .addPort(22)
+ .addPortRange(23, 24).build())
+ .addSourceTag("tag1")
+ .addSourceRange("10.0.1.0/32")
+ .addTargetTag("tag2")), new ParseOperationTest().expected());
+ }
+
+ public void testDeleteFirewallResponseIs2xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/firewalls/default-allow-internal")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/operation.json")).build();
+
+ FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getFirewallApiForProject("myproject");
+
+ assertEquals(api.delete("default-allow-internal"),
+ new ParseOperationTest().expected());
+ }
+
+ public void testDeleteFirewallResponseIs4xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/firewalls/default-allow-internal")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
+
+ FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getFirewallApiForProject("myproject");
+
+ assertNull(api.delete("default-allow-internal"));
+ }
+
+ public void testListFirewallsResponseIs2xx() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/firewalls")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/firewall_list.json")).build();
+
+ FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getFirewallApiForProject("myproject");
+
+ assertEquals(api.listFirstPage().toString(),
+ new ParseFirewallListTest().expected().toString());
+ }
+
+ public void testListFirewallsResponseIs4xx() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/firewalls")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getFirewallApiForProject("myproject");
+
+ assertTrue(api.list().concat().isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
new file mode 100644
index 0000000..669046f
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.FirewallOptions;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+
+@Test(groups = "live", testName = "FirewallApiLiveTest")
+public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private static final String FIREWALL_NAME = "firewall-api-live-test-firewall";
+ private static final String FIREWALL_NETWORK_NAME = "firewall-api-live-test-network";
+ private static final String IPV4_RANGE = "10.0.0.0/8";
+ private static final int TIME_WAIT = 30;
+
+ private FirewallApi api() {
+ return api.getFirewallApiForProject(userProject.get());
+ }
+
+ @Test(groups = "live")
+ public void testInsertFirewall() {
+
+ // need to create the network first
+ assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).createInIPv4Range
+ (FIREWALL_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
+
+ FirewallOptions firewall = new FirewallOptions()
+ .addAllowedRule(
+ Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.TCP)
+ .addPort(22).build())
+ .addSourceRange("10.0.0.0/8")
+ .addSourceTag("tag1")
+ .addTargetTag("tag2");
+
+ assertGlobalOperationDoneSucessfully(api().createInNetwork(FIREWALL_NAME, getNetworkUrl(userProject.get(),
+ FIREWALL_NETWORK_NAME), firewall), TIME_WAIT);
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testInsertFirewall")
+ public void testUpdateFirewall() {
+
+ FirewallOptions firewall = new FirewallOptions()
+ .name(FIREWALL_NAME)
+ .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
+ .addSourceRange("10.0.0.0/8")
+ .addSourceTag("tag1")
+ .addTargetTag("tag2")
+ .allowedRules(ImmutableSet.of(
+ Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.TCP)
+ .addPort(23)
+ .build()));
+
+
+ assertGlobalOperationDoneSucessfully(api().update(FIREWALL_NAME, firewall), TIME_WAIT);
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testUpdateFirewall")
+ public void testPatchFirewall() {
+
+ FirewallOptions firewall = new FirewallOptions()
+ .name(FIREWALL_NAME)
+ .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
+ .allowedRules(ImmutableSet.of(
+ Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.TCP)
+ .addPort(22)
+ .build(),
+ Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.TCP)
+ .addPort(23)
+ .build()))
+ .addSourceRange("10.0.0.0/8")
+ .addSourceTag("tag1")
+ .addTargetTag("tag2");
+
+ assertGlobalOperationDoneSucessfully(api().update(FIREWALL_NAME, firewall), TIME_WAIT);
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testPatchFirewall")
+ public void testGetFirewall() {
+
+ FirewallOptions patchedFirewall = new FirewallOptions()
+ .name(FIREWALL_NAME)
+ .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
+ .allowedRules(ImmutableSet.of(
+ Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.TCP)
+ .addPort(22)
+ .build(),
+ Firewall.Rule.builder()
+ .IpProtocol(IpProtocol.TCP)
+ .addPort(23)
+ .build()))
+ .addSourceRange("10.0.0.0/8")
+ .addSourceTag("tag1")
+ .addTargetTag("tag2");
+
+ Firewall firewall = api().get(FIREWALL_NAME);
+ assertNotNull(firewall);
+ assertFirewallEquals(firewall, patchedFirewall);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testGetFirewall")
+ public void testListFirewall() {
+
+ PagedIterable<Firewall> firewalls = api().list(new ListOptions.Builder()
+ .filter("name eq " + FIREWALL_NAME));
+
+ List<Firewall> firewallsAsList = Lists.newArrayList(firewalls.concat());
+
+ assertEquals(firewallsAsList.size(), 1);
+
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testListFirewall")
+ public void testDeleteFirewall() {
+
+ assertGlobalOperationDoneSucessfully(api().delete(FIREWALL_NAME), TIME_WAIT);
+ assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).delete
+ (FIREWALL_NETWORK_NAME), TIME_WAIT);
+ }
+
+ private void assertFirewallEquals(Firewall result, FirewallOptions expected) {
+ assertEquals(result.getName(), expected.getName());
+ assertEquals(getOnlyElement(result.getSourceRanges()), getOnlyElement(expected.getSourceRanges()));
+ assertEquals(getOnlyElement(result.getSourceTags()), getOnlyElement(expected.getSourceTags()));
+ assertEquals(getOnlyElement(result.getTargetTags()), getOnlyElement(expected.getTargetTags()));
+ assertEquals(result.getAllowed(), expected.getAllowed());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
new file mode 100644
index 0000000..7fac1d7
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.googlecomputeengine.parse.ParseOperationListTest;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ private static final String OPERATIONS_URL_PREFIX = "https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/operations";
+
+ public static final HttpRequest GET_GLOBAL_OPERATION_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX + "/operation-1354084865060-4cf88735faeb8-bbbb12cb")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse GET_GLOBAL_OPERATION_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/global_operation.json")).build();
+
+ public void testGetOperationResponseIs2xx() throws Exception {
+
+ GlobalOperationApi operationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, GET_GLOBAL_OPERATION_RESPONSE).getGlobalOperationApiForProject("myproject");
+
+ assertEquals(operationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"),
+ new ParseOperationTest().expected());
+ }
+
+ public void testGetOperationResponseIs4xx() throws Exception {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, operationResponse).getGlobalOperationApiForProject("myproject");
+
+ assertNull(globalOperationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"));
+ }
+
+ public void testDeleteOperationResponseIs2xx() throws Exception {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
+
+ GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApiForProject("myproject");
+
+ globalOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
+ }
+
+ public void testDeleteOperationResponseIs4xx() throws Exception {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApiForProject("myproject");
+
+ globalOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
+ }
+
+ public void testLisOperationWithNoOptionsResponseIs2xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/global_operation_list.json")).build();
+
+ GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject");
+
+ assertEquals(globalOperationApi.listFirstPage().toString(),
+ new ParseOperationListTest().expected().toString());
+ }
+
+ public void testListOperationWithPaginationOptionsResponseIs2xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX +
+ "?pageToken=CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcG" +
+ "VyYXRpb24tMTM1MjI0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz&" +
+ "filter=" +
+ "status%20eq%20done&" +
+ "maxResults=3")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/global_operation_list.json")).build();
+
+ GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject");
+
+ assertEquals(globalOperationApi.listAtMarker("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
+ "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
+ new ListOptions.Builder().filter("status eq done").maxResults(3)).toString(),
+ new ParseOperationListTest().expected().toString());
+ }
+
+ public void testListOperationWithPaginationOptionsResponseIs4xx() {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(OPERATIONS_URL_PREFIX)
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject");
+
+ assertTrue(globalOperationApi.list().concat().isEmpty());
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
new file mode 100644
index 0000000..704df02
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.features.ProjectApiLiveTest.addItemToMetadata;
+import static org.jclouds.googlecomputeengine.features.ProjectApiLiveTest.deleteItemFromMetadata;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+public class GlobalOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private static final String METADATA_ITEM_KEY = "operationLiveTestTestProp";
+ private static final String METADATA_ITEM_VALUE = "operationLiveTestTestValue";
+ private Operation addOperation;
+ private Operation deleteOperation;
+
+ private GlobalOperationApi api() {
+ return api.getGlobalOperationApiForProject(userProject.get());
+ }
+
+
+ @Test(groups = "live")
+ public void testCreateOperations() {
+ //create some operations by adding and deleting metadata items
+ // this will make sure there is stuff to listFirstPage
+ addOperation = assertGlobalOperationDoneSucessfully(addItemToMetadata(api.getProjectApi(),
+ userProject.get(), METADATA_ITEM_KEY, METADATA_ITEM_VALUE), 20);
+ deleteOperation = assertGlobalOperationDoneSucessfully(deleteItemFromMetadata(api
+ .getProjectApi(), userProject.get(), METADATA_ITEM_KEY), 20);
+
+ assertNotNull(addOperation);
+ assertNotNull(deleteOperation);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testCreateOperations")
+ public void testGetOperation() {
+ Operation operation = api().get(addOperation.getName());
+ assertNotNull(operation);
+ assertOperationEquals(operation, this.addOperation);
+ }
+
+ @Test(groups = "live", dependsOnMethods = "testCreateOperations")
+ public void testListOperationsWithFiltersAndPagination() {
+ PagedIterable<Operation> operations = api().list(new ListOptions.Builder()
+ .filter("operationType eq setMetadata")
+ .maxResults(1));
+
+ // make sure that in spite of having only one result per page we get at least two results
+ final AtomicInteger counter = new AtomicInteger();
+ operations.firstMatch(new Predicate<IterableWithMarker<Operation>>() {
+
+ @Override
+ public boolean apply(IterableWithMarker<Operation> input) {
+ counter.addAndGet(Iterables.size(input));
+ return counter.get() == 2;
+ }
+ });
+ }
+
+ private void assertOperationEquals(Operation result, Operation expected) {
+ assertEquals(result.getName(), expected.getName());
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
new file mode 100644
index 0000000..1deb178
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.AssertJUnit.assertNull;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.parse.ParseImageListTest;
+import org.jclouds.googlecomputeengine.parse.ParseImageTest;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ public static final HttpRequest LIST_PROJECT_IMAGES_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/images")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse LIST_PROJECT_IMAGES_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/image_list.json")).build();
+
+ public static final HttpRequest LIST_CENTOS_IMAGES_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse LIST_CENTOS_IMAGES_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/image_list_centos.json")).build();
+
+ public static final HttpRequest LIST_DEBIAN_IMAGES_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse LIST_DEBIAN_IMAGES_RESPONSE =
+ HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/image_list_debian.json")).build();
+
+ public void testGetImageResponseIs2xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120326")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/image_get.json")).build();
+
+ ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("centos-cloud");
+
+ assertEquals(imageApi.get("centos-6-2-v20120326"),
+ new ParseImageTest().expected());
+ }
+
+ public void testGetImageResponseIs4xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120326")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("centos-cloud");
+
+ assertNull(imageApi.get("centos-6-2-v20120326"));
+ }
+
+ public void testDeleteImageResponseIs2xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/images/centos-6-2-v20120326")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/operation.json")).build();
+
+ ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getImageApiForProject("myproject");
+
+ assertEquals(imageApi.delete("centos-6-2-v20120326"),
+ new ParseOperationTest().expected());
+ }
+
+ public void testDeleteImageResponseIs4xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/images/centos-6-2-v20120326")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
+
+ ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getImageApiForProject("myproject");
+
+ assertNull(imageApi.delete("centos-6-2-v20120326"));
+ }
+
+ public void testListImagesResponseIs2xx() {
+
+ ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE).getImageApiForProject
+ ("myproject");
+
+ assertEquals(imageApi.listFirstPage().toString(),
+ new ParseImageListTest().expected().toString());
+ }
+
+ public void testListImagesResponseIs4xx() {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, operationResponse).getImageApiForProject("myproject");
+
+ assertTrue(imageApi.list().concat().isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
new file mode 100644
index 0000000..a4922b4
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
+
+ private Image image;
+
+ private ImageApi api() {
+ return api.getImageApiForProject("centos-cloud");
+ }
+
+ @Test(groups = "live")
+ public void testListImage() {
+
+ PagedIterable<Image> images = api().list(new ListOptions.Builder().maxResults(1));
+
+ Iterator<IterableWithMarker<Image>> pageIterator = images.iterator();
+ assertTrue(pageIterator.hasNext());
+
+ IterableWithMarker<Image> singlePageIterator = pageIterator.next();
+ List<Image> imageAsList = Lists.newArrayList(singlePageIterator);
+
+ assertSame(imageAsList.size(), 1);
+
+ this.image = Iterables.getOnlyElement(imageAsList);
+ }
+
+
+ @Test(groups = "live", dependsOnMethods = "testListImage")
+ public void testGetImage() {
+ Image image = api().get(this.image.getName());
+ assertNotNull(image);
+ assertImageEquals(image, this.image);
+ }
+
+ private void assertImageEquals(Image result, Image expected) {
+ assertEquals(result.getName(), expected.getName());
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java
new file mode 100644
index 0000000..f460de6
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java
@@ -0,0 +1,410 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.features;
+
+import static java.net.URI.create;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.jclouds.googlecomputeengine.features.ProjectApiExpectTest.GET_PROJECT_REQUEST;
+import static org.jclouds.googlecomputeengine.features.ProjectApiExpectTest.GET_PROJECT_RESPONSE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.AssertJUnit.assertNull;
+
+import java.net.URI;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.InstanceTemplate;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.options.AttachDiskOptions;
+import org.jclouds.googlecomputeengine.options.AttachDiskOptions.DiskMode;
+import org.jclouds.googlecomputeengine.options.AttachDiskOptions.DiskType;
+import org.jclouds.googlecomputeengine.parse.ParseInstanceListTest;
+import org.jclouds.googlecomputeengine.parse.ParseInstanceSerialOutputTest;
+import org.jclouds.googlecomputeengine.parse.ParseInstanceTest;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+@Test(groups = "unit")
+public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ public static final HttpRequest GET_INSTANCE_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+
+ public static final HttpResponse GET_INSTANCE_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/instance_get.json")).build();
+
+ public static final HttpRequest LIST_INSTANCES_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse LIST_INSTANCES_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/instance_list.json")).build();
+
+ public static final HttpRequest LIST_CENTRAL1B_INSTANCES_REQUEST = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-b/instances")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ public static final HttpResponse LIST_CENTRAL1B_INSTANCES_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/instance_list_central1b_empty.json")).build();
+
+ public static final HttpResponse CREATE_INSTANCE_RESPONSE = HttpResponse.builder().statusCode(200)
+ .payload(staticPayloadFromResource("/zone_operation.json")).build();
+
+
+ public void testGetInstanceResponseIs2xx() throws Exception {
+
+ InstanceApi api = requestsSendResponses(
+ requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE,
+ GET_INSTANCE_REQUEST, GET_INSTANCE_RESPONSE).getInstanceApiForProject("myproject");
+
+ assertEquals(api.getInZone("us-central1-a", "test-1"), new ParseInstanceTest().expected());
+ }
+
+ public void testGetInstanceResponseIs4xx() throws Exception {
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_INSTANCE_REQUEST, operationResponse).getInstanceApiForProject("myproject");
+
+ assertNull(api.getInZone("us-central1-a", "test-1"));
+ }
+
+ public void testGetInstanceSerialPortOutput() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/serialPort")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/instance_serial_port.json")).build();
+
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getInstanceApiForProject("myproject");
+
+ assertEquals(api.getSerialPortOutputInZone("us-central1-a", "test-1"), new ParseInstanceSerialOutputTest().expected());
+ }
+
+ public void testInsertInstanceResponseIs2xxNoOptions() {
+ HttpRequest insert = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/instance_insert_simple.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ InstanceApi api = requestsSendResponses(ImmutableMap.of(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE,
+ requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, insert,
+ CREATE_INSTANCE_RESPONSE)).getInstanceApiForProject("myproject");
+
+ InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1")
+ .addNetworkInterface(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/default"));
+
+ assertEquals(api.createInZone("test-1", "us-central1-a", options), new ParseOperationTest().expected());
+ }
+
+ public void testInsertInstanceResponseIs2xxAllOptions() {
+ HttpRequest insert = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/instance_insert.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse insertInstanceResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation.json")).build();
+
+ InstanceApi api = requestsSendResponses(ImmutableMap.of(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE,
+ requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, insert, insertInstanceResponse)).getInstanceApiForProject("myproject");
+
+ InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1")
+ .addNetworkInterface(URI.create("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/global/networks/default"), Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT)
+ .description("desc")
+ .addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE,
+ create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/test"),
+ true)
+ .addServiceAccount(Instance.ServiceAccount.builder().email("default").addScopes("myscope").build())
+ .addMetadata("aKey", "aValue");
+
+ assertEquals(api.createInZone("test-0", "us-central1-a", options),
+ new ParseOperationTest().expected());
+ }
+
+ public void testDeleteInstanceResponseIs2xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation.json")).build();
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getInstanceApiForProject("myproject");
+
+ assertEquals(api.deleteInZone("us-central1-a", "test-1"),
+ new ParseOperationTest().expected());
+ }
+
+ public void testDeleteInstanceResponseIs4xx() {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, delete, deleteResponse).getInstanceApiForProject("myproject");
+
+ assertNull(api.deleteInZone("us-central1-a", "test-1"));
+ }
+
+ public void testListInstancesResponseIs2xx() {
+
+ InstanceApi api = requestsSendResponses(
+ requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE,
+ LIST_INSTANCES_REQUEST, LIST_INSTANCES_RESPONSE).getInstanceApiForProject("myproject");
+
+ assertEquals(api.listFirstPageInZone("us-central1-a").toString(),
+ new ParseInstanceListTest().expected().toString());
+ }
+
+ public void testListInstancesResponseIs4xx() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getInstanceApiForProject("myproject");
+
+ assertTrue(api.listInZone("us-central1-a").concat().isEmpty());
+ }
+
+ public void testSetInstanceMetadataResponseIs2xx() {
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/setMetadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/instance_set_metadata.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation.json")).build();
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, setMetadata, setMetadataResponse).getInstanceApiForProject("myproject");
+
+ assertEquals(api.setMetadataInZone("us-central1-a", "test-1", ImmutableMap.of("foo", "bar"), "efgh"),
+ new ParseOperationTest().expected());
+ }
+
+ public void testSetInstanceMetadataResponseIs4xx() {
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/setMetadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/instance_set_metadata.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404).build();
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, setMetadata, setMetadataResponse).getInstanceApiForProject("myproject");
+
+ assertNull(api.setMetadataInZone("us-central1-a", "test-1", ImmutableMap.of("foo", "bar"), "efgh"));
+ }
+
+ public void testResetInstanceResponseIs2xx() {
+ HttpRequest reset = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/reset")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse resetResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation.json")).build();
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, reset, resetResponse).getInstanceApiForProject("myproject");
+
+ assertEquals(api.resetInZone("us-central1-a", "test-1"),
+ new ParseOperationTest().expected());
+ }
+
+ public void testResetInstanceResponseIs4xx() {
+ HttpRequest reset = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/reset")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse resetResponse = HttpResponse.builder().statusCode(404).build();
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, reset, resetResponse).getInstanceApiForProject("myproject");
+
+ assertNull(api.resetInZone("us-central1-a", "test-1"));
+ }
+
+ public void testAttachDiskResponseIs2xx() {
+ HttpRequest attach = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/attachDisk")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/instance_attach_disk.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse attachResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation.json")).build();
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, attach, attachResponse).getInstanceApiForProject("myproject");
+
+ assertEquals(api.attachDiskInZone("us-central1-a", "test-1",
+ new AttachDiskOptions()
+ .mode(DiskMode.READ_ONLY)
+ .source(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
+ .type(DiskType.PERSISTENT)),
+ new ParseOperationTest().expected());
+ }
+
+ public void testAttachDiskResponseIs4xx() {
+ HttpRequest attach = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/attachDisk")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .payload(payloadFromResourceWithContentType("/instance_attach_disk.json", MediaType.APPLICATION_JSON))
+ .build();
+
+ HttpResponse attachResponse = HttpResponse.builder().statusCode(404).build();
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, attach, attachResponse).getInstanceApiForProject("myproject");
+
+ assertNull(api.attachDiskInZone("us-central1-a", "test-1",
+ new AttachDiskOptions()
+ .mode(DiskMode.READ_ONLY)
+ .source(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
+ .type(DiskType.PERSISTENT)));
+
+ }
+
+ public void testDetachDiskResponseIs2xx() {
+ HttpRequest detach = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/detachDisk" +
+ "?deviceName=test-disk-1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .build();
+
+ HttpResponse detachResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/zone_operation.json")).build();
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, detach, detachResponse).getInstanceApiForProject("myproject");
+
+ assertEquals(api.detachDiskInZone("us-central1-a", "test-1", "test-disk-1"),
+ new ParseOperationTest().expected());
+ }
+
+ public void testDetachDiskResponseIs4xx() {
+ HttpRequest detach = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://www.googleapis" +
+ ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/detachDisk" +
+ "?deviceName=test-disk-1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN)
+ .build();
+
+ HttpResponse detachResponse = HttpResponse.builder().statusCode(404).build();
+
+ InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
+ TOKEN_RESPONSE, detach, detachResponse).getInstanceApiForProject("myproject");
+
+ assertNull(api.detachDiskInZone("us-central1-a", "test-1", "test-disk-1"));
+ }
+
+}
[11/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java
new file mode 100644
index 0000000..b12be86
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.ovf;
+
+import java.util.List;
+
+import org.jclouds.cim.ResourceAllocationSettingData;
+import org.jclouds.vcloud.domain.ReferenceType;
+
+public class EditableResourceAllocationSettingData extends ResourceAllocationSettingData {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder toBuilder() {
+ return builder().fromEditableResourceAllocationSettingData(this);
+ }
+
+ public static class Builder extends ResourceAllocationSettingData.Builder {
+ private ReferenceType edit;
+
+ /**
+ * @see EditableResourceAllocationSettingData#getEdit
+ */
+ public Builder edit(ReferenceType edit) {
+ this.edit = edit;
+ return this;
+ }
+
+ public EditableResourceAllocationSettingData build() {
+ return new EditableResourceAllocationSettingData(elementName, instanceID, caption, description, address,
+ addressOnParent, allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit,
+ mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType,
+ virtualQuantity, virtualQuantityUnits, weight, connections, hostResources, edit);
+ }
+
+ public Builder fromEditableResourceAllocationSettingData(EditableResourceAllocationSettingData in) {
+ return edit(in.getEdit()).fromResourceAllocationSettingData(in);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder caption(String caption) {
+ return Builder.class.cast(super.caption(caption));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder description(String description) {
+ return Builder.class.cast(super.description(description));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder elementName(String elementName) {
+ return Builder.class.cast(super.elementName(elementName));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder instanceID(String instanceID) {
+ return Builder.class.cast(super.instanceID(instanceID));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder address(String address) {
+ return Builder.class.cast(super.address(address));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder addressOnParent(String addressOnParent) {
+ return Builder.class.cast(super.addressOnParent(addressOnParent));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder allocationUnits(String allocationUnits) {
+ return Builder.class.cast(super.allocationUnits(allocationUnits));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder automaticAllocation(Boolean automaticAllocation) {
+ return Builder.class.cast(super.automaticAllocation(automaticAllocation));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder automaticDeallocation(Boolean automaticDeallocation) {
+ return Builder.class.cast(super.automaticDeallocation(automaticDeallocation));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder connection(String connection) {
+ return Builder.class.cast(super.connection(connection));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder connections(List<String> connections) {
+ return Builder.class.cast(super.connections(connections));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder consumerVisibility(ConsumerVisibility consumerVisibility) {
+ return Builder.class.cast(super.consumerVisibility(consumerVisibility));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder hostResource(String hostResource) {
+ return Builder.class.cast(super.hostResource(hostResource));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder hostResources(List<String> hostResources) {
+ return Builder.class.cast(super.hostResources(hostResources));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder limit(Long limit) {
+ return Builder.class.cast(super.limit(limit));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder mappingBehavior(MappingBehavior mappingBehavior) {
+ return Builder.class.cast(super.mappingBehavior(mappingBehavior));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder otherResourceType(String otherResourceType) {
+ return Builder.class.cast(super.otherResourceType(otherResourceType));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder parent(String parent) {
+ return Builder.class.cast(super.parent(parent));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder poolID(String poolID) {
+ return Builder.class.cast(super.poolID(poolID));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder reservation(Long reservation) {
+ return Builder.class.cast(super.reservation(reservation));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder resourceSubType(String resourceSubType) {
+ return Builder.class.cast(super.resourceSubType(resourceSubType));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder resourceType(org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType) {
+ return Builder.class.cast(super.resourceType(resourceType));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder virtualQuantity(Long virtualQuantity) {
+ return Builder.class.cast(super.virtualQuantity(virtualQuantity));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder virtualQuantityUnits(String virtualQuantityUnits) {
+ return Builder.class.cast(super.virtualQuantityUnits(virtualQuantityUnits));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder weight(Integer weight) {
+ return Builder.class.cast(super.weight(weight));
+ }
+
+ @Override
+ public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) {
+ return Builder.class.cast(super.fromResourceAllocationSettingData(in));
+ }
+
+ }
+
+ private final ReferenceType edit;
+
+ public EditableResourceAllocationSettingData(String elementName, String instanceID, String caption,
+ String description, String address, String addressOnParent, String allocationUnits,
+ Boolean automaticAllocation, Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, Long limit,
+ MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, Long reservation,
+ String resourceSubType, org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType,
+ Long virtualQuantity, String virtualQuantityUnits, Integer weight, List<String> connections,
+ List<String> hostResources, ReferenceType edit) {
+ super(elementName, instanceID, caption, description, address, addressOnParent, allocationUnits,
+ automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior, otherResourceType,
+ parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity, virtualQuantityUnits, weight,
+ connections, hostResources);
+ this.edit = edit;
+ }
+
+ public ReferenceType getEdit() {
+ return edit;
+ }
+
+ @Override
+ public String toString() {
+ return String
+ .format(
+ "[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s, edit=%s]",
+ elementName, instanceID, caption, description, address, addressOnParent, allocationUnits,
+ automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, limit,
+ mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType,
+ virtualQuantity, virtualQuantityUnits, weight, edit);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java
new file mode 100644
index 0000000..b281785
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java
@@ -0,0 +1,326 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.ovf;
+
+import java.util.List;
+
+import org.jclouds.cim.ResourceAllocationSettingData;
+
+public class VCloudHardDisk extends ResourceAllocationSettingData {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder toBuilder() {
+ return builder().fromVCloudHardDisk(this);
+ }
+
+ public static class Builder extends ResourceAllocationSettingData.Builder {
+ private long capacity;
+ private int busType;
+ private String busSubType;
+
+ /**
+ * @see VCloudHardDisk#getCapacity
+ */
+ public Builder capacity(long capacity) {
+ this.capacity = capacity;
+ return this;
+ }
+
+ /**
+ * @see VCloudHardDisk#getBusType
+ */
+ public Builder busType(int busType) {
+ this.busType = busType;
+ return this;
+ }
+
+ /**
+ * @see VCloudHardDisk#getBusSubType
+ */
+ public Builder busSubType(String busSubType) {
+ this.busSubType = busSubType;
+ return this;
+ }
+
+ public VCloudHardDisk build() {
+ return new VCloudHardDisk(elementName, instanceID, caption, description, address, addressOnParent,
+ allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior,
+ otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity,
+ virtualQuantityUnits, weight, connections, hostResources, capacity, busType, busSubType);
+ }
+
+ public Builder fromVCloudHardDisk(VCloudHardDisk in) {
+ return capacity(in.getCapacity()).busType(in.getBusType()).busSubType(in.getBusSubType())
+ .fromResourceAllocationSettingData(in);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder caption(String caption) {
+ return Builder.class.cast(super.caption(caption));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder description(String description) {
+ return Builder.class.cast(super.description(description));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder elementName(String elementName) {
+ return Builder.class.cast(super.elementName(elementName));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder instanceID(String instanceID) {
+ return Builder.class.cast(super.instanceID(instanceID));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder address(String address) {
+ return Builder.class.cast(super.address(address));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder addressOnParent(String addressOnParent) {
+ return Builder.class.cast(super.addressOnParent(addressOnParent));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder allocationUnits(String allocationUnits) {
+ return Builder.class.cast(super.allocationUnits(allocationUnits));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder automaticAllocation(Boolean automaticAllocation) {
+ return Builder.class.cast(super.automaticAllocation(automaticAllocation));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder automaticDeallocation(Boolean automaticDeallocation) {
+ return Builder.class.cast(super.automaticDeallocation(automaticDeallocation));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder connection(String connection) {
+ return Builder.class.cast(super.connection(connection));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder connections(List<String> connections) {
+ return Builder.class.cast(super.connections(connections));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder consumerVisibility(ConsumerVisibility consumerVisibility) {
+ return Builder.class.cast(super.consumerVisibility(consumerVisibility));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder hostResource(String hostResource) {
+ return Builder.class.cast(super.hostResource(hostResource));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder hostResources(List<String> hostResources) {
+ return Builder.class.cast(super.hostResources(hostResources));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder limit(Long limit) {
+ return Builder.class.cast(super.limit(limit));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder mappingBehavior(MappingBehavior mappingBehavior) {
+ return Builder.class.cast(super.mappingBehavior(mappingBehavior));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder otherResourceType(String otherResourceType) {
+ return Builder.class.cast(super.otherResourceType(otherResourceType));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder parent(String parent) {
+ return Builder.class.cast(super.parent(parent));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder poolID(String poolID) {
+ return Builder.class.cast(super.poolID(poolID));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder reservation(Long reservation) {
+ return Builder.class.cast(super.reservation(reservation));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder resourceSubType(String resourceSubType) {
+ return Builder.class.cast(super.resourceSubType(resourceSubType));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder resourceType(org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType) {
+ return Builder.class.cast(super.resourceType(resourceType));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder virtualQuantity(Long virtualQuantity) {
+ return Builder.class.cast(super.virtualQuantity(virtualQuantity));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder virtualQuantityUnits(String virtualQuantityUnits) {
+ return Builder.class.cast(super.virtualQuantityUnits(virtualQuantityUnits));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder weight(Integer weight) {
+ return Builder.class.cast(super.weight(weight));
+ }
+
+ @Override
+ public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) {
+ return Builder.class.cast(super.fromResourceAllocationSettingData(in));
+ }
+ }
+
+ private final long capacity;
+ private final int busType;
+ private final String busSubType;
+
+ public VCloudHardDisk(String elementName, String instanceID, String caption, String description, String address,
+ String addressOnParent, String allocationUnits, Boolean automaticAllocation, Boolean automaticDeallocation,
+ ConsumerVisibility consumerVisibility, Long limit, MappingBehavior mappingBehavior, String otherResourceType,
+ String parent, String poolID, Long reservation, String resourceSubType,
+ org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType, Long virtualQuantity,
+ String virtualQuantityUnits, Integer weight, List<String> connections, List<String> hostResources,
+ long capacity, int busType, String busSubType) {
+ super(elementName, instanceID, caption, description, address, addressOnParent, allocationUnits,
+ automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior, otherResourceType,
+ parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity, virtualQuantityUnits, weight,
+ connections, hostResources);
+ this.capacity = capacity;
+ this.busType = busType;
+ this.busSubType = busSubType;
+ }
+
+ public long getCapacity() {
+ return capacity;
+ }
+
+ public int getBusType() {
+ return busType;
+ }
+
+ public String getBusSubType() {
+ return busSubType;
+ }
+
+ @Override
+ public String toString() {
+ return String
+ .format(
+ "[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s, busSubType=%s, busType=%s, capacity=%s]",
+ elementName, instanceID, caption, description, address, addressOnParent, allocationUnits,
+ automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, limit,
+ mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType,
+ virtualQuantity, virtualQuantityUnits, weight, busSubType, busType, capacity);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java
new file mode 100644
index 0000000..7a48916
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java
@@ -0,0 +1,328 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.ovf;
+
+import java.util.List;
+
+import org.jclouds.cim.ResourceAllocationSettingData;
+
+public class VCloudNetworkAdapter extends ResourceAllocationSettingData {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder toBuilder() {
+ return builder().fromVCloudNetworkAdapter(this);
+ }
+
+ public static class Builder extends ResourceAllocationSettingData.Builder {
+ private String ipAddress;
+ private boolean primaryNetworkConnection;
+ private String ipAddressingMode;
+
+ /**
+ * @see VCloudNetworkAdapter#getCapacity
+ */
+ public Builder ipAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ return this;
+ }
+
+ /**
+ * @see VCloudNetworkAdapter#getBusType
+ */
+ public Builder primaryNetworkConnection(boolean primaryNetworkConnection) {
+ this.primaryNetworkConnection = primaryNetworkConnection;
+ return this;
+ }
+
+ /**
+ * @see VCloudNetworkAdapter#getBusSubType
+ */
+ public Builder ipAddressingMode(String ipAddressingMode) {
+ this.ipAddressingMode = ipAddressingMode;
+ return this;
+ }
+
+ public VCloudNetworkAdapter build() {
+ return new VCloudNetworkAdapter(elementName, instanceID, caption, description, address, addressOnParent,
+ allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit,
+ mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType,
+ virtualQuantity, virtualQuantityUnits, weight, connections, hostResources, ipAddress,
+ primaryNetworkConnection, ipAddressingMode);
+ }
+
+ public Builder fromVCloudNetworkAdapter(VCloudNetworkAdapter in) {
+ return ipAddress(in.getIpAddress()).primaryNetworkConnection(in.isPrimaryNetworkConnection())
+ .ipAddressingMode(in.getIpAddressingMode()).fromResourceAllocationSettingData(in);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder caption(String caption) {
+ return Builder.class.cast(super.caption(caption));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder description(String description) {
+ return Builder.class.cast(super.description(description));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder elementName(String elementName) {
+ return Builder.class.cast(super.elementName(elementName));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder instanceID(String instanceID) {
+ return Builder.class.cast(super.instanceID(instanceID));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder address(String address) {
+ return Builder.class.cast(super.address(address));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder addressOnParent(String addressOnParent) {
+ return Builder.class.cast(super.addressOnParent(addressOnParent));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder allocationUnits(String allocationUnits) {
+ return Builder.class.cast(super.allocationUnits(allocationUnits));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder automaticAllocation(Boolean automaticAllocation) {
+ return Builder.class.cast(super.automaticAllocation(automaticAllocation));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder automaticDeallocation(Boolean automaticDeallocation) {
+ return Builder.class.cast(super.automaticDeallocation(automaticDeallocation));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder connection(String connection) {
+ return Builder.class.cast(super.connection(connection));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder connections(List<String> connections) {
+ return Builder.class.cast(super.connections(connections));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder consumerVisibility(ConsumerVisibility consumerVisibility) {
+ return Builder.class.cast(super.consumerVisibility(consumerVisibility));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder hostResource(String hostResource) {
+ return Builder.class.cast(super.hostResource(hostResource));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder hostResources(List<String> hostResources) {
+ return Builder.class.cast(super.hostResources(hostResources));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder limit(Long limit) {
+ return Builder.class.cast(super.limit(limit));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder mappingBehavior(MappingBehavior mappingBehavior) {
+ return Builder.class.cast(super.mappingBehavior(mappingBehavior));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder otherResourceType(String otherResourceType) {
+ return Builder.class.cast(super.otherResourceType(otherResourceType));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder parent(String parent) {
+ return Builder.class.cast(super.parent(parent));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder poolID(String poolID) {
+ return Builder.class.cast(super.poolID(poolID));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder reservation(Long reservation) {
+ return Builder.class.cast(super.reservation(reservation));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder resourceSubType(String resourceSubType) {
+ return Builder.class.cast(super.resourceSubType(resourceSubType));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder resourceType(org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType) {
+ return Builder.class.cast(super.resourceType(resourceType));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder virtualQuantity(Long virtualQuantity) {
+ return Builder.class.cast(super.virtualQuantity(virtualQuantity));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder virtualQuantityUnits(String virtualQuantityUnits) {
+ return Builder.class.cast(super.virtualQuantityUnits(virtualQuantityUnits));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder weight(Integer weight) {
+ return Builder.class.cast(super.weight(weight));
+ }
+
+ @Override
+ public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) {
+ return Builder.class.cast(super.fromResourceAllocationSettingData(in));
+ }
+ }
+
+ private final String ipAddress;
+ private final boolean primaryNetworkConnection;
+ private final String ipAddressingMode;
+
+ public VCloudNetworkAdapter(String elementName, String instanceID, String caption, String description,
+ String address, String addressOnParent, String allocationUnits, Boolean automaticAllocation,
+ Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, Long limit,
+ MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, Long reservation,
+ String resourceSubType, org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType,
+ Long virtualQuantity, String virtualQuantityUnits, Integer weight, List<String> connections,
+ List<String> hostResources, String ipAddress, boolean primaryNetworkConnection, String ipAddressingMode) {
+ super(elementName, instanceID, caption, description, address, addressOnParent, allocationUnits,
+ automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior,
+ otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity,
+ virtualQuantityUnits, weight, connections, hostResources);
+ this.ipAddress = ipAddress;
+ this.primaryNetworkConnection = primaryNetworkConnection;
+ this.ipAddressingMode = ipAddressingMode;
+ }
+
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ public boolean isPrimaryNetworkConnection() {
+ return primaryNetworkConnection;
+ }
+
+ public String getIpAddressingMode() {
+ return ipAddressingMode;
+ }
+
+ @Override
+ public String toString() {
+ return String
+ .format(
+ "[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s, ipAddressingMode=%s, primaryNetworkConnection=%s, ipAddress=%s]",
+ elementName, instanceID, caption, description, address, addressOnParent, allocationUnits,
+ automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources,
+ limit, mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType,
+ resourceType, virtualQuantity, virtualQuantityUnits, weight, ipAddressingMode,
+ primaryNetworkConnection, ipAddress);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java
new file mode 100644
index 0000000..64dddc5
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.ovf;
+
+import java.net.URI;
+
+import org.jclouds.ovf.Network;
+import org.jclouds.ovf.NetworkSection;
+
+/**
+ * VCloud extension
+ */
+public class VCloudNetworkSection extends NetworkSection {
+ protected final String type;
+ protected final URI href;
+
+ public VCloudNetworkSection(String type, URI href, String info, Iterable<Network> networks) {
+ super(info, networks);
+ this.type = type;
+ this.href = href;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public URI getHref() {
+ return href;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((href == null) ? 0 : href.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.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;
+ VCloudNetworkSection other = (VCloudNetworkSection) obj;
+ if (href == null) {
+ if (other.href != null)
+ return false;
+ } else if (!href.equals(other.href))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[href=" + getHref() + ", type=" + getType() + ", info=" + getInfo() + ", networks=" + getNetworks() + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java
new file mode 100644
index 0000000..052eadd
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.ovf;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.ovf.OperatingSystemSection;
+import org.jclouds.vcloud.domain.ReferenceType;
+
+/**
+ * A description of the operating system supported by a virtual machine.
+ */
+public class VCloudOperatingSystemSection extends OperatingSystemSection {
+ protected final String type;
+ protected final URI href;
+ @Nullable
+ protected final String vmwOsType;
+ protected final ReferenceType edit;
+
+ public VCloudOperatingSystemSection(@Nullable Integer id, @Nullable String info, @Nullable String description, String type,
+ URI href, @Nullable String vmwOsType, ReferenceType edit) {
+ super(id, info, description);
+ this.type = type;
+ this.href = href;
+ this.vmwOsType = vmwOsType;
+ this.edit = checkNotNull(edit, "edit");
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public URI getHref() {
+ return href;
+ }
+
+ /**
+ *
+ * @return VMware osType, if running on VMware
+ */
+ public String getVmwOsType() {
+ return vmwOsType;
+ }
+
+ /**
+ *
+ * @return edit link
+ */
+ public ReferenceType getEdit() {
+ return edit;
+ }
+
+ @Override
+ public String toString() {
+ return "[href=" + getHref() + ", type=" + getType() + ", id=" + getId() + ", vmwOsType=" + getVmwOsType()
+ + ", description=" + getDescription() + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((edit == null) ? 0 : edit.hashCode());
+ result = prime * result + ((href == null) ? 0 : href.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ result = prime * result + ((vmwOsType == null) ? 0 : vmwOsType.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;
+ VCloudOperatingSystemSection other = (VCloudOperatingSystemSection) obj;
+ if (edit == null) {
+ if (other.edit != null)
+ return false;
+ } else if (!edit.equals(other.edit))
+ return false;
+ if (href == null) {
+ if (other.href != null)
+ return false;
+ } else if (!href.equals(other.href))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ if (vmwOsType == null) {
+ if (other.vmwOsType != null)
+ return false;
+ } else if (!vmwOsType.equals(other.vmwOsType))
+ return false;
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java
new file mode 100644
index 0000000..6d89b95
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.ovf;
+
+import java.net.URI;
+
+import org.jclouds.cim.ResourceAllocationSettingData;
+import org.jclouds.cim.VirtualSystemSettingData;
+import org.jclouds.ovf.Section;
+import org.jclouds.ovf.VirtualHardwareSection;
+
+/**
+ * A description of the virtual hardware supported by a virtual machine.
+ */
+public class VCloudVirtualHardwareSection extends VirtualHardwareSection {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder toBuilder() {
+ return builder().fromVCloudVirtualHardwareSection(this);
+ }
+
+ public static class Builder extends VirtualHardwareSection.Builder {
+ protected String type;
+ protected URI href;
+
+ /**
+ * @see VCloudVirtualHardware#getType
+ */
+ public Builder type(String type) {
+ this.type = type;
+ return this;
+ }
+
+ /**
+ * @see VCloudVirtualHardware#getHref
+ */
+ public Builder href(URI href) {
+ this.href = href;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder system(VirtualSystemSettingData virtualSystem) {
+ return Builder.class.cast(super.system(virtualSystem));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder transport(String transport) {
+ return Builder.class.cast(super.transport(transport));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder transports(Iterable<String> transports) {
+ return Builder.class.cast(super.transports(transports));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder item(ResourceAllocationSettingData item) {
+ return Builder.class.cast(super.item(item));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder items(Iterable<? extends ResourceAllocationSettingData> items) {
+ return Builder.class.cast(super.items(items));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public VCloudVirtualHardwareSection build() {
+ return new VCloudVirtualHardwareSection(type, href, info, transports, virtualSystem, items);
+ }
+
+ public Builder fromVCloudVirtualHardwareSection(VCloudVirtualHardwareSection in) {
+ return fromVirtualHardwareSection(in).type(in.getType()).href(in.getHref());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder fromVirtualHardwareSection(VirtualHardwareSection in) {
+ return Builder.class.cast(super.fromVirtualHardwareSection(in));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder fromSection(Section<VirtualHardwareSection> in) {
+ return Builder.class.cast(super.fromSection(in));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder info(String info) {
+ return Builder.class.cast(super.info(info));
+ }
+ }
+
+ protected final String type;
+ protected final URI href;
+
+ public VCloudVirtualHardwareSection(String type, URI href, String info, Iterable<String> transports,
+ VirtualSystemSettingData virtualSystem, Iterable<? extends ResourceAllocationSettingData> resourceAllocations) {
+ super(info, transports, virtualSystem, resourceAllocations);
+ this.type = type;
+ this.href = href;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public URI getHref() {
+ return href;
+ }
+
+ @Override
+ public int hashCode() {
+ return href.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ VCloudVirtualHardwareSection other = (VCloudVirtualHardwareSection) obj;
+ return href.equals(other.href);
+ }
+
+ @Override
+ public String toString() {
+ return "[href=" + getHref() + ", type=" + getType() + ", info=" + getInfo() + ", virtualSystem=" + getSystem()
+ + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java
new file mode 100644
index 0000000..7b59d1e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.endpoints;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Related to a VCloud Catalog.
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
+@Qualifier
+public @interface Catalog {
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Network.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Network.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Network.java
new file mode 100644
index 0000000..f30162e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Network.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.endpoints;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Related to a VCloud Network.
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
+@Qualifier
+public @interface Network {
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Org.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Org.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Org.java
new file mode 100644
index 0000000..167b1ee
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Org.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.endpoints;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Related to a VCloud express Org.
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
+@Qualifier
+public @interface Org {
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java
new file mode 100644
index 0000000..5e0caab
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.endpoints;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Related to a VCloud express Org List.
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
+@Qualifier
+public @interface OrgList {
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java
new file mode 100644
index 0000000..333a39f
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.endpoints;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Related to a VCloud express Task List.
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
+@Qualifier
+public @interface TasksList {
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java
new file mode 100644
index 0000000..7d3124b
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.endpoints;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Represents a component related to vCloud.
+ *
+ * @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
+@Qualifier
+public @interface VCloudLogin {
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VDC.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VDC.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VDC.java
new file mode 100644
index 0000000..193eb74
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VDC.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.endpoints;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Related to a VCloud express Catalog.
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
+@Qualifier
+public @interface VDC {
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/CatalogApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/CatalogApi.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/CatalogApi.java
new file mode 100644
index 0000000..1aa660e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/CatalogApi.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML;
+import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.vcloud.binders.BindCatalogItemToXmlPayload;
+import org.jclouds.vcloud.binders.OrgNameAndCatalogNameToEndpoint;
+import org.jclouds.vcloud.binders.OrgNameCatalogNameItemNameToEndpoint;
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+import org.jclouds.vcloud.options.CatalogItemOptions;
+import org.jclouds.vcloud.xml.CatalogHandler;
+import org.jclouds.vcloud.xml.CatalogItemHandler;
+
+
+/**
+ * Provides access to Catalog functionality in vCloud
+ * <p/>
+ *
+ * @see <a href="http://communities.vmware.com/community/developer/forums/vcloudapi" />
+ */
+@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
+public interface CatalogApi {
+
+ @GET
+ @XMLResponseParser(CatalogHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Consumes(CATALOG_XML)
+ Catalog getCatalog(@EndpointParam URI catalogId);
+
+ /**
+ * returns the catalog in the organization associated with the specified name. Note that both
+ * parameters can be null to choose default.
+ *
+ * @param orgName
+ * organization name, or null for the default
+ * @param catalogName
+ * catalog name, or null for the default
+ * @throws NoSuchElementException
+ * if you specified an org or catalog name that isn't present
+ */
+ @GET
+ @XMLResponseParser(CatalogHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Consumes(CATALOG_XML)
+ @MapBinder(OrgNameAndCatalogNameToEndpoint.class)
+ Catalog findCatalogInOrgNamed(@Nullable @PayloadParam("orgName") String orgName,
+ @Nullable @PayloadParam("catalogName") String catalogName);
+
+ @GET
+ @Consumes(CATALOGITEM_XML)
+ @XMLResponseParser(CatalogItemHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ CatalogItem getCatalogItem(@EndpointParam URI catalogItem);
+
+ /**
+ * returns the catalog item in the catalog associated with the specified name. Note that the org
+ * and catalog parameters can be null to choose default.
+ *
+ * @param orgName
+ * organization name, or null for the default
+ * @param catalogName
+ * catalog name, or null for the default
+ * @param itemName
+ * item you wish to lookup
+ *
+ * @throws NoSuchElementException
+ * if you specified an org, catalog, or catalog item name that isn't present
+ */
+ @GET
+ @Consumes(CATALOGITEM_XML)
+ @XMLResponseParser(CatalogItemHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(OrgNameCatalogNameItemNameToEndpoint.class)
+ CatalogItem findCatalogItemInOrgCatalogNamed(@Nullable @PayloadParam("orgName") String orgName,
+ @Nullable @PayloadParam("catalogName") String catalogName,
+ @PayloadParam("itemName") String itemName);
+
+ /**
+ * A catalog can contain references to vApp templates and media images that have been uploaded to
+ * any vDC in an organization. A vApp template or media image can be listed in at most one
+ * catalog.
+ *
+ * @param entity
+ * the reference to the vApp templates and media image
+ * @param catalog
+ * URI of the catalog to add the resourceEntity from
+ * @param name
+ * name of the entry in the catalog
+ *
+ * @param options
+ * options such as description or properties
+ * @return the new catalog item
+ */
+ @POST
+ @Path("/catalogItems")
+ @Consumes(CATALOGITEM_XML)
+ @Produces(CATALOGITEM_XML)
+ @MapBinder(BindCatalogItemToXmlPayload.class)
+ @XMLResponseParser(CatalogItemHandler.class)
+ CatalogItem addVAppTemplateOrMediaImageToCatalogAndNameItem(@PayloadParam("Entity") URI entity,
+ @EndpointParam URI catalog,
+ @PayloadParam("name") String name,
+ CatalogItemOptions... options);
+
+ @DELETE
+ @Fallback(Fallbacks.VoidOnNotFoundOr404.class)
+ void deleteCatalogItem(@EndpointParam URI href);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/NetworkApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/NetworkApi.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/NetworkApi.java
new file mode 100644
index 0000000..d36e471
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/NetworkApi.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.vcloud.VCloudMediaType.NETWORK_XML;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.vcloud.binders.OrgNameVDCNameNetworkNameToEndpoint;
+import org.jclouds.vcloud.domain.network.OrgNetwork;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+import org.jclouds.vcloud.xml.OrgNetworkHandler;
+
+/**
+ * Provides access to Network functionality in vCloud
+ * <p/>
+ */
+@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
+public interface NetworkApi {
+
+ @GET
+ @Consumes(NETWORK_XML)
+ @XMLResponseParser(OrgNetworkHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(OrgNameVDCNameNetworkNameToEndpoint.class)
+ OrgNetwork findNetworkInOrgVDCNamed(@Nullable @PayloadParam("orgName") String orgName,
+ @Nullable @PayloadParam("vdcName") String vdcName,
+ @PayloadParam("resourceName") String networkName);
+
+ @GET
+ @Consumes(NETWORK_XML)
+ @XMLResponseParser(OrgNetworkHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ OrgNetwork getNetwork(@EndpointParam URI network);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/OrgApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/OrgApi.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/OrgApi.java
new file mode 100644
index 0000000..3b7cf3a
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/OrgApi.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
+
+import java.net.URI;
+import java.util.Map;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.rest.annotations.Endpoint;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.OrgList;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+import org.jclouds.vcloud.functions.OrgNameToEndpoint;
+import org.jclouds.vcloud.xml.OrgHandler;
+import org.jclouds.vcloud.xml.OrgListHandler;
+
+
+/**
+ * Provides access to Org functionality in vCloud
+ * <p/>
+ */
+@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
+public interface OrgApi {
+
+ /**
+ * The response to a login request includes a list of the organizations to which the
+ * authenticated user has access.
+ *
+ * @return organizations indexed by name
+ */
+ @GET
+ @Endpoint(OrgList.class)
+ @XMLResponseParser(OrgListHandler.class)
+ @Consumes(VCloudMediaType.ORGLIST_XML)
+ Map<String, ReferenceType> listOrgs();
+
+ @GET
+ @XMLResponseParser(OrgHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Consumes(ORG_XML)
+ Org getOrg(@EndpointParam URI orgId);
+
+ /**
+ * This call returns a list of all vCloud Data Centers (vdcs), catalogs, and task lists within
+ * the organization.
+ *
+ * @param name
+ * organization name, or null for the default
+ * @throws NoSuchElementException
+ * if you specified an org name that isn't present
+ */
+ @GET
+ @XMLResponseParser(OrgHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Consumes(ORG_XML)
+ Org findOrgNamed(@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/TaskApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/TaskApi.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/TaskApi.java
new file mode 100644
index 0000000..b9a60a6
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/TaskApi.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
+import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.TasksList;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+import org.jclouds.vcloud.functions.OrgNameToTasksListEndpoint;
+import org.jclouds.vcloud.xml.TaskHandler;
+import org.jclouds.vcloud.xml.TasksListHandler;
+
+/**
+ * Provides access to Task functionality in vCloud
+ * <p/>
+ */
+@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
+public interface TaskApi {
+
+ @GET
+ @Consumes(TASKSLIST_XML)
+ @XMLResponseParser(TasksListHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ TasksList getTasksList(@EndpointParam URI tasksListId);
+
+ @GET
+ @Consumes(TASKSLIST_XML)
+ @XMLResponseParser(TasksListHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ TasksList findTasksListInOrgNamed(@Nullable @EndpointParam(parser = OrgNameToTasksListEndpoint.class) String orgName);
+
+ /**
+ * Whenever the result of a request cannot be returned immediately, the server creates a Task
+ * object and includes it in the response, as a member of the Tasks container in the response
+ * body. Each Task has an href value, which is a URL that the client can use to retrieve the Task
+ * element alone, without the rest of the response in which it was contained. All information
+ * about the task is included in the Task element when it is returned in the response’s Tasks
+ * container, so a client does not need to make an additional request to the Task URL unless it
+ * wants to follow the progress of a task that was incomplete.
+ */
+ @GET
+ @Consumes(TASK_XML)
+ @XMLResponseParser(TaskHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Task getTask(@EndpointParam URI taskId);
+
+ @POST
+ @Path("/action/cancel")
+ void cancelTask(@EndpointParam URI taskId);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppApi.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppApi.java
new file mode 100644
index 0000000..af44c3e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppApi.java
@@ -0,0 +1,260 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.vcloud.VCloudMediaType.DEPLOYVAPPPARAMS_XML;
+import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
+import static org.jclouds.vcloud.VCloudMediaType.UNDEPLOYVAPPPARAMS_XML;
+import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.predicates.validators.DnsNameValidator;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.ParamValidators;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.PayloadParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload;
+import org.jclouds.vcloud.binders.BindDeployVAppParamsToXmlPayload;
+import org.jclouds.vcloud.binders.BindUndeployVAppParamsToXmlPayload;
+import org.jclouds.vcloud.binders.OrgNameVDCNameResourceEntityNameToEndpoint;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+import org.jclouds.vcloud.options.CloneVAppOptions;
+import org.jclouds.vcloud.xml.TaskHandler;
+import org.jclouds.vcloud.xml.VAppHandler;
+
+
+/**
+ * Provides access to VApp functionality in vCloud
+ * <p/>
+ *
+ * @see <a href="http://communities.vmware.com/community/developer/forums/vcloudapi" />
+ */
+@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
+public interface VAppApi {
+ @GET
+ @Consumes(VAPP_XML)
+ @XMLResponseParser(VAppHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(OrgNameVDCNameResourceEntityNameToEndpoint.class)
+ VApp findVAppInOrgVDCNamed(@Nullable @PayloadParam("orgName") String orgName,
+ @Nullable @PayloadParam("vdcName") String vdcName, @PayloadParam("resourceName") String vAppName);
+
+ @POST
+ @Path("/action/cloneVApp")
+ @Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml")
+ @Consumes(TASK_XML)
+ @XMLResponseParser(TaskHandler.class)
+ @MapBinder(BindCloneVAppParamsToXmlPayload.class)
+ Task copyVAppToVDCAndName(@PayloadParam("Source") URI sourceVApp,
+ @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
+ CloneVAppOptions... options);
+
+ @POST
+ @Path("/action/cloneVApp")
+ @Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml")
+ @Consumes(TASK_XML)
+ @XMLResponseParser(TaskHandler.class)
+ @PayloadParams(keys = "IsSourceDelete", values = "true")
+ @MapBinder(BindCloneVAppParamsToXmlPayload.class)
+ Task moveVAppToVDCAndRename(@PayloadParam("Source") URI sourceVApp,
+ @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
+ CloneVAppOptions... options);
+
+ @GET
+ @Consumes(VAPP_XML)
+ @XMLResponseParser(VAppHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ VApp getVApp(@EndpointParam URI href);
+
+ /**
+ * To deploy a vApp, the client makes a request to its action/deploy URL. Deploying a vApp
+ * automatically deploys all of the virtual machines it contains. To deploy a virtual machine,
+ * the client makes a request to its action/deploy URL.
+ * <p/>
+ * Deploying a Vm implicitly deploys the parent vApp if that vApp is not already deployed.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(DEPLOYVAPPPARAMS_XML)
+ @Path("/action/deploy")
+ @MapBinder(BindDeployVAppParamsToXmlPayload.class)
+ @XMLResponseParser(TaskHandler.class)
+ Task deployVApp(@EndpointParam URI href);
+
+ /**
+ * like {@link #deployVApp(URI)}, except deploy transitions to power on state
+ *
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(DEPLOYVAPPPARAMS_XML)
+ @Path("/action/deploy")
+ @MapBinder(BindDeployVAppParamsToXmlPayload.class)
+ @PayloadParams(keys = "powerOn", values = "true")
+ @XMLResponseParser(TaskHandler.class)
+ Task deployAndPowerOnVApp(@EndpointParam URI href);
+
+ /**
+ * Undeploying a vApp powers off or suspends any running virtual machines it contains, then frees
+ * the resources reserved for the vApp and sets the vApp’s deploy attribute to a value of false
+ * to indicate that it is not deployed.
+ * <p/>
+ * Undeploying a virtual machine powers off or suspends the virtual machine, then frees the
+ * resources reserved for it and sets the its deploy attribute to a value of false to indicate
+ * that it is not deployed. This operation has no effect on the containing vApp.
+ * <h4>NOTE</h4>
+ * Using this method will simply power off the vms. In order to save their state, use
+ * {@link #undeployAndSaveStateOf}
+ *
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(UNDEPLOYVAPPPARAMS_XML)
+ @Path("/action/undeploy")
+ @MapBinder(BindUndeployVAppParamsToXmlPayload.class)
+ @XMLResponseParser(TaskHandler.class)
+ Task undeployVApp(@EndpointParam URI href);
+
+ /**
+ * like {@link #undeployVApp(URI)}, where the undeployed virtual machines are suspended and their
+ * suspend state saved
+ *
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(UNDEPLOYVAPPPARAMS_XML)
+ @Path("/action/undeploy")
+ @MapBinder(BindUndeployVAppParamsToXmlPayload.class)
+ @PayloadParams(keys = "saveState", values = "true")
+ @XMLResponseParser(TaskHandler.class)
+ Task undeployAndSaveStateOfVApp(@EndpointParam URI href);
+
+ /**
+ * A powerOn request to a vApp URL powers on all of the virtual machines in the vApp, as
+ * specified in the vApp’s StartupSection field.
+ * <p/>
+ * A powerOn request to a virtual machine URL powers on the specified virtual machine and forces
+ * deployment of the parent vApp.
+ * <p/>
+ * <h4>NOTE</h4> A powerOn request to a vApp or virtual machine that is undeployed forces
+ * deployment.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Path("/power/action/powerOn")
+ @XMLResponseParser(TaskHandler.class)
+ Task powerOnVApp(@EndpointParam URI href);
+
+ /**
+ * A powerOff request to a vApp URL powers off all of the virtual machines in the vApp, as
+ * specified in its StartupSection field.
+ * <p/>
+ * A powerOff request to a virtual machine URL powers off the specified virtual machine.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Path("/power/action/powerOff")
+ @XMLResponseParser(TaskHandler.class)
+ Task powerOffVApp(@EndpointParam URI href);
+
+ /**
+ * A shutdown request to a vApp URL shuts down all of the virtual machines in the vApp, as
+ * specified in its StartupSection field.
+ * <p/>
+ * A shutdown request to a virtual machine URL shuts down the specified virtual machine.
+ * <p/>
+ * <h4>NOTE</h4Because this request sends a signal to the guest OS, the vCloud API cannot track
+ * the progress or verify the result of the requested operation. Hence, void is returned
+ */
+ @POST
+ @Path("/power/action/shutdown")
+ void shutdownVApp(@EndpointParam URI href);
+
+ /**
+ * A reset request to a vApp URL resets all of the virtual machines in the vApp, as specified in
+ * its StartupSection field.
+ * <p/>
+ * A reset request to a virtual machine URL resets the specified virtual machine.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Path("/power/action/reset")
+ @XMLResponseParser(TaskHandler.class)
+ Task resetVApp(@EndpointParam URI href);
+
+ /**
+ * A reboot request to a vApp URL reboots all of the virtual machines in the vApp, as specified
+ * in its StartupSection field.
+ * <p/>
+ * A reboot request to a virtual machine URL reboots the specified virtual machine.
+ * <p/>
+ * <h4>NOTE</h4> Because this request sends a signal to the guest OS, the vCloud API cannot track
+ * the progress or verify the result of the requested operation. Hence, void is returned
+ */
+ @POST
+ @Path("/power/action/reboot")
+ void rebootVApp(@EndpointParam URI href);
+
+ /**
+ * A suspend request to a vApp URL suspends all of the virtual machines in the vApp, as specified
+ * in its StartupSection field.
+ * <p/>
+ * A suspend request to a virtual machine URL suspends the specified virtual machine.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Path("/power/action/suspend")
+ @XMLResponseParser(TaskHandler.class)
+ Task suspendVApp(@EndpointParam URI href);
+
+ /**
+ * delete a vAppTemplate, vApp, or media image. You cannot delete an object if it is in use. Any
+ * object that is being copied or moved is in use. Other criteria that determine whether an
+ * object is in use depend on the object type.
+ * <ul>
+ * <li>A vApptemplate is in use if it is being instantiated. After instantiation is complete, the
+ * template is no longer in use.</li>
+ * <li>A vApp is in use if it is deployed.</li>
+ * <li>A media image is in use if it is inserted in a Vm.</li>
+ * </ul>
+ *
+ * @param href
+ * href of the vApp
+ * @return task of the operation in progress
+ */
+ @DELETE
+ @Consumes(TASK_XML)
+ @Fallback(Fallbacks.VoidOnNotFoundOr404.class)
+ @XMLResponseParser(TaskHandler.class)
+ Task deleteVApp(@EndpointParam URI href);
+}
[20/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApiExpectTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApiExpectTest.java
new file mode 100644
index 0000000..0cab1dd
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApiExpectTest.java
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.features;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.domain.Subnet;
+import org.jclouds.openstack.neutron.v2_0.internal.BaseNeutronApiExpectTest;
+import org.jclouds.openstack.neutron.v2_0.options.CreateSubnetBulkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreateSubnetOptions;
+import org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions;
+import org.jclouds.openstack.neutron.v2_0.parse.ParseSubnetTest;
+import org.jclouds.rest.AuthorizationException;
+import org.testng.annotations.Test;
+
+import java.util.Set;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * Tests parsing and Guice wiring of SubnetApi
+ */
+@Test(groups = "unit", testName = "SubnetApiExpectTest")
+public class SubnetApiExpectTest extends BaseNeutronApiExpectTest {
+
+ private static final String ZONE = "region-a.geo-1";
+
+ public void testListReferencesReturns2xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets").addQueryParam("fields", "id", "tenant_id", "name").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/list_subnets.json", APPLICATION_JSON)).build())
+ .getSubnetApiForZone(ZONE);
+
+ Set<? extends ReferenceWithName> references = api.list().concat().toSet();
+ assertEquals(references, listOfReferencesWithNames());
+ }
+
+ public void testListReferencesReturns4xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets").addQueryParam("fields", "id", "tenant_id", "name").build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getSubnetApiForZone(ZONE);
+
+ assertTrue(api.list().concat().isEmpty());
+ }
+
+ public void testListReturns2xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/list_subnets.json", APPLICATION_JSON)).build())
+ .getSubnetApiForZone(ZONE);
+
+ Set<? extends Subnet> subnets = api.listInDetail().concat().toSet();
+ assertEquals(subnets, listOfSubnets());
+ }
+
+ public void testListReturns4xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets").build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getSubnetApiForZone(ZONE);
+
+ assertTrue(api.listInDetail().concat().isEmpty());
+ }
+
+ public void testGetReturns2xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets/624312ff-d14b-4ba3-9834-1c78d23d574d").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/subnet.json", APPLICATION_JSON)).build())
+ .getSubnetApiForZone(ZONE);
+
+ Subnet subnet = api.get("624312ff-d14b-4ba3-9834-1c78d23d574d");
+ assertEquals(subnet, new ParseSubnetTest().expected());
+ }
+
+ public void testGetReturns4xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets/624312ff-d14b-4ba3-9834-1c78d23d574d").build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getSubnetApiForZone(ZONE);
+
+ assertNull(api.get("624312ff-d14b-4ba3-9834-1c78d23d574d"));
+ }
+
+ public void testCreateReturns2xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets").method("POST")
+ .payload(payloadFromStringWithContentType("{\"subnet\":{\"network_id\":\"1234567890\",\"ip_version\":4,\"cidr\":\"10.0.3.0/24\",\"name\":\"subnet-test\"}}", APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromStringWithContentType("{\"subnet\":{\"id\":\"12345\",\"tenant_id\":\"6789\",\"network_id\":\"1234567890\",\"ip_version\":4,\"cidr\":\"10.0.3.0/24\",\"name\":\"subnet-test\"}}", APPLICATION_JSON)).build())
+ .getSubnetApiForZone(ZONE);
+
+ Subnet net = api.create("1234567890", 4, "10.0.3.0/24", CreateSubnetOptions.builder().name("subnet-test").build());
+ assertEquals(net, Subnet.builder().id("12345").tenantId("6789").name("subnet-test").networkId("1234567890").ipVersion(4).cidr("10.0.3.0/24").build());
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testCreateReturns4xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets").method("POST")
+ .payload(payloadFromStringWithContentType("{\"subnet\":{\"network_id\":\"1234567890\",\"ip_version\":4,\"cidr\":\"10.0.3.0/24\",\"name\":\"subnet-test\"}}", APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(401).build())
+ .getSubnetApiForZone(ZONE);
+
+ api.create("1234567890", 4, "10.0.3.0/24", CreateSubnetOptions.builder().name("subnet-test").build());
+ }
+
+ public void testCreateBulkReturns2xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets").method("POST")
+ .payload(payloadFromStringWithContentType(
+ "{\"subnets\":[" +
+ "{\"network_id\":\"1234567890\",\"ip_version\":4,\"cidr\":\"10.0.3.0/24\",\"name\":\"subnet-test\"}," +
+ "{\"network_id\":\"9876543210\",\"ip_version\":4,\"cidr\":\"192.168.3.0/24\",\"name\":\"subnet-test-2\"}" +
+ "]}", APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromStringWithContentType(
+ "{\"subnets\":[" +
+ "{\"id\":\"1\",\"tenant_id\":\"1\",\"network_id\":\"1234567890\",\"ip_version\":4,\"cidr\":\"10.0.3.0/24\",\"name\":\"subnet-test\"}," +
+ "{\"id\":\"2\",\"tenant_id\":\"1\",\"network_id\":\"9876543210\",\"ip_version\":4,\"cidr\":\"192.168.3.0/24\",\"name\":\"subnet-test-2\"}" +
+ "]}", APPLICATION_JSON)).build())
+ .getSubnetApiForZone(ZONE);
+
+ Set<? extends Subnet> nets = api.createBulk(
+ CreateSubnetBulkOptions.builder().subnets(
+ ImmutableList.of(
+ BulkSubnet.builder().networkId("1234567890").ipVersion(4).cidr("10.0.3.0/24").name("subnet-test").build(),
+ BulkSubnet.builder().networkId("9876543210").ipVersion(4).cidr("192.168.3.0/24").name("subnet-test-2").build()
+ )
+ ).build()
+ ).toSet();
+ assertEquals(nets, createBulkReturns2xxResponse());
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testCreateBulkReturns4xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets").method("POST")
+ .payload(payloadFromStringWithContentType(
+ "{\"subnets\":[" +
+ "{\"network_id\":\"1234567890\",\"ip_version\":4,\"cidr\":\"10.0.3.0/24\",\"name\":\"subnet-test\"}," +
+ "{\"network_id\":\"9876543210\",\"ip_version\":4,\"cidr\":\"192.168.3.0/24\",\"name\":\"subnet-test-2\"}" +
+ "]}", APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(401).build())
+ .getSubnetApiForZone(ZONE);
+
+ api.createBulk(
+ CreateSubnetBulkOptions.builder().subnets(
+ ImmutableList.of(
+ BulkSubnet.builder().networkId("1234567890").ipVersion(4).cidr("10.0.3.0/24").name("subnet-test").build(),
+ BulkSubnet.builder().networkId("9876543210").ipVersion(4).cidr("192.168.3.0/24").name("subnet-test-2").build()
+ )
+ ).build()
+ );
+ }
+
+ public void testUpdateReturns2xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets/12345").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"subnet\":{\"name\":\"another-test\",\"gateway_ip\":\"13.13.13.13\"}}", APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).build())
+ .getSubnetApiForZone(ZONE);
+
+ assertTrue(api.update("12345", UpdateSubnetOptions.builder().name("another-test").gatewayIp("13.13.13.13").build()));
+ }
+
+ public void testUpdateReturns4xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets/12345").method("PUT")
+ .payload(payloadFromStringWithContentType("{\"subnet\":{\"name\":\"another-test\",\"gateway_ip\":\"13.13.13.13\"}}", APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(404).build())
+ .getSubnetApiForZone(ZONE);
+
+ assertFalse(api.update("12345", UpdateSubnetOptions.builder().name("another-test").gatewayIp("13.13.13.13").build()));
+ }
+
+ public void testDeleteReturns2xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets/12345").method("DELETE").build(),
+ HttpResponse.builder().statusCode(200).build())
+ .getSubnetApiForZone(ZONE);
+
+ assertTrue(api.delete("12345"));
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testDeleteReturns4xx() {
+ SubnetApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ authenticatedGET().endpoint(endpoint + "/subnets/12345").method("DELETE").build(),
+ HttpResponse.builder().statusCode(403).build())
+ .getSubnetApiForZone(ZONE);
+
+ api.delete("12345");
+ }
+
+ protected Set<Subnet> listOfSubnets() {
+ return ImmutableSet.of(
+ Subnet.builder().ipVersion(4).cidr("10.0.3.0/24").networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("16dba3bc-f3fa-4775-afdc-237e12c72f6a").build(),
+ Subnet.builder().ipVersion(4).cidr("10.0.3.0/24").networkId("1234567890").name("wibble").tenantId("1234567890").id("1a104cf5-cb18-4d35-9407-2fd2646d9d0b").build(),
+ Subnet.builder().ipVersion(4).cidr("10.0.3.0/24").networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("31083ae2-420d-48b2-ac98-9f7a4fd8dbdc").build(),
+ Subnet.builder().ipVersion(4).cidr("10.0.3.0/24").networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("49c6d6fa-ff2a-459d-b975-75a8d31c9a89").build(),
+ Subnet.builder().ipVersion(4).cidr("10.0.3.0/24").networkId("1234567890").name("wibble").tenantId("1234567890").id("5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e").build(),
+ Subnet.builder().ipVersion(4).cidr("10.0.3.0/24").networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("5d51d012-3491-4db7-b1b5-6f254015015d").build(),
+ Subnet.builder().ipVersion(4).cidr("10.0.3.0/24").networkId("1234567890").name("wibble").tenantId("1234567890").id("5f9cf7dc-22ca-4097-8e49-1cc8b23faf17").build(),
+ Subnet.builder().ipVersion(4).cidr("10.0.3.0/24").networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("6319ecad-6bff-48b2-9b53-02ede8cb7588").build(),
+ Subnet.builder().ipVersion(4).cidr("10.0.3.0/24").networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("6ba4c788-661f-49ab-9bf8-5f10cbbb2f57").build(),
+ Subnet.builder().ipVersion(4).cidr("10.0.3.0/24").networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("74ed170b-5069-4353-ab38-9719766dc57e").build(),
+ Subnet.builder().ipVersion(4).cidr("10.0.3.0/24").networkId("1234567890").name("wibble").tenantId("1234567890").id("b71fcac1-e864-4031-8c5b-edbecd9ece36").build(),
+ Subnet.builder().ipVersion(4).cidr("10.0.3.0/24").networkId("1234567890").name("jclouds-test").tenantId("1234567890").id("c7681895-d84d-4650-9ca0-82c72036b855").build()
+ );
+ }
+
+ protected Set<Subnet> createBulkReturns2xxResponse() {
+ return ImmutableSet.of(
+ Subnet.builder().id("1").tenantId("1").name("subnet-test").networkId("1234567890").ipVersion(4).cidr("10.0.3.0/24").build(),
+ Subnet.builder().id("2").tenantId("1").name("subnet-test-2").networkId("9876543210").ipVersion(4).cidr("192.168.3.0/24").build()
+ );
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApiLiveTest.java
new file mode 100644
index 0000000..b463339
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApiLiveTest.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.neutron.v2_0.domain.AllocationPool;
+import org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet;
+import org.jclouds.openstack.neutron.v2_0.domain.HostRoute;
+import org.jclouds.openstack.neutron.v2_0.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.domain.Subnet;
+import org.jclouds.openstack.neutron.v2_0.internal.BaseNeutronApiLiveTest;
+import org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreateSubnetBulkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreateSubnetOptions;
+import org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions;
+import org.jclouds.openstack.neutron.v2_0.util.PredicateUtil;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+/**
+ * Tests subnet api in combination with the network api
+ *
+ */
+@Test(groups = "live", testName = "SubnetApiLiveTest")
+public class SubnetApiLiveTest extends BaseNeutronApiLiveTest {
+
+ public void testGetAndListSubnets() {
+ for (String zone : api.getConfiguredZones()) {
+ Set<? extends ReferenceWithName> references = api.getSubnetApiForZone(zone).list().concat().toSet();
+ Set<? extends Subnet> subnets = api.getSubnetApiForZone(zone).listInDetail().concat().toSet();
+
+ assertNotNull(references);
+ assertNotNull(subnets);
+ assertEquals(references.size(), subnets.size());
+
+ for (Subnet subnet : subnets) {
+ assertNotNull(subnet.getNetworkId());
+ assertTrue(references.contains(ReferenceWithName.builder().id(subnet.getId()).tenantId(subnet.getTenantId()).name(subnet.getName()).build()));
+
+ Subnet retrievedSubnet = api.getSubnetApiForZone(zone).get(subnet.getId());
+ assertEquals(retrievedSubnet, subnet);
+ }
+ }
+ }
+
+ public void testCreateUpdateAndDeleteSubnet() {
+ for (String zone : api.getConfiguredZones()) {
+ NetworkApi networkApi = api.getNetworkApiForZone(zone);
+ String networkId = networkApi.create(CreateNetworkOptions.builder().name("jclouds-live-test").networkType(NetworkType.LOCAL).build()).getId();
+
+ SubnetApi subnetApi = api.getSubnetApiForZone(zone);
+ Set<AllocationPool> allocationPools = ImmutableSet.of(
+ AllocationPool.builder().start("a3:bc00::10").end("a3:bc00::20").build(),
+ AllocationPool.builder().start("a3:bc00::50").end("a3:bc00::90").build()
+ );
+ Set<HostRoute> hostRoutes = ImmutableSet.of(
+ HostRoute.builder().destinationCidr("a3:bc00::/48").nextHop("a3:bc00::0004").build()
+ );
+ Subnet subnet = subnetApi.create(networkId, 6, "a3:bc00::/48", CreateSubnetOptions.builder().allocationPools(allocationPools).hostRoutes(hostRoutes).build());
+ assertNotNull(subnet);
+
+ Subnet retrievedSubnet = subnetApi.get(subnet.getId());
+
+ assertEquals(retrievedSubnet.getId(), subnet.getId());
+ assertEquals(retrievedSubnet.getCidr(), "a3:bc00::/48");
+ assertTrue(retrievedSubnet.getDnsNameServers().isEmpty());
+ assertEquals(retrievedSubnet.getAllocationPools().size(), 2);
+ assertEquals(retrievedSubnet.getHostRoutes().size(), 1);
+ assertTrue(subnetApi.update(retrievedSubnet.getId(), UpdateSubnetOptions.builder().name("jclouds-live-test-update").build()));
+
+ retrievedSubnet = subnetApi.get(retrievedSubnet.getId());
+
+ assertEquals(retrievedSubnet.getId(), subnet.getId());
+ assertEquals(retrievedSubnet.getName(), "jclouds-live-test-update");
+ assertTrue(retrievedSubnet.getDnsNameServers().isEmpty());
+
+ Subnet subnet2 = subnetApi.create(networkId, 6, "a3:bd01::/48");
+ assertNotNull(subnet2);
+
+ assertTrue(subnetApi.delete(subnet.getId()));
+ assertTrue(subnetApi.delete(subnet2.getId()));
+ assertTrue(networkApi.delete(networkId));
+ }
+ }
+
+ public void testBulkCreateSubnet() {
+ for (String zone : api.getConfiguredZones()) {
+ NetworkApi networkApi = api.getNetworkApiForZone(zone);
+ String networkId = networkApi.create(CreateNetworkOptions.builder().name("jclouds-live-test").networkType(NetworkType.LOCAL).build()).getId();
+
+ SubnetApi subnetApi = api.getSubnetApiForZone(zone);
+ Set<? extends Subnet> subnets = subnetApi.createBulk(
+ CreateSubnetBulkOptions.builder().subnets(
+ ImmutableList.of(
+ BulkSubnet.builder().name("jclouds-live-test-1").cidr("a3:bd01::/48").ipVersion(6).networkId(networkId).build(),
+ BulkSubnet.builder().name("jclouds-live-test-2").cidr("a3:bd02::/48").ipVersion(6).networkId(networkId).build(),
+ BulkSubnet.builder().name("jclouds-live-test-3").cidr("a3:bd03::/48").ipVersion(6).networkId(networkId).build()
+ )
+ ).build()
+ ).toSet();
+ Set<? extends Subnet> existingSubnets = subnetApi.listInDetail().concat().toSet();
+
+ assertNotNull(subnets);
+ assertTrue(!subnets.isEmpty());
+ assertEquals(subnets.size(), 3);
+
+ for (Subnet net : subnets) {
+ Predicate<Subnet> idEqualsPredicate = PredicateUtil.createIdEqualsPredicate(net.getId());
+ assertEquals(1, Sets.filter(existingSubnets, idEqualsPredicate).size());
+ assertTrue(subnetApi.delete(net.getId()));
+ }
+ assertTrue(networkApi.delete(networkId));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiExpectTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiExpectTest.java
new file mode 100644
index 0000000..ff9ffa7
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiExpectTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.internal;
+
+import com.google.common.collect.ImmutableSet;
+import org.jclouds.openstack.neutron.v2_0.NeutronApi;
+import org.jclouds.openstack.neutron.v2_0.domain.Reference;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+
+import java.util.Set;
+
+/**
+ * Base class for writing Neutron Rest Api Expect tests
+ */
+public class BaseNeutronApiExpectTest extends BaseNeutronExpectTest<NeutronApi> {
+
+ protected Set<Reference> listOfReferences() {
+ return ImmutableSet.of(
+ Reference.builder().tenantId("1234567890").id("16dba3bc-f3fa-4775-afdc-237e12c72f6a").build(),
+ Reference.builder().tenantId("1234567890").id("1a104cf5-cb18-4d35-9407-2fd2646d9d0b").build(),
+ Reference.builder().tenantId("1234567890").id("31083ae2-420d-48b2-ac98-9f7a4fd8dbdc").build(),
+ Reference.builder().tenantId("1234567890").id("49c6d6fa-ff2a-459d-b975-75a8d31c9a89").build(),
+ Reference.builder().tenantId("1234567890").id("5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e").build(),
+ Reference.builder().tenantId("1234567890").id("5d51d012-3491-4db7-b1b5-6f254015015d").build(),
+ Reference.builder().tenantId("1234567890").id("5f9cf7dc-22ca-4097-8e49-1cc8b23faf17").build(),
+ Reference.builder().tenantId("1234567890").id("6319ecad-6bff-48b2-9b53-02ede8cb7588").build(),
+ Reference.builder().tenantId("1234567890").id("6ba4c788-661f-49ab-9bf8-5f10cbbb2f57").build(),
+ Reference.builder().tenantId("1234567890").id("74ed170b-5069-4353-ab38-9719766dc57e").build(),
+ Reference.builder().tenantId("1234567890").id("b71fcac1-e864-4031-8c5b-edbecd9ece36").build(),
+ Reference.builder().tenantId("1234567890").id("c7681895-d84d-4650-9ca0-82c72036b855").build()
+ );
+ }
+
+ protected Set<ReferenceWithName> listOfReferencesWithNames() {
+ return ImmutableSet.of(
+ ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("16dba3bc-f3fa-4775-afdc-237e12c72f6a").build(),
+ ReferenceWithName.builder().name("wibble").tenantId("1234567890").id("1a104cf5-cb18-4d35-9407-2fd2646d9d0b").build(),
+ ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("31083ae2-420d-48b2-ac98-9f7a4fd8dbdc").build(),
+ ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("49c6d6fa-ff2a-459d-b975-75a8d31c9a89").build(),
+ ReferenceWithName.builder().name("wibble").tenantId("1234567890").id("5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e").build(),
+ ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("5d51d012-3491-4db7-b1b5-6f254015015d").build(),
+ ReferenceWithName.builder().name("wibble").tenantId("1234567890").id("5f9cf7dc-22ca-4097-8e49-1cc8b23faf17").build(),
+ ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("6319ecad-6bff-48b2-9b53-02ede8cb7588").build(),
+ ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("6ba4c788-661f-49ab-9bf8-5f10cbbb2f57").build(),
+ ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("74ed170b-5069-4353-ab38-9719766dc57e").build(),
+ ReferenceWithName.builder().name("wibble").tenantId("1234567890").id("b71fcac1-e864-4031-8c5b-edbecd9ece36").build(),
+ ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("c7681895-d84d-4650-9ca0-82c72036b855").build()
+ );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiLiveTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiLiveTest.java
new file mode 100644
index 0000000..de5755e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiLiveTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.internal;
+
+import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
+import org.jclouds.openstack.neutron.v2_0.NeutronApi;
+import org.testng.annotations.Test;
+
+import java.util.Properties;
+
+/**
+ * Tests behavior of {@code NeutronApi}
+ */
+@Test(groups = "live")
+public class BaseNeutronApiLiveTest extends BaseApiLiveTest<NeutronApi> {
+
+ public BaseNeutronApiLiveTest() {
+ provider = "openstack-neutron-legacy";
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties props = super.setupProperties();
+ setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
+ return props;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronExpectTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronExpectTest.java
new file mode 100644
index 0000000..d8c024c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronExpectTest.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.internal;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture;
+import org.jclouds.rest.internal.BaseRestApiExpectTest;
+
+import javax.ws.rs.core.MediaType;
+
+/**
+ * Base class for writing Neutron Expect tests
+ */
+public class BaseNeutronExpectTest<T> extends BaseRestApiExpectTest<T> {
+ protected HttpRequest keystoneAuthWithUsernameAndPassword;
+ protected HttpRequest keystoneAuthWithUsernameAndPasswordAndTenantName;
+ protected HttpRequest keystoneAuthWithAccessKeyAndSecretKeyAndTenantName;
+ protected String authToken;
+ protected HttpResponse responseWithKeystoneAccess;
+ protected HttpRequest keystoneAuthWithAccessKeyAndSecretKeyAndTenantId;
+ protected String identityWithTenantId;
+ protected String endpoint = "https://csnode.jclouds.org:9696/v2.0";
+
+ public BaseNeutronExpectTest() {
+ provider = "openstack-neutron-legacy";
+ keystoneAuthWithUsernameAndPassword = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPassword(identity,
+ credential);
+ keystoneAuthWithUsernameAndPasswordAndTenantName = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPasswordAndTenantName(identity,
+ credential);
+ keystoneAuthWithAccessKeyAndSecretKeyAndTenantName = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKeyAndTenantName(identity,
+ credential);
+ keystoneAuthWithAccessKeyAndSecretKeyAndTenantId = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKeyAndTenantId(identity,
+ credential);
+
+ authToken = KeystoneFixture.INSTANCE.getAuthToken();
+ responseWithKeystoneAccess = KeystoneFixture.INSTANCE.responseWithAccess();
+ // now, createContext arg will need tenant prefix
+ identityWithTenantId = KeystoneFixture.INSTANCE.getTenantId() + ":" + identity;
+ identity = KeystoneFixture.INSTANCE.getTenantName() + ":" + identity;
+ }
+
+ protected HttpRequest.Builder<?> authenticatedGET() {
+ return HttpRequest.builder()
+ .method("GET")
+ .addHeader("Accept", MediaType.APPLICATION_JSON)
+ .addHeader("X-Auth-Token", authToken);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseNetworkTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseNetworkTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseNetworkTest.java
new file mode 100644
index 0000000..9509ba3
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseNetworkTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.parse;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.openstack.neutron.v2_0.domain.Network;
+import org.jclouds.openstack.neutron.v2_0.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2_0.domain.State;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+@Test(groups = "unit", testName = "ParseNetworkTest")
+public class ParseNetworkTest extends BaseItemParserTest<Network> {
+
+ @Override
+ public String resource() {
+ return "/network.json";
+ }
+
+ @Override
+ @SelectJson("network")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Network expected() {
+ return Network.builder()
+ .networkType(NetworkType.LOCAL)
+ .state(State.ACTIVE)
+ .name("jclouds-wibble")
+ .tenantId("1234567890")
+ .id("624312ff-d14b-4ba3-9834-1c78d23d574d")
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParsePortTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParsePortTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParsePortTest.java
new file mode 100644
index 0000000..b029299
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParsePortTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.parse;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.openstack.neutron.v2_0.domain.Port;
+import org.jclouds.openstack.neutron.v2_0.domain.State;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+@Test(groups = "unit", testName = "ParsePortTest")
+public class ParsePortTest extends BaseItemParserTest<Port> {
+
+ @Override
+ public String resource() {
+ return "/port.json";
+ }
+
+ @Override
+ @SelectJson("port")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Port expected() {
+ return Port.builder()
+ .state(State.ACTIVE)
+ .networkId("1234567890")
+ .name("jclouds-wibble")
+ .tenantId("1234567890")
+ .id("624312ff-d14b-4ba3-9834-1c78d23d574d")
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseRouterTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseRouterTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseRouterTest.java
new file mode 100644
index 0000000..1787129
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseRouterTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.parse;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.openstack.neutron.v2_0.domain.ExternalGatewayInfo;
+import org.jclouds.openstack.neutron.v2_0.domain.Router;
+import org.jclouds.openstack.neutron.v2_0.domain.State;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+@Test(groups = "unit", testName = "ParseRouterTest")
+public class ParseRouterTest extends BaseItemParserTest<Router> {
+
+ @Override
+ public String resource() {
+ return "/router.json";
+ }
+
+ @Override
+ @SelectJson("router")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Router expected() {
+ return Router.builder()
+ .externalGatewayInfo(ExternalGatewayInfo.builder().networkId("624312ff-d14b-4ba3-9834-1c78d23d574d").build())
+ .state(State.ACTIVE)
+ .name("jclouds-wibble")
+ .tenantId("1234567890")
+ .id("16dba3bc-f3fa-4775-afdc-237e12c72f6a")
+ .build();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseSubnetTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseSubnetTest.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseSubnetTest.java
new file mode 100644
index 0000000..afe84b4
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseSubnetTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.parse;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.openstack.neutron.v2_0.domain.Subnet;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+@Test(groups = "unit", testName = "ParseSubnetTest")
+public class ParseSubnetTest extends BaseItemParserTest<Subnet> {
+
+ @Override
+ public String resource() {
+ return "/subnet.json";
+ }
+
+ @Override
+ @SelectJson("subnet")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Subnet expected() {
+ return Subnet.builder()
+ .ipVersion(4)
+ .cidr("10.0.3.0/24")
+ .networkId("1234567890")
+ .name("jclouds-wibble")
+ .tenantId("1234567890")
+ .id("624312ff-d14b-4ba3-9834-1c78d23d574d")
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/util/ClassUtil.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/util/ClassUtil.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/util/ClassUtil.java
new file mode 100644
index 0000000..1797fb3
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/util/ClassUtil.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.util;
+
+import java.lang.reflect.Field;
+
+public class ClassUtil {
+
+ public static Field findField(Class clazz, String fieldName) {
+ Field fieldToFind = null;
+ if (clazz.getSuperclass() != null)
+ fieldToFind = findField(clazz.getSuperclass(), fieldName);
+
+ if (fieldToFind != null)
+ return fieldToFind;
+
+ for (Field field : clazz.getDeclaredFields()) {
+ if (field.getName().equals(fieldName))
+ return field;
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/util/PredicateUtil.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/util/PredicateUtil.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/util/PredicateUtil.java
new file mode 100644
index 0000000..95ede8f
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/java/org/jclouds/openstack/neutron/v2_0/util/PredicateUtil.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.util;
+
+import com.google.common.base.Predicate;
+import org.jclouds.javax.annotation.Nullable;
+
+import java.lang.reflect.Field;
+
+public class PredicateUtil {
+
+ public static <T> Predicate<T> createIdEqualsPredicate(final String id) {
+ return new Predicate<T>() {
+ @Override
+ public boolean apply(@Nullable T input) {
+ if (input == null) return false;
+
+ try {
+ Class clazz = input.getClass();
+ Field field = ClassUtil.findField(clazz, "id");
+ field.setAccessible(true);
+ String value = (String) field.get(input);
+ field.setAccessible(false);
+ return value != null && value.equals(id);
+ } catch (IllegalAccessException iae) {
+ return false;
+ }
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/access.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/access.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/access.json
new file mode 100644
index 0000000..fab1645
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/access.json
@@ -0,0 +1,228 @@
+{
+ "access": {
+ "metadata": {
+ "roles": [
+ "9fe2ff9ee4384b1894a90878d3e92bab",
+ "b926cb0f4e2642678735f86c2b06205e",
+ "33484487e73d4da0918a19b9c7e1f8ae",
+ "f2e54c2105fb49e29479af047115cebc"
+ ],
+ "is_admin": 0
+ },
+ "user": {
+ "name": "joe",
+ "roles": [
+ {
+ "name": "_member_"
+ },
+ {
+ "name": "anotherrole"
+ },
+ {
+ "name": "heat_stack_owner"
+ },
+ {
+ "name": "Member"
+ }
+ ],
+ "id": "8fbf8e68d36e4ac7bcf912a26213bd49",
+ "roles_links": [],
+ "username": "joe"
+ },
+ "serviceCatalog": [
+ {
+ "name": "nova",
+ "type": "compute",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL/v2/da0d12be20394afb851716e10a49e4a7",
+ "id": "2122bcaa704343c19ad2578410d4961d",
+ "internalURL": "URL/v2/da0d12be20394afb851716e10a49e4a7",
+ "region": "RegionOne",
+ "adminURL": "URL/v2/da0d12be20394afb851716e10a49e4a7"
+ }
+ ]
+ },
+ {
+ "name": "neutron",
+ "type": "network",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL/",
+ "id": "65a4d3f13cfb49a6a57a04e205cc2158",
+ "internalURL": "URL/",
+ "region": "RegionOne",
+ "adminURL": "URL/"
+ }
+ ]
+ },
+ {
+ "name": "cinderv2",
+ "type": "volumev2",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL/v2/da0d12be20394afb851716e10a49e4a7",
+ "id": "31fe4d92eac44044b05be21c6f44cebc",
+ "internalURL": "URL/v2/da0d12be20394afb851716e10a49e4a7",
+ "region": "RegionOne",
+ "adminURL": "URL/v2/da0d12be20394afb851716e10a49e4a7"
+ }
+ ]
+ },
+ {
+ "name": "trove",
+ "type": "database",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL/v1.0/da0d12be20394afb851716e10a49e4a7",
+ "id": "06b7a7dbd25c4a01819c879700a9712a",
+ "internalURL": "URL/v1.0/da0d12be20394afb851716e10a49e4a7",
+ "region": "RegionOne",
+ "adminURL": "URL/v1.0/da0d12be20394afb851716e10a49e4a7"
+ }
+ ]
+ },
+ {
+ "name": "s3",
+ "type": "s3",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL",
+ "id": "93b0b67091324e8ba01b62ee0584994c",
+ "internalURL": "URL",
+ "region": "RegionOne",
+ "adminURL": "URL"
+ }
+ ]
+ },
+ {
+ "name": "glance",
+ "type": "image",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL",
+ "id": "a542e91bcfa046bfa1bf2397356d1414",
+ "internalURL": "URL",
+ "region": "RegionOne",
+ "adminURL": "URL"
+ }
+ ]
+ },
+ {
+ "name": "novav3",
+ "type": "computev3",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL/v3",
+ "id": "9c3e8abb576d483db93bcef70c67bc1d",
+ "internalURL": "URL/v3",
+ "region": "RegionOne",
+ "adminURL": "URL/v3"
+ }
+ ]
+ },
+ {
+ "name": "heat",
+ "type": "cloudformation",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL/v1",
+ "id": "6f4ca5ca9698425b85c300b3fc176c39",
+ "internalURL": "URL/v1",
+ "region": "RegionOne",
+ "adminURL": "URL/v1"
+ }
+ ]
+ },
+ {
+ "name": "cinder",
+ "type": "volume",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL/v1/da0d12be20394afb851716e10a49e4a7",
+ "id": "037039c676694a35aa28d34fce09e51d",
+ "internalURL": "URL/v1/da0d12be20394afb851716e10a49e4a7",
+ "region": "RegionOne",
+ "adminURL": "URL/v1/da0d12be20394afb851716e10a49e4a7"
+ }
+ ]
+ },
+ {
+ "name": "ec2",
+ "type": "ec2",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL/services/Cloud",
+ "id": "1d242631bccb4ff4ba7a395dbcb51648",
+ "internalURL": "URL/services/Cloud",
+ "region": "RegionOne",
+ "adminURL": "URL/services/Admin"
+ }
+ ]
+ },
+ {
+ "name": "heat",
+ "type": "orchestration",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL/v1/da0d12be20394afb851716e10a49e4a7",
+ "id": "199d00075e4a40308a6ad2aa8980d0cd",
+ "internalURL": "URL/v1/da0d12be20394afb851716e10a49e4a7",
+ "region": "RegionOne",
+ "adminURL": "URL/v1/da0d12be20394afb851716e10a49e4a7"
+ }
+ ]
+ },
+ {
+ "name": "swift",
+ "type": "object-store",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL/v1/AUTH_da0d12be20394afb851716e10a49e4a7",
+ "id": "26b2cb1efb044193b847fc3f2fb12e82",
+ "internalURL": "URL/v1/AUTH_da0d12be20394afb851716e10a49e4a7",
+ "region": "RegionOne",
+ "adminURL": "URL"
+ }
+ ]
+ },
+ {
+ "name": "keystone",
+ "type": "identity",
+ "endpoints_links": [],
+ "endpoints": [
+ {
+ "publicURL": "URL/v2.0",
+ "id": "1bbfe80b50df4c4a84040aa782e42140",
+ "internalURL": "URL/v2.0",
+ "region": "RegionOne",
+ "adminURL": "URL/v2.0"
+ }
+ ]
+ }
+ ],
+ "token": {
+ "tenant": {
+ "name": "jclouds",
+ "id": "da0d12be20394afb851716e10a49e4a7",
+ "enabled": true,
+ "description": null
+ },
+ "id": "TOKEN",
+ "expires": "2014-04-28T22:48:24Z",
+ "issued_at": "2014-04-28T21:48:24.972896"
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_details.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_details.json
new file mode 100644
index 0000000..9e10fef
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_details.json
@@ -0,0 +1,10 @@
+{
+ "extension": {
+ "name": "Neutron L3 Router",
+ "namespace": "http://docs.openstack.org/ext/neutron/router/api/v1.0",
+ "alias": "router",
+ "updated": "2012-07-20T10:00:00-00:00",
+ "description": "Router abstraction for basic L3 forwarding between L2 Neutron networks and access to external networks via a NAT gateway.",
+ "links": []
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_list.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_list.json
new file mode 100644
index 0000000..9f85e1e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_list.json
@@ -0,0 +1,140 @@
+{
+ "extensions": [
+ {
+ "updated": "2013-01-20T00:00:00-00:00",
+ "name": "Neutron Service Type Management",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
+ "alias": "service-type",
+ "description": "API for retrieving service providers for Neutron advanced services"
+ },
+ {
+ "updated": "2012-10-05T10:00:00-00:00",
+ "name": "security-group",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/securitygroups/api/v2.0",
+ "alias": "security-group",
+ "description": "The security groups extension."
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "L3 Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/l3_agent_scheduler/api/v1.0",
+ "alias": "l3_agent_scheduler",
+ "description": "Schedule routers among l3 agents"
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "Loadbalancer Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/lbaas_agent_scheduler/api/v1.0",
+ "alias": "lbaas_agent_scheduler",
+ "description": "Schedule pools among lbaas agents"
+ },
+ {
+ "updated": "2013-03-28T10:00:00-00:00",
+ "name": "Neutron L3 Configurable external gateway mode",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/ext-gw-mode/api/v1.0",
+ "alias": "ext-gw-mode",
+ "description": "Extension of the router abstraction for specifying whether SNAT should occur on the external gateway"
+ },
+ {
+ "updated": "2014-02-03T10:00:00-00:00",
+ "name": "Port Binding",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/binding/api/v1.0",
+ "alias": "binding",
+ "description": "Expose port bindings of a virtual port to external application"
+ },
+ {
+ "updated": "2012-09-07T10:00:00-00:00",
+ "name": "Provider Network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/provider/api/v1.0",
+ "alias": "provider",
+ "description": "Expose mapping of virtual networks to physical networks"
+ },
+ {
+ "updated": "2013-02-03T10:00:00-00:00",
+ "name": "agent",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/agent/api/v2.0",
+ "alias": "agent",
+ "description": "The agent management extension."
+ },
+ {
+ "updated": "2012-07-29T10:00:00-00:00",
+ "name": "Quota management support",
+ "links": [],
+ "namespace": "http://docs.openstack.org/network/ext/quotas-sets/api/v2.0",
+ "alias": "quotas",
+ "description": "Expose functions for quotas management per tenant"
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "DHCP Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/dhcp_agent_scheduler/api/v1.0",
+ "alias": "dhcp_agent_scheduler",
+ "description": "Schedule networks among dhcp agents"
+ },
+ {
+ "updated": "2013-06-27T10:00:00-00:00",
+ "name": "Multi Provider Network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/multi-provider/api/v1.0",
+ "alias": "multi-provider",
+ "description": "Expose mapping of virtual networks to multiple physical networks"
+ },
+ {
+ "updated": "2013-01-14T10:00:00-00:00",
+ "name": "Neutron external network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/external_net/api/v1.0",
+ "alias": "external-net",
+ "description": "Adds external network attribute to network resource."
+ },
+ {
+ "updated": "2012-07-20T10:00:00-00:00",
+ "name": "Neutron L3 Router",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/router/api/v1.0",
+ "alias": "router",
+ "description": "Router abstraction for basic L3 forwarding between L2 Neutron networks and access to external networks via a NAT gateway."
+ },
+ {
+ "updated": "2013-07-23T10:00:00-00:00",
+ "name": "Allowed Address Pairs",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/allowedaddresspairs/api/v2.0",
+ "alias": "allowed-address-pairs",
+ "description": "Provides allowed address pairs"
+ },
+ {
+ "updated": "2013-03-17T12:00:00-00:00",
+ "name": "Neutron Extra DHCP opts",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/extra_dhcp_opt/api/v1.0",
+ "alias": "extra_dhcp_opt",
+ "description": "Extra options configuration for DHCP. For example PXE boot options to DHCP clients can be specified (e.g. tftp-server, server-ip-address, bootfile-name)"
+ },
+ {
+ "updated": "2012-10-07T10:00:00-00:00",
+ "name": "LoadBalancing service",
+ "links": [],
+ "namespace": "http://wiki.openstack.org/neutron/LBaaS/API_1.0",
+ "alias": "lbaas",
+ "description": "Extension for LoadBalancing service"
+ },
+ {
+ "updated": "2013-02-01T10:00:00-00:00",
+ "name": "Neutron Extra Route",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/extraroutes/api/v1.0",
+ "alias": "extraroute",
+ "description": "Extra routes configuration for L3 router"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_list_with_lbaas_v1_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_list_with_lbaas_v1_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_list_with_lbaas_v1_response.json
new file mode 100644
index 0000000..9f85e1e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_list_with_lbaas_v1_response.json
@@ -0,0 +1,140 @@
+{
+ "extensions": [
+ {
+ "updated": "2013-01-20T00:00:00-00:00",
+ "name": "Neutron Service Type Management",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
+ "alias": "service-type",
+ "description": "API for retrieving service providers for Neutron advanced services"
+ },
+ {
+ "updated": "2012-10-05T10:00:00-00:00",
+ "name": "security-group",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/securitygroups/api/v2.0",
+ "alias": "security-group",
+ "description": "The security groups extension."
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "L3 Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/l3_agent_scheduler/api/v1.0",
+ "alias": "l3_agent_scheduler",
+ "description": "Schedule routers among l3 agents"
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "Loadbalancer Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/lbaas_agent_scheduler/api/v1.0",
+ "alias": "lbaas_agent_scheduler",
+ "description": "Schedule pools among lbaas agents"
+ },
+ {
+ "updated": "2013-03-28T10:00:00-00:00",
+ "name": "Neutron L3 Configurable external gateway mode",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/ext-gw-mode/api/v1.0",
+ "alias": "ext-gw-mode",
+ "description": "Extension of the router abstraction for specifying whether SNAT should occur on the external gateway"
+ },
+ {
+ "updated": "2014-02-03T10:00:00-00:00",
+ "name": "Port Binding",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/binding/api/v1.0",
+ "alias": "binding",
+ "description": "Expose port bindings of a virtual port to external application"
+ },
+ {
+ "updated": "2012-09-07T10:00:00-00:00",
+ "name": "Provider Network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/provider/api/v1.0",
+ "alias": "provider",
+ "description": "Expose mapping of virtual networks to physical networks"
+ },
+ {
+ "updated": "2013-02-03T10:00:00-00:00",
+ "name": "agent",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/agent/api/v2.0",
+ "alias": "agent",
+ "description": "The agent management extension."
+ },
+ {
+ "updated": "2012-07-29T10:00:00-00:00",
+ "name": "Quota management support",
+ "links": [],
+ "namespace": "http://docs.openstack.org/network/ext/quotas-sets/api/v2.0",
+ "alias": "quotas",
+ "description": "Expose functions for quotas management per tenant"
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "DHCP Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/dhcp_agent_scheduler/api/v1.0",
+ "alias": "dhcp_agent_scheduler",
+ "description": "Schedule networks among dhcp agents"
+ },
+ {
+ "updated": "2013-06-27T10:00:00-00:00",
+ "name": "Multi Provider Network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/multi-provider/api/v1.0",
+ "alias": "multi-provider",
+ "description": "Expose mapping of virtual networks to multiple physical networks"
+ },
+ {
+ "updated": "2013-01-14T10:00:00-00:00",
+ "name": "Neutron external network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/external_net/api/v1.0",
+ "alias": "external-net",
+ "description": "Adds external network attribute to network resource."
+ },
+ {
+ "updated": "2012-07-20T10:00:00-00:00",
+ "name": "Neutron L3 Router",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/router/api/v1.0",
+ "alias": "router",
+ "description": "Router abstraction for basic L3 forwarding between L2 Neutron networks and access to external networks via a NAT gateway."
+ },
+ {
+ "updated": "2013-07-23T10:00:00-00:00",
+ "name": "Allowed Address Pairs",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/allowedaddresspairs/api/v2.0",
+ "alias": "allowed-address-pairs",
+ "description": "Provides allowed address pairs"
+ },
+ {
+ "updated": "2013-03-17T12:00:00-00:00",
+ "name": "Neutron Extra DHCP opts",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/extra_dhcp_opt/api/v1.0",
+ "alias": "extra_dhcp_opt",
+ "description": "Extra options configuration for DHCP. For example PXE boot options to DHCP clients can be specified (e.g. tftp-server, server-ip-address, bootfile-name)"
+ },
+ {
+ "updated": "2012-10-07T10:00:00-00:00",
+ "name": "LoadBalancing service",
+ "links": [],
+ "namespace": "http://wiki.openstack.org/neutron/LBaaS/API_1.0",
+ "alias": "lbaas",
+ "description": "Extension for LoadBalancing service"
+ },
+ {
+ "updated": "2013-02-01T10:00:00-00:00",
+ "name": "Neutron Extra Route",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/extraroutes/api/v1.0",
+ "alias": "extraroute",
+ "description": "Extra routes configuration for L3 router"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_list_without_lbaas_v1_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_list_without_lbaas_v1_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_list_without_lbaas_v1_response.json
new file mode 100644
index 0000000..7f4a7c1
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/extension_list_without_lbaas_v1_response.json
@@ -0,0 +1,132 @@
+{
+ "extensions": [
+ {
+ "updated": "2013-01-20T00:00:00-00:00",
+ "name": "Neutron Service Type Management",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
+ "alias": "service-type",
+ "description": "API for retrieving service providers for Neutron advanced services"
+ },
+ {
+ "updated": "2012-10-05T10:00:00-00:00",
+ "name": "security-group",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/securitygroups/api/v2.0",
+ "alias": "security-group",
+ "description": "The security groups extension."
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "L3 Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/l3_agent_scheduler/api/v1.0",
+ "alias": "l3_agent_scheduler",
+ "description": "Schedule routers among l3 agents"
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "Loadbalancer Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/lbaas_agent_scheduler/api/v1.0",
+ "alias": "lbaas_agent_scheduler",
+ "description": "Schedule pools among lbaas agents"
+ },
+ {
+ "updated": "2013-03-28T10:00:00-00:00",
+ "name": "Neutron L3 Configurable external gateway mode",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/ext-gw-mode/api/v1.0",
+ "alias": "ext-gw-mode",
+ "description": "Extension of the router abstraction for specifying whether SNAT should occur on the external gateway"
+ },
+ {
+ "updated": "2014-02-03T10:00:00-00:00",
+ "name": "Port Binding",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/binding/api/v1.0",
+ "alias": "binding",
+ "description": "Expose port bindings of a virtual port to external application"
+ },
+ {
+ "updated": "2012-09-07T10:00:00-00:00",
+ "name": "Provider Network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/provider/api/v1.0",
+ "alias": "provider",
+ "description": "Expose mapping of virtual networks to physical networks"
+ },
+ {
+ "updated": "2013-02-03T10:00:00-00:00",
+ "name": "agent",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/agent/api/v2.0",
+ "alias": "agent",
+ "description": "The agent management extension."
+ },
+ {
+ "updated": "2012-07-29T10:00:00-00:00",
+ "name": "Quota management support",
+ "links": [],
+ "namespace": "http://docs.openstack.org/network/ext/quotas-sets/api/v2.0",
+ "alias": "quotas",
+ "description": "Expose functions for quotas management per tenant"
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "DHCP Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/dhcp_agent_scheduler/api/v1.0",
+ "alias": "dhcp_agent_scheduler",
+ "description": "Schedule networks among dhcp agents"
+ },
+ {
+ "updated": "2013-06-27T10:00:00-00:00",
+ "name": "Multi Provider Network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/multi-provider/api/v1.0",
+ "alias": "multi-provider",
+ "description": "Expose mapping of virtual networks to multiple physical networks"
+ },
+ {
+ "updated": "2013-01-14T10:00:00-00:00",
+ "name": "Neutron external network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/external_net/api/v1.0",
+ "alias": "external-net",
+ "description": "Adds external network attribute to network resource."
+ },
+ {
+ "updated": "2012-07-20T10:00:00-00:00",
+ "name": "Neutron L3 Router",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/router/api/v1.0",
+ "alias": "router",
+ "description": "Router abstraction for basic L3 forwarding between L2 Neutron networks and access to external networks via a NAT gateway."
+ },
+ {
+ "updated": "2013-07-23T10:00:00-00:00",
+ "name": "Allowed Address Pairs",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/allowedaddresspairs/api/v2.0",
+ "alias": "allowed-address-pairs",
+ "description": "Provides allowed address pairs"
+ },
+ {
+ "updated": "2013-03-17T12:00:00-00:00",
+ "name": "Neutron Extra DHCP opts",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/extra_dhcp_opt/api/v1.0",
+ "alias": "extra_dhcp_opt",
+ "description": "Extra options configuration for DHCP. For example PXE boot options to DHCP clients can be specified (e.g. tftp-server, server-ip-address, bootfile-name)"
+ },
+ {
+ "updated": "2013-02-01T10:00:00-00:00",
+ "name": "Neutron Extra Route",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/extraroutes/api/v1.0",
+ "alias": "extraroute",
+ "description": "Extra routes configuration for L3 router"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_create_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_create_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_create_request.json
new file mode 100644
index 0000000..72ed72f
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_create_request.json
@@ -0,0 +1,6 @@
+{
+ "floatingip": {
+ "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",
+ "port_id": "ce705c24-c1ef-408a-bda3-7bbd946164ab"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_create_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_create_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_create_response.json
new file mode 100644
index 0000000..4dbb82c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_create_response.json
@@ -0,0 +1,11 @@
+{
+ "floatingip": {
+ "router_id": "d23abc8d-2991-4a55-ba98-2aaea84cc72f",
+ "tenant_id": "4969c491a3c74ee4af974e6d800c62de",
+ "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",
+ "fixed_ip_address": "10.0.0.3",
+ "floating_ip_address": "172.24.4.228",
+ "port_id": "ce705c24-c1ef-408a-bda3-7bbd946164ab",
+ "id": "2f245a7b-796b-4f26-9cf9-9e82d248fda7"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_get_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_get_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_get_response.json
new file mode 100644
index 0000000..4dbb82c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_get_response.json
@@ -0,0 +1,11 @@
+{
+ "floatingip": {
+ "router_id": "d23abc8d-2991-4a55-ba98-2aaea84cc72f",
+ "tenant_id": "4969c491a3c74ee4af974e6d800c62de",
+ "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",
+ "fixed_ip_address": "10.0.0.3",
+ "floating_ip_address": "172.24.4.228",
+ "port_id": "ce705c24-c1ef-408a-bda3-7bbd946164ab",
+ "id": "2f245a7b-796b-4f26-9cf9-9e82d248fda7"
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_list_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_list_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_list_response.json
new file mode 100644
index 0000000..6b41bf9
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_list_response.json
@@ -0,0 +1,22 @@
+{
+ "floatingips": [
+ {
+ "router_id": "d23abc8d-2991-4a55-ba98-2aaea84cc72f",
+ "tenant_id": "4969c491a3c74ee4af974e6d800c62de",
+ "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",
+ "fixed_ip_address": "10.0.0.3",
+ "floating_ip_address": "172.24.4.228",
+ "port_id": "ce705c24-c1ef-408a-bda3-7bbd946164ab",
+ "id": "2f245a7b-796b-4f26-9cf9-9e82d248fda7"
+ },
+ {
+ "router_id": null,
+ "tenant_id": "4969c491a3c74ee4af974e6d800c62de",
+ "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",
+ "fixed_ip_address": null,
+ "floating_ip_address": "172.24.4.227",
+ "port_id": null,
+ "id": "61cea855-49cb-4846-997d-801b70c71bdd"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_list_response_paged1.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_list_response_paged1.json
new file mode 100644
index 0000000..7b809f8
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_list_response_paged1.json
@@ -0,0 +1,32 @@
+{
+ "floatingips": [
+ {
+ "router_id": "d23abc8d-2991-4a55-ba98-2aaea84cc72f",
+ "tenant_id": "4969c491a3c74ee4af974e6d800c62de",
+ "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",
+ "fixed_ip_address": "10.0.0.3",
+ "floating_ip_address": "172.24.4.228",
+ "port_id": "ce705c24-c1ef-408a-bda3-7bbd946164ab",
+ "id": "2f245a7b-796b-4f26-9cf9-9e82d248fda7"
+ },
+ {
+ "router_id": null,
+ "tenant_id": "4969c491a3c74ee4af974e6d800c62de",
+ "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",
+ "fixed_ip_address": null,
+ "floating_ip_address": "172.24.4.227",
+ "port_id": null,
+ "id": "61cea855-49cb-4846-997d-801b70c71bdd"
+ }
+ ],
+ "floatingips_links": [
+ {
+ "href": "/v2.0/floatingips.json?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718",
+ "rel": "next"
+ },
+ {
+ "href": "/v2.0/floatingips.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_list_response_paged2.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_list_response_paged2.json
new file mode 100644
index 0000000..9ca8cd2
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_list_response_paged2.json
@@ -0,0 +1,28 @@
+{
+ "floatingips": [
+ {
+ "router_id": "d23abc8d-2991-4a55-ba98-2aaea84cc72f2",
+ "tenant_id": "4969c491a3c74ee4af974e6d800c62de2",
+ "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf572",
+ "fixed_ip_address": "10.0.0.3",
+ "floating_ip_address": "172.24.4.228",
+ "port_id": "ce705c24-c1ef-408a-bda3-7bbd946164ab2",
+ "id": "2f245a7b-796b-4f26-9cf9-9e82d248fda72"
+ },
+ {
+ "router_id": null,
+ "tenant_id": "4969c491a3c74ee4af974e6d800c62de2",
+ "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf572",
+ "fixed_ip_address": null,
+ "floating_ip_address": "172.24.4.227",
+ "port_id": null,
+ "id": "61cea855-49cb-4846-997d-801b70c71bdd2"
+ }
+ ],
+ "floatingips_links": [
+ {
+ "href": "/v2.0/floatingips.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_dissociate_request.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_dissociate_request.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_dissociate_request.json
new file mode 100644
index 0000000..a45f500
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_dissociate_request.json
@@ -0,0 +1,5 @@
+{
+ "floatingip": {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_dissociate_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_dissociate_response.json b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_dissociate_response.json
new file mode 100644
index 0000000..5515a22
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/test/resources/floatingip_update_dissociate_response.json
@@ -0,0 +1,11 @@
+{
+ "floatingip": {
+ "router_id": "d23abc8d-2991-4a55-ba98-2aaea84cc72f",
+ "tenant_id": "4969c491a3c74ee4af974e6d800c62de",
+ "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",
+ "fixed_ip_address": null,
+ "floating_ip_address": "172.24.4.228",
+ "port_id": null,
+ "id": "2f245a7b-796b-4f26-9cf9-9e82d248fda7"
+ }
+}
[48/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java
new file mode 100644
index 0000000..8d5a10c
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java
@@ -0,0 +1,342 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.extensions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_INTERVAL;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_TIMEOUT;
+import static org.jclouds.googlecomputeengine.compute.strategy.CreateNodesWithGroupEncodedIntoNameThenAddToSet.DEFAULT_INTERNAL_NETWORK_RANGE;
+import static org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.equalsIpPermission;
+import static org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.providesIpPermission;
+import static org.jclouds.util.Predicates2.retry;
+
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.compute.extensions.SecurityGroupExtension;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.domain.Location;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.SlashEncodedIds;
+import org.jclouds.googlecomputeengine.domain.internal.NetworkAndAddressRange;
+import org.jclouds.googlecomputeengine.options.FirewallOptions;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.googlecomputeengine.options.ListOptions.Builder;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.base.Supplier;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Multimap;
+import com.google.common.util.concurrent.Atomics;
+
+/**
+ * An extension to compute service to allow for the manipulation of {@link org.jclouds.compute.domain.SecurityGroup}s. Implementation
+ * is optional by providers.
+ */
+public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupExtension {
+
+ protected final Supplier<String> userProject;
+ protected final GroupNamingConvention.Factory namingConvention;
+ protected final LoadingCache<NetworkAndAddressRange, Network> networkCreator;
+ protected final Function<Network, SecurityGroup> groupConverter;
+ protected final GoogleComputeEngineApi api;
+ protected final Predicate<AtomicReference<Operation>> operationDonePredicate;
+ protected final long operationCompleteCheckInterval;
+ protected final long operationCompleteCheckTimeout;
+
+ @Inject
+ public GoogleComputeEngineSecurityGroupExtension(GoogleComputeEngineApi api,
+ @UserProject Supplier<String> userProject,
+ GroupNamingConvention.Factory namingConvention,
+ LoadingCache<NetworkAndAddressRange, Network> networkCreator,
+ Function<Network, SecurityGroup> groupConverter,
+ @Named("global") Predicate<AtomicReference<Operation>> operationDonePredicate,
+ @Named(OPERATION_COMPLETE_INTERVAL) Long operationCompleteCheckInterval,
+ @Named(OPERATION_COMPLETE_TIMEOUT) Long operationCompleteCheckTimeout) {
+ this.api = checkNotNull(api, "api");
+ this.userProject = checkNotNull(userProject, "userProject");
+ this.namingConvention = checkNotNull(namingConvention, "namingConvention");
+ this.networkCreator = checkNotNull(networkCreator, "networkCreator");
+ this.groupConverter = checkNotNull(groupConverter, "groupConverter");
+ this.operationCompleteCheckInterval = checkNotNull(operationCompleteCheckInterval,
+ "operation completed check interval");
+ this.operationCompleteCheckTimeout = checkNotNull(operationCompleteCheckTimeout,
+ "operation completed check timeout");
+ this.operationDonePredicate = checkNotNull(operationDonePredicate, "operationDonePredicate");
+ }
+
+ @Override
+ public Set<SecurityGroup> listSecurityGroups() {
+ return api.getNetworkApiForProject(userProject.get()).list().concat().transform(groupConverter).toSet();
+ }
+
+ @Override
+ public Set<SecurityGroup> listSecurityGroupsInLocation(final Location location) {
+ return listSecurityGroups();
+ }
+
+ @Override
+ public Set<SecurityGroup> listSecurityGroupsForNode(String id) {
+ SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(id);
+
+ Instance instance = api.getInstanceApiForProject(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
+ slashEncodedIds.getSecondId());
+
+ if (instance == null) {
+ return ImmutableSet.of();
+ }
+
+ ImmutableSet.Builder builder = ImmutableSet.builder();
+
+
+ for (NetworkInterface nwInterface : instance.getNetworkInterfaces()) {
+ String networkUrl = nwInterface.getNetwork().getPath();
+ Network nw = api.getNetworkApiForProject(userProject.get()).get(networkUrl.substring(networkUrl.lastIndexOf('/') + 1));
+
+ SecurityGroup grp = groupForTagsInNetwork(nw, instance.getTags().getItems());
+ if (grp != null) {
+ builder.add(grp);
+ }
+ }
+
+ return builder.build();
+ }
+
+ @Override
+ public SecurityGroup getSecurityGroupById(String id) {
+ checkNotNull(id, "id");
+ Network network = api.getNetworkApiForProject(userProject.get()).get(id);
+
+ if (network == null) {
+ return null;
+ }
+
+ return groupConverter.apply(network);
+ }
+
+ @Override
+ public SecurityGroup createSecurityGroup(String name, Location location) {
+ return createSecurityGroup(name);
+ }
+
+ public SecurityGroup createSecurityGroup(String name) {
+ checkNotNull(name, "name");
+
+ NetworkAndAddressRange nAr = new NetworkAndAddressRange(name, DEFAULT_INTERNAL_NETWORK_RANGE, null);
+
+ Network nw = networkCreator.apply(nAr);
+
+ return groupConverter.apply(nw);
+ }
+
+ @Override
+ public boolean removeSecurityGroup(String id) {
+ checkNotNull(id, "id");
+ if (api.getNetworkApiForProject(userProject.get()).get(id) == null) {
+ return false;
+ }
+
+ ListOptions options = new ListOptions.Builder().filter("network eq .*/" + id);
+
+ FluentIterable<Firewall> fws = api.getFirewallApiForProject(userProject.get()).list(options).concat();
+
+ for (Firewall fw : fws) {
+ AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApiForProject(userProject.get())
+ .delete(fw.getName()));
+
+ retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
+ MILLISECONDS).apply(operation);
+
+ checkState(!operation.get().getHttpError().isPresent(), "Could not delete firewall, operation failed" + operation);
+ }
+
+ AtomicReference<Operation> operation = Atomics.newReference(
+ api.getNetworkApiForProject(userProject.get()).delete(id));
+
+ retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
+ MILLISECONDS).apply(operation);
+
+ checkState(!operation.get().getHttpError().isPresent(), "Could not create network, operation failed" + operation);
+
+ return true;
+ }
+
+ @Override
+ public SecurityGroup addIpPermission(IpPermission ipPermission, SecurityGroup group) {
+ checkNotNull(group, "group");
+ checkNotNull(ipPermission, "ipPermission");
+
+ checkNotNull(api.getNetworkApiForProject(userProject.get()).get(group.getId()) == null, "network for group is null");
+
+ ListOptions options = new ListOptions.Builder().filter("network eq .*/" + group.getName());
+
+ if (api.getFirewallApiForProject(userProject.get()).list(options).concat().anyMatch(providesIpPermission(ipPermission))) {
+ // Permission already exists.
+ return group;
+ }
+
+ FirewallOptions fwOptions = new FirewallOptions();
+ String uniqueFwName = namingConvention.createWithoutPrefix().uniqueNameForGroup(group.getName());
+ fwOptions.name(uniqueFwName);
+ fwOptions.network(group.getUri());
+ if (!ipPermission.getGroupIds().isEmpty()) {
+ fwOptions.sourceTags(ipPermission.getGroupIds());
+ }
+ if (!ipPermission.getCidrBlocks().isEmpty()) {
+ fwOptions.sourceRanges(ipPermission.getCidrBlocks());
+ }
+ Firewall.Rule.Builder ruleBuilder = Firewall.Rule.builder();
+ ruleBuilder.IpProtocol(ipPermission.getIpProtocol());
+ if (ipPermission.getFromPort() > 0) {
+ if (ipPermission.getFromPort() == ipPermission.getToPort()) {
+ ruleBuilder.addPort(ipPermission.getToPort());
+ } else {
+ ruleBuilder.addPortRange(ipPermission.getFromPort(), ipPermission.getToPort());
+ }
+ }
+ fwOptions.addAllowedRule(ruleBuilder.build());
+
+ AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApiForProject(userProject
+ .get()).createInNetwork(
+ uniqueFwName,
+ group.getUri(),
+ fwOptions));
+
+ retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
+ MILLISECONDS).apply(operation);
+
+ checkState(!operation.get().getHttpError().isPresent(), "Could not create firewall, operation failed" + operation);
+
+ return getSecurityGroupById(group.getId());
+ }
+
+ @Override
+ public SecurityGroup addIpPermission(IpProtocol protocol, int fromPort, int toPort,
+ Multimap<String, String> tenantIdGroupNamePairs, Iterable<String> cidrBlocks,
+ Iterable<String> groupIds, SecurityGroup group) {
+
+ IpPermission.Builder permBuilder = IpPermission.builder();
+ permBuilder.ipProtocol(protocol);
+ permBuilder.fromPort(fromPort);
+ permBuilder.toPort(toPort);
+ permBuilder.groupIds(groupIds);
+ permBuilder.cidrBlocks(cidrBlocks);
+
+ return addIpPermission(permBuilder.build(), group);
+
+ }
+
+ @Override
+ public SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group) {
+ checkNotNull(group, "group");
+ checkNotNull(ipPermission, "ipPermission");
+
+ checkNotNull(api.getNetworkApiForProject(userProject.get()).get(group.getId()) == null, "network for group is null");
+
+ ListOptions options = new ListOptions.Builder().filter("network eq .*/" + group.getName());
+
+ FluentIterable<Firewall> fws = api.getFirewallApiForProject(userProject.get()).list(options).concat();
+
+ for (Firewall fw : fws) {
+ if (equalsIpPermission(ipPermission).apply(fw)) {
+ AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApiForProject(userProject.get())
+ .delete(fw.getName()));
+
+ retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
+ MILLISECONDS).apply(operation);
+
+ checkState(!operation.get().getHttpError().isPresent(), "Could not delete firewall, operation failed" + operation);
+ }
+ }
+
+ return getSecurityGroupById(group.getId());
+ }
+
+ @Override
+ public SecurityGroup removeIpPermission(IpProtocol protocol, int fromPort, int toPort,
+ Multimap<String, String> tenantIdGroupNamePairs, Iterable<String> cidrBlocks,
+ Iterable<String> groupIds, SecurityGroup group) {
+
+ IpPermission.Builder permBuilder = IpPermission.builder();
+ permBuilder.ipProtocol(protocol);
+ permBuilder.fromPort(fromPort);
+ permBuilder.toPort(toPort);
+ permBuilder.groupIds(groupIds);
+ permBuilder.cidrBlocks(cidrBlocks);
+
+ return removeIpPermission(permBuilder.build(), group);
+
+ }
+
+ @Override
+ public boolean supportsTenantIdGroupNamePairs() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsTenantIdGroupIdPairs() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsGroupIds() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsPortRangesForGroups() {
+ return true;
+ }
+
+ private SecurityGroup groupForTagsInNetwork(Network nw, final Set <String> tags) {
+ ListOptions opts = new Builder().filter("network eq .*/" + nw.getName());
+ Set<Firewall> fws = api.getFirewallApiForProject(userProject.get()).list(opts).concat()
+ .filter(new Predicate<Firewall>() {
+ @Override
+ public boolean apply(final Firewall input) {
+ // If any of the targetTags on the firewall apply or the firewall has no target tags...
+ return Iterables.any(input.getTargetTags(), Predicates.in(tags))
+ || Predicates.equalTo(0).apply(input.getTargetTags().size());
+ }
+ }).toSet();
+
+ if (fws.isEmpty()) {
+ return null;
+ }
+
+ return groupConverter.apply(nw);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/BuildInstanceMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/BuildInstanceMetadata.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/BuildInstanceMetadata.java
new file mode 100644
index 0000000..80b18b1
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/BuildInstanceMetadata.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.lang.String.format;
+
+import javax.inject.Singleton;
+
+import org.jclouds.compute.options.TemplateOptions;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Prepares metadata from the provided TemplateOptions
+ */
+@Singleton
+public class BuildInstanceMetadata implements Function<TemplateOptions, ImmutableMap.Builder<String, String>> {
+
+ @Override
+ public ImmutableMap.Builder apply(TemplateOptions input) {
+ ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
+ if (input.getPublicKey() != null) {
+ builder.put("sshKeys", format("%s:%s %s@localhost", checkNotNull(input.getLoginUser(),
+ "loginUser cannot be null"), input.getPublicKey(), input.getLoginUser()));
+ }
+ builder.putAll(input.getUserMetadata());
+ return builder;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/FirewallTagNamingConvention.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/FirewallTagNamingConvention.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/FirewallTagNamingConvention.java
new file mode 100644
index 0000000..1d2508b
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/FirewallTagNamingConvention.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import com.google.common.base.Predicate;
+import org.jclouds.compute.functions.GroupNamingConvention;
+
+import javax.inject.Inject;
+
+/**
+ * The convention for naming instance tags that firewall rules recognise.
+ */
+public class FirewallTagNamingConvention {
+
+ public static class Factory {
+
+ private final GroupNamingConvention.Factory namingConvention;
+
+ @Inject
+ public Factory(GroupNamingConvention.Factory namingConvention) {
+ this.namingConvention = namingConvention;
+ }
+
+ public FirewallTagNamingConvention get(String groupName) {
+ return new FirewallTagNamingConvention(namingConvention.create().sharedNameForGroup(groupName));
+ }
+ }
+
+ private final String sharedResourceName;
+
+ public FirewallTagNamingConvention(String sharedResourceName) {
+ this.sharedResourceName = sharedResourceName;
+ }
+
+ public String name(int port) {
+ return String.format("%s-port-%s", sharedResourceName, port);
+ }
+
+ public Predicate<? super String> isFirewallTag() {
+ return new Predicate<String>() {
+ @Override
+ public boolean apply(String input) {
+ return input != null && input.startsWith(sharedResourceName + "-port-");
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/FirewallToIpPermission.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/FirewallToIpPermission.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/FirewallToIpPermission.java
new file mode 100644
index 0000000..ea069e0
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/FirewallToIpPermission.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import javax.annotation.Resource;
+import javax.inject.Named;
+
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.domain.Firewall.Rule;
+import org.jclouds.logging.Logger;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Range;
+
+/**
+ * A function for transforming a GCE-specific Firewall into a generic
+ * IpPermission object.
+ */
+public class FirewallToIpPermission implements Function<Firewall, Iterable<IpPermission>> {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ public FirewallToIpPermission() {
+ }
+
+
+ @Override
+ public Iterable<IpPermission> apply(Firewall fw) {
+ ImmutableSet.Builder setBuilder = ImmutableSet.builder();
+
+ for (Rule rule : fw.getAllowed()) {
+ if (!rule.getPorts().isEmpty()) {
+ for (Range<Integer> r : rule.getPorts().asRanges()) {
+ IpPermission.Builder builder = populateBuilder(fw, rule.getIpProtocol());
+ builder.fromPort(r.lowerEndpoint());
+ builder.toPort(r.upperEndpoint());
+ setBuilder.add(builder.build());
+ }
+ } else {
+ setBuilder.add(populateBuilder(fw, rule.getIpProtocol()).build());
+ }
+ }
+
+ return setBuilder.build();
+ }
+
+ /**
+ * Convenience method for populating common parts of the IpPermission.
+ * @param fw
+ * @param protocol
+ * @return a pre-populated builder.
+ */
+ private IpPermission.Builder populateBuilder(Firewall fw, IpProtocol protocol) {
+ IpPermission.Builder builder = IpPermission.builder();
+
+ builder.ipProtocol(protocol);
+
+ if (!fw.getSourceRanges().isEmpty()) {
+ builder.cidrBlocks(fw.getSourceRanges());
+ }
+ if (!fw.getSourceTags().isEmpty()) {
+ builder.groupIds(fw.getSourceTags());
+ }
+
+ return builder;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImage.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImage.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImage.java
new file mode 100644
index 0000000..b783fc9
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImage.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import static com.google.common.base.Joiner.on;
+import static com.google.common.collect.Iterables.getLast;
+import static com.google.common.collect.Iterables.limit;
+import static com.google.common.collect.Iterables.skip;
+import static org.jclouds.compute.domain.Image.Status;
+
+import java.util.List;
+
+import org.jclouds.compute.domain.ImageBuilder;
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.googlecomputeengine.domain.Image;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+
+/**
+ * Transforms a google compute domain specific image to a generic Image object.
+ */
+public class GoogleComputeEngineImageToImage implements Function<Image, org.jclouds.compute.domain.Image> {
+
+
+ @Override
+ public org.jclouds.compute.domain.Image apply(Image image) {
+ ImageBuilder builder = new ImageBuilder()
+ .id(image.getName())
+ .name(image.getName())
+ .providerId(image.getId())
+ .description(image.getDescription().orNull())
+ .status(Status.AVAILABLE)
+ .uri(image.getSelfLink());
+
+ List<String> splits = Lists.newArrayList(image.getName().split("-"));
+ OperatingSystem.Builder osBuilder = defaultOperatingSystem(image);
+ if (splits == null || splits.size() == 0 || splits.size() < 3) {
+ return builder.operatingSystem(osBuilder.build()).build();
+ }
+
+ OsFamily family = OsFamily.fromValue(splits.get(0));
+ if (family != OsFamily.UNRECOGNIZED) {
+ osBuilder.family(family);
+ }
+
+ String version = on(".").join(limit(skip(splits, 1), splits.size() - 2));
+ osBuilder.version(version);
+
+ if (image.getDeprecated().isPresent()) {
+ builder.userMetadata(ImmutableMap.of("deprecatedState", image.getDeprecated().get().getState().orNull()));
+ }
+ builder.version(getLast(splits));
+ return builder.operatingSystem(osBuilder.build()).build();
+ }
+
+ private OperatingSystem.Builder defaultOperatingSystem(Image image) {
+ return OperatingSystem.builder()
+ .family(OsFamily.LINUX)
+ .is64Bit(true)
+ .description(image.getName());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadata.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadata.java
new file mode 100644
index 0000000..c1ddea1
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadata.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.compute.util.ComputeServiceUtils.groupFromMapOrName;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GCE_IMAGE_METADATA_KEY;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.domain.Location;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.InstanceInZone;
+import org.jclouds.googlecomputeengine.domain.SlashEncodedIds;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicates;
+import com.google.common.base.Supplier;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Transforms a google compute domain Instance into a generic NodeMetatada object.
+ */
+public class InstanceInZoneToNodeMetadata implements Function<InstanceInZone, NodeMetadata> {
+
+ private final Map<Instance.Status, NodeMetadata.Status> toPortableNodeStatus;
+ private final GroupNamingConvention nodeNamingConvention;
+ private final Supplier<Map<URI, ? extends Image>> images;
+ private final Supplier<Map<URI, ? extends Hardware>> hardwares;
+ private final Supplier<Map<URI, ? extends Location>> locations;
+ private final FirewallTagNamingConvention.Factory firewallTagNamingConvention;
+ private final GoogleComputeEngineApi api;
+ private final Supplier<String> userProject;
+
+ @Inject
+ public InstanceInZoneToNodeMetadata(Map<Instance.Status, NodeMetadata.Status> toPortableNodeStatus,
+ GroupNamingConvention.Factory namingConvention,
+ @Memoized Supplier<Map<URI, ? extends Image>> images,
+ @Memoized Supplier<Map<URI, ? extends Hardware>> hardwares,
+ @Memoized Supplier<Map<URI, ? extends Location>> locations,
+ FirewallTagNamingConvention.Factory firewallTagNamingConvention,
+ GoogleComputeEngineApi api,
+ @UserProject Supplier<String> userProject) {
+ this.toPortableNodeStatus = toPortableNodeStatus;
+ this.nodeNamingConvention = namingConvention.createWithoutPrefix();
+ this.images = images;
+ this.hardwares = hardwares;
+ this.locations = locations;
+ this.firewallTagNamingConvention = checkNotNull(firewallTagNamingConvention, "firewallTagNamingConvention");
+ this.api = checkNotNull(api, "api");
+ this.userProject = checkNotNull(userProject, "userProject");
+ }
+
+ @Override
+ public NodeMetadata apply(InstanceInZone instanceInZone) {
+ Instance input = instanceInZone.getInstance();
+
+ String group = groupFromMapOrName(input.getMetadata().getItems(),
+ input.getName(), nodeNamingConvention);
+ FluentIterable<String> tags = FluentIterable.from(input.getTags().getItems());
+ if (group != null) {
+ tags = tags.filter(Predicates.not(firewallTagNamingConvention.get(group).isFirewallTag()));
+ }
+
+ NodeMetadataBuilder builder = new NodeMetadataBuilder();
+
+ builder.id(SlashEncodedIds.fromTwoIds(checkNotNull(locations.get().get(input.getZone()),
+ "location for %s", input.getZone())
+ .getId(), input.getName()).slashEncode())
+ .name(input.getName())
+ .providerId(input.getId())
+ .hostname(input.getName())
+ .location(checkNotNull(locations.get().get(input.getZone()), "location for %s", input.getZone()))
+ .hardware(hardwares.get().get(input.getMachineType()))
+ .status(toPortableNodeStatus.get(input.getStatus()))
+ .tags(tags)
+ .uri(input.getSelfLink())
+ .userMetadata(input.getMetadata().getItems())
+ .group(group)
+ .privateAddresses(collectPrivateAddresses(input))
+ .publicAddresses(collectPublicAddresses(input));
+
+ if (input.getMetadata().getItems().containsKey(GCE_IMAGE_METADATA_KEY)) {
+ try {
+ URI imageUri = URI.create(input.getMetadata().getItems()
+ .get(GCE_IMAGE_METADATA_KEY));
+
+ Map<URI, ? extends Image> imagesMap = images.get();
+
+ Image image = checkNotNull(imagesMap.get(imageUri),
+ "no image for %s. images: %s", imageUri,
+ imagesMap.values());
+ builder.imageId(image.getId());
+ } catch (IllegalArgumentException e) {
+ // Swallow any exception here - it just means we don't actually have a valid image URI, so we skip it.
+ }
+ }
+
+ return builder.build();
+ }
+
+ private Set<String> collectPrivateAddresses(Instance input) {
+ ImmutableSet.Builder<String> privateAddressesBuilder = ImmutableSet.builder();
+ for (Instance.NetworkInterface networkInterface : input.getNetworkInterfaces()) {
+ if (networkInterface.getNetworkIP().isPresent()) {
+ privateAddressesBuilder.add(networkInterface.getNetworkIP().get());
+ }
+ }
+ return privateAddressesBuilder.build();
+ }
+
+ private Set<String> collectPublicAddresses(Instance input) {
+ ImmutableSet.Builder<String> publicAddressesBuilder = ImmutableSet.builder();
+ for (Instance.NetworkInterface networkInterface : input.getNetworkInterfaces()) {
+ for (Instance.NetworkInterface.AccessConfig accessConfig : networkInterface.getAccessConfigs()) {
+ if (accessConfig.getNatIP().isPresent()) {
+ publicAddressesBuilder.add(accessConfig.getNatIP().get());
+ }
+ }
+ }
+ return publicAddressesBuilder.build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/MachineTypeInZoneToHardware.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/MachineTypeInZoneToHardware.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/MachineTypeInZoneToHardware.java
new file mode 100644
index 0000000..e12a4a3
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/MachineTypeInZoneToHardware.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.getOnlyElement;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.HardwareBuilder;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.Processor;
+import org.jclouds.compute.domain.Volume;
+import org.jclouds.compute.domain.VolumeBuilder;
+import org.jclouds.domain.Location;
+import org.jclouds.googlecomputeengine.domain.MachineType;
+import org.jclouds.googlecomputeengine.domain.MachineTypeInZone;
+import org.jclouds.googlecomputeengine.domain.SlashEncodedIds;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Inject;
+
+/**
+ * Transforms a google compute domain specific machine type to a generic Hardware object.
+ */
+public class MachineTypeInZoneToHardware implements Function<MachineTypeInZone, Hardware> {
+
+ private final Supplier<Map<URI, ? extends Location>> locations;
+
+ @Inject
+ public MachineTypeInZoneToHardware(@Memoized Supplier<Map<URI, ? extends Location>> locations) {
+ this.locations = locations;
+ }
+
+ @Override
+ public Hardware apply(final MachineTypeInZone input) {
+ Iterable<? extends Location> zonesForMachineType = filter(locations.get().values(), new Predicate<Location>() {
+ @Override
+ public boolean apply(Location l) {
+ return l.getId().equals(input.getMachineType().getZone());
+ }
+ });
+
+ Location location = checkNotNull(getOnlyElement(zonesForMachineType),
+ "location for %s",
+ input.getMachineType().getZone());
+
+ return new HardwareBuilder()
+ .id(SlashEncodedIds.fromTwoIds(input.getMachineType().getZone(), input.getMachineType().getName()).slashEncode())
+ .location(location)
+ .name(input.getMachineType().getName())
+ .hypervisor("kvm")
+ .processor(new Processor(input.getMachineType().getGuestCpus(), 1.0))
+ .providerId(input.getMachineType().getId())
+ .ram(input.getMachineType().getMemoryMb())
+ .uri(input.getMachineType().getSelfLink())
+ .volumes(collectVolumes(input.getMachineType()))
+ .supportsImage(Predicates.<Image>alwaysTrue())
+ .build();
+ }
+
+ private Iterable<Volume> collectVolumes(MachineType input) {
+ ImmutableSet.Builder<Volume> volumes = ImmutableSet.builder();
+ for (MachineType.ScratchDisk disk : input.getScratchDisks()) {
+ volumes.add(new VolumeBuilder()
+ .type(Volume.Type.LOCAL)
+ .size(new Integer(disk.getDiskGb()).floatValue())
+ .bootDevice(true)
+ .durable(false).build());
+ }
+ return volumes.build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java
new file mode 100644
index 0000000..1a9be54
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.compute.domain.SecurityGroupBuilder;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.logging.Logger;
+import org.jclouds.net.domain.IpPermission;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A function for transforming a GCE-specific Network into a generic
+ * SecurityGroup object.
+ */
+public class NetworkToSecurityGroup implements Function<Network, SecurityGroup> {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ private final Function<Firewall, Iterable<IpPermission>> firewallToPerms;
+ private final GoogleComputeEngineApi api;
+ private final Supplier<String> project;
+
+ @Inject
+ public NetworkToSecurityGroup(Function<Firewall, Iterable<IpPermission>> firewallToPerms,
+ GoogleComputeEngineApi api,
+ @UserProject Supplier<String> project) {
+ this.firewallToPerms = firewallToPerms;
+ this.api = api;
+ this.project = project;
+ }
+
+ @Override
+ public SecurityGroup apply(Network network) {
+ SecurityGroupBuilder builder = new SecurityGroupBuilder();
+
+ builder.id(network.getName());
+ builder.providerId(network.getId());
+ builder.name(network.getName());
+ builder.uri(network.getSelfLink());
+
+ ImmutableSet.Builder permBuilder = ImmutableSet.builder();
+
+ ListOptions options = new ListOptions.Builder().filter("network eq .*/" + network.getName());
+
+ for (Firewall fw : api.getFirewallApiForProject(project.get()).list(options).concat()) {
+ permBuilder.addAll(firewallToPerms.apply(fw));
+ }
+
+ builder.ipPermissions(permBuilder.build());
+
+ return builder.build();
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodes.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodes.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodes.java
new file mode 100644
index 0000000..3301c8f
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodes.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.domain.NodeMetadata;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Sets;
+
+@Singleton
+public class OrphanedGroupsFromDeadNodes implements Function<Set<? extends NodeMetadata>, Set<String>> {
+
+ private final Predicate<String> isOrphanedGroupPredicate;
+
+ @Inject
+ public OrphanedGroupsFromDeadNodes(Predicate<String> isOrphanedGroupPredicate) {
+ this.isOrphanedGroupPredicate = isOrphanedGroupPredicate;
+ }
+
+
+ @Override
+ public Set<String> apply(Set<? extends NodeMetadata> deadNodes) {
+ Set<String> groups = Sets.newLinkedHashSet();
+ for (NodeMetadata deadNode : deadNodes) {
+ groups.add(deadNode.getGroup());
+ }
+ Set<String> orphanedGroups = Sets.newLinkedHashSet();
+ for (String group : groups) {
+ if (isOrphanedGroupPredicate.apply(group)) {
+ orphanedGroups.add(group);
+ }
+ }
+ return orphanedGroups;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/RegionToLocation.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/RegionToLocation.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/RegionToLocation.java
new file mode 100644
index 0000000..2f880de
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/RegionToLocation.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GOOGLE_PROVIDER_LOCATION;
+
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.googlecomputeengine.domain.Region;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Transforms a google compute domain specific region to a generic Region object.
+ */
+public class RegionToLocation implements Function<Region, Location> {
+
+ @Override
+ public Location apply(Region input) {
+ return new LocationBuilder()
+ .description(input.getDescription().orNull())
+ .metadata(ImmutableMap.of("selfLink", (Object) checkNotNull(input.getSelfLink(), "region URI")))
+ .id(input.getName())
+ .scope(LocationScope.REGION)
+ .parent(GOOGLE_PROVIDER_LOCATION)
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/ZoneToLocation.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/ZoneToLocation.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/ZoneToLocation.java
new file mode 100644
index 0000000..0dc1c78
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/functions/ZoneToLocation.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GOOGLE_PROVIDER_LOCATION;
+
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.googlecomputeengine.domain.Zone;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Transforms a google compute domain specific zone to a generic Zone object.
+ */
+public class ZoneToLocation implements Function<Zone, Location> {
+
+ @Override
+ public Location apply(Zone input) {
+ return new LocationBuilder()
+ .description(input.getDescription().orNull())
+ .metadata(ImmutableMap.of("selfLink", (Object) checkNotNull(input.getSelfLink(), "zone URI")))
+ .id(input.getName())
+ .scope(LocationScope.ZONE)
+ .parent(GOOGLE_PROVIDER_LOCATION)
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/loaders/FindNetworkOrCreate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/loaders/FindNetworkOrCreate.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/loaders/FindNetworkOrCreate.java
new file mode 100644
index 0000000..2c84787
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/loaders/FindNetworkOrCreate.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.loaders;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.domain.internal.NetworkAndAddressRange;
+import org.jclouds.logging.Logger;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.cache.CacheLoader;
+
+public class FindNetworkOrCreate extends CacheLoader<NetworkAndAddressRange, Network> {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+ protected final GoogleComputeEngineApi api;
+ protected final Function<NetworkAndAddressRange, Network> networkCreator;
+ protected final Supplier<String> userProject;
+
+ @Inject
+ public FindNetworkOrCreate(GoogleComputeEngineApi api,
+ Function<NetworkAndAddressRange, Network> networkCreator,
+ @UserProject Supplier<String> userProject) {
+ this.api = checkNotNull(api, "api");
+ this.networkCreator = checkNotNull(networkCreator, "networkCreator");
+ this.userProject = checkNotNull(userProject, "userProject");
+ }
+
+ @Override
+ public Network load(NetworkAndAddressRange in) {
+ Network network = api.getNetworkApiForProject(userProject.get()).get(in.getName());
+ if (network != null) {
+ return network;
+ } else {
+ return networkCreator.apply(in);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/options/GoogleComputeEngineTemplateOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/options/GoogleComputeEngineTemplateOptions.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/options/GoogleComputeEngineTemplateOptions.java
new file mode 100644
index 0000000..c6aad00
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/options/GoogleComputeEngineTemplateOptions.java
@@ -0,0 +1,382 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.options;
+
+import static com.google.common.base.Optional.fromNullable;
+import static org.jclouds.googlecomputeengine.domain.Instance.ServiceAccount;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk;
+import org.jclouds.scriptbuilder.domain.Statement;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+
+/**
+ * Instance options specific to Google Compute Engine.
+ */
+public class GoogleComputeEngineTemplateOptions extends TemplateOptions {
+
+ private Optional<URI> network = Optional.absent();
+ private Optional<String> networkName = Optional.absent();
+ private Set<Instance.ServiceAccount> serviceAccounts = Sets.newLinkedHashSet();
+ private boolean enableNat = true;
+ private Set<PersistentDisk> disks = Sets.newLinkedHashSet();
+ private Optional<Long> bootDiskSize = Optional.absent();
+ private boolean keepBootDisk = false;
+
+ @Override
+ public GoogleComputeEngineTemplateOptions clone() {
+ GoogleComputeEngineTemplateOptions options = new GoogleComputeEngineTemplateOptions();
+ copyTo(options);
+ return options;
+ }
+
+ @Override
+ public void copyTo(TemplateOptions to) {
+ super.copyTo(to);
+ if (to instanceof GoogleComputeEngineTemplateOptions) {
+ GoogleComputeEngineTemplateOptions eTo = GoogleComputeEngineTemplateOptions.class.cast(to);
+ eTo.network(getNetwork().orNull());
+ eTo.serviceAccounts(getServiceAccounts());
+ eTo.enableNat(isEnableNat());
+ eTo.disks(getDisks());
+ eTo.keepBootDisk(shouldKeepBootDisk());
+ }
+ }
+
+ /**
+ * @deprecated See TemplateOptions#networks
+ * @see #getNetworkName()
+ */
+ @Deprecated
+ public GoogleComputeEngineTemplateOptions network(String networkName) {
+ return this.networks(networkName);
+ }
+
+ /**
+ * @see #getNetwork()
+ */
+ public GoogleComputeEngineTemplateOptions network(URI network) {
+ this.network = fromNullable(network);
+ return this;
+ }
+
+ /**
+ * @see #getServiceAccounts()
+ * @see ServiceAccount
+ */
+ public GoogleComputeEngineTemplateOptions addServiceAccount(ServiceAccount serviceAccout) {
+ this.serviceAccounts.add(serviceAccout);
+ return this;
+ }
+
+ /**
+ * @see #getServiceAccounts()
+ * @see ServiceAccount
+ */
+ public GoogleComputeEngineTemplateOptions serviceAccounts(Set<ServiceAccount> serviceAccounts) {
+ this.serviceAccounts = Sets.newLinkedHashSet(serviceAccounts);
+ return this;
+ }
+
+ /**
+ * @see #getDisks()
+ * @see org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk
+ */
+ public GoogleComputeEngineTemplateOptions addDisk(PersistentDisk disk) {
+ this.disks.add(disk);
+ return this;
+ }
+
+ /**
+ * @see #getDisks()
+ * @see org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk
+ */
+ public GoogleComputeEngineTemplateOptions disks(Set<PersistentDisk> disks) {
+ this.disks = Sets.newLinkedHashSet(disks);
+ return this;
+ }
+
+ /**
+ * @see #isEnableNat()
+ */
+ public GoogleComputeEngineTemplateOptions enableNat(boolean enableNat) {
+ this.enableNat = enableNat;
+ return this;
+ }
+
+ /**
+ * @see #getBootDiskSize()
+ */
+ public GoogleComputeEngineTemplateOptions bootDiskSize(Long bootDiskSize) {
+ this.bootDiskSize = fromNullable(bootDiskSize);
+ return this;
+ }
+
+ /**
+ * @see #shouldKeepBootDisk()
+ */
+ public GoogleComputeEngineTemplateOptions keepBootDisk(boolean keepBootDisk) {
+ this.keepBootDisk = keepBootDisk;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions blockOnPort(int port, int seconds) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.blockOnPort(port, seconds));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions inboundPorts(int... ports) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.inboundPorts(ports));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions authorizePublicKey(String publicKey) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions installPrivateKey(String privateKey) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.installPrivateKey(privateKey));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions blockUntilRunning(boolean blockUntilRunning) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions dontAuthorizePublicKey() {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.dontAuthorizePublicKey());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions nameTask(String name) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.nameTask(name));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions runAsRoot(boolean runAsRoot) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.runAsRoot(runAsRoot));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions runScript(Statement script) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.runScript(script));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.overrideLoginCredentials(overridingCredentials));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions overrideLoginPassword(String password) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.overrideLoginPassword(password));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions overrideLoginPrivateKey(String privateKey) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.overrideLoginPrivateKey(privateKey));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions overrideLoginUser(String loginUser) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.overrideLoginUser(loginUser));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.overrideAuthenticateSudo(authenticateSudo));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions userMetadata(Map<String, String> userMetadata) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.userMetadata(userMetadata));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions userMetadata(String key, String value) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.userMetadata(key, value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions nodeNames(Iterable<String> nodeNames) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.nodeNames(nodeNames));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions networks(Iterable<String> networks) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.networks(networks));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions networks(String... networks) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.networks(networks));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions tags(Iterable<String> tags) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.tags(tags));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions wrapInInitScript(boolean wrapInInitScript) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.wrapInInitScript(wrapInInitScript));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions runScript(String script) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.runScript(script));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GoogleComputeEngineTemplateOptions blockOnComplete(boolean blockOnComplete) {
+ return GoogleComputeEngineTemplateOptions.class.cast(super.blockOnComplete(blockOnComplete));
+ }
+
+ /**
+ * @return the ServiceAccounts to enable in the instances.
+ */
+ public Set<Instance.ServiceAccount> getServiceAccounts() {
+ return serviceAccounts;
+ }
+
+ /**
+ * @return the PersistentDisks for this instance.
+ */
+ public Set<PersistentDisk> getDisks() {
+ return disks;
+ }
+
+ /**
+ * @return the URI of an existing network the instances will be attached to. If no network URI or network name are
+ * provided a new network will be created for the project.
+ */
+ public Optional<URI> getNetwork() {
+ return network;
+ }
+
+ /**
+ * @return the name of an existing network the instances will be attached to, the network is assumed to belong to
+ * user's project. If no network URI network name are provided a new network will be created for the project.
+ * <b>Note that this is now pulling from the first element in the networks field from TemplateOptions.</b>
+ */
+ public Optional<String> getNetworkName() {
+ return fromNullable(Iterables.getFirst(getNetworks(), null));
+ }
+
+ /**
+ * @return whether an AccessConfig with Type ONE_TO_ONE_NAT should be enabled in the instances. When true
+ * instances will have a NAT address that will be publicly accessible.
+ */
+ public boolean isEnableNat() {
+ return enableNat;
+ }
+
+ /**
+ * @return the boot disk size, if specified. Defaults to 10gb.
+ */
+ public Optional<Long> getBootDiskSize() {
+ return bootDiskSize;
+ }
+
+ /**
+ * @return whether we should keep the boot disk around when deleting the instance. Defaults to false.
+ */
+ public boolean shouldKeepBootDisk() {
+ return keepBootDisk;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/predicates/AllNodesInGroupTerminated.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/predicates/AllNodesInGroupTerminated.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/predicates/AllNodesInGroupTerminated.java
new file mode 100644
index 0000000..38066ba
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/predicates/AllNodesInGroupTerminated.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.predicates;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.all;
+import static com.google.common.collect.Sets.filter;
+import static org.jclouds.compute.predicates.NodePredicates.TERMINATED;
+import static org.jclouds.compute.predicates.NodePredicates.all;
+import static org.jclouds.compute.predicates.NodePredicates.inGroup;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.ComputeService;
+
+import com.google.common.base.Predicate;
+
+@Singleton
+public class AllNodesInGroupTerminated implements Predicate<String> {
+
+ private final ComputeService computeService;
+
+ @Inject
+ public AllNodesInGroupTerminated(ComputeService computeService) {
+ this.computeService = checkNotNull(computeService, "compute service");
+ }
+
+
+ @Override
+ public boolean apply(String groupName) {
+ return all(filter(computeService.listNodesDetailsMatching(all()), inGroup(groupName)), TERMINATED);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java
new file mode 100644
index 0000000..14af9cd
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.strategy;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableSet.of;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_INTERVAL;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_TIMEOUT;
+import static org.jclouds.util.Predicates2.retry;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.Constants;
+import org.jclouds.compute.config.CustomizationResponse;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
+import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap;
+import org.jclouds.compute.strategy.ListNodesStrategy;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
+import org.jclouds.googlecomputeengine.compute.functions.FirewallTagNamingConvention;
+import org.jclouds.googlecomputeengine.compute.options.GoogleComputeEngineTemplateOptions;
+import org.jclouds.googlecomputeengine.config.UserProject;
+import org.jclouds.googlecomputeengine.domain.Firewall;
+import org.jclouds.googlecomputeengine.domain.Network;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.domain.internal.NetworkAndAddressRange;
+import org.jclouds.googlecomputeengine.features.FirewallApi;
+import org.jclouds.googlecomputeengine.options.FirewallOptions;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.Atomics;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+
+public class CreateNodesWithGroupEncodedIntoNameThenAddToSet extends
+ org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet {
+
+ public static final String EXTERIOR_RANGE = "0.0.0.0/0";
+ public static final String DEFAULT_INTERNAL_NETWORK_RANGE = "10.0.0.0/8";
+
+ private final GoogleComputeEngineApi api;
+ private final Supplier<String> userProject;
+ private final LoadingCache<NetworkAndAddressRange, Network> networkMap;
+ private final Predicate<AtomicReference<Operation>> operationDonePredicate;
+ private final long operationCompleteCheckInterval;
+ private final long operationCompleteCheckTimeout;
+ private final FirewallTagNamingConvention.Factory firewallTagNamingConvention;
+
+ @Inject
+ protected CreateNodesWithGroupEncodedIntoNameThenAddToSet(
+ CreateNodeWithGroupEncodedIntoName addNodeWithGroupStrategy,
+ ListNodesStrategy listNodesStrategy,
+ GroupNamingConvention.Factory namingConvention,
+ @Named(Constants.PROPERTY_USER_THREADS)
+ ListeningExecutorService userExecutor,
+ CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory
+ customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory,
+ GoogleComputeEngineApi api,
+ @UserProject Supplier<String> userProject,
+ @Named("global") Predicate<AtomicReference<Operation>> operationDonePredicate,
+ @Named(OPERATION_COMPLETE_INTERVAL) Long operationCompleteCheckInterval,
+ @Named(OPERATION_COMPLETE_TIMEOUT) Long operationCompleteCheckTimeout,
+ LoadingCache<NetworkAndAddressRange, Network> networkMap,
+ FirewallTagNamingConvention.Factory firewallTagNamingConvention) {
+ super(addNodeWithGroupStrategy, listNodesStrategy, namingConvention, userExecutor,
+ customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory);
+
+ this.api = checkNotNull(api, "google compute api");
+ this.userProject = checkNotNull(userProject, "user project name");
+ this.operationCompleteCheckInterval = checkNotNull(operationCompleteCheckInterval,
+ "operation completed check interval");
+ this.operationCompleteCheckTimeout = checkNotNull(operationCompleteCheckTimeout,
+ "operation completed check timeout");
+ this.operationDonePredicate = checkNotNull(operationDonePredicate, "operationDonePredicate");
+ this.networkMap = checkNotNull(networkMap, "networkMap");
+ this.firewallTagNamingConvention = checkNotNull(firewallTagNamingConvention, "firewallTagNamingConvention");
+ }
+
+ @Override
+ public synchronized Map<?, ListenableFuture<Void>> execute(String group, int count,
+ Template template,
+ Set<NodeMetadata> goodNodes,
+ Map<NodeMetadata, Exception> badNodes,
+ Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
+
+ String sharedResourceName = namingConvention.create().sharedNameForGroup(group);
+ Template mutableTemplate = template.clone();
+ GoogleComputeEngineTemplateOptions templateOptions = GoogleComputeEngineTemplateOptions.class.cast(mutableTemplate
+ .getOptions());
+ assert template.getOptions().equals(templateOptions) : "options didn't clone properly";
+
+ // get or create the network and create a firewall with the users configuration
+ Network network = getOrCreateNetwork(templateOptions, sharedResourceName);
+ getOrCreateFirewalls(templateOptions, network, firewallTagNamingConvention.get(group));
+ templateOptions.network(network.getSelfLink());
+ templateOptions.userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, group);
+
+ return super.execute(group, count, mutableTemplate, goodNodes, badNodes, customizationResponses);
+ }
+
+ /**
+ * Try and find a network either previously created by jclouds or user defined.
+ */
+ private Network getOrCreateNetwork(GoogleComputeEngineTemplateOptions templateOptions, String sharedResourceName) {
+
+ String networkName = templateOptions.getNetworkName().or(sharedResourceName);
+
+ return networkMap.apply(new NetworkAndAddressRange(networkName, DEFAULT_INTERNAL_NETWORK_RANGE, null));
+ }
+
+ /**
+ * Ensures that a firewall exists for every inbound port that the instance requests.
+ * <p>
+ * For each port, there must be a firewall with a name following the {@link FirewallTagNamingConvention},
+ * with a target tag also following the {@link FirewallTagNamingConvention}, which opens the requested port
+ * for all sources on both TCP and UDP protocols.
+ * @see org.jclouds.googlecomputeengine.features.FirewallApi#patch(String, org.jclouds.googlecomputeengine.options.FirewallOptions)
+ */
+ private void getOrCreateFirewalls(GoogleComputeEngineTemplateOptions templateOptions, Network network,
+ FirewallTagNamingConvention naming) {
+
+ String projectName = userProject.get();
+ FirewallApi firewallApi = api.getFirewallApiForProject(projectName);
+ Set<AtomicReference<Operation>> operations = Sets.newHashSet();
+
+ for (Integer port : templateOptions.getInboundPorts()) {
+ String name = naming.name(port);
+ Firewall firewall = firewallApi.get(name);
+ if (firewall == null) {
+ ImmutableSet<Firewall.Rule> rules = ImmutableSet.of(Firewall.Rule.permitTcpRule(port), Firewall.Rule.permitUdpRule(port));
+ FirewallOptions firewallOptions = new FirewallOptions()
+ .name(name)
+ .network(network.getSelfLink())
+ .allowedRules(rules)
+ .sourceTags(templateOptions.getTags())
+ .sourceRanges(of(DEFAULT_INTERNAL_NETWORK_RANGE, EXTERIOR_RANGE))
+ .targetTags(ImmutableSet.of(name));
+ AtomicReference<Operation> operation = Atomics.newReference(firewallApi.createInNetwork(
+ firewallOptions.getName(),
+ network.getSelfLink(),
+ firewallOptions));
+ operations.add(operation);
+ }
+ }
+
+ for (AtomicReference<Operation> operation : operations) {
+ retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
+ MILLISECONDS).apply(operation);
+ checkState(!operation.get().getHttpError().isPresent(),
+ "Could not create firewall, operation failed" + operation);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/PopulateDefaultLoginCredentialsForImageStrategy.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/PopulateDefaultLoginCredentialsForImageStrategy.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/PopulateDefaultLoginCredentialsForImageStrategy.java
new file mode 100644
index 0000000..082d9ed
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/compute/strategy/PopulateDefaultLoginCredentialsForImageStrategy.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.compute.strategy;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
+
+import java.security.NoSuchAlgorithmException;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.domain.TemplateBuilderSpec;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.ssh.internal.RsaSshKeyPairGenerator;
+
+import com.google.inject.Inject;
+
+@Singleton
+public class PopulateDefaultLoginCredentialsForImageStrategy implements
+ org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy {
+
+ private final TemplateBuilderSpec templateBuilder;
+ private final RsaSshKeyPairGenerator keyPairGenerator;
+ private String compoundKey;
+
+ @Inject
+ PopulateDefaultLoginCredentialsForImageStrategy(@Named(TEMPLATE) String templateSpec,
+ RsaSshKeyPairGenerator keyPairGenerator)
+ throws NoSuchAlgorithmException {
+ this.templateBuilder = TemplateBuilderSpec.parse(checkNotNull(templateSpec, "template builder spec"));
+ checkNotNull(templateBuilder.getLoginUser(), "template builder spec must provide a loginUser");
+ this.keyPairGenerator = checkNotNull(keyPairGenerator, "keypair generator");
+ }
+
+ @PostConstruct
+ private void generateKeys() {
+ Map<String, String> keys = keyPairGenerator.get();
+ // as we need to store both the pubk and the pk, store them separated by : (base64 does not contain that char)
+ compoundKey = String.format("%s:%s", checkNotNull(keys.get("public"), "public key cannot be null"),
+ checkNotNull(keys.get("private"), "private key cannot be null"));
+ }
+
+ @Override
+ public LoginCredentials apply(Object image) {
+ return LoginCredentials.builder()
+ .authenticateSudo(templateBuilder.getAuthenticateSudo() != null ?
+ templateBuilder.getAuthenticateSudo() : false)
+ .privateKey(compoundKey)
+ .user(templateBuilder.getLoginUser()).build();
+ }
+
+}
[27/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Subnet.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Subnet.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Subnet.java
new file mode 100644
index 0000000..d8be96c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/domain/Subnet.java
@@ -0,0 +1,264 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.domain;
+
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+
+import java.beans.ConstructorProperties;
+import java.util.Collection;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * A Neutron subnet
+ *
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api doc</a>
+ */
+public class Subnet extends ReferenceWithName {
+
+ private final String networkId;
+ private final String gatewayIp;
+ private final Integer ipVersion;
+ private final String cidr;
+ private final Set<AllocationPool> allocationPools;
+ private final Boolean enableDhcp;
+ private final Set<String> dnsNameServers;
+ private final Set<HostRoute> hostRoutes;
+
+ @ConstructorProperties({
+ "id", "tenant_id", "name", "network_id", "gateway_ip", "ip_version", "cidr", "allocation_pools", "enable_dhcp", "dns_nameservers", "host_routes"
+ })
+ protected Subnet(String id, String tenantId, String name, String networkId,
+ String gatewayIp, Integer ipVersion, String cidr, Set<AllocationPool> allocationPools,
+ Boolean enableDhcp, Set<String> dnsNameServers, Set<HostRoute> hostRoutes) {
+ super(id, tenantId, name);
+ this.networkId = checkNotNull(networkId, "networkId");
+ this.gatewayIp = gatewayIp;
+ this.ipVersion = checkNotNull(ipVersion, "ipVersion");
+ this.cidr = checkNotNull(cidr, "cidr");
+ this.allocationPools = allocationPools != null ? ImmutableSet.copyOf(allocationPools) : ImmutableSet.<AllocationPool>of();
+ this.enableDhcp = enableDhcp;
+ this.dnsNameServers = dnsNameServers != null ? ImmutableSet.copyOf(dnsNameServers) : ImmutableSet.<String>of();
+ this.hostRoutes = hostRoutes != null ? ImmutableSet.copyOf(hostRoutes) : ImmutableSet.<HostRoute>of();
+ }
+
+ /**
+ * @return the id of the network this subnet is associated with
+ */
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ /**
+ * @return the default gateway used by devices in this subnet
+ */
+ public String getGatewayIp() {
+ return gatewayIp;
+ }
+
+ /**
+ * @return the ip version used by this subnet
+ */
+ public Integer getIpVersion() {
+ return ipVersion;
+ }
+
+ /**
+ * @return the cidr representing the IP range for this subnet, based on IP version
+ */
+ public String getCidr() {
+ return cidr;
+ }
+
+ /**
+ * @return the sub-ranges of cidr available for dynamic allocation to ports
+ */
+ public Set<AllocationPool> getAllocationPools() {
+ return allocationPools;
+ }
+
+ /**
+ * @return true if DHCP is enabled for this subnet, false if not.
+ */
+ public Boolean getEnableDhcp() {
+ return enableDhcp;
+ }
+
+ /**
+ * @return the set of DNS name servers used by hosts in this subnet.
+ */
+ public Set<String> getDnsNameServers() {
+ return dnsNameServers;
+ }
+
+ /**
+ * @return the set of routes that should be used by devices with IPs from this subnet
+ */
+ public Set<HostRoute> getHostRoutes() {
+ return hostRoutes;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), networkId, gatewayIp, ipVersion, cidr,
+ allocationPools, enableDhcp, dnsNameServers, hostRoutes);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Subnet that = Subnet.class.cast(obj);
+ return super.equals(obj)
+ && Objects.equal(this.networkId, that.networkId)
+ && Objects.equal(this.gatewayIp, that.gatewayIp)
+ && Objects.equal(this.ipVersion, that.ipVersion)
+ && Objects.equal(this.cidr, that.cidr)
+ && Objects.equal(this.allocationPools, that.allocationPools)
+ && Objects.equal(this.enableDhcp, that.enableDhcp)
+ && Objects.equal(this.dnsNameServers, that.dnsNameServers)
+ && Objects.equal(this.hostRoutes, that.hostRoutes);
+ }
+
+ protected ToStringHelper string() {
+ return super.string()
+ .add("networkId", networkId)
+ .add("gatewayIp", gatewayIp)
+ .add("ipVersion", ipVersion)
+ .add("cidr", cidr)
+ .add("enableDHCP", enableDhcp)
+ .add("allocationPools", allocationPools)
+ .add("dnsNameServers", dnsNameServers)
+ .add("hostRoutes", hostRoutes);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromSubnet(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends ReferenceWithName.Builder<T> {
+ protected String networkId;
+ protected String gatewayIp;
+ protected Integer ipVersion;
+ protected String cidr;
+ protected Set<AllocationPool> allocationPools;
+ protected Boolean enableDhcp;
+ protected Set<String> dnsNameServers;
+ protected Set<HostRoute> hostRoutes;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Subnet#getNetworkId()
+ */
+ public T networkId(String networkId) {
+ this.networkId = networkId;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Subnet#getGatewayIp()
+ */
+ public T gatewayIp(String gatewayIp) {
+ this.gatewayIp = gatewayIp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Subnet#getIpVersion()
+ */
+ public T ipVersion(Integer ipVersion) {
+ this.ipVersion = ipVersion;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Subnet#getCidr()
+ */
+ public T cidr(String cidr) {
+ this.cidr = cidr;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Subnet#getAllocationPools()
+ */
+ public T allocationPools(Collection<AllocationPool> allocationPools) {
+ this.allocationPools = ImmutableSet.copyOf(allocationPools);
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Subnet#getEnableDhcp()
+ */
+ public T enableDhcp(Boolean enableDhcp) {
+ this.enableDhcp = enableDhcp;
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Subnet#getDnsNameServers()
+ */
+ public T dnsNameServers(Collection<String> dnsNameServers) {
+ this.dnsNameServers = ImmutableSet.copyOf(dnsNameServers);
+ return self();
+ }
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.domain.Subnet#getHostRoutes()
+ */
+ public T hostRoutes(Collection<HostRoute> hostRoutes) {
+ this.hostRoutes = ImmutableSet.copyOf(hostRoutes);
+ return self();
+ }
+
+ public Subnet build() {
+ return new Subnet(id, tenantId, name, networkId, gatewayIp, ipVersion, cidr, allocationPools, enableDhcp, dnsNameServers, hostRoutes);
+ }
+
+ public T fromSubnet(Subnet in) {
+ return super.fromReference(in)
+ .networkId(in.getNetworkId())
+ .gatewayIp(in.getGatewayIp())
+ .ipVersion(in.getIpVersion())
+ .cidr(in.getCidr())
+ .allocationPools(in.getAllocationPools())
+ .enableDhcp(in.getEnableDhcp())
+ .dnsNameServers(in.getDnsNameServers())
+ .hostRoutes(in.getHostRoutes());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/extensions/RouterApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/extensions/RouterApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/extensions/RouterApi.java
new file mode 100644
index 0000000..dca4427
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/extensions/RouterApi.java
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.domain.Router;
+import org.jclouds.openstack.neutron.v2_0.domain.RouterInterface;
+import org.jclouds.openstack.neutron.v2_0.functions.ParseRouterDetails;
+import org.jclouds.openstack.neutron.v2_0.functions.ParseRouters;
+import org.jclouds.openstack.neutron.v2_0.options.CreateRouterOptions;
+import org.jclouds.openstack.neutron.v2_0.options.EmptyOptions;
+import org.jclouds.openstack.neutron.v2_0.options.UpdateRouterOptions;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+
+/**
+ * Provides access to Router operations for the OpenStack Networking (Neutron) v2 API.
+ * <p/>
+ * A logical entity for forwarding packets across internal subnets and NATting them on external
+ * networks through an appropriate external gateway.
+ *
+ * @deprecated Please use {@link org.jclouds.openstack.neutron.v2.extensions.RouterApi} as this
+ * interface will be removed in jclouds 3.0.
+ */
+@Deprecated
+@Path("/v2.0/routers")
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface RouterApi {
+
+ /**
+ * Returns the list of all routers currently defined in Neutron for the current tenant. The list provides the unique
+ * identifier of each router configured for the tenant
+ *
+ * @return the list of all router references configured for the tenant.
+ */
+ @Named("router:list")
+ @GET
+ @ResponseParser(ParseRouters.class)
+ @Transform(ParseRouters.ToPagedIterable.class)
+ @Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class)
+ @QueryParams(keys = {"fields", "fields", "fields"}, values = {"id", "tenant_id", "name"})
+ PagedIterable<? extends ReferenceWithName> list();
+
+ /**
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a>
+ */
+ @Named("router:list")
+ @GET
+ @ResponseParser(ParseRouters.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ @QueryParams(keys = {"fields", "fields", "fields"}, values = {"id", "tenant_id", "name"})
+ PagedIterable<? extends ReferenceWithName> list(PaginationOptions options);
+
+ /**
+ * Returns all routers currently defined in Neutron for the current tenant.
+ *
+ * @return the list of all routers configured for the tenant
+ */
+ @Named("router:list")
+ @GET
+ @ResponseParser(ParseRouterDetails.class)
+ @Transform(ParseRouterDetails.ToPagedIterable.class)
+ @Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<? extends Router> listInDetail();
+
+ /**
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a>
+ */
+ @Named("router:list")
+ @GET
+ @ResponseParser(ParseRouterDetails.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ PagedIterable<? extends Router> listInDetail(PaginationOptions options);
+
+ /**
+ * Returns the specific router.
+ *
+ * @param id the id of the router to return
+ * @return Router or null if not found
+ */
+ @Named("router:get")
+ @GET
+ @Path("/{id}")
+ @SelectJson("router")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Nullable
+ Router get(@PathParam("id") String id);
+
+ /**
+ * Create a new router
+ *
+ * @param options optional arguments
+ * @return the newly created router
+ */
+ @Named("router:create")
+ @POST
+ @SelectJson("router")
+ @MapBinder(CreateRouterOptions.class)
+ Router create(CreateRouterOptions... options);
+
+ /**
+ * Update a router
+ *
+ * @param id the id of the router to update
+ * @param options the attributes to update
+ * @return true if update successful, false if not
+ */
+ @Named("router:update")
+ @PUT
+ @Path("/{id}")
+ @MapBinder(UpdateRouterOptions.class)
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean update(@PathParam("id") String id, UpdateRouterOptions... options);
+
+ /**
+ * Deletes the specified router
+ *
+ * @param id the id of the router to delete
+ * @return true if delete successful, false if not
+ */
+ @Named("router:delete")
+ @DELETE
+ @Path("/{id}")
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean delete(@PathParam("id") String id);
+
+ /**
+ * Add a interface to a router to connect to the specified subnet
+ *
+ * @param routerId the id of the router to create the interface at
+ * @param subnetId the id of the subnet to connect with the interface
+ * @return the newly-created router interface
+ */
+ @Named("router:addInterfaceForSubnet")
+ @PUT
+ @Path("/{id}/add_router_interface")
+ @MapBinder(EmptyOptions.class)
+ RouterInterface addInterfaceForSubnet(@PathParam("id") String routerId, @PayloadParam("subnet_id") String subnetId);
+
+ /**
+ * Add a interface to a router to connect to the specified port
+ *
+ * @param routerId the id of the router to create the interface at
+ * @param portId the id of the port to connect with the interface
+ * @return the newly-created router interface
+ */
+ @Named("router:addInterfaceForPort")
+ @PUT
+ @Path("{id}/add_router_interface")
+ @MapBinder(EmptyOptions.class)
+ RouterInterface addInterfaceForPort(@PathParam("id") String routerId, @PayloadParam("port_id") String portId);
+
+ /**
+ * Remove the interface where the specified subnet is connected to
+ *
+ * @param routerId the id of the router to remove the interface from
+ * @param subnetId the id of the subnet to disconnect from the interface
+ */
+ @Named("router:removeInterfaceForSubnet")
+ @PUT
+ @Path("/{id}/remove_router_interface")
+ @MapBinder(EmptyOptions.class)
+ boolean removeInterfaceForSubnet(@PathParam("id") String routerId, @PayloadParam("subnet_id") String subnetId);
+
+ /**
+ * Remove the interface where the specified port is connected to
+ *
+ * @param routerId the id of the router to remove the interface from
+ * @param portId the id of the port to disconnect from the interface
+ */
+ @Named("router:removeInterfaceForPort")
+ @PUT
+ @Path("{id}/remove_router_interface")
+ @MapBinder(EmptyOptions.class)
+ boolean removeInterfaceForPort(@PathParam("id") String routerId, @PayloadParam("port_id") String portId);
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/features/NetworkApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/features/NetworkApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/features/NetworkApi.java
new file mode 100644
index 0000000..c2b4aa5
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/features/NetworkApi.java
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.features;
+
+import com.google.common.collect.FluentIterable;
+import org.jclouds.Fallbacks;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.Network;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.functions.ParseNetworkDetails;
+import org.jclouds.openstack.neutron.v2_0.functions.ParseNetworks;
+import org.jclouds.openstack.neutron.v2_0.options.CreateNetworkBulkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.UpdateNetworkOptions;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.core.MediaType;
+
+import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import static org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
+
+/**
+ * Provides access to Network operations for the OpenStack Networking (Neutron) v2 API.
+ * <p/>
+ * Each tenant can define one or more networks. A network is a virtual isolated layer-2 broadcast domain reserved to the
+ * tenant. A tenant can create several ports for a network, and plug virtual interfaces into these ports.
+ *
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-network/2.0/content/Networks.html">api doc</a>
+ * @deprecated Use v2 instead of v2_0
+ */
+@Deprecated
+@Path("/v2.0/networks")
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface NetworkApi {
+
+ /**
+ * Returns the list of all networks currently defined in Neutron for the current tenant. The list provides the unique
+ * identifier of each network configured for the tenant.
+ *
+ * @return the list of all network references configured for the tenant
+ */
+ @Named("network:list")
+ @GET
+ @ResponseParser(ParseNetworks.class)
+ @Transform(ParseNetworks.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ @QueryParams(keys = {"fields", "fields", "fields"}, values = {"id", "tenant_id", "name"})
+ PagedIterable<? extends ReferenceWithName> list();
+
+ /**
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a>
+ */
+ @Named("network:list")
+ @GET
+ @ResponseParser(ParseNetworks.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ @QueryParams(keys = {"fields", "fields", "fields"}, values = {"id", "tenant_id", "name"})
+ PagedIterable<? extends ReferenceWithName> list(PaginationOptions options);
+
+ /**
+ * Returns all networks currently defined in Neutron for the current tenant.
+ *
+ * @return the list of all networks configured for the tenant
+ */
+ @Named("network:list")
+ @GET
+ @ResponseParser(ParseNetworkDetails.class)
+ @Transform(ParseNetworkDetails.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<? extends Network> listInDetail();
+
+ /**
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a>
+ */
+ @Named("network:list")
+ @GET
+ @ResponseParser(ParseNetworkDetails.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ PagedIterable<? extends Network> listInDetail(PaginationOptions options);
+
+ /**
+ * Return a specific network
+ *
+ * @param id the id of the network to return
+ * @return Network or null if not found
+ */
+ @Named("network:get")
+ @GET
+ @Path("/{id}")
+ @SelectJson("network")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Nullable
+ Network get(@PathParam("id") String id);
+
+ /**
+ * Create a new network with the specified type
+ *
+ * @param options optional arguments
+ * @return a reference of the newly-created network
+ */
+ @Named("network:create")
+ @POST
+ @SelectJson("network")
+ @MapBinder(CreateNetworkOptions.class)
+ Network create(CreateNetworkOptions... options);
+
+ /**
+ * Create multiple networks
+ *
+ * @param networks the bulk of networks to create
+ * @return list of references of the newly-created networks
+ */
+ @Named("network:createBulk")
+ @POST
+ @SelectJson("networks")
+ @MapBinder(CreateNetworkBulkOptions.class)
+ FluentIterable<? extends Network> createBulk(CreateNetworkBulkOptions networks);
+
+ /**
+ * Update a network
+ *
+ * @param id the id of the network to update
+ * @param options the attributes to update
+ * @return true if update successful, false if not
+ */
+ @Named("network:update")
+ @PUT
+ @Path("/{id}")
+ @MapBinder(UpdateNetworkOptions.class)
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean update(@PathParam("id") String id, UpdateNetworkOptions... options);
+
+ /**
+ * Deletes the specified network
+ *
+ * @param id the id of the network to delete
+ * @return true if delete was successful, false if not
+ */
+ @Named("network:delete")
+ @DELETE
+ @Path("/{id}")
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean delete(@PathParam("id") String id);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/features/PortApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/features/PortApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/features/PortApi.java
new file mode 100644
index 0000000..7390131
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/features/PortApi.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.features;
+
+import com.google.common.collect.FluentIterable;
+import org.jclouds.Fallbacks;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.Port;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.functions.ParsePortDetails;
+import org.jclouds.openstack.neutron.v2_0.functions.ParsePorts;
+import org.jclouds.openstack.neutron.v2_0.options.CreatePortBulkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreatePortOptions;
+import org.jclouds.openstack.neutron.v2_0.options.UpdatePortOptions;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.core.MediaType;
+
+import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import static org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
+
+/**
+ * Provides access to Port operations for the OpenStack Networking (Neutron) v2 API.
+ * <p/>
+ * A port represents a virtual switch port on a logical network switch where all the interfaces attached to a given network are connected.
+ * <p/>
+ * A port has an administrative state which is either 'DOWN' or 'ACTIVE'. Ports which are administratively down will not be able to receive/send traffic.
+
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-network/2.0/content/Ports.html">api doc</a>
+ * @deprecated Use v2 instead of v2_0
+ */
+@Deprecated
+@Path("/v2.0/ports")
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface PortApi {
+
+ /**
+ * Returns the list of all ports currently defined in Neutron for the current tenant. The list provides the unique
+ * identifier of each network configured for the tenant.
+ *
+ * @return the list of all port references configured for the tenant
+ */
+ @Named("port:list")
+ @GET
+ @ResponseParser(ParsePorts.class)
+ @Transform(ParsePorts.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ @QueryParams(keys = {"fields", "fields", "fields"}, values = {"id", "tenant_id", "name"})
+ PagedIterable<? extends ReferenceWithName> list();
+
+ /**
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a>
+ */
+ @Named("port:list")
+ @GET
+ @ResponseParser(ParsePorts.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ @QueryParams(keys = {"fields", "fields", "fields"}, values = {"id", "tenant_id", "name"})
+ PagedIterable<? extends ReferenceWithName> list(PaginationOptions options);
+
+ /**
+ * Returns the set of ports currently defined in Neutron for the requested network.
+ *
+ * @return the list of all ports configured for the tenant
+ */
+ @Named("port:list")
+ @GET
+ @ResponseParser(ParsePortDetails.class)
+ @Transform(ParsePortDetails.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<? extends Port> listInDetail();
+
+ /**
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a>
+ */
+ @Named("port:list")
+ @GET
+ @ResponseParser(ParsePortDetails.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ PagedIterable<? extends Port> listInDetail(PaginationOptions options);
+
+ /**
+ * Returns the specific port
+ *
+ * @param id the id of the port to return
+ * @return Port or null if not found
+ */
+ @Named("port:get")
+ @GET
+ @Path("/{id}")
+ @SelectJson("port")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Nullable
+ Port get(@PathParam("id") String id);
+
+ /**
+ * Create a new port in the specified network
+ *
+ * @param networkId the id of the network to associate this port with
+ * @param options optional arguments
+ * @return a reference of the newly-created port
+ */
+ @Named("port:create")
+ @POST
+ @SelectJson("port")
+ @MapBinder(CreatePortOptions.class)
+ Port create(@PayloadParam("network_id") String networkId, CreatePortOptions... options);
+
+ /**
+ * Create multiple ports
+ *
+ * @param ports the bulk of ports to create
+ * @return list of references of the newly-created ports
+ */
+ @Named("port:createBulk")
+ @POST
+ @SelectJson("ports")
+ @MapBinder(CreatePortBulkOptions.class)
+ FluentIterable<? extends Port> createBulk(CreatePortBulkOptions ports);
+
+ /**
+ * Update a port
+ *
+ * @param id the id of the port to update
+ * @param options the attributes to update
+ * @return true if update successful, false if not
+ */
+ @Named("port:update")
+ @PUT
+ @Path("/{id}")
+ @MapBinder(UpdatePortOptions.class)
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean update(@PathParam("id") String id, UpdatePortOptions... options);
+
+ /**
+ * Delete a port
+ *
+ * @param id the id of the port to delete
+ * @return true if delete successful, false if not
+ */
+ @Named("port:delete")
+ @DELETE
+ @Path("/{id}")
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean delete(@PathParam("id") String id);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApi.java
new file mode 100644
index 0000000..5c2acc5
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApi.java
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.features;
+
+import com.google.common.collect.FluentIterable;
+import org.jclouds.Fallbacks;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.domain.Subnet;
+import org.jclouds.openstack.neutron.v2_0.functions.ParseSubnetDetails;
+import org.jclouds.openstack.neutron.v2_0.functions.ParseSubnets;
+import org.jclouds.openstack.neutron.v2_0.options.CreateSubnetBulkOptions;
+import org.jclouds.openstack.neutron.v2_0.options.CreateSubnetOptions;
+import org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.core.MediaType;
+
+import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import static org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
+
+/**
+ * Provides access to Subnet operations for the OpenStack Networking (Neutron) v2 API.
+ *
+
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api doc</a>
+ * @deprecated Use v2 instead of v2_0
+ */
+@Deprecated
+@Path("/v2.0/subnets")
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface SubnetApi {
+
+ /**
+ * Returns the list of all subnets currently defined in Neutron for the current tenant. The list provides the unique
+ * identifier of each subnet configured for the tenant.
+ *
+ * @return the list of all subnet references configured for the tenant
+ */
+ @Named("subnet:list")
+ @GET
+ @ResponseParser(ParseSubnets.class)
+ @Transform(ParseSubnets.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ @QueryParams(keys = {"fields", "fields", "fields"}, values = {"id", "tenant_id", "name"})
+ PagedIterable<? extends ReferenceWithName> list();
+
+ /**
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a>
+ */
+ @Named("subnet:list")
+ @GET
+ @ResponseParser(ParseSubnets.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ @QueryParams(keys = {"fields", "fields", "fields"}, values = {"id", "tenant_id", "name"})
+ PagedIterable<? extends ReferenceWithName> list(PaginationOptions options);
+
+ /**
+ * Returns all subnets currently defined in Neutron for the current tenant.
+ *
+ * @return the list of all subnets configured for the tenant
+ */
+ @Named("subnet:list")
+ @GET
+ @ResponseParser(ParseSubnetDetails.class)
+ @Transform(ParseSubnetDetails.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<? extends Subnet> listInDetail();
+
+ /**
+ * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a>
+ */
+ @Named("subnet:list")
+ @GET
+ @ResponseParser(ParseSubnetDetails.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ PagedIterable<? extends Subnet> listInDetail(PaginationOptions options);
+
+ /**
+ * Returns the specific Subnet.
+ *
+ * @param id the id of the subnet to return
+ * @return Subnet or null if not found
+ */
+ @Named("subnet:get")
+ @GET
+ @Path("/{id}")
+ @SelectJson("subnet")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @Nullable
+ Subnet get(@PathParam("id") String id);
+
+ /**
+ * Create a subnet within a specified network
+ *
+ * @param networkId the id of the network to associate the subnet with
+ * @param ipVersion the ip version of this subnet
+ * @param cidr the cidr for this subnet
+ * @param options optional arugments
+ * @return a reference of the newly-created subnet
+ */
+ @Named("subnet:create")
+ @POST
+ @SelectJson("subnet")
+ @MapBinder(CreateSubnetOptions.class)
+ Subnet create(@PayloadParam("network_id") String networkId, @PayloadParam("ip_version") Integer ipVersion,
+ @PayloadParam("cidr") String cidr, CreateSubnetOptions... options);
+
+ /**
+ * Create multiple subnets
+ *
+ * @param subnets the bulk of subnets to create
+ * @return list of references of the newly-created subnets
+ */
+ @Named("subnet:createBulk")
+ @POST
+ @SelectJson("subnets")
+ @MapBinder(CreateSubnetBulkOptions.class)
+ FluentIterable<? extends Subnet> createBulk(CreateSubnetBulkOptions subnets);
+
+ /**
+ * Update a subnet
+ *
+ * @param id the id of the subnet to update
+ * @param options the attributes to update
+ * @return true if update was successful, false if not
+ */
+ @Named("subnet:update")
+ @PUT
+ @Path("/{id}")
+ @MapBinder(UpdateSubnetOptions.class)
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean update(@PathParam("id") String id, UpdateSubnetOptions... options);
+
+ /**
+ * Delete a subnet
+ *
+ * @param id the id of the subnet to delete
+ * @return true if delete successful, false if not
+ */
+ @Named("subnet:delete")
+ @DELETE
+ @Path("/{id}")
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean delete(@PathParam("id") String id);
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseNetworkDetails.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseNetworkDetails.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseNetworkDetails.java
new file mode 100644
index 0000000..421bf71
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseNetworkDetails.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2_0.NeutronApi;
+import org.jclouds.openstack.neutron.v2_0.domain.Network;
+import org.jclouds.openstack.neutron.v2_0.features.NetworkApi;
+import org.jclouds.openstack.neutron.v2_0.functions.ParseNetworkDetails.Networks;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.inject.TypeLiteral;
+
+/**
+ */
+@Beta
+@Singleton
+public class ParseNetworkDetails extends ParseJson<Networks> {
+ static class Networks extends PaginatedCollection<Network> {
+
+ @ConstructorProperties({ "networks", "networks_links" })
+ protected Networks(Iterable<Network> networks, Iterable<Link> networksLinks) {
+ super(networks, networksLinks);
+ }
+
+ }
+
+ @Inject
+ public ParseNetworkDetails(Json json) {
+ super(json, TypeLiteral.get(Networks.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Network, ToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected ToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Network>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.isPresent() ? arg0.get().toString() : null;
+ final NetworkApi networkApi = api.getNetworkApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Network>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Network> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(networkApi.listInDetail(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listNetworksInDetail()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseNetworks.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseNetworks.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseNetworks.java
new file mode 100644
index 0000000..a1c1448
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseNetworks.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2_0.NeutronApi;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.features.NetworkApi;
+import org.jclouds.openstack.neutron.v2_0.functions.ParseNetworks.Networks;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.inject.TypeLiteral;
+
+/**
+ */
+@Beta
+@Singleton
+public class ParseNetworks extends ParseJson<Networks> {
+ static class Networks extends PaginatedCollection<ReferenceWithName> {
+
+ @ConstructorProperties({ "networks", "networks_links" })
+ protected Networks(Iterable<ReferenceWithName> networks, Iterable<Link> networksLinks) {
+ super(networks, networksLinks);
+ }
+
+ }
+
+ @Inject
+ public ParseNetworks(Json json) {
+ super(json, TypeLiteral.get(Networks.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<ReferenceWithName, ToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected ToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<ReferenceWithName>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.isPresent() ? arg0.get().toString() : null;
+ final NetworkApi networkApi = api.getNetworkApiForZone(zone);
+ return new Function<Object, IterableWithMarker<ReferenceWithName>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<ReferenceWithName> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(networkApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listNetworks()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParsePortDetails.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParsePortDetails.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParsePortDetails.java
new file mode 100644
index 0000000..a4e461e
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParsePortDetails.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2_0.NeutronApi;
+import org.jclouds.openstack.neutron.v2_0.domain.Port;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.features.PortApi;
+import org.jclouds.openstack.neutron.v2_0.functions.ParsePortDetails.Ports;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.inject.TypeLiteral;
+
+/**
+ */
+@Beta
+@Singleton
+public class ParsePortDetails extends ParseJson<Ports> {
+ static class Ports extends PaginatedCollection<Port> {
+
+ @ConstructorProperties({ "ports", "ports_links" })
+ protected Ports(Iterable<Port> ports, Iterable<Link> portsLinks) {
+ super(ports, portsLinks);
+ }
+
+ }
+
+ @Inject
+ public ParsePortDetails(Json json) {
+ super(json, TypeLiteral.get(Ports.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<ReferenceWithName, ToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected ToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<ReferenceWithName>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.isPresent() ? arg0.get().toString() : null;
+ final PortApi portApi = api.getPortApiForZone(zone);
+ return new Function<Object, IterableWithMarker<ReferenceWithName>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<ReferenceWithName> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(portApi.listInDetail(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listPortsInDetail()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParsePorts.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParsePorts.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParsePorts.java
new file mode 100644
index 0000000..1a11231
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParsePorts.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2_0.NeutronApi;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.features.PortApi;
+import org.jclouds.openstack.neutron.v2_0.functions.ParsePorts.Ports;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.inject.TypeLiteral;
+
+/**
+ */
+@Beta
+@Singleton
+public class ParsePorts extends ParseJson<Ports> {
+ static class Ports extends PaginatedCollection<ReferenceWithName> {
+
+ @ConstructorProperties({ "ports", "ports_links" })
+ protected Ports(Iterable<ReferenceWithName> ports, Iterable<Link> portsLinks) {
+ super(ports, portsLinks);
+ }
+
+ }
+
+ @Inject
+ public ParsePorts(Json json) {
+ super(json, TypeLiteral.get(Ports.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<ReferenceWithName, ToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected ToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<ReferenceWithName>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.isPresent() ? arg0.get().toString() : null;
+ final PortApi portApi = api.getPortApiForZone(zone);
+ return new Function<Object, IterableWithMarker<ReferenceWithName>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<ReferenceWithName> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(portApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listPorts()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseRouterDetails.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseRouterDetails.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseRouterDetails.java
new file mode 100644
index 0000000..537cc97
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseRouterDetails.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2_0.NeutronApi;
+import org.jclouds.openstack.neutron.v2_0.domain.Router;
+import org.jclouds.openstack.neutron.v2_0.extensions.RouterApi;
+import org.jclouds.openstack.neutron.v2_0.functions.ParseRouterDetails.Routers;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.inject.TypeLiteral;
+
+/**
+ */
+@Beta
+@Singleton
+public class ParseRouterDetails extends ParseJson<Routers> {
+ static class Routers extends PaginatedCollection<Router> {
+
+ @ConstructorProperties({ "routers", "routers_links" })
+ protected Routers(Iterable<Router> routers, Iterable<Link> routersLinks) {
+ super(routers, routersLinks);
+ }
+
+ }
+
+ @Inject
+ public ParseRouterDetails(Json json) {
+ super(json, TypeLiteral.get(Routers.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Router, ToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected ToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Router>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.isPresent() ? arg0.get().toString() : null;
+ final RouterApi routerApi = api.getRouterExtensionForZone(zone).get();
+ return new Function<Object, IterableWithMarker<Router>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Router> apply(Object input) {
+ return IterableWithMarker.class.cast(routerApi.listInDetail(marker(input.toString())));
+ }
+
+ @Override
+ public String toString() {
+ return "listRoutersInDetail()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseRouters.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseRouters.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseRouters.java
new file mode 100644
index 0000000..eb612f4
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseRouters.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2_0.NeutronApi;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.extensions.RouterApi;
+import org.jclouds.openstack.neutron.v2_0.functions.ParseRouters.Routers;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.inject.TypeLiteral;
+
+/**
+ */
+@Beta
+@Singleton
+public class ParseRouters extends ParseJson<Routers> {
+ static class Routers extends PaginatedCollection<ReferenceWithName> {
+
+ @ConstructorProperties({ "routers", "routers_links" })
+ protected Routers(Iterable<ReferenceWithName> routers, Iterable<Link> routersLinks) {
+ super(routers, routersLinks);
+ }
+
+ }
+
+ @Inject
+ public ParseRouters(Json json) {
+ super(json, TypeLiteral.get(Routers.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<ReferenceWithName, ToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected ToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<ReferenceWithName>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.isPresent() ? arg0.get().toString() : null;
+ final RouterApi routerApi = api.getRouterExtensionForZone(zone).get();
+ return new Function<Object, IterableWithMarker<ReferenceWithName>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<ReferenceWithName> apply(Object input) {
+ return IterableWithMarker.class.cast(routerApi.list(marker(input.toString())));
+ }
+
+ @Override
+ public String toString() {
+ return "listRouters()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseSubnetDetails.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseSubnetDetails.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseSubnetDetails.java
new file mode 100644
index 0000000..17201f2
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseSubnetDetails.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2_0.NeutronApi;
+import org.jclouds.openstack.neutron.v2_0.domain.Subnet;
+import org.jclouds.openstack.neutron.v2_0.features.SubnetApi;
+import org.jclouds.openstack.neutron.v2_0.functions.ParseSubnetDetails.Subnets;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.inject.TypeLiteral;
+
+/**
+ */
+@Beta
+@Singleton
+public class ParseSubnetDetails extends ParseJson<Subnets> {
+ static class Subnets extends PaginatedCollection<Subnet> {
+
+ @ConstructorProperties({ "subnets", "subnets_links" })
+ protected Subnets(Iterable<Subnet> subnets, Iterable<Link> subnetsLinks) {
+ super(subnets, subnetsLinks);
+ }
+
+ }
+
+ @Inject
+ public ParseSubnetDetails(Json json) {
+ super(json, TypeLiteral.get(Subnets.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Subnet, ToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected ToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Subnet>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.isPresent() ? arg0.get().toString() : null;
+ final SubnetApi subnetApi = api.getSubnetApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Subnet>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Subnet> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(subnetApi.listInDetail(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listSubnetsInDetail()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseSubnets.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseSubnets.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseSubnets.java
new file mode 100644
index 0000000..bc7ef13
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/functions/ParseSubnets.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2_0.NeutronApi;
+import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName;
+import org.jclouds.openstack.neutron.v2_0.features.SubnetApi;
+import org.jclouds.openstack.neutron.v2_0.functions.ParseSubnets.Subnets;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.inject.TypeLiteral;
+
+/**
+ */
+@Beta
+@Singleton
+public class ParseSubnets extends ParseJson<Subnets> {
+ static class Subnets extends PaginatedCollection<ReferenceWithName> {
+
+ @ConstructorProperties({ "subnets", "subnets_links" })
+ protected Subnets(Iterable<ReferenceWithName> subnets, Iterable<Link> subnetsLinks) {
+ super(subnets, subnetsLinks);
+ }
+
+ }
+
+ @Inject
+ public ParseSubnets(Json json) {
+ super(json, TypeLiteral.get(Subnets.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<ReferenceWithName, ToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected ToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<ReferenceWithName>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.isPresent() ? arg0.get().toString() : null;
+ final SubnetApi subnetApi = api.getSubnetApiForZone(zone);
+ return new Function<Object, IterableWithMarker<ReferenceWithName>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<ReferenceWithName> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(subnetApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listSubnets()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/handlers/NeutronErrorHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/handlers/NeutronErrorHandler.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/handlers/NeutronErrorHandler.java
new file mode 100644
index 0000000..87c28c5
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/handlers/NeutronErrorHandler.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.neutron.v2_0.handlers;
+
+import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
+
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ResourceNotFoundException;
+
+/**
+ * This will parse and set an appropriate exception on the command object.
+ */
+@Singleton
+public class NeutronErrorHandler implements HttpErrorHandler {
+ public void handleError(HttpCommand command, HttpResponse response) {
+ // it is important to always read fully and close streams
+ byte[] data = closeClientButKeepContentStream(response);
+ String message = data != null ? new String(data) : null;
+
+ Exception exception = message != null ? new HttpResponseException(command, response, message)
+ : new HttpResponseException(command, response);
+ message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
+ response.getStatusLine());
+ switch (response.getStatusCode()) {
+ case 400:
+ break;
+ case 401:
+ case 403:
+ exception = new AuthorizationException(message, exception);
+ break;
+ case 404:
+ if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
+ exception = new ResourceNotFoundException(message, exception);
+ }
+ break;
+ }
+ command.setException(exception);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateNetworkBulkOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateNetworkBulkOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateNetworkBulkOptions.java
new file mode 100644
index 0000000..7410839
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/options/CreateNetworkBulkOptions.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.openstack.neutron.v2_0.options;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.neutron.v2_0.domain.BulkNetwork;
+import org.jclouds.openstack.neutron.v2_0.domain.NetworkType;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import javax.inject.Inject;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions.CreateNetworkRequest;
+
+public class CreateNetworkBulkOptions implements MapBinder {
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromCreateNetworkOptions(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected List<BulkNetwork> networks;
+
+ /**
+ * @see org.jclouds.openstack.neutron.v2_0.options.CreateNetworkBulkOptions#getNetworks()
+ */
+ public T networks(Collection<BulkNetwork> networks) {
+ this.networks = ImmutableList.copyOf(networks);
+ return self();
+ }
+
+ public CreateNetworkBulkOptions build() {
+ return new CreateNetworkBulkOptions(networks);
+ }
+
+ public T fromCreateNetworkOptions(CreateNetworkBulkOptions in) {
+ return this.networks(in.getNetworks());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final List<BulkNetwork> networks;
+
+ protected CreateNetworkBulkOptions() {
+ this.networks = Lists.newArrayList();
+ }
+
+ public CreateNetworkBulkOptions(List<BulkNetwork> networks) {
+ this.networks = networks != null ? ImmutableList.copyOf(networks) : Lists.<BulkNetwork>newArrayList();
+ }
+
+ /**
+ * @return the list of networks to create
+ */
+ public List<BulkNetwork> getNetworks() {
+ return networks;
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ List<CreateNetworkRequest> createNetworkRequests = Lists.newArrayList();
+
+ for (BulkNetwork network : this.networks) {
+ if (network.getNetworkType() != null) {
+ //Validations for each NetworkType
+ if (network.getNetworkType() == NetworkType.FLAT) {
+ checkNotNull(network.getPhysicalNetworkName(), "physicalNetworkName must be present when networkType=FLAT");
+ } else if (network.getNetworkType() == NetworkType.VLAN) {
+ checkNotNull(network.getPhysicalNetworkName(), "physicalNetworkName must be present when networkType=VLAN");
+ checkNotNull(network.getSegmentationId(), "segmentationId must be present when networkType=VLAN");
+ } else if (network.getNetworkType() == NetworkType.GRE) {
+ checkNotNull(network.getSegmentationId(), "segmentationId must be present when NetworkType=GRE");
+ }
+ }
+
+ CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
+ if (network.getName() != null)
+ createNetworkRequest.name = network.getName();
+ if (network.getAdminStateUp() != null)
+ createNetworkRequest.admin_state_up = network.getAdminStateUp();
+ if (network.getExternal() != null)
+ createNetworkRequest.external = network.getExternal();
+ if (network.getNetworkType() != null)
+ createNetworkRequest.networkType = network.getNetworkType().getValue();
+ if (network.getPhysicalNetworkName() != null && (network.getNetworkType() == NetworkType.FLAT || network.getNetworkType() == NetworkType.VLAN))
+ createNetworkRequest.physicalNetworkName = network.getPhysicalNetworkName();
+ if (network.getSegmentationId() != null && (network.getNetworkType() == NetworkType.VLAN || network.getNetworkType() == NetworkType.GRE))
+ createNetworkRequest.segmentationId = network.getSegmentationId();
+
+ createNetworkRequests.add(createNetworkRequest);
+ }
+
+ return bindToRequest(request, ImmutableMap.of("networks", createNetworkRequests));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}
[08/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java
new file mode 100644
index 0000000..bd0a4d1
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java
@@ -0,0 +1,322 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.network.DhcpService;
+import org.jclouds.vcloud.domain.network.Features;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.jclouds.vcloud.domain.network.FirewallService;
+import org.jclouds.vcloud.domain.network.IpRange;
+import org.jclouds.vcloud.domain.network.IpScope;
+import org.jclouds.vcloud.domain.network.NatService;
+import org.jclouds.vcloud.domain.network.OrgNetwork;
+import org.jclouds.vcloud.domain.network.firewall.FirewallPolicy;
+import org.jclouds.vcloud.domain.network.firewall.FirewallProtocols;
+import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
+import org.jclouds.vcloud.domain.network.internal.OrgNetworkImpl;
+import org.jclouds.vcloud.domain.network.nat.NatPolicy;
+import org.jclouds.vcloud.domain.network.nat.NatProtocol;
+import org.jclouds.vcloud.domain.network.nat.NatRule;
+import org.jclouds.vcloud.domain.network.nat.NatType;
+import org.jclouds.vcloud.domain.network.nat.rules.MappingMode;
+import org.jclouds.vcloud.domain.network.nat.rules.OneToOneVmRule;
+import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
+import org.jclouds.vcloud.domain.network.nat.rules.VmRule;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+public class OrgNetworkHandler extends ParseSax.HandlerWithResult<OrgNetwork> {
+
+ protected final TaskHandler taskHandler;
+
+ @Inject
+ public OrgNetworkHandler(TaskHandler taskHandler) {
+ this.taskHandler = taskHandler;
+ }
+
+ protected StringBuilder currentText = new StringBuilder();
+
+ protected ReferenceType network;
+ protected ReferenceType org;
+ protected String orgDescription;
+ protected List<Task> tasks = Lists.newArrayList();
+
+ protected String startAddress;
+ protected String endAddress;
+
+ protected boolean inherited;
+ protected String gateway;
+ protected String netmask;
+ protected String dns1;
+ protected String dns2;
+ protected String dnsSuffix;
+ protected Set<IpRange> ipRanges = Sets.newLinkedHashSet();
+ protected Set<String> allocatedIpAddresses = Sets.newLinkedHashSet();
+
+ protected IpScope ipScope;
+ protected ReferenceType parentNetwork;
+ protected FenceMode fenceMode;
+
+ protected boolean serviceEnabled;
+ protected Integer defaultLeaseTime;
+ protected Integer maxLeaseTime;
+
+ protected DhcpService dhcpService;
+
+ protected boolean inFirewallRule;
+ protected boolean firewallRuleEnabled;
+ protected String firewallRuleDescription;
+ protected FirewallPolicy firewallPolicy;
+
+ protected boolean tcp;
+ protected boolean udp;
+ protected FirewallProtocols protocols;
+ protected int port;
+ protected String destinationIp;
+
+ protected List<FirewallRule> firewallRules = Lists.newArrayList();
+ protected FirewallService firewallService;
+
+ protected NatType natType;
+ protected NatPolicy natPolicy;
+
+ protected MappingMode mappingMode;
+ protected String externalIP;
+ protected String vAppScopedVmId;
+ protected int vmNicId;
+
+ protected int externalPort;
+ protected String internalIP;
+ protected int internalPort;
+ protected NatProtocol natProtocol;
+
+ protected String vAppScopedLocalId;
+
+ protected List<NatRule> natRules = Lists.newArrayList();
+ protected NatService natService;
+
+ protected Features features;
+ protected OrgNetwork.Configuration configuration;
+
+ protected ReferenceType networkPool;
+ protected Set<String> allowedExternalIpAddresses = Sets.newLinkedHashSet();
+
+ public OrgNetwork getResult() {
+ return new OrgNetworkImpl(network.getName(), network.getType(), network.getHref(), org, orgDescription, tasks,
+ configuration, networkPool, allowedExternalIpAddresses);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (SaxUtils.equalsOrSuffix(qName, "OrgNetwork")) {
+ network = newReferenceType(attributes);
+ } else if (SaxUtils.equalsOrSuffix(qName, "FirewallRule")) {
+ this.inFirewallRule = true;
+ } else if (SaxUtils.equalsOrSuffix(qName, "ParentNetwork")) {
+ parentNetwork = newReferenceType(attributes);
+ } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) {
+ org = newReferenceType(attributes);
+ } else {
+ taskHandler.startElement(uri, localName, qName, attrs);
+ }
+ String type = attributes.get("type");
+ if (type != null) {
+ if (type.indexOf("networkPool+xml") != -1) {
+ networkPool = newReferenceType(attributes);
+ }
+ }
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ taskHandler.endElement(uri, name, qName);
+ if (SaxUtils.equalsOrSuffix(qName, "Task")) {
+ this.tasks.add(taskHandler.getResult());
+ } else if (SaxUtils.equalsOrSuffix(qName, "Description")) {
+ if (inFirewallRule)
+ firewallRuleDescription = currentOrNull();
+ else
+ orgDescription = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "FenceMode")) {
+ fenceMode = FenceMode.fromValue(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "StartAddress")) {
+ startAddress = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "EndAddress")) {
+ endAddress = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "AllocatedIpAddress")) {
+ allocatedIpAddresses.add(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "IpRange")) {
+ ipRanges.add(new IpRange(startAddress, endAddress));
+ this.startAddress = null;
+ this.endAddress = null;
+ } else if (SaxUtils.equalsOrSuffix(qName, "IsInherited")) {
+ inherited = Boolean.parseBoolean(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "Gateway")) {
+ gateway = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "Netmask")) {
+ netmask = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "Dns1")) {
+ dns1 = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "Dns2")) {
+ dns2 = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "DnsSuffix")) {
+ dnsSuffix = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "IpScope")) {
+ ipScope = new IpScope(inherited, gateway, netmask, dns1, dns2, dnsSuffix, ipRanges, allocatedIpAddresses);
+ this.inherited = false;
+ this.gateway = null;
+ this.netmask = null;
+ this.dns1 = null;
+ this.dns2 = null;
+ this.dnsSuffix = null;
+ this.ipRanges = Sets.newLinkedHashSet();
+ this.allocatedIpAddresses = Sets.newLinkedHashSet();
+ } else if (SaxUtils.equalsOrSuffix(qName, "IsEnabled")) {
+ if (inFirewallRule)
+ firewallRuleEnabled = Boolean.parseBoolean(currentOrNull());
+ else
+ serviceEnabled = Boolean.parseBoolean(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "DefaultLeaseTime")) {
+ defaultLeaseTime = Integer.parseInt(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "MaxLeaseTime")) {
+ maxLeaseTime = Integer.parseInt(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "DhcpService")) {
+ this.dhcpService = new DhcpService(serviceEnabled, defaultLeaseTime, maxLeaseTime, Iterables
+ .getOnlyElement(ipRanges));
+ this.serviceEnabled = false;
+ this.defaultLeaseTime = null;
+ this.maxLeaseTime = null;
+ this.ipRanges = Sets.newLinkedHashSet();
+ } else if (SaxUtils.equalsOrSuffix(qName, "Policy")) {
+ if (inFirewallRule)
+ firewallPolicy = FirewallPolicy.fromValue(currentOrNull());
+ else
+ natPolicy = NatPolicy.fromValue(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "Tcp")) {
+ tcp = Boolean.parseBoolean(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "Udp")) {
+ udp = Boolean.parseBoolean(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "Protocols")) {
+ this.protocols = new FirewallProtocols(tcp, udp);
+ this.tcp = false;
+ this.udp = false;
+ } else if (SaxUtils.equalsOrSuffix(qName, "DestinationIp")) {
+ this.destinationIp = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "FirewallRule")) {
+ this.inFirewallRule = false;
+ this.firewallRules.add(new FirewallRule(firewallRuleEnabled, firewallRuleDescription, firewallPolicy,
+ protocols, port, destinationIp));
+ this.firewallRuleEnabled = false;
+ this.firewallRuleDescription = null;
+ this.firewallPolicy = null;
+ this.protocols = null;
+ this.port = -1;
+ this.destinationIp = null;
+ } else if (SaxUtils.equalsOrSuffix(qName, "FirewallService")) {
+ firewallService = new FirewallService(serviceEnabled, firewallRules);
+ this.serviceEnabled = false;
+ this.firewallRules = Lists.newArrayList();
+ } else if (SaxUtils.equalsOrSuffix(qName, "NatType")) {
+ natType = NatType.fromValue(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "MappingMode")) {
+ mappingMode = MappingMode.fromValue(currentOrNull());
+ } else if (qName.equalsIgnoreCase("ExternalIPAddress")) {
+ externalIP = currentOrNull();
+ } else if (qName.equalsIgnoreCase("VAppScopedVmId")) {
+ vAppScopedVmId = currentOrNull();
+ } else if (qName.equalsIgnoreCase("VAppScopedLocalId")) {
+ vAppScopedLocalId = currentOrNull();
+ } else if (qName.equalsIgnoreCase("vmNicId")) {
+ vmNicId = Integer.parseInt(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "OneToOneVmRule")) {
+ natRules.add(new OneToOneVmRule(mappingMode, externalIP, vAppScopedVmId, vmNicId));
+ this.mappingMode = null;
+ this.externalIP = null;
+ this.vAppScopedVmId = null;
+ this.vmNicId = -1;
+ } else if (qName.equalsIgnoreCase("ExternalPort")) {
+ externalPort = Integer.parseInt(currentOrNull());
+ } else if (qName.equalsIgnoreCase("InternalIPAddress")) {
+ internalIP = currentOrNull();
+ } else if (qName.equalsIgnoreCase("InternalPort")) {
+ internalPort = Integer.parseInt(currentOrNull());
+ } else if (equalsOrSuffix(qName, "Protocol")) {
+ natProtocol = NatProtocol.valueOf(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "PortForwardingRule")) {
+ natRules.add(new PortForwardingRule(externalIP, externalPort, internalIP, internalPort, natProtocol));
+ this.externalIP = null;
+ this.externalPort = -1;
+ this.internalIP = null;
+ this.internalPort = -1;
+ this.natProtocol = null;
+ } else if (SaxUtils.equalsOrSuffix(qName, "VmRule")) {
+ natRules.add(new VmRule(externalIP, externalPort, vAppScopedLocalId, vmNicId, internalPort, natProtocol));
+ this.externalIP = null;
+ this.externalPort = -1;
+ this.vAppScopedLocalId = null;
+ this.vmNicId = -1;
+ this.internalPort = -1;
+ this.natProtocol = null;
+ } else if (SaxUtils.equalsOrSuffix(qName, "NatService")) {
+ this.natService = new NatService(serviceEnabled, natType, natPolicy, natRules);
+ this.serviceEnabled = false;
+ this.natType = null;
+ this.natPolicy = null;
+ this.natRules = Lists.newArrayList();
+ } else if (SaxUtils.equalsOrSuffix(qName, "Features")) {
+ this.features = new Features(dhcpService, firewallService, natService);
+ this.dhcpService = null;
+ this.firewallService = null;
+ this.natService = null;
+ } else if (SaxUtils.equalsOrSuffix(qName, "Configuration")) {
+ configuration = new OrgNetworkImpl.ConfigurationImpl(ipScope, parentNetwork, fenceMode, features);
+ this.ipScope = null;
+ this.parentNetwork = null;
+ this.fenceMode = null;
+ this.features = null;
+ } else if (SaxUtils.equalsOrSuffix(qName, "AllowedExternalIpAddress")) {
+ allowedExternalIpAddresses.add(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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java
new file mode 100644
index 0000000..3e393ac
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import java.net.URI;
+import java.util.SortedMap;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+
+import com.google.common.collect.Maps;
+
+public class SupportedVersionsHandler extends ParseSax.HandlerWithResult<SortedMap<String, URI>> {
+ private StringBuilder currentText = new StringBuilder();
+
+ private SortedMap<String, URI> contents = Maps.newTreeMap();
+ private String version;
+ private URI location;
+
+ public SortedMap<String, URI> getResult() {
+ return contents;
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ if (SaxUtils.equalsOrSuffix(qName, "Version")) {
+ version = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "LoginUrl")) {
+ location = URI.create(currentOrNull());
+ } else if (SaxUtils.equalsOrSuffix(qName, "VersionInfo")) {
+ contents.put(version, location);
+ }
+ 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java
new file mode 100644
index 0000000..fd421ab
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+
+import org.jclouds.date.DateService;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.logging.Logger;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.TaskStatus;
+import org.jclouds.vcloud.domain.VCloudError;
+import org.jclouds.vcloud.domain.internal.TaskImpl;
+import org.jclouds.vcloud.util.Utils;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
+ protected final DateService dateService;
+ private String operation;
+ private ReferenceType taskLink;
+ private ReferenceType owner;
+ private TaskStatus status;
+ private Date startTime;
+ private Date endTime;
+ private Date expiryTime;
+ private Task task;
+ private VCloudError error;
+ private boolean inOwner;
+
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ @Inject
+ public TaskHandler(DateService dateService) {
+ this.dateService = dateService;
+ }
+
+ public Task getResult() {
+ return task;
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (equalsOrSuffix(qName, "Task")) {
+ if (attributes.get("href") != null && !inOwner)// queued tasks may not have an
+ // href yet
+ taskLink = Utils.newReferenceType(attributes);
+ status = TaskStatus.fromValue(attributes.get("status"));
+ operation = attributes.get("operation");
+ if (attributes.containsKey("startTime"))
+ startTime = parseDate(attributes.get("startTime"));
+ if (attributes.containsKey("endTime"))
+ endTime = parseDate(attributes.get("endTime"));
+ if (attributes.containsKey("expiryTime"))
+ expiryTime = parseDate(attributes.get("expiryTime"));
+ // TODO technically the old Result object should only be owner for copy and delete tasks
+ } else if (equalsOrSuffix(qName, "Owner") || equalsOrSuffix(qName, "Result")) {
+ owner = Utils.newReferenceType(attributes);
+ } else if (equalsOrSuffix(qName, "Link") && "self".equals(attributes.get("rel"))) {
+ taskLink = Utils.newReferenceType(attributes);
+ } else if (equalsOrSuffix(qName, "Error")) {
+ error = Utils.newError(attributes);
+ }
+ }
+
+ private Date parseDate(String toParse) {
+ try {
+ return dateService.iso8601DateParse(toParse);
+ } catch (RuntimeException e) {
+ if (e.getCause() instanceof ParseException) {
+ if (!toParse.endsWith("Z"))
+ toParse += "Z";
+ return dateService.iso8601SecondsDateParse(toParse);
+ } else {
+ logger.error(e, "error parsing date");
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) {
+ if (equalsOrSuffix(qName, "Task")) {
+ this.task = new TaskImpl(taskLink.getHref(), operation, status, startTime, endTime, expiryTime, owner, error);
+ operation = null;
+ taskLink = null;
+ status = null;
+ startTime = null;
+ endTime = null;
+ owner = null;
+ error = null;
+ } else if (equalsOrSuffix(qName, "Owner")) {
+ inOwner = false;
+ }
+ }
+
+ public void characters(char ch[], int start, int length) {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java
new file mode 100644
index 0000000..47ef461
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import java.util.Map;
+import java.util.SortedSet;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.TasksList;
+import org.jclouds.vcloud.domain.internal.TasksListImpl;
+import org.jclouds.vcloud.util.Utils;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Sets;
+
+public class TasksListHandler extends ParseSax.HandlerWithResult<TasksList> {
+
+ private SortedSet<Task> tasks = Sets.newTreeSet();
+ private final TaskHandler taskHandler;
+ private ReferenceType resource;
+
+ @Inject
+ public TasksListHandler(TaskHandler taskHandler) {
+ this.taskHandler = taskHandler;
+ }
+
+ public TasksList getResult() {
+ return new TasksListImpl(resource.getHref(), tasks);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (SaxUtils.equalsOrSuffix(qName, "TasksList")) {
+ resource = Utils.newReferenceType(attributes);
+ } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "self".equals(attributes.get("rel"))) {
+ resource = Utils.newReferenceType(attributes);
+ } else {
+ taskHandler.startElement(uri, localName, qName, attrs);
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ taskHandler.endElement(uri, localName, qName);
+ if (SaxUtils.equalsOrSuffix(qName, "Task")) {
+ this.tasks.add(taskHandler.getResult());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java
new file mode 100644
index 0000000..34ac869
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.internal.VAppImpl;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
+import org.jclouds.vcloud.xml.ovf.VCloudNetworkSectionHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
+
+ protected final TaskHandler taskHandler;
+ protected final VmHandler vmHandler;
+ protected final VCloudNetworkSectionHandler networkSectionHandler;
+
+ @Inject
+ public VAppHandler(TaskHandler taskHandler, VmHandler vmHandler,
+ VCloudNetworkSectionHandler networkSectionHandler) {
+ this.taskHandler = taskHandler;
+ this.vmHandler = vmHandler;
+ this.networkSectionHandler = networkSectionHandler;
+ }
+
+ protected StringBuilder currentText = new StringBuilder();
+
+ protected ReferenceType template;
+ protected Status status;
+ protected ReferenceType vdc;
+ protected String description;
+ protected List<Task> tasks = Lists.newArrayList();
+ protected boolean ovfDescriptorUploaded = true;
+
+ private boolean inChildren;
+ private boolean inTasks;
+ private boolean inNetworkSection;
+ protected Set<Vm> children = Sets.newLinkedHashSet();
+ private VCloudNetworkSection networkSection;
+
+ public VApp getResult() {
+ return new VAppImpl(template.getName(), template.getType(), template.getHref(), status, vdc, description, tasks,
+ ovfDescriptorUploaded, children, networkSection);
+ }
+
+ protected int depth = 0;
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ depth++;
+ if (depth == 2) {
+ if (equalsOrSuffix(qName, "Children")) {
+ inChildren = true;
+ } else if (equalsOrSuffix(qName, "Tasks")) {
+ inTasks = true;
+ } else if (equalsOrSuffix(qName, "NetworkSection")) {
+ inNetworkSection = true;
+ }
+ }
+ if (inChildren) {
+ vmHandler.startElement(uri, localName, qName, attrs);
+ } else if (inTasks) {
+ taskHandler.startElement(uri, localName, qName, attrs);
+ } else if (inNetworkSection) {
+ networkSectionHandler.startElement(uri, localName, qName, attrs);
+ } else if (equalsOrSuffix(qName, "VApp")) {
+ template = newReferenceType(attributes);
+ if (attributes.containsKey("status"))
+ this.status = Status.fromValue(Integer.parseInt(attributes.get("status")));
+ } else if (equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) {
+ vdc = newReferenceType(attributes);
+ }
+
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ depth--;
+ if (depth == 1) {
+ if (equalsOrSuffix(qName, "Children")) {
+ inChildren = false;
+ this.children.add(vmHandler.getResult());
+ } else if (equalsOrSuffix(qName, "Tasks")) {
+ inTasks = false;
+ this.tasks.add(taskHandler.getResult());
+ } else if (equalsOrSuffix(qName, "Description")) {
+ description = SaxUtils.currentOrNull(currentText);
+ } else if (equalsOrSuffix(qName, "NetworkSection")) {
+ inNetworkSection = false;
+ this.networkSection = networkSectionHandler.getResult();
+ }
+ }
+ if (inChildren) {
+ vmHandler.endElement(uri, name, qName);
+ } else if (inTasks) {
+ taskHandler.endElement(uri, name, qName);
+ } else if (inNetworkSection) {
+ networkSectionHandler.endElement(uri, name, qName);
+ } else if (equalsOrSuffix(qName, "ovfDescriptorUploaded")) {
+ ovfDescriptorUploaded = Boolean.parseBoolean(SaxUtils.currentOrNull(currentText));
+ }
+ currentText = new StringBuilder();
+ }
+
+ public void characters(char ch[], int start, int length) {
+ if (inTasks)
+ taskHandler.characters(ch, start, length);
+ else if (inChildren)
+ vmHandler.characters(ch, start, length);
+ else if (inNetworkSection)
+ networkSectionHandler.characters(ch, start, length);
+ else
+ currentText.append(ch, start, length);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java
new file mode 100644
index 0000000..2476c16
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.internal.VAppTemplateImpl;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
+import org.jclouds.vcloud.xml.ovf.VCloudNetworkSectionHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate> {
+
+ protected final TaskHandler taskHandler;
+ protected final VmHandler vmHandler;
+ protected final VCloudNetworkSectionHandler networkSectionHandler;
+
+ @Inject
+ public VAppTemplateHandler(TaskHandler taskHandler, VmHandler vmHandler,
+ VCloudNetworkSectionHandler networkSectionHandler) {
+ this.taskHandler = taskHandler;
+ this.vmHandler = vmHandler;
+ this.networkSectionHandler = networkSectionHandler;
+ }
+
+ protected StringBuilder currentText = new StringBuilder();
+
+ protected ReferenceType template;
+ protected Status status;
+ protected ReferenceType vdc;
+ protected String description;
+ protected List<Task> tasks = Lists.newArrayList();
+ protected boolean ovfDescriptorUploaded = true;
+ protected String vAppScopedLocalId;
+
+ private boolean inChildren;
+ private boolean inTasks;
+ private boolean inNetworkSection;
+ protected Set<Vm> children = Sets.newLinkedHashSet();
+ private VCloudNetworkSection networkSection;
+
+ public VAppTemplate getResult() {
+ return new VAppTemplateImpl(template.getName(), template.getType(), template.getHref(), status, vdc, description,
+ tasks, ovfDescriptorUploaded, vAppScopedLocalId, children, networkSection);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (equalsOrSuffix(qName, "Children")) {
+ inChildren = true;
+ } else if (equalsOrSuffix(qName, "Tasks")) {
+ inTasks = true;
+ } else if (equalsOrSuffix(qName, "NetworkSection")) {
+ inNetworkSection = true;
+ }
+ if (inChildren) {
+ vmHandler.startElement(uri, localName, qName, attrs);
+ } else if (inTasks) {
+ taskHandler.startElement(uri, localName, qName, attrs);
+ } else if (inNetworkSection) {
+ networkSectionHandler.startElement(uri, localName, qName, attrs);
+ } else if (equalsOrSuffix(qName, "VAppTemplate")) {
+ template = newReferenceType(attributes);
+ if (attributes.containsKey("status"))
+ this.status = Status.fromValue(Integer.parseInt(attributes.get("status")));
+ } else if (equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) {
+ vdc = newReferenceType(attributes);
+ }
+
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ if (equalsOrSuffix(qName, "Children")) {
+ inChildren = false;
+ Vm vm = vmHandler.getResult();
+ if (vm != null)
+ this.children.add(vmHandler.getResult());
+ } else if (equalsOrSuffix(qName, "Tasks")) {
+ inTasks = false;
+ this.tasks.add(taskHandler.getResult());
+ } else if (equalsOrSuffix(qName, "NetworkSection")) {
+ inNetworkSection = false;
+ this.networkSection = networkSectionHandler.getResult();
+ }
+ if (inChildren) {
+ vmHandler.endElement(uri, name, qName);
+ } else if (inTasks) {
+ taskHandler.endElement(uri, name, qName);
+ } else if (inNetworkSection) {
+ networkSectionHandler.endElement(uri, name, qName);
+ } else if (equalsOrSuffix(qName, "Description")) {
+ description = currentOrNull();
+ } else if (equalsOrSuffix(qName, "VAppScopedLocalId")) {
+ vAppScopedLocalId = currentOrNull();
+ } else if (equalsOrSuffix(qName, "ovfDescriptorUploaded")) {
+ ovfDescriptorUploaded = Boolean.parseBoolean(currentOrNull());
+ }
+ currentText = new StringBuilder();
+ }
+
+ public void characters(char ch[], int start, int length) {
+ if (inTasks)
+ taskHandler.characters(ch, start, length);
+ else if (inChildren)
+ vmHandler.characters(ch, start, length);
+ else if (inNetworkSection)
+ networkSectionHandler.characters(ch, start, length);
+ else
+ currentText.append(ch, start, length);
+ }
+
+ protected String currentOrNull() {
+ String returnVal = currentText.toString().trim();
+ return returnVal.equals("") ? null : returnVal;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java
new file mode 100644
index 0000000..cf6f6e5
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.ovf.VirtualHardwareSection;
+import org.jclouds.ovf.xml.VirtualHardwareSectionHandler;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
+import org.xml.sax.Attributes;
+
+public class VCloudVirtualHardwareHandler extends ParseSax.HandlerWithResult<VCloudVirtualHardwareSection> {
+
+ private final VirtualHardwareSectionHandler hardwareHandler;
+
+ private ReferenceType hardware;
+
+ @Inject
+ public VCloudVirtualHardwareHandler(VirtualHardwareSectionHandler hardwareHandler) {
+ this.hardwareHandler = hardwareHandler;
+ }
+
+ public VCloudVirtualHardwareSection getResult() {
+ VirtualHardwareSection hardware = hardwareHandler.getResult();
+ return new VCloudVirtualHardwareSection(this.hardware.getType(), this.hardware.getHref(), hardware.getInfo(), hardware
+ .getTransports(), hardware.getSystem(), hardware.getItems());
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attrs) {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (qName.endsWith("VirtualHardwareSection")) {
+ hardware = newReferenceType(attributes);
+ }
+ hardwareHandler.startElement(uri, localName, qName, attrs);
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) {
+ hardwareHandler.endElement(uri, localName, qName);
+
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) {
+ hardwareHandler.characters(ch, start, length);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java
new file mode 100644
index 0000000..a7670be
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+import static org.jclouds.vcloud.util.Utils.putReferenceType;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.AllocationModel;
+import org.jclouds.vcloud.domain.Capacity;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.domain.VDCStatus;
+import org.jclouds.vcloud.domain.internal.VDCImpl;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class VDCHandler extends ParseSax.HandlerWithResult<VDC> {
+
+ protected final TaskHandler taskHandler;
+
+ @Inject
+ public VDCHandler(TaskHandler taskHandler) {
+ this.taskHandler = taskHandler;
+ }
+
+ protected StringBuilder currentText = new StringBuilder();
+
+ protected ReferenceType vDC;
+ protected VDCStatus status = VDCStatus.READY;
+ protected ReferenceType org;
+ protected String description;
+ protected List<Task> tasks = Lists.newArrayList();
+ protected AllocationModel allocationModel = AllocationModel.UNRECOGNIZED;
+
+ protected Capacity storageCapacity;
+ protected Capacity cpuCapacity;
+ protected Capacity memoryCapacity;
+
+ protected String units;
+ protected long allocated = 0;
+ protected long limit = 0;
+ protected int used = 0;
+ protected long overhead = 0;
+
+ protected Map<String, ReferenceType> resourceEntities = Maps.newLinkedHashMap();
+ protected Map<String, ReferenceType> availableNetworks = Maps.newLinkedHashMap();
+
+ protected int nicQuota;
+ protected int networkQuota;
+ protected int vmQuota;
+ protected boolean isEnabled = true;
+
+ public VDC getResult() {
+ return new VDCImpl(vDC.getName(), vDC.getType(), vDC.getHref(), status, org, description, tasks, allocationModel,
+ storageCapacity, cpuCapacity, memoryCapacity, resourceEntities, availableNetworks, nicQuota,
+ networkQuota, vmQuota, isEnabled);
+ }
+
+ void resetCapacity() {
+ units = null;
+ allocated = 0;
+ limit = 0;
+ used = 0;
+ overhead = 0;
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ 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.endsWith("Network")) {
+ putReferenceType(availableNetworks, attributes);
+ } else if (qName.endsWith("ResourceEntity")) {
+ putReferenceType(resourceEntities, attributes);
+ } else if (qName.endsWith("Link") && "up".equals(attributes.get("rel"))) {
+ org = newReferenceType(attributes);
+ } else {
+ taskHandler.startElement(uri, localName, qName, attrs);
+ }
+
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ taskHandler.endElement(uri, name, qName);
+ if (qName.endsWith("Task")) {
+ this.tasks.add(taskHandler.getResult());
+ } else if (qName.endsWith("Description")) {
+ description = currentOrNull();
+ } else if (qName.endsWith("AllocationModel")) {
+ allocationModel = AllocationModel.fromValue(currentOrNull());
+ } else if (qName.endsWith("Units")) {
+ units = currentOrNull();
+ } else if (qName.endsWith("Allocated")) {
+ allocated = Integer.parseInt(currentOrNull());
+ } else if (qName.endsWith("Used")) {
+ used = Integer.parseInt(currentOrNull());
+ } else if (qName.endsWith("Limit")) {
+ limit = Integer.parseInt(currentOrNull());
+ } else if (qName.endsWith("Overhead")) {
+ overhead = Integer.parseInt(currentOrNull());
+ } else if (qName.endsWith("StorageCapacity")) {
+ storageCapacity = new Capacity(units, allocated, limit, used, overhead);
+ resetCapacity();
+ } else if (qName.endsWith("Cpu")) {
+ cpuCapacity = new Capacity(units, allocated, limit, used, overhead);
+ resetCapacity();
+ } else if (qName.endsWith("Memory")) {
+ memoryCapacity = new Capacity(units, allocated, limit, used, overhead);
+ resetCapacity();
+ } else if (qName.endsWith("DeployedVmsQuota")) {
+ vmQuota = (int) limit;
+ // vcloud express doesn't have the zero is unlimited rule
+ if (vmQuota == -1)
+ vmQuota = 0;
+ } else if (qName.endsWith("VmQuota")) {
+ vmQuota = Integer.parseInt(currentOrNull());
+ } else if (qName.endsWith("NicQuota")) {
+ nicQuota = Integer.parseInt(currentOrNull());
+ } else if (qName.endsWith("NetworkQuota")) {
+ networkQuota = Integer.parseInt(currentOrNull());
+ } else if (qName.endsWith("IsEnabled")) {
+ isEnabled = Boolean.parseBoolean(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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java
new file mode 100644
index 0000000..dd04477
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.GuestCustomizationSection;
+import org.jclouds.vcloud.domain.NetworkConnectionSection;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.internal.VmImpl;
+import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
+import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
+import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.google.common.collect.Lists;
+
+public class VmHandler extends ParseSax.HandlerWithResult<Vm> {
+
+ protected final TaskHandler taskHandler;
+ protected final VCloudVirtualHardwareHandler virtualHardwareHandler;
+ protected final VCloudOperatingSystemHandler operatingSystemHandler;
+ protected final GuestCustomizationSectionHandler guestCustomizationHandler;
+ protected final NetworkConnectionSectionHandler networkConnectionSectionHandler;
+
+ @Inject
+ public VmHandler(TaskHandler taskHandler, VCloudVirtualHardwareHandler virtualHardwareHandler,
+ VCloudOperatingSystemHandler operatingSystemHandler,
+ NetworkConnectionSectionHandler networkConnectionSectionHandler,
+ GuestCustomizationSectionHandler guestCustomizationHandler) {
+ this.taskHandler = taskHandler;
+ this.virtualHardwareHandler = virtualHardwareHandler;
+ this.operatingSystemHandler = operatingSystemHandler;
+ this.networkConnectionSectionHandler = networkConnectionSectionHandler;
+ this.guestCustomizationHandler = guestCustomizationHandler;
+ }
+
+ protected StringBuilder currentText = new StringBuilder();
+
+ protected ReferenceType vm;
+ protected Status status;
+ protected ReferenceType vdc;
+ protected String description;
+ protected List<Task> tasks = Lists.newArrayList();
+ protected VCloudVirtualHardwareSection hardware;
+ protected VCloudOperatingSystemSection os;
+ protected NetworkConnectionSection networkConnectionSection;
+ protected GuestCustomizationSection guestCustomization;
+ protected String vAppScopedLocalId;
+
+ private boolean inTasks;
+ private boolean inHardware;
+ private boolean inOs;
+ private boolean inNetworkConnectionSection;
+ private boolean inGuestCustomization;
+
+ public Vm getResult() {
+ return vm == null ? null : new VmImpl(vm.getName(), vm.getType(), vm.getHref(), status, vdc, description, tasks,
+ hardware, os, networkConnectionSection, guestCustomization, vAppScopedLocalId);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (qName.endsWith("VirtualHardwareSection")) {
+ inHardware = true;
+ } else if (qName.endsWith("OperatingSystemSection")) {
+ inOs = true;
+ } else if (qName.endsWith("GuestCustomizationSection")) {
+ inGuestCustomization = true;
+ } else if (qName.endsWith("NetworkConnectionSection")) {
+ inNetworkConnectionSection = true;
+ } else if (qName.endsWith("Tasks")) {
+ inTasks = true;
+ }
+ if (inHardware) {
+ virtualHardwareHandler.startElement(uri, localName, qName, attrs);
+ } else if (inOs) {
+ operatingSystemHandler.startElement(uri, localName, qName, attrs);
+ } else if (inNetworkConnectionSection) {
+ networkConnectionSectionHandler.startElement(uri, localName, qName, attrs);
+ } else if (inGuestCustomization) {
+ guestCustomizationHandler.startElement(uri, localName, qName, attrs);
+ } else if (inTasks) {
+ taskHandler.startElement(uri, localName, qName, attrs);
+ } else if (SaxUtils.equalsOrSuffix(qName, "Vm")) {
+ vm = newReferenceType(attributes);
+ String status = attributes.get("status");
+ if (status != null)
+ this.status = Status.fromValue(Integer.parseInt(status));
+ } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) {
+ vdc = newReferenceType(attributes);
+ }
+ }
+
+ public void endElement(String uri, String name, String qName) {
+ if (qName.endsWith("VirtualHardwareSection")) {
+ inHardware = false;
+ this.hardware = virtualHardwareHandler.getResult();
+ } else if (qName.endsWith("OperatingSystemSection")) {
+ inOs = false;
+ os = operatingSystemHandler.getResult();
+ } else if (qName.endsWith("NetworkConnectionSection")) {
+ inNetworkConnectionSection = false;
+ networkConnectionSection = networkConnectionSectionHandler.getResult();
+ } else if (qName.endsWith("GuestCustomizationSection")) {
+ inGuestCustomization = false;
+ guestCustomization = guestCustomizationHandler.getResult();
+ } else if (qName.endsWith("Tasks")) {
+ inTasks = false;
+ this.tasks.add(taskHandler.getResult());
+ }
+ if (inHardware) {
+ virtualHardwareHandler.endElement(uri, name, qName);
+ } else if (inOs) {
+ operatingSystemHandler.endElement(uri, name, qName);
+ } else if (inGuestCustomization) {
+ guestCustomizationHandler.endElement(uri, name, qName);
+ } else if (inNetworkConnectionSection) {
+ networkConnectionSectionHandler.endElement(uri, name, qName);
+ } else if (inTasks) {
+ taskHandler.endElement(uri, name, qName);
+ } else if (SaxUtils.equalsOrSuffix(qName, "Description")) {
+ description = currentOrNull();
+ } else if (SaxUtils.equalsOrSuffix(qName, "VAppScopedLocalId")) {
+ vAppScopedLocalId = currentOrNull();
+ }
+ currentText = new StringBuilder();
+ }
+
+ public void characters(char ch[], int start, int length) {
+ if (inHardware)
+ virtualHardwareHandler.characters(ch, start, length);
+ else if (inOs)
+ operatingSystemHandler.characters(ch, start, length);
+ else if (inGuestCustomization)
+ guestCustomizationHandler.characters(ch, start, length);
+ else if (inNetworkConnectionSection)
+ networkConnectionSectionHandler.characters(ch, start, length);
+ else if (inTasks)
+ taskHandler.characters(ch, start, length);
+ else
+ currentText.append(ch, start, length);
+ }
+
+ protected String currentOrNull() {
+ String returnVal = currentText.toString().trim();
+ return returnVal.equals("") ? null : returnVal;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java
new file mode 100644
index 0000000..39013bf
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml.ovf;
+
+import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.ovf.NetworkSection;
+import org.jclouds.ovf.xml.NetworkSectionHandler;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
+import org.jclouds.vcloud.util.Utils;
+import org.xml.sax.Attributes;
+
+public class VCloudNetworkSectionHandler extends ParseSax.HandlerWithResult<VCloudNetworkSection> {
+ private final NetworkSectionHandler networkSectionHandler;
+
+ @Inject
+ VCloudNetworkSectionHandler(NetworkSectionHandler networkSectionHandler) {
+ this.networkSectionHandler = networkSectionHandler;
+ }
+
+ private ReferenceType net;
+
+ public VCloudNetworkSection getResult() {
+ NetworkSection system = networkSectionHandler.getResult();
+ return new VCloudNetworkSection(net.getType(), net.getHref(), system.getInfo(), system.getNetworks());
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attrs) {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (equalsOrSuffix(qName, "NetworkSection")) {
+ this.net = Utils.newReferenceType(attributes);
+ }
+ networkSectionHandler.startElement(uri, localName, qName, attrs);
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) {
+ networkSectionHandler.endElement(uri, localName, qName);
+ }
+
+ public void characters(char ch[], int start, int length) {
+ networkSectionHandler.characters(ch, start, length);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java
new file mode 100644
index 0000000..058e76a
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml.ovf;
+
+import static org.jclouds.vcloud.util.Utils.newReferenceType;
+
+import java.util.Map;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
+import org.jclouds.vcloud.util.Utils;
+import org.xml.sax.Attributes;
+
+public class VCloudOperatingSystemHandler extends ParseSax.HandlerWithResult<VCloudOperatingSystemSection> {
+ private StringBuilder currentText = new StringBuilder();
+
+ protected ReferenceType os;
+ protected Integer id;
+ protected String info;
+ protected String vmwOsType;
+ protected String description;
+ protected ReferenceType edit;
+
+ public VCloudOperatingSystemSection getResult() {
+ VCloudOperatingSystemSection system = new VCloudOperatingSystemSection(id, info, description, os.getType(), os.getHref(),
+ vmwOsType, edit);
+ os = null;
+ id = null;
+ info = null;
+ vmwOsType = null;
+ description = null;
+ edit = null;
+ return system;
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (qName.endsWith("Link")) {
+ this.edit = Utils.newReferenceType(attributes);
+ } else if (qName.endsWith("OperatingSystemSection")) {
+ os = newReferenceType(attributes);
+ vmwOsType = attributes.get("osType");
+ if (attributes.containsKey("id"))
+ this.id = Integer.parseInt(attributes.get("id"));
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) {
+ if (qName.endsWith("Info")) {
+ this.info = currentText.toString().trim();
+ } else if (qName.endsWith("Description")) {
+ this.description = currentText.toString().trim();
+ }
+ currentText = new StringBuilder();
+ }
+
+ public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java
new file mode 100644
index 0000000..b576c1f
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.xml.ovf;
+
+import java.util.Map;
+
+import org.jclouds.cim.ResourceAllocationSettingData;
+import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
+import org.jclouds.util.SaxUtils;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.ovf.EditableResourceAllocationSettingData;
+import org.jclouds.vcloud.domain.ovf.VCloudHardDisk;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
+import org.jclouds.vcloud.util.Utils;
+import org.xml.sax.Attributes;
+
+public class VCloudResourceAllocationSettingDataHandler extends ResourceAllocationSettingDataHandler {
+
+ private ReferenceType edit;
+
+ private long capacity;
+ private int busType;
+ private String busSubType;
+
+ private String ipAddress;
+ private boolean primaryNetworkConnection;
+ private String ipAddressingMode;
+
+ public ResourceAllocationSettingData getResult() {
+ try {
+ ResourceAllocationSettingData from = super.getResult();
+ if (edit != null) {
+ return EditableResourceAllocationSettingData.builder().fromResourceAllocationSettingData(from).edit(edit)
+ .build();
+ } else if (busSubType != null) {
+ return VCloudHardDisk.builder().fromResourceAllocationSettingData(from).capacity(capacity).busType(busType)
+ .busSubType(busSubType).build();
+ } else if (ipAddress != null) {
+ return VCloudNetworkAdapter.builder().fromResourceAllocationSettingData(from).ipAddress(ipAddress)
+ .primaryNetworkConnection(primaryNetworkConnection).ipAddressingMode(ipAddressingMode).build();
+ } else {
+ return from;
+ }
+ } finally {
+ ipAddress = null;
+ primaryNetworkConnection = false;
+ ipAddressingMode = null;
+ capacity = -1;
+ busType = -1;
+ busSubType = null;
+ edit = null;
+ }
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) {
+ Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
+ if (qName.endsWith("Link")) {
+ this.edit = Utils.newReferenceType(attributes);
+ } else if (qName.endsWith("HostResource") && attributes.size() > 0) {
+ capacity = Long.parseLong(attributes.get("capacity"));
+ busType = Integer.parseInt(attributes.get("busType"));
+ busSubType = attributes.get("busSubType");
+ } else if (qName.endsWith("Connection") && attributes.size() > 0) {
+ ipAddress = attributes.get("ipAddress");
+ primaryNetworkConnection = Boolean.parseBoolean(attributes.get("primaryNetworkConnection"));
+ ipAddressingMode = attributes.get("ipAddressingMode");
+ }
+ super.startElement(uri, localName, qName, attrs);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
new file mode 100644
index 0000000..d800a94
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
@@ -0,0 +1 @@
+org.jclouds.vcloud.VCloudApiMetadata
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java
new file mode 100644
index 0000000..8e3f826
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+
+import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "VCloudApiMetadataTest")
+public class VCloudApiMetadataTest extends BaseComputeServiceApiMetadataTest {
+
+ public VCloudApiMetadataTest() {
+ super(new VCloudApiMetadata());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java
new file mode 100644
index 0000000..049b3d9
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+
+import org.jclouds.vcloud.internal.BaseVCloudApiTest;
+import org.jclouds.vcloud.utils.TestUtils;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code VCloudApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "VCloudApiTest")
+public class VCloudApiTest extends BaseVCloudApiTest<VCloudApi> {
+
+ private VCloudApi syncClient;
+
+ public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
+ assert syncClient.getVAppApi() != null;
+ assert syncClient.getCatalogApi() != null;
+ assert syncClient.getVmApi() != null;
+ assert syncClient.getVAppTemplateApi() != null;
+ assert syncClient.getTaskApi() != null;
+ assert syncClient.getVDCApi() != null;
+ assert syncClient.getNetworkApi() != null;
+ assert syncClient.getOrgApi() != null;
+ }
+
+ @BeforeClass
+ @Override
+ protected void setupFactory() throws IOException {
+ super.setupFactory();
+ syncClient = injector.getInstance(VCloudApi.class);
+ }
+
+ @DataProvider
+ public Object[][] ignoreOnWindows() {
+ return TestUtils.isWindowsOs() ? TestUtils.NO_INVOCATIONS
+ : TestUtils.SINGLE_NO_ARG_INVOCATION;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java
new file mode 100644
index 0000000..dcd3e8e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+
+import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ * Tests session refresh works
+ */
+@Test(groups = "live", singleThreaded = true)
+public class VCloudSessionRefreshLiveTest extends BaseVCloudApiLiveTest {
+
+ private static final int timeOut = 40;
+
+ @Test
+ public void testSessionRefresh() throws Exception {
+ VCloudApi connection = view.unwrapApi(VCloudApi.class);
+
+ connection.getOrgApi().findOrgNamed(null);
+ Thread.sleep(timeOut * 1000);
+ connection.getOrgApi().findOrgNamed(null);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java
new file mode 100644
index 0000000..37ae52b
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+
+import static org.jclouds.reflect.Reflection2.method;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.providers.AnonymousProviderMetadata;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.rest.internal.BaseRestAnnotationProcessingTest;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.xml.SupportedVersionsHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+
+/**
+ * Tests behavior of {@code VCloudVersionsApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "VCloudVersionsApiTest")
+public class VCloudVersionsApiTest extends BaseRestAnnotationProcessingTest<VCloudVersionsApi> {
+
+ public void testVersions() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VCloudVersionsApi.class, "getSupportedVersions");
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
+
+ assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, SupportedVersionsHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ @Override
+ protected void checkFilters(HttpRequest request) {
+ assertEquals(request.getFilters().size(), 1);
+ }
+
+ @Override
+ protected ProviderMetadata createProviderMetadata() {
+ return AnonymousProviderMetadata.forApiOnEndpoint(VCloudVersionsApi.class,
+ "http://localhost:8080");
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java
new file mode 100644
index 0000000..599f4a1
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.internal.BasePayloadTest;
+import org.jclouds.vcloud.options.CatalogItemOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests behavior of {@code BindCatalogItemToXmlPayload}
+ */
+@Test(groups = "unit")
+public class BindCatalogItemToXmlPayloadTest extends BasePayloadTest {
+
+ public void testDefault() throws IOException {
+ String expected = "<CatalogItem xmlns=\"http://www.vmware.com/vcloud/v1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"myname\" xsi:schemaLocation=\"http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd\"><Description>mydescription</Description><Entity href=\"http://fooentity\"/><Property key=\"foo\">bar</Property></CatalogItem>";
+
+ CatalogItemOptions options = CatalogItemOptions.Builder.description("mydescription").properties(
+ ImmutableMap.of("foo", "bar"));
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(options));
+
+ BindCatalogItemToXmlPayload binder = injector.getInstance(BindCatalogItemToXmlPayload.class);
+
+ Map<String, Object> map = ImmutableMap.<String, Object> of("name", "myname", "Entity", "http://fooentity");
+
+ assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java
new file mode 100644
index 0000000..8d6042d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.binders;
+
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.util.Strings2;
+import org.jclouds.vcloud.internal.BasePayloadTest;
+import org.jclouds.vcloud.options.CloneVAppOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+
+/**
+ * Tests behavior of {@code BindCloneVAppParamsToXmlPayload}
+ */
+@Test(groups = "unit")
+public class BindCloneVAppParamsToXmlPayloadTest extends BasePayloadTest {
+
+ public void testWithDescriptionDeployOn() throws Exception {
+ String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp.xml"));
+
+ CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().description(
+ "The description of the new vApp");
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(options));
+
+ BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
+
+ Builder<String, Object> map = ImmutableMap.builder();
+ map.put("name", "new-linux-server");
+ map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/201");
+ assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected);
+ }
+
+ public void testWithDescriptionDeployOnSourceDelete() throws Exception {
+ String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/moveVApp.xml"));
+
+ CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().description(
+ "The description of the new vApp");
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(options));
+
+ BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
+
+ Builder<String, Object> map = ImmutableMap.builder();
+ map.put("name", "new-linux-server");
+ map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/201");
+ map.put("IsSourceDelete", "true");
+ assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected);
+ }
+
+ public void testDefault() throws Exception {
+ String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp-default.xml"));
+ GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
+
+ BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
+
+ Builder<String, Object> map = ImmutableMap.builder();
+ map.put("name", "my-vapp");
+ map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/4181");
+ assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected);
+ }
+}
[12/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java
new file mode 100644
index 0000000..a6385c6
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.List;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.GuestCustomizationSection;
+import org.jclouds.vcloud.domain.NetworkConnectionSection;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
+import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * Locations of resources in vCloud
+ */
+public class VmImpl extends ReferenceTypeImpl implements Vm {
+
+ @Nullable
+ private final Status status;
+ private final ReferenceType vApp;
+ @Nullable
+ private final String description;
+ private final List<Task> tasks = Lists.newArrayList();
+ @Nullable
+ private final VCloudVirtualHardwareSection hardware;
+ private final String vAppScopedLocalId;
+ private final VCloudOperatingSystemSection os;
+ @Nullable
+ private final GuestCustomizationSection guestCustomization;
+ @Nullable
+ private final NetworkConnectionSection networkConnectionSection;
+
+ public VmImpl(String name, String type, URI id, @Nullable Status status, ReferenceType vApp,
+ @Nullable String description, Iterable<Task> tasks, @Nullable VCloudVirtualHardwareSection hardware,
+ @Nullable VCloudOperatingSystemSection os, @Nullable NetworkConnectionSection networkConnectionSection,
+ @Nullable GuestCustomizationSection guestCustomization, @Nullable String vAppScopedLocalId) {
+ super(name, type, id);
+ this.status = status;
+ this.vApp = vApp;// TODO: once <1.0 is killed check not null
+ this.description = description;
+ Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
+ this.hardware = hardware;
+ this.os = os;
+ this.networkConnectionSection = networkConnectionSection;
+ this.guestCustomization = guestCustomization;
+ this.vAppScopedLocalId = vAppScopedLocalId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @Nullable
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ReferenceType getParent() {
+ return vApp;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<Task> getTasks() {
+ return tasks;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public VCloudVirtualHardwareSection getVirtualHardwareSection() {
+ return hardware;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public VCloudOperatingSystemSection getOperatingSystemSection() {
+ return os;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NetworkConnectionSection getNetworkConnectionSection() {
+ return networkConnectionSection;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GuestCustomizationSection getGuestCustomizationSection() {
+ return guestCustomization;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getVAppScopedLocalId() {
+ return vAppScopedLocalId;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((guestCustomization == null) ? 0 : guestCustomization.hashCode());
+ result = prime * result + ((hardware == null) ? 0 : hardware.hashCode());
+ result = prime * result + ((networkConnectionSection == null) ? 0 : networkConnectionSection.hashCode());
+ result = prime * result + ((os == null) ? 0 : os.hashCode());
+ result = prime * result + ((vApp == null) ? 0 : vApp.hashCode());
+ result = prime * result + ((vAppScopedLocalId == null) ? 0 : vAppScopedLocalId.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;
+ VmImpl other = (VmImpl) obj;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (guestCustomization == null) {
+ if (other.guestCustomization != null)
+ return false;
+ } else if (!guestCustomization.equals(other.guestCustomization))
+ return false;
+ if (hardware == null) {
+ if (other.hardware != null)
+ return false;
+ } else if (!hardware.equals(other.hardware))
+ return false;
+ if (networkConnectionSection == null) {
+ if (other.networkConnectionSection != null)
+ return false;
+ } else if (!networkConnectionSection.equals(other.networkConnectionSection))
+ return false;
+ if (os == null) {
+ if (other.os != null)
+ return false;
+ } else if (!os.equals(other.os))
+ return false;
+ if (vApp == null) {
+ if (other.vApp != null)
+ return false;
+ } else if (!vApp.equals(other.vApp))
+ return false;
+ if (vAppScopedLocalId == null) {
+ if (other.vAppScopedLocalId != null)
+ return false;
+ } else if (!vAppScopedLocalId.equals(other.vAppScopedLocalId))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[href=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", description=" + description
+ + ", status=" + status + ", tasks=" + tasks + ", vApp=" + vApp + ", hardware=" + hardware + ", os=" + os
+ + ", network=" + networkConnectionSection + ", vAppScopedLocalId=" + vAppScopedLocalId + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/DhcpService.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/DhcpService.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/DhcpService.java
new file mode 100644
index 0000000..628a7d1
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/DhcpService.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network;
+
+import static com.google.common.base.Objects.equal;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * specifies the properties of the network’s DHCP service
+ */
+public class DhcpService {
+ private final boolean enabled;
+ @Nullable
+ private final Integer defaultLeaseTime;
+ @Nullable
+ private final Integer maxLeaseTime;
+ @Nullable
+ private final IpRange ipRange;
+
+ public DhcpService(boolean enabled, @Nullable Integer defaultLeaseTime, @Nullable Integer maxLeaseTime,
+ @Nullable IpRange ipRange) {
+ this.enabled = enabled;
+ this.defaultLeaseTime = defaultLeaseTime;
+ this.maxLeaseTime = maxLeaseTime;
+ this.ipRange = ipRange;
+ }
+
+ /**
+ * @return true if the service is enabled
+ *
+ * @since vcloud api 0.8
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * default duration of a DHCP address lease
+ *
+ * @since vcloud api 0.9
+ */
+ @Nullable
+ public Integer getDefaultLeaseTime() {
+ return defaultLeaseTime;
+ }
+
+ /**
+ * maximum duration of a DHCP address lease.
+ *
+ * @since vcloud api 0.9
+ */
+ @Nullable
+ public Integer getMaxLeaseTime() {
+ return maxLeaseTime;
+ }
+
+ /**
+ * @return range of IP addresses available to DHCP clients
+ *
+ * @since vcloud api 0.9
+ */
+ @Nullable
+ public IpRange getIpRange() {
+ return ipRange;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ DhcpService that = DhcpService.class.cast(o);
+ return equal(this.enabled, that.enabled) && equal(this.defaultLeaseTime, that.defaultLeaseTime)
+ && equal(this.maxLeaseTime, that.maxLeaseTime) && equal(this.ipRange, that.ipRange);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(enabled, defaultLeaseTime, maxLeaseTime, ipRange);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper("").omitNullValues().add("enabled", enabled)
+ .add("defaultLeaseTime", defaultLeaseTime).add("maxLeaseTime", maxLeaseTime).add("ipRange", ipRange)
+ .toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/Features.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/Features.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/Features.java
new file mode 100644
index 0000000..24eb38e
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/Features.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network;
+
+import static com.google.common.base.Objects.equal;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * The Features element defines the DHCP and firewall features of a network.
+ */
+public class Features {
+ @Nullable
+ private final DhcpService dhcpService;
+ @Nullable
+ private final FirewallService firewallService;
+ @Nullable
+ private final NatService natService;
+
+ public Features(@Nullable DhcpService dhcpService, @Nullable FirewallService firewallService,
+ @Nullable NatService natService) {
+ this.dhcpService = dhcpService;
+ this.firewallService = firewallService;
+ this.natService = natService;
+ }
+
+ /**
+ * specifies the properties of the network’s DHCP service
+ *
+ * @since vcloud api 0.9, but emulated for 0.8
+ */
+ @Nullable
+ public DhcpService getDhcpService() {
+ return dhcpService;
+ }
+
+ /**
+ * defines the firewall service capabilities of the network
+ *
+ * @since vcloud api 0.8
+ */
+ @Nullable
+ public FirewallService getFirewallService() {
+ return firewallService;
+ }
+
+ /**
+ * defines the NAT service capabilities of the network
+ *
+ * @since vcloud api 0.8
+ */
+ @Nullable
+ public NatService getNatService() {
+ return natService;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ Features that = Features.class.cast(o);
+ return equal(this.dhcpService, that.dhcpService) && equal(this.firewallService, that.firewallService)
+ && equal(this.natService, that.natService);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(dhcpService, firewallService, natService);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper("").omitNullValues().add("dhcpService", dhcpService)
+ .add("firewallService", firewallService).add("natService", natService).toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java
new file mode 100644
index 0000000..a531b0d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.CaseFormat;
+
+/**
+ *
+ * The FenceMode element contains one of the following strings that specify how a network is
+ * connected to its parent network.
+ */
+public enum FenceMode {
+ /**
+ * The two networks are bridged.
+ * <p/>
+ * Note that in vcloud 0.8 this was called ALLOW_IN_OUT, and so our implementation automatically
+ * converts this for you. Use bridged instead of allowInOut.
+ *
+ * @since vcloud api 0.9
+ */
+ BRIDGED,
+ /**
+ * The two networks are not connected.
+ *
+ * @since vcloud api 0.8
+ */
+ ISOLATED,
+ /**
+ * The two networks are connected as specified in their NatService elements.
+ *
+ * @since vcloud api 0.8
+ */
+ NAT_ROUTED, UNRECOGNIZED;
+
+ public String value() {
+ return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static FenceMode fromValue(String fenceMode) {
+ try {
+ return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(fenceMode, "fenceMode")));
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FirewallService.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FirewallService.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FirewallService.java
new file mode 100644
index 0000000..63212b2
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FirewallService.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * The FirewallService element defines the firewall service capabilities of a network.
+ */
+public class FirewallService {
+ private final boolean enabled;
+
+ List<FirewallRule> firewallRules = Lists.newArrayList();
+
+ public FirewallService(boolean enabled, Iterable<FirewallRule> firewallRules) {
+ this.enabled = enabled;
+ Iterables.addAll(this.firewallRules, checkNotNull(firewallRules, "firewallRules"));
+ }
+
+ /**
+ * @return Firewall rules for the network
+ *
+ * @since vcloud api 0.8
+ */
+ public List<FirewallRule> getFirewallRules() {
+ return firewallRules;
+ }
+
+ /**
+ * @return true if the service is enabled
+ *
+ * @since vcloud api 0.9
+ */
+ @Nullable
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ FirewallService that = FirewallService.class.cast(o);
+ return equal(this.enabled, that.enabled) && equal(this.firewallRules, that.firewallRules);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(enabled, firewallRules);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper helper = Objects.toStringHelper("").omitNullValues().add("enabled", enabled);
+ if (firewallRules.size() > 0)
+ helper.add("firewallRules", firewallRules);
+ return helper.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java
new file mode 100644
index 0000000..2b32691
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network;
+
+
+/**
+ *
+ * The IpAddressAllocationMode element specifies how an IP address is allocated to this connection.
+ */
+public enum IpAddressAllocationMode {
+ /**
+ * no IP addressing mode specified
+ *
+ * @since vcloud api 1.0
+ */
+ NONE,
+ /**
+ * static IP address assigned manually
+ *
+ * @since vcloud api 1.0
+ */
+ MANUAL,
+ /**
+ * static IP address allocated from a pool
+ *
+ * @since vcloud api 1.0
+ */
+ POOL,
+ /**
+ * IP address assigned by DHCP
+ *
+ * @since vcloud api 1.0
+ */
+ DHCP;
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java
new file mode 100644
index 0000000..180d13d
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.Objects;
+
+/**
+ * The IpRange element defines a range of IP addresses available on a network.
+ */
+public class IpRange {
+ private final String startAddress;
+ private final String endAddress;
+
+ public IpRange(String startAddress, String endAddress) {
+ this.startAddress = checkNotNull(startAddress, "startAddress");
+ this.endAddress = checkNotNull(endAddress, "endAddress");
+ }
+
+ /**
+ * @return lowest IP address in the range
+ *
+ * @since vcloud api 0.9
+ */
+ public String getStartAddress() {
+ return startAddress;
+ }
+
+ /**
+ * @return highest IP address in the range
+ *
+ * @since vcloud api 0.9
+ */
+ public String getEndAddress() {
+ return endAddress;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ IpRange that = IpRange.class.cast(o);
+ return equal(this.startAddress, that.startAddress) && equal(this.endAddress, that.endAddress);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(startAddress, endAddress);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper("").omitNullValues().add("startAddress", startAddress)
+ .add("endAddress", endAddress).toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java
new file mode 100644
index 0000000..e5af063
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+
+/**
+ * The IpScope element defines the address range, gateway, netmask, and other properties of the
+ * network.
+ */
+public class IpScope {
+ private final boolean inherited;
+ @Nullable
+ private final String gateway;
+ @Nullable
+ private final String netmask;
+ @Nullable
+ private final String dns1;
+ @Nullable
+ private final String dns2;
+ @Nullable
+ private final String dnsSuffix;
+ private final Set<IpRange> ipRanges = Sets.newLinkedHashSet();
+ private final Set<String> allocatedIpAddresses = Sets.newLinkedHashSet();
+
+ public IpScope(boolean inherited, @Nullable String gateway, @Nullable String netmask, @Nullable String dns1,
+ @Nullable String dns2, @Nullable String dnsSuffix, Iterable<IpRange> ipRanges,
+ Iterable<String> allocatedIpAddresses) {
+ this.inherited = inherited;
+ this.gateway = gateway;
+ this.netmask = netmask;
+ this.dns1 = dns1;
+ this.dns2 = dns2;
+ this.dnsSuffix = dnsSuffix;
+ Iterables.addAll(this.ipRanges, checkNotNull(ipRanges, "ipRanges"));
+ Iterables.addAll(this.allocatedIpAddresses, checkNotNull(allocatedIpAddresses, "allocatedIpAddresses"));
+ }
+
+ /**
+ * @return true of the values in this IpScope element are inherited from the ParentNetwork of the
+ * containing Configuration
+ * @since vcloud api 0.9
+ */
+ public boolean isInherited() {
+ return inherited;
+ }
+
+ /**
+ * @return IP address of the network gateway
+ *
+ * @since vcloud api 0.8
+ */
+ @Nullable
+ public String getGateway() {
+ return gateway;
+ }
+
+ /**
+ * @return netmask to apply to addresses on the network
+ *
+ * @since vcloud api 0.8
+ */
+ @Nullable
+ public String getNetmask() {
+ return netmask;
+ }
+
+ /**
+ * @return IP address of the primary DNS server for this network
+ *
+ * @since vcloud api 0.9
+ */
+ @Nullable
+ public String getDns1() {
+ return dns1;
+ }
+
+ /**
+ * @return IP address of the secondary DNS server for this network
+ *
+ * @since vcloud api 0.9
+ */
+ @Nullable
+ public String getDns2() {
+ return dns2;
+ }
+
+ /**
+ * @return suffix to be applied when resolving hostnames that are not fully‐qualified.
+ *
+ * @since vcloud api 0.9
+ */
+ @Nullable
+ public String getDnsSuffix() {
+ return dnsSuffix;
+ }
+
+ /**
+ * @return A container for IpRange elements.
+ *
+ * @since vcloud api 0.9
+ */
+ public Set<IpRange> getIpRanges() {
+ return ipRanges;
+ }
+
+ /**
+ * @return A list of addresses allocated from any of the specified IpRanges
+ *
+ * @since vcloud api 0.9
+ */
+ public Set<String> getAllocatedIpAddresses() {
+ return allocatedIpAddresses;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ IpScope that = IpScope.class.cast(o);
+ return equal(this.inherited, that.inherited) && equal(this.gateway, that.gateway)
+ && equal(this.netmask, that.netmask) && equal(this.dns1, that.dns1) && equal(this.dns2, that.dns2)
+ && equal(this.dnsSuffix, that.dnsSuffix)
+ && equal(this.ipRanges, that.ipRanges)
+ && equal(this.allocatedIpAddresses, that.allocatedIpAddresses);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(inherited, gateway, netmask, dns1, dns2, dnsSuffix, ipRanges, allocatedIpAddresses);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper helper = Objects.toStringHelper("").omitNullValues().add("inherited", inherited).add("gateway", gateway)
+ .add("netmask", netmask).add("dns1", dns1).add("dns2", dns2).add("dnsSuffix", dnsSuffix);
+ if (ipRanges.size() > 0)
+ helper.add("ipRanges", ipRanges);
+ if (allocatedIpAddresses.size() > 0)
+ helper.add("allocatedIpAddresses", allocatedIpAddresses);
+ return helper.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NatService.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NatService.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NatService.java
new file mode 100644
index 0000000..ea4c388
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NatService.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.network.nat.NatPolicy;
+import org.jclouds.vcloud.domain.network.nat.NatRule;
+import org.jclouds.vcloud.domain.network.nat.NatType;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * The NatService element defines the network address translation capabilities of a network.
+ */
+public class NatService {
+ private final boolean enabled;
+ @Nullable
+ private final NatType type;
+ @Nullable
+ private final NatPolicy policy;
+ private final List<NatRule> natRules = Lists.newArrayList();
+
+ public NatService(boolean enabled, @Nullable NatType type, @Nullable NatPolicy policy,
+ Iterable<NatRule> natRules) {
+ this.enabled = enabled;
+ this.type = type;
+ this.policy = policy;
+ Iterables.addAll(this.natRules, checkNotNull(natRules, "natRules"));
+ }
+
+ /**
+ * @return Nat rules for the network
+ *
+ * @since vcloud api 0.8
+ */
+ public List<NatRule> getNatRules() {
+ return natRules;
+ }
+
+ /**
+ * @return true if the service is enabled
+ *
+ * @since vcloud api 0.9
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * @return specifies how Network Address Translation is implemented by the NAT service
+ *
+ * @since vcloud api 0.9
+ */
+ @Nullable
+ public NatType getType() {
+ return type;
+ }
+
+ /**
+ * @return specifies how packets are handled by the NAT service.
+ *
+ * @since vcloud api 0.9
+ */
+ @Nullable
+ public NatPolicy getPolicy() {
+ return policy;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ NatService that = NatService.class.cast(o);
+ return equal(this.enabled, that.enabled) && equal(this.type, that.type)
+ && equal(this.policy, that.policy) && equal(this.natRules, that.natRules);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(enabled, type, policy, natRules);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper helper = Objects.toStringHelper("").omitNullValues().add("enabled", enabled)
+ .add("type", type).add("policy", policy);
+ if (natRules.size() > 0)
+ helper.add("natRules", natRules);
+ return helper.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java
new file mode 100644
index 0000000..79e6461
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+
+import org.jclouds.javax.annotation.Nullable;
+
+public class NetworkConfig {
+
+ public Builder toBuilder() {
+ return builder().fromNetworkConfig(this);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private String networkName;
+ private URI parentNetwork;
+ private FenceMode fenceMode;
+
+ public Builder networkName(String networkName) {
+ this.networkName = networkName;
+ return this;
+ }
+
+ public Builder parentNetwork(URI parentNetwork) {
+ this.parentNetwork = parentNetwork;
+ return this;
+ }
+
+ public Builder fenceMode(FenceMode fenceMode) {
+ this.fenceMode = fenceMode;
+ return this;
+ }
+
+ public Builder fromNetworkConfig(NetworkConfig in) {
+ return networkName(in.getNetworkName()).parentNetwork(in.getParentNetwork()).fenceMode(in.getFenceMode());
+ }
+
+ public NetworkConfig build() {
+ return new NetworkConfig(networkName, parentNetwork, fenceMode);
+ }
+ }
+
+ @Nullable
+ private final String networkName;
+ private final URI parentNetwork;
+ @Nullable
+ private final FenceMode fenceMode;
+
+ /**
+ *
+ * Create a new NetworkConfig.
+ *
+ * @param networkName
+ * a valid {@networkConfig
+ * org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection network in the vapp
+ * template}, or null to have us choose default
+ * @param parentNetwork
+ * a valid {@networkConfig org.jclouds.vcloud.domain.Org#getNetworks in
+ * the Org}
+ * @param fenceMode
+ * how to manage the relationship between the two networks
+ */
+ public NetworkConfig(String networkName, URI parentNetwork, FenceMode fenceMode) {
+ this.networkName = networkName;
+ this.parentNetwork = checkNotNull(parentNetwork, "parentNetwork");
+ this.fenceMode = fenceMode;
+ }
+
+ public NetworkConfig(URI parentNetwork) {
+ this(null, parentNetwork, null);
+ }
+
+ /**
+ * A name for the network. If the
+ * {@link org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection} includes a
+ * {@link NetworkSection.Network} network element, the name you specify for the vApp network must
+ * match the name specified in that element’s name attribute.
+ *
+ * @return
+ */
+ public String getNetworkName() {
+ return networkName;
+ }
+
+ /**
+ *
+ * @return A reference to the organization network to which this network connects.
+ */
+ public URI getParentNetwork() {
+ return parentNetwork;
+ }
+
+ /**
+ * A value of bridged indicates that this vApp network is connected directly to the organization
+ * network.
+ */
+ public FenceMode getFenceMode() {
+ return fenceMode;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((fenceMode == null) ? 0 : fenceMode.hashCode());
+ result = prime * result + ((parentNetwork == null) ? 0 : parentNetwork.hashCode());
+ result = prime * result + ((networkName == null) ? 0 : networkName.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ NetworkConfig other = (NetworkConfig) obj;
+ if (fenceMode == null) {
+ if (other.fenceMode != null)
+ return false;
+ } else if (!fenceMode.equals(other.fenceMode))
+ return false;
+ if (parentNetwork == null) {
+ if (other.parentNetwork != null)
+ return false;
+ } else if (!parentNetwork.equals(other.parentNetwork))
+ return false;
+ if (networkName == null) {
+ if (other.networkName != null)
+ return false;
+ } else if (!networkName.equals(other.networkName))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[networkName=" + networkName + ", parentNetwork=" + parentNetwork + ", fenceMode=" + fenceMode + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java
new file mode 100644
index 0000000..f50d18c
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.network.internal.OrgNetworkImpl;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * A vDC is a deployment environment for vApps. A Vdc element provides a user view of a vDC.
+ */
+@org.jclouds.vcloud.endpoints.Network
+@ImplementedBy(OrgNetworkImpl.class)
+public interface OrgNetwork extends ReferenceType {
+ /**
+ * The org this network belongs to.
+ *
+ * @since vcloud api 0.9
+ */
+ @Nullable
+ ReferenceType getOrg();
+
+ /**
+ * optional description
+ *
+ * @since vcloud api 0.8
+ */
+ @Nullable
+ String getDescription();
+
+ /**
+ * read‐only container for Task elements. Each element in the container represents a queued,
+ * running, or failed task owned by this object.
+ *
+ * @since vcloud api 0.9
+ */
+ List<Task> getTasks();
+
+ /**
+ *
+ * @return properties of the network
+ *
+ * @since vcloud api 0.9, but emulated for 0.8
+ */
+ Configuration getConfiguration();
+
+ /**
+ * A reference the network pool from which this network is provisioned. This element, which is
+ * required when creating a NatRouted or Isolated network, is returned in response to a creation
+ * request but not shown in subsequent GET requests.
+ *
+ * @since vcloud api 0.9
+ */
+ @Nullable
+ ReferenceType getNetworkPool();
+
+ /**
+ * list of external IP addresses that this network can use for NAT.
+ *
+ * @since vcloud api 0.9
+ */
+ Set<String> getAllowedExternalIpAddresses();
+
+ /**
+ * The Configuration element specifies properties of a network.
+ */
+ interface Configuration {
+ /**
+ * defines the address range, gateway, netmask, and other properties of the network.
+ *
+ * @since vcloud api 0.9, but emulated for 0.8
+ */
+ @Nullable
+ IpScope getIpScope();
+
+ /**
+ * reference to a network to which this network connects
+ *
+ * @since vcloud api 0.9
+ */
+ @Nullable
+ ReferenceType getParentNetwork();
+
+ /**
+ * defines how this network is connected to its ParentNetwork
+ *
+ * @since vcloud api 0.8
+ */
+ FenceMode getFenceMode();
+
+ /**
+ * defines a set of network features.
+ *
+ * @since vcloud api 0.9, but emulated for 0.8
+ */
+ @Nullable Features getFeatures();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java
new file mode 100644
index 0000000..44a5e81
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network.firewall;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.CaseFormat;
+
+/**
+ * specifies how packets are handled by the firewall
+ */
+public enum FirewallPolicy {
+ /**
+ * drop packets of this type
+ */
+ DROP,
+ /**
+ * allow packets of this type to pass through the firewall
+ */
+ ALLOW, UNRECOGNIZED;
+
+ public String value() {
+ return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static FirewallPolicy fromValue(String policy) {
+ try {
+ return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(policy, "policy")));
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java
new file mode 100644
index 0000000..8b09dc2
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network.firewall;
+
+import static com.google.common.base.Objects.equal;
+
+import com.google.common.base.Objects;
+
+/**
+ * The Protocols element specifies the protocols to which firewall rules apply.
+ *
+ * @since vcloud api 0.9 emulated for 0.8
+ */
+public class FirewallProtocols {
+ private final boolean tcp;
+ private final boolean udp;
+
+ public FirewallProtocols(boolean tcp, boolean udp) {
+ this.tcp = tcp;
+ this.udp = udp;
+ }
+
+ /**
+ * @return true if the firewall rules apply to the TCP protocol
+ */
+ public boolean isTcp() {
+ return tcp;
+ }
+
+ /**
+ * @return true if the firewall rules apply to the UDP protocol
+ */
+ public boolean isUdp() {
+ return udp;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ FirewallProtocols that = FirewallProtocols.class.cast(o);
+ return equal(this.tcp, that.tcp) && equal(this.udp, that.udp);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(tcp, udp);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper("").omitNullValues().add("tcp", tcp).add("udp", udp).toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java
new file mode 100644
index 0000000..dfb578b
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network.firewall;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * The FirewallRule element defines a single firewall rule.
+ *
+ * @since vcloud api 0.8
+ */
+public class FirewallRule {
+
+ private final boolean enabled;
+ @Nullable
+ private final String description;
+ @Nullable
+ private final FirewallPolicy policy;
+ @Nullable
+ private final FirewallProtocols protocols;
+ private final int port;
+ private final String destinationIp;
+
+ public FirewallRule(boolean enabled, @Nullable String description, @Nullable FirewallPolicy policy,
+ @Nullable FirewallProtocols protocols, int port, String destinationIp) {
+ this.enabled = enabled;
+ this.description = description;
+ this.policy = policy;
+ this.protocols = protocols;
+ this.port = port;
+ this.destinationIp = checkNotNull(destinationIp, "destinationIp");
+ }
+
+ /**
+ * @return true if the rule is enabled
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * @return description of the rule
+ */
+ @Nullable
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @return specifies how packets are handled by the firewall
+ */
+ @Nullable
+ public FirewallPolicy getPolicy() {
+ return policy;
+ }
+
+ /**
+ * @return specifies the protocols to which this firewall rule applies
+ */
+ @Nullable
+ public FirewallProtocols getProtocols() {
+ return protocols;
+ }
+
+ /**
+ * @return specifies the network port to which this firewall rule applies. A value of ‐1 matches
+ * any port.
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * @return specifies the destination IP address, inside the firewall, to which this firewall rule
+ * applies
+ */
+ public String getDestinationIp() {
+ return destinationIp;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ FirewallRule that = FirewallRule.class.cast(o);
+ return equal(this.enabled, that.enabled) && equal(this.description, that.description)
+ && equal(this.policy, that.policy) && equal(this.protocols, that.protocols) && equal(this.port, that.port)
+ && equal(this.destinationIp, that.destinationIp);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(enabled, description, policy, protocols, port, destinationIp);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper("").omitNullValues().add("enabled", enabled).add("description", description)
+ .add("policy", policy).add("protocols", protocols).add("port", port).add("destinationIp", destinationIp)
+ .toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java
new file mode 100644
index 0000000..76a394f
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network.internal;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.network.Features;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.jclouds.vcloud.domain.network.IpScope;
+import org.jclouds.vcloud.domain.network.OrgNetwork;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+public class OrgNetworkImpl extends ReferenceTypeImpl implements OrgNetwork {
+ @Nullable
+ private final ReferenceType org;
+ @Nullable
+ private final String description;
+ private final List<Task> tasks = Lists.newArrayList();
+ private final Configuration configuration;
+ @Nullable
+ private final ReferenceType networkPool;
+ private final Set<String> allowedExternalIpAddresses = Sets.newLinkedHashSet();
+
+ public OrgNetworkImpl(String name, String type, URI id, @Nullable ReferenceType org, @Nullable String description,
+ Iterable<Task> tasks, Configuration configuration, @Nullable ReferenceType networkPool,
+ Iterable<String> allowedExternalIpAddresses) {
+ super(name, type, id);
+ this.org = org;
+ this.description = description;
+ Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
+ this.configuration = checkNotNull(configuration, "configuration");
+ this.networkPool = networkPool;
+ Iterables.addAll(this.allowedExternalIpAddresses, checkNotNull(allowedExternalIpAddresses,
+ "allowedExternalIpAddresses"));
+ }
+
+ public static class ConfigurationImpl implements Configuration {
+
+ @Nullable
+ private final IpScope ipScope;
+ @Nullable
+ private final ReferenceType parentNetwork;
+ private final FenceMode fenceMode;
+ private final Features features;
+
+ public ConfigurationImpl(@Nullable IpScope ipScope, @Nullable ReferenceType parentNetwork, FenceMode fenceMode,
+ @Nullable Features features) {
+ this.ipScope = ipScope;
+ this.parentNetwork = parentNetwork;
+ this.fenceMode = checkNotNull(fenceMode, "fenceMode");
+ this.features = features;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IpScope getIpScope() {
+ return ipScope;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ReferenceType getParentNetwork() {
+ return parentNetwork;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public FenceMode getFenceMode() {
+ return fenceMode;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @Nullable
+ public Features getFeatures() {
+ return features;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ ConfigurationImpl that = ConfigurationImpl.class.cast(o);
+ return equal(this.ipScope, that.ipScope) && equal(this.parentNetwork, that.parentNetwork)
+ && equal(this.fenceMode, that.fenceMode) && equal(this.features, that.features);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(ipScope, parentNetwork, fenceMode, features);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper("").omitNullValues().add("ipScope", ipScope).add("parentNetwork", parentNetwork)
+ .add("fenceMode", fenceMode).add("features", features).toString();
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ReferenceType getOrg() {
+ return org;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<Task> getTasks() {
+ return tasks;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ReferenceType getNetworkPool() {
+ return networkPool;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<String> getAllowedExternalIpAddresses() {
+ return allowedExternalIpAddresses;
+ }
+
+ @Override
+ public ToStringHelper string() {
+ ToStringHelper helper = super.string().add("org", org).add("description", description)
+ .add("configuration", configuration).add("networkPool", networkPool);
+ if (allowedExternalIpAddresses.size() > 0)
+ helper.add("allowedExternalIpAddresses", allowedExternalIpAddresses);
+ if (tasks.size() > 0)
+ helper.add("tasks", tasks);
+ return helper;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java
new file mode 100644
index 0000000..8a49b33
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network.nat;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.CaseFormat;
+
+/**
+ * The Policy element of a NatService element specifies how packets are handled by the NAT service.
+ */
+public enum NatPolicy {
+ /**
+ * packets of this type pass through the firewall in both directions
+ */
+ ALLOW_TRAFFIC,
+ /**
+ * only inbound packets of this type pass through the firewall
+ */
+ ALLOW_TRAFFIC_IN, UNRECOGNIZED;
+
+ public String value() {
+ return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static NatPolicy fromValue(String policy) {
+ try {
+ return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(policy, "policy")));
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java
new file mode 100644
index 0000000..7204bae
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network.nat;
+
+
+/**
+ *
+ * The Protocol specifies the network protocol to which this rule applies
+ *
+ * @since vcloud api 0.9
+ */
+public enum NatProtocol {
+ /**
+ * the rule applies to the TCP protocol
+ *
+ * @since vcloud api 0.9
+ */
+ TCP,
+ /**
+ * the rule applies to the UDP protocol
+ *
+ * @since vcloud api 0.9
+ */
+ UDP,
+ /**
+ * the rule applies to the TCP and UDP protocols.
+ *
+ * @since vcloud api 0.9
+ */
+ TCP_UDP;
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java
new file mode 100644
index 0000000..b9ca510
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network.nat;
+
+import org.jclouds.javax.annotation.Nullable;
+
+/**
+ *
+ * Defines a rule associated with Nat
+ *
+ * @since vcloud api 0.9
+ */
+public interface NatRule {
+ /**
+ * IP address to which this NAT rule maps the IP address specified in the InternalIp element.
+ */
+ @Nullable
+ String getExternalIP();
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java
new file mode 100644
index 0000000..98b95e2
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network.nat;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.CaseFormat;
+
+/**
+ *
+ * The NatType element specifies how network address translation is implemented by the NAT service.
+ *
+ * @since vcloud api 0.9
+ */
+public enum NatType {
+ /**
+ * NAT service implemented by IP address translation
+ *
+ * @since vcloud api 0.9
+ */
+ IP_TRANSLATION,
+ /**
+ * NAT service implemented by network port forwarding
+ *
+ * @since vcloud api 0.9
+ */
+ PORT_FORWARDING, UNRECOGNIZED;
+
+ public String value() {
+ return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static NatType fromValue(String natType) {
+ try {
+ return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(natType, "natType")));
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java
new file mode 100644
index 0000000..6d71116
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network.nat.rules;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.CaseFormat;
+
+/**
+ * The MappingMode element specifies how IP address mapping is implemented by the NAT service.
+ */
+public enum MappingMode {
+ /**
+ * the external IP address is specified in the ExternalIP element
+ */
+ MANUAL,
+ /**
+ * the external IP address is assigned automatically
+ */
+ AUTOMATIC, UNRECOGNIZED;
+
+ public String value() {
+ return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static MappingMode fromValue(String mode) {
+ try {
+ return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(mode, "mode")));
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java
new file mode 100644
index 0000000..c2b1b4b
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network.nat.rules;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.network.nat.NatRule;
+
+import com.google.common.base.Objects;
+
+/**
+ * The OneToOneVmRule element describes a NAT rule that specifies network address translation
+ * details for a single virtual machine. The external IP address can be specified manually or
+ * assigned automatically at deployment time. The internal IP address is discovered by looking up
+ * the specified VmReference and NIC ID.
+ *
+ * @since vcloud 0.9
+ */
+public class OneToOneVmRule implements NatRule {
+ private final MappingMode mappingMode;
+ @Nullable
+ private final String externalIP;
+ @Nullable
+ private final String vAppScopedVmId;
+ private final int vmNicId;
+
+ public OneToOneVmRule(MappingMode mappingMode, @Nullable String externalIp, @Nullable String vAppScopedVmId,
+ int vmNicId) {
+ this.mappingMode = checkNotNull(mappingMode, "mappingMode");
+ this.externalIP = externalIp;
+ this.vAppScopedVmId = vAppScopedVmId;
+ this.vmNicId = vmNicId;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ OneToOneVmRule that = OneToOneVmRule.class.cast(o);
+ return equal(this.mappingMode, that.mappingMode) && equal(this.externalIP, that.externalIP)
+ && equal(this.vAppScopedVmId, that.vAppScopedVmId) && equal(this.vmNicId, that.vmNicId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(mappingMode, externalIP, vAppScopedVmId, vmNicId);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper("").omitNullValues().add("mappingMode", mappingMode).add("externalIP", externalIP)
+ .add("vAppScopedVmId", vAppScopedVmId).add("vmNicId", vmNicId).toString();
+ }
+
+ /**
+ * @return how IP address mapping is implemented by the NAT service
+ * @since vcloud 0.9
+ */
+ public MappingMode getMappingMode() {
+ return mappingMode;
+ }
+
+ /**
+ * @return if MappingMode is manual, specifies the external IP address of this Vm, otherwise
+ * null.
+ * @since vcloud 0.9
+ */
+ @Nullable
+ @Override
+ public String getExternalIP() {
+ return externalIP;
+ }
+
+ /**
+ * @return read‐only identifier created on import
+ * @since vcloud 0.9
+ */
+ @Nullable
+ public String getVAppScopedVmId() {
+ return vAppScopedVmId;
+ }
+
+ /**
+ * @return device number of the NIC on the referenced virtual machine
+ * @since vcloud 0.9
+ */
+ public int getVmNicId() {
+ return vmNicId;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java
new file mode 100644
index 0000000..3170a73
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network.nat.rules;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.vcloud.domain.network.nat.NatProtocol;
+import org.jclouds.vcloud.domain.network.nat.NatRule;
+
+import com.google.common.base.Objects;
+
+/**
+ * The PortForwardingRule element describes a NAT rule that maps an IP address and port in an
+ * organization network to an external IP address and port.
+ *
+ * @since vcloud 0.8
+ */
+public class PortForwardingRule implements NatRule {
+ private final String externalIP;
+ private final int externalPort;
+ private final String internalIP;
+ private final int internalPort;
+ private final NatProtocol protocol;
+
+ public PortForwardingRule(String externalIP, int externalPort, String internalIP, int internalPort,
+ NatProtocol protocol) {
+ this.externalIP = checkNotNull(externalIP, "externalIP");
+ this.externalPort = externalPort;
+ this.internalIP = checkNotNull(internalIP, "internalIP");
+ this.internalPort = internalPort;
+ this.protocol = checkNotNull(protocol, "protocol");
+ }
+
+ /**
+ * IP address to which this NAT rule maps the IP address specified in the InternalIp element.
+ */
+ @Override
+ public String getExternalIP() {
+ return externalIP;
+ }
+
+ /**
+ * network port to which this NAT rule maps the port number specified in the InternalPort element
+ */
+ public int getExternalPort() {
+ return externalPort;
+ }
+
+ /**
+ * IP address to which this NAT rule maps the IP address specified in the ExternalIp element.
+ */
+ public String getInternalIP() {
+ return internalIP;
+ }
+
+ /**
+ * network port to which this NAT rule maps the port number specified in the ExternalPort
+ * element.
+ */
+ public int getInternalPort() {
+ return internalPort;
+ }
+
+ /**
+ * specifies the network protocol to which this rule applies
+ */
+ public NatProtocol getProtocol() {
+ return protocol;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ PortForwardingRule that = PortForwardingRule.class.cast(o);
+ return equal(this.externalIP, that.externalIP) && equal(this.externalPort, that.externalPort)
+ && equal(this.internalIP, that.internalIP) && equal(this.internalPort, that.internalPort)
+ && equal(this.protocol, that.protocol);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(externalIP, externalPort, internalIP, internalPort, protocol);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper("").omitNullValues().add("externalIP", externalIP)
+ .add("externalPort", externalPort).add("internalIP", internalIP).add("internalPort", internalPort)
+ .add("protocol", protocol).toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java
new file mode 100644
index 0000000..8793a58
--- /dev/null
+++ b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.domain.network.nat.rules;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.vcloud.domain.network.nat.NatProtocol;
+import org.jclouds.vcloud.domain.network.nat.NatRule;
+
+import com.google.common.base.Objects;
+
+/**
+ * The VmRule element describes a NAT rule that maps an IP address and port in a vApp network to an
+ * external IP address and port. The external IP address, external port, and internal port are
+ * specified in the element. The internal IP address is discovered by looking up the specified
+ * VmReference and VmNicId.
+ *
+ * @since vcloud 0.9
+ */
+public class VmRule implements NatRule {
+ @Nullable
+ private final String externalIP;
+ private final int externalPort;
+ @Nullable
+ private final String vAppScopedLocalId;
+ private final int vmNicId;
+ private final int internalPort;
+ private final NatProtocol protocol;
+
+ public VmRule(@Nullable String externalIP, int externalPort, @Nullable String vAppScopedLocalId, int vmNicId,
+ int internalPort, NatProtocol protocol) {
+ this.externalIP = externalIP;
+ this.externalPort = externalPort;
+ this.vAppScopedLocalId = vAppScopedLocalId;
+ this.vmNicId = vmNicId;
+ this.internalPort = internalPort;
+ this.protocol = checkNotNull(protocol, "protocol");
+ }
+
+ /**
+ * IP address to which this NAT rule maps the IP address specified in the vAppScopedLocalId element.
+ */
+ @Nullable
+ public String getExternalIP() {
+ return externalIP;
+ }
+
+ /**
+ * network port to which this NAT rule maps the port number specified in the InternalPort element
+ */
+ public Integer getExternalPort() {
+ return externalPort;
+ }
+
+ /**
+ * @return read‐only identifier created on import
+ * @since vcloud 0.9
+ */
+ @Nullable
+ public String getVAppScopedLocalId() {
+ return vAppScopedLocalId;
+ }
+
+ /**
+ * @return device number of the NIC on the referenced virtual machine
+ * @since vcloud 0.9
+ */
+ public int getVmNicId() {
+ return vmNicId;
+ }
+
+ /**
+ * network port to which this NAT rule maps the port number specified in the ExternalPort
+ * element.
+ */
+ public Integer getInternalPort() {
+ return internalPort;
+ }
+
+ /**
+ * specifies the network protocol to which this rule applies
+ */
+ public NatProtocol getProtocol() {
+ return protocol;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ VmRule that = VmRule.class.cast(o);
+ return equal(this.externalIP, that.externalIP) && equal(this.externalPort, that.externalPort)
+ && equal(this.vAppScopedLocalId, that.vAppScopedLocalId) && equal(this.vmNicId, that.vmNicId)
+ && equal(this.internalPort, that.internalPort) && equal(this.protocol, that.protocol);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(externalIP, externalPort, vAppScopedLocalId, vmNicId, internalPort, protocol);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper("").omitNullValues().add("externalIP", externalIP)
+ .add("externalPort", externalPort).add("vAppScopedLocalId", vAppScopedLocalId).add("vmNicId", vmNicId)
+ .add("internalPort", internalPort).add("protocol", protocol).toString();
+ }
+
+}