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

COVERAGE SUMMARY FOR SOURCE FILE [VCloudExpressVAppToNodeMetadata.java]

nameclass, %method, %block, %line, %
VCloudExpressVAppToNodeMetadata.java0%   (0/1)0%   (0/2)0%   (0/144)0%   (0/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VCloudExpressVAppToNodeMetadata0%   (0/1)0%   (0/2)0%   (0/144)0%   (0/21)
VCloudExpressVAppToNodeMetadata (VCloudExpressComputeClient, Map, Map, Hardwa... 0%   (0/1)0%   (0/39)0%   (0/8)
apply (VCloudExpressVApp): NodeMetadata 0%   (0/1)0%   (0/105)0%   (0/13)

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.functions;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName;
23 
24import java.util.Map;
25import java.util.Set;
26 
27import javax.inject.Inject;
28import javax.inject.Singleton;
29 
30import org.jclouds.cim.OSType;
31import org.jclouds.collect.Memoized;
32import org.jclouds.compute.domain.CIMOperatingSystem;
33import org.jclouds.compute.domain.Image;
34import org.jclouds.compute.domain.NodeMetadata;
35import org.jclouds.compute.domain.NodeMetadataBuilder;
36import org.jclouds.compute.domain.NodeState;
37import org.jclouds.domain.Credentials;
38import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
39import org.jclouds.vcloud.domain.Status;
40import org.jclouds.vcloud.domain.VCloudExpressVApp;
41 
42import com.google.common.base.Function;
43import com.google.common.base.Supplier;
44 
45/**
46 * @author Adrian Cole
47 */
48@Singleton
49public class VCloudExpressVAppToNodeMetadata implements Function<VCloudExpressVApp, NodeMetadata> {
50 
51   protected final VCloudExpressComputeClient computeClient;
52   protected final Map<String, Credentials> credentialStore;
53   protected final Supplier<Set<? extends Image>> images;
54   protected final FindLocationForResource findLocationForResourceInVDC;
55   protected final HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp;
56   protected final Map<Status, NodeState> vAppStatusToNodeState;
57 
58   @Inject
59   protected VCloudExpressVAppToNodeMetadata(VCloudExpressComputeClient computeClient,
60            Map<String, Credentials> credentialStore, Map<Status, NodeState> vAppStatusToNodeState,
61            HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp,
62            FindLocationForResource findLocationForResourceInVDC, @Memoized Supplier<Set<? extends Image>> images) {
63      this.images = checkNotNull(images, "images");
64      this.hardwareForVCloudExpressVApp = checkNotNull(hardwareForVCloudExpressVApp, "hardwareForVCloudExpressVApp");
65      this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC");
66      this.credentialStore = checkNotNull(credentialStore, "credentialStore");
67      this.computeClient = checkNotNull(computeClient, "computeClient");
68      this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState");
69   }
70 
71   @Override
72   public NodeMetadata apply(VCloudExpressVApp from) {
73      NodeMetadataBuilder builder = new NodeMetadataBuilder();
74      builder.ids(from.getHref().toASCIIString());
75      builder.uri(from.getHref());
76      builder.name(from.getName());
77      builder.location(findLocationForResourceInVDC.apply(from.getVDC()));
78      builder.group(parseGroupFromName(from.getName()));
79      builder.operatingSystem(from.getOsType() != null ? new CIMOperatingSystem(OSType
80               .fromValue(from.getOsType()), null, null, from.getOperatingSystemDescription()) : null);
81      builder.hardware(hardwareForVCloudExpressVApp.apply(from));
82      builder.state(vAppStatusToNodeState.get(from.getStatus()));
83      builder.publicAddresses(computeClient.getPublicAddresses(from.getHref()));
84      builder.privateAddresses(computeClient.getPrivateAddresses(from.getHref()));
85      builder.credentials(credentialStore.get("node#" + from.getHref().toASCIIString()));
86      return builder.build();
87   }
88}

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