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:47 UTC
[2/3] jclouds-labs git commit: azurecompute: improvements to the
domain objects
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))
+ )
+ );
+ }
+
+}