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

COVERAGE SUMMARY FOR SOURCE FILE [StartVAppWithGroupEncodedIntoName.java]

nameclass, %method, %block, %line, %
StartVAppWithGroupEncodedIntoName.java0%   (0/1)0%   (0/2)0%   (0/68)0%   (0/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StartVAppWithGroupEncodedIntoName0%   (0/1)0%   (0/2)0%   (0/68)0%   (0/10)
StartVAppWithGroupEncodedIntoName (VCloudExpressClient, VCloudExpressComputeC... 0%   (0/1)0%   (0/12)0%   (0/5)
createNodeWithGroupEncodedIntoName (String, String, Template): NodeMetadata 0%   (0/1)0%   (0/56)0%   (0/5)

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.compute.strategy;
20 
21import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
22import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
23 
24import java.net.URI;
25 
26import javax.inject.Inject;
27import javax.inject.Singleton;
28 
29import org.jclouds.compute.domain.NodeMetadata;
30import org.jclouds.compute.domain.Template;
31import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
32import org.jclouds.vcloud.VCloudExpressClient;
33import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
34import org.jclouds.vcloud.domain.VCloudExpressVApp;
35import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
36 
37import com.google.common.base.Function;
38 
39/**
40 * @author Adrian Cole
41 */
42@Singleton
43public class StartVAppWithGroupEncodedIntoName implements CreateNodeWithGroupEncodedIntoName {
44   protected final VCloudExpressClient client;
45   protected final VCloudExpressComputeClient computeClient;
46   protected final Function<VCloudExpressVApp, NodeMetadata> vAppToNodeMetadata;
47 
48   @Inject
49   protected StartVAppWithGroupEncodedIntoName(VCloudExpressClient client, VCloudExpressComputeClient computeClient,
50         Function<VCloudExpressVApp, NodeMetadata> vAppToNodeMetadata) {
51      this.client = client;
52      this.computeClient = computeClient;
53      this.vAppToNodeMetadata = vAppToNodeMetadata;
54   }
55 
56   @Override
57   public NodeMetadata createNodeWithGroupEncodedIntoName(String tag, String name, Template template) {
58      InstantiateVAppTemplateOptions options = processorCount((int) getCores(template.getHardware())).memory(
59            template.getHardware().getRam()).disk(
60            (long) ((template.getHardware().getVolumes().get(0).getSize()) * 1024 * 1024l));
61      if (!template.getOptions().shouldBlockUntilRunning())
62         options.block(false);
63      VCloudExpressVApp vApp = computeClient.start(URI.create(template.getLocation().getId()),
64            URI.create(template.getImage().getId()), name, options, template.getOptions().getInboundPorts());
65      return vAppToNodeMetadata.apply(vApp);
66   }
67 
68}

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