| 1 | /** |
| 2 | * |
| 3 | * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> |
| 4 | * |
| 5 | * ==================================================================== |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * ==================================================================== |
| 18 | */ |
| 19 | package org.jclouds.aws.ec2.compute.config; |
| 20 | |
| 21 | import static org.jclouds.compute.domain.OsFamily.AMZN_LINUX; |
| 22 | |
| 23 | import org.jclouds.aws.ec2.compute.AWSEC2TemplateBuilderImpl; |
| 24 | import org.jclouds.aws.ec2.compute.functions.AWSRunningInstanceToNodeMetadata; |
| 25 | import org.jclouds.aws.ec2.compute.predicates.AWSEC2InstancePresent; |
| 26 | import org.jclouds.aws.ec2.compute.strategy.AWSEC2CreateNodesInGroupThenAddToSet; |
| 27 | import org.jclouds.aws.ec2.compute.strategy.AWSEC2DestroyNodeStrategy; |
| 28 | import org.jclouds.aws.ec2.compute.strategy.AWSEC2GetNodeMetadataStrategy; |
| 29 | import org.jclouds.aws.ec2.compute.strategy.AWSEC2ListNodesStrategy; |
| 30 | import org.jclouds.aws.ec2.compute.strategy.AWSEC2ReviseParsedImage; |
| 31 | import org.jclouds.aws.ec2.compute.strategy.CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions; |
| 32 | import org.jclouds.aws.ec2.compute.suppliers.AWSEC2HardwareSupplier; |
| 33 | import org.jclouds.aws.ec2.compute.suppliers.AWSRegionAndNameToImageSupplier; |
| 34 | import org.jclouds.compute.domain.TemplateBuilder; |
| 35 | import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule; |
| 36 | import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata; |
| 37 | import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl; |
| 38 | import org.jclouds.ec2.compute.predicates.InstancePresent; |
| 39 | import org.jclouds.ec2.compute.strategy.CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions; |
| 40 | import org.jclouds.ec2.compute.strategy.EC2CreateNodesInGroupThenAddToSet; |
| 41 | import org.jclouds.ec2.compute.strategy.EC2DestroyNodeStrategy; |
| 42 | import org.jclouds.ec2.compute.strategy.EC2GetNodeMetadataStrategy; |
| 43 | import org.jclouds.ec2.compute.strategy.EC2ListNodesStrategy; |
| 44 | import org.jclouds.ec2.compute.strategy.ReviseParsedImage; |
| 45 | import org.jclouds.ec2.compute.suppliers.EC2HardwareSupplier; |
| 46 | import org.jclouds.ec2.compute.suppliers.RegionAndNameToImageSupplier; |
| 47 | |
| 48 | import com.google.inject.Injector; |
| 49 | |
| 50 | /** |
| 51 | * |
| 52 | * @author Adrian Cole |
| 53 | */ |
| 54 | public class AWSEC2ComputeServiceContextModule extends EC2ComputeServiceContextModule { |
| 55 | |
| 56 | @Override |
| 57 | protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { |
| 58 | return template.osFamily(AMZN_LINUX).os64Bit(true); |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | protected void configure() { |
| 63 | super.configure(); |
| 64 | bind(ReviseParsedImage.class).to(AWSEC2ReviseParsedImage.class); |
| 65 | bind(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class).to( |
| 66 | CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class); |
| 67 | bind(EC2HardwareSupplier.class).to(AWSEC2HardwareSupplier.class); |
| 68 | bind(RegionAndNameToImageSupplier.class).to(AWSRegionAndNameToImageSupplier.class); |
| 69 | bind(EC2TemplateBuilderImpl.class).to(AWSEC2TemplateBuilderImpl.class); |
| 70 | bind(EC2GetNodeMetadataStrategy.class).to(AWSEC2GetNodeMetadataStrategy.class); |
| 71 | bind(EC2ListNodesStrategy.class).to(AWSEC2ListNodesStrategy.class); |
| 72 | bind(EC2DestroyNodeStrategy.class).to(AWSEC2DestroyNodeStrategy.class); |
| 73 | bind(InstancePresent.class).to(AWSEC2InstancePresent.class); |
| 74 | bind(EC2CreateNodesInGroupThenAddToSet.class).to(AWSEC2CreateNodesInGroupThenAddToSet.class); |
| 75 | bind(RunningInstanceToNodeMetadata.class).to(AWSRunningInstanceToNodeMetadata.class); |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | protected void installDependencies() { |
| 80 | install(new AWSEC2ComputeServiceDependenciesModule()); |
| 81 | } |
| 82 | |
| 83 | } |