You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2018/01/08 14:56:00 UTC

[19/21] jclouds-labs git commit: Promoted Azure ARM to the main repo

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeSecurityGroupExtension.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeSecurityGroupExtension.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeSecurityGroupExtension.java
deleted file mode 100644
index b31e2a0..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeSecurityGroupExtension.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.extensions;
-
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.base.Predicates.equalTo;
-import static com.google.common.base.Predicates.notNull;
-import static com.google.common.collect.Iterables.any;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.transform;
-import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED;
-import static org.jclouds.azurecompute.arm.domain.IdReference.extractName;
-import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.jclouds.azurecompute.arm.AzureComputeApi;
-import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.SecurityGroupAvailablePredicateFactory;
-import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName;
-import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard;
-import org.jclouds.azurecompute.arm.domain.NetworkProfile.NetworkInterface;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroupProperties;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Access;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Direction;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Protocol;
-import org.jclouds.azurecompute.arm.domain.ResourceGroup;
-import org.jclouds.azurecompute.arm.domain.VirtualMachine;
-import org.jclouds.azurecompute.arm.features.NetworkSecurityGroupApi;
-import org.jclouds.azurecompute.arm.features.NetworkSecurityRuleApi;
-import org.jclouds.compute.domain.SecurityGroup;
-import org.jclouds.compute.domain.SecurityGroupBuilder;
-import org.jclouds.compute.extensions.SecurityGroupExtension;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.domain.Location;
-import org.jclouds.location.Region;
-import org.jclouds.logging.Logger;
-import org.jclouds.net.domain.IpPermission;
-import org.jclouds.net.domain.IpProtocol;
-
-import com.google.common.base.Function;
-import com.google.common.base.Objects;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Ordering;
-
-public class AzureComputeSecurityGroupExtension implements SecurityGroupExtension {
-   @Resource
-   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
-   protected Logger logger = Logger.NULL;
-
-   private final AzureComputeApi api;
-   private final Function<NetworkSecurityGroup, SecurityGroup> securityGroupConverter;
-   private final SecurityGroupAvailablePredicateFactory securityGroupAvailable;
-   private final Predicate<URI> resourceDeleted;
-   private final LoadingCache<String, ResourceGroup> defaultResourceGroup;
-   private final Supplier<Set<String>> regionIds;
-
-   @Inject
-   AzureComputeSecurityGroupExtension(AzureComputeApi api,
-         Function<NetworkSecurityGroup, SecurityGroup> groupConverter,
-         SecurityGroupAvailablePredicateFactory securityRuleAvailable,
-         @Named(TIMEOUT_RESOURCE_DELETED) Predicate<URI> resourceDeleted,
-         LoadingCache<String, ResourceGroup> defaultResourceGroup,
-         @Region Supplier<Set<String>> regionIds) {
-      this.api = api;
-      this.securityGroupConverter = groupConverter;
-      this.securityGroupAvailable = securityRuleAvailable;
-      this.resourceDeleted = resourceDeleted;
-      this.defaultResourceGroup = defaultResourceGroup;
-      this.regionIds = regionIds;
-   }
-
-   @Override
-   public Set<SecurityGroup> listSecurityGroupsInLocation(Location location) {
-      return securityGroupsInLocations(ImmutableSet.of(location.getId()));
-   }
-
-   @Override
-   public Set<SecurityGroup> listSecurityGroups() {
-      return securityGroupsInLocations(regionIds.get());
-   }
-
-   private Set<SecurityGroup> securityGroupsInLocations(final Set<String> locations) {
-      List<SecurityGroup> securityGroups = new ArrayList<SecurityGroup>();
-      for (ResourceGroup rg : api.getResourceGroupApi().list()) {
-         securityGroups.addAll(securityGroupsInResourceGroup(rg.name()));
-      }
-      
-      return ImmutableSet.copyOf(filter(securityGroups, new Predicate<SecurityGroup>() {
-         @Override
-         public boolean apply(SecurityGroup input) {
-            return locations.contains(input.getLocation().getId());
-         }
-      }));
-   }
-
-   private Set<SecurityGroup> securityGroupsInResourceGroup(String resourceGroup) {
-      List<NetworkSecurityGroup> networkGroups = api.getNetworkSecurityGroupApi(resourceGroup).list();
-      return ImmutableSet.copyOf(transform(filter(networkGroups, notNull()), securityGroupConverter));
-   }
-
-   @Override
-   public Set<SecurityGroup> listSecurityGroupsForNode(String nodeId) {
-      logger.debug(">> getting security groups for node %s...", nodeId);
-
-      final ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(nodeId);
-
-      VirtualMachine vm = api.getVirtualMachineApi(resourceGroupAndName.resourceGroup()).get(
-            resourceGroupAndName.name());
-      if (vm == null) {
-         throw new IllegalArgumentException("Node " + nodeId + " was not found");
-      }
-      List<NetworkInterface> networkInterfaces = vm.properties().networkProfile().networkInterfaces();
-      List<NetworkSecurityGroup> networkGroups = new ArrayList<NetworkSecurityGroup>();
-
-      for (NetworkInterface networkInterfaceCardIdReference : networkInterfaces) {
-         String nicName = extractName(networkInterfaceCardIdReference.id());
-         String nicResourceGroup = extractResourceGroup(networkInterfaceCardIdReference.id());
-         NetworkInterfaceCard card = api.getNetworkInterfaceCardApi(nicResourceGroup).get(nicName);
-         if (card != null && card.properties().networkSecurityGroup() != null) {
-            String secGroupName = card.properties().networkSecurityGroup().name();
-            String sgResourceGroup = card.properties().networkSecurityGroup().resourceGroup();
-            NetworkSecurityGroup group = api.getNetworkSecurityGroupApi(sgResourceGroup).get(secGroupName);
-            networkGroups.add(group);
-         }
-      }
-
-      return ImmutableSet.copyOf(transform(filter(networkGroups, notNull()), securityGroupConverter));
-   }
-
-   @Override
-   public SecurityGroup getSecurityGroupById(String id) {
-      logger.debug(">> getting security group %s...", id);
-      final ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(id);
-      NetworkSecurityGroup securityGroup = api.getNetworkSecurityGroupApi(resourceGroupAndName.resourceGroup()).get(
-            resourceGroupAndName.name());
-      return securityGroup == null ? null : securityGroupConverter.apply(securityGroup);
-   }
-
-   @Override
-   public SecurityGroup createSecurityGroup(String name, Location location) {
-      ResourceGroup resourceGroup = defaultResourceGroup.getUnchecked(location.getId());
-
-      logger.debug(">> creating security group %s in %s...", name, location);
-
-      SecurityGroupBuilder builder = new SecurityGroupBuilder();
-      builder.name(name);
-      builder.location(location);
-      
-      NetworkSecurityGroup sg = api.getNetworkSecurityGroupApi(resourceGroup.name()).createOrUpdate(name,
-            location.getId(), null, NetworkSecurityGroupProperties.builder().build());
-      
-      checkState(securityGroupAvailable.create(resourceGroup.name()).apply(name),
-            "Security group was not created in the configured timeout");
-
-      return securityGroupConverter.apply(sg);
-   }
-
-   @Override
-   public boolean removeSecurityGroup(String id) {
-      logger.debug(">> deleting security group %s...", id);
-
-      final ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(id);
-      URI uri = api.getNetworkSecurityGroupApi(resourceGroupAndName.resourceGroup())
-            .delete(resourceGroupAndName.name());
-
-      // https://docs.microsoft.com/en-us/rest/api/network/virtualnetwork/delete-a-network-security-group
-      if (uri != null) {
-         // 202-Accepted if resource exists and the request is accepted.
-         return resourceDeleted.apply(uri);
-      } else {
-         // 204-No Content if resource does not exist.
-         return false;
-      }
-   }
-
-   @Override
-   public SecurityGroup addIpPermission(IpPermission ipPermission, SecurityGroup group) {
-      return addIpPermission(ipPermission.getIpProtocol(), ipPermission.getFromPort(), ipPermission.getToPort(),
-            ipPermission.getTenantIdGroupNamePairs(), ipPermission.getCidrBlocks(), ipPermission.getGroupIds(), group);
-   }
-
-   @Override
-   public SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group) {
-      return removeIpPermission(ipPermission.getIpProtocol(), ipPermission.getFromPort(), ipPermission.getToPort(),
-            ipPermission.getTenantIdGroupNamePairs(), ipPermission.getCidrBlocks(), ipPermission.getGroupIds(), group);
-   }
-
-   @Override
-   public SecurityGroup addIpPermission(IpProtocol protocol, int startPort, int endPort,
-         Multimap<String, String> tenantIdGroupNamePairs, Iterable<String> ipRanges, Iterable<String> groupIds,
-         SecurityGroup group) {
-      String portRange = startPort + "-" + endPort;
-      String ruleName = "ingress-" + protocol.name().toLowerCase() + "-" + portRange;
-
-      logger.debug(">> adding ip permission [%s] to %s...", ruleName, group.getName());
-
-      // TODO: Support Azure network tags somehow?
-
-      final ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(group.getId());
-
-      NetworkSecurityGroupApi groupApi = api.getNetworkSecurityGroupApi(resourceGroupAndName.resourceGroup());
-      NetworkSecurityGroup networkSecurityGroup = groupApi.get(resourceGroupAndName.name());
-
-      if (networkSecurityGroup == null) {
-         throw new IllegalArgumentException("Security group " + group.getName() + " was not found");
-      }
-
-      NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourceGroupAndName.resourceGroup(), networkSecurityGroup.name());
-      int nextPriority = getRuleStartingPriority(networkSecurityGroup);
-
-      for (String ipRange : ipRanges) {
-         NetworkSecurityRuleProperties properties = NetworkSecurityRuleProperties.builder()
-               .protocol(Protocol.fromValue(protocol.name()))
-               .sourceAddressPrefix(ipRange)
-               .sourcePortRange("*")
-               .destinationAddressPrefix("*")
-               .destinationPortRange(portRange)
-               .direction(Direction.Inbound)
-               .access(Access.Allow)
-               .priority(nextPriority++)
-               .build();
-
-         logger.debug(">> creating network security rule %s for %s...", ruleName, ipRange);
-
-         ruleApi.createOrUpdate(ruleName, properties);
-
-         checkState(
-               securityGroupAvailable.create(resourceGroupAndName.resourceGroup()).apply(networkSecurityGroup.name()),
-               "Security group was not updated in the configured timeout");
-      }
-
-      return getSecurityGroupById(group.getId());
-   }
-
-   @Override
-   public SecurityGroup removeIpPermission(final IpProtocol protocol, int startPort, int endPort,
-         Multimap<String, String> tenantIdGroupNamePairs, final Iterable<String> ipRanges, Iterable<String> groupIds,
-         SecurityGroup group) {
-      final String portRange = startPort + "-" + endPort;
-      String ruleName = "ingress-" + protocol.name().toLowerCase() + "-" + portRange;
-
-      logger.debug(">> deleting ip permissions matching [%s] from %s...", ruleName, group.getName());
-
-      final ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(group.getId());
-
-      NetworkSecurityGroupApi groupApi = api.getNetworkSecurityGroupApi(resourceGroupAndName.resourceGroup());
-      NetworkSecurityGroup networkSecurityGroup = groupApi.get(resourceGroupAndName.name());
-
-      if (networkSecurityGroup == null) {
-         throw new IllegalArgumentException("Security group " + group.getName() + " was not found");
-      }
-
-      NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourceGroupAndName.resourceGroup(),
-            networkSecurityGroup.name());
-      Iterable<NetworkSecurityRule> rules = filter(ruleApi.list(), new Predicate<NetworkSecurityRule>() {
-         @Override
-         public boolean apply(NetworkSecurityRule input) {
-            NetworkSecurityRuleProperties props = input.properties();
-            return Objects.equal(portRange, props.destinationPortRange())
-                  && Objects.equal(Protocol.fromValue(protocol.name()), props.protocol())
-                  && Objects.equal(Direction.Inbound, props.direction()) //
-                  && Objects.equal(Access.Allow, props.access())
-                  && any(ipRanges, equalTo(props.sourceAddressPrefix().replace("*", "0.0.0.0/0")));
-         }
-      });
-
-      for (NetworkSecurityRule matchingRule : rules) {
-         logger.debug(">> deleting network security rule %s from %s...", matchingRule.name(), group.getName());
-         ruleApi.delete(matchingRule.name());
-         checkState(
-               securityGroupAvailable.create(resourceGroupAndName.resourceGroup()).apply(networkSecurityGroup.name()),
-               "Security group was not updated in the configured timeout");
-      }
-
-      return getSecurityGroupById(group.getId());
-   }
-
-   @Override
-   public boolean supportsTenantIdGroupNamePairs() {
-      return false;
-   }
-
-   @Override
-   public boolean supportsTenantIdGroupIdPairs() {
-      return false;
-   }
-
-   @Override
-   public boolean supportsGroupIds() {
-      return false;
-   }
-
-   @Override
-   public boolean supportsPortRangesForGroups() {
-      return false;
-   }
-
-   @Override
-   public boolean supportsExclusionCidrBlocks() {
-      return false;
-   }
-
-   private int getRuleStartingPriority(NetworkSecurityGroup securityGroup) {
-      List<NetworkSecurityRule> existingRules = securityGroup.properties().securityRules();
-      return existingRules.isEmpty() ? 100 : rulesByPriority().max(existingRules).properties().priority() + 1;
-   }
-
-   private static Ordering<NetworkSecurityRule> rulesByPriority() {
-      return new Ordering<NetworkSecurityRule>() {
-         @Override
-         public int compare(NetworkSecurityRule left, NetworkSecurityRule right) {
-            return left.properties().priority() - right.properties().priority();
-         }
-      };
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/CustomImageToVMImage.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/CustomImageToVMImage.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/CustomImageToVMImage.java
deleted file mode 100644
index 2220535..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/CustomImageToVMImage.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.functions;
-
-import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
-
-import org.jclouds.azurecompute.arm.domain.Image;
-import org.jclouds.azurecompute.arm.domain.VMImage;
-
-import com.google.common.base.Function;
-
-public class CustomImageToVMImage implements Function<Image, VMImage> {
-
-   @Override
-   public VMImage apply(Image input) {
-      return VMImage.customImage().resourceGroup(extractResourceGroup(input.id())).customImageId(input.id()).location(input.location()).name(input.name())
-            .offer(input.properties().storageProfile().osDisk().osType()).build();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/LocationToLocation.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/LocationToLocation.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/LocationToLocation.java
deleted file mode 100644
index 7c60175..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/LocationToLocation.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.functions;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.azurecompute.arm.domain.Location;
-import org.jclouds.azurecompute.arm.domain.Region;
-import org.jclouds.domain.LocationBuilder;
-import org.jclouds.domain.LocationScope;
-import org.jclouds.location.suppliers.all.JustProvider;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSet;
-
-import static com.google.common.collect.Iterables.getOnlyElement;
-
-/**
- * Converts an Location into a Location.
- */
-@Singleton
-public class LocationToLocation implements Function<Location, org.jclouds.domain.Location> {
-
-   private final JustProvider justProvider;
-
-   // allow us to lazy discover the provider of a resource
-   @Inject
-   LocationToLocation(JustProvider justProvider) {
-      this.justProvider = justProvider;
-   }
-
-   @Override
-   public org.jclouds.domain.Location apply(final Location location) {
-      final LocationBuilder builder = new LocationBuilder();
-      builder.id(location.name());
-      builder.description(location.displayName());
-      builder.parent(getOnlyElement(justProvider.get()));
-      builder.scope(LocationScope.REGION);
-      final Region region = Region.byName(location.displayName());
-      if (region != null) {
-         builder.iso3166Codes(ImmutableSet.of(region.iso3166Code()));
-      }
-      return builder.build();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/LocationToResourceGroupName.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/LocationToResourceGroupName.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/LocationToResourceGroupName.java
deleted file mode 100644
index c97850a..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/LocationToResourceGroupName.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.functions;
-
-import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_DELIMITER;
-import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_PREFIX;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import com.google.common.base.Function;
-
-/**
- * Returns the name of the resource group for the current location.
- */
-public class LocationToResourceGroupName implements Function<String, String> {
-
-   private final String prefix;
-   private final char delimiter;
-
-   @Inject
-   LocationToResourceGroupName(@Named(RESOURCENAME_PREFIX) String prefix, @Named(RESOURCENAME_DELIMITER) char delimiter) {
-      this.prefix = prefix;
-      this.delimiter = delimiter;
-   }
-
-   @Override
-   public String apply(String input) {
-      return String.format("%s%s%s", prefix, delimiter, input);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/NetworkSecurityGroupToSecurityGroup.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/NetworkSecurityGroupToSecurityGroup.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/NetworkSecurityGroupToSecurityGroup.java
deleted file mode 100644
index d38f94c..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/NetworkSecurityGroupToSecurityGroup.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.functions;
-
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.transform;
-import static org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName.fromResourceGroupAndName;
-import static org.jclouds.azurecompute.arm.compute.functions.NetworkSecurityRuleToIpPermission.InboundRule;
-import static org.jclouds.azurecompute.arm.compute.functions.VirtualMachineToNodeMetadata.getLocation;
-import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
-
-import java.util.Set;
-
-import javax.inject.Singleton;
-
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule;
-import org.jclouds.collect.Memoized;
-import org.jclouds.compute.domain.SecurityGroup;
-import org.jclouds.compute.domain.SecurityGroupBuilder;
-import org.jclouds.domain.Location;
-import org.jclouds.net.domain.IpPermission;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-import com.google.inject.Inject;
-
-@Singleton
-public class NetworkSecurityGroupToSecurityGroup implements Function<NetworkSecurityGroup, SecurityGroup> {
-   private final Function<NetworkSecurityRule, IpPermission> ruleToPermission;
-   private final Supplier<Set<? extends Location>> locations;
-
-   @Inject
-   NetworkSecurityGroupToSecurityGroup(Function<NetworkSecurityRule, IpPermission> ruleToPermission,
-         @Memoized Supplier<Set<? extends Location>> locations) {
-      this.ruleToPermission = ruleToPermission;
-      this.locations = locations;
-   }
-
-   @Override
-   public SecurityGroup apply(NetworkSecurityGroup input) {
-      SecurityGroupBuilder builder = new SecurityGroupBuilder();
-
-      builder.id(fromResourceGroupAndName(extractResourceGroup(input.id()), input.name()).slashEncode());
-      builder.providerId(input.id());
-      builder.name(input.name());
-      builder.location(getLocation(locations, input.location()));
-
-      if (input.properties().securityRules() != null) {
-         // We just support security groups that allow traffic to a set of
-         // targets. We don't support deny rules or origin based rules in the
-         // security group api.
-         builder.ipPermissions(transform(filter(input.properties().securityRules(), InboundRule), ruleToPermission));
-      }
-
-      return builder.build();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/NetworkSecurityRuleToIpPermission.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/NetworkSecurityRuleToIpPermission.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/NetworkSecurityRuleToIpPermission.java
deleted file mode 100644
index 10b3174..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/NetworkSecurityRuleToIpPermission.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.functions;
-
-import javax.annotation.Resource;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Access;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Direction;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.logging.Logger;
-import org.jclouds.net.domain.IpPermission;
-import org.jclouds.net.domain.IpProtocol;
-import org.jclouds.net.util.IpPermissions;
-import org.jclouds.net.util.IpPermissions.PortSelection;
-import org.jclouds.net.util.IpPermissions.ToSourceSelection;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-
-@Singleton
-public class NetworkSecurityRuleToIpPermission implements Function<NetworkSecurityRule, IpPermission> {
-
-   public static final Predicate<NetworkSecurityRule> InboundRule = new Predicate<NetworkSecurityRule>() {
-      @Override
-      public boolean apply(NetworkSecurityRule input) {
-         return Direction.Inbound.equals(input.properties().direction())
-               && Access.Allow.equals(input.properties().access());
-      }
-   };
-
-   @Resource
-   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
-   protected Logger logger = Logger.NULL;
-
-   @Override
-   public IpPermission apply(final NetworkSecurityRule rule) {
-      if (!InboundRule.apply(rule)) {
-         logger.warn(">> ignoring non-inbound network security rule %s...", rule.name());
-         return null;
-      }
-
-      IpPermission permissions = IpPermissions.permit(IpProtocol.fromValue(rule.properties().protocol().name()));
-
-      String portRange = rule.properties().destinationPortRange();
-      if (!"*".equals(portRange)) {
-         String[] range = portRange.split("-"); // One single element if it is a single port
-         permissions = PortSelection.class.cast(permissions).fromPort(Integer.parseInt(range[0]))
-               .to(Integer.parseInt(range[range.length - 1]));
-      }
-
-      if (!"*".equals(rule.properties().sourceAddressPrefix())) {
-         permissions = ToSourceSelection.class.cast(permissions).originatingFromCidrBlock(
-               rule.properties().sourceAddressPrefix());
-      }
-
-      return permissions;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/TemplateToAvailabilitySet.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/TemplateToAvailabilitySet.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/TemplateToAvailabilitySet.java
deleted file mode 100644
index 7359ace..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/TemplateToAvailabilitySet.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.functions;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.azurecompute.arm.AzureComputeApi;
-import org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions;
-import org.jclouds.azurecompute.arm.domain.AvailabilitySet;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Function;
-
-@Singleton
-public class TemplateToAvailabilitySet implements Function<Template, AvailabilitySet> {
-
-   @Resource
-   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
-   protected Logger logger = Logger.NULL;
-
-   private final AzureComputeApi api;
-
-   @Inject
-   TemplateToAvailabilitySet(AzureComputeApi api) {
-      this.api = api;
-   }
-
-   @Nullable
-   @Override
-   public AvailabilitySet apply(final Template input) {
-      checkArgument(input.getOptions() instanceof AzureTemplateOptions, "An AzureTemplateOptions object is required");
-      AzureTemplateOptions options = input.getOptions().as(AzureTemplateOptions.class);
-
-      AvailabilitySet availabilitySet = null;
-      String location = input.getLocation().getId();
-      String resourceGroup = options.getResourceGroup();
-
-      if (options.getAvailabilitySetName() != null) {
-         availabilitySet = api.getAvailabilitySetApi(resourceGroup).get(options.getAvailabilitySetName());
-
-         checkArgument(availabilitySet != null, "No availability set with name '%s' was found", options.getAvailabilitySetName());
-         checkArgument(location.equals(availabilitySet.location()), "The availability set %s does not belong to location %s",
-               options.getAvailabilitySetName(), location);
-
-      } else if (options.getAvailabilitySet() != null) {
-         availabilitySet = api.getAvailabilitySetApi(resourceGroup).get(options.getAvailabilitySet().name());
-
-         if (availabilitySet != null) {
-            checkArgument(location.equals(availabilitySet.location()), "The availability set %s does not belong to location %s",
-                  options.getAvailabilitySet().name(), location);
-         } else {
-            Map<String, String> tags = new HashMap<String, String>();
-            if (options.getAvailabilitySet().tags() != null) {
-               tags.putAll(options.getAvailabilitySet().tags());
-            }
-            tags.put("jclouds", options.getAvailabilitySet().name());
-
-            logger.debug(">> creating availability set [%s]", options.getAvailabilitySet().name());
-
-            availabilitySet = api.getAvailabilitySetApi(resourceGroup).createOrUpdate(
-                  options.getAvailabilitySet().name(), options.getAvailabilitySet().sku(), location, tags,
-                  options.getAvailabilitySet().properties());
-         }
-      }
-
-      return availabilitySet;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VMHardwareToHardware.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VMHardwareToHardware.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VMHardwareToHardware.java
deleted file mode 100644
index d877aba..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VMHardwareToHardware.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.functions;
-
-import static org.jclouds.azurecompute.arm.compute.domain.LocationAndName.fromLocationAndName;
-
-import java.util.Set;
-
-import org.jclouds.azurecompute.arm.domain.VMHardware;
-import org.jclouds.collect.Memoized;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Processor;
-import org.jclouds.compute.domain.Volume;
-import org.jclouds.compute.domain.VolumeBuilder;
-import org.jclouds.domain.Location;
-import org.jclouds.location.predicates.LocationPredicates;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Inject;
-
-public class VMHardwareToHardware implements Function<VMHardware, Hardware> {
-
-   private final Supplier<Set<? extends Location>> locations;
-
-   @Inject
-   VMHardwareToHardware(@Memoized final Supplier<Set<? extends Location>> locations) {
-      this.locations = locations;
-   }
-
-   @Override
-   public Hardware apply(VMHardware from) {
-      final HardwareBuilder builder = new HardwareBuilder()
-              .name(from.name())
-              .providerId(from.name())
-              .id(fromLocationAndName(from.location(), from.name()).slashEncode())
-              .processors(ImmutableList.of(new Processor(from.numberOfCores(), 2)))
-              .ram(from.memoryInMB())
-              .location(FluentIterable.from(locations.get())
-                      .firstMatch(LocationPredicates.idEquals(from.location()))
-                      .get());
-
-      // No id or providerId from Azure
-      if (from.resourceDiskSizeInMB() != null) {
-         builder.volume(new VolumeBuilder()
-                 .size(Float.valueOf(from.resourceDiskSizeInMB()))
-                 .type(Volume.Type.LOCAL)
-                 .build());
-      }
-      if (from.osDiskSizeInMB() != null) {
-         builder.volume(new VolumeBuilder()
-                 .size(Float.valueOf(from.osDiskSizeInMB()))
-                 .type(Volume.Type.LOCAL)
-                 .build());
-      }
-
-      ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder();
-      metadata.put("maxDataDiskCount", String.valueOf(from.maxDataDiskCount()));
-      builder.userMetadata(metadata.build());
-
-      return builder.build();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VMImageToImage.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VMImageToImage.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VMImageToImage.java
deleted file mode 100644
index 028ad9c..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VMImageToImage.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.functions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.tryFind;
-import static java.util.Arrays.asList;
-import static org.jclouds.location.predicates.LocationPredicates.idEquals;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.jclouds.azurecompute.arm.compute.extensions.AzureComputeImageExtension;
-import org.jclouds.azurecompute.arm.domain.Plan;
-import org.jclouds.azurecompute.arm.domain.VMImage;
-import org.jclouds.collect.Memoized;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.ImageBuilder;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.domain.Location;
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Inject;
-
-public class VMImageToImage implements Function<VMImage, Image> {
-
-   private static final Map<String, OsFamily> OTHER_OS_MAP = ImmutableMap.<String, OsFamily> builder()
-         .put("openlogic", OsFamily.CENTOS)
-         .put("win", OsFamily.WINDOWS)
-         .put("sles", OsFamily.SUSE)
-         .put("oracle-linux", OsFamily.OEL)
-         .build();
-
-   private final Supplier<Set<? extends org.jclouds.domain.Location>> locations;
-
-   @Inject
-   VMImageToImage(@Memoized Supplier<Set<? extends Location>> locations) {
-      this.locations = locations;
-   }
-
-   @Override
-   public Image apply(final VMImage image) {
-      final ImageBuilder builder = new ImageBuilder();
-      addMarketplacePlanToMetadataIfPresent(builder, image);
-      
-      Location location = FluentIterable.from(locations.get()).firstMatch(idEquals(image.location())).get();
-      
-      if (image.custom()) {
-         builder
-            .id(image.encodeFieldsToUniqueIdCustom())
-            .providerId(image.customImageId())
-            .name(image.name())
-            .location(location)
-            .description(image.group())
-            .status(Image.Status.AVAILABLE)
-            .version("latest");
-      } else {
-         builder
-            .id(image.encodeFieldsToUniqueId())
-            .providerId(image.publisher())
-            .name(image.offer())
-            .location(location)
-            .description(image.sku())
-            .status(Image.Status.AVAILABLE)
-            .version(image.sku());
-      }
-      
-      final OperatingSystem.Builder osBuilder = osFamily().apply(image);
-      builder.operatingSystem(osBuilder.build());
-      
-      return builder.build();
-   }
-   
-   private static void addMarketplacePlanToMetadataIfPresent(ImageBuilder builder, VMImage image) {
-      if (image.versionProperties() != null && image.versionProperties().plan() != null) {
-         // Store the plan information in the metadata so the adapter can
-         // properly configure it when deploying images from the marketplace
-         Plan plan = image.versionProperties().plan();
-         builder.userMetadata(ImmutableMap.of("publisher", plan.publisher(), "name", plan.name(), "product",
-               plan.product()));
-      }
-   }
-   
-   @Nullable
-   public static Plan getMarketplacePlanFromImageMetadata(Image image) {
-      Map<String, String> imageMetadata = image.getUserMetadata();
-      return imageMetadata.containsKey("product") ? Plan.create(imageMetadata.get("publisher"),
-            imageMetadata.get("name"), imageMetadata.get("product")) : null;
-   }
-
-   public static Function<VMImage, OperatingSystem.Builder> osFamily() {
-      return new Function<VMImage, OperatingSystem.Builder>() {
-         @Override
-         public OperatingSystem.Builder apply(final VMImage image) {
-            final String label = checkNotNull(image.offer(), "offer").toLowerCase();
-            OsFamily family = findInStandardFamilies(label).or(findInOtherOSMap(label)).or(OsFamily.UNRECOGNIZED);
-            
-            // Fallback to generic operating system type
-            if (OsFamily.UNRECOGNIZED == family && image.versionProperties() != null
-                  && image.versionProperties().osDiskImage() != null
-                  && image.versionProperties().osDiskImage().operatingSystem() != null) {
-               family = OsFamily.fromValue(image.versionProperties().osDiskImage().operatingSystem().toUpperCase());
-            }
-
-            // only 64bit OS images are supported by Azure ARM
-            return OperatingSystem.builder().family(family).is64Bit(true)
-                  .description(image.custom() ? AzureComputeImageExtension.CUSTOM_IMAGE_OFFER : image.sku())
-                  .version(image.custom() ? "latest" : image.sku());
-         }
-      };
-   }
-
-   private static Optional<OsFamily> findInStandardFamilies(final String label) {
-      return tryFind(asList(OsFamily.values()), new Predicate<OsFamily>() {
-         @Override
-         public boolean apply(OsFamily input) {
-            return label.contains(input.value());
-         }
-      });
-   }
-
-   private static Optional<OsFamily> findInOtherOSMap(final String label) {
-      return tryFind(OTHER_OS_MAP.keySet(), new Predicate<String>() {
-         @Override
-         public boolean apply(String input) {
-            return label.contains(input);
-         }
-      }).transform(new Function<String, OsFamily>() {
-         @Override
-         public OsFamily apply(String input) {
-            return OTHER_OS_MAP.get(input);
-         }
-      });
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VirtualMachineToNodeMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VirtualMachineToNodeMetadata.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VirtualMachineToNodeMetadata.java
deleted file mode 100644
index af43cbb..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VirtualMachineToNodeMetadata.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.functions;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Strings.nullToEmpty;
-import static com.google.common.collect.Iterables.find;
-import static org.jclouds.azurecompute.arm.compute.AzureComputeServiceAdapter.GROUP_KEY;
-import static org.jclouds.azurecompute.arm.compute.domain.LocationAndName.fromLocationAndName;
-import static org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName.fromResourceGroupAndName;
-import static org.jclouds.azurecompute.arm.domain.IdReference.extractName;
-import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
-import static org.jclouds.compute.util.ComputeServiceUtils.addMetadataAndParseTagsFromCommaDelimitedValue;
-import static org.jclouds.location.predicates.LocationPredicates.idEquals;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.jclouds.azurecompute.arm.AzureComputeApi;
-import org.jclouds.azurecompute.arm.compute.domain.LocationAndName;
-import org.jclouds.azurecompute.arm.compute.functions.VirtualMachineToStatus.StatusAndBackendStatus;
-import org.jclouds.azurecompute.arm.domain.IdReference;
-import org.jclouds.azurecompute.arm.domain.IpConfiguration;
-import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard;
-import org.jclouds.azurecompute.arm.domain.NetworkProfile.NetworkInterface;
-import org.jclouds.azurecompute.arm.domain.PublicIPAddress;
-import org.jclouds.azurecompute.arm.domain.StorageProfile;
-import org.jclouds.azurecompute.arm.domain.VirtualMachine;
-import org.jclouds.collect.Memoized;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadataBuilder;
-import org.jclouds.compute.functions.GroupNamingConvention;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.compute.suppliers.ImageCacheSupplier;
-import org.jclouds.domain.Credentials;
-import org.jclouds.domain.Location;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.collect.Lists;
-
-public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, NodeMetadata> {
-
-   @Resource
-   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
-   protected Logger logger = Logger.NULL;
-
-   private final AzureComputeApi api;
-   private final GroupNamingConvention nodeNamingConvention;
-   private final Supplier<Set<? extends Location>> locations;
-   private final Supplier<Map<String, ? extends Hardware>> hardwares;
-   private final ImageCacheSupplier imageCache;
-   private final VirtualMachineToStatus virtualMachineToStatus;
-
-   @Inject
-   VirtualMachineToNodeMetadata(AzureComputeApi api, GroupNamingConvention.Factory namingConvention,
-         Supplier<Map<String, ? extends Hardware>> hardwares, @Memoized Supplier<Set<? extends Location>> locations,
-         Map<String, Credentials> credentialStore, @Memoized Supplier<Set<? extends Image>> imageCache,
-         VirtualMachineToStatus virtualMachineToStatus) {
-      this.api = api;
-      this.nodeNamingConvention = namingConvention.createWithoutPrefix();
-      this.locations = locations;
-      this.hardwares = hardwares;
-      this.virtualMachineToStatus = virtualMachineToStatus;
-      checkArgument(imageCache instanceof ImageCacheSupplier,
-            "This provider needs an instance of the ImageCacheSupplier");
-      this.imageCache = (ImageCacheSupplier) imageCache;
-   }
-
-   @Override
-   public NodeMetadata apply(VirtualMachine virtualMachine) {
-      NodeMetadataBuilder builder = new NodeMetadataBuilder();
-      builder.id(fromResourceGroupAndName(extractResourceGroup(virtualMachine.id()), virtualMachine.name())
-            .slashEncode());
-      builder.providerId(virtualMachine.id());
-      builder.name(virtualMachine.name());
-      builder.hostname(virtualMachine.name());
-
-      StatusAndBackendStatus status = virtualMachineToStatus.apply(virtualMachine);
-      builder.status(status.status());
-      builder.backendStatus(status.backendStatus());
-
-      builder.publicAddresses(getPublicIpAddresses(virtualMachine.properties().networkProfile().networkInterfaces()));
-      builder.privateAddresses(getPrivateIpAddresses(virtualMachine.properties().networkProfile().networkInterfaces()));
-
-      String groupFromMetadata = null;
-      if (virtualMachine.tags() != null) {
-         addMetadataAndParseTagsFromCommaDelimitedValue(builder, virtualMachine.tags());
-         groupFromMetadata = virtualMachine.tags().get(GROUP_KEY);
-      }
-
-      // Try to read the group from the virtual machine tags, and parse the name
-      // if missing
-      builder.group(groupFromMetadata != null ? groupFromMetadata : nodeNamingConvention.extractGroup(virtualMachine
-            .name()));
-
-      String locationName = virtualMachine.location();
-      builder.location(getLocation(locations, locationName));
-
-      Optional<? extends Image> image = findImage(virtualMachine.properties().storageProfile(), locationName);
-      
-      if (image.isPresent()) {
-         builder.imageId(image.get().getId());
-         builder.operatingSystem(image.get().getOperatingSystem());
-      } else {
-         logger.info(">> image with id %s for virtualmachine %s was not found. "
-               + "This might be because the image that was used to create the virtualmachine has a new id.",
-               virtualMachine.id(), virtualMachine.id());
-      }
-
-      builder.hardware(getHardware(fromLocationAndName(virtualMachine.location(), virtualMachine.properties()
-            .hardwareProfile().vmSize())));
-
-      return builder.build();
-   }
-
-   private Iterable<String> getPrivateIpAddresses(List<NetworkInterface> networkInterfaces) {
-      List<String> privateIpAddresses = Lists.newArrayList();
-      for (NetworkInterface networkInterfaceCardIdReference : networkInterfaces) {
-         NetworkInterfaceCard networkInterfaceCard = getNetworkInterfaceCard(networkInterfaceCardIdReference);
-         if (networkInterfaceCard != null && networkInterfaceCard.properties() != null
-               && networkInterfaceCard.properties().ipConfigurations() != null) {
-            for (IpConfiguration ipConfiguration : networkInterfaceCard.properties().ipConfigurations()) {
-               if (ipConfiguration.properties().privateIPAddress() != null) {
-                  privateIpAddresses.add(ipConfiguration.properties().privateIPAddress());
-               }
-            }
-         }
-      }
-      return privateIpAddresses;
-   }
-
-   private NetworkInterfaceCard getNetworkInterfaceCard(NetworkInterface nic) {
-      return api.getNetworkInterfaceCardApi(extractResourceGroup(nic.id())).get(extractName(nic.id()));
-   }
-
-   private Iterable<String> getPublicIpAddresses(List<NetworkInterface> networkInterfaces) {
-      List<String> publicIpAddresses = Lists.newArrayList();
-      for (NetworkInterface networkInterfaceCardIdReference : networkInterfaces) {
-         NetworkInterfaceCard networkInterfaceCard = getNetworkInterfaceCard(networkInterfaceCardIdReference);
-         if (networkInterfaceCard != null && networkInterfaceCard.properties() != null
-               && networkInterfaceCard.properties().ipConfigurations() != null) {
-            for (IpConfiguration ipConfiguration : networkInterfaceCard.properties().ipConfigurations()) {
-               if (ipConfiguration.properties().publicIPAddress() != null) {
-                  IdReference publicIpId = ipConfiguration.properties().publicIPAddress();
-                  PublicIPAddress publicIp = api.getPublicIPAddressApi(publicIpId.resourceGroup()).get(
-                        publicIpId.name());
-                  if (publicIp != null && publicIp.properties().ipAddress() != null) {
-                     publicIpAddresses.add(publicIp.properties().ipAddress());
-                  }
-               }
-            }
-         }
-      }
-      return publicIpAddresses;
-   }
-
-   protected static Location getLocation(Supplier<Set<? extends Location>> locations, final String locationName) {
-      return find(locations.get(), idEquals(nullToEmpty(locationName)), null);
-   }
-
-   protected Optional<? extends Image> findImage(final StorageProfile storageProfile, String locatioName) {
-      if (storageProfile.imageReference() != null) {
-         String imageId = storageProfile.imageReference().customImageId() != null ?
-               storageProfile.imageReference().encodeFieldsToUniqueIdCustom(locatioName) :
-               storageProfile.imageReference().encodeFieldsToUniqueId(locatioName); 
-         return imageCache.get(imageId);
-      } else {
-         logger.warn("could not find image for storage profile %s", storageProfile);
-         return Optional.absent();
-      }
-   }
-
-   protected Hardware getHardware(final LocationAndName hardwareId) {
-      final String slashEncoded = hardwareId.slashEncode();
-      return find(hardwares.get().values(), new Predicate<Hardware>() {
-         @Override
-         public boolean apply(Hardware input) {
-            return input.getId().equals(slashEncoded);
-         }
-      });
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VirtualMachineToStatus.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VirtualMachineToStatus.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VirtualMachineToStatus.java
deleted file mode 100644
index 9669f50..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/functions/VirtualMachineToStatus.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.functions;
-
-import static com.google.common.collect.Iterables.transform;
-import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.azurecompute.arm.AzureComputeApi;
-import org.jclouds.azurecompute.arm.compute.functions.VirtualMachineToStatus.StatusAndBackendStatus;
-import org.jclouds.azurecompute.arm.domain.Status;
-import org.jclouds.azurecompute.arm.domain.VirtualMachine;
-import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance;
-import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance.PowerState;
-import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties;
-import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties.ProvisioningState;
-import org.jclouds.compute.domain.NodeMetadata;
-
-import com.google.auto.value.AutoValue;
-import com.google.common.base.Function;
-import com.google.common.base.Functions;
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableMap;
-
-@Singleton
-public class VirtualMachineToStatus implements Function<VirtualMachine, StatusAndBackendStatus> {
-
-   @AutoValue
-   public abstract static class StatusAndBackendStatus {
-      public abstract NodeMetadata.Status status();
-
-      public abstract String backendStatus();
-
-      public static StatusAndBackendStatus create(NodeMetadata.Status status, String backendStatus) {
-         return new AutoValue_VirtualMachineToStatus_StatusAndBackendStatus(status, backendStatus);
-      }
-   }
-
-   // When using the Deployment API to deploy an ARM template, the deployment
-   // goes through stages: Accepted -> Running -> Succeeded.
-   // Only when the deployment has SUCCEEDED is the resource deployed using the
-   // template actually ready.
-   // To get details about the resource(s) deployed via template, one needs to
-   // query the various resources after the deployment has SUCCEEDED.
-   private static final Function<VirtualMachineProperties.ProvisioningState, NodeMetadata.Status> PROVISIONINGSTATE_TO_NODESTATUS = Functions
-         .forMap(
-               ImmutableMap.<VirtualMachineProperties.ProvisioningState, NodeMetadata.Status> builder()
-                     .put(VirtualMachineProperties.ProvisioningState.ACCEPTED, NodeMetadata.Status.PENDING)
-                     .put(VirtualMachineProperties.ProvisioningState.READY, NodeMetadata.Status.PENDING)
-                     .put(VirtualMachineProperties.ProvisioningState.CREATING, NodeMetadata.Status.PENDING)
-                     .put(VirtualMachineProperties.ProvisioningState.RUNNING, NodeMetadata.Status.PENDING)
-                     .put(VirtualMachineProperties.ProvisioningState.UPDATING, NodeMetadata.Status.PENDING)
-                     .put(VirtualMachineProperties.ProvisioningState.DELETED, NodeMetadata.Status.TERMINATED)
-                     .put(VirtualMachineProperties.ProvisioningState.CANCELED, NodeMetadata.Status.TERMINATED)
-                     .put(VirtualMachineProperties.ProvisioningState.FAILED, NodeMetadata.Status.ERROR)
-                     .put(VirtualMachineProperties.ProvisioningState.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED)
-                     .build(), NodeMetadata.Status.UNRECOGNIZED);
-
-   private static final Function<PowerState, NodeMetadata.Status> POWERSTATE_TO_NODESTATUS = Functions.forMap(
-         ImmutableMap.<PowerState, NodeMetadata.Status> builder().put(PowerState.RUNNING, NodeMetadata.Status.RUNNING)
-               .put(PowerState.STOPPED, NodeMetadata.Status.SUSPENDED)
-               .put(PowerState.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED).build(),
-         NodeMetadata.Status.UNRECOGNIZED);
-
-   private final AzureComputeApi api;
-
-   @Inject
-   VirtualMachineToStatus(AzureComputeApi api) {
-      this.api = api;
-   }
-
-   @Override
-   public StatusAndBackendStatus apply(VirtualMachine virtualMachine) {
-      String resourceGroup = extractResourceGroup(virtualMachine.id());
-      ProvisioningState provisioningState = virtualMachine.properties().provisioningState();
-
-      NodeMetadata.Status status = PROVISIONINGSTATE_TO_NODESTATUS.apply(provisioningState);
-      String backendStatus = provisioningState.name();
-
-      if (ProvisioningState.SUCCEEDED.equals(provisioningState)) {
-         // If the provisioning succeeded, we need to query the *real* status of
-         // the VM
-         VirtualMachineInstance instanceDetails = api.getVirtualMachineApi(resourceGroup).getInstanceDetails(
-               virtualMachine.name());
-         if (instanceDetails != null && instanceDetails.powerState() != null) {
-            status = POWERSTATE_TO_NODESTATUS.apply(instanceDetails.powerState());
-            backendStatus = Joiner.on(',').join(transform(instanceDetails.statuses(), new Function<Status, String>() {
-               @Override
-               public String apply(Status input) {
-                  return input.code();
-               }
-            }));
-         } else {
-            status = NodeMetadata.Status.PENDING;
-         }
-      }
-
-      return StatusAndBackendStatus.create(status, backendStatus);
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/loaders/CreateSecurityGroupIfNeeded.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/loaders/CreateSecurityGroupIfNeeded.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/loaders/CreateSecurityGroupIfNeeded.java
deleted file mode 100644
index baba6f9..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/loaders/CreateSecurityGroupIfNeeded.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.loaders;
-
-import static com.google.common.base.Preconditions.checkState;
-import static org.jclouds.compute.util.ComputeServiceUtils.getPortRangesFromList;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.azurecompute.arm.AzureComputeApi;
-import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.SecurityGroupAvailablePredicateFactory;
-import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndNameAndIngressRules;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroupProperties;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Access;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Direction;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Protocol;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.logging.Logger;
-
-import com.google.common.cache.CacheLoader;
-
-@Singleton
-public class CreateSecurityGroupIfNeeded extends CacheLoader<ResourceGroupAndNameAndIngressRules, String> {
-   @Resource
-   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
-   protected Logger logger = Logger.NULL;
-
-   private final AzureComputeApi api;
-   private final SecurityGroupAvailablePredicateFactory securityGroupAvailable;
-
-   @Inject
-   CreateSecurityGroupIfNeeded(AzureComputeApi api, SecurityGroupAvailablePredicateFactory securityRuleAvailable) {
-      this.api = api;
-      this.securityGroupAvailable = securityRuleAvailable;
-   }
-
-   @Override
-   public String load(ResourceGroupAndNameAndIngressRules key) throws Exception {
-      return createSecurityGroup(key.location(), key.resourceGroup(), key.name(), key.inboundPorts());
-   }
-
-   private String createSecurityGroup(String location, String resourceGroup, String name, int[] inboundPorts) {
-      logger.debug(">> creating security group %s in %s...", name, location);
-
-      Map<Integer, Integer> portRanges = getPortRangesFromList(inboundPorts);
-
-      List<NetworkSecurityRule> rules = new ArrayList<NetworkSecurityRule>();
-
-      int startPriority = 100;
-      for (Map.Entry<Integer, Integer> portRange : portRanges.entrySet()) {
-         String range = portRange.getKey() + "-" + portRange.getValue();
-         String ruleName = "tcp-" + range;
-
-         NetworkSecurityRuleProperties properties = NetworkSecurityRuleProperties.builder().protocol(Protocol.Tcp) //
-               .sourceAddressPrefix("*") //
-               .sourcePortRange("*") //
-               .destinationAddressPrefix("*") //
-               .destinationPortRange(range) //
-               .direction(Direction.Inbound) //
-               .access(Access.Allow) //
-               .priority(startPriority++) //
-               .build();
-
-         rules.add(NetworkSecurityRule.create(ruleName, null, null, properties));
-      }
-
-      NetworkSecurityGroup securityGroup = api.getNetworkSecurityGroupApi(resourceGroup).createOrUpdate(name, location,
-            null, NetworkSecurityGroupProperties.builder().securityRules(rules).build());
-      
-      checkState(securityGroupAvailable.create(resourceGroup).apply(name),
-            "Security group was not created in the configured timeout");
-
-      return securityGroup.id();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/loaders/DefaultResourceGroup.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/loaders/DefaultResourceGroup.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/loaders/DefaultResourceGroup.java
deleted file mode 100644
index 7caec25..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/loaders/DefaultResourceGroup.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.loaders;
-
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.azurecompute.arm.AzureComputeApi;
-import org.jclouds.azurecompute.arm.compute.functions.LocationToResourceGroupName;
-import org.jclouds.azurecompute.arm.domain.ResourceGroup;
-import org.jclouds.azurecompute.arm.features.ResourceGroupApi;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.logging.Logger;
-
-import com.google.common.cache.CacheLoader;
-import com.google.common.collect.ImmutableMap;
-
-@Singleton
-public class DefaultResourceGroup extends CacheLoader<String, ResourceGroup> {
-   @Resource
-   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
-   protected Logger logger = Logger.NULL;
-
-   private final ResourceGroupApi api;
-   private final LocationToResourceGroupName locationToResourceGroupName;
-
-   @Inject
-   DefaultResourceGroup(AzureComputeApi api, LocationToResourceGroupName locationToResourceGroupName) {
-      this.api = api.getResourceGroupApi();
-      this.locationToResourceGroupName = locationToResourceGroupName;
-   }
-
-   @Override
-   public ResourceGroup load(String locationId) throws Exception {
-      String azureGroupName = locationToResourceGroupName.apply(locationId);
-      ResourceGroup resourceGroup = api.get(azureGroupName);
-      if (resourceGroup == null) {
-         logger.debug(">> creating resource group %s", azureGroupName);
-         final Map<String, String> tags = ImmutableMap.of("description", "jclouds default resource group");
-         resourceGroup = api.create(azureGroupName, locationId, tags);
-      }
-      return resourceGroup;
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/options/AzureTemplateOptions.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/options/AzureTemplateOptions.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/options/AzureTemplateOptions.java
deleted file mode 100644
index b551811..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/options/AzureTemplateOptions.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.options;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.List;
-
-import org.jclouds.azurecompute.arm.domain.AvailabilitySet;
-import org.jclouds.azurecompute.arm.domain.DataDisk;
-import org.jclouds.azurecompute.arm.domain.OSProfile.WindowsConfiguration;
-import org.jclouds.azurecompute.arm.domain.Secrets;
-import org.jclouds.compute.options.TemplateOptions;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-
-/**
- * Azure ARM custom options
- */
-public class AzureTemplateOptions extends TemplateOptions implements Cloneable {
-
-   private AvailabilitySet availabilitySet;
-   private String availabilitySetName;
-   private List<DataDisk> dataDisks = ImmutableList.of();
-   private String resourceGroup;
-   private List<IpOptions> ipOptions = ImmutableList.of();
-   private WindowsConfiguration windowsConfiguration;
-   private List<Secrets> secrets = ImmutableList.of();
-   private String customData;
-
-   /**
-    * Sets the availability set where the nodes will be configured. If it does
-    * not exist jclouds will create a new one with the given configuration.
-    */
-   public AzureTemplateOptions availabilitySet(AvailabilitySet availabilitySet) {
-      this.availabilitySet = availabilitySet;
-      return this;
-   }
-
-   /**
-    * Sets the availability set where the nodes will be configured. The
-    * availability set must exist.
-    */
-   public AzureTemplateOptions availabilitySet(String availabilitySetName) {
-      this.availabilitySetName = availabilitySetName;
-      return this;
-   }
-
-   /**
-    * The resource group where the new resources will be created.
-    */
-   public AzureTemplateOptions resourceGroup(String resourceGroup) {
-      this.resourceGroup = resourceGroup;
-      return this;
-   }
-
-   public AzureTemplateOptions dataDisks(Iterable<DataDisk> dataDisks) {
-      for (DataDisk dataDisk : checkNotNull(dataDisks, "dataDisks"))
-         checkNotNull(dataDisk, "all dataDisks must be non-empty");
-      this.dataDisks = ImmutableList.copyOf(dataDisks);
-      return this;
-   }
-
-   public AzureTemplateOptions dataDisks(DataDisk... dataDisks) {
-      return dataDisks(ImmutableList.copyOf(checkNotNull(dataDisks, "dataDisks")));
-   }
-
-   /**
-    * Configure the NICs that will be attached to the created nodes.
-    * <p>
-    * Note that the number of NICs that can be attached depends on the size of
-    * the virtual machine, and that the guest operating system needs to be
-    * prepared to set up all the configured interfaces.
-    * <p>
-    * Depending on the image being used, a cloud-init or bootstrap script might
-    * be needed to make the interface setup.
-    */
-   public AzureTemplateOptions ipOptions(Iterable<IpOptions> ipOptions) {
-      for (IpOptions ipOption : checkNotNull(ipOptions, "ipOptions"))
-         checkNotNull(ipOption, "all ipOptions must be non-empty");
-      this.ipOptions = ImmutableList.copyOf(ipOptions);
-      return this;
-   }
-
-   /**
-    * @see {@link AzureTemplateOptions#ipOptions(Iterable)
-
-    */
-   public AzureTemplateOptions ipOptions(IpOptions... ipOptions) {
-      return ipOptions(ImmutableList.copyOf(checkNotNull(ipOptions, "ipOptions")));
-   }
-
-   /**
-    * Windows configuration parameters
-    *
-    * @see <a
-    *      href="https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/virtualmachines-create-or-update#bk_windowsconfig5">docs</a>
-    */
-   public AzureTemplateOptions windowsConfiguration(WindowsConfiguration windowsConfiguration) {
-      this.windowsConfiguration = windowsConfiguration;
-      return this;
-   }
-
-   /**
-    * Import certificates in the Windows Certificate Store
-    *
-    * @see <a
-    *      href="https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/virtualmachines-create-or-update#bk_srcvault">docs</a>
-    */
-   public AzureTemplateOptions secrets(Iterable<? extends Secrets> secrets) {
-      for (Secrets secret : checkNotNull(secrets, "secrets"))
-         checkNotNull(secret, "secrets can not be empty");
-      this.secrets = ImmutableList.copyOf(secrets);
-      return this;
-   }
-
-   /**
-    * Custom data (for cloud-init) for the Azure ARM API
-    */
-   public AzureTemplateOptions customData(String customData) {
-      this.customData = customData;
-      return this;
-   }
-
-   public AvailabilitySet getAvailabilitySet() {
-      return availabilitySet;
-   }
-
-   public String getAvailabilitySetName() {
-      return availabilitySetName;
-   }
-
-   public List<DataDisk> getDataDisks() {
-      return dataDisks;
-   }
-
-   public String getResourceGroup() {
-      return resourceGroup;
-   }
-
-   public List<IpOptions> getIpOptions() {
-      return ipOptions;
-   }
-
-   public WindowsConfiguration getWindowsConfiguration() {
-      return windowsConfiguration;
-   }
-
-   public List<Secrets> getSecrets() {
-      return secrets;
-   }
-
-   public String getCustomData() {
-      return customData;
-   }
-
-   @Override
-   public AzureTemplateOptions clone() {
-      AzureTemplateOptions options = new AzureTemplateOptions();
-      copyTo(options);
-      return options;
-   }
-
-   @Override
-   public void copyTo(TemplateOptions to) {
-      super.copyTo(to);
-      if (to instanceof AzureTemplateOptions) {
-         AzureTemplateOptions eTo = AzureTemplateOptions.class.cast(to);
-         eTo.availabilitySet(availabilitySet);
-         eTo.availabilitySet(availabilitySetName);
-         eTo.dataDisks(dataDisks);
-         eTo.resourceGroup(resourceGroup);
-         eTo.ipOptions(ipOptions);
-         eTo.windowsConfiguration(windowsConfiguration);
-         eTo.secrets(secrets);
-         eTo.customData(customData);
-      }
-   }
-
-   @Override
-   public boolean equals(Object o) {
-      if (this == o)
-         return true;
-      if (!(o instanceof AzureTemplateOptions))
-         return false;
-      if (!super.equals(o))
-         return false;
-
-      AzureTemplateOptions that = (AzureTemplateOptions) o;
-
-      return Objects.equal(availabilitySetName, that.availabilitySetName)
-            && Objects.equal(resourceGroup, that.resourceGroup) && Objects.equal(availabilitySet, that.availabilitySet)
-            && Objects.equal(dataDisks, that.dataDisks) && Objects.equal(ipOptions, that.ipOptions)
-            && Objects.equal(windowsConfiguration, that.windowsConfiguration) && Objects.equal(secrets, that.secrets)
-            && Objects.equal(this.customData, that.customData);
-   }
-
-   @Override
-   public int hashCode() {
-      return Objects.hashCode(super.hashCode(), availabilitySet, availabilitySetName, dataDisks, resourceGroup,
-            ipOptions, customData);
-   }
-
-   @Override
-   public MoreObjects.ToStringHelper string() {
-      MoreObjects.ToStringHelper toString = super.string();
-      if (availabilitySet != null)
-         toString.add("availabilitySet", availabilitySet);
-      if (availabilitySetName != null)
-         toString.add("availabilitySetName", availabilitySetName);
-      if (!dataDisks.isEmpty())
-         toString.add("dataDisks", dataDisks);
-      if (resourceGroup != null)
-         toString.add("resourceGroup", resourceGroup);
-      if (!ipOptions.isEmpty())
-         toString.add("ipOptions", ipOptions);
-      if (windowsConfiguration != null)
-         toString.add("windowsConfiguration", windowsConfiguration);
-      if (!secrets.isEmpty())
-         toString.add("secrets", secrets);
-      if (customData != null)
-         toString.add("customData", customData);
-      return toString;
-   }
-
-   public static class Builder {
-
-      /**
-       * @see AzureTemplateOptions#availabilitySet(AvailabilitySet)
-       */
-      public static AzureTemplateOptions availabilitySet(AvailabilitySet availabilitySet) {
-         AzureTemplateOptions options = new AzureTemplateOptions();
-         return options.availabilitySet(availabilitySet);
-      }
-
-      /**
-       * @see AzureTemplateOptions#availabilitySet(String)
-       */
-      public static AzureTemplateOptions availabilitySet(String availabilitySetName) {
-         AzureTemplateOptions options = new AzureTemplateOptions();
-         return options.availabilitySet(availabilitySetName);
-      }
-
-      /**
-       * @see AzureTemplateOptions#dataDisks(DataDisk...)
-       */
-      public static AzureTemplateOptions dataDisks(DataDisk... dataDisks) {
-         AzureTemplateOptions options = new AzureTemplateOptions();
-         return options.dataDisks(dataDisks);
-      }
-
-      /**
-       * @see AzureTemplateOptions#dataDisks(Iterable)
-       */
-      public static AzureTemplateOptions dataDisks(Iterable<DataDisk> dataDisks) {
-         AzureTemplateOptions options = new AzureTemplateOptions();
-         return options.dataDisks(dataDisks);
-      }
-
-      /**
-       * @see AzureTemplateOptions#resourceGroup(String)
-       */
-      public static AzureTemplateOptions resourceGroup(String resourceGroup) {
-         AzureTemplateOptions options = new AzureTemplateOptions();
-         return options.resourceGroup(resourceGroup);
-      }
-
-      /**
-       * @see AzureTemplateOptions#ipOptions(IpOptions...)
-       */
-      public static AzureTemplateOptions ipOptions(IpOptions... ipOptions) {
-         AzureTemplateOptions options = new AzureTemplateOptions();
-         return options.ipOptions(ipOptions);
-      }
-
-      /**
-       * @see AzureTemplateOptions#ipOptions(Iterable)
-       */
-      public static AzureTemplateOptions ipOptions(Iterable<IpOptions> ipOptions) {
-         AzureTemplateOptions options = new AzureTemplateOptions();
-         return options.ipOptions(ipOptions);
-      }
-
-      /**
-       * @see AzureTemplateOptions#windowsConfiguration(WindowsConfiguration)
-       */
-      public static AzureTemplateOptions windowsConfiguration(WindowsConfiguration windowsConfiguration) {
-         AzureTemplateOptions options = new AzureTemplateOptions();
-         return options.windowsConfiguration(windowsConfiguration);
-      }
-
-      /**
-       * @see AzureTemplateOptions#secrets(List)
-       */
-      public static AzureTemplateOptions secrets(Iterable<? extends Secrets> secrets) {
-         AzureTemplateOptions options = new AzureTemplateOptions();
-         return options.secrets(secrets);
-      }
-
-      /**
-       * @see AzureTemplateOptions#customData
-       */
-      public static AzureTemplateOptions customData(String customData) {
-         AzureTemplateOptions options = new AzureTemplateOptions();
-         return options.customData(customData);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/options/IpOptions.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/options/IpOptions.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/options/IpOptions.java
deleted file mode 100644
index 73c4c6c..0000000
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/options/IpOptions.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.arm.compute.options;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.auto.value.AutoValue;
-import com.google.common.base.Optional;
-
-/**
- * Configures the ip addresses to be configured for the created nodes.
- */
-@AutoValue
-public abstract class IpOptions {
-
-   /**
-    * The subnet where the NIC will be attached.
-    */
-   public abstract String subnet();
-
-   /**
-    * The IP address to be configured, in case of static allocation, or absent
-    * for dynamic assignment.
-    */
-   public abstract Optional<String> address();
-
-   /**
-    * Flag to indicate if a public ip address should be allocated and bound to
-    * this NIC.
-    */
-   public abstract boolean allocateNewPublicIp();
-   
-   /**
-    * ID of the public IP to associate with the NIC.
-    */
-   @Nullable
-   public abstract String publicIpId();
-   
-   IpOptions() {
-      
-   }
-
-   public abstract Builder toBuilder();
-
-   public static Builder builder() {
-      return new AutoValue_IpOptions.Builder().address((String) null).allocateNewPublicIp(false);
-   }
-
-   @AutoValue.Builder
-   public abstract static class Builder {
-      public abstract Builder subnet(String subnet);
-      public abstract Builder allocateNewPublicIp(boolean allocatePublicIp);
-      public abstract Builder publicIpId(String publicIpId);
-      
-      abstract Builder address(Optional<String> address);
-      public Builder address(String address) {
-         return address(Optional.fromNullable(address));
-      }
-      
-      public abstract IpOptions build();
-   }
-}