EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.servermanager.compute.strategy]

COVERAGE SUMMARY FOR SOURCE FILE [ServerManagerComputeServiceAdapter.java]

nameclass, %method, %block, %line, %
ServerManagerComputeServiceAdapter.java100% (1/1)9%   (1/11)9%   (9/97)15%  (3/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ServerManagerComputeServiceAdapter100% (1/1)9%   (1/11)9%   (9/97)15%  (3/20)
createNodeWithGroupEncodedIntoNameThenStoreCredentials (String, String, Templ... 0%   (0/1)0%   (0/37)0%   (0/3)
destroyNode (String): void 0%   (0/1)0%   (0/6)0%   (0/2)
getNode (String): Server 0%   (0/1)0%   (0/8)0%   (0/2)
listHardwareProfiles (): Iterable 0%   (0/1)0%   (0/4)0%   (0/1)
listImages (): Iterable 0%   (0/1)0%   (0/4)0%   (0/1)
listLocations (): Iterable 0%   (0/1)0%   (0/7)0%   (0/1)
listNodes (): Iterable 0%   (0/1)0%   (0/4)0%   (0/1)
rebootNode (String): void 0%   (0/1)0%   (0/6)0%   (0/2)
resumeNode (String): void 0%   (0/1)0%   (0/6)0%   (0/2)
suspendNode (String): void 0%   (0/1)0%   (0/6)0%   (0/2)
ServerManagerComputeServiceAdapter (ServerManager): void 100% (1/1)100% (9/9)100% (3/3)

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.servermanager.compute.strategy;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.util.Map;
24 
25import javax.inject.Inject;
26import javax.inject.Singleton;
27 
28import org.jclouds.compute.ComputeService;
29import org.jclouds.compute.ComputeServiceAdapter;
30import org.jclouds.compute.domain.Template;
31import org.jclouds.domain.Credentials;
32import org.jclouds.servermanager.Datacenter;
33import org.jclouds.servermanager.Hardware;
34import org.jclouds.servermanager.Image;
35import org.jclouds.servermanager.Server;
36import org.jclouds.servermanager.ServerManager;
37 
38import com.google.common.collect.ImmutableSet;
39 
40/**
41 * defines the connection between the {@link ServerManager} implementation and the jclouds
42 * {@link ComputeService}
43 * 
44 */
45@Singleton
46public class ServerManagerComputeServiceAdapter implements ComputeServiceAdapter<Server, Hardware, Image, Datacenter> {
47   private final ServerManager client;
48 
49   @Inject
50   public ServerManagerComputeServiceAdapter(ServerManager client) {
51      this.client = checkNotNull(client, "client");
52   }
53 
54   @Override
55   public Server createNodeWithGroupEncodedIntoNameThenStoreCredentials(String tag, String name, Template template,
56         Map<String, Credentials> credentialStore) {
57      // create the backend object using parameters from the template.
58      Server from = client.createServerInDC(template.getLocation().getId(), name,
59            Integer.parseInt(template.getImage().getProviderId()),
60            Integer.parseInt(template.getHardware().getProviderId()));
61      // store the credentials so that later functions can use them
62      credentialStore.put(from.id + "", new Credentials(from.loginUser, from.password));
63      return from;
64   }
65 
66   @Override
67   public Iterable<Hardware> listHardwareProfiles() {
68      return client.listHardware();
69   }
70 
71   @Override
72   public Iterable<Image> listImages() {
73      return client.listImages();
74   }
75   
76   @Override
77   public Iterable<Server> listNodes() {
78      return client.listServers();
79   }
80   
81   @Override
82   public Iterable<Datacenter> listLocations() {
83      return ImmutableSet.of(new Datacenter(1, "SFO"));
84   }
85 
86   @Override
87   public Server getNode(String id) {
88      int serverId = Integer.parseInt(id);
89      return client.getServer(serverId);
90   }
91 
92   @Override
93   public void destroyNode(String id) {
94      client.destroyServer(Integer.parseInt(id));
95   }
96 
97   @Override
98   public void rebootNode(String id) {
99      client.rebootServer(Integer.parseInt(id));      
100   }
101 
102   @Override
103   public void resumeNode(String id) {
104      client.startServer(Integer.parseInt(id));      
105      
106   }
107 
108   @Override
109   public void suspendNode(String id) {
110      client.stopServer(Integer.parseInt(id));      
111   }
112}

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