EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.trmk.vcloud_0_8.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 * 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 */
19package org.jclouds.trmk.vcloud_0_8.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.trmk.vcloud_0_8.compute.TerremarkVCloudComputeClient;
35import org.jclouds.trmk.vcloud_0_8.compute.functions.TemplateToInstantiateOptions;
36import org.jclouds.trmk.vcloud_0_8.domain.VApp;
37import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions;
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<VApp, NodeMetadata> vAppToNodeMetadata;
49   private final Map<String, Credentials> credentialStore;
50 
51   @Inject
52   protected StartVAppWithGroupEncodedIntoName(TerremarkVCloudComputeClient computeClient,
53            Function<VApp, 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      InstantiateVAppTemplateOptions options = getOptions.apply(template);
64      VApp 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.trmk.vcloud_0_8.compute.strategy]
EMMA 2.0.5312 (C) Vladimir Roubtsov