You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2014/09/06 17:54:59 UTC
[42/51] [partial] merging master branch to 4.0.0-grouping - 6th Sept
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java
deleted file mode 100644
index 9a81a94..0000000
--- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java
+++ /dev/null
@@ -1,331 +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.ec2.compute;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Strings.emptyToNull;
-import static com.google.common.collect.Iterables.concat;
-import static com.google.common.collect.Iterables.transform;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_DELIMITER;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
-import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
-import static org.jclouds.compute.util.ComputeServiceUtils.addMetadataAndParseTagsFromValuesOfEmptyString;
-import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsValuesOfEmptyString;
-import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_GENERATE_INSTANCE_NAMES;
-import static org.jclouds.ec2.util.Tags.resourceToTagsAsMap;
-import static org.jclouds.util.Predicates2.retry;
-
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.inject.Named;
-import javax.inject.Provider;
-import javax.inject.Singleton;
-
-import org.jclouds.Constants;
-import org.jclouds.aws.util.AWSUtils;
-import org.jclouds.collect.Memoized;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.RunNodesException;
-import org.jclouds.compute.callables.RunScriptOnNode;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadataBuilder;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.domain.TemplateBuilder;
-import org.jclouds.compute.extensions.ImageExtension;
-import org.jclouds.compute.extensions.SecurityGroupExtension;
-import org.jclouds.compute.functions.GroupNamingConvention;
-import org.jclouds.compute.functions.GroupNamingConvention.Factory;
-import org.jclouds.compute.internal.BaseComputeService;
-import org.jclouds.compute.internal.PersistNodeCredentials;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
-import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
-import org.jclouds.compute.strategy.DestroyNodeStrategy;
-import org.jclouds.compute.strategy.GetImageStrategy;
-import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
-import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap;
-import org.jclouds.compute.strategy.ListNodesStrategy;
-import org.jclouds.compute.strategy.RebootNodeStrategy;
-import org.jclouds.compute.strategy.ResumeNodeStrategy;
-import org.jclouds.compute.strategy.SuspendNodeStrategy;
-import org.jclouds.domain.Credentials;
-import org.jclouds.domain.Location;
-import org.jclouds.ec2.EC2Api;
-import org.jclouds.ec2.compute.domain.RegionAndName;
-import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules;
-import org.jclouds.ec2.compute.options.EC2TemplateOptions;
-import org.jclouds.ec2.domain.InstanceState;
-import org.jclouds.ec2.domain.KeyPair;
-import org.jclouds.ec2.domain.RunningInstance;
-import org.jclouds.ec2.domain.Tag;
-import org.jclouds.ec2.util.TagFilterBuilder;
-import org.jclouds.scriptbuilder.functions.InitAdminAccess;
-import org.jclouds.util.Strings2;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableMultimap.Builder;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Multimap;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.inject.Inject;
-
-/**
- * @author Adrian Cole
- */
-@Singleton
-public class EC2ComputeService extends BaseComputeService {
- private final EC2Api client;
- private final ConcurrentMap<RegionAndName, KeyPair> credentialsMap;
- private final LoadingCache<RegionAndName, String> securityGroupMap;
- private final Factory namingConvention;
- private final boolean generateInstanceNames;
-
- @Inject
- protected EC2ComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
- @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
- @Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
- GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
- CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
- DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy,
- SuspendNodeStrategy stopNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
- @Named("DEFAULT") Provider<TemplateOptions> templateOptionsProvider,
- @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
- @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
- @Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
- InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
- RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
- PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
- @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, EC2Api client,
- ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
- @Named("SECURITY") LoadingCache<RegionAndName, String> securityGroupMap,
- Optional<ImageExtension> imageExtension, GroupNamingConvention.Factory namingConvention,
- @Named(PROPERTY_EC2_GENERATE_INSTANCE_NAMES) boolean generateInstanceNames,
- Optional<SecurityGroupExtension> securityGroupExtension) {
- super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
- getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
- startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
- nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory,
- persistNodeCredentials, timeouts, userExecutor, imageExtension, securityGroupExtension);
- this.client = client;
- this.credentialsMap = credentialsMap;
- this.securityGroupMap = securityGroupMap;
- this.namingConvention = namingConvention;
- this.generateInstanceNames = generateInstanceNames;
- }
-
- @Override
- public Set<? extends NodeMetadata> createNodesInGroup(String group, int count, final Template template)
- throws RunNodesException {
- Set<? extends NodeMetadata> nodes = super.createNodesInGroup(group, count, template);
- String region = AWSUtils.getRegionFromLocationOrNull(template.getLocation());
-
- if (client.getTagApiForRegion(region).isPresent()) {
- Map<String, String> common = metadataAndTagsAsValuesOfEmptyString(template.getOptions());
- if (generateInstanceNames || !common.isEmpty() || !template.getOptions().getNodeNames().isEmpty()) {
- return addTagsAndNamesToInstancesInRegion(common, template.getOptions().getNodeNames(),
- nodes, region, group);
- }
- }
- return nodes;
- }
-
- private static final Function<NodeMetadata, String> instanceId = new Function<NodeMetadata, String>() {
- @Override
- public String apply(NodeMetadata in) {
- return in.getProviderId();
- }
- };
-
- private Set<NodeMetadata> addTagsAndNamesToInstancesInRegion(Map<String, String> common, Set<String> nodeNames,
- Set<? extends NodeMetadata> input, String region,
- String group) {
- Map<String, ? extends NodeMetadata> instancesById = Maps.uniqueIndex(input, instanceId);
- ImmutableSet.Builder<NodeMetadata> builder = ImmutableSet.<NodeMetadata> builder();
-
- if (generateInstanceNames && !common.containsKey("Name")) {
- for (Map.Entry<String, ? extends NodeMetadata> entry : instancesById.entrySet()) {
- String id = entry.getKey();
- String name;
- if (!nodeNames.isEmpty()) {
- name = Iterables.get(nodeNames, 0);
- } else {
- name = id.replaceAll(".*-", group + "-");
- }
- Map<String, String> tags = ImmutableMap.<String, String> builder().putAll(common)
- .put("Name", name).build();
- logger.debug(">> applying tags %s to instance %s in region %s", tags, id, region);
- client.getTagApiForRegion(region).get().applyToResources(tags, ImmutableSet.of(id));
- builder.add(addTagsForInstance(tags, instancesById.get(id)));
- }
- } else {
- Iterable<String> ids = instancesById.keySet();
- logger.debug(">> applying tags %s to instances %s in region %s", common, ids, region);
- client.getTagApiForRegion(region).get().applyToResources(common, ids);
- for (NodeMetadata in : input)
- builder.add(addTagsForInstance(common, in));
- }
- if (logger.isDebugEnabled()) {
- Multimap<String, String> filter = new TagFilterBuilder().resourceIds(instancesById.keySet()).build();
- FluentIterable<Tag> tags = client.getTagApiForRegion(region).get().filter(filter);
- logger.debug("<< applied tags in region %s: %s", region, resourceToTagsAsMap(tags));
- }
- return builder.build();
- }
-
- private static NodeMetadata addTagsForInstance(Map<String, String> tags, NodeMetadata input) {
- NodeMetadataBuilder builder = NodeMetadataBuilder.fromNodeMetadata(input).name(tags.get("Name"));
- return addMetadataAndParseTagsFromValuesOfEmptyString(builder, tags).build();
- }
-
- @Inject(optional = true)
- @Named(RESOURCENAME_DELIMITER)
- char delimiter = '#';
-
- /**
- * @throws IllegalStateException If the security group was in use
- */
- @VisibleForTesting
- void deleteSecurityGroup(String region, String group) {
- checkNotNull(emptyToNull(region), "region must be defined");
- checkNotNull(emptyToNull(group), "group must be defined");
- String groupName = namingConvention.create().sharedNameForGroup(group);
-
- if (client.getSecurityGroupApi().get().describeSecurityGroupsInRegion(region, groupName).size() > 0) {
- logger.debug(">> deleting securityGroup(%s)", groupName);
- client.getSecurityGroupApi().get().deleteSecurityGroupInRegion(region, groupName);
- // TODO: test this clear happens
- securityGroupMap.invalidate(new RegionNameAndIngressRules(region, groupName, null, false));
- logger.debug("<< deleted securityGroup(%s)", groupName);
- }
- }
-
- @VisibleForTesting
- void deleteKeyPair(String region, String group) {
- for (KeyPair keyPair : client.getKeyPairApi().get().describeKeyPairsInRegionWithFilter(region,
- ImmutableMultimap.<String, String>builder()
- .put("key-name", Strings2.urlEncode(
- String.format("jclouds#%s#%s*", group, region).replace('#', delimiter)))
- .build())) {
- String keyName = keyPair.getKeyName();
- Predicate<String> keyNameMatcher = namingConvention.create().containsGroup(group);
- String oldKeyNameRegex = String.format("jclouds#%s#%s#%s", group, region, "[0-9a-f]+").replace('#', delimiter);
- // old keypair pattern too verbose as it has an unnecessary region qualifier
-
- if (keyNameMatcher.apply(keyName) || keyName.matches(oldKeyNameRegex)) {
- Set<String> instancesUsingKeyPair = extractIdsFromInstances(concat(client.getInstanceApi().get()
- .describeInstancesInRegionWithFilter(region, ImmutableMultimap.<String, String>builder()
- .put("instance-state-name", InstanceState.TERMINATED.toString())
- .put("instance-state-name", InstanceState.SHUTTING_DOWN.toString())
- .put("key-name", keyPair.getKeyName()).build())));
-
- if (instancesUsingKeyPair.size() > 0) {
- logger.debug("<< inUse keyPair(%s), by (%s)", keyPair.getKeyName(), instancesUsingKeyPair);
- } else {
- logger.debug(">> deleting keyPair(%s)", keyPair.getKeyName());
- client.getKeyPairApi().get().deleteKeyPairInRegion(region, keyPair.getKeyName());
- // TODO: test this clear happens
- credentialsMap.remove(new RegionAndName(region, keyPair.getKeyName()));
- credentialsMap.remove(new RegionAndName(region, group));
- logger.debug("<< deleted keyPair(%s)", keyPair.getKeyName());
- }
- }
- }
- }
-
- protected ImmutableSet<String> extractIdsFromInstances(Iterable<? extends RunningInstance> deadOnes) {
- return ImmutableSet.copyOf(transform(deadOnes, new Function<RunningInstance, String>() {
-
- @Override
- public String apply(RunningInstance input) {
- return input.getId();
- }
-
- }));
- }
-
- /**
- * Cleans implicit keypairs and security groups.
- */
- @Override
- protected void cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes) {
- Builder<String, String> regionGroups = ImmutableMultimap.builder();
- for (NodeMetadata nodeMetadata : deadNodes) {
- if (nodeMetadata.getGroup() != null)
- regionGroups.put(AWSUtils.parseHandle(nodeMetadata.getId())[0], nodeMetadata.getGroup());
- }
- for (Entry<String, String> regionGroup : regionGroups.build().entries()) {
- cleanUpIncidentalResources(regionGroup.getKey(), regionGroup.getValue());
- }
- }
-
- protected void cleanUpIncidentalResources(final String region, final String group) {
- // For issue #445, tries to delete security groups first: ec2 throws exception if in use, but
- // deleting a key pair does not.
- // This is "belt-and-braces" because deleteKeyPair also does extractIdsFromInstances & usingKeyPairAndNotDead
- // for us to check if any instances are using the key-pair before we delete it.
- // There is (probably?) still a race if someone is creating instances at the same time as deleting them:
- // we may delete the key-pair just when the node-being-created was about to rely on the incidental
- // resources existing.
-
- // Also in #445, in aws-ec2 the deleteSecurityGroup sometimes fails after terminating the final VM using a
- // given security group, if called very soon after the VM's state reports terminated. Empirically, it seems that
- // waiting a small time (e.g. enabling logging or debugging!) then the tests pass. We therefore retry.
- // TODO: this could be moved to a config module, also the narrative above made more concise
- retry(new Predicate<RegionAndName>() {
- public boolean apply(RegionAndName input) {
- try {
- logger.debug(">> deleting incidentalResources(%s)", input);
- deleteSecurityGroup(input.getRegion(), input.getName());
- deleteKeyPair(input.getRegion(), input.getName()); // not executed if securityGroup was in use
- logger.debug("<< deleted incidentalResources(%s)", input);
- return true;
- } catch (IllegalStateException e) {
- logger.debug("<< inUse incidentalResources(%s)", input);
- return false;
- }
- }
- }, SECONDS.toMillis(3), 50, 1000, MILLISECONDS).apply(new RegionAndName(region, group));
- }
-
- /**
- * returns template options, except of type {@link EC2TemplateOptions}.
- */
- @Override
- public EC2TemplateOptions templateOptions() {
- return EC2TemplateOptions.class.cast(super.templateOptions());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java
deleted file mode 100644
index 76473c6..0000000
--- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java
+++ /dev/null
@@ -1,32 +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.ec2.compute;
-
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.ec2.compute.internal.EC2ComputeServiceContextImpl;
-
-import com.google.inject.ImplementedBy;
-
-/**
- * @author Adrian Cole
- */
-@ImplementedBy(EC2ComputeServiceContextImpl.class)
-public interface EC2ComputeServiceContext extends ComputeServiceContext {
-
- @Override
- EC2ComputeService getComputeService();
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java
deleted file mode 100644
index 6fd1ca5..0000000
--- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java
+++ /dev/null
@@ -1,97 +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.ec2.compute.config;
-
-import org.jclouds.compute.config.BindComputeStrategiesByClass;
-import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
-import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
-import org.jclouds.compute.strategy.DestroyNodeStrategy;
-import org.jclouds.compute.strategy.GetImageStrategy;
-import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
-import org.jclouds.compute.strategy.ListNodesStrategy;
-import org.jclouds.compute.strategy.RebootNodeStrategy;
-import org.jclouds.compute.strategy.ResumeNodeStrategy;
-import org.jclouds.compute.strategy.SuspendNodeStrategy;
-import org.jclouds.ec2.compute.strategy.EC2CreateNodesInGroupThenAddToSet;
-import org.jclouds.ec2.compute.strategy.EC2DestroyNodeStrategy;
-import org.jclouds.ec2.compute.strategy.EC2GetImageStrategy;
-import org.jclouds.ec2.compute.strategy.EC2GetNodeMetadataStrategy;
-import org.jclouds.ec2.compute.strategy.EC2ListNodesStrategy;
-import org.jclouds.ec2.compute.strategy.EC2RebootNodeStrategy;
-import org.jclouds.ec2.compute.strategy.EC2ResumeNodeStrategy;
-import org.jclouds.ec2.compute.strategy.EC2SuspendNodeStrategy;
-
-/**
- * @author Adrian Cole
- */
-public class EC2BindComputeStrategiesByClass extends BindComputeStrategiesByClass {
- @Override
- protected Class<? extends CreateNodesInGroupThenAddToSet> defineRunNodesAndAddToSetStrategy() {
- return EC2CreateNodesInGroupThenAddToSet.class;
- }
-
- /**
- * not needed, as {@link EC2CreateNodesInGroupThenAddToSet} is used and is already set-based.
- */
- @Override
- protected Class<? extends CreateNodeWithGroupEncodedIntoName> defineAddNodeWithTagStrategy() {
- return null;
- }
-
- /**
- * not needed, as {@link EC2CreateNodesInGroupThenAddToSet} is used and is already set-based.
- */
- @Override
- protected void bindAddNodeWithTagStrategy(Class<? extends CreateNodeWithGroupEncodedIntoName> clazz) {
- }
-
- @Override
- protected Class<? extends DestroyNodeStrategy> defineDestroyNodeStrategy() {
- return EC2DestroyNodeStrategy.class;
- }
-
- @Override
- protected Class<? extends GetNodeMetadataStrategy> defineGetNodeMetadataStrategy() {
- return EC2GetNodeMetadataStrategy.class;
- }
-
- @Override
- protected Class<? extends GetImageStrategy> defineGetImageStrategy() {
- return EC2GetImageStrategy.class;
- }
-
- @Override
- protected Class<? extends ListNodesStrategy> defineListNodesStrategy() {
- return EC2ListNodesStrategy.class;
- }
-
- @Override
- protected Class<? extends RebootNodeStrategy> defineRebootNodeStrategy() {
- return EC2RebootNodeStrategy.class;
- }
-
- @Override
- protected Class<? extends ResumeNodeStrategy> defineStartNodeStrategy() {
- return EC2ResumeNodeStrategy.class;
- }
-
- @Override
- protected Class<? extends SuspendNodeStrategy> defineStopNodeStrategy() {
- return EC2SuspendNodeStrategy.class;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeSuppliersByClass.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeSuppliersByClass.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeSuppliersByClass.java
deleted file mode 100644
index c131608..0000000
--- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeSuppliersByClass.java
+++ /dev/null
@@ -1,41 +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.ec2.compute.config;
-
-import java.util.Set;
-
-import org.jclouds.compute.config.BindComputeSuppliersByClass;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.ec2.compute.suppliers.EC2HardwareSupplier;
-import org.jclouds.ec2.compute.suppliers.EC2ImageSupplier;
-
-import com.google.common.base.Supplier;
-/**
- * @author Adrian Cole
- */
-public class EC2BindComputeSuppliersByClass extends BindComputeSuppliersByClass {
- @Override
- protected Class<? extends Supplier<Set<? extends Hardware>>> defineHardwareSupplier() {
- return EC2HardwareSupplier.class;
- }
-
- @Override
- protected Class<? extends Supplier<Set<? extends Image>>> defineImageSupplier() {
- return EC2ImageSupplier.class;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java
deleted file mode 100644
index 81c874d..0000000
--- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java
+++ /dev/null
@@ -1,144 +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.ec2.compute.config;
-
-import static com.google.common.collect.Iterables.toArray;
-import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
-import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
-
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.compute.config.BaseComputeServiceContextModule;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.extensions.ImageExtension;
-import org.jclouds.compute.extensions.SecurityGroupExtension;
-import org.jclouds.ec2.compute.domain.RegionAndName;
-import org.jclouds.ec2.compute.loaders.RegionAndIdToImage;
-import org.jclouds.ec2.compute.suppliers.RegionAndNameToImageSupplier;
-import org.jclouds.rest.AuthorizationException;
-import org.jclouds.rest.suppliers.SetAndThrowAuthorizationExceptionSupplier;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Splitter;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-import com.google.common.base.Throwables;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.Atomics;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.Provides;
-import com.google.inject.TypeLiteral;
-import com.google.inject.name.Names;
-
-/**
- * Configures the {@link ComputeServiceContext}; requires {@link EC2ComputeService} bound.
- *
- * @author Adrian Cole
- */
-public class EC2ComputeServiceContextModule extends BaseComputeServiceContextModule {
- @Override
- protected void configure() {
- installDependencies();
- install(new EC2BindComputeStrategiesByClass());
- install(new EC2BindComputeSuppliersByClass());
- super.configure();
- }
-
- protected void installDependencies() {
- install(new EC2ComputeServiceDependenciesModule());
- }
-
- @Override
- protected boolean shouldEagerlyParseImages(Injector injector) {
- // If no owners to query, then will never lookup all images
- String[] amiOwners = injector.getInstance(Key.get(String[].class, Names.named(PROPERTY_EC2_AMI_OWNERS)));
- return amiOwners.length > 0;
- }
-
- @Override
- protected Supplier<Set<? extends Image>> supplyNonParsingImageCache(
- AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
- final Supplier<Set<? extends Image>> imageSupplier, Injector injector) {
- final Supplier<LoadingCache<RegionAndName, ? extends Image>> cache = injector.getInstance(Key.get(new TypeLiteral<Supplier<LoadingCache<RegionAndName, ? extends Image>>>() {}));
- return new Supplier<Set<? extends Image>>() {
- @Override
- public Set<? extends Image> get() {
- return ImmutableSet.copyOf(cache.get().asMap().values());
- }
- };
- }
-
- @Provides
- @Singleton
- protected Supplier<LoadingCache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
- final RegionAndNameToImageSupplier supplier) {
- return supplier;
- }
-
- @Provides
- @Singleton
- protected Supplier<CacheLoader<RegionAndName, Image>> provideRegionAndNameToImageSupplierCacheLoader(
- final RegionAndIdToImage delegate) {
- return Suppliers.<CacheLoader<RegionAndName, Image>>ofInstance(new CacheLoader<RegionAndName, Image>() {
- private final AtomicReference<AuthorizationException> authException = Atomics.newReference();
-
- @Override
- public Image load(final RegionAndName key) throws Exception {
- // raw lookup of an image
- Supplier<Image> rawSupplier = new Supplier<Image>() {
- @Override public Image get() {
- try {
- return delegate.load(key);
- } catch (ExecutionException e) {
- throw Throwables.propagate(e);
- }
- }
- };
- return new SetAndThrowAuthorizationExceptionSupplier<Image>(rawSupplier, authException).get();
- }
-
- });
- }
-
- @Provides
- @Singleton
- @Named(PROPERTY_EC2_AMI_OWNERS)
- String[] amiOwners(@Named(PROPERTY_EC2_AMI_OWNERS) String amiOwners) {
- if (amiOwners.trim().equals(""))
- return new String[] {};
- return toArray(Splitter.on(',').split(amiOwners), String.class);
- }
-
- @Override
- protected Optional<ImageExtension> provideImageExtension(Injector i) {
- return Optional.of(i.getInstance(ImageExtension.class));
- }
-
- @Override
- protected Optional<SecurityGroupExtension> provideSecurityGroupExtension(Injector i) {
- return Optional.of(i.getInstance(SecurityGroupExtension.class));
- }
-}
-
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java
deleted file mode 100644
index 9f6c285..0000000
--- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java
+++ /dev/null
@@ -1,197 +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.ec2.compute.config;
-
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_TIMEOUT_SECURITYGROUP_PRESENT;
-import static org.jclouds.util.Predicates2.retry;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadata.Status;
-import org.jclouds.compute.domain.SecurityGroup;
-import org.jclouds.compute.domain.TemplateBuilder;
-import org.jclouds.compute.extensions.ImageExtension;
-import org.jclouds.compute.extensions.SecurityGroupExtension;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.ec2.compute.EC2ComputeService;
-import org.jclouds.ec2.compute.domain.PasswordDataAndPrivateKey;
-import org.jclouds.ec2.compute.domain.RegionAndName;
-import org.jclouds.ec2.compute.extensions.EC2ImageExtension;
-import org.jclouds.ec2.compute.extensions.EC2SecurityGroupExtension;
-import org.jclouds.ec2.compute.functions.AddElasticIpsToNodemetadata;
-import org.jclouds.ec2.compute.functions.CreateUniqueKeyPair;
-import org.jclouds.ec2.compute.functions.CredentialsForInstance;
-import org.jclouds.ec2.compute.functions.EC2ImageParser;
-import org.jclouds.ec2.compute.functions.EC2SecurityGroupIdFromName;
-import org.jclouds.ec2.compute.functions.EC2SecurityGroupToSecurityGroup;
-import org.jclouds.ec2.compute.functions.PasswordCredentialsFromWindowsInstance;
-import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata;
-import org.jclouds.ec2.compute.functions.WindowsLoginCredentialsFromEncryptedData;
-import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl;
-import org.jclouds.ec2.compute.loaders.CreateSecurityGroupIfNeeded;
-import org.jclouds.ec2.compute.loaders.LoadPublicIpForInstanceOrNull;
-import org.jclouds.ec2.compute.loaders.RegionAndIdToImage;
-import org.jclouds.ec2.compute.options.EC2TemplateOptions;
-import org.jclouds.ec2.compute.predicates.SecurityGroupPresent;
-import org.jclouds.ec2.domain.Image.ImageState;
-import org.jclouds.ec2.domain.InstanceState;
-import org.jclouds.ec2.domain.KeyPair;
-import org.jclouds.ec2.domain.RunningInstance;
-import org.jclouds.ec2.reference.EC2Constants;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.base.Functions;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import com.google.inject.AbstractModule;
-import com.google.inject.Injector;
-import com.google.inject.Provides;
-import com.google.inject.TypeLiteral;
-import com.google.inject.name.Names;
-
-/**
- *
- * @author Adrian Cole
- */
-public class EC2ComputeServiceDependenciesModule extends AbstractModule {
-
- public static final Map<InstanceState, Status> toPortableNodeStatus = ImmutableMap
- .<InstanceState, Status> builder()
- .put(InstanceState.PENDING, Status.PENDING)
- .put(InstanceState.RUNNING, Status.RUNNING)
- .put(InstanceState.SHUTTING_DOWN, Status.PENDING)
- .put(InstanceState.TERMINATED, Status.TERMINATED)
- .put(InstanceState.STOPPING, Status.PENDING)
- .put(InstanceState.STOPPED, Status.SUSPENDED)
- .put(InstanceState.UNRECOGNIZED, Status.UNRECOGNIZED)
- .build();
-
- @Singleton
- @Provides
- protected Map<InstanceState, NodeMetadata.Status> toPortableNodeStatus() {
- return toPortableNodeStatus;
- }
-
- @VisibleForTesting
- public static final Map<ImageState, Image.Status> toPortableImageStatus = ImmutableMap
- .<ImageState, Image.Status> builder()
- .put(ImageState.AVAILABLE, Image.Status.AVAILABLE)
- .put(ImageState.DEREGISTERED, Image.Status.DELETED)
- .put(ImageState.UNRECOGNIZED, Image.Status.UNRECOGNIZED).build();
-
- @Singleton
- @Provides
- protected Map<ImageState, Image.Status> toPortableImageStatus() {
- return toPortableImageStatus;
- }
-
- @Override
- protected void configure() {
- bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class);
- bind(TemplateOptions.class).to(EC2TemplateOptions.class);
- bind(ComputeService.class).to(EC2ComputeService.class);
- bind(new TypeLiteral<CacheLoader<RunningInstance, Optional<LoginCredentials>>>() {
- }).to(CredentialsForInstance.class);
- bind(new TypeLiteral<Function<RegionAndName, KeyPair>>() {
- }).to(CreateUniqueKeyPair.class);
- bind(new TypeLiteral<CacheLoader<RegionAndName, Image>>() {
- }).to(RegionAndIdToImage.class);
- bind(new TypeLiteral<CacheLoader<RegionAndName, String>>() {
- }).annotatedWith(Names.named("SECURITY")).to(CreateSecurityGroupIfNeeded.class);
- bind(new TypeLiteral<CacheLoader<RegionAndName, String>>() {
- }).annotatedWith(Names.named("ELASTICIP")).to(LoadPublicIpForInstanceOrNull.class);
- bind(new TypeLiteral<Function<String, String>>() {
- }).annotatedWith(Names.named("SECGROUP_NAME_TO_ID")).to(EC2SecurityGroupIdFromName.class);
- bind(new TypeLiteral<Function<PasswordDataAndPrivateKey, LoginCredentials>>() {
- }).to(WindowsLoginCredentialsFromEncryptedData.class);
- bind(new TypeLiteral<Function<RunningInstance, LoginCredentials>>() {
- }).to(PasswordCredentialsFromWindowsInstance.class);
- bind(new TypeLiteral<Function<org.jclouds.ec2.domain.Image, Image>>() {
- }).to(EC2ImageParser.class);
- bind(new TypeLiteral<Function<org.jclouds.ec2.domain.SecurityGroup, SecurityGroup>>() {
- }).to(EC2SecurityGroupToSecurityGroup.class);
- bind(new TypeLiteral<ImageExtension>() {
- }).to(EC2ImageExtension.class);
- bind(new TypeLiteral<SecurityGroupExtension>() {
- }).to(EC2SecurityGroupExtension.class);
- }
-
- /**
- * only add the overhead of looking up ips when we have enabled the auto-allocate functionality
- */
- @Provides
- @Singleton
- public Function<RunningInstance, NodeMetadata> bindNodeConverter(RunningInstanceToNodeMetadata baseConverter,
- AddElasticIpsToNodemetadata addElasticIpsToNodemetadata,
- @Named(EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS) boolean autoAllocateElasticIps) {
- if (!autoAllocateElasticIps)
- return baseConverter;
- return Functions.compose(addElasticIpsToNodemetadata, baseConverter);
- }
-
- @Provides
- @Singleton
- protected LoadingCache<RunningInstance, Optional<LoginCredentials>> credentialsMap(CacheLoader<RunningInstance, Optional<LoginCredentials>> in) {
- return CacheBuilder.newBuilder().build(in);
- }
-
- @Provides
- @Singleton
- protected ConcurrentMap<RegionAndName, KeyPair> keypairMap(Injector i) {
- return Maps.newConcurrentMap();
- }
-
- @Provides
- @Singleton
- @Named("SECURITY")
- protected LoadingCache<RegionAndName, String> securityGroupMap(
- @Named("SECURITY") CacheLoader<RegionAndName, String> in) {
- return CacheBuilder.newBuilder().build(in);
- }
-
- @Provides
- @Singleton
- @Named("ELASTICIP")
- protected LoadingCache<RegionAndName, String> instanceToElasticIp(
- @Named("ELASTICIP") CacheLoader<RegionAndName, String> in) {
- return CacheBuilder.newBuilder().build(in);
- }
-
- @Provides
- @Singleton
- @Named("SECURITY")
- protected Predicate<RegionAndName> securityGroupEventualConsistencyDelay(SecurityGroupPresent in,
- @Named(PROPERTY_EC2_TIMEOUT_SECURITYGROUP_PRESENT) long msDelay) {
- return retry(in, msDelay, 100l, MILLISECONDS);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ResolveImagesModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ResolveImagesModule.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ResolveImagesModule.java
deleted file mode 100644
index e3e98e6..0000000
--- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ResolveImagesModule.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.ec2.compute.config;
-
-import org.jclouds.compute.config.ResolvesImages;
-import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
-import org.jclouds.ec2.compute.strategy.EC2PopulateDefaultLoginCredentialsForImageStrategy;
-
-import com.google.inject.AbstractModule;
-
-/**
- * @author Oleksiy Yarmula
- */
-@ResolvesImages
-public class EC2ResolveImagesModule extends AbstractModule {
-
- @Override
- protected void configure() {
- bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to(EC2PopulateDefaultLoginCredentialsForImageStrategy.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java
deleted file mode 100644
index 185644e..0000000
--- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java
+++ /dev/null
@@ -1,599 +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.ec2.compute.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Predicates.not;
-import static org.jclouds.compute.domain.Volume.Type.LOCAL;
-import static org.jclouds.compute.predicates.ImagePredicates.any;
-import static org.jclouds.compute.predicates.ImagePredicates.idIn;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.compute.domain.Processor;
-import org.jclouds.compute.domain.Volume;
-import org.jclouds.compute.domain.VolumeBuilder;
-import org.jclouds.compute.predicates.ImagePredicates;
-import org.jclouds.domain.Location;
-import org.jclouds.ec2.domain.InstanceType;
-import org.jclouds.ec2.domain.RootDeviceType;
-import org.jclouds.ec2.domain.VirtualizationType;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import com.google.common.collect.ImmutableSet;
-
-/**
- *
- * @author Adrian Cole
- * @see <a href=
- * "http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?instance-types.html"
- * />
- */
-public class EC2HardwareBuilder extends HardwareBuilder {
- private Predicate<Image> rootDeviceType = any();
- private Predicate<Image> virtualizationType = Predicates.or(new IsWindows(), new RequiresVirtualizationType(
- VirtualizationType.PARAVIRTUAL));
- private Predicate<Image> imageIds = any();
- private Predicate<Image> is64Bit = any();
-
- public EC2HardwareBuilder() {
- this.supportsImage = null;
- }
-
- /**
- * evaluates true if the Image has the following rootDeviceType
- *
- * @param type
- * rootDeviceType of the image
- * @return predicate
- */
- public static class RequiresRootDeviceType implements Predicate<Image> {
- final RootDeviceType type;
-
- public RequiresRootDeviceType(final RootDeviceType type) {
- this.type = checkNotNull(type, "type must be defined");
- }
-
- @Override
- public boolean apply(Image image) {
- return image.getUserMetadata().containsKey("rootDeviceType")
- && type == RootDeviceType.fromValue(image.getUserMetadata().get("rootDeviceType"));
- }
-
- @Override
- public String toString() {
- return "requiresRootDeviceType(" + type + ")";
- }
-
- }
-
- public static class IsWindows implements Predicate<Image> {
-
- @Override
- public boolean apply(Image image) {
- return image.getOperatingSystem() != null && OsFamily.WINDOWS == image.getOperatingSystem().getFamily();
- }
-
- @Override
- public String toString() {
- return "isWindows()";
- }
-
- }
-
- /**
- * evaluates true if the Image requires the following virtualizationType
- *
- * @param type
- * virtualizationType of the image
- * @return predicate
- */
- public static class RequiresVirtualizationType implements Predicate<Image> {
- final VirtualizationType type;
-
- public RequiresVirtualizationType(final VirtualizationType type) {
- this.type = checkNotNull(type, "type must be defined");
- }
-
- @Override
- public boolean apply(Image image) {
- return image.getOperatingSystem() != null && image.getOperatingSystem().getArch() != null
- && type == VirtualizationType.fromValue(image.getOperatingSystem().getArch());
- }
-
- @Override
- public String toString() {
- return "requiresVirtualizationType(" + type + ")";
- }
-
- }
-
- public EC2HardwareBuilder(String instanceType) {
- ids(instanceType);
- }
-
- public EC2HardwareBuilder virtualizationType(VirtualizationType virtualizationType) {
- this.virtualizationType = new RequiresVirtualizationType(virtualizationType);
- return this;
- }
-
- public EC2HardwareBuilder rootDeviceType(RootDeviceType rootDeviceType) {
- this.rootDeviceType = new RequiresRootDeviceType(rootDeviceType);
- return this;
- }
-
- public EC2HardwareBuilder supportsImageIds(Iterable<String> ids) {
- this.imageIds = idIn(ids);
- return this;
- }
-
- public EC2HardwareBuilder ids(String id) {
- return EC2HardwareBuilder.class.cast(super.ids(id));
- }
-
- public EC2HardwareBuilder ram(int ram) {
- return EC2HardwareBuilder.class.cast(super.ram(ram));
- }
-
- public EC2HardwareBuilder processors(List<Processor> processors) {
- return EC2HardwareBuilder.class.cast(super.processors(processors));
- }
-
- public EC2HardwareBuilder volumes(List<Volume> volumes) {
- return EC2HardwareBuilder.class.cast(super.volumes(volumes));
- }
-
- public EC2HardwareBuilder supportsImage(Predicate<Image> supportsImage) {
- return EC2HardwareBuilder.class.cast(super.supportsImage(supportsImage));
- }
-
- public EC2HardwareBuilder is64Bit(boolean is64Bit) {
- this.is64Bit = is64Bit ? ImagePredicates.is64Bit() : not(ImagePredicates.is64Bit());
- return this;
- }
-
- public EC2HardwareBuilder id(String id) {
- return EC2HardwareBuilder.class.cast(super.id(id));
- }
-
- @Override
- public EC2HardwareBuilder providerId(String providerId) {
- return EC2HardwareBuilder.class.cast(super.providerId(providerId));
- }
-
- @Override
- public EC2HardwareBuilder name(String name) {
- return EC2HardwareBuilder.class.cast(super.name(name));
- }
-
- @Override
- public EC2HardwareBuilder location(Location location) {
- return EC2HardwareBuilder.class.cast(super.location(location));
- }
-
- @Override
- public EC2HardwareBuilder uri(URI uri) {
- return EC2HardwareBuilder.class.cast(super.uri(uri));
- }
-
- @Override
- public EC2HardwareBuilder userMetadata(Map<String, String> userMetadata) {
- return EC2HardwareBuilder.class.cast(super.userMetadata(userMetadata));
- }
-
- /**
- * @see InstanceType#M1_SMALL
- */
- public static EC2HardwareBuilder m1_small() {
- return new EC2HardwareBuilder(InstanceType.M1_SMALL)
- .ram(1740)
- .processors(ImmutableList.of(new Processor(1.0, 1.0)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(150.0f).device("/dev/sda2").bootDevice(false).durable(false).build()));
- }
-
- /**
- * @see InstanceType#M1_MEDIUM
- */
- public static EC2HardwareBuilder m1_medium() {
- return new EC2HardwareBuilder(InstanceType.M1_MEDIUM)
- .ram(3750)
- .processors(ImmutableList.of(new Processor(1.0, 2.0)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sdc").bootDevice(false).durable(false).build()));
- }
-
-
- /**
- * @see InstanceType#T1_MICRO
- */
- public static EC2HardwareBuilder t1_micro() {
- return new EC2HardwareBuilder(InstanceType.T1_MICRO).ram(630)
- .processors(ImmutableList.of(new Processor(1.0, 1.0))).rootDeviceType(RootDeviceType.EBS);
- }
-
- /**
- * @see InstanceType#M1_LARGE
- */
- public static EC2HardwareBuilder m1_large() {
- return new EC2HardwareBuilder(InstanceType.M1_LARGE)
- .ram(7680)
- .processors(ImmutableList.of(new Processor(2.0, 2.0)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sdc").bootDevice(false).durable(false).build()))
- .is64Bit(true);
- }
-
- /**
- * @see InstanceType#M1_XLARGE
- */
- public static EC2HardwareBuilder m1_xlarge() {
- return new EC2HardwareBuilder(InstanceType.M1_XLARGE)
- .ram(15360)
- .processors(ImmutableList.of(new Processor(4.0, 2.0)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sdc").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sdd").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sde").bootDevice(false).durable(false).build()))
- .is64Bit(true);
- }
-
- /**
- * @see InstanceType#M2_XLARGE
- */
- public static EC2HardwareBuilder m2_xlarge() {
- return new EC2HardwareBuilder(InstanceType.M2_XLARGE).ram(17510)
- .processors(ImmutableList.of(new Processor(2.0, 3.25)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sda1").bootDevice(true).durable(false).build()))
- .is64Bit(true);
- }
-
- /**
- * @see InstanceType#M2_2XLARGE
- */
- public static EC2HardwareBuilder m2_2xlarge() {
- return new EC2HardwareBuilder(InstanceType.M2_2XLARGE)
- .ram(35020)
- .processors(ImmutableList.of(new Processor(4.0, 3.25)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(840.0f).device("/dev/sdb").bootDevice(false).durable(false).build()))
- .is64Bit(true);
- }
-
- /**
- * @see InstanceType#M2_4XLARGE
- */
- public static EC2HardwareBuilder m2_4xlarge() {
- return new EC2HardwareBuilder(InstanceType.M2_4XLARGE)
- .ram(70041)
- .processors(ImmutableList.of(new Processor(8.0, 3.25)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(840.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(840.0f).device("/dev/sdc").bootDevice(false).durable(false).build()))
- .is64Bit(true);
- }
-
- /**
- * @see InstanceType#M3_MEDIUM
- */
- public static EC2HardwareBuilder m3_medium() {
- return new EC2HardwareBuilder(InstanceType.M3_MEDIUM)
- .ram(3840)
- .processors(ImmutableList.of(new Processor(1.0, 3.0)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(4.0f).device("/dev/sdb").bootDevice(false).durable(false).build()));
- }
-
- /**
- * @see InstanceType#M3_LARGE
- */
- public static EC2HardwareBuilder m3_large() {
- return new EC2HardwareBuilder(InstanceType.M3_LARGE)
- .ram(7680)
- .processors(ImmutableList.of(new Processor(2.0, 3.25)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(32.0f).device("/dev/sdb").bootDevice(false).durable(false).build()));
- }
-
- /**
- * @see InstanceType#M3_XLARGE
- */
- public static EC2HardwareBuilder m3_xlarge() {
- return new EC2HardwareBuilder(InstanceType.M3_XLARGE).ram(15360)
- .processors(ImmutableList.of(new Processor(4.0, 3.25))).rootDeviceType(RootDeviceType.EBS).is64Bit(true);
- }
-
- /**
- * @see InstanceType#M3_2XLARGE
- */
- public static EC2HardwareBuilder m3_2xlarge() {
- return new EC2HardwareBuilder(InstanceType.M3_2XLARGE).ram(30720)
- .processors(ImmutableList.of(new Processor(8.0, 3.25))).rootDeviceType(RootDeviceType.EBS).is64Bit(true);
- }
-
- /**
- * @see InstanceType#C1_MEDIUM
- */
- public static EC2HardwareBuilder c1_medium() {
- return new EC2HardwareBuilder(InstanceType.C1_MEDIUM)
- .ram(1740)
- .processors(ImmutableList.of(new Processor(2.0, 2.5)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(340.0f).device("/dev/sda2").bootDevice(false).durable(false).build()));
- }
-
- /**
- * @see InstanceType#C1_XLARGE
- */
- public static EC2HardwareBuilder c1_xlarge() {
- return new EC2HardwareBuilder(InstanceType.C1_XLARGE)
- .ram(7168)
- .processors(ImmutableList.of(new Processor(8.0, 2.5)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sdc").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sdd").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(420.0f).device("/dev/sde").bootDevice(false).durable(false).build()))
- .is64Bit(true);
- }
-
- /**
- * @see InstanceType#C3_LARGE
- */
- public static EC2HardwareBuilder c3_large() {
- return new EC2HardwareBuilder(InstanceType.C3_LARGE)
- .ram(3750)
- .processors(ImmutableList.of(new Processor(2.0, 3.5)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(16.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(16.0f).device("/dev/sdc").bootDevice(false).durable(false).build()))
- .is64Bit(true);
- }
-
- /**
- * @see InstanceType#C3_XLARGE
- */
- public static EC2HardwareBuilder c3_xlarge() {
- return new EC2HardwareBuilder(InstanceType.C3_XLARGE)
- .ram(7168)
- .processors(ImmutableList.of(new Processor(4.0, 3.5)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(40.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(40.0f).device("/dev/sdc").bootDevice(false).durable(false).build()))
- .is64Bit(true);
- }
-
- /**
- * @see InstanceType#C3_2XLARGE
- */
- public static EC2HardwareBuilder c3_2xlarge() {
- return new EC2HardwareBuilder(InstanceType.C3_2XLARGE)
- .ram(15360)
- .processors(ImmutableList.of(new Processor(8.0, 3.5)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(80.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(80.0f).device("/dev/sdc").bootDevice(false).durable(false).build()))
- .is64Bit(true);
- }
-
- /**
- * @see InstanceType#C3_4XLARGE
- */
- public static EC2HardwareBuilder c3_4xlarge() {
- return new EC2HardwareBuilder(InstanceType.C3_4XLARGE)
- .ram(30720)
- .processors(ImmutableList.of(new Processor(16.0, 3.4375)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(160.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(160.0f).device("/dev/sdc").bootDevice(false).durable(false).build()))
- .is64Bit(true);
- }
-
- /**
- * @see InstanceType#C3_8XLARGE
- */
- public static EC2HardwareBuilder c3_8xlarge() {
- return new EC2HardwareBuilder(InstanceType.C3_8XLARGE)
- .ram(61440)
- .processors(ImmutableList.of(new Processor(32.0, 3.375)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(320.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(320.0f).device("/dev/sdc").bootDevice(false).durable(false).build()))
- .is64Bit(true);
- }
-
- public static EC2HardwareBuilder cg1_4xlarge() {
- return new EC2HardwareBuilder(InstanceType.CG1_4XLARGE)
- .ram(22 * 1024)
- .processors(ImmutableList.of(new Processor(4.0, 4.0), new Processor(4.0, 4.0)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(840.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(840.0f).device("/dev/sdc").bootDevice(false).durable(false).build()))
- .virtualizationType(VirtualizationType.HVM);
- }
-
- public static EC2HardwareBuilder cc1_4xlarge() {
- return new EC2HardwareBuilder(InstanceType.CC1_4XLARGE)
- .ram(23 * 1024)
- .processors(ImmutableList.of(new Processor(4.0, 4.0), new Processor(4.0, 4.0)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(840.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(840.0f).device("/dev/sdc").bootDevice(false).durable(false).build()))
- .virtualizationType(VirtualizationType.HVM);
- }
-
- public static EC2HardwareBuilder cc2_8xlarge() {
- return new EC2HardwareBuilder(InstanceType.CC2_8XLARGE)
- .ram(60 * 1024 + 512)
- .processors(ImmutableList.of(new Processor(8.0, 5.5), new Processor(8.0, 5.5)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(840.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(840.0f).device("/dev/sdc").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(840.0f).device("/dev/sdd").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(840.0f).device("/dev/sde").bootDevice(false).durable(false).build()))
- .virtualizationType(VirtualizationType.HVM);
- }
-
- /**
- * @see InstanceType#G2_2XLARGE
- */
- public static EC2HardwareBuilder g2_2xlarge() {
- return new EC2HardwareBuilder(InstanceType.G2_2XLARGE)
- .ram(15*1024)
- .processors(ImmutableList.of(new Processor(8.0, 3.25)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(60.0f).device("/dev/sdb").bootDevice(false).durable(false).build()))
- .virtualizationType(VirtualizationType.HVM);
- }
-
- /**
- * @see InstanceType#I2_XLARGE
- */
- public static EC2HardwareBuilder i2_xlarge() {
- return new EC2HardwareBuilder(InstanceType.I2_XLARGE)
- .ram(30 * 1024 + 512)
- .processors(ImmutableList.of(new Processor(4.0, 3.5)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdb").bootDevice(false).durable(false).build()))
- .virtualizationType(VirtualizationType.HVM);
- }
-
- /**
- * @see InstanceType#I2_2XLARGE
- */
- public static EC2HardwareBuilder i2_2xlarge() {
- return new EC2HardwareBuilder(InstanceType.I2_2XLARGE)
- .ram(61 * 1024)
- .processors(ImmutableList.of(new Processor(8.0, 3.375)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdc").bootDevice(false).durable(false).build()))
- .virtualizationType(VirtualizationType.HVM);
- }
-
- /**
- * @see InstanceType#I2_4XLARGE
- */
- public static EC2HardwareBuilder i2_4xlarge() {
- return new EC2HardwareBuilder(InstanceType.I2_4XLARGE)
- .ram(122 * 1024)
- .processors(ImmutableList.of(new Processor(16.0, 3.3125)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdc").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdd").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sde").bootDevice(false).durable(false).build()))
- .virtualizationType(VirtualizationType.HVM);
- }
-
- /**
- * @see InstanceType#I2_8XLARGE
- */
- public static EC2HardwareBuilder i2_8xlarge() {
- return new EC2HardwareBuilder(InstanceType.I2_8XLARGE)
- .ram(244 * 1024)
- .processors(ImmutableList.of(new Processor(32.0, 3.25)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdb").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdc").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdd").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sde").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdf").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdg").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdh").bootDevice(false).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(800.0f).device("/dev/sdi").bootDevice(false).durable(false).build()))
- .virtualizationType(VirtualizationType.HVM);
- }
-
- public static EC2HardwareBuilder hi1_4xlarge() {
- return new EC2HardwareBuilder(InstanceType.HI1_4XLARGE)
- .ram(60 * 1024 + 512)
- .processors(ImmutableList.of(new Processor(16.0, 2.1875)))
- .volumes(ImmutableList.<Volume> of(
- new VolumeBuilder().type(LOCAL).size(1024.0f).device("/dev/sda1").bootDevice(true).durable(false).build(),
- new VolumeBuilder().type(LOCAL).size(1024.0f).device("/dev/sdb").bootDevice(false).durable(false).build()))
- .virtualizationType(VirtualizationType.HVM);
- }
-
- public static EC2HardwareBuilder hs1_8xlarge() {
- float twoTB = 2048.0f * 1024.0f;
- Builder<Volume> all24Volumes = ImmutableList.<Volume>builder();
- all24Volumes.add(new VolumeBuilder().type(LOCAL).size(twoTB).device("/dev/sda1").bootDevice(true).durable(false).build());
- for (char letter : ImmutableSet.of('b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
- 'q', 'r', 's', 't', 'u', 'v', 'w', 'x')) {
- all24Volumes.add(new VolumeBuilder().type(LOCAL).size(twoTB).device("/dev/sd" + letter).bootDevice(false).durable(false).build());
- }
- return new EC2HardwareBuilder(InstanceType.HS1_8XLARGE)
- .ram(117 * 1024)
- .processors(ImmutableList.of(new Processor(16.0, 2.1875)))
- .volumes(all24Volumes.build())
- .virtualizationType(VirtualizationType.HVM);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Hardware build() {
- boolean reset = false;
- if (this.supportsImage == null)
- reset = true;
- try {
- supportsImage = Predicates.<Image> and(rootDeviceType, virtualizationType, imageIds, is64Bit);
- return super.build();
- } finally {
- if (reset)
- this.supportsImage = null;
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/PasswordDataAndPrivateKey.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/PasswordDataAndPrivateKey.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/PasswordDataAndPrivateKey.java
deleted file mode 100644
index 9e0748f..0000000
--- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/PasswordDataAndPrivateKey.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.ec2.compute.domain;
-
-import org.jclouds.ec2.domain.PasswordData;
-
-import com.google.common.base.Objects;
-
-/**
- * An encrypted Windows Administrator password, and the private key that can decrypt it.
- *
- * @author Richard Downer
- */
-public class PasswordDataAndPrivateKey {
-
- private final PasswordData passwordData;
- private final String privateKey;
-
- public PasswordDataAndPrivateKey(PasswordData passwordData, String privateKey) {
- this.passwordData = passwordData;
- this.privateKey = privateKey;
- }
-
- public PasswordData getPasswordData() {
- return passwordData;
- }
-
- public String getPrivateKey() {
- return privateKey;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(passwordData, privateKey);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- PasswordDataAndPrivateKey other = PasswordDataAndPrivateKey.class.cast(obj);
- return Objects.equal(this.passwordData, other.passwordData) && Objects.equal(this.privateKey, other.privateKey);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return Objects.toStringHelper(this).omitNullValues().add("passwordData", passwordData).toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionAndName.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionAndName.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionAndName.java
deleted file mode 100644
index bdfc04d..0000000
--- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionAndName.java
+++ /dev/null
@@ -1,111 +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.ec2.compute.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.base.Function;
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- *
- * @author Adrian Cole
- */
-public class RegionAndName {
-
- protected final String region;
- protected final String name;
-
- public String slashEncode() {
- return new StringBuilder(region).append('/').append(name).toString();
- }
-
- public RegionAndName(String region, String name) {
- this.region = checkNotNull(region, "region");
- this.name = checkNotNull(name, "name");
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(region, name);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof RegionAndName))
- return false;
- RegionAndName other = RegionAndName.class.cast(obj);
- return Objects.equal(region, other.region) && Objects.equal(name, other.name);
- }
-
- public String getRegion() {
- return region;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- protected ToStringHelper string() {
- return Objects.toStringHelper("").add("region", region).add("name", name);
- }
-
- private static enum RegionFunction implements Function<RegionAndName, String> {
- INSTANCE;
- @Override
- public String apply(RegionAndName input) {
- return input.getRegion();
- }
-
- @Override
- public String toString() {
- return "getRegion()";
- }
- };
-
- public static Function<RegionAndName, String> regionFunction() {
- return RegionFunction.INSTANCE;
- }
-
- private static enum NameFunction implements Function<RegionAndName, String> {
- INSTANCE;
- @Override
- public String apply(RegionAndName input) {
- return input.getName();
- }
-
- @Override
- public String toString() {
- return "getName()";
- }
- };
-
- public static Function<RegionAndName, String> nameFunction() {
- return NameFunction.INSTANCE;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionNameAndIngressRules.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionNameAndIngressRules.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionNameAndIngressRules.java
deleted file mode 100644
index 0063104..0000000
--- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionNameAndIngressRules.java
+++ /dev/null
@@ -1,44 +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.ec2.compute.domain;
-
-/**
- *
- * @author Adrian Cole
- */
-public class RegionNameAndIngressRules extends RegionAndName {
- private final int[] ports;
- private final boolean authorizeSelf;
-
- public RegionNameAndIngressRules(String region, String tag, int[] ports, boolean authorizeSelf) {
- super(region, tag);
- this.ports = ports;
- this.authorizeSelf = authorizeSelf;
- }
-
- // intentionally not overriding equals or hash-code so that we can search only by region/tag in a
- // map
-
- public int[] getPorts() {
- return ports;
- }
-
- public boolean shouldAuthorizeSelf() {
- return authorizeSelf;
- }
-
-}