http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/compute/options/AzureComputeTemplateOptions.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/options/AzureComputeTemplateOptions.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/options/AzureComputeTemplateOptions.java deleted file mode 100644 index db2c35d..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/options/AzureComputeTemplateOptions.java +++ /dev/null @@ -1,443 +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.compute.options; - -import static com.google.common.base.Preconditions.checkNotNull; -import java.util.List; -import java.util.Map; - -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.scriptbuilder.domain.Statement; - -import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableList; - -/** - * Contains options supported by the {@link org.jclouds.compute.ComputeService#createNodesInGroup( - * String, int, org.jclouds.compute.options.TemplateOptions)} operation. - * - * <h2>Usage</h2> The recommended way to instantiate a {@link AzureComputeTemplateOptions} object is to statically - * import {@code AzureComputeTemplateOptions.*} and invoke a static creation method followed by an instance mutator (if - * needed): - * <p> - * - * <pre> - * import static org.jclouds.compute.options.AzureComputeTemplateOptions.Builder.*; - * ComputeService client = // get connection - * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); - * Set<? extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build()); - * </pre> - * - */ -public class AzureComputeTemplateOptions extends TemplateOptions implements Cloneable { - - protected String virtualNetworkName; - protected List<String> subnetNames = ImmutableList.of(); - protected String storageAccountName; - protected String storageAccountType; - protected String networkSecurityGroupName; - protected String reservedIPName; - protected Boolean provisionGuestAgent; - protected Boolean winrmUseHttps; - - @Override - public AzureComputeTemplateOptions clone() { - final AzureComputeTemplateOptions options = new AzureComputeTemplateOptions(); - copyTo(options); - return options; - } - - @Override - public void copyTo(final TemplateOptions to) { - super.copyTo(to); - if (to instanceof AzureComputeTemplateOptions) { - final AzureComputeTemplateOptions eTo = AzureComputeTemplateOptions.class.cast(to); - eTo.virtualNetworkName(virtualNetworkName); - if (!subnetNames.isEmpty()) { - eTo.subnetNames(subnetNames); - } - eTo.storageAccountName(storageAccountName); - eTo.storageAccountType(storageAccountType); - eTo.reservedIPName(reservedIPName); - eTo.provisionGuestAgent(provisionGuestAgent); - eTo.winrmUseHttps(winrmUseHttps); - } - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof AzureComputeTemplateOptions)) return false; - if (!super.equals(o)) return false; - - AzureComputeTemplateOptions that = (AzureComputeTemplateOptions) o; - - if (networkSecurityGroupName != null ? !networkSecurityGroupName.equals(that.networkSecurityGroupName) : that.networkSecurityGroupName != null) - return false; - if (reservedIPName != null ? !reservedIPName.equals(that.reservedIPName) : that.reservedIPName != null) return false; - if (storageAccountName != null ? !storageAccountName.equals(that.storageAccountName) : that.storageAccountName != null) return false; - if (storageAccountType != null ? !storageAccountType.equals(that.storageAccountType) : that.storageAccountType != null) return false; - if (subnetNames != null ? !subnetNames.equals(that.subnetNames) : that.subnetNames != null) return false; - if (virtualNetworkName != null ? !virtualNetworkName.equals(that.virtualNetworkName) : that.virtualNetworkName != null) return false; - if (provisionGuestAgent != null ? !provisionGuestAgent.equals(that.provisionGuestAgent) : that.provisionGuestAgent != null) return false; - if (winrmUseHttps != null ? !winrmUseHttps.equals(that.winrmUseHttps) : that.winrmUseHttps != null) return false; - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (virtualNetworkName != null ? virtualNetworkName.hashCode() : 0); - result = 31 * result + (subnetNames != null ? subnetNames.hashCode() : 0); - result = 31 * result + (storageAccountName != null ? storageAccountName.hashCode() : 0); - result = 31 * result + (storageAccountType != null ? storageAccountType.hashCode() : 0); - result = 31 * result + (networkSecurityGroupName != null ? networkSecurityGroupName.hashCode() : 0); - result = 31 * result + (reservedIPName != null ? reservedIPName.hashCode() : 0); - result = 31 * result + (provisionGuestAgent != null ? provisionGuestAgent.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("virtualNetworkName", virtualNetworkName) - .add("subnetNames", subnetNames) - .add("storageAccountName", storageAccountName) - .add("storageAccountType", storageAccountType) - .add("networkSecurityGroupName", networkSecurityGroupName) - .add("reservedIPName", reservedIPName) - .add("provisionGuestAgent", provisionGuestAgent) - .toString(); - } - - public AzureComputeTemplateOptions virtualNetworkName(@Nullable String virtualNetworkName) { - this.virtualNetworkName = virtualNetworkName; - return this; - } - - public AzureComputeTemplateOptions subnetNames(Iterable<String> subnetNames) { - this.subnetNames = ImmutableList.copyOf(checkNotNull(subnetNames, "subnetNames")); - return this; - } - - public AzureComputeTemplateOptions subnetNames(String...subnetNames) { - return subnetNames(ImmutableList.copyOf(checkNotNull(subnetNames, "subnetNames"))); - } - - - public AzureComputeTemplateOptions networkSecurityGroupName(@Nullable String networkSecurityGroupName) { - this.networkSecurityGroupName = networkSecurityGroupName; - return this; - } - - public AzureComputeTemplateOptions storageAccountName(@Nullable String storageAccountName) { - this.storageAccountName = storageAccountName; - return this; - } - - public AzureComputeTemplateOptions storageAccountType(@Nullable String storageAccountType) { - this.storageAccountType = storageAccountType; - return this; - } - - public AzureComputeTemplateOptions reservedIPName(@Nullable String reservedIPName) { - this.reservedIPName = reservedIPName; - return this; - } - - public AzureComputeTemplateOptions provisionGuestAgent(@Nullable Boolean provisionGuestAgent) { - this.provisionGuestAgent = provisionGuestAgent; - return this; - } - - public AzureComputeTemplateOptions winrmUseHttps(@Nullable Boolean winrmUseHttps) { - this.winrmUseHttps = winrmUseHttps; - return this; - } - - public String getVirtualNetworkName() { - return virtualNetworkName; - } - - public List<String> getSubnetNames() { - return subnetNames; - } - - public String getStorageAccountName() { - return storageAccountName; - } - - public String getStorageAccountType() { - return storageAccountType; - } - - public String getNetworkSecurityGroupName() { - return networkSecurityGroupName; - } - - public String getReservedIPName() { - return reservedIPName; - } - - public Boolean getProvisionGuestAgent() { - return provisionGuestAgent; - } - - public Boolean getWinrmUseHttps() { - return winrmUseHttps; - } - - public static class Builder { - - /** - * @see #virtualNetworkName - */ - public static AzureComputeTemplateOptions virtualNetworkName(final String virtualNetworkName) { - final AzureComputeTemplateOptions options = new AzureComputeTemplateOptions(); - return options.virtualNetworkName(virtualNetworkName); - } - - /** - * @see #subnetNames - */ - public static AzureComputeTemplateOptions subnetNames(String...subnetNames) { - AzureComputeTemplateOptions options = new AzureComputeTemplateOptions(); - return options.subnetNames(subnetNames); - } - - /** - * @see #subnetNames - */ - public static AzureComputeTemplateOptions subnetNames(Iterable<String> subnetNames) { - AzureComputeTemplateOptions options = new AzureComputeTemplateOptions(); - return options.subnetNames(subnetNames); - } - - /** - * @see #storageAccountName - */ - public static AzureComputeTemplateOptions storageAccountName(final String storageAccountName) { - final AzureComputeTemplateOptions options = new AzureComputeTemplateOptions(); - return options.storageAccountName(storageAccountName); - } - - /** - * @see #storageAccountType - */ - public static AzureComputeTemplateOptions storageAccountType(final String storageAccountType) { - final AzureComputeTemplateOptions options = new AzureComputeTemplateOptions(); - return options.storageAccountType(storageAccountType); - } - - /** - * @see org.jclouds.compute.options.TemplateOptions#inboundPorts(int...) - */ - public static AzureComputeTemplateOptions inboundPorts(final int... ports) { - final AzureComputeTemplateOptions options = new AzureComputeTemplateOptions(); - return options.inboundPorts(ports); - } - - /** - * @see org.jclouds.compute.options.TemplateOptions#blockOnPort(int, int) - */ - public static AzureComputeTemplateOptions blockOnPort(final int port, final int seconds) { - final AzureComputeTemplateOptions options = new AzureComputeTemplateOptions(); - return options.blockOnPort(port, seconds); - } - - /** - * @see org.jclouds.compute.options.TemplateOptions#userMetadata(java.util.Map) - */ - public static AzureComputeTemplateOptions userMetadata(final Map<String, String> userMetadata) { - final AzureComputeTemplateOptions options = new AzureComputeTemplateOptions(); - return options.userMetadata(userMetadata); - } - - /** - * @see org.jclouds.compute.options.TemplateOptions#userMetadata(String, String) - */ - public static AzureComputeTemplateOptions userMetadata(final String key, final String value) { - final AzureComputeTemplateOptions options = new AzureComputeTemplateOptions(); - return options.userMetadata(key, value); - } - - /** - * @see org.jclouds.compute.options.TemplateOptions#nodeNames(Iterable) - */ - public static AzureComputeTemplateOptions nodeNames(final Iterable<String> nodeNames) { - final AzureComputeTemplateOptions options = new AzureComputeTemplateOptions(); - return options.nodeNames(nodeNames); - } - - /** - * @see org.jclouds.compute.options.TemplateOptions#networks(Iterable) - */ - public static AzureComputeTemplateOptions networks(final Iterable<String> networks) { - final AzureComputeTemplateOptions options = new AzureComputeTemplateOptions(); - return options.networks(networks); - } - } - - // methods that only facilitate returning the correct object type - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions blockOnPort(int port, int seconds) { - return AzureComputeTemplateOptions.class.cast(super.blockOnPort(port, seconds)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions inboundPorts(int... ports) { - return AzureComputeTemplateOptions.class.cast(super.inboundPorts(ports)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions authorizePublicKey(String publicKey) { - return AzureComputeTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions installPrivateKey(String privateKey) { - return AzureComputeTemplateOptions.class.cast(super.installPrivateKey(privateKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions blockUntilRunning(boolean blockUntilRunning) { - return AzureComputeTemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions dontAuthorizePublicKey() { - return AzureComputeTemplateOptions.class.cast(super.dontAuthorizePublicKey()); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions nameTask(String name) { - return AzureComputeTemplateOptions.class.cast(super.nameTask(name)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions runAsRoot(boolean runAsRoot) { - return AzureComputeTemplateOptions.class.cast(super.runAsRoot(runAsRoot)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions runScript(Statement script) { - return AzureComputeTemplateOptions.class.cast(super.runScript(script)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials) { - return AzureComputeTemplateOptions.class.cast(super.overrideLoginCredentials(overridingCredentials)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions overrideLoginPassword(String password) { - return AzureComputeTemplateOptions.class.cast(super.overrideLoginPassword(password)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions overrideLoginPrivateKey(String privateKey) { - return AzureComputeTemplateOptions.class.cast(super.overrideLoginPrivateKey(privateKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions overrideLoginUser(String loginUser) { - return AzureComputeTemplateOptions.class.cast(super.overrideLoginUser(loginUser)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) { - return AzureComputeTemplateOptions.class.cast(super.overrideAuthenticateSudo(authenticateSudo)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions userMetadata(Map<String, String> userMetadata) { - return AzureComputeTemplateOptions.class.cast(super.userMetadata(userMetadata)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions userMetadata(String key, String value) { - return AzureComputeTemplateOptions.class.cast(super.userMetadata(key, value)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions nodeNames(Iterable<String> nodeNames) { - return AzureComputeTemplateOptions.class.cast(super.nodeNames(nodeNames)); - } - - /** - * {@inheritDoc} - */ - @Override - public AzureComputeTemplateOptions networks(Iterable<String> networks) { - return AzureComputeTemplateOptions.class.cast(super.networks(networks)); - } - -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/compute/predicates/StorageServicePredicates.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/predicates/StorageServicePredicates.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/predicates/StorageServicePredicates.java deleted file mode 100644 index 4b8d3f2..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/predicates/StorageServicePredicates.java +++ /dev/null @@ -1,80 +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.compute.predicates; - -import static com.google.common.base.Preconditions.checkNotNull; -import static java.lang.String.format; - -import org.jclouds.azurecompute.domain.StorageService; - -import com.google.common.base.Predicate; - -/** - * Predicates for working with {@link StorageService} collections. - */ -public class StorageServicePredicates { - - - public static Predicate<StorageService> sameLocation(final String location) { - checkNotNull(location, "location must be defined"); - - return new Predicate<StorageService>() { - @Override - public boolean apply(StorageService storageService) { - return storageService.storageServiceProperties().location().equals(location); - } - - @Override - public String toString() { - return "sameLocation(" + location + ")"; - } - }; - } - - public static Predicate<StorageService> status(final StorageService.Status status) { - checkNotNull(status, "status must be defined"); - - return new Predicate<StorageService>() { - @Override - public boolean apply(StorageService storageService) { - return storageService.storageServiceProperties().status() == status; - } - - @Override - public String toString() { - return "status(" + status + ")"; - } - }; - } - - public static Predicate<StorageService> matchesName(final String defaultStorageAccountPrefix) { - checkNotNull(defaultStorageAccountPrefix, "defaultStorageAccountPrefix must be defined"); - - return new Predicate<StorageService>() { - @Override - public boolean apply(StorageService storageService) { - return storageService.serviceName().matches(format("^%s[a-z]{10}$", defaultStorageAccountPrefix)); - } - - @Override - public String toString() { - return "matchesName(" + defaultStorageAccountPrefix + ")"; - } - }; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/compute/strategy/GetOrCreateStorageServiceAndVirtualNetworkThenCreateNodes.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/strategy/GetOrCreateStorageServiceAndVirtualNetworkThenCreateNodes.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/strategy/GetOrCreateStorageServiceAndVirtualNetworkThenCreateNodes.java deleted file mode 100644 index 348b72d..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/strategy/GetOrCreateStorageServiceAndVirtualNetworkThenCreateNodes.java +++ /dev/null @@ -1,190 +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.compute.strategy; - -import static com.google.common.base.MoreObjects.firstNonNull; -import static com.google.common.base.Predicates.and; -import static com.google.common.base.Predicates.notNull; -import static com.google.common.collect.Iterables.tryFind; -import static java.lang.String.format; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.azurecompute.AzureComputeApi; -import org.jclouds.azurecompute.compute.config.AzureComputeServiceContextModule.AzureComputeConstants; -import org.jclouds.azurecompute.compute.options.AzureComputeTemplateOptions; -import org.jclouds.azurecompute.compute.predicates.StorageServicePredicates; -import org.jclouds.azurecompute.config.AzureComputeProperties; -import org.jclouds.azurecompute.domain.CreateStorageServiceParams; -import org.jclouds.azurecompute.domain.StorageService; -import org.jclouds.compute.config.CustomizationResponse; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; -import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory; -import org.jclouds.compute.strategy.ListNodesStrategy; -import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; - -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.inject.Inject; - -@Singleton -public class GetOrCreateStorageServiceAndVirtualNetworkThenCreateNodes - extends CreateNodesWithGroupEncodedIntoNameThenAddToSet { - - private static final String DEFAULT_STORAGE_ACCOUNT_PREFIX = "jclouds"; - private static final String DEFAULT_STORAGE_SERVICE_TYPE = "Standard_GRS"; - - private final AzureComputeApi api; - private final Predicate<String> operationSucceededPredicate; - private final AzureComputeConstants azureComputeConstants; - - @Inject - protected GetOrCreateStorageServiceAndVirtualNetworkThenCreateNodes( - CreateNodeWithGroupEncodedIntoName addNodeWithGroupStrategy, - ListNodesStrategy listNodesStrategy, - GroupNamingConvention.Factory namingConvention, - @Named("jclouds.user-threads") ListeningExecutorService userExecutor, - Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory, - AzureComputeApi api, - Predicate<String> operationSucceededPredicate, - AzureComputeConstants azureComputeConstants) { - - super(addNodeWithGroupStrategy, listNodesStrategy, namingConvention, userExecutor, - customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory); - - this.api = api; - this.operationSucceededPredicate = operationSucceededPredicate; - this.azureComputeConstants = azureComputeConstants; - } - - @Override - protected ListenableFuture<AtomicReference<NodeMetadata>> createNodeInGroupWithNameAndTemplate( - final String group, final String name, final Template template) { - - return super.createNodeInGroupWithNameAndTemplate(group, name, template); - } - - @Override - public Map<?, ListenableFuture<Void>> execute( - final String group, final int count, final Template template, - final Set<NodeMetadata> goodNodes, final Map<NodeMetadata, Exception> badNodes, - final Multimap<NodeMetadata, CustomizationResponse> customizationResponses) { - - final AzureComputeTemplateOptions templateOptions = template.getOptions().as(AzureComputeTemplateOptions.class); - final String location = template.getLocation().getId(); - final String storageAccountName = templateOptions.getStorageAccountName(); - final String storageAccountType = firstNonNull(templateOptions.getStorageAccountType(), DEFAULT_STORAGE_SERVICE_TYPE); - final String virtualNetworkName = templateOptions.getVirtualNetworkName(); - - final StorageService storageService; - if (storageAccountName != null) { - if (api.getStorageAccountApi().get(storageAccountName) == null) { - String message = String.format("storageAccountName %s specified via AzureComputeTemplateOptions doesn't exist", storageAccountName); - logger.error(message); - throw new IllegalStateException(message); - } - } else { // get suitable or create storage service - storageService = tryFindExistingStorageServiceAccountOrCreate(api, location, generateStorageServiceName(DEFAULT_STORAGE_ACCOUNT_PREFIX), storageAccountType); - templateOptions.storageAccountName(storageService.serviceName()); - } - - if (virtualNetworkName != null && templateOptions.getSubnetNames().isEmpty()) { - String message = "AzureComputeTemplateOption.subnetNames must not be empty, if AzureComputeTemplateOption.virtualNetworkName is defined."; - logger.warn(message); - throw new IllegalArgumentException(message); - } - - return super.execute(group, count, template, goodNodes, badNodes, customizationResponses); - } - - /** - * Tries to find a storage service account whose name matches the regex DEFAULT_STORAGE_ACCOUNT_PREFIX+"[a-z]{10}" in - * the location, otherwise it creates a new storage service account with name and type in the location - */ - private StorageService tryFindExistingStorageServiceAccountOrCreate( - final AzureComputeApi api, final String location, final String storageAccountName, final String type) { - - final List<StorageService> storageServices = api.getStorageAccountApi().list(); - logger.debug("Looking for a suitable existing storage account ..."); - - final Predicate<StorageService> storageServicePredicate = and( - notNull(), - StorageServicePredicates.sameLocation(location), - StorageServicePredicates.status(StorageService.Status.Created), - StorageServicePredicates.matchesName(DEFAULT_STORAGE_ACCOUNT_PREFIX) - ); - - final Optional<StorageService> storageServiceOptional = tryFind(storageServices, storageServicePredicate); - if (storageServiceOptional.isPresent()) { - final StorageService storageService = storageServiceOptional.get(); - logger.debug("Found a suitable existing storage service account '%s'", storageService); - return storageService; - } else { - // create - if (!checkAvailability(storageAccountName)) { - logger.warn("The storage service account name %s is not available", storageAccountName); - throw new IllegalStateException(format("Can't create a valid storage account with name %s. " - + "Please, try by choosing a different `storageAccountName` in templateOptions and try again", storageAccountName)); - } - logger.debug("Creating a storage service account '%s' in location '%s' ...", storageAccountName, location); - final String createStorageServiceRequestId = api.getStorageAccountApi().create( - CreateStorageServiceParams.builder() - .serviceName(storageAccountName) - .label(storageAccountName) - .location(location) - .accountType(StorageService.AccountType.valueOf(type)) - .build()); - if (!operationSucceededPredicate.apply(createStorageServiceRequestId)) { - final String warnMessage = format("Create storage service account has not been completed within %sms.", - azureComputeConstants.operationTimeout()); - logger.warn(warnMessage); - final String illegalStateExceptionMessage = format("%s. Please, try by increasing `%s` and try again", - warnMessage, AzureComputeProperties.OPERATION_TIMEOUT); - throw new IllegalStateException(illegalStateExceptionMessage); - } - return api.getStorageAccountApi().get(storageAccountName); - } - } - - private boolean checkAvailability(final String name) { - return api.getStorageAccountApi().isAvailable(name).result(); - } - - private static String generateStorageServiceName(final String prefix) { - String characters = "abcdefghijklmnopqrstuvwxyz"; - StringBuilder builder = new StringBuilder(); - builder.append(prefix); - int charactersLength = characters.length(); - for (int i = 0; i < 10; i++) { - double index = Math.random() * charactersLength; - builder.append(characters.charAt((int) index)); - } - return builder.toString(); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/compute/strategy/UseNodeCredentialsButOverrideFromTemplate.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/strategy/UseNodeCredentialsButOverrideFromTemplate.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/strategy/UseNodeCredentialsButOverrideFromTemplate.java deleted file mode 100644 index 8987dea..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/strategy/UseNodeCredentialsButOverrideFromTemplate.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.compute.strategy; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.options.RunScriptOptions; -import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; -import org.jclouds.domain.LoginCredentials; - -import com.google.common.base.Function; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -/** - * Azure needs the credentials to insert the node so the node credentials already take the Image credentials into - * account, as such only overriding the TemplateOptions credentials is required. - */ -@Singleton -public class UseNodeCredentialsButOverrideFromTemplate extends PrioritizeCredentialsFromTemplate { - - @Inject - public UseNodeCredentialsButOverrideFromTemplate( - Function<Template, LoginCredentials> credentialsFromImageOrTemplateOptions) { - - super(credentialsFromImageOrTemplateOptions); - } - - public LoginCredentials apply(final Template template, final LoginCredentials fromNode) { - final RunScriptOptions options = checkNotNull(template.getOptions(), "template options are required"); - final LoginCredentials.Builder builder = LoginCredentials.builder(fromNode); - if (options.getLoginUser() != null) { - builder.user(template.getOptions().getLoginUser()); - } - if (options.getLoginPassword() != null) { - builder.password(options.getLoginPassword()); - } - if (options.getLoginPrivateKey() != null) { - builder.privateKey(options.getLoginPrivateKey()); - } - if (options.shouldAuthenticateSudo() != null && options.shouldAuthenticateSudo()) { - builder.authenticateSudo(true); - } - return builder.build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java b/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java deleted file mode 100644 index 779de7f..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java +++ /dev/null @@ -1,64 +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.config; - -import javax.net.ssl.SSLContext; - -import org.jclouds.azurecompute.AzureComputeApi; -import org.jclouds.azurecompute.handlers.AzureComputeErrorHandler; -import org.jclouds.azurecompute.suppliers.DelegatingSSLContextSupplier; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.location.config.LocationModule; -import org.jclouds.location.suppliers.ImplicitLocationSupplier; -import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstRegionOptionallyMatchingRegionId; -import org.jclouds.rest.ConfiguresHttpApi; -import org.jclouds.rest.config.HttpApiModule; - -import com.google.common.base.Supplier; -import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; - -@ConfiguresHttpApi -public class AzureComputeHttpApiModule extends HttpApiModule<AzureComputeApi> { - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(AzureComputeErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(AzureComputeErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(AzureComputeErrorHandler.class); - } - - @Override - protected void installLocations() { - install(new LocationModule()); - bind(ImplicitLocationSupplier.class). - to(OnlyLocationOrFirstRegionOptionallyMatchingRegionId.class). - in(Scopes.SINGLETON); - } - - @Override - protected void configure() { - install(new AzureComputeParserModule()); - super.configure(); - bind(new TypeLiteral<Supplier<SSLContext>>() { - }).to(new TypeLiteral<DelegatingSSLContextSupplier>() { - }); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeParserModule.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeParserModule.java b/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeParserModule.java deleted file mode 100644 index f357ad4..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeParserModule.java +++ /dev/null @@ -1,29 +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.config; - -import org.jclouds.json.config.GsonModule; - -import com.google.inject.AbstractModule; - -public class AzureComputeParserModule extends AbstractModule { - - @Override - protected void configure() { - bind(GsonModule.DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeProperties.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeProperties.java b/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeProperties.java deleted file mode 100644 index 381e1b8..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeProperties.java +++ /dev/null @@ -1,36 +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.config; - -/** - * Configuration properties and constants used in Azure Service Management connections. - */ -public class AzureComputeProperties { - - public static final String OPERATION_TIMEOUT = "jclouds.azurecompute.operation.timeout"; - - public static final String OPERATION_POLL_INITIAL_PERIOD = "jclouds.azurecompute..operation.poll.initial.period"; - - public static final String OPERATION_POLL_MAX_PERIOD = "jclouds.azurecompute.operation.poll.max.period"; - - public static final String TCP_RULE_FORMAT = "jclouds.azurecompute.tcp.rule.format"; - - public static final String TCP_RULE_REGEXP = "jclouds.azurecompute.tcp.rule.regexp"; - - public static final String DEALLOCATE_WHEN_SUSPENDING = "jclouds.azurecompute.deallocate.when.suspending"; - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/domain/AffinityGroup.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/AffinityGroup.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/AffinityGroup.java deleted file mode 100644 index e4bb196..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/AffinityGroup.java +++ /dev/null @@ -1,104 +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.domain; - -import static com.google.common.collect.ImmutableList.copyOf; - -import java.util.List; - -import com.google.auto.value.AutoValue; -import java.util.Date; -import org.jclouds.javax.annotation.Nullable; - -@AutoValue -public abstract class AffinityGroup { - - public enum Capability { - - /** - * Enables an affinity group to support Virtual Machines. - */ - PersistentVMRole, - /** - * Enables the affinity group to support Virtual Machines that use high memory relative to the number of CPUs. - */ - HighMemory; - - } - - AffinityGroup() { - } // For AutoValue only! - - /** - * Specifies the name of the affinity group. - * - * @return the name of the affinity group - */ - public abstract String name(); - - /** - * Specifies the base-64-encoded identifier of the affinity group. - * - * @return the identifier of the affinity group - */ - public abstract String label(); - - /** - * Specified the description of this affinity group. - * - * @return the description of this affinity group - */ - @Nullable - public abstract String description(); - - /** - * Specifies the data center in which the affinity group is located. - * - * @return the data center in which the affinity group is located - */ - public abstract String location(); - - /** - * Specifies the capabilities that of the affinity group. - * - * @return the capabilities that of the affinity group - */ - public abstract List<Capability> capabilities(); - - /** - * Specifies in UTC format when the affinity group was created. - * - * @return when the affinity group was created (in UTC) - */ - public abstract Date createdTime(); - - /** - * Specifies the roles sizes that are available for deployments in the affinity group. - * - * @return the roles sizes that are available for deployments in the affinity group - */ - @Nullable - public abstract ComputeCapabilities computeCapabilities(); - - public static AffinityGroup create(final String name, final String label, final String description, - final String location, final List<Capability> capabilities, final Date createdTime, - final ComputeCapabilities computeCapabilities) { - - return new AutoValue_AffinityGroup(name, label, description, location, copyOf(capabilities), - createdTime, computeCapabilities); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Availability.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Availability.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Availability.java deleted file mode 100644 index c770b9e..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Availability.java +++ /dev/null @@ -1,38 +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.domain; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Availability { - - Availability() { - } // For AutoValue only! - - public abstract Boolean result(); - - @Nullable - public abstract String reason(); - - public static Availability create(final Boolean result, final String reason) { - return new AutoValue_Availability(result, reason); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CaptureVMImageParams.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CaptureVMImageParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CaptureVMImageParams.java deleted file mode 100644 index a68625e..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CaptureVMImageParams.java +++ /dev/null @@ -1,117 +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.domain; - -import com.google.auto.value.AutoValue; -import org.jclouds.javax.annotation.Nullable; - -/** - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn499768.aspx" >api</a> - */ -@AutoValue -public abstract class CaptureVMImageParams { - - public abstract VMImage.OSDiskConfiguration.OSState osState(); - - public abstract String name(); - - public abstract String label(); - - @Nullable public abstract String description(); - - @Nullable public abstract String language(); - - @Nullable public abstract String imageFamily(); - - @Nullable public abstract RoleSize.Type recommendedVMSize(); - - public Builder toBuilder() { - return builder().fromVMImageParams(this); - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private VMImage.OSDiskConfiguration.OSState osState; - private String name; - private String label; - private String description; - private String language; - private String imageFamily; - private RoleSize.Type recommendedVMSize; - - public Builder osState(VMImage.OSDiskConfiguration.OSState osState) { - this.osState = osState; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder label(String label) { - this.label = label; - return this; - } - - public Builder description(String description) { - this.description = description; - return this; - } - - public Builder language(String language) { - this.language = language; - return this; - } - - public Builder imageFamily(String imageFamily) { - this.imageFamily = imageFamily; - return this; - } - - public Builder recommendedVMSize(RoleSize.Type recommendedRoleSize) { - this.recommendedVMSize = recommendedRoleSize; - return this; - } - - public Builder fromVMImageParams(CaptureVMImageParams in) { - return name(in.name()) - .label(in.label()) - .osState(in.osState()) - .description(in.description()) - .language(in.language()) - .imageFamily(in.imageFamily()) - .recommendedVMSize(in.recommendedVMSize()); - - } - - public CaptureVMImageParams build() { - return CaptureVMImageParams.create(osState, name, label, description, language, - imageFamily, recommendedVMSize); - } - - } - - public static CaptureVMImageParams create(VMImage.OSDiskConfiguration.OSState osState, String name, String label, - String description, String language, String imageFamily, RoleSize.Type recommendedVMSize) { - return new AutoValue_CaptureVMImageParams(osState, name, label, description, language, imageFamily, - recommendedVMSize); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java deleted file mode 100644 index 561c679..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java +++ /dev/null @@ -1,117 +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.domain; - -import static com.google.common.collect.ImmutableMap.copyOf; -import java.util.Date; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.auto.value.AutoValue; - -/** - * System properties for the specified cloud service. These properties include the service name and service type; the - * name of the affinity group to which the service belongs, or its location if it is not part of an affinity group. - * - * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >CloudService</a> - */ -@AutoValue -public abstract class CloudService { - - public enum Status { - - CREATING, - CREATED, - DELETING, - DELETED, - CHANGING, - RESOLVING_DNS, - UNRECOGNIZED; - - public static Status fromString(final String text) { - if (text != null) { - for (Status status : Status.values()) { - if (text.equalsIgnoreCase(status.name())) { - return status; - } - } - } - return UNRECOGNIZED; - } - } - - CloudService() { - } // For AutoValue only! - - /** - * The name of the cloud service. This name is the DNS prefix name and can be used to access the cloud service. - * - * <p/> - * For example, if the service name is MyService you could access the access the service by calling: - * http://MyService.cloudapp.net - */ - public abstract String name(); - - /** - * The geo-location of the cloud service in Windows Azure, if the cloud service is not associated with an affinity - * group. If a location has been specified, the AffinityGroup element is not returned. - */ - @Nullable - public abstract String location(); - - /** - * The affinity group with which this cloud service is associated, if any. If the service is associated with an - * affinity group, the Location element is not returned. - */ - @Nullable - public abstract String affinityGroup(); - - /** - * The name can be up to 100 characters in length. The name can be used identify the storage account for your - * tracking purposes. - */ - public abstract String label(); - - @Nullable - public abstract String description(); - - public abstract Status status(); - - public abstract Date created(); - - public abstract Date lastModified(); - - /** - * Represents the name of an extended cloud service property. Each extended property must have both a defined name - * and value. You can have a maximum of 50 extended property name/value pairs. - * - * <p/> - * The maximum length of the Name element is 64 characters, only alphanumeric characters and underscores are valid in - * the Name, and the name must start with a letter. Each extended property value has a maximum length of 255 - * characters. - */ - public abstract Map<String, String> extendedProperties(); - - public static CloudService create(final String name, final String location, final String affinityGroup, - final String label, final String description, final Status status, final Date created, - final Date lastModified, final Map<String, String> extendedProperties) { - - return new AutoValue_CloudService(name, location, affinityGroup, label, description, status, created, - lastModified, copyOf(extendedProperties)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudServiceProperties.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudServiceProperties.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudServiceProperties.java deleted file mode 100644 index a363b83..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudServiceProperties.java +++ /dev/null @@ -1,96 +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.domain; - -import com.google.auto.value.AutoValue; -import org.jclouds.javax.annotation.Nullable; - -import java.net.URI; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import static com.google.common.collect.ImmutableMap.copyOf; -import static com.google.common.collect.ImmutableList.copyOf; - -/** - * System properties for the specified cloud service. These properties include the service name and - * service type; the name of the affinity group to which the service belongs, or its location if it - * is not part of an affinity group. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/ee460806.aspx" >CloudService</a> - */ -@AutoValue -public abstract class CloudServiceProperties { - - public enum Status { - CREATING, CREATED, DELETING, DELETED, CHANGING, RESOLVING_DNS, - UNRECOGNIZED; - } - - CloudServiceProperties() { - } // For AutoValue only! - - /** - * The name of the cloud service. This name is the DNS prefix name and can be used to access the - * cloud service. - * <p/> - * <p/>For example, if the service name is MyService you could access the access the service by - * calling: http://MyService.cloudapp.net - */ - public abstract String serviceName(); - - public abstract URI url(); - - /** - * The geo-location of the cloud service in Windows Azure, if the cloud service is not - * associated with an affinity group. If a location has been specified, the AffinityGroup element - * is not returned. - */ - @Nullable public abstract String location(); - - /** - * The affinity group with which this cloud service is associated, if any. If the service is - * associated with an affinity group, the Location element is not returned. - */ - @Nullable public abstract String affinityGroup(); - - /** - * The name can be up to 100 characters in length. The name can be used identify the storage account for your - * tracking purposes. - */ - public abstract String label(); - - @Nullable public abstract String description(); - - @Nullable public abstract Status status(); - - @Nullable public abstract Date created(); - - @Nullable public abstract Date lastModified(); - - public abstract Map<String, String> extendedProperties(); - - public abstract List<Deployment> deployments(); - - public static CloudServiceProperties create(String name, URI url, String location, String affinityGroup, - String label, String description, Status status, Date created, Date lastModified, Map<String, String> extendedProperties, - List<Deployment> deployments) { - return new AutoValue_CloudServiceProperties(name, url, location, affinityGroup, label, description, status, - created, lastModified, copyOf(extendedProperties), copyOf(deployments)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ComputeCapabilities.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ComputeCapabilities.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ComputeCapabilities.java deleted file mode 100644 index 4c5eba9..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ComputeCapabilities.java +++ /dev/null @@ -1,56 +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.domain; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; -import java.util.List; - -/** - * Shared by {@link Location} and {@link AffinityGroup}. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/gg441293#bk_computecapabilities">docs</a> - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/ee460797.aspx#bk_computecapabilities">docs</a> - */ -@AutoValue -public abstract class ComputeCapabilities { - - ComputeCapabilities() { - } // For AutoValue only! - - /** - * Specifies the role size that is available for the type of deployment. - * - * @return the role size that is available for the type of deployment - */ - public abstract List<RoleSize.Type> virtualMachineRoleSizes(); - - /** - * Specifies the role size that is available for the type of deployment. - * - * @return the role size that is available for the type of deployment - */ - public abstract List<RoleSize.Type> webWorkerRoleSizes(); - - public static ComputeCapabilities create( - final List<RoleSize.Type> virtualMachineRoleSizes, final List<RoleSize.Type> webWorkerRoleSizes) { - - return new AutoValue_ComputeCapabilities( - ImmutableList.copyOf(virtualMachineRoleSizes), ImmutableList.copyOf(webWorkerRoleSizes)); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateAffinityGroupParams.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateAffinityGroupParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateAffinityGroupParams.java deleted file mode 100644 index 57e853c..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateAffinityGroupParams.java +++ /dev/null @@ -1,115 +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.domain; - -import com.google.auto.value.AutoValue; -import org.jclouds.javax.annotation.Nullable; - -/** - * To create a new affinity group. - */ -@AutoValue -public abstract class CreateAffinityGroupParams { - - CreateAffinityGroupParams() { - } // For AutoValue only! - - /** - * Specifies the name of the affinity group. - * - * @return the name of the affinity group - */ - public abstract String name(); - - /** - * Specifies the base-64-encoded identifier of the affinity group. - * - * @return the identifier of the affinity group - */ - public abstract String label(); - - /** - * Specified the description of this affinity group. - * - * @return the description of this affinity group - */ - @Nullable - public abstract String description(); - - /** - * Specifies the data center in which the affinity group is located. - * - * @return the data center in which the affinity group is located - */ - public abstract String location(); - - public Builder toBuilder() { - return builder().fromAffinityGroupParams(this); - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - - private String name; - - private String label; - - private String description; - - private String location; - - public Builder name(final String name) { - this.name = name; - return this; - } - - public Builder label(final String label) { - this.label = label; - return this; - } - - public Builder description(final String description) { - this.description = description; - return this; - } - - public Builder location(final String location) { - this.location = location; - return this; - } - - public CreateAffinityGroupParams build() { - return CreateAffinityGroupParams.create(name, label, description, location); - } - - public Builder fromAffinityGroupParams(final CreateAffinityGroupParams in) { - return name(in.name()) - .label(in.label()) - .description(in.description()) - .location(in.location()); - } - } - - private static CreateAffinityGroupParams create( - final String name, final String label, final String description, final String location) { - - return new AutoValue_CreateAffinityGroupParams(name, label, description, location); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateProfileParams.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateProfileParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateProfileParams.java deleted file mode 100644 index 0f2a9a3..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateProfileParams.java +++ /dev/null @@ -1,91 +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.domain; - -import com.google.auto.value.AutoValue; - -/** - * The Create Profile operation creates a new profile for a domain name, owned by the specified subscription. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/hh758254.aspx">docs</a> - */ -@AutoValue -public abstract class CreateProfileParams { - - CreateProfileParams() { - } // For AutoValue only! - - /** - * Specifies the name of the domain that the profile is being created for. - * - * A valid DNS name of the form <subdomain name>.trafficmanager.net, conforming to RFC 1123 specification. - * - * Total length of the domain name must be less than or equal to 253 characters. The <subdomain name> can - * contain periods and each label within the subdomain must be less or equal to 63 characters. - * - * @return profile domain name. - */ - public abstract String domain(); - - /** - * Specifies the name of the profile. - * - * The name must be composed of letters, numbers, and hyphens. The maximum length of the profile name is 256 - * characters. Hyphens cannot be the first or last character. - * - * @return profile name.. - */ - public abstract String name(); - - public Builder toBuilder() { - return builder().fromImageParams(this); - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - - private String domain; - private String name; - - public Builder domain(final String domain) { - this.domain = domain; - return this; - } - - public Builder name(final String name) { - this.name = name; - return this; - } - - public CreateProfileParams build() { - return CreateProfileParams.create(domain, name); - } - - public Builder fromImageParams(final CreateProfileParams in) { - return domain(in.domain()).name(in.name()); - } - } - - private static CreateProfileParams create( - final String domain, - final String name) { - return new AutoValue_CreateProfileParams(domain, name); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateStorageServiceParams.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateStorageServiceParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateStorageServiceParams.java deleted file mode 100644 index 64bd9c3..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateStorageServiceParams.java +++ /dev/null @@ -1,161 +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.domain; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableMap; -import java.util.Map; -import org.jclouds.azurecompute.domain.StorageService.AccountType; -import org.jclouds.javax.annotation.Nullable; - -@AutoValue -public abstract class CreateStorageServiceParams { - - CreateStorageServiceParams() { - } // For AutoValue only! - - /** - * A name for the storage account that is unique within Azure. Storage account names must be between 3 and 24 - * characters in length and use numbers and lower-case letters only. - */ - public abstract String serviceName(); - - /** - * A description for the storage account. The description may be up to 1024 characters in length. - */ - @Nullable - public abstract String description(); - - /** - * A label for the storage account specified as a base64-encoded string. The label may be up to 100 characters in - * length. The label can be used identify the storage account for your tracking purposes. - */ - public abstract String label(); - - /** - * Required if AffinityGroup is not specified. The location where the storage account is created. - */ - @Nullable - public abstract String location(); - - /** - * Required if Location is not specified. The name of an existing affinity group in the specified subscription. - */ - @Nullable - public abstract String affinityGroup(); - - /** - * Represents the name of an extended cloud service property. Each extended property must have both a defined name - * and value. You can have a maximum of 50 extended property name/value pairs. - * - * <p/> - * The maximum length of the Name element is 64 characters, only alphanumeric characters and underscores are valid in - * the Name, and the name must start with a letter. Each extended property value has a maximum length of 255 - * characters. - */ - @Nullable - public abstract Map<String, String> extendedProperties(); - - /** - * Specifies whether the account supports locally-redundant storage, geo-redundant storage, zone-redundant storage, - * or read access geo-redundant storage. - */ - public abstract AccountType accountType(); - - public Builder toBuilder() { - return builder().fromCreateStorageServiceParams(this); - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - - private String serviceName; - - private String description; - - private String label; - - private String location; - - private String affinityGroup; - - private Map<String, String> extendedProperties; - - private AccountType accountType; - - public Builder serviceName(final String serviceName) { - this.serviceName = serviceName; - return this; - } - - public Builder description(final String description) { - this.description = description; - return this; - } - - public Builder label(final String label) { - this.label = label; - return this; - } - - public Builder location(final String location) { - this.location = location; - return this; - } - - public Builder affinityGroup(final String affinityGroup) { - this.affinityGroup = affinityGroup; - return this; - } - - public Builder extendedProperties(final Map<String, String> extendedProperties) { - this.extendedProperties = extendedProperties; - return this; - } - - public Builder accountType(final AccountType accountType) { - this.accountType = accountType; - return this; - } - - public CreateStorageServiceParams build() { - return CreateStorageServiceParams.create(serviceName, description, label, location, affinityGroup, - extendedProperties, accountType); - } - - public Builder fromCreateStorageServiceParams(final CreateStorageServiceParams storageServiceParams) { - return serviceName(storageServiceParams.serviceName()). - description(storageServiceParams.description()). - label(storageServiceParams.label()). - location(storageServiceParams.location()). - affinityGroup(storageServiceParams.affinityGroup()). - extendedProperties(storageServiceParams.extendedProperties()). - accountType(storageServiceParams.accountType()); - } - } - - private static CreateStorageServiceParams create( - final String serviceName, final String description, final String label, final String location, - final String affinityGroup, final Map<String, String> extendedProperties, final AccountType accountType) { - - return new AutoValue_CreateStorageServiceParams(serviceName, description, label, location, affinityGroup, - extendedProperties == null ? null : ImmutableMap.copyOf(extendedProperties), accountType); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b8ab3758/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DataVirtualHardDisk.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DataVirtualHardDisk.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DataVirtualHardDisk.java deleted file mode 100644 index cf482a7..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DataVirtualHardDisk.java +++ /dev/null @@ -1,108 +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.domain; - -import com.google.auto.value.AutoValue; -import org.jclouds.javax.annotation.Nullable; - -import java.net.URI; - -/** - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/jj157193.aspx#DataVirtualHardDisks" >api</a> - */ -@AutoValue -public abstract class DataVirtualHardDisk { - - public enum Caching { - - READ_ONLY, - READ_WRITE, - NONE; - - public static Caching fromString(final String text) { - if (text != null) { - for (Caching caching : Caching.values()) { - if (text.equalsIgnoreCase(caching.name())) { - return caching; - } - } - } - return NONE; - } - - } - - /** - * Specifies the caching mode of the operating system disk. This setting impacts the consistency and performance of - * the disk. Possible values are: ReadOnly ReadWrite The default value is ReadWrite - */ - @Nullable - public abstract Caching hostCaching(); - - /** - * Required if an existing disk is being used to create a Virtual Machine. Specifies the name of a new or existing - * disk - */ - @Nullable - public abstract String diskName(); - - /** - * Specifies the Logical Unit Number (LUN) for the data disk. If the disk is the first disk that is added, this - * element is optional and the default value of 0 is used. If more than one disk is being added, this element is - * required. - * <p/> - * You can use Get Role to find the LUN numbers that are already being used. Valid LUN values are 0 through 31 - */ - @Nullable - public abstract Integer lun(); - - /** - * Specifies the size, in GB, of an empty disk to be attached to the Virtual Machine.If the disk that is being added - * is already registered in the subscription, this element is ignored.If the disk and VHD is being created by Azure - * as it is added, this element defines the size of the new disk. - * <p/> - * The number of disks that can be added to a Virtual Machine is limited by the size of the machine. - * <p/> - * This element is used with the MediaLink element. - */ - @Nullable - public abstract Integer logicalDiskSizeInGB(); - - /** - * If the disk that is being added is already registered in the subscription or the VHD for the disk already exists - * in blob storage, this element is ignored. If a VHD file does not exist in blob storage, this element defines the - * location of the new VHD that is created when the new disk is added. Example: - * http://example.blob.core.windows.net/disks/mydatadisk.vhd - */ - @Nullable - public abstract URI mediaLink(); - - /** - * This property identifies the type of the storage account for the backing VHD. If the backing VHD is in an - * Provisioned Storage account, âProvisionedâ is returned otherwise âStandardâ is returned. - * <p/> - * This property is only returned with a version header of 2014-10-01 or newer - */ - @Nullable - public abstract String ioType(); - - public static DataVirtualHardDisk create(final Caching hostCaching, final String diskName, - final Integer lun, final Integer logicalDiskSizeInGB, final URI mediaLink, final String ioType) { - - return new AutoValue_DataVirtualHardDisk(hostCaching, diskName, lun, logicalDiskSizeInGB, mediaLink, ioType); - } -}
