You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2015/02/11 17:48:46 UTC
[1/3] jclouds-labs git commit: azurecompute: improvements to the
domain objects
Repository: jclouds-labs
Updated Branches:
refs/heads/master 58a9be6ad -> a34e62ca3
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/java/org/jclouds/azurecompute/xml/NetworkSecurityGroupHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/NetworkSecurityGroupHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/NetworkSecurityGroupHandlerTest.java
new file mode 100644
index 0000000..f1bb03c
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/NetworkSecurityGroupHandlerTest.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.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+import java.io.InputStream;
+
+import org.jclouds.azurecompute.domain.NetworkSecurityGroup;
+import org.jclouds.azurecompute.domain.Rule;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "NetworkSecurityGroupHandlerTest")
+public class NetworkSecurityGroupHandlerTest extends BaseHandlerTest {
+
+ public void test() {
+ InputStream is = getClass().getResourceAsStream("/networksecuritygroup.xml");
+ NetworkSecurityGroup result = factory.create(new NetworkSecurityGroupHandler()).parse(is);
+
+ assertEquals(result, expected());
+ }
+
+ public static NetworkSecurityGroup expected() {
+ return NetworkSecurityGroup.create( //
+ "jclouds-NSG", // name
+ "jclouds-NSG", // label
+ "West Europe", // location
+ ImmutableList.of(
+ Rule.create("ALLOW VNET INBOUND", // name
+ "Inbound", // type
+ "65000", // priority
+ "Allow", // action
+ "VIRTUAL_NETWORK", // sourceAddressPrefix
+ "*", // sourcePortRange
+ "VIRTUAL_NETWORK", // destinationAddressPrefix
+ "*", // destinationPortRange
+ "*", // protocol
+ "Active", // state
+ true // isDefault
+ ),
+ Rule.create("ALLOW VNET OUTBOUND", // name
+ "Outbound", // type
+ "65000", // priority
+ "Allow", // action
+ "VIRTUAL_NETWORK", // sourceAddressPrefix
+ "*", // sourcePortRange
+ "VIRTUAL_NETWORK", // destinationAddressPrefix
+ "*", // destinationPortRange
+ "*", // protocol
+ "Active", // state
+ true // isDefault
+ ),
+ Rule.create("ALLOW AZURE LOAD BALANCER INBOUND", // name
+ "Inbound", // type
+ "65001", // priority
+ "Allow", // action
+ "AZURE_LOADBALANCER", // sourceAddressPrefix
+ "*", // sourcePortRange
+ "*", // destinationAddressPrefix
+ "*", // destinationPortRange
+ "*", // protocol
+ "Active", // state
+ true // isDefault
+ ),
+ Rule.create("ALLOW INTERNET OUTBOUND", // name
+ "Outbound", // type
+ "65001", // priority
+ "Allow", // action
+ "*", // sourceAddressPrefix
+ "*", // sourcePortRange
+ "INTERNET", // destinationAddressPrefix
+ "*", // destinationPortRange
+ "*", // protocol
+ "Active", // state
+ true // isDefault
+ ),
+ Rule.create("DENY ALL OUTBOUND", // name
+ "Outbound", // type
+ "65500", // priority
+ "Deny", // action
+ "*", // sourceAddressPrefix
+ "*", // sourcePortRange
+ "*", // destinationAddressPrefix
+ "*", // destinationPortRange
+ "*", // protocol
+ "Active", // state
+ true // isDefault
+ ),
+ Rule.create("DENY ALL INBOUND", // name
+ "Inbound", // type
+ "65500", // priority
+ "Deny", // action
+ "*", // sourceAddressPrefix
+ "*", // sourcePortRange
+ "*", // destinationAddressPrefix
+ "*", // destinationPortRange
+ "*", // protocol
+ "Active", // state
+ true // isDefault
+ )
+ ) // rules
+ );
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/resources/deployment.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/deployment.xml b/azurecompute/src/test/resources/deployment.xml
index b3029d6..c7db84d 100644
--- a/azurecompute/src/test/resources/deployment.xml
+++ b/azurecompute/src/test/resources/deployment.xml
@@ -1,74 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
- <Name>deployment_name</Name>
+ <Name>node1855162607153993262-b26</Name>
<DeploymentSlot>Production</DeploymentSlot>
- <PrivateID>05aa8ec5d8ee4215894431c7db401b31</PrivateID>
+ <PrivateID>706868c87c1847f28a47644b68f3babf</PrivateID>
<Status>Running</Status>
- <Label>bmVvdHlzc3M=</Label>
- <Url>http://neotysss.cloudapp.net/</Url>
- <Configuration>
- PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJuZW90eXNzcyI+DQogICAgPEluc3RhbmNlcyBjb3VudD0iMSIgLz4NCiAgPC9Sb2xlPg0KPC9TZXJ2aWNlQ29uZmlndXJhdGlvbj4=
- </Configuration>
+ <Label>bm9kZTE4NTUxNjI2MDcxNTM5OTMyNjItYjI2</Label>
+ <Url>http://node1855162607153993262-b26.cloudapp.net/</Url>
+ <Configuration>PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJub2RlMTg1NTE2MjYwNzE1Mzk5MzI2Mi1iMjYiPg0KICAgIDxJbnN0YW5jZXMgY291bnQ9IjEiIC8+DQogIDwvUm9sZT4NCjwvU2VydmljZUNvbmZpZ3VyYXRpb24+</Configuration>
<RoleInstanceList>
<RoleInstance>
- <RoleName>role_name_from_instance</RoleName>
- <InstanceName>instance_name</InstanceName>
+ <RoleName>node1855162607153993262-b26</RoleName>
+ <InstanceName>node1855162607153993262-b26</InstanceName>
<InstanceStatus>ReadyRole</InstanceStatus>
<InstanceUpgradeDomain>0</InstanceUpgradeDomain>
<InstanceFaultDomain>0</InstanceFaultDomain>
- <InstanceSize>Medium</InstanceSize>
- <InstanceStateDetails/>
- <IpAddress>10.59.244.162</IpAddress>
+ <InstanceSize>Basic_A0</InstanceSize>
+ <InstanceStateDetails />
+ <IpAddress>10.0.2.6</IpAddress>
<InstanceEndpoints>
<InstanceEndpoint>
- <Name>SSH</Name>
- <Vip>168.63.27.148</Vip>
+ <Name>tcp_22-22</Name>
+ <Vip>191.233.85.49</Vip>
<PublicPort>22</PublicPort>
<LocalPort>22</LocalPort>
<Protocol>tcp</Protocol>
</InstanceEndpoint>
</InstanceEndpoints>
<PowerState>Started</PowerState>
- <HostName>host_name</HostName>
+ <HostName>node1855162607153993262-b26</HostName>
</RoleInstance>
</RoleInstanceList>
<UpgradeDomainCount>1</UpgradeDomainCount>
<RoleList>
<Role i:type="PersistentVMRole">
- <RoleName>role_name_from_role_list</RoleName>
- <OsVersion/>
+ <RoleName>node1855162607153993262-b26</RoleName>
+ <OsVersion />
<RoleType>PersistentVMRole</RoleType>
<ConfigurationSets>
<ConfigurationSet i:type="NetworkConfigurationSet">
<ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
<InputEndpoints>
<InputEndpoint>
- <LocalPort>22</LocalPort>
- <Name>SSH</Name>
- <Port>22</Port>
+ <LocalPort>22</LocalPort>
+ <Name>tcp_22-22</Name>
+ <Port>22</Port>
+ <Protocol>tcp</Protocol>
+ <Vip>191.233.85.49</Vip>
+ <EnableDirectServerReturn>false</EnableDirectServerReturn>
+ </InputEndpoint>
+ <InputEndpoint>
+ <LocalPort>2375</LocalPort>
+ <Name>tcp_2375-2375</Name>
+ <Port>2375</Port>
<Protocol>tcp</Protocol>
- <Vip>168.63.27.148</Vip>
+ <Vip>191.233.85.49</Vip>
+ <EnableDirectServerReturn>false</EnableDirectServerReturn>
</InputEndpoint>
</InputEndpoints>
- <SubnetNames/>
+ <SubnetNames>
+ <SubnetName>Subnet-1</SubnetName>
+ </SubnetNames>
</ConfigurationSet>
</ConfigurationSets>
- <DataVirtualHardDisks/>
+ <DataVirtualHardDisks />
<OSVirtualHardDisk>
<HostCaching>ReadWrite</HostCaching>
- <DiskName>neotysss-neotysss-0-20120824091357</DiskName>
- <MediaLink>
- http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd
- </MediaLink>
- <SourceImageName>MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</SourceImageName>
- <OS>Windows</OS>
+ <DiskName>node1855162607153993262-b26-node1855162607153993262-b26-0-201412221704390597</DiskName>
+ <MediaLink>https://test.blob.core.windows.net/clockerblob/container-node1855162607153993262-b26.vhd</MediaLink>
+ <SourceImageName>b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-trusty-14_04_1-LTS-amd64-server-20141212-en-us-30GB</SourceImageName>
+ <OS>Linux</OS>
</OSVirtualHardDisk>
- <RoleSize>Medium</RoleSize>
+ <RoleSize>Basic_A0</RoleSize>
</Role>
</RoleList>
- <SdkVersion/>
+ <SdkVersion />
<Locked>false</Locked>
<RollbackAllowed>false</RollbackAllowed>
- <CreatedTime>2012-08-24T09:13:53Z</CreatedTime>
- <LastModifiedTime>2012-08-27T08:55:13Z</LastModifiedTime>
- <ExtendedProperties/>
+ <VirtualNetworkName>jclouds</VirtualNetworkName>
+ <CreatedTime>2014-12-22T17:04:35Z</CreatedTime>
+ <LastModifiedTime>2014-12-22T17:07:02Z</LastModifiedTime>
+ <ExtendedProperties />
+ <PersistentVMDowntime>
+ <StartTime>2014-12-02T01:25:12Z</StartTime>
+ <EndTime>2014-12-04T01:25:12Z</EndTime>
+ <Status>PersistentVMUpdateScheduled</Status>
+ </PersistentVMDowntime>
+ <VirtualIPs>
+ <VirtualIP>
+ <Address>191.233.85.49</Address>
+ <IsDnsProgrammed>true</IsDnsProgrammed>
+ <Name>node1855162607153993262-b26ContractContract</Name>
+ </VirtualIP>
+ </VirtualIPs>
+ <InternalDnsSuffix>node1855162607153993262-b26.a5.internal.cloudapp.net</InternalDnsSuffix>
+ <LoadBalancers />
</Deployment>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/resources/deploymentparams-windows.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/deploymentparams-windows.xml b/azurecompute/src/test/resources/deploymentparams-windows.xml
index a819115..a4f1d67 100644
--- a/azurecompute/src/test/resources/deploymentparams-windows.xml
+++ b/azurecompute/src/test/resources/deploymentparams-windows.xml
@@ -1 +1 @@
-<Deployment xmlns="http://schemas.microsoft.com/windowsazure"><Name>mydeployment</Name><DeploymentSlot>Production</DeploymentSlot><Label>mydeployment</Label><RoleList><Role><RoleName>mydeployment</RoleName><RoleType>PersistentVMRole</RoleType><ConfigurationSets><ConfigurationSet><ConfigurationSetType>WindowsProvisioningConfiguration</ConfigurationSetType><ComputerName>mydeployment</ComputerName><AdminPassword>testpwd</AdminPassword><ResetPasswordOnFirstLogon>false</ResetPasswordOnFirstLogon><EnableAutomaticUpdate>false</EnableAutomaticUpdate><DomainJoin><Credentials><Domain>mydeployment</Domain><Username>username</Username><Password>testpwd</Password></Credentials><JoinDomain>mydeployment</JoinDomain></DomainJoin><StoredCertificateSettings/></ConfigurationSet><ConfigurationSet><ConfigurationSetType>NetworkConfiguration</ConfigurationSetType><InputEndpoints><InputEndpoint><LocalPort>8080</LocalPort><Name>tcp 80:8080</Name><Port>80</Port><Protocol>tcp</Protocol></InputEndpoint><InputE
ndpoint><LocalPort>53</LocalPort><Name>udp 53:53</Name><Port>53</Port><Protocol>udp</Protocol></InputEndpoint></InputEndpoints><SubnetNames/></ConfigurationSet></ConfigurationSets><DataVirtualHardDisks/><OSVirtualHardDisk><HostCaching>ReadWrite</HostCaching><MediaLink>http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</MediaLink><SourceImageName>MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</SourceImageName><OS>Windows</OS></OSVirtualHardDisk><RoleSize>Medium</RoleSize></Role></RoleList></Deployment>
\ No newline at end of file
+<Deployment xmlns="http://schemas.microsoft.com/windowsazure"><Name>mydeployment</Name><DeploymentSlot>Production</DeploymentSlot><Label>mydeployment</Label><RoleList><Role><RoleName>mydeployment</RoleName><RoleType>PersistentVMRole</RoleType><ConfigurationSets><ConfigurationSet><ConfigurationSetType>WindowsProvisioningConfiguration</ConfigurationSetType><ComputerName>mydeployment</ComputerName><AdminPassword>testpwd</AdminPassword><ResetPasswordOnFirstLogon>false</ResetPasswordOnFirstLogon><EnableAutomaticUpdate>false</EnableAutomaticUpdate><DomainJoin><Credentials><Domain>mydeployment</Domain><Username>username</Username><Password>testpwd</Password></Credentials><JoinDomain>mydeployment</JoinDomain></DomainJoin><StoredCertificateSettings/></ConfigurationSet><ConfigurationSet><ConfigurationSetType>NetworkConfiguration</ConfigurationSetType><InputEndpoints><InputEndpoint><LocalPort>8080</LocalPort><Name>tcp_80-8080</Name><Port>80</Port><Protocol>tcp</Protocol></InputEndpoint><InputE
ndpoint><LocalPort>53</LocalPort><Name>udp_53-53</Name><Port>53</Port><Protocol>udp</Protocol></InputEndpoint></InputEndpoints><SubnetNames/></ConfigurationSet></ConfigurationSets><DataVirtualHardDisks/><OSVirtualHardDisk><HostCaching>ReadWrite</HostCaching><MediaLink>http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</MediaLink><SourceImageName>MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</SourceImageName><OS>Windows</OS></OSVirtualHardDisk><RoleSize>Medium</RoleSize></Role></RoleList></Deployment>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/resources/deploymentparams.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/deploymentparams.xml b/azurecompute/src/test/resources/deploymentparams.xml
index 415276f..aa98238 100644
--- a/azurecompute/src/test/resources/deploymentparams.xml
+++ b/azurecompute/src/test/resources/deploymentparams.xml
@@ -1 +1 @@
-<Deployment xmlns="http://schemas.microsoft.com/windowsazure"><Name>mydeployment</Name><DeploymentSlot>Production</DeploymentSlot><Label>mydeployment</Label><RoleList><Role><RoleName>mydeployment</RoleName><RoleType>PersistentVMRole</RoleType><ConfigurationSets><ConfigurationSet><ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType><HostName>mydeployment</HostName><UserName>username</UserName><UserPassword>testpwd</UserPassword><DisableSshPasswordAuthentication>false</DisableSshPasswordAuthentication><SSH/></ConfigurationSet><ConfigurationSet><ConfigurationSetType>NetworkConfiguration</ConfigurationSetType><InputEndpoints><InputEndpoint><LocalPort>8080</LocalPort><Name>tcp 80:8080</Name><Port>80</Port><Protocol>tcp</Protocol></InputEndpoint><InputEndpoint><LocalPort>53</LocalPort><Name>udp 53:53</Name><Port>53</Port><Protocol>udp</Protocol></InputEndpoint></InputEndpoints><SubnetNames/></ConfigurationSet></ConfigurationSets><DataVirtualHardDisks/><OSVirtualHardD
isk><HostCaching>ReadWrite</HostCaching><MediaLink>http://blobs/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd</MediaLink><SourceImageName>OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd</SourceImageName><OS>Linux</OS></OSVirtualHardDisk><RoleSize>Medium</RoleSize></Role></RoleList></Deployment>
\ No newline at end of file
+<Deployment xmlns="http://schemas.microsoft.com/windowsazure"><Name>mydeployment</Name><DeploymentSlot>Production</DeploymentSlot><Label>mydeployment</Label><RoleList><Role><RoleName>mydeployment</RoleName><RoleType>PersistentVMRole</RoleType><ConfigurationSets><ConfigurationSet><ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType><HostName>mydeployment</HostName><UserName>username</UserName><UserPassword>testpwd</UserPassword><DisableSshPasswordAuthentication>false</DisableSshPasswordAuthentication><SSH/></ConfigurationSet><ConfigurationSet><ConfigurationSetType>NetworkConfiguration</ConfigurationSetType><InputEndpoints><InputEndpoint><LocalPort>8080</LocalPort><Name>tcp_80-8080</Name><Port>80</Port><Protocol>tcp</Protocol></InputEndpoint><InputEndpoint><LocalPort>53</LocalPort><Name>udp_53-53</Name><Port>53</Port><Protocol>udp</Protocol></InputEndpoint></InputEndpoints><SubnetNames/></ConfigurationSet></ConfigurationSets><DataVirtualHardDisks/><OSVirtualHardD
isk><HostCaching>ReadWrite</HostCaching><MediaLink>http://blobs/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd</MediaLink><SourceImageName>OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd</SourceImageName><OS>Linux</OS></OSVirtualHardDisk><RoleSize>Medium</RoleSize></Role></RoleList></Deployment>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/resources/images.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/images.xml b/azurecompute/src/test/resources/images.xml
index 4601fc6..179ef75 100644
--- a/azurecompute/src/test/resources/images.xml
+++ b/azurecompute/src/test/resources/images.xml
@@ -92,4 +92,5 @@
<Eula>;</Eula>
<Description/>
</OSImage>
-</Images>
\ No newline at end of file
+</Images>
+
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/logback.xml b/azurecompute/src/test/resources/logback.xml
new file mode 100644
index 0000000..c823913
--- /dev/null
+++ b/azurecompute/src/test/resources/logback.xml
@@ -0,0 +1,34 @@
+<?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>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>- %msg%n</pattern>
+ </encoder>
+ </appender>
+ <root level="info">
+ <appender-ref ref="STDOUT"/>
+ </root>
+ <logger name="jclouds.compute" level="debug"/>
+ <logger name="net.schmizz" level="warn"/>
+ <logger name="jclouds.wire" level="debug"/>
+ <logger name="jclouds.headers" level="debug"/>
+ <logger name="jclouds.ssh" level="debug"/>
+</configuration>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/resources/networksecuritygroup.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/networksecuritygroup.xml b/azurecompute/src/test/resources/networksecuritygroup.xml
new file mode 100644
index 0000000..34f5026
--- /dev/null
+++ b/azurecompute/src/test/resources/networksecuritygroup.xml
@@ -0,0 +1,85 @@
+<NetworkSecurityGroup xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
+ <Name>jclouds-NSG</Name>
+ <Label>jclouds-NSG</Label>
+ <Location>West Europe</Location>
+ <Rules>
+ <Rule>
+ <Name>ALLOW VNET INBOUND</Name>
+ <Type>Inbound</Type>
+ <Priority>65000</Priority>
+ <Action>Allow</Action>
+ <SourceAddressPrefix>VIRTUAL_NETWORK</SourceAddressPrefix>
+ <SourcePortRange>*</SourcePortRange>
+ <DestinationAddressPrefix>VIRTUAL_NETWORK</DestinationAddressPrefix>
+ <DestinationPortRange>*</DestinationPortRange>
+ <Protocol>*</Protocol>
+ <State>Active</State>
+ <IsDefault>true</IsDefault>
+ </Rule>
+ <Rule>
+ <Name>ALLOW VNET OUTBOUND</Name>
+ <Type>Outbound</Type>
+ <Priority>65000</Priority>
+ <Action>Allow</Action>
+ <SourceAddressPrefix>VIRTUAL_NETWORK</SourceAddressPrefix>
+ <SourcePortRange>*</SourcePortRange>
+ <DestinationAddressPrefix>VIRTUAL_NETWORK</DestinationAddressPrefix>
+ <DestinationPortRange>*</DestinationPortRange>
+ <Protocol>*</Protocol>
+ <State>Active</State>
+ <IsDefault>true</IsDefault>
+ </Rule>
+ <Rule>
+ <Name>ALLOW AZURE LOAD BALANCER INBOUND</Name>
+ <Type>Inbound</Type>
+ <Priority>65001</Priority>
+ <Action>Allow</Action>
+ <SourceAddressPrefix>AZURE_LOADBALANCER</SourceAddressPrefix>
+ <SourcePortRange>*</SourcePortRange>
+ <DestinationAddressPrefix>*</DestinationAddressPrefix>
+ <DestinationPortRange>*</DestinationPortRange>
+ <Protocol>*</Protocol>
+ <State>Active</State>
+ <IsDefault>true</IsDefault>
+ </Rule>
+ <Rule>
+ <Name>ALLOW INTERNET OUTBOUND</Name>
+ <Type>Outbound</Type>
+ <Priority>65001</Priority>
+ <Action>Allow</Action>
+ <SourceAddressPrefix>*</SourceAddressPrefix>
+ <SourcePortRange>*</SourcePortRange>
+ <DestinationAddressPrefix>INTERNET</DestinationAddressPrefix>
+ <DestinationPortRange>*</DestinationPortRange>
+ <Protocol>*</Protocol>
+ <State>Active</State>
+ <IsDefault>true</IsDefault>
+ </Rule>
+ <Rule>
+ <Name>DENY ALL OUTBOUND</Name>
+ <Type>Outbound</Type>
+ <Priority>65500</Priority>
+ <Action>Deny</Action>
+ <SourceAddressPrefix>*</SourceAddressPrefix>
+ <SourcePortRange>*</SourcePortRange>
+ <DestinationAddressPrefix>*</DestinationAddressPrefix>
+ <DestinationPortRange>*</DestinationPortRange>
+ <Protocol>*</Protocol>
+ <State>Active</State>
+ <IsDefault>true</IsDefault>
+ </Rule>
+ <Rule>
+ <Name>DENY ALL INBOUND</Name>
+ <Type>Inbound</Type>
+ <Priority>65500</Priority>
+ <Action>Deny</Action>
+ <SourceAddressPrefix>*</SourceAddressPrefix>
+ <SourcePortRange>*</SourcePortRange>
+ <DestinationAddressPrefix>*</DestinationAddressPrefix>
+ <DestinationPortRange>*</DestinationPortRange>
+ <Protocol>*</Protocol>
+ <State>Active</State>
+ <IsDefault>true</IsDefault>
+ </Rule>
+ </Rules>
+</NetworkSecurityGroup>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/resources/rolesizes.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/rolesizes.xml b/azurecompute/src/test/resources/rolesizes.xml
new file mode 100644
index 0000000..ae4fec3
--- /dev/null
+++ b/azurecompute/src/test/resources/rolesizes.xml
@@ -0,0 +1,255 @@
+<RoleSizes xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
+ <RoleSize>
+ <Name>A5</Name>
+ <Label>A5 (2 cores, 14336 MB)</Label>
+ <Cores>2</Cores>
+ <MemoryInMb>14336</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>4</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>501760</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>138240</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>A6</Name>
+ <Label>A6 (4 cores, 28672 MB)</Label>
+ <Cores>4</Cores>
+ <MemoryInMb>28672</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>8</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>1024000</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>291840</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>A7</Name>
+ <Label>A7 (8 cores, 57344 MB)</Label>
+ <Cores>8</Cores>
+ <MemoryInMb>57344</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>16</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>2088960</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>619520</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>A8</Name>
+ <Label>A8 (8 cores, 57344 MB)</Label>
+ <Cores>8</Cores>
+ <MemoryInMb>57344</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>16</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>1861268</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>391828</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>A9</Name>
+ <Label>A9 (16 cores, 114688 MB)</Label>
+ <Cores>16</Cores>
+ <MemoryInMb>114688</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>16</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>1861268</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>391828</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Basic_A0</Name>
+ <Label>Basic_A0 (1 cores, 768 MB)</Label>
+ <Cores>1</Cores>
+ <MemoryInMb>768</MemoryInMb>
+ <SupportedByWebWorkerRoles>false</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>1</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>0</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>20480</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Basic_A1</Name>
+ <Label>Basic_A1 (1 cores, 1792 MB)</Label>
+ <Cores>1</Cores>
+ <MemoryInMb>1792</MemoryInMb>
+ <SupportedByWebWorkerRoles>false</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>2</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>0</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>40960</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Basic_A2</Name>
+ <Label>Basic_A2 (2 cores, 3584 MB)</Label>
+ <Cores>2</Cores>
+ <MemoryInMb>3584</MemoryInMb>
+ <SupportedByWebWorkerRoles>false</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>4</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>0</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>61440</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Basic_A3</Name>
+ <Label>Basic_A3 (4 cores, 7168 MB)</Label>
+ <Cores>4</Cores>
+ <MemoryInMb>7168</MemoryInMb>
+ <SupportedByWebWorkerRoles>false</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>8</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>0</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>122880</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Basic_A4</Name>
+ <Label>Basic_A4 (8 cores, 14336 MB)</Label>
+ <Cores>8</Cores>
+ <MemoryInMb>14336</MemoryInMb>
+ <SupportedByWebWorkerRoles>false</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>16</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>0</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>245760</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>ExtraLarge</Name>
+ <Label>ExtraLarge (8 cores, 14336 MB)</Label>
+ <Cores>8</Cores>
+ <MemoryInMb>14336</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>16</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>2088960</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>619520</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>ExtraSmall</Name>
+ <Label>ExtraSmall (1 cores, 768 MB)</Label>
+ <Cores>1</Cores>
+ <MemoryInMb>768</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>1</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>20480</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>20480</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Large</Name>
+ <Label>Large (4 cores, 7168 MB)</Label>
+ <Cores>4</Cores>
+ <MemoryInMb>7168</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>8</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>1024000</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>291840</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Medium</Name>
+ <Label>Medium (2 cores, 3584 MB)</Label>
+ <Cores>2</Cores>
+ <MemoryInMb>3584</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>4</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>501760</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>138240</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Small</Name>
+ <Label>Small (1 cores, 1792 MB)</Label>
+ <Cores>1</Cores>
+ <MemoryInMb>1792</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>2</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>230400</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>71680</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Standard_D1</Name>
+ <Label>Standard_D1 (1 cores, 3584 MB)</Label>
+ <Cores>1</Cores>
+ <MemoryInMb>3584</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>2</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>51200</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>51200</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Standard_D11</Name>
+ <Label>Standard_D11 (2 cores, 14336 MB)</Label>
+ <Cores>2</Cores>
+ <MemoryInMb>14336</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>4</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>102400</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>102400</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Standard_D12</Name>
+ <Label>Standard_D12 (4 cores, 28672 MB)</Label>
+ <Cores>4</Cores>
+ <MemoryInMb>28672</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>8</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>256000</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>256000</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Standard_D13</Name>
+ <Label>Standard_D13 (8 cores, 57344 MB)</Label>
+ <Cores>8</Cores>
+ <MemoryInMb>57344</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>16</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>512000</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>512000</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Standard_D14</Name>
+ <Label>Standard_D14 (16 cores, 114688 MB)</Label>
+ <Cores>16</Cores>
+ <MemoryInMb>114688</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>32</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>1024000</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>1024000</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Standard_D2</Name>
+ <Label>Standard_D2 (2 cores, 7168 MB)</Label>
+ <Cores>2</Cores>
+ <MemoryInMb>7168</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>4</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>102400</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>102400</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Standard_D3</Name>
+ <Label>Standard_D3 (4 cores, 14336 MB)</Label>
+ <Cores>4</Cores>
+ <MemoryInMb>14336</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>8</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>256000</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>256000</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+ <RoleSize>
+ <Name>Standard_D4</Name>
+ <Label>Standard_D4 (8 cores, 28672 MB)</Label>
+ <Cores>8</Cores>
+ <MemoryInMb>28672</MemoryInMb>
+ <SupportedByWebWorkerRoles>true</SupportedByWebWorkerRoles>
+ <SupportedByVirtualMachines>true</SupportedByVirtualMachines>
+ <MaxDataDiskCount>16</MaxDataDiskCount>
+ <WebWorkerResourceDiskSizeInMb>512000</WebWorkerResourceDiskSizeInMb>
+ <VirtualMachineResourceDiskSizeInMb>512000</VirtualMachineResourceDiskSizeInMb>
+ </RoleSize>
+</RoleSizes>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/resources/virtualIPs.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/virtualIPs.xml b/azurecompute/src/test/resources/virtualIPs.xml
new file mode 100644
index 0000000..c684d75
--- /dev/null
+++ b/azurecompute/src/test/resources/virtualIPs.xml
@@ -0,0 +1,7 @@
+<VirtualIPs>
+ <VirtualIP>
+ <Address>104.40.193.219</Address>
+ <IsDnsProgrammed>true</IsDnsProgrammed>
+ <Name>__PseudoBackEndContractVip</Name>
+ </VirtualIP>
+</VirtualIPs>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/resources/virtualnetworksites.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/virtualnetworksites.xml b/azurecompute/src/test/resources/virtualnetworksites.xml
new file mode 100644
index 0000000..5f62b11
--- /dev/null
+++ b/azurecompute/src/test/resources/virtualnetworksites.xml
@@ -0,0 +1,36 @@
+<VirtualNetworkSites xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
+ <VirtualNetworkSite>
+ <Name>Group Group testDocker</Name>
+ <Id>39d0d14b-fc1d-496f-8928-b5a13a6f4b64</Id>
+ <State>Created</State>
+ <AddressSpace>
+ <AddressPrefixes>
+ <AddressPrefix>10.1.0.0/16</AddressPrefix>
+ </AddressPrefixes>
+ </AddressSpace>
+ <Subnets>
+ <Subnet>
+ <Name>Subnet-1</Name>
+ <AddressPrefix>10.1.0.0/24</AddressPrefix>
+ </Subnet>
+ </Subnets>
+ <Location>West Europe</Location>
+ </VirtualNetworkSite>
+ <VirtualNetworkSite>
+ <Name>Group Group-1 dockertest</Name>
+ <Id>12252126-cffc-4fac-8ba4-afa7150a8d4a</Id>
+ <State>Created</State>
+ <AddressSpace>
+ <AddressPrefixes>
+ <AddressPrefix>10.2.0.0/16</AddressPrefix>
+ </AddressPrefixes>
+ </AddressSpace>
+ <Subnets>
+ <Subnet>
+ <Name>Subnet-1</Name>
+ <AddressPrefix>10.2.0.0/24</AddressPrefix>
+ </Subnet>
+ </Subnets>
+ <Location>West Europe</Location>
+ </VirtualNetworkSite>
+</VirtualNetworkSites>
[2/3] jclouds-labs git commit: azurecompute: improvements to the
domain objects
Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java
index dc05df5..dd37e32 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java
@@ -24,12 +24,17 @@ import org.xml.sax.Attributes;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
+import com.google.inject.Inject;
public final class ListLocationsHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<Location>> {
private boolean inLocation;
- private final LocationHandler locationHandler = new LocationHandler();
+ private final LocationHandler locationHandler;
private final Builder<Location> locations = ImmutableList.builder();
+ @Inject ListLocationsHandler(LocationHandler locationHandler) {
+ this.locationHandler = locationHandler;
+ }
+
@Override public List<Location> getResult() {
return locations.build();
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListNetworkSecurityGroupsHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListNetworkSecurityGroupsHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListNetworkSecurityGroupsHandler.java
new file mode 100644
index 0000000..9916fe6
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListNetworkSecurityGroupsHandler.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.azurecompute.xml;
+
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.NetworkSecurityGroup;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Inject;
+
+public class ListNetworkSecurityGroupsHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<NetworkSecurityGroup>> {
+
+ private boolean inNetworkSecurityGroup;
+ private final NetworkSecurityGroupHandler networkSecurityGroupHandler;
+ private final ImmutableList.Builder<NetworkSecurityGroup> networkSecurityGroups = ImmutableList.builder();
+
+ @Inject ListNetworkSecurityGroupsHandler(NetworkSecurityGroupHandler networkSecurityGroupHandler) {
+ this.networkSecurityGroupHandler = networkSecurityGroupHandler;
+ }
+
+ @Override public List<NetworkSecurityGroup> getResult() {
+ return networkSecurityGroups.build();
+ }
+
+ @Override public void startElement(String url, String name, String qName, Attributes attributes) {
+ if (qName.equals("NetworkSecurityGroup")) {
+ inNetworkSecurityGroup = true;
+ }
+ }
+
+ @Override public void endElement(String uri, String name, String qName) {
+ if (qName.equals("NetworkSecurityGroup")) {
+ inNetworkSecurityGroup = false;
+ networkSecurityGroups.add(networkSecurityGroupHandler.getResult());
+ } else if (inNetworkSecurityGroup) {
+ networkSecurityGroupHandler.endElement(uri, name, qName);
+ }
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) {
+ if (inNetworkSecurityGroup) {
+ networkSecurityGroupHandler.characters(ch, start, length);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
index a3b8819..b3ce14a 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
@@ -24,12 +24,17 @@ import org.xml.sax.Attributes;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
+import com.google.inject.Inject;
public final class ListOSImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<OSImage>> {
private boolean inOSImage;
- private final OSImageHandler OSImageHandler = new OSImageHandler();
+ private final OSImageHandler osImageHandler;
private final Builder<OSImage> images = ImmutableList.builder();
+ @Inject ListOSImagesHandler(OSImageHandler osImageHandler) {
+ this.osImageHandler = osImageHandler;
+ }
+
@Override
public List<OSImage> getResult() {
return images.build();
@@ -46,16 +51,16 @@ public final class ListOSImagesHandler extends ParseSax.HandlerForGeneratedReque
public void endElement(String uri, String name, String qName) {
if (qName.equals("OSImage")) {
inOSImage = false;
- images.add(OSImageHandler.getResult());
+ images.add(osImageHandler.getResult());
} else if (inOSImage) {
- OSImageHandler.endElement(uri, name, qName);
+ osImageHandler.endElement(uri, name, qName);
}
}
@Override
public void characters(char ch[], int start, int length) {
if (inOSImage) {
- OSImageHandler.characters(ch, start, length);
+ osImageHandler.characters(ch, start, length);
}
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListRoleSizesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListRoleSizesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListRoleSizesHandler.java
new file mode 100644
index 0000000..107418f
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListRoleSizesHandler.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.azurecompute.xml;
+
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.RoleSize;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Inject;
+
+public final class ListRoleSizesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<RoleSize>> {
+ private boolean inRoleSize;
+ private final RoleSizeHandler roleSizeHandler;
+ private final ImmutableList.Builder<RoleSize> roleSizes = ImmutableList.builder();
+
+ @Inject ListRoleSizesHandler(RoleSizeHandler roleSizeHandler) {
+ this.roleSizeHandler = roleSizeHandler;
+ }
+
+ @Override
+ public List<RoleSize> getResult() {
+ return roleSizes.build();
+ }
+
+ @Override
+ public void startElement(String url, String name, String qName, Attributes attributes) {
+ if (qName.equals("RoleSize")) {
+ inRoleSize = true;
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String name, String qName) {
+ if (qName.equals("RoleSize")) {
+ inRoleSize = false;
+ roleSizes.add(roleSizeHandler.getResult());
+ } else if (inRoleSize) {
+ roleSizeHandler.endElement(uri, name, qName);
+ }
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) {
+ if (inRoleSize) {
+ roleSizeHandler.characters(ch, start, length);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListStorageServicesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListStorageServicesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListStorageServicesHandler.java
new file mode 100644
index 0000000..aa993c6
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListStorageServicesHandler.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.azurecompute.xml;
+
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.StorageService;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Inject;
+
+public class ListStorageServicesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<StorageService>> {
+
+ private boolean inStorageService;
+ private final StorageServiceHandler storageServiceHandler;
+ private final ImmutableList.Builder<StorageService> storageAccounts = ImmutableList.builder();
+
+ @Inject ListStorageServicesHandler(StorageServiceHandler storageServiceHandler) {
+ this.storageServiceHandler = storageServiceHandler;
+ }
+
+ @Override
+ public List<StorageService> getResult() {
+ return storageAccounts.build();
+ }
+
+ @Override
+ public void startElement(String url, String name, String qName, Attributes attributes) {
+ if (qName.equals("StorageService")) {
+ inStorageService = true;
+ }
+ if (inStorageService) {
+ storageServiceHandler.startElement(url, name, qName, attributes);
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String name, String qName) {
+ if (qName.equals("StorageService")) {
+ inStorageService = false;
+ storageAccounts.add(storageServiceHandler.getResult());
+ } else if (inStorageService) {
+ storageServiceHandler.endElement(uri, name, qName);
+ }
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) {
+ if (inStorageService) {
+ storageServiceHandler.characters(ch, start, length);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListVirtualNetworkSitesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListVirtualNetworkSitesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListVirtualNetworkSitesHandler.java
new file mode 100644
index 0000000..134c102
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListVirtualNetworkSitesHandler.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.azurecompute.xml;
+
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.NetworkConfiguration.VirtualNetworkSite;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Inject;
+
+public class ListVirtualNetworkSitesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<VirtualNetworkSite>> {
+
+ private boolean inVirtualNetworkSite;
+ private final VirtualNetworkSiteHandler virtualNetworkSiteHandler;
+ private final ImmutableList.Builder<VirtualNetworkSite> virtualNetworkSites = ImmutableList.builder();
+
+ @Inject ListVirtualNetworkSitesHandler(VirtualNetworkSiteHandler virtualNetworkSiteHandler) {
+ this.virtualNetworkSiteHandler = virtualNetworkSiteHandler;
+ }
+
+ @Override public List<VirtualNetworkSite> getResult() {
+ return virtualNetworkSites.build();
+ }
+
+ @Override public void startElement(String url, String name, String qName, Attributes attributes) {
+ if (qName.equals("VirtualNetworkSite")) {
+ inVirtualNetworkSite = true;
+ }
+ if (inVirtualNetworkSite) {
+ virtualNetworkSiteHandler.startElement(url, name, qName, attributes);
+ }
+ }
+
+ @Override public void endElement(String uri, String name, String qName) {
+ if (qName.equals("VirtualNetworkSite")) {
+ inVirtualNetworkSite = false;
+ virtualNetworkSites.add(virtualNetworkSiteHandler.getResult());
+ } else if (inVirtualNetworkSite) {
+ virtualNetworkSiteHandler.endElement(uri, name, qName);
+ }
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) {
+ if (inVirtualNetworkSite) {
+ virtualNetworkSiteHandler.characters(ch, start, length);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/NetworkConfigurationHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/NetworkConfigurationHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/NetworkConfigurationHandler.java
new file mode 100644
index 0000000..10666ec
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/NetworkConfigurationHandler.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.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.NetworkConfiguration;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.Lists;
+
+public class NetworkConfigurationHandler extends ParseSax.HandlerForGeneratedRequestWithResult<NetworkConfiguration> {
+
+ private String dns;
+ private List<NetworkConfiguration.VirtualNetworkSite> virtualNetworkSites = Lists.newArrayList();
+
+ private boolean inVirtualNetworkSites;
+ private final VirtualNetworkSiteHandler virtualNetworkSiteHandler = new VirtualNetworkSiteHandler();
+
+ private final StringBuilder currentText = new StringBuilder();
+
+ @Override public void startElement(String url, String name, String qName, Attributes attributes) {
+ if (qName.equals("VirtualNetworkSite")) {
+ inVirtualNetworkSites = true;
+ }
+ }
+
+ @Override
+ public NetworkConfiguration getResult() {
+ return NetworkConfiguration.create(dns, virtualNetworkSites);
+ }
+
+ @Override
+ public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("Dns")) {
+ dns = currentOrNull(currentText);
+ } else if (qName.equals("VirtualNetworkSites")) {
+ inVirtualNetworkSites = false;
+ } else if (qName.equals("VirtualNetworkSite")) {
+ virtualNetworkSites.add(virtualNetworkSiteHandler.getResult());
+ } else if (inVirtualNetworkSites) {
+ virtualNetworkSiteHandler.endElement(ignoredUri, ignoredName, qName);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ if (inVirtualNetworkSites) {
+ virtualNetworkSiteHandler.characters(ch, start, length);
+ } else
+ currentText.append(ch, start, length);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/NetworkSecurityGroupHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/NetworkSecurityGroupHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/NetworkSecurityGroupHandler.java
new file mode 100644
index 0000000..6ee7aee
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/NetworkSecurityGroupHandler.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.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.NetworkSecurityGroup;
+import org.jclouds.azurecompute.domain.Rule;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.Lists;
+
+public class NetworkSecurityGroupHandler extends ParseSax.HandlerForGeneratedRequestWithResult<NetworkSecurityGroup> {
+ private String name;
+ private String label;
+ private String location;
+ private List<Rule> rules = Lists.newArrayList();
+
+ private boolean inRule;
+ private final RuleHandler ruleHandler = new RuleHandler();
+
+ private final StringBuilder currentText = new StringBuilder();
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ if (qName.equals("Rule")) {
+ inRule = true;
+ }
+ }
+
+ @Override public NetworkSecurityGroup getResult() {
+ NetworkSecurityGroup result = NetworkSecurityGroup.create(name, label, location, rules);
+ name = label = location = null; // handler is called in a loop.
+ rules = Lists.newArrayList();
+ return result;
+ }
+
+ @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("Rule")) {
+ inRule = false;
+ rules.add(ruleHandler.getResult());
+ } else if (inRule) {
+ ruleHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (qName.equals("Name")) {
+ name = currentOrNull(currentText);
+ } else if (qName.equals("Label")) {
+ label = currentOrNull(currentText);
+ } else if (qName.equals("Location")) {
+ location = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ if (inRule) {
+ ruleHandler.characters(ch, start, length);
+ } else {
+ currentText.append(ch, start, length);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
index ddbbc30..1150ffb 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
@@ -20,9 +20,11 @@ import static com.google.common.base.Strings.emptyToNull;
import static org.jclouds.util.SaxUtils.currentOrNull;
import java.net.URI;
+import java.util.Date;
import java.util.List;
import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.functions.ParseSax;
import com.google.common.base.Splitter;
@@ -33,6 +35,7 @@ import com.google.common.collect.Lists;
* @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
*/
final class OSImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult<OSImage> {
+
private String name;
private String location;
private String affinityGroup;
@@ -40,10 +43,19 @@ final class OSImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult
private String category;
private String description;
private OSImage.Type os;
- private String publisherName;
private URI mediaLink;
private Integer logicalSizeInGB;
private final List<String> eulas = Lists.newArrayList();
+ private String imageFamily;
+ private Date publishedDate;
+ private String iconUri;
+ private String smallIconUri;
+ private URI privacyUri;
+ private URI pricingDetailLink;
+ private String recommendedVMSize;
+ private Boolean isPremium;
+ private Boolean showInGui;
+ private String publisherName;
private final StringBuilder currentText = new StringBuilder();
@@ -57,11 +69,16 @@ final class OSImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult
}
private void resetState() {
- name = affinityGroup = label = description = category = null;
+ name = affinityGroup = label = description = category = imageFamily = iconUri = smallIconUri = recommendedVMSize
+ = publisherName = null;
os = null;
publisherName = null;
mediaLink = null;
logicalSizeInGB = null;
+ publishedDate = null;
+ privacyUri = pricingDetailLink = null;
+ isPremium = null;
+ showInGui = null;
eulas.clear();
location = null;
}
@@ -105,7 +122,43 @@ final class OSImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult
}
} else if (qName.equals("Label")) {
label = currentOrNull(currentText);
+ } else if (qName.equals("ImageFamily")) {
+ imageFamily = currentOrNull(currentText);
+ } else if (qName.equals("PublishedDate")) {
+ String date = currentOrNull(currentText);
+ if (date != null) {
+ publishedDate = new SimpleDateFormatDateService().iso8601DateOrSecondsDateParse(date);
+ }
+ } else if (qName.equals("IconUri")) {
+ iconUri = currentOrNull(currentText);
+ } else if (qName.equals("SmallIconUri")) {
+ smallIconUri = currentOrNull(currentText);
+ } else if (qName.equals("PrivacyUri")) {
+ String uri = currentOrNull(currentText);
+ if (uri != null) {
+ privacyUri = URI.create(uri);
+ }
+ } else if (qName.equals("RecommendedVMSize")) {
+ recommendedVMSize = currentOrNull(currentText);
+ } else if (qName.equals("IsPremium")) {
+ String premium = currentOrNull(currentText);
+ if (premium != null) {
+ isPremium = Boolean.valueOf(premium);
+ }
+ } else if (qName.equals("ShowInGui")) {
+ String show = currentOrNull(currentText);
+ if (show != null) {
+ showInGui = Boolean.valueOf(show);
+ }
+ } else if (qName.equals("PublisherName")) {
+ publisherName = currentOrNull(currentText);
+ } else if (qName.equals("PricingDetailLink")) {
+ String uri = currentOrNull(currentText);
+ if (uri != null) {
+ pricingDetailLink = URI.create(uri);
+ }
}
+
currentText.setLength(0);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSVirtualHardDiskHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSVirtualHardDiskHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSVirtualHardDiskHandler.java
new file mode 100644
index 0000000..d2f7332
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSVirtualHardDiskHandler.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.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+import java.net.URI;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.azurecompute.domain.Role;
+import org.jclouds.http.functions.ParseSax;
+
+public class OSVirtualHardDiskHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Role.OSVirtualHardDisk> {
+ private String hostCaching;
+ private String diskName;
+ private URI mediaLink;
+ private String sourceImageName;
+ private OSImage.Type os;
+ private Integer lun;
+ private Integer logicalDiskSizeInGB;
+
+ private final StringBuilder currentText = new StringBuilder();
+
+ @Override public Role.OSVirtualHardDisk getResult() {
+ return Role.OSVirtualHardDisk.create(hostCaching, diskName, lun, logicalDiskSizeInGB, mediaLink, sourceImageName, os);
+ }
+
+ @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("HostCaching")) {
+ hostCaching = currentOrNull(currentText);
+ } else if (qName.equals("DiskName")) {
+ diskName = currentOrNull(currentText);
+ } else if (qName.equals("MediaLink")) {
+ String link = currentOrNull(currentText);
+ if (link != null) {
+ mediaLink = URI.create(link);
+ }
+ } else if (qName.equals("SourceImageName")) {
+ sourceImageName = currentOrNull(currentText);
+ } else if (qName.equals("OS")) {
+ String osText = currentOrNull(currentText);
+ if (osText != null) {
+ os = OSImage.Type.valueOf(currentOrNull(currentText).toUpperCase());
+ }
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RoleHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RoleHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RoleHandler.java
new file mode 100644
index 0000000..f066526
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RoleHandler.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.DataVirtualHardDisk;
+import org.jclouds.azurecompute.domain.Role;
+import org.jclouds.azurecompute.domain.Role.ConfigurationSet;
+import org.jclouds.azurecompute.domain.Role.ResourceExtensionReference;
+import org.jclouds.azurecompute.domain.RoleSize;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.Lists;
+import com.google.inject.Inject;
+
+public class RoleHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Role> {
+
+ private String roleName;
+ private String roleType;
+ private String vmImage;
+ private String mediaLocation;
+ private List<ConfigurationSet> configurationSets = Lists.newArrayList();
+ private List<ResourceExtensionReference> resourceExtensionReferences = Lists.newArrayList();
+ private String availabilitySetName;
+ private List<DataVirtualHardDisk> dataVirtualHardDisks = Lists.newArrayList();
+ private Role.OSVirtualHardDisk osVirtualHardDisk;
+ private RoleSize.Type roleSize;
+ private Boolean provisionGuestAgent;
+ private String defaultWinRmCertificateThumbprint;
+
+ private boolean inConfigurationSets;
+ private boolean inOSVirtualHardDisk;
+ private boolean inDataVirtualHardDisks;
+
+ private final ConfigurationSetHandler configurationSetHandler;
+ private final OSVirtualHardDiskHandler osVirtualDiskHandler;
+ private final DataVirtualHardDiskHandler dataVirtualHardDiskHandler;
+
+ @Inject
+ RoleHandler(ConfigurationSetHandler configurationSetHandler, OSVirtualHardDiskHandler osVirtualDiskHandler,
+ DataVirtualHardDiskHandler dataVirtualHardDiskHandler) {
+ this.configurationSetHandler = configurationSetHandler;
+ this.osVirtualDiskHandler = osVirtualDiskHandler;
+ this.dataVirtualHardDiskHandler = dataVirtualHardDiskHandler;
+ }
+
+ private StringBuilder currentText = new StringBuilder();
+
+ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ if (qName.equals("ConfigurationSets")) {
+ inConfigurationSets = true;
+ }
+ if (inConfigurationSets) {
+ configurationSetHandler.startElement(uri, localName, qName, attributes);
+ }
+ if (qName.equals("OSVirtualHardDisk")) {
+ inOSVirtualHardDisk = true;
+ }
+ if (qName.equals("DataVirtualHardDisks")) {
+ inDataVirtualHardDisks = true;
+ }
+ if (inDataVirtualHardDisks) {
+ dataVirtualHardDiskHandler.startElement(uri, localName, qName, attributes);
+ }
+ }
+
+ private void resetState() {
+ roleName = roleType = vmImage = mediaLocation = availabilitySetName = defaultWinRmCertificateThumbprint = null;
+ configurationSets = null;
+ osVirtualHardDisk = null;
+ configurationSets = Lists.newArrayList();
+ resourceExtensionReferences = Lists.newArrayList();
+ dataVirtualHardDisks = Lists.newArrayList();
+ roleSize = null;
+ provisionGuestAgent = null;
+ }
+
+ @Override
+ public Role getResult() {
+ Role result = Role.create(roleName, roleType, vmImage, mediaLocation, configurationSets,
+ resourceExtensionReferences, availabilitySetName, dataVirtualHardDisks, osVirtualHardDisk, roleSize,
+ provisionGuestAgent, defaultWinRmCertificateThumbprint);
+ resetState(); // handler is called in a loop.
+ return result;
+ }
+
+ @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("DataVirtualHardDisks")) {
+ inDataVirtualHardDisks = false;
+ } else if (qName.equals("ConfigurationSet")) {
+ inConfigurationSets = false;
+ configurationSets.add(configurationSetHandler.getResult());
+ } else if (inConfigurationSets) {
+ configurationSetHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (qName.equals("DataVirtualHardDisks")) {
+ inDataVirtualHardDisks = false;
+ dataVirtualHardDisks.add(dataVirtualHardDiskHandler.getResult());
+ } else if (inDataVirtualHardDisks) {
+ dataVirtualHardDiskHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (qName.equals("RoleName")) {
+ roleName = currentOrNull(currentText);
+ } else if (qName.equals("VMImage")) {
+ vmImage = currentOrNull(currentText);
+ } else if (qName.equals("MediaLocation")) {
+ mediaLocation = currentOrNull(currentText);
+ } else if (qName.equals("AvailabilitySetName")) {
+ availabilitySetName = currentOrNull(currentText);
+ } else if (qName.equals("DefaultWinRmCertificateThumbprint")) {
+ defaultWinRmCertificateThumbprint = currentOrNull(currentText);
+ } else if (qName.equals("RoleType")) {
+ roleType = currentOrNull(currentText);
+ } else if (qName.equals("OSVirtualHardDisk")) {
+ inOSVirtualHardDisk = false;
+ osVirtualHardDisk = osVirtualDiskHandler.getResult();
+ } else if (inOSVirtualHardDisk) {
+ osVirtualDiskHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (qName.equals("RoleSize")) {
+ roleSize = RoleSize.Type.valueOf(currentOrNull(currentText).toUpperCase());
+ } else if (qName.equals("ProvisionGuestAgent")) {
+ String provisionGuestAgentString = currentOrNull(currentText);
+ if (provisionGuestAgentString != null) {
+ provisionGuestAgent = Boolean.valueOf(provisionGuestAgentString);
+ }
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ if (inConfigurationSets) {
+ configurationSetHandler.characters(ch, start, length);
+ } else if (inOSVirtualHardDisk) {
+ osVirtualDiskHandler.characters(ch, start, length);
+ } else {
+ currentText.append(ch, start, length);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RoleInstanceHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RoleInstanceHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RoleInstanceHandler.java
new file mode 100644
index 0000000..fa6d2b5
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RoleInstanceHandler.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.azurecompute.xml;
+
+import static com.google.common.base.CaseFormat.UPPER_CAMEL;
+import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
+import static org.jclouds.util.SaxUtils.currentOrNull;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.Deployment.InstanceEndpoint;
+import org.jclouds.azurecompute.domain.Deployment.InstanceStatus;
+import org.jclouds.azurecompute.domain.Deployment.RoleInstance;
+import org.jclouds.azurecompute.domain.RoleSize;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.Lists;
+
+public class RoleInstanceHandler extends ParseSax.HandlerForGeneratedRequestWithResult<RoleInstance> {
+
+ private String roleName;
+ private String instanceName;
+ private InstanceStatus instanceStatus;
+ private Integer instanceUpgradeDomain;
+ private Integer instanceFaultDomain;
+ private RoleSize.Type instanceSize;
+ private String ipAddress;
+ private String hostname;
+
+ private boolean inInstanceEndpoints;
+ private final InstanceEndpointHandler instanceEndpointHandler = new InstanceEndpointHandler();
+
+ private List<InstanceEndpoint> instanceEndpoints = Lists.newArrayList();
+
+ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ if (qName.equals("InstanceEndpoints")) {
+ inInstanceEndpoints = true;
+ }
+ if (inInstanceEndpoints) {
+ instanceEndpointHandler.startElement(uri, localName, qName, attributes);
+ }
+ }
+
+ private void resetState() {
+ roleName = instanceName = ipAddress = hostname = null;
+ instanceStatus = null;
+ instanceUpgradeDomain = instanceFaultDomain = null;
+ instanceSize = null;
+ instanceEndpoints = Lists.newArrayList();
+ }
+
+ private StringBuilder currentText = new StringBuilder();
+ @Override
+ public RoleInstance getResult() {
+ RoleInstance result = RoleInstance.create(roleName, instanceName, instanceStatus, instanceUpgradeDomain,
+ instanceFaultDomain, instanceSize, ipAddress, hostname, instanceEndpoints);
+ resetState(); // handler is called in a loop.
+ return result;
+ }
+
+ @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("InstanceEndpoints")) {
+ inInstanceEndpoints = false;
+ } else if (qName.equals("InstanceEndpoint")) {
+ instanceEndpoints.add(instanceEndpointHandler.getResult());
+ } else if (inInstanceEndpoints) {
+ instanceEndpointHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (qName.equals("RoleName")) {
+ roleName = currentOrNull(currentText);
+ } else if (qName.equals("InstanceName")) {
+ instanceName = currentOrNull(currentText);
+ } else if (qName.equals("InstanceStatus")) {
+ String instanceStatusText = currentOrNull(currentText);
+ if (instanceStatusText != null) {
+ instanceStatus = parseInstanceStatus(instanceStatusText);
+ }
+ } else if (qName.equals("InstanceUpgradeDomain")) {
+ String upgradeDomain = currentOrNull(currentText);
+ if (upgradeDomain != null) {
+ instanceUpgradeDomain = Integer.parseInt(upgradeDomain);
+ }
+ } else if (qName.equals("InstanceFaultDomain")) {
+ String faultDomain = currentOrNull(currentText);
+ if (faultDomain != null) {
+ instanceFaultDomain = Integer.parseInt(faultDomain);
+ }
+ } else if (qName.equals("InstanceSize")) {
+ String size = currentOrNull(currentText);
+ if (size != null) {
+ instanceSize = RoleSize.Type.fromString(size);
+ }
+ } else if (qName.equals("IpAddress")) {
+ ipAddress = currentOrNull(currentText);
+ } else if (qName.equals("HostName")) {
+ hostname = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ if (inInstanceEndpoints) {
+ instanceEndpointHandler.characters(ch, start, length);
+ } else {
+ currentText.append(ch, start, length);
+ }
+ }
+
+ static InstanceStatus parseInstanceStatus(String instanceStatus) {
+ try {
+ // Azure isn't exactly upper-camel, as some states end in VM, not Vm.
+ return InstanceStatus.valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, instanceStatus).replace("V_M", "VM"));
+ } catch (IllegalArgumentException e) {
+ return InstanceStatus.UNRECOGNIZED;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RoleSizeHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RoleSizeHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RoleSizeHandler.java
new file mode 100644
index 0000000..271a57e
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RoleSizeHandler.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+import org.jclouds.azurecompute.domain.RoleSize;
+import org.jclouds.http.functions.ParseSax;
+
+/**
+ * @see <a href="http://msdn.microsoft.com/en-us/library/dn469422.aspx" >api</a>
+ */
+final class RoleSizeHandler extends ParseSax.HandlerForGeneratedRequestWithResult<RoleSize> {
+ private RoleSize.Type name;
+ private String label;
+ private Integer cores;
+ private Integer memoryInMb;
+ private Boolean supportedByWebWorkerRoles;
+ private Boolean supportedByVirtualMachines;
+ private Integer maxDataDiskCount;
+ private Integer webWorkerResourceDiskSizeInMb;
+ private Integer virtualMachineResourceDiskSizeInMb;
+
+ private final StringBuilder currentText = new StringBuilder();
+
+ @Override
+ public RoleSize getResult() {
+ return RoleSize.create(name, label, cores, memoryInMb, supportedByWebWorkerRoles,
+ supportedByVirtualMachines, maxDataDiskCount, webWorkerResourceDiskSizeInMb, virtualMachineResourceDiskSizeInMb);
+ }
+
+ @Override
+ public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("Name")) {
+ String type = currentOrNull(currentText);
+ if (type != null) {
+ name = RoleSize.Type.valueOf(currentOrNull(currentText).toUpperCase());
+ }
+ } else if (qName.equals("Label")) {
+ label = currentOrNull(currentText);
+
+ } else if (qName.equals("Cores")) {
+ String coresString = currentOrNull(currentText);
+ if (coresString != null) {
+ cores = Integer.parseInt(coresString);
+ }
+ } else if (qName.equals("MemoryInMb")) {
+ String memoryInMbString = currentOrNull(currentText);
+ if (memoryInMbString != null) {
+ memoryInMb = Integer.parseInt(memoryInMbString);
+ }
+ } else if (qName.equals("SupportedByWebWorkerRoles")) {
+ String supportedByWebWorkerRolesString = currentOrNull(currentText);
+ if (supportedByWebWorkerRolesString != null) {
+ supportedByWebWorkerRoles = Boolean.valueOf(supportedByWebWorkerRolesString);
+ }
+ } else if (qName.equals("SupportedByVirtualMachines")) {
+ String supportedByVirtualMachinesString = currentOrNull(currentText);
+ if (supportedByVirtualMachinesString != null) {
+ supportedByVirtualMachines = Boolean.valueOf(supportedByVirtualMachinesString);
+ }
+ } else if (qName.equals("MaxDataDiskCount")) {
+ String maxDataDiskCountString = currentOrNull(currentText);
+ if (maxDataDiskCountString != null) {
+ maxDataDiskCount = Integer.parseInt(maxDataDiskCountString);
+ }
+ } else if (qName.equals("WebWorkerResourceDiskSizeInMb")) {
+ String webWorkerResourceDiskSizeInMbString = currentOrNull(currentText);
+ if (webWorkerResourceDiskSizeInMbString != null) {
+ webWorkerResourceDiskSizeInMb = Integer.parseInt(webWorkerResourceDiskSizeInMbString);
+ }
+ } else if (qName.equals("VirtualMachineResourceDiskSizeInMb")) {
+ String virtualMachineResourceDiskSizeInMbString = currentOrNull(currentText);
+ if (virtualMachineResourceDiskSizeInMbString != null) {
+ virtualMachineResourceDiskSizeInMb = Integer.parseInt(virtualMachineResourceDiskSizeInMbString);
+ }
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RuleHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RuleHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RuleHandler.java
new file mode 100644
index 0000000..9e7243c
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/RuleHandler.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.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import org.jclouds.azurecompute.domain.Rule;
+import org.jclouds.http.functions.ParseSax;
+
+final class RuleHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Rule> {
+
+ private String name;
+ private String type;
+ private String priority;
+ private String action;
+ private String sourceAddressPrefix;
+ private String sourcePortRange;
+ private String destinationAddressPrefix;
+ private String destinationPortRange;
+ private String protocol;
+ private String state;
+ private Boolean isDefault;
+
+ private final StringBuilder currentText = new StringBuilder();
+
+ @Override public Rule getResult() {
+ Rule result = Rule.create(name, type, priority, action, sourceAddressPrefix, sourcePortRange,
+ destinationAddressPrefix, destinationPortRange, protocol, state, isDefault);
+ name = type = priority = action = sourceAddressPrefix = sourcePortRange = destinationAddressPrefix =
+ destinationPortRange = protocol = state = null; // handler is called in a loop.
+ isDefault = false;
+ return result;
+ }
+
+ @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("Name")) {
+ name = currentOrNull(currentText);
+ } else if (qName.equals("Type")) {
+ type = currentOrNull(currentText);
+ } else if (qName.equals("Priority")) {
+ priority = currentOrNull(currentText);
+ } else if (qName.equals("Action")) {
+ action = currentOrNull(currentText);
+ } else if (qName.equals("SourceAddressPrefix")) {
+ sourceAddressPrefix = currentOrNull(currentText);
+ } else if (qName.equals("SourcePortRange")) {
+ sourcePortRange = currentOrNull(currentText);
+ } else if (qName.equals("DestinationAddressPrefix")) {
+ destinationAddressPrefix = currentOrNull(currentText);
+ } else if (qName.equals("DestinationPortRange")) {
+ destinationPortRange = currentOrNull(currentText);
+ } else if (qName.equals("Protocol")) {
+ protocol = currentOrNull(currentText);
+ } else if (qName.equals("State")) {
+ state = currentOrNull(currentText);
+ } else if (qName.equals("IsDefault")) {
+ String isDefaultString = currentOrNull(currentText);
+ if (isDefaultString != null) {
+ isDefault = Boolean.valueOf(isDefaultString);
+ }
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/StorageServiceHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/StorageServiceHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/StorageServiceHandler.java
new file mode 100644
index 0000000..99b49f2
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/StorageServiceHandler.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.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.jclouds.azurecompute.domain.StorageService;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.base.Throwables;
+
+/**
+ * @see <a href="http://msdn.microsoft.com/en-us/library/ee460787.aspx" >api</a>
+ */
+final class StorageServiceHandler extends ParseSax.HandlerForGeneratedRequestWithResult<StorageService> {
+ private URL url;
+ private String serviceName;
+ private StorageService.StorageServiceProperties storageServiceProperties;
+
+ private boolean inStorageServiceProperties;
+ private final StorageServicePropertiesHandler storageServicePropertiesHandler = new StorageServicePropertiesHandler();
+ private final StringBuilder currentText = new StringBuilder();
+
+ @Override
+ public StorageService getResult() {
+ StorageService result = StorageService.create(url, serviceName, storageServiceProperties);
+ resetState(); // handler is called in a loop.
+ return result;
+ }
+
+ private void resetState() {
+ serviceName = null;
+ url = null;
+ storageServiceProperties = null;
+ }
+
+ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ if (qName.equals("StorageServiceProperties")) {
+ inStorageServiceProperties = true;
+ }
+ }
+
+ @Override
+ public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("StorageServiceProperties")) {
+ storageServiceProperties = storageServicePropertiesHandler.getResult();
+ inStorageServiceProperties = false;
+ } else if (inStorageServiceProperties) {
+ storageServicePropertiesHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (qName.equals("Url")) {
+ String urlText = currentOrNull(currentText);
+ if (urlText != null) {
+ try {
+ url = new URL(urlText);
+ } catch (MalformedURLException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+ } else if (qName.equals("ServiceName")) {
+ serviceName = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ if (inStorageServiceProperties) {
+ storageServicePropertiesHandler.characters(ch, start, length);
+ } else {
+ currentText.append(ch, start, length);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/StorageServicePropertiesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/StorageServicePropertiesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/StorageServicePropertiesHandler.java
new file mode 100644
index 0000000..9e5e600
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/StorageServicePropertiesHandler.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.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import org.jclouds.azurecompute.domain.StorageService;
+import org.jclouds.http.functions.ParseSax;
+
+public class StorageServicePropertiesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<StorageService.StorageServiceProperties> {
+ private String description;
+ private String status;
+ private String location;
+ private String accountType;
+
+ private final StringBuilder currentText = new StringBuilder();
+
+ @Override public StorageService.StorageServiceProperties getResult() {
+ StorageService.StorageServiceProperties result = StorageService.StorageServiceProperties.create(description, status, location, accountType);
+ description = status = location = accountType = null; // handler could be called in a loop.
+ return result;
+ }
+
+ @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("Description")) {
+ description = currentOrNull(currentText);
+ } else if (qName.equals("Status")) {
+ status = currentOrNull(currentText);
+ } else if (qName.equals("Location")) {
+ location = currentOrNull(currentText);
+ } else if (qName.equals("AccountType")) {
+ accountType = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/SubnetHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/SubnetHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/SubnetHandler.java
new file mode 100644
index 0000000..5e2993d
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/SubnetHandler.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.azurecompute.xml;
+
+import static org.jclouds.azurecompute.domain.NetworkConfiguration.Subnet;
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+public class SubnetHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Subnet> {
+
+ private String name;
+ private String addressPrefix;
+ private String networkSecurityGroup;
+
+ private StringBuilder currentText = new StringBuilder();
+
+ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ }
+
+ @Override public Subnet getResult() {
+ Subnet result = Subnet.create(name, addressPrefix, networkSecurityGroup);
+ resetState(); // handler is called in a loop.
+ return result;
+ }
+
+ private void resetState() {
+ name = addressPrefix = null;
+ }
+
+ @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("Name")) {
+ name = currentOrNull(currentText);
+ } else if (qName.equals("AddressPrefix")) {
+ addressPrefix = currentOrNull(currentText);
+ } else if (qName.equals("NetworkSecurityGroup")) {
+ networkSecurityGroup = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/SubnetNameHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/SubnetNameHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/SubnetNameHandler.java
new file mode 100644
index 0000000..8bab972
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/SubnetNameHandler.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.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import org.jclouds.azurecompute.domain.Role;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+public class SubnetNameHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Role.ConfigurationSet.SubnetName> {
+ private String name;
+
+ private StringBuilder currentText = new StringBuilder();
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ }
+
+ @Override
+ public Role.ConfigurationSet.SubnetName getResult() {
+ Role.ConfigurationSet.SubnetName result = Role.ConfigurationSet.SubnetName.create(name);
+ resetState(); // handler is called in a loop.
+ return result;
+ }
+
+ private void resetState() {
+ name = null;
+ }
+
+ @Override
+ public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("SubnetName")) {
+ name = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/VirtualIPHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/VirtualIPHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/VirtualIPHandler.java
new file mode 100644
index 0000000..e1dff77
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/VirtualIPHandler.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.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import org.jclouds.azurecompute.domain.Deployment.VirtualIP;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+public final class VirtualIPHandler extends ParseSax.HandlerForGeneratedRequestWithResult<VirtualIP> {
+ private String address;
+ private Boolean isDnsProgrammed;
+ private String name;
+
+ private StringBuilder currentText = new StringBuilder();
+
+ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ }
+
+ @Override public VirtualIP getResult() {
+ VirtualIP result = VirtualIP.create(address, isDnsProgrammed, name);
+ resetState(); // handler is called in a loop.
+ return result;
+ }
+
+ private void resetState() {
+ name = address = null;
+ isDnsProgrammed = null;
+ }
+
+ @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("Address")) {
+ address = currentOrNull(currentText);
+ } else if (qName.equals("IsDnsProgrammed")) {
+ String dnsProgrammed = currentOrNull(currentText);
+ if (dnsProgrammed != null) {
+ isDnsProgrammed = Boolean.valueOf(dnsProgrammed);
+ }
+ } else if (qName.equals("Name")) {
+ name = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/VirtualNetworkSiteHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/VirtualNetworkSiteHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/VirtualNetworkSiteHandler.java
new file mode 100644
index 0000000..d196253
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/VirtualNetworkSiteHandler.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.NetworkConfiguration.AddressSpace;
+import org.jclouds.azurecompute.domain.NetworkConfiguration.Subnet;
+import org.jclouds.azurecompute.domain.NetworkConfiguration.VirtualNetworkSite;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.Lists;
+
+public class VirtualNetworkSiteHandler extends ParseSax.HandlerForGeneratedRequestWithResult<VirtualNetworkSite> {
+
+ private String id;
+ private String name;
+ private String location;
+ private AddressSpace addressSpace;
+ private List<Subnet> subnets = Lists.newArrayList();
+
+ private boolean inSubnet;
+ private boolean inAddressSpace;
+ private final SubnetHandler subnetHandler = new SubnetHandler();
+ private final AddressSpaceHandler addressSpaceHandler = new AddressSpaceHandler();
+
+ private StringBuilder currentText = new StringBuilder();
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ if (qName.equals("AddressSpace")) {
+ inAddressSpace = true;
+ } else if (qName.equals("Subnet")) {
+ inSubnet = true;
+ }
+ if (inAddressSpace) {
+ addressSpaceHandler.startElement(uri, name, qName, attributes);
+ }
+ if (inSubnet) {
+ subnetHandler.startElement(uri, name, qName, attributes);
+ }
+ }
+
+ private void resetState() {
+ id = name = location = null;
+ subnets = Lists.newArrayList();
+ addressSpace = null;
+ }
+
+ @Override
+ public VirtualNetworkSite getResult() {
+ VirtualNetworkSite result = VirtualNetworkSite.create(id, name, location, addressSpace, subnets);
+ resetState(); // handler is called in a loop.
+ return result;
+ }
+
+ @Override
+ public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("AddressSpace")) {
+ inAddressSpace = false;
+ addressSpace = addressSpaceHandler.getResult();
+ } else if (inAddressSpace) {
+ addressSpaceHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (qName.equals("Subnet")) {
+ inSubnet = false;
+ subnets.add(subnetHandler.getResult());
+ } else if (inSubnet) {
+ subnetHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (qName.equals("Id")) {
+ id = currentOrNull(currentText);
+ } else if (qName.equals("Name")) {
+ name = currentOrNull(currentText);
+ } else if (qName.equals("Location")) {
+ location = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ if (inAddressSpace) {
+ addressSpaceHandler.characters(ch, start, length);
+ } else if (inSubnet) {
+ subnetHandler.characters(ch, start, length);
+ } else if (!inAddressSpace && !inSubnet) {
+ currentText.append(ch, start, length);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
index a469df3..f027932 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
@@ -46,7 +46,7 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
DeploymentParams params = DeploymentParams.builder()
.name("mydeployment")
- .size(RoleSize.MEDIUM)
+ .size(RoleSize.Type.MEDIUM)
.sourceImageName(OSImage.name()).mediaLink(OSImage.mediaLink()).os(OSImage.os())
.username("username").password("testpwd")
.externalEndpoint(inboundTcpToLocalPort(80, 8080))
@@ -71,7 +71,7 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
DeploymentParams params = DeploymentParams.builder()
.name("mydeployment")
- .size(RoleSize.MEDIUM)
+ .size(RoleSize.Type.MEDIUM)
.sourceImageName(OSImage.name()).mediaLink(OSImage.mediaLink()).os(OSImage.os())
.username("username").password("testpwd")
.externalEndpoint(inboundTcpToLocalPort(80, 8080))
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
index ddd82a8..5dc041d 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
@@ -91,7 +91,7 @@ public class BaseAzureComputeApiMockTest {
protected RecordedRequest assertSent(MockWebServer server, String method, String path, String resource)
throws InterruptedException {
RecordedRequest request = assertSent(server, method, path);
- assertThat(new String(request.getBody(), UTF_8)).isEqualTo(stringFromResource(resource));
+ assertThat(new String(request.getBody(), UTF_8)).isEqualTo(stringFromResource(resource).trim());
return request;
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/java/org/jclouds/azurecompute/xml/DeploymentHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/DeploymentHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/DeploymentHandlerTest.java
index d622b42..c131971 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/DeploymentHandlerTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/DeploymentHandlerTest.java
@@ -18,17 +18,25 @@ package org.jclouds.azurecompute.xml;
import static org.jclouds.azurecompute.xml.DeploymentHandler.parseInstanceStatus;
import static org.testng.Assert.assertEquals;
-
import java.io.InputStream;
+import java.net.URI;
+import org.jclouds.azurecompute.domain.DataVirtualHardDisk;
import org.jclouds.azurecompute.domain.Deployment;
import org.jclouds.azurecompute.domain.Deployment.InstanceStatus;
import org.jclouds.azurecompute.domain.Deployment.Slot;
import org.jclouds.azurecompute.domain.Deployment.Status;
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.azurecompute.domain.Role;
+import org.jclouds.azurecompute.domain.Role.ConfigurationSet;
+import org.jclouds.azurecompute.domain.Role.ConfigurationSet.InputEndpoint;
+import org.jclouds.azurecompute.domain.Role.OSVirtualHardDisk;
import org.jclouds.azurecompute.domain.RoleSize;
import org.jclouds.http.functions.BaseHandlerTest;
import org.testng.annotations.Test;
+import com.google.common.collect.ImmutableList;
+
@Test(groups = "unit", testName = "DeploymentHandlerTest")
public class DeploymentHandlerTest extends BaseHandlerTest {
@@ -62,25 +70,76 @@ public class DeploymentHandlerTest extends BaseHandlerTest {
public void test() {
InputStream is = getClass().getResourceAsStream("/deployment.xml");
- Deployment result = factory.create(new DeploymentHandler()).parse(is);
+ Deployment result = factory.create(new DeploymentHandler(
+ new VirtualIPHandler(),
+ new RoleInstanceHandler(),
+ new RoleHandler(
+ new ConfigurationSetHandler(new InputEndpointHandler(), new SubnetNameHandler()),
+ new OSVirtualHardDiskHandler(),
+ new DataVirtualHardDiskHandler())))
+ .parse(is);
assertEquals(result, expected());
}
public static Deployment expected() {
return Deployment.create( //
- "deployment_name", // name
- Slot.PRODUCTION, // slot
- Status.RUNNING, // status
- "neotysss", // label
- "role_name_from_role_list", // virtualMachineName
- "instance_name", // instanceName
- InstanceStatus.READY_ROLE, // instanceStatus
- null, // instanceStateDetails
- null, // instanceErrorCode
- RoleSize.MEDIUM, // instanceSize
- "10.59.244.162", // privateIpAddress
- "168.63.27.148" // publicIpAddress
+ "node1855162607153993262-b26", // name
+ Slot.PRODUCTION, // slot
+ Status.RUNNING, // status
+ "node1855162607153993262-b26", // label
+ null, // instanceStateDetails
+ null, // instanceErrorCode
+ ImmutableList.of(Deployment.VirtualIP.create("191.233.85.49", true, "node1855162607153993262-b26ContractContract")), //virtualIPs
+ ImmutableList.of(Deployment.RoleInstance.create(
+ "node1855162607153993262-b26", // roleName
+ "node1855162607153993262-b26", // instanceName
+ InstanceStatus.READY_ROLE, //instanceStatus
+ 0,
+ 0,
+ RoleSize.Type.BASIC_A0,
+ "10.0.2.6",
+ "node1855162607153993262-b26", // hostname
+ ImmutableList.of(
+ Deployment.InstanceEndpoint.create(
+ "tcp_22-22", // name
+ "191.233.85.49", // vip
+ 22, // publicPort
+ 22, // localPort
+ "tcp" // protocol
+ )
+ )
+ )),
+ ImmutableList.of(Role.create(
+ "node1855162607153993262-b26",
+ "PersistentVMRole",
+ null,
+ null,
+ ImmutableList.of(ConfigurationSet.create(
+ "NetworkConfiguration",
+ ImmutableList.of(
+ InputEndpoint.create("tcp_22-22", "tcp", 22, 22, "191.233.85.49", false, null, null, null),
+ InputEndpoint.create("tcp_2375-2375", "tcp", 2375, 2375, "191.233.85.49", false, null, null, null)
+ ),
+ ImmutableList.of(ConfigurationSet.SubnetName.create("Subnet-1")),
+ null,
+ ImmutableList.<ConfigurationSet.PublicIP>of())),
+ ImmutableList.<Role.ResourceExtensionReference>of(),
+ null,
+ ImmutableList.<DataVirtualHardDisk>of(),
+ OSVirtualHardDisk.create(
+ "ReadWrite",
+ "node1855162607153993262-b26-node1855162607153993262-b26-0-201412221704390597",
+ null,
+ null,
+ URI.create("https://test.blob.core.windows.net/clockerblob/container-node1855162607153993262-b26.vhd"),
+ "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-trusty-14_04_1-LTS-amd64-server-20141212-en-us-30GB",
+ OSImage.Type.LINUX),
+ RoleSize.Type.BASIC_A0,
+ null,
+ null
+ )),
+ "jclouds" // virtualNetworkName
);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
index 491653b..6dc2b91 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
@@ -35,7 +35,7 @@ public class ListDisksHandlerTest extends BaseHandlerTest {
public void test() {
InputStream is = getClass().getResourceAsStream("/disks.xml");
- List<Disk> result = factory.create(new ListDisksHandler()).parse(is);
+ List<Disk> result = factory.create(new ListDisksHandler(new DiskHandler())).parse(is);
assertEquals(result, expected());
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListLocationsHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListLocationsHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListLocationsHandlerTest.java
index 599d307..42f4010 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListLocationsHandlerTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListLocationsHandlerTest.java
@@ -32,7 +32,7 @@ public class ListLocationsHandlerTest extends BaseHandlerTest {
public void test() {
InputStream is = getClass().getResourceAsStream("/locations.xml");
- List<Location> result = factory.create(new ListLocationsHandler()).parse(is);
+ List<Location> result = factory.create(new ListLocationsHandler(new LocationHandler())).parse(is);
assertEquals(result, expected());
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
index bdf7aaf..922f3c5 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
@@ -35,7 +35,7 @@ public class ListOSImagesHandlerTest extends BaseHandlerTest {
public void test() {
InputStream is = getClass().getResourceAsStream("/images.xml");
- List<OSImage> result = factory.create(new ListOSImagesHandler()).parse(is);
+ List<OSImage> result = factory.create(new ListOSImagesHandler(new OSImageHandler())).parse(is);
assertEquals(result, expected());
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListVirtualNetworkSitesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListVirtualNetworkSitesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListVirtualNetworkSitesHandlerTest.java
new file mode 100644
index 0000000..ecbb663
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListVirtualNetworkSitesHandlerTest.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.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+import java.io.InputStream;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.NetworkConfiguration;
+import org.jclouds.azurecompute.domain.NetworkConfiguration.VirtualNetworkSite;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "ListVirtualNetworkSitesHandlerTest")
+public class ListVirtualNetworkSitesHandlerTest extends BaseHandlerTest {
+
+ public void test() {
+ InputStream is = getClass().getResourceAsStream("/virtualnetworksites.xml");
+ List<VirtualNetworkSite> result = factory.create(new ListVirtualNetworkSitesHandler(new VirtualNetworkSiteHandler())).parse(is);
+
+ assertEquals(result, expected());
+ }
+
+ public static List<VirtualNetworkSite> expected() {
+ return ImmutableList.of(
+ VirtualNetworkSite.create(
+ "39d0d14b-fc1d-496f-8928-b5a13a6f4b64",
+ "Group Group testDocker",
+ "West Europe",
+ NetworkConfiguration.AddressSpace.create("10.1.0.0/16"),
+ ImmutableList.of(NetworkConfiguration.Subnet.create("Subnet-1", "10.1.0.0/24", null))
+ ),
+ VirtualNetworkSite.create(
+ "12252126-cffc-4fac-8ba4-afa7150a8d4a",
+ "Group Group-1 dockertest",
+ "West Europe",
+ NetworkConfiguration.AddressSpace.create("10.2.0.0/16"),
+ ImmutableList.of(NetworkConfiguration.Subnet.create("Subnet-1", "10.2.0.0/24", null))
+ )
+ );
+ }
+
+}
[3/3] jclouds-labs git commit: azurecompute: improvements to the
domain objects
Posted by an...@apache.org.
azurecompute: improvements to the domain objects
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/a34e62ca
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/a34e62ca
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/a34e62ca
Branch: refs/heads/master
Commit: a34e62ca3b2d326a9b19540a297f6d660997e231
Parents: 58a9be6
Author: Andrea Turli <an...@gmail.com>
Authored: Wed Feb 4 10:28:07 2015 +0100
Committer: andreaturli <an...@gmail.com>
Committed: Wed Feb 11 17:40:47 2015 +0100
----------------------------------------------------------------------
azurecompute/pom.xml | 8 +-
.../azurecompute/domain/Availability.java | 36 +++
.../azurecompute/domain/CloudService.java | 8 +-
.../domain/DataVirtualHardDisk.java | 6 +-
.../jclouds/azurecompute/domain/Deployment.java | 101 +++++--
.../azurecompute/domain/DeploymentParams.java | 52 +++-
.../org/jclouds/azurecompute/domain/Disk.java | 6 +
.../org/jclouds/azurecompute/domain/Error.java | 3 +
.../jclouds/azurecompute/domain/Location.java | 5 +-
.../domain/NetworkConfiguration.java | 85 ++++++
.../domain/NetworkSecurityGroup.java | 43 +++
.../jclouds/azurecompute/domain/OSImage.java | 6 +-
.../azurecompute/domain/OSImageParams.java | 2 +
.../jclouds/azurecompute/domain/Operation.java | 3 +
.../org/jclouds/azurecompute/domain/Role.java | 271 +++++++++++++++++++
.../jclouds/azurecompute/domain/RoleSize.java | 107 +++++++-
.../org/jclouds/azurecompute/domain/Rule.java | 57 ++++
.../azurecompute/domain/StorageService.java | 57 ++++
.../domain/StorageServiceParams.java | 89 ++++++
.../handlers/AzureComputeErrorHandler.java | 83 ++++++
.../azurecompute/xml/AddressSpaceHandler.java | 54 ++++
.../azurecompute/xml/AvailabilityHandler.java | 49 ++++
.../xml/ConfigurationSetHandler.java | 110 ++++++++
.../xml/DataVirtualHardDiskHandler.java | 12 +-
.../azurecompute/xml/DeploymentHandler.java | 104 ++++---
.../azurecompute/xml/InputEndpointHandler.java | 87 ++++++
.../xml/InstanceEndpointHandler.java | 72 +++++
.../azurecompute/xml/ListDisksHandler.java | 7 +-
.../azurecompute/xml/ListLocationsHandler.java | 7 +-
.../xml/ListNetworkSecurityGroupsHandler.java | 64 +++++
.../azurecompute/xml/ListOSImagesHandler.java | 13 +-
.../azurecompute/xml/ListRoleSizesHandler.java | 65 +++++
.../xml/ListStorageServicesHandler.java | 69 +++++
.../xml/ListVirtualNetworkSitesHandler.java | 66 +++++
.../xml/NetworkConfigurationHandler.java | 70 +++++
.../xml/NetworkSecurityGroupHandler.java | 78 ++++++
.../azurecompute/xml/OSImageHandler.java | 57 +++-
.../xml/OSVirtualHardDiskHandler.java | 66 +++++
.../jclouds/azurecompute/xml/RoleHandler.java | 155 +++++++++++
.../azurecompute/xml/RoleInstanceHandler.java | 131 +++++++++
.../azurecompute/xml/RoleSizeHandler.java | 98 +++++++
.../jclouds/azurecompute/xml/RuleHandler.java | 82 ++++++
.../azurecompute/xml/StorageServiceHandler.java | 91 +++++++
.../xml/StorageServicePropertiesHandler.java | 54 ++++
.../jclouds/azurecompute/xml/SubnetHandler.java | 61 +++++
.../azurecompute/xml/SubnetNameHandler.java | 58 ++++
.../azurecompute/xml/VirtualIPHandler.java | 64 +++++
.../xml/VirtualNetworkSiteHandler.java | 105 +++++++
.../features/DeploymentApiMockTest.java | 4 +-
.../internal/BaseAzureComputeApiMockTest.java | 2 +-
.../azurecompute/xml/DeploymentHandlerTest.java | 87 +++++-
.../azurecompute/xml/ListDisksHandlerTest.java | 2 +-
.../xml/ListLocationsHandlerTest.java | 2 +-
.../xml/ListOSImagesHandlerTest.java | 2 +-
.../xml/ListVirtualNetworkSitesHandlerTest.java | 59 ++++
.../xml/NetworkSecurityGroupHandlerTest.java | 120 ++++++++
azurecompute/src/test/resources/deployment.xml | 91 ++++---
.../test/resources/deploymentparams-windows.xml | 2 +-
.../src/test/resources/deploymentparams.xml | 2 +-
azurecompute/src/test/resources/images.xml | 3 +-
azurecompute/src/test/resources/logback.xml | 34 +++
.../src/test/resources/networksecuritygroup.xml | 85 ++++++
azurecompute/src/test/resources/rolesizes.xml | 255 +++++++++++++++++
azurecompute/src/test/resources/virtualIPs.xml | 7 +
.../src/test/resources/virtualnetworksites.xml | 36 +++
65 files changed, 3620 insertions(+), 150 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/pom.xml
----------------------------------------------------------------------
diff --git a/azurecompute/pom.xml b/azurecompute/pom.xml
index a590613..48f2a54 100644
--- a/azurecompute/pom.xml
+++ b/azurecompute/pom.xml
@@ -77,13 +77,7 @@
<artifactId>auto-value</artifactId>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-compute</artifactId>
- <version>${project.parent.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Availability.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Availability.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Availability.java
new file mode 100644
index 0000000..26ecbf7
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Availability.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.azurecompute.domain;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class Availability {
+
+ Availability() {} // For AutoValue only!
+
+ public abstract Boolean result();
+
+ @Nullable public abstract String reason();
+
+ public static Availability create(Boolean result, String reason) {
+ return new AutoValue_Availability(result, reason);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java
index be61725..2187a75 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.azurecompute.domain;
+import static com.google.common.collect.ImmutableMap.copyOf;
import java.util.Date;
import java.util.Map;
@@ -28,15 +29,18 @@ import com.google.auto.value.AutoValue;
* service type; the name of the affinity group to which the service belongs, or its location if it
* is not part of an affinity group.
*
- * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
+ * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >CloudService</a>
*/
@AutoValue
public abstract class CloudService {
+
public enum Status {
CREATING, CREATED, DELETING, DELETED, CHANGING, RESOLVING_DNS,
UNRECOGNIZED;
}
+ CloudService() {} // For AutoValue only!
+
/**
* The name of the cloud service. This name is the DNS prefix name and can be used to access the
* cloud service.
@@ -87,6 +91,6 @@ public abstract class CloudService {
public static CloudService create(String name, String location, String affinityGroup, String label,
String description, Status status, Date created, Date lastModified, Map<String, String> extendedProperties) {
return new AutoValue_CloudService(name, location, affinityGroup, label, description, status, created,
- lastModified, extendedProperties);
+ lastModified, copyOf(extendedProperties));
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DataVirtualHardDisk.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DataVirtualHardDisk.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DataVirtualHardDisk.java
index 05b39e2..2dcaa70 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DataVirtualHardDisk.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DataVirtualHardDisk.java
@@ -89,9 +89,7 @@ public abstract class DataVirtualHardDisk {
*/
@Nullable public abstract String ioType();
- public static DataVirtualHardDisk create(Caching hostCaching, String diskName,
- Integer lun, Integer logicalDiskSizeInGB, URI mediaLink, String ioType) {
- return new AutoValue_DataVirtualHardDisk(hostCaching, diskName, lun, logicalDiskSizeInGB,
- mediaLink, ioType);
+ public static DataVirtualHardDisk create(Caching hostCaching, String diskName, Integer lun, Integer logicalDiskSizeInGB, URI mediaLink, String ioType) {
+ return new AutoValue_DataVirtualHardDisk(hostCaching, diskName, lun, logicalDiskSizeInGB, mediaLink, ioType);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java
index fa4d033..7d71965 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java
@@ -16,6 +16,9 @@
*/
package org.jclouds.azurecompute.domain;
+import static com.google.common.collect.ImmutableList.copyOf;
+import java.util.List;
+
import org.jclouds.javax.annotation.Nullable;
import com.google.auto.value.AutoValue;
@@ -43,6 +46,78 @@ public abstract class Deployment {
UNRECOGNIZED,
}
+ @AutoValue
+ public abstract static class VirtualIP {
+
+ public abstract String address();
+
+ public abstract Boolean isDnsProgrammed();
+
+ public abstract String name();
+
+ VirtualIP() { // For AutoValue only!
+ }
+
+ public static VirtualIP create(String address, Boolean isDnsProgrammed, String name) {
+ return new AutoValue_Deployment_VirtualIP(address, isDnsProgrammed, name);
+ }
+ }
+
+ @AutoValue
+ public abstract static class InstanceEndpoint {
+
+ public abstract String name();
+
+ public abstract String vip();
+
+ public abstract int publicPort();
+
+ public abstract int localPort();
+
+ public abstract String protocol();
+
+ InstanceEndpoint() { // For AutoValue only!
+ }
+
+ public static InstanceEndpoint create(String name, String vip, int publicPort, int localPort, String protocol) {
+ return new AutoValue_Deployment_InstanceEndpoint(name, vip, publicPort, localPort, protocol);
+ }
+ }
+
+ @AutoValue
+ public abstract static class RoleInstance {
+
+ public abstract String roleName();
+
+ public abstract String instanceName();
+
+ public abstract InstanceStatus instanceStatus();
+
+ public abstract int instanceUpgradeDomain();
+
+ public abstract int instanceFaultDomain();
+
+ public abstract RoleSize.Type instanceSize();
+
+ public abstract String ipAddress();
+
+ @Nullable public abstract String hostname();
+
+ @Nullable public abstract List<InstanceEndpoint> instanceEndpoints();
+
+ RoleInstance() { // For AutoValue only!
+ }
+
+ public static RoleInstance create(String roleName, String instanceName, InstanceStatus instanceStatus, int instanceUpgradeDomain,
+ int instanceFaultDomain, RoleSize.Type instanceSize, String ipAddress, String hostname, List<InstanceEndpoint> instanceEndpoints) {
+ return new AutoValue_Deployment_RoleInstance(roleName, instanceName, instanceStatus, instanceUpgradeDomain,
+ instanceFaultDomain, instanceSize, ipAddress, hostname, copyOf(instanceEndpoints));
+ }
+ }
+
+ Deployment() {} // For AutoValue only!
+
+
/** The user-supplied name for this deployment. */
public abstract String name();
@@ -58,15 +133,6 @@ public abstract class Deployment {
*/
public abstract String label();
- /** Specifies the name for the virtual machine. The name must be unique within Windows Azure. */
- public abstract String virtualMachineName();
-
- /** The name of the specific role instance (if any). */
- @Nullable public abstract String instanceName();
-
- /** The current status of this instance. */
- public abstract InstanceStatus instanceStatus();
-
/**
* The instance state is returned as an English human-readable string that,
* when present, provides a snapshot of the state of the virtual machine at
@@ -98,16 +164,17 @@ public abstract class Deployment {
*/
@Nullable public abstract String instanceErrorCode();
- public abstract RoleSize instanceSize();
+ public abstract List<VirtualIP> virtualIPs();
+
+ public abstract List<RoleInstance> roleInstanceList();
- public abstract String privateIpAddress();
+ @Nullable public abstract List<Role> roles();
- public abstract String publicIpAddress();
+ @Nullable public abstract String virtualNetworkName();
- public static Deployment create(String name, Slot slot, Status status, String label, String virtualMachineName,
- String instanceName, InstanceStatus instanceStatus, String instanceStateDetails, String instanceErrorCode,
- RoleSize instanceSize, String privateIpAddress, String publicIpAddress) {
- return new AutoValue_Deployment(name, slot, status, label, virtualMachineName, instanceName, instanceStatus,
- instanceStateDetails, instanceErrorCode, instanceSize, privateIpAddress, publicIpAddress);
+ public static Deployment create(String name, Slot slot, Status status, String label, String instanceStateDetails, String instanceErrorCode,
+ List<VirtualIP> virtualIPs, List<RoleInstance> roleInstanceList, List<Role> roles, String virtualNetworkName) {
+ return new AutoValue_Deployment(name, slot, status, label, instanceStateDetails,
+ instanceErrorCode, copyOf(virtualIPs), copyOf(roleInstanceList), copyOf(roles), virtualNetworkName);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
index 6ccc5e8..5260b0f 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
@@ -16,10 +16,13 @@
*/
package org.jclouds.azurecompute.domain;
+import static com.google.common.collect.ImmutableList.copyOf;
import java.net.URI;
import java.util.Collection;
import java.util.List;
+import org.jclouds.javax.annotation.Nullable;
+
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@@ -45,12 +48,12 @@ public abstract class DeploymentParams {
public abstract int localPort();
public static ExternalEndpoint inboundTcpToLocalPort(int port, int localPort) {
- return new AutoValue_DeploymentParams_ExternalEndpoint(String.format("tcp %s:%s", port, localPort), "tcp",
+ return new AutoValue_DeploymentParams_ExternalEndpoint(String.format("tcp_%s-%s", port, localPort), "tcp",
port, localPort);
}
public static ExternalEndpoint inboundUdpToLocalPort(int port, int localPort) {
- return new AutoValue_DeploymentParams_ExternalEndpoint(String.format("udp %s:%s", port, localPort), "udp",
+ return new AutoValue_DeploymentParams_ExternalEndpoint(String.format("udp_%s-%s", port, localPort), "udp",
port, localPort);
}
@@ -58,11 +61,13 @@ public abstract class DeploymentParams {
}
}
+ DeploymentParams() {} // For AutoValue only!
+
/** The user-supplied name for this deployment. */
public abstract String name();
/** The size of the virtual machine to allocate. The default value is Small. */
- public abstract RoleSize size();
+ public abstract RoleSize.Type size();
/**
* Specifies the name of a user to be created in the sudoers group of the
@@ -89,6 +94,11 @@ public abstract class DeploymentParams {
public abstract List<ExternalEndpoint> externalEndpoints();
+ /** {@link org.jclouds.azurecompute.domain.NetworkConfiguration.VirtualNetworkSite#name} */
+ @Nullable public abstract String virtualNetworkName();
+
+ public abstract List<String> subnetNames();
+
public Builder toBuilder() {
return builder().fromDeploymentParams(this);
}
@@ -99,20 +109,22 @@ public abstract class DeploymentParams {
public static final class Builder {
private String name;
- private RoleSize size = RoleSize.SMALL;
+ private RoleSize.Type size;
private String username;
private String password;
private String sourceImageName;
private URI mediaLink;
private OSImage.Type os;
private List<ExternalEndpoint> externalEndpoints = Lists.newArrayList();
+ private String virtualNetworkName;
+ private List<String> subnetNames = Lists.newArrayList();
public Builder name(String name) {
this.name = name;
return this;
}
- public Builder size(RoleSize size) {
+ public Builder size(RoleSize.Type size) {
this.size = size;
return this;
}
@@ -148,13 +160,28 @@ public abstract class DeploymentParams {
}
public Builder externalEndpoints(Collection<ExternalEndpoint> externalEndpoints) {
- externalEndpoints.addAll(externalEndpoints);
+ this.externalEndpoints.addAll(externalEndpoints);
+ return this;
+ }
+
+ public Builder virtualNetworkName(String virtualNetworkName) {
+ this.virtualNetworkName = virtualNetworkName;
+ return this;
+ }
+
+ public Builder subnetName(String subnetName) {
+ subnetNames.add(subnetName);
+ return this;
+ }
+
+ public Builder subnetNames(Collection<String> subnetNames) {
+ this.subnetNames.addAll(subnetNames);
return this;
}
public DeploymentParams build() {
return DeploymentParams.create(name, size, username, password, sourceImageName, mediaLink, os,
- ImmutableList.copyOf(externalEndpoints));
+ ImmutableList.copyOf(externalEndpoints), virtualNetworkName, ImmutableList.copyOf(subnetNames));
}
public Builder fromDeploymentParams(DeploymentParams in) {
@@ -165,12 +192,15 @@ public abstract class DeploymentParams {
.sourceImageName(in.sourceImageName())
.mediaLink(in.mediaLink())
.os(in.os())
- .externalEndpoints(in.externalEndpoints());
+ .externalEndpoints(in.externalEndpoints())
+ .subnetNames(in.subnetNames());
}
}
- private static DeploymentParams create(String name, RoleSize size, String username, String password, String sourceImageName,
- URI mediaLink, OSImage.Type os, List<ExternalEndpoint> externalEndpoints) {
- return new AutoValue_DeploymentParams(name, size, username, password, sourceImageName, mediaLink, os, externalEndpoints);
+ private static DeploymentParams create(String name, RoleSize.Type size, String username, String password, String sourceImageName,
+ URI mediaLink, OSImage.Type os, List<ExternalEndpoint> externalEndpoints,
+ String virtualNetworkName, List<String> subnetNames) {
+ return new AutoValue_DeploymentParams(name, size, username, password, sourceImageName, mediaLink, os,
+ copyOf(externalEndpoints), virtualNetworkName, copyOf(subnetNames));
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
index 6c67ac4..2f211aa 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
@@ -29,8 +29,14 @@ import com.google.auto.value.AutoValue;
*/
@AutoValue
public abstract class Disk {
+
+ Disk() {} // For AutoValue only!
+
@AutoValue
public abstract static class Attachment {
+
+ Attachment() {} // For AutoValue only!
+
/** The deployment in which the disk is being used. */
public abstract String deployment();
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java
index beafd2a..40d6e02 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java
@@ -23,6 +23,7 @@ import com.google.auto.value.AutoValue;
*/
@AutoValue
public abstract class Error {
+
public static enum Code {
MISSING_OR_INCORRECT_VERSION_HEADER,
INVALID_XML_REQUEST,
@@ -39,6 +40,8 @@ public abstract class Error {
UNRECOGNIZED;
}
+ Error() {} // For AutoValue only!
+
/** Error code */
public abstract Code code();
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java
index 230cf9a..1cf1005 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.azurecompute.domain;
+import static com.google.common.collect.ImmutableList.copyOf;
import java.util.List;
import com.google.auto.value.AutoValue;
@@ -24,6 +25,8 @@ import com.google.auto.value.AutoValue;
@AutoValue
public abstract class Location {
+ Location() {} // For AutoValue only!
+
/** The name of the data center location. Ex. {@code West Europe}. */
public abstract String name();
@@ -34,6 +37,6 @@ public abstract class Location {
public abstract List<String> availableServices();
public static Location create(String name, String displayName, List<String> availableServices) {
- return new AutoValue_Location(name, displayName, availableServices);
+ return new AutoValue_Location(name, displayName, copyOf(availableServices));
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/NetworkConfiguration.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/NetworkConfiguration.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/NetworkConfiguration.java
new file mode 100644
index 0000000..c4f1e55
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/NetworkConfiguration.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.azurecompute.domain;
+
+import java.util.List;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class NetworkConfiguration {
+
+ @AutoValue
+ public abstract static class Subnet {
+
+ Subnet() {} // For AutoValue only!
+
+ public abstract String name();
+
+ @Nullable public abstract String addressPrefix();
+
+ @Nullable public abstract String networkSecurityGroup();
+
+ public static Subnet create(String name, String addressPrefix, String networkSecurityGroup) {
+ return new AutoValue_NetworkConfiguration_Subnet(name, addressPrefix, networkSecurityGroup);
+ }
+ }
+
+ @AutoValue
+ public abstract static class AddressSpace {
+
+ AddressSpace() {} // For AutoValue only!
+
+ @Nullable public abstract String addressPrefix();
+
+ public static AddressSpace create(String addressPrefix) {
+ return new AutoValue_NetworkConfiguration_AddressSpace(addressPrefix);
+ }
+ }
+
+ @AutoValue
+ public abstract static class VirtualNetworkSite {
+
+ VirtualNetworkSite() {} // For AutoValue only!
+
+ @Nullable public abstract String id();
+
+ @Nullable public abstract String name();
+
+ @Nullable public abstract String location();
+
+ public abstract AddressSpace addressSpace();
+
+ public abstract List<Subnet> subnets();
+
+ public static VirtualNetworkSite create(String id, String name, String location, AddressSpace addressSpace, List<Subnet> subnets) {
+ return new AutoValue_NetworkConfiguration_VirtualNetworkSite(id, name, location, addressSpace, subnets);
+ }
+
+ }
+
+ public NetworkConfiguration() {} // For AutoValue only!
+
+ @Nullable public abstract String dns();
+ @Nullable public abstract List<VirtualNetworkSite> virtualNetworkSites();
+
+ public static NetworkConfiguration create(String dns, List<VirtualNetworkSite> virtualNetworkSites) {
+ return new AutoValue_NetworkConfiguration(dns, virtualNetworkSites);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/NetworkSecurityGroup.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/NetworkSecurityGroup.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/NetworkSecurityGroup.java
new file mode 100644
index 0000000..4343452
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/NetworkSecurityGroup.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.domain;
+
+import static com.google.common.collect.ImmutableList.copyOf;
+import java.util.List;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class NetworkSecurityGroup {
+
+ NetworkSecurityGroup() {} // For AutoValue only!
+
+ public abstract String name();
+
+ @Nullable public abstract String label();
+
+ @Nullable public abstract String location();
+
+ @Nullable public abstract List<Rule> rules();
+
+ public static NetworkSecurityGroup create(String name, String label, String location, List<Rule> rules) {
+ return new AutoValue_NetworkSecurityGroup(name, label, location, copyOf(rules));
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java
index e9069a9..eac4b1e 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.azurecompute.domain;
+import static com.google.common.collect.ImmutableList.copyOf;
import java.net.URI;
import java.util.List;
@@ -30,10 +31,13 @@ import com.google.auto.value.AutoValue;
*/
@AutoValue
public abstract class OSImage {
+
public enum Type {
LINUX, WINDOWS;
}
+ OSImage() {} // For AutoValue only!
+
public abstract String name();
/** The geo-locations of the image, if the image is not associated with an affinity group. */
@@ -83,6 +87,6 @@ public abstract class OSImage {
public static OSImage create(String name, String location, String affinityGroup, String label,
String description, String category, Type os, String publisherName, URI mediaLink, int logicalSizeInGB, List<String> eula) {
return new AutoValue_OSImage(name, location, affinityGroup, label, description, category, os, publisherName, mediaLink,
- logicalSizeInGB, eula);
+ logicalSizeInGB, copyOf(eula));
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java
index 1b3906a..ed2b623 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java
@@ -24,6 +24,8 @@ import com.google.auto.value.AutoValue;
@AutoValue
public abstract class OSImageParams {
+ OSImageParams() {} // For AutoValue only!
+
/** Specifies a name that is used to identify the image when you create a Virtual Machine. */
public abstract String name();
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java
index 73e7e9a..a74a1e1 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java
@@ -28,11 +28,14 @@ import com.google.auto.value.AutoValue;
*/
@AutoValue
public abstract class Operation {
+
public enum Status {
IN_PROGRESS, SUCCEEDED, FAILED,
UNRECOGNIZED;
}
+ Operation() {} // For AutoValue only!
+
public abstract String id();
public abstract Status status();
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Role.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Role.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Role.java
new file mode 100644
index 0000000..c0207af
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Role.java
@@ -0,0 +1,271 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.domain;
+
+import static com.google.common.collect.ImmutableList.copyOf;
+import java.net.URI;
+import java.util.List;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.auto.value.AutoValue;
+
+/**
+ * @see <a href="https://msdn.microsoft.com/en-us/library/azure/jj157193.aspx">Role</a>
+ */
+@AutoValue
+public abstract class Role {
+
+ @AutoValue
+ public abstract static class ConfigurationSet {
+
+ @AutoValue
+ public abstract static class InputEndpoint {
+
+ @AutoValue
+ public abstract static class LoadBalancerProbe {
+
+ public abstract String path();
+
+ public abstract int port();
+
+ public abstract String protocol();
+
+ LoadBalancerProbe() { // For AutoValue only!
+ }
+
+ public static LoadBalancerProbe create(String path, int port, String protocol) {
+ return new AutoValue_Role_ConfigurationSet_InputEndpoint_LoadBalancerProbe(path, port, protocol);
+ }
+ }
+
+ public abstract int localPort();
+
+ public abstract String name();
+
+ public abstract Integer port();
+
+ public abstract String protocol();
+
+ public abstract String vip();
+
+ public abstract Boolean enableDirectServerReturn();
+
+ @Nullable public abstract String loadBalancerName();
+
+ @Nullable public abstract LoadBalancerProbe loadBalancerProbe();
+
+ @Nullable public abstract Integer idleTimeoutInMinutes();
+
+ InputEndpoint() { // For AutoValue only!
+ }
+
+ public static InputEndpoint create(String name, String protocol, int localPort, int port,
+ String vip, boolean enableDirectServerReturn, String loadBalancerName,
+ LoadBalancerProbe loadBalancerProbe, Integer idleTimeoutInMinutes) {
+ return new AutoValue_Role_ConfigurationSet_InputEndpoint(localPort, name, port, protocol, vip,
+ enableDirectServerReturn, loadBalancerName, loadBalancerProbe, idleTimeoutInMinutes);
+ }
+ }
+
+ @AutoValue
+ public abstract static class SubnetName {
+
+ @Nullable public abstract String name();
+
+ SubnetName() { // For AutoValue only!
+ }
+
+ public static SubnetName create(String name) {
+ return new AutoValue_Role_ConfigurationSet_SubnetName(name);
+ }
+ }
+
+ @AutoValue
+ public abstract static class PublicIP {
+
+ public abstract String name();
+
+ public abstract int idleTimeoutInMinutes();
+
+ PublicIP() { // For AutoValue only!
+ }
+
+ public static PublicIP create(String name, int idleTimeoutInMinutes) {
+ return new AutoValue_Role_ConfigurationSet_PublicIP(name, idleTimeoutInMinutes);
+ }
+ }
+
+ public abstract String configurationSetType();
+
+ public abstract List<InputEndpoint> inputEndpoints();
+
+ @Nullable public abstract List<SubnetName> subnetNames();
+
+ @Nullable public abstract String staticVirtualNetworkIPAddress();
+
+ @Nullable public abstract List<PublicIP> publicIPs();
+
+ ConfigurationSet() { // For AutoValue only!
+ }
+
+ public static ConfigurationSet create(String configurationSetType, List<InputEndpoint> inputEndpoints,
+ List<SubnetName> subnetNames, String staticVirtualNetworkIPAddress, List<PublicIP> publicIPs) {
+ return new AutoValue_Role_ConfigurationSet(configurationSetType, inputEndpoints, subnetNames,
+ staticVirtualNetworkIPAddress, publicIPs);
+ }
+ }
+
+ @AutoValue
+ public abstract static class ResourceExtensionReference {
+
+ @AutoValue
+ public abstract static class ResourceExtensionParameterValue {
+
+ public abstract String key();
+
+ public abstract String value();
+
+ public abstract String type();
+
+ ResourceExtensionParameterValue() { // For AutoValue only!
+ }
+
+ public static ResourceExtensionParameterValue create(String key, String value, String type) {
+ return new AutoValue_Role_ResourceExtensionReference_ResourceExtensionParameterValue(key, value, type);
+ }
+ }
+
+ public abstract String referenceName();
+
+ public abstract String publisher();
+
+ public abstract String name();
+
+ public abstract String version();
+
+ public abstract List<ResourceExtensionParameterValue> resourceExtensionParameterValues();
+
+ public abstract String state();
+
+ ResourceExtensionReference() { // For AutoValue only!
+ }
+
+ public static ResourceExtensionReference create(String referenceName, String publisher, String name, String
+ version, List<ResourceExtensionParameterValue> resourceExtensionParameterValues, String state) {
+ return new AutoValue_Role_ResourceExtensionReference(referenceName, publisher, name, version,
+ resourceExtensionParameterValues, state);
+ }
+ }
+
+ @AutoValue
+ public abstract static class OSVirtualHardDisk {
+
+ public abstract String hostCaching();
+
+ public abstract String diskName();
+
+ @Nullable public abstract Integer lun();
+
+ @Nullable public abstract Integer logicalDiskSizeInGB();
+
+ public abstract URI mediaLink();
+
+ public abstract String sourceImageName();
+
+ public abstract OSImage.Type os();
+
+ OSVirtualHardDisk() { // For AutoValue only!
+ }
+
+ public static OSVirtualHardDisk create(String hostCaching, String diskName, Integer lun, Integer logicalDiskSizeInGB, URI mediaLink, String sourceImageName, OSImage.Type os) {
+ return new AutoValue_Role_OSVirtualHardDisk(hostCaching, diskName, lun, logicalDiskSizeInGB, mediaLink, sourceImageName, os);
+ }
+ }
+
+ /**
+ * Represents the name of the Virtual Machine.
+ */
+ public abstract String roleName();
+
+ /**
+ * Specifies the type of role that is used. For Virtual Machines, this must be PersistentVMRole.
+ */
+ public abstract String roleType();
+
+ /**
+ * Specifies the name of the VM Image that was used to create the Virtual Machine.
+ */
+ @Nullable public abstract String vmImage();
+
+ /**
+ * Specifies the path to the VHD files that are associated with the VM Image.
+ */
+ @Nullable public abstract String mediaLocation();
+
+ /**
+ * Contains a collection of configuration sets that define system and application settings.
+ */
+ public abstract List<ConfigurationSet> configurationSets();
+
+ /**
+ * Optional. Contains a collection of resource extensions that are installed on the Virtual Machine. This element is used if ProvisionGuestAgent is set to true.
+ */
+ @Nullable public abstract List<ResourceExtensionReference> resourceExtensionReferences();
+
+ /**
+ * Specifies the name of a collection of Virtual Machines.
+ * Virtual Machines specified in the same availability set are allocated to different nodes to maximize availability.
+ */
+ @Nullable public abstract String availabilitySetName();
+
+ /**
+ * Contains the parameters that were used to add a data disk to a Virtual Machine.
+ */
+ @Nullable public abstract List<DataVirtualHardDisk> dataVirtualHardDisks();
+
+ /**
+ * Contains the parameters that were used to create the operating system disk for a Virtual Machine.
+ */
+ public abstract OSVirtualHardDisk osVirtualHardDisk();
+
+ /**
+ * Specifies the size of the Virtual Machine.
+ */
+ public abstract RoleSize.Type roleSize();
+
+ /**
+ * Optional. Indicates whether the VM Agent is installed on the Virtual Machine.
+ * To run a resource extension in a Virtual Machine, this service must be installed.
+ * @return true or false
+ */
+ @Nullable public abstract Boolean provisionGuestAgent();
+
+ /**
+ * Specifies the read-only thumbprint of the certificate that is used with the HTTPS listener for WinRM.
+ */
+ @Nullable public abstract String defaultWinRmCertificateThumbprint();
+
+ public static Role create(String roleName, String roleType, String vmImage, String mediaLocation,
+ List<ConfigurationSet> configurationSets, List<ResourceExtensionReference> resourceExtensionReferences,
+ String availabilitySetName, List<DataVirtualHardDisk> dataVirtualHardDisks,
+ OSVirtualHardDisk osVirtualHardDisk, RoleSize.Type roleSize, Boolean provisionGuestAgent,
+ String defaultWinRmCertificateThumbprint) {
+ return new AutoValue_Role(roleName, roleType, vmImage, mediaLocation, copyOf(configurationSets), copyOf(resourceExtensionReferences),
+ availabilitySetName, copyOf(dataVirtualHardDisks), osVirtualHardDisk, roleSize, provisionGuestAgent, defaultWinRmCertificateThumbprint);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java
index 5e2aa8b..30ea00f 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java
@@ -16,6 +16,109 @@
*/
package org.jclouds.azurecompute.domain;
-public enum RoleSize {
- EXTRA_SMALL, SMALL, MEDIUM, LARGE, EXTRA_LARGE, UNRECOGNIZED;
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.auto.value.AutoValue;
+
+/**
+ * A Role Size that is available in a given subscription.
+ *
+ * @see <a href="http://msdn.microsoft.com/en-us/library/jj157176" >api</a>
+ */
+@AutoValue
+public abstract class RoleSize {
+
+ public enum Type {
+ BASIC_A0 ("Basic_A0"), BASIC_A1 ("Basic_A1"), BASIC_A2 ("Basic_A2"), BASIC_A3 ("Basic_A3"), BASIC_A4 ("Basic_A4"),
+ A0 ("A0"), A1 ("A1"), A2 ("A2"), A3 ("A3"), A4 ("A4"), A5 ("A5"), A6 ("A6"), A7 ("A7"), A8 ("A8"), A9 ("A9"),
+ STANDARD_A0 ("Standard_A0"), STANDARD_A1 ("Standard_A1"), STANDARD_A2 ("Standard_A2"), STANDARD_A3
+ ("Standard_A3"),
+ STANDARD_A4 ("Standard_A4"), STANDARD_A5 ("Standard_A5"), STANDARD_A6 ("Standard_A6"),
+ STANDARD_A7 ("Standard_A7"),
+ STANDARD_A8 ("Standard_A8"), STANDARD_A9 ("Standard_A9"),
+ STANDARD_D1 ("Standard_D1"), STANDARD_D2 ("Standard_D2"), STANDARD_D3 ("Standard_D3"), STANDARD_D4
+ ("Standard_D4"),
+ STANDARD_D11 ("Standard_D11"),
+ STANDARD_D12 ("Standard_D12"), STANDARD_D13 ("Standard_D13"),
+ STANDARD_D14 ("Standard_D14"),
+ STANDARD_G1 ("Standard_G1"), STANDARD_G2 ("Standard_G2"), STANDARD_G3 ("Standard_G3"),
+ STANDARD_G4 ("Standard_G4"), STANDARD_G5 ("Standard_G5"),
+ EXTRASMALL ("ExtraSmall"), SMALL ("Small"), MEDIUM ("Medium"), LARGE ("Large"), EXTRALARGE ("ExtraLarge"),
+ UNRECOGNIZED ("UNRECOGNIZED");
+
+ private String text;
+
+ Type(String text) {
+ this.text = text;
+ }
+
+ public String getText() {
+ return this.text;
+ }
+
+ public static Type fromString(String text) {
+ if (text != null) {
+ for (Type b : Type.values()) {
+ if (text.equalsIgnoreCase(b.text)) {
+ return b;
+ }
+ }
+ }
+ throw new IllegalArgumentException("No constant with text " + text + " found");
+ }
+ }
+
+ RoleSize() {} // For AutoValue only!
+
+ /**
+ * The name of the role size.
+ */
+ public abstract Type name();
+
+ /**
+ * The description of the role size.
+ */
+ @Nullable
+ public abstract String label();
+
+ /**
+ * The number of cores that are available in the role size.
+ */
+ public abstract Integer cores();
+
+ /**
+ * The amount of memory that is available in the role size.
+ */
+ public abstract Integer memoryInMb();
+
+ /**
+ * Indicates whether the role size supports web roles or worker roles.
+ */
+ public abstract Boolean supportedByWebWorkerRoles();
+
+ /**
+ * Indicates whether the role size supports Virtual Machines.
+ */
+ public abstract Boolean supportedByVirtualMachines();
+
+ /**
+ * The maximum number of data disks that can be attached to the role.
+ */
+ public abstract Integer maxDataDiskCount();
+
+ /**
+ * The size of the resource disk for a web role or worker role.
+ */
+ public abstract Integer webWorkerResourceDiskSizeInMb();
+
+ /**
+ * The size of the resource disk for a Virtual Machine.
+ */
+ public abstract Integer virtualMachineResourceDiskSizeInMb();
+
+ public static RoleSize create(Type name, String label, Integer cores, Integer memoryInMb, Boolean
+ supportedByWebWorkerRoles, Boolean supportedByVirtualMachines, Integer maxDataDiskCount, Integer webWorkerResourceDiskSizeInMb, Integer virtualMachineResourceDiskSizeInMb) {
+ return new AutoValue_RoleSize(name, label, cores, memoryInMb, supportedByWebWorkerRoles, supportedByVirtualMachines, maxDataDiskCount, webWorkerResourceDiskSizeInMb, virtualMachineResourceDiskSizeInMb);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Rule.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Rule.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Rule.java
new file mode 100644
index 0000000..825417a
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Rule.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.azurecompute.domain;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class Rule {
+
+ public abstract String name();
+
+ public abstract String type();
+
+ public abstract String priority();
+
+ public abstract String action();
+
+ public abstract String sourceAddressPrefix();
+
+ public abstract String sourcePortRange();
+
+ public abstract String destinationAddressPrefix();
+
+ public abstract String destinationPortRange();
+
+ public abstract String protocol();
+
+ public abstract String state();
+
+ @Nullable public abstract Boolean isDefault();
+
+ Rule() {} // For AutoValue only!
+
+ public static Rule create(String name, String type, String priority, String action, String sourceAddressPrefix,
+ String sourcePortRange, String destinationAddressPrefix, String destinationPortRange,
+ String protocol, String state, Boolean isDefault) {
+ return new AutoValue_Rule(name, type, priority, action, sourceAddressPrefix, sourcePortRange,
+ destinationAddressPrefix, destinationPortRange, protocol, state, isDefault);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/StorageService.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/StorageService.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/StorageService.java
new file mode 100644
index 0000000..f8e2dbd
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/StorageService.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.azurecompute.domain;
+
+import java.net.URL;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class StorageService {
+
+ @AutoValue
+ public abstract static class StorageServiceProperties {
+
+ StorageServiceProperties() {} // For AutoValue only!
+
+ @Nullable public abstract String description();
+
+ public abstract String status();
+
+ public abstract String location();
+
+ public abstract String accountType();
+
+ public static StorageServiceProperties create(String description, String status, String location, String accountType) {
+ return new AutoValue_StorageService_StorageServiceProperties(description, status, location, accountType);
+ }
+ }
+
+ StorageService() {} // For AutoValue only!
+
+ public abstract URL url();
+
+ public abstract String serviceName();
+
+ public abstract StorageServiceProperties storageServiceProperties();
+
+ public static StorageService create(URL url, String serviceName, StorageServiceProperties storageServiceProperties) {
+ return new AutoValue_StorageService(url, serviceName, storageServiceProperties);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/domain/StorageServiceParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/StorageServiceParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/StorageServiceParams.java
new file mode 100644
index 0000000..86d92c9
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/StorageServiceParams.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.azurecompute.domain;
+
+import com.google.auto.value.AutoValue;
+
+// TODO: check which can be null.
+@AutoValue
+public abstract class StorageServiceParams {
+
+ public enum Type {
+ Standard_LRS, Standard_ZRS, Standard_GRS, Standard_RAGRS, Premium_LRS;
+ }
+
+ StorageServiceParams() {} // For AutoValue only!
+
+ /** The user-supplied name for this deployment. */
+ public abstract String name();
+
+ public abstract String label();
+
+ public abstract String location();
+
+ public abstract Type accountType();
+
+ public Builder toBuilder() {
+ return builder().fromStorageServiceParams(this);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static final class Builder {
+ private String name;
+ private String label;
+ private String location;
+ private Type accountType;
+
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder label(String label) {
+ this.label = label;
+ return this;
+ }
+
+ public Builder location(String location) {
+ this.location = location;
+ return this;
+ }
+
+ public Builder accountType(Type accountType) {
+ this.accountType = accountType;
+ return this;
+ }
+
+ public StorageServiceParams build() {
+ return StorageServiceParams.create(name, label, location, accountType);
+ }
+
+ public Builder fromStorageServiceParams(StorageServiceParams in) {
+ return name(in.name())
+ .label(in.label())
+ .location(in.location())
+ .accountType(in.accountType());
+ }
+ }
+
+ private static StorageServiceParams create(String name, String label, String location, Type accountType) {
+ return new AutoValue_StorageServiceParams(name, label, location, accountType);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/handlers/AzureComputeErrorHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/handlers/AzureComputeErrorHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/handlers/AzureComputeErrorHandler.java
new file mode 100644
index 0000000..1ce14bf
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/handlers/AzureComputeErrorHandler.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.azurecompute.handlers;
+
+import java.io.IOException;
+
+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;
+import org.jclouds.util.Closeables2;
+import org.jclouds.util.Strings2;
+
+import com.google.common.base.Throwables;
+
+/**
+ * This will parse and set an appropriate exception on the command object.
+ */
+@Singleton
+public class AzureComputeErrorHandler implements HttpErrorHandler {
+
+ public void handleError(HttpCommand command, HttpResponse response) {
+ // it is important to always read fully and close streams
+ String message = parseMessage(response);
+ Exception exception = message != null ? new HttpResponseException(command, response, message)
+ : new HttpResponseException(command, response);
+ try {
+ message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
+ response.getStatusLine());
+ switch (response.getStatusCode()) {
+ 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;
+ }
+ } finally {
+ Closeables2.closeQuietly(response.getPayload());
+ command.setException(exception);
+ }
+ }
+
+ public String parseMessage(HttpResponse response) {
+ if (response.getPayload() == null)
+ return null;
+ try {
+ return Strings2.toStringAndClose(response.getPayload().openStream());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ try {
+ response.getPayload().getInput().close();
+ } catch (IOException e) {
+ Throwables.propagate(e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AddressSpaceHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AddressSpaceHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AddressSpaceHandler.java
new file mode 100644
index 0000000..ddcc10b
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AddressSpaceHandler.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.azurecompute.xml;
+
+import static org.jclouds.azurecompute.domain.NetworkConfiguration.AddressSpace;
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+public class AddressSpaceHandler extends ParseSax.HandlerForGeneratedRequestWithResult<AddressSpace> {
+ private String addressPrefix;
+
+ private StringBuilder currentText = new StringBuilder();
+
+ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ }
+
+ @Override public AddressSpace getResult() {
+ AddressSpace result = AddressSpace.create(addressPrefix);
+ resetState(); // handler is called in a loop.
+ return result;
+ }
+
+ private void resetState() {
+ addressPrefix = null;
+ }
+
+ @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("AddressPrefix")) {
+ addressPrefix = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AvailabilityHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AvailabilityHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AvailabilityHandler.java
new file mode 100644
index 0000000..3c22ac5
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AvailabilityHandler.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.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import org.jclouds.azurecompute.domain.Availability;
+import org.jclouds.http.functions.ParseSax;
+
+public class AvailabilityHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Availability> {
+ private Boolean result;
+ private String reason;
+
+ private final StringBuilder currentText = new StringBuilder();
+
+ @Override public Availability getResult() {
+ return Availability.create(result, reason);
+ }
+
+ @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("Result")) {
+ String resultText = currentOrNull(currentText);
+ if (resultText != null) {
+ result = Boolean.valueOf(resultText);
+ }
+ } else if (qName.equals("Reason")) {
+ reason = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ConfigurationSetHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ConfigurationSetHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ConfigurationSetHandler.java
new file mode 100644
index 0000000..4e5b54b
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ConfigurationSetHandler.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.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.Role.ConfigurationSet;
+import org.jclouds.azurecompute.domain.Role.ConfigurationSet.InputEndpoint;
+import org.jclouds.azurecompute.domain.Role.ConfigurationSet.PublicIP;
+import org.jclouds.azurecompute.domain.Role.ConfigurationSet.SubnetName;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.Lists;
+import com.google.inject.Inject;
+
+public class ConfigurationSetHandler extends ParseSax.HandlerForGeneratedRequestWithResult<ConfigurationSet> {
+ private String configurationSetType;
+ private List<InputEndpoint> inputEndpoint = Lists.newArrayList();
+ private List<SubnetName> subnetNames = Lists.newArrayList();
+ private String staticVirtualNetworkIPAddress;
+ private List<PublicIP> publicIPs = Lists.newArrayList();
+
+ private boolean inInputEndpoint;
+ private boolean inSubnetNames;
+
+ private final InputEndpointHandler inputEndpointHandler;
+ private final SubnetNameHandler subnetNameHandler;
+ private final StringBuilder currentText = new StringBuilder();
+
+ @Inject ConfigurationSetHandler(InputEndpointHandler inputEndpointHandler, SubnetNameHandler subnetNameHandler) {
+ this.inputEndpointHandler = inputEndpointHandler;
+ this.subnetNameHandler = subnetNameHandler;
+ }
+
+ @Override
+ public ConfigurationSet getResult() {
+ ConfigurationSet result = ConfigurationSet.create(configurationSetType, inputEndpoint, subnetNames, staticVirtualNetworkIPAddress, publicIPs);
+ resetState(); // handler is called in a loop.
+ return result;
+ }
+
+ private void resetState() {
+ configurationSetType = staticVirtualNetworkIPAddress = null;
+ inputEndpoint = Lists.newArrayList();
+ subnetNames = Lists.newArrayList();
+ publicIPs = Lists.newArrayList();
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ if (qName.equals("InputEndpoint")) {
+ inInputEndpoint = true;
+ }
+ if (inInputEndpoint) {
+ inputEndpointHandler.startElement(uri, localName, qName, attributes);
+ }
+ if (qName.equals("SubnetNames")) {
+ inSubnetNames = true;
+ }
+ if (inSubnetNames) {
+ subnetNameHandler.startElement(uri, localName, qName, attributes);
+ }
+ }
+
+ @Override
+ public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("InputEndpoint")) {
+ inInputEndpoint = false;
+ inputEndpoint.add(inputEndpointHandler.getResult());
+ } else if (qName.equals("SubnetNames")) {
+ inSubnetNames = false;
+ subnetNames.add(subnetNameHandler.getResult());
+ } else if (inInputEndpoint) {
+ inputEndpointHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (inSubnetNames) {
+ subnetNameHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (qName.equals("ConfigurationSetType")) {
+ configurationSetType = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) {
+ if (inInputEndpoint) {
+ inputEndpointHandler.characters(ch, start, length);
+ } else if (inSubnetNames) {
+ subnetNameHandler.characters(ch, start, length);
+ } else {
+ currentText.append(ch, start, length);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DataVirtualHardDiskHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DataVirtualHardDiskHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DataVirtualHardDiskHandler.java
index 97452de..acfaabe 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DataVirtualHardDiskHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DataVirtualHardDiskHandler.java
@@ -16,15 +16,14 @@
*/
package org.jclouds.azurecompute.xml;
-import org.jclouds.azurecompute.domain.DataVirtualHardDisk;
-import org.jclouds.http.functions.ParseSax;
-
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
-
+import static org.jclouds.util.SaxUtils.currentOrNull;
import java.net.URI;
-import static org.jclouds.util.SaxUtils.currentOrNull;
+import org.jclouds.azurecompute.domain.DataVirtualHardDisk;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
/**
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/jj157193.aspx#DataVirtualHardDisks" >api</a>
@@ -40,6 +39,9 @@ final class DataVirtualHardDiskHandler extends ParseSax.HandlerForGeneratedReque
private final StringBuilder currentText = new StringBuilder();
+ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ }
+
@Override
public DataVirtualHardDisk getResult() {
DataVirtualHardDisk result = DataVirtualHardDisk
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java
index 50e8294..4c93ece 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java
@@ -22,15 +22,20 @@ import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.io.BaseEncoding.base64;
import static org.jclouds.util.SaxUtils.currentOrNull;
+import java.util.List;
+
import org.jclouds.azurecompute.domain.Deployment;
import org.jclouds.azurecompute.domain.Deployment.InstanceStatus;
import org.jclouds.azurecompute.domain.Deployment.Slot;
import org.jclouds.azurecompute.domain.Deployment.Status;
+import org.jclouds.azurecompute.domain.Role;
import org.jclouds.azurecompute.domain.RoleSize;
import org.jclouds.http.functions.ParseSax;
import org.xml.sax.Attributes;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.Lists;
+import com.google.inject.Inject;
/**
* @see <a href="http://msdn.microsoft.com/en-us/library/ee460804" >Response body description</a>.
@@ -40,29 +45,67 @@ public final class DeploymentHandler extends ParseSax.HandlerForGeneratedRequest
private Slot slot;
private Status status;
private String label;
- private String virtualMachineName;
- private String instanceName;
- private InstanceStatus instanceStatus;
private String instanceStateDetails;
+ private String virtualNetworkName;
+ private List<Deployment.VirtualIP> virtualIPs = Lists.newArrayList();
+ private List<Deployment.RoleInstance> roleInstanceList = Lists.newArrayList();
+ private List<Role> roleList = Lists.newArrayList();
private String instanceErrorCode;
- private RoleSize instanceSize;
- private String privateIpAddress;
- private String publicIpAddress;
- private int depth;
+ private boolean inRoleInstanceList;
+ private boolean inRoleList;
+ private boolean inListVirtualIPs;
+ private final VirtualIPHandler virtualIPHandler;
+ private final RoleInstanceHandler roleInstanceHandler;
+ private final RoleHandler roleHandler;
private final StringBuilder currentText = new StringBuilder();
+ @Inject DeploymentHandler(VirtualIPHandler virtualIPHandler, RoleInstanceHandler roleInstanceHandler, RoleHandler roleHandler) {
+ this.virtualIPHandler = virtualIPHandler;
+ this.roleInstanceHandler = roleInstanceHandler;
+ this.roleHandler = roleHandler;
+ }
+
@Override public Deployment getResult() { // Fields don't need to be reset as this isn't used in a loop.
- return Deployment.create(name, slot, status, label, virtualMachineName, instanceName, instanceStatus, //
- instanceStateDetails, instanceErrorCode, instanceSize, privateIpAddress, publicIpAddress);
+ return Deployment.create(name, slot, status, label, //
+ instanceStateDetails, instanceErrorCode, virtualIPs, roleInstanceList, roleList, virtualNetworkName);
}
@Override public void startElement(String url, String name, String qName, Attributes attributes) {
- depth++;
+ if (qName.equals("VirtualIPs")) {
+ inListVirtualIPs = true;
+ } else if (qName.equals("RoleInstanceList")) {
+ inRoleInstanceList = true;
+ } else if (qName.equals("RoleList")) {
+ inRoleList = true;
+ }
+ if (inRoleInstanceList) {
+ roleInstanceHandler.startElement(url, name, qName, attributes);
+ }
+ if (inRoleList) {
+ roleHandler.startElement(url, name, qName, attributes);
+ }
}
@Override public void endElement(String ignoredUri, String ignoredName, String qName) {
- if (qName.equals("Name") && depth == 2) {
+ if (qName.equals("RoleInstanceList")) {
+ inRoleInstanceList = false;
+ } else if (qName.equals("RoleInstance")) {
+ roleInstanceList.add(roleInstanceHandler.getResult());
+ } else if (inRoleInstanceList) {
+ roleInstanceHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (qName.equals("RoleList")) {
+ inRoleList = false;
+ } else if (qName.equals("Role")) {
+ roleList.add(roleHandler.getResult());
+ } else if (inRoleList) {
+ roleHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (qName.equals("VirtualIPs")) {
+ inListVirtualIPs = false;
+ virtualIPs.add(virtualIPHandler.getResult());
+ } else if (inListVirtualIPs) {
+ virtualIPHandler.endElement(ignoredUri, ignoredName, qName);
+ } else if (qName.equals("Name") && name == null) {
name = currentOrNull(currentText);
} else if (qName.equals("DeploymentSlot")) {
String slotText = currentOrNull(currentText);
@@ -71,7 +114,7 @@ public final class DeploymentHandler extends ParseSax.HandlerForGeneratedRequest
}
} else if (qName.equals("Status")) {
String statusText = currentOrNull(currentText);
- if (statusText != null) {
+ if (status == null && statusText != null) {
status = parseStatus(statusText);
}
} else if (qName.equals("Label")) {
@@ -79,35 +122,26 @@ public final class DeploymentHandler extends ParseSax.HandlerForGeneratedRequest
if (labelText != null) {
label = new String(base64().decode(labelText), UTF_8);
}
- } else if (qName.equals("RoleName")) {
- virtualMachineName = currentOrNull(currentText);
- } else if (qName.equals("InstanceName")) {
- instanceName = currentOrNull(currentText);
- } else if (qName.equals("InstanceStatus")) {
- String instanceStatusText = currentOrNull(currentText);
- if (instanceStatusText != null) {
- instanceStatus = parseInstanceStatus(instanceStatusText);
- }
} else if (qName.equals("InstanceStateDetails")) {
instanceStateDetails = currentOrNull(currentText);
} else if (qName.equals("InstanceErrorCode")) {
instanceErrorCode = currentOrNull(currentText);
- } else if (qName.equals("InstanceSize")) {
- String instanceSizeText = currentOrNull(currentText);
- if (instanceSizeText != null) {
- instanceSize = parseRoleSize(instanceSizeText);
- }
- } else if (qName.equals("IpAddress")) {
- privateIpAddress = currentOrNull(currentText);
- } else if (qName.equals("Vip")) {
- publicIpAddress = currentOrNull(currentText);
+ } else if (qName.equals("VirtualNetworkName")) {
+ virtualNetworkName = currentOrNull(currentText);
}
currentText.setLength(0);
- depth--;
}
@Override public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
+ if (inListVirtualIPs) {
+ virtualIPHandler.characters(ch, start, length);
+ } else if (inRoleInstanceList) {
+ roleInstanceHandler.characters(ch, start, length);
+ } else if (inRoleList) {
+ roleHandler.characters(ch, start, length);
+ } else if (!inListVirtualIPs && !inRoleInstanceList && !inRoleList) {
+ currentText.append(ch, start, length);
+ }
}
private static Status parseStatus(String status) {
@@ -135,11 +169,11 @@ public final class DeploymentHandler extends ParseSax.HandlerForGeneratedRequest
}
}
- private static RoleSize parseRoleSize(String roleSize) {
+ private static RoleSize.Type parseRoleSize(String roleSize) {
try {
- return RoleSize.valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, roleSize));
+ return RoleSize.Type.valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, roleSize));
} catch (IllegalArgumentException e) {
- return RoleSize.UNRECOGNIZED;
+ return RoleSize.Type.UNRECOGNIZED;
}
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/InputEndpointHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/InputEndpointHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/InputEndpointHandler.java
new file mode 100644
index 0000000..88c0102
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/InputEndpointHandler.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.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import org.jclouds.azurecompute.domain.Role.ConfigurationSet.InputEndpoint;
+import org.jclouds.azurecompute.domain.Role.ConfigurationSet.InputEndpoint.LoadBalancerProbe;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+public class InputEndpointHandler extends ParseSax.HandlerForGeneratedRequestWithResult<InputEndpoint> {
+ private Integer localPort;
+ private String name;
+ private Integer port;
+ private String protocol;
+ private Boolean enableDirectServerReturn;
+ private String vip;
+ private String loadBalancerName;
+ private LoadBalancerProbe loadBalancerProbe;
+ private Integer idleTimeoutInMinutes;
+
+ private StringBuilder currentText = new StringBuilder();
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ }
+
+ @Override
+ public InputEndpoint getResult() {
+ InputEndpoint result = InputEndpoint.create(name, protocol, localPort, port, vip,
+ enableDirectServerReturn, loadBalancerName, loadBalancerProbe, idleTimeoutInMinutes);
+ resetState(); // handler is called in a loop.
+ return result;
+ }
+
+ private void resetState() {
+ name = vip = protocol = null;
+ }
+
+ @Override
+ public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("Name")) {
+ name = currentOrNull(currentText);
+ } else if (qName.equals("Vip")) {
+ vip = currentOrNull(currentText);
+ } else if (qName.equals("LocalPort")) {
+ String localPortText = currentOrNull(currentText);
+ if (localPortText != null) {
+ localPort = Integer.parseInt(localPortText);
+ }
+ } else if (qName.equals("Port")) {
+ String portText = currentOrNull(currentText);
+ if (portText != null) {
+ port = Integer.parseInt(portText);
+ }
+ } else if (qName.equals("Protocol")) {
+ protocol = currentOrNull(currentText);
+ } else if (qName.equals("EnableDirectServerReturn")) {
+ String enableDirectServerReturnText = currentOrNull(currentText);
+ if (enableDirectServerReturnText != null) {
+ enableDirectServerReturn = Boolean.parseBoolean(enableDirectServerReturnText);
+ }
+ }
+ currentText.setLength(0);
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/InstanceEndpointHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/InstanceEndpointHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/InstanceEndpointHandler.java
new file mode 100644
index 0000000..6092428
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/InstanceEndpointHandler.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.azurecompute.xml;
+
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import org.jclouds.azurecompute.domain.Deployment.InstanceEndpoint;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+public class InstanceEndpointHandler extends ParseSax.HandlerForGeneratedRequestWithResult<InstanceEndpoint> {
+ private String name;
+ private String vip;
+ private Integer publicPort;
+ private Integer localPort;
+ private String protocol;
+
+ private StringBuilder currentText = new StringBuilder();
+
+ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ }
+
+ @Override public InstanceEndpoint getResult() {
+ InstanceEndpoint result = InstanceEndpoint.create(name, vip, publicPort, localPort, protocol);
+ resetState(); // handler is called in a loop.
+ return result;
+ }
+
+ private void resetState() {
+ name = vip = protocol = null;
+ publicPort = localPort = null;
+ }
+
+ @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("Name")) {
+ name = currentOrNull(currentText);
+ } else if (qName.equals("Vip")) {
+ vip = currentOrNull(currentText);
+ } else if (qName.equals("PublicPort")) {
+ String publicPortText = currentOrNull(currentText);
+ if (publicPortText != null){
+ publicPort = Integer.parseInt(publicPortText);
+ }
+ } else if (qName.equals("LocalPort")) {
+ String localPortText = currentOrNull(currentText);
+ if (localPortText != null){
+ localPort = Integer.parseInt(localPortText);
+ }
+ } else if (qName.equals("Protocol")) {
+ protocol = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a34e62ca/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java
index acdc7b5..c23c6d0 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java
@@ -24,12 +24,17 @@ import org.xml.sax.Attributes;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
+import com.google.inject.Inject;
public final class ListDisksHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<Disk>> {
private boolean inDisk;
- private final DiskHandler diskHandler = new DiskHandler();
+ private final DiskHandler diskHandler;
private final Builder<Disk> disks = ImmutableList.builder();
+ @Inject ListDisksHandler(DiskHandler diskHandler) {
+ this.diskHandler = diskHandler;
+ }
+
@Override public List<Disk> getResult() {
return disks.build();
}