| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. 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, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.savvis.vpdc.compute.config; |
| 20 | |
| 21 | import static org.jclouds.compute.domain.OsFamily.RHEL; |
| 22 | |
| 23 | import org.jclouds.compute.ComputeServiceAdapter; |
| 24 | import org.jclouds.compute.config.ComputeServiceAdapterContextModule; |
| 25 | import org.jclouds.compute.domain.CIMOperatingSystem; |
| 26 | import org.jclouds.compute.domain.NodeMetadata; |
| 27 | import org.jclouds.compute.domain.TemplateBuilder; |
| 28 | import org.jclouds.domain.Location; |
| 29 | import org.jclouds.savvis.vpdc.VPDCAsyncClient; |
| 30 | import org.jclouds.savvis.vpdc.VPDCClient; |
| 31 | import org.jclouds.savvis.vpdc.compute.functions.CIMOperatingSystemToImage; |
| 32 | import org.jclouds.savvis.vpdc.compute.functions.NetworkToLocation; |
| 33 | import org.jclouds.savvis.vpdc.compute.functions.VMSpecToHardware; |
| 34 | import org.jclouds.savvis.vpdc.compute.functions.VMToNodeMetadata; |
| 35 | import org.jclouds.savvis.vpdc.compute.strategy.VPDCComputeServiceAdapter; |
| 36 | import org.jclouds.savvis.vpdc.compute.suppliers.FirstNetwork; |
| 37 | import org.jclouds.savvis.vpdc.domain.Network; |
| 38 | import org.jclouds.savvis.vpdc.domain.VM; |
| 39 | import org.jclouds.savvis.vpdc.domain.VMSpec; |
| 40 | |
| 41 | import com.google.common.base.Function; |
| 42 | import com.google.common.base.Supplier; |
| 43 | import com.google.inject.Injector; |
| 44 | import com.google.inject.TypeLiteral; |
| 45 | |
| 46 | /** |
| 47 | * |
| 48 | * @author Adrian Cole |
| 49 | */ |
| 50 | public class VPDCComputeServiceContextModule extends |
| 51 | ComputeServiceAdapterContextModule<VPDCClient, VPDCAsyncClient, VM, VMSpec, CIMOperatingSystem, Network> { |
| 52 | |
| 53 | public VPDCComputeServiceContextModule() { |
| 54 | super(VPDCClient.class, VPDCAsyncClient.class); |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { |
| 59 | return template.osFamily(RHEL).os64Bit(true); |
| 60 | } |
| 61 | |
| 62 | @Override |
| 63 | protected void configure() { |
| 64 | super.configure(); |
| 65 | bind(new TypeLiteral<ComputeServiceAdapter<VM, VMSpec, CIMOperatingSystem, Network>>() { |
| 66 | }).to(VPDCComputeServiceAdapter.class); |
| 67 | bind(new TypeLiteral<Function<VM, NodeMetadata>>() { |
| 68 | }).to(VMToNodeMetadata.class); |
| 69 | bind(new TypeLiteral<Function<CIMOperatingSystem, org.jclouds.compute.domain.Image>>() { |
| 70 | }).to(CIMOperatingSystemToImage.class); |
| 71 | bind(new TypeLiteral<Function<VMSpec, org.jclouds.compute.domain.Hardware>>() { |
| 72 | }).to(VMSpecToHardware.class); |
| 73 | bind(new TypeLiteral<Function<Network, Location>>() { |
| 74 | }).to(NetworkToLocation.class); |
| 75 | bind(new TypeLiteral<Supplier<Location>>() { |
| 76 | }).to(FirstNetwork.class); |
| 77 | } |
| 78 | } |