EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.savvis.vpdc.domain]

COVERAGE SUMMARY FOR SOURCE FILE [VM.java]

nameclass, %method, %block, %line, %
VM.java75%  (3/4)45%  (19/42)46%  (238/521)53%  (41.9/79)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VM$10%   (0/1)0%   (0/1)0%   (0/47)0%   (0/1)
<static initializer> 0%   (0/1)0%   (0/47)0%   (0/1)
     
class VM100% (1/1)18%  (2/11)28%  (40/143)50%  (9/18)
compareTo (Resource): int 0%   (0/1)0%   (0/11)0%   (0/1)
getHref (): URI 0%   (0/1)0%   (0/3)0%   (0/1)
getNetworkConfigSections (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
getNetworkConnectionSections (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
getNetworkSection (): NetworkSection 0%   (0/1)0%   (0/3)0%   (0/1)
getStatus (): VM$Status 0%   (0/1)0%   (0/3)0%   (0/1)
getType (): String 0%   (0/1)0%   (0/3)0%   (0/1)
toBuilder (): VM$Builder 0%   (0/1)0%   (0/4)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/70)0%   (0/1)
VM (String, String, String, OperatingSystemSection, Iterable, Iterable, Multi... 100% (1/1)100% (36/36)100% (8/8)
builder (): VM$Builder 100% (1/1)100% (4/4)100% (1/1)
     
class VM$Builder100% (1/1)57%  (13/23)55%  (108/198)66%  (23/35)
additionalSection (String, Section): VM$Builder 0%   (0/1)0%   (0/8)0%   (0/1)
additionalSections (Multimap): VM$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
fromSection (Section): VM$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
fromVM (VM): VM$Builder 0%   (0/1)0%   (0/22)0%   (0/1)
fromVirtualSystem (BaseVirtualSystem): VM$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
info (String): VM$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
networkConfigSections (Iterable): VM$Builder 0%   (0/1)0%   (0/9)0%   (0/2)
networkConnectionSections (Iterable): VM$Builder 0%   (0/1)0%   (0/9)0%   (0/2)
productSections (Iterable): VM$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
virtualHardwareSections (Iterable): VM$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
VM$Builder (): void 100% (1/1)100% (9/9)100% (3/3)
build (): VM 100% (1/1)100% (30/30)100% (1/1)
href (URI): VM$Builder 100% (1/1)100% (5/5)100% (2/2)
id (String): VM$Builder 100% (1/1)100% (5/5)100% (2/2)
name (String): VM$Builder 100% (1/1)100% (5/5)100% (2/2)
networkConfigSection (NetworkConfigSection): VM$Builder 100% (1/1)100% (9/9)100% (2/2)
networkConnectionSection (NetworkConnectionSection): VM$Builder 100% (1/1)100% (9/9)100% (2/2)
networkSection (NetworkSection): VM$Builder 100% (1/1)100% (5/5)100% (2/2)
operatingSystemSection (OperatingSystemSection): VM$Builder 100% (1/1)100% (7/7)100% (1/1)
productSection (ProductSection): VM$Builder 100% (1/1)100% (7/7)100% (1/1)
status (VM$Status): VM$Builder 100% (1/1)100% (5/5)100% (2/2)
type (String): VM$Builder 100% (1/1)100% (5/5)100% (2/2)
virtualHardwareSection (VirtualHardwareSection): VM$Builder 100% (1/1)100% (7/7)100% (1/1)
     
class VM$Status100% (1/1)57%  (4/7)68%  (90/133)38%  (9.9/26)
value (): String 0%   (0/1)0%   (0/19)0%   (0/8)
valueOf (String): VM$Status 0%   (0/1)0%   (0/5)0%   (0/1)
values (): VM$Status [] 0%   (0/1)0%   (0/4)0%   (0/1)
fromValue (int): VM$Status 100% (1/1)25%  (4/16)25%  (2/8)
fromValue (String): VM$Status 100% (1/1)70%  (7/10)33%  (1/3)
<static initializer> 100% (1/1)100% (74/74)100% (7/7)
VM$Status (String, int): void 100% (1/1)100% (5/5)100% (1/1)

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.savvis.vpdc.domain;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.net.URI;
24import java.util.Set;
25 
26import org.jclouds.ovf.NetworkSection;
27import org.jclouds.ovf.OperatingSystemSection;
28import org.jclouds.ovf.ProductSection;
29import org.jclouds.ovf.Section;
30import org.jclouds.ovf.VirtualHardwareSection;
31import org.jclouds.ovf.internal.BaseVirtualSystem;
32 
33import com.google.common.collect.ImmutableSet;
34import com.google.common.collect.Multimap;
35import com.google.common.collect.Sets;
36 
37/**
38 * A virtual application (vApp) is a software solution, packaged in OVF containing one or more
39 * virtual machines. A vApp can be authored by Developers at ISVs and VARs or by IT Administrators
40 * in Enterprises and Service Providers.
41 * 
42 * @author Adrian Cole
43 */
44public class VM extends BaseVirtualSystem<VM> implements Resource {
45   /**
46    * Objects such as vAppTemplate, vApp, and Vm have a status attribute whose value indicates the
47    * state of the object. Status for an object, such as a vAppTemplate or vApp, whose Children (Vm
48    * objects) each have a status of their own, is computed from the status of the Children.
49    * 
50    * <h2>NOTE</h2>
51    * <p/>
52    * The deployment status of an object is indicated by the value of its deployed attribute.
53    * 
54    * @since vcloud api 0.8
55    * 
56    * @author Adrian Cole
57    */
58   public enum Status {
59 
60      /**
61       * When the VM is in Designing,Saved,Inqueue, has issue in pre provisioning or any exception
62       * cases. VM is not in Savvis VPDC (may the VM has been removed) or cannot get VM state due to
63       * unknown exception
64       */
65      UNRESOLVED,
66      /**
67       * When the Savvis VPDC is in Provisioning, PartiallyDeployed, Failed and the VM failed in
68       * provisioning or pending infrastructure notification
69       */
70      RESOLVED,
71      /**
72       * When the VM is deployed in vmware and powered off.
73       */
74      OFF,
75      /**
76       * We do not support suspended state.
77       */
78      SUSPENDED,
79      /**
80       * When the VM is deployed in vmware and powered on.
81       */
82      ON,
83      /**
84       * The VM is deployed in vmware but the state of VM may be Uninitialized, Start, Stop, Resume,
85       * Reset, RebootGuest, Error, Failed, Unknown, PoweringOn, PoweringOff, Suspending, Stopping,
86       * Starting, Resetting, RebootingGuest. Please call back the Get VApp Power State API after
87       * few minute.
88       */
89      UNKNOWN, UNRECOGNIZED;
90 
91      public String value() {
92         switch (this) {
93            case UNRESOLVED:
94               return "0";
95            case RESOLVED:
96               return "1";
97            case OFF:
98               return "2";
99            case SUSPENDED:
100               return "3";
101            case ON:
102               return "4";
103            case UNKNOWN:
104               return "5";
105            default:
106               return "UNRECOGNIZED";
107         }
108      }
109 
110      public static Status fromValue(String status) {
111         try {
112            return fromValue(Integer.parseInt(checkNotNull(status, "status")));
113         } catch (IllegalArgumentException e) {
114            return UNRECOGNIZED;
115         }
116      }
117 
118      public static Status fromValue(int v) {
119         switch (v) {
120            case 0:
121               return UNRESOLVED;
122            case 1:
123               return RESOLVED;
124            case 2:
125               return OFF;
126            case 3:
127               return SUSPENDED;
128            case 4:
129               return ON;
130            case 5:
131               return UNKNOWN;
132            default:
133               return UNRECOGNIZED;
134         }
135      }
136 
137   }
138 
139   public static Builder builder() {
140      return new Builder();
141   }
142 
143   public static class Builder extends BaseVirtualSystem.Builder<VM> {
144      protected String type;
145      protected URI href;
146      protected Status status;
147      protected NetworkSection networkSection;
148      protected Set<NetworkConfigSection> networkConfigSections = Sets.newLinkedHashSet();
149      protected Set<NetworkConnectionSection> networkConnectionSections = Sets.newLinkedHashSet();
150 
151      public Builder id(String id) {
152         this.id = id;
153         return this;
154      }
155 
156      public Builder name(String name) {
157         this.name = name;
158         return this;
159      }
160 
161      public Builder type(String type) {
162         this.type = type;
163         return this;
164      }
165 
166      public Builder href(URI href) {
167         this.href = href;
168         return this;
169      }
170 
171      public Builder status(Status status) {
172         this.status = status;
173         return this;
174      }
175 
176      public Builder networkSection(NetworkSection networkSection) {
177         this.networkSection = networkSection;
178         return this;
179      }
180 
181      /**
182       * @see VM#getNetworkConfigSections
183       */
184      public Builder networkConfigSection(NetworkConfigSection networkConfigSection) {
185         this.networkConfigSections.add(checkNotNull(networkConfigSection, "networkConfigSection"));
186         return this;
187      }
188 
189      /**
190       * @see VM#getNetworkConfigSections
191       */
192      public Builder networkConfigSections(Iterable<NetworkConfigSection> networkConfigSections) {
193         this.networkConfigSections = ImmutableSet.<NetworkConfigSection> copyOf(checkNotNull(networkConfigSections,
194                  "networkConfigSections"));
195         return this;
196      }
197 
198      /**
199       * @see VM#getNetworkConnectionSections
200       */
201      public Builder networkConnectionSection(NetworkConnectionSection networkConnectionSection) {
202         this.networkConnectionSections.add(checkNotNull(networkConnectionSection, "networkConnectionSection"));
203         return this;
204      }
205 
206      /**
207       * @see VM#getNetworkConnectionSections
208       */
209      public Builder networkConnectionSections(Iterable<NetworkConnectionSection> networkConnectionSections) {
210         this.networkConnectionSections = ImmutableSet.<NetworkConnectionSection> copyOf(checkNotNull(
211                  networkConnectionSections, "networkConnectionSections"));
212         return this;
213      }
214 
215      @Override
216      public VM build() {
217         return new VM(id, info, name, operatingSystem, virtualHardwareSections, productSections, additionalSections, type,
218                  href, status, networkSection, networkConfigSections, networkConnectionSections);
219      }
220 
221      public Builder fromVM(VM in) {
222         return fromVirtualSystem(in).type(in.getType()).href(in.getHref()).status(in.getStatus()).networkSection(
223                  in.getNetworkSection()).networkConfigSections(in.getNetworkConfigSections())
224                  .networkConnectionSections(in.getNetworkConnectionSections());
225      }
226 
227      /**
228       * {@inheritDoc}
229       */
230      @SuppressWarnings("unchecked")
231      @Override
232      public Builder additionalSection(String name, Section additionalSection) {
233         return Builder.class.cast(super.additionalSection(name, additionalSection));
234      }
235 
236      /**
237       * {@inheritDoc}
238       */
239      @SuppressWarnings("unchecked")
240      @Override
241      public Builder additionalSections(Multimap<String, Section> additionalSections) {
242         return Builder.class.cast(super.additionalSections(additionalSections));
243      }
244 
245      /**
246       * {@inheritDoc}
247       */
248      @Override
249      public Builder fromSection(Section<VM> in) {
250         return Builder.class.cast(super.fromSection(in));
251      }
252 
253      /**
254       * {@inheritDoc}
255       */
256      @Override
257      public Builder fromVirtualSystem(BaseVirtualSystem<VM> in) {
258         return Builder.class.cast(super.fromVirtualSystem(in));
259      }
260 
261      /**
262       * {@inheritDoc}
263       */
264      @Override
265      public Builder virtualHardwareSection(VirtualHardwareSection virtualHardwareSection) {
266         return Builder.class.cast(super.virtualHardwareSection(virtualHardwareSection));
267      }
268 
269      /**
270       * {@inheritDoc}
271       */
272      @Override
273      public Builder virtualHardwareSections(Iterable<? extends VirtualHardwareSection> virtualHardwareSections) {
274         return Builder.class.cast(super.virtualHardwareSections(virtualHardwareSections));
275      }
276 
277      /**
278       * {@inheritDoc}
279       */
280      @Override
281      public Builder info(String info) {
282         return Builder.class.cast(super.info(info));
283      }
284 
285      /**
286       * {@inheritDoc}
287       */
288      @Override
289      public Builder operatingSystemSection(OperatingSystemSection operatingSystem) {
290         return Builder.class.cast(super.operatingSystemSection(operatingSystem));
291      }
292 
293      /**
294       * {@inheritDoc}
295       */
296      @Override
297      public Builder productSection(ProductSection productSection) {
298         return Builder.class.cast(super.productSection(productSection));
299      }
300 
301      /**
302       * {@inheritDoc}
303       */
304      @Override
305      public Builder productSections(Iterable<? extends ProductSection> productSections) {
306         return Builder.class.cast(super.productSections(productSections));
307      }
308   }
309 
310   protected final String type;
311   protected final URI href;
312   protected final Status status;
313   protected final NetworkSection networkSection;
314   protected final Set<NetworkConfigSection> networkConfigSections;
315   protected final Set<NetworkConnectionSection> networkConnectionSections;
316 
317   @SuppressWarnings("unchecked")
318   public VM(String id, String info, String name, OperatingSystemSection operatingSystem,
319            Iterable<? extends VirtualHardwareSection> virtualHardwareSections,
320            Iterable<? extends ProductSection> productSections, Multimap<String, Section> additionalSections,
321            String type, URI href, Status status, NetworkSection networkSection,
322            Iterable<NetworkConfigSection> networkConfigSections,
323            Iterable<NetworkConnectionSection> networkConnectionSections) {
324      super(id, info, name, operatingSystem, virtualHardwareSections, productSections, additionalSections);
325      this.type = type;
326      this.href = href;
327      this.status = status;
328      this.networkSection = networkSection;
329      this.networkConfigSections = ImmutableSet.copyOf(checkNotNull(networkConfigSections, "networkConfigSections"));
330      this.networkConnectionSections = ImmutableSet.copyOf(checkNotNull(networkConnectionSections,
331               "networkConnectionSections"));
332   }
333 
334   public Status getStatus() {
335      return status;
336   }
337 
338   public NetworkSection getNetworkSection() {
339      return networkSection;
340   }
341 
342   public Set<NetworkConfigSection> getNetworkConfigSections() {
343      return networkConfigSections;
344   }
345 
346   public Set<NetworkConnectionSection> getNetworkConnectionSections() {
347      return networkConnectionSections;
348   }
349 
350   public String getType() {
351      return type;
352   }
353 
354   public URI getHref() {
355      return href;
356   }
357 
358   @Override
359   public String toString() {
360      return String
361               .format(
362                        "[id=%s, name=%s, info=%s, href=%s,status=%s, type=%s, virtualHardwareSections=%s, operatingSystem=%s, productSections=%s, networkSection=%s,  networkConfigSections=%s, networkConnectionSections=%s, additionalSections=%s]",
363                        id, name, info, href, status, type, virtualHardwareSections, operatingSystem, productSections,
364                        networkSection, networkConfigSections, networkConnectionSections, additionalSections);
365   }
366 
367   @Override
368   public int compareTo(Resource that) {
369      return (this == that) ? 0 : getHref().compareTo(that.getHref());
370   }
371 
372   public Builder toBuilder() {
373      return builder().fromVM(this);
374   }
375 
376}

[all classes][org.jclouds.savvis.vpdc.domain]
EMMA 2.0.5312 (C) Vladimir Roubtsov