EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.vcloud.terremark.compute.strategy]

COVERAGE SUMMARY FOR SOURCE FILE [StartVAppWithGroupEncodedIntoName.java]

nameclass, %method, %block, %line, %
StartVAppWithGroupEncodedIntoName.java0%   (0/1)0%   (0/2)0%   (0/87)0%   (0/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StartVAppWithGroupEncodedIntoName0%   (0/1)0%   (0/2)0%   (0/87)0%   (0/14)
StartVAppWithGroupEncodedIntoName (TerremarkVCloudComputeClient, Function, Te... 0%   (0/1)0%   (0/21)0%   (0/6)
createNodeWithGroupEncodedIntoName (String, String, Template): NodeMetadata 0%   (0/1)0%   (0/66)0%   (0/8)

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 */
19package org.jclouds.vcloud.terremark.compute.strategy;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.net.URI;
24import java.util.Map;
25 
26import javax.inject.Inject;
27import javax.inject.Singleton;
28 
29import org.jclouds.compute.domain.NodeMetadata;
30import org.jclouds.compute.domain.NodeMetadataBuilder;
31import org.jclouds.compute.domain.Template;
32import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
33import org.jclouds.domain.Credentials;
34import org.jclouds.vcloud.domain.VCloudExpressVApp;
35import org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeClient;
36import org.jclouds.vcloud.terremark.compute.functions.TemplateToInstantiateOptions;
37import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
38 
39import com.google.common.base.Function;
40 
41/**
42 * @author Adrian Cole
43 */
44@Singleton
45public class StartVAppWithGroupEncodedIntoName implements CreateNodeWithGroupEncodedIntoName {
46   protected final TerremarkVCloudComputeClient computeClient;
47   protected final TemplateToInstantiateOptions getOptions;
48   protected final Function<VCloudExpressVApp, NodeMetadata> vAppToNodeMetadata;
49   private final Map<String, Credentials> credentialStore;
50 
51   @Inject
52   protected StartVAppWithGroupEncodedIntoName(TerremarkVCloudComputeClient computeClient,
53            Function<VCloudExpressVApp, NodeMetadata> vAppToNodeMetadata, TemplateToInstantiateOptions getOptions,
54            Map<String, Credentials> credentialStore) {
55      this.computeClient = computeClient;
56      this.vAppToNodeMetadata = vAppToNodeMetadata;
57      this.getOptions = checkNotNull(getOptions, "getOptions");
58      this.credentialStore = checkNotNull(credentialStore, "credentialStore");
59   }
60 
61   @Override
62   public NodeMetadata createNodeWithGroupEncodedIntoName(String group, String name, Template template) {
63      TerremarkInstantiateVAppTemplateOptions options = getOptions.apply(template);
64      VCloudExpressVApp vApp = computeClient.start(URI.create(template.getLocation().getId()), URI.create(template
65               .getImage().getId()), name, options, template.getOptions().getInboundPorts());
66      NodeMetadata node = vAppToNodeMetadata.apply(vApp);
67      NodeMetadataBuilder builder = NodeMetadataBuilder.fromNodeMetadata(node);
68      // TODO refactor this so that it is automatic in any provider
69      if (template.getImage().getAdminPassword() != null) {
70         builder.adminPassword(template.getImage().getAdminPassword());
71         // this is going to need refactoring.. we really need a credential list in the store per
72         // node.  we need to store the credential here explicitly, as there's no connection from a node
73         // in vcloud to the image it was created with.
74         credentialStore.put("node#" + node.getId() + "#adminPassword", new Credentials("root", template.getImage()
75                  .getAdminPassword()));
76      }
77      return builder.build();
78   }
79 
80}

[all classes][org.jclouds.vcloud.terremark.compute.strategy]
EMMA 2.0.5312 (C) Vladimir Roubtsov