EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.trmk.vcloud_0_8.options]

COVERAGE SUMMARY FOR SOURCE FILE [InstantiateVAppTemplateOptions.java]

nameclass, %method, %block, %line, %
InstantiateVAppTemplateOptions.java100% (3/3)61%  (31/51)45%  (313/695)49%  (78.6/162)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InstantiateVAppTemplateOptions$NetworkConfig100% (1/1)75%  (6/8)44%  (73/166)40%  (15.9/40)
equals (Object): boolean 0%   (0/1)0%   (0/69)0%   (0/23)
toString (): String 0%   (0/1)0%   (0/22)0%   (0/1)
hashCode (): int 100% (1/1)96%  (43/45)98%  (5.9/6)
InstantiateVAppTemplateOptions$NetworkConfig (String, URI, FenceMode): void 100% (1/1)100% (15/15)100% (5/5)
InstantiateVAppTemplateOptions$NetworkConfig (URI): void 100% (1/1)100% (6/6)100% (2/2)
getFenceMode (): FenceMode 100% (1/1)100% (3/3)100% (1/1)
getNetworkName (): String 100% (1/1)100% (3/3)100% (1/1)
getParentNetwork (): URI 100% (1/1)100% (3/3)100% (1/1)
     
class InstantiateVAppTemplateOptions100% (1/1)67%  (18/27)45%  (182/403)53%  (48.9/92)
block (boolean): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/5)0%   (0/2)
deploy (boolean): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/5)0%   (0/2)
hashCode (): int 0%   (0/1)0%   (0/91)0%   (0/10)
powerOn (boolean): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/5)0%   (0/2)
primaryDNS (String): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/7)0%   (0/2)
productProperties (Map): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/6)0%   (0/2)
secondaryDNS (String): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/7)0%   (0/2)
sshKeyFingerprint (String): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/7)0%   (0/2)
toString (): String 0%   (0/1)0%   (0/37)0%   (0/1)
equals (Object): boolean 100% (1/1)54%  (57/106)47%  (16/34)
processorCount (int): InstantiateVAppTemplateOptions 100% (1/1)95%  (19/20)98%  (3/3)
memory (long): InstantiateVAppTemplateOptions 100% (1/1)95%  (20/21)98%  (3/3)
InstantiateVAppTemplateOptions (): void 100% (1/1)100% (18/18)100% (7/7)
addNetworkConfig (InstantiateVAppTemplateOptions$NetworkConfig): InstantiateV... 100% (1/1)100% (9/9)100% (2/2)
customizeOnInstantiate (boolean): InstantiateVAppTemplateOptions 100% (1/1)100% (6/6)100% (2/2)
getCpuCount (): String 100% (1/1)100% (3/3)100% (1/1)
getMemorySizeMegabytes (): String 100% (1/1)100% (3/3)100% (1/1)
getNetworkConfig (): Set 100% (1/1)100% (3/3)100% (1/1)
getProperties (): Map 100% (1/1)100% (3/3)100% (1/1)
inGroup (String): InstantiateVAppTemplateOptions 100% (1/1)100% (7/7)100% (2/2)
inRow (String): InstantiateVAppTemplateOptions 100% (1/1)100% (7/7)100% (2/2)
productProperty (String, String): InstantiateVAppTemplateOptions 100% (1/1)100% (8/8)100% (2/2)
shouldBlock (): boolean 100% (1/1)100% (3/3)100% (1/1)
shouldCustomizeOnInstantiate (): Boolean 100% (1/1)100% (3/3)100% (1/1)
shouldDeploy (): boolean 100% (1/1)100% (3/3)100% (1/1)
shouldPowerOn (): boolean 100% (1/1)100% (3/3)100% (1/1)
withPassword (String): InstantiateVAppTemplateOptions 100% (1/1)100% (7/7)100% (2/2)
     
class InstantiateVAppTemplateOptions$Builder100% (1/1)44%  (7/16)46%  (58/126)45%  (14/31)
InstantiateVAppTemplateOptions$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
block (boolean): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
deploy (boolean): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
powerOn (boolean): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
primaryDNS (String): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
productProperties (Map): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
productProperty (String, String): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/9)0%   (0/2)
secondaryDNS (String): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
sshKeyFingerprint (String): InstantiateVAppTemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
addNetworkConfig (InstantiateVAppTemplateOptions$NetworkConfig): InstantiateV... 100% (1/1)100% (8/8)100% (2/2)
customizeOnInstantiate (Boolean): InstantiateVAppTemplateOptions 100% (1/1)100% (9/9)100% (2/2)
inGroup (String): InstantiateVAppTemplateOptions 100% (1/1)100% (8/8)100% (2/2)
inRow (String): InstantiateVAppTemplateOptions 100% (1/1)100% (8/8)100% (2/2)
memory (int): InstantiateVAppTemplateOptions 100% (1/1)100% (9/9)100% (2/2)
processorCount (int): InstantiateVAppTemplateOptions 100% (1/1)100% (8/8)100% (2/2)
withPassword (String): InstantiateVAppTemplateOptions 100% (1/1)100% (8/8)100% (2/2)

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.options;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22import static com.google.common.base.Preconditions.checkNotNull;
23 
24import java.net.URI;
25import java.util.Map;
26import java.util.Set;
27 
28import org.jclouds.javax.annotation.Nullable;
29 
30import org.jclouds.ovf.NetworkSection;
31import org.jclouds.trmk.vcloud_0_8.domain.FenceMode;
32 
33import com.google.common.collect.Maps;
34import com.google.common.collect.Sets;
35 
36/**
37 * 
38 * @author Adrian Cole
39 * 
40 */
41public class InstantiateVAppTemplateOptions {
42   public static class NetworkConfig {
43      @Nullable
44      private final String networkName;
45      private final URI parentNetwork;
46      @Nullable
47      private final FenceMode fenceMode;
48 
49      /**
50       * 
51       * Create a new NetworkConfig.
52       * 
53       * @param networkName
54       *           a valid {@networkConfig
55       *           org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection
56       *           network in the vapp template}, or null to have us choose
57       *           default
58       * @param parentNetwork
59       *           a valid {@networkConfig
60       *           org.jclouds.vcloud.domain.Org#getNetworks in the Org}
61       * @param fenceMode
62       *           how to manage the relationship between the two networks
63       */
64      public NetworkConfig(String networkName, URI parentNetwork, FenceMode fenceMode) {
65         this.networkName = networkName;
66         this.parentNetwork = checkNotNull(parentNetwork, "parentNetwork");
67         this.fenceMode = fenceMode;
68      }
69 
70      public NetworkConfig(URI parentNetwork) {
71         this(null, parentNetwork, null);
72      }
73 
74      /**
75       * A name for the network. If the
76       * {@link org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection}
77       * includes a {@link NetworkSection.Network} network element, the name you
78       * specify for the vApp network must match the name specified in that
79       * element's name attribute.
80       * 
81       * @return
82       */
83      public String getNetworkName() {
84         return networkName;
85      }
86 
87      /**
88       * 
89       * @return A reference to the organization network to which this network
90       *         connects.
91       */
92      public URI getParentNetwork() {
93         return parentNetwork;
94      }
95 
96      /**
97       * A value of bridged indicates that this vApp network is connected
98       * directly to the organization network.
99       */
100      public FenceMode getFenceMode() {
101         return fenceMode;
102      }
103 
104      @Override
105      public int hashCode() {
106         final int prime = 31;
107         int result = 1;
108         result = prime * result + ((fenceMode == null) ? 0 : fenceMode.hashCode());
109         result = prime * result + ((parentNetwork == null) ? 0 : parentNetwork.hashCode());
110         result = prime * result + ((networkName == null) ? 0 : networkName.hashCode());
111         return result;
112      }
113 
114      @Override
115      public boolean equals(Object obj) {
116         if (this == obj)
117            return true;
118         if (obj == null)
119            return false;
120         if (getClass() != obj.getClass())
121            return false;
122         NetworkConfig other = (NetworkConfig) obj;
123         if (fenceMode == null) {
124            if (other.fenceMode != null)
125               return false;
126         } else if (!fenceMode.equals(other.fenceMode))
127            return false;
128         if (parentNetwork == null) {
129            if (other.parentNetwork != null)
130               return false;
131         } else if (!parentNetwork.equals(other.parentNetwork))
132            return false;
133         if (networkName == null) {
134            if (other.networkName != null)
135               return false;
136         } else if (!networkName.equals(other.networkName))
137            return false;
138         return true;
139      }
140 
141      @Override
142      public String toString() {
143         return "[networkName=" + networkName + ", parentNetwork=" + parentNetwork + ", fenceMode=" + fenceMode + "]";
144      }
145   }
146 
147   private Set<NetworkConfig> networkConfig = Sets.newLinkedHashSet();
148 
149   private Boolean customizeOnInstantiate;
150   private String cpuCount;
151   private String memorySizeMegabytes;
152 
153   private boolean block = true;
154   private boolean deploy = true;
155   private boolean powerOn = true;
156 
157   private final Map<String, String> properties = Maps.newLinkedHashMap();
158 
159   public InstantiateVAppTemplateOptions sshKeyFingerprint(String sshKeyFingerprint) {
160      productProperty("sshKeyFingerprint", sshKeyFingerprint);
161      return this;
162   }
163 
164   public InstantiateVAppTemplateOptions primaryDNS(String primaryDNS) {
165      productProperty("primaryDNS", primaryDNS);
166      return this;
167   }
168 
169   public InstantiateVAppTemplateOptions secondaryDNS(String secondaryDNS) {
170      productProperty("secondaryDNS", secondaryDNS);
171      return this;
172   }
173 
174   public InstantiateVAppTemplateOptions withPassword(String password) {
175      productProperty("password", password);
176      return this;
177   }
178 
179   public InstantiateVAppTemplateOptions inGroup(String group) {
180      productProperty("group", group);
181      return this;
182   }
183 
184   public InstantiateVAppTemplateOptions inRow(String row) {
185      productProperty("row", row);
186      return this;
187   }
188 
189   public InstantiateVAppTemplateOptions productProperties(Map<String, String> properties) {
190      this.properties.putAll(properties);
191      return this;
192   }
193 
194   public InstantiateVAppTemplateOptions productProperty(String key, String value) {
195      this.properties.put(key, value);
196      return this;
197   }
198 
199   public Map<String, String> getProperties() {
200      return properties;
201   }
202 
203   public boolean shouldBlock() {
204      return block;
205   }
206 
207   public boolean shouldDeploy() {
208      return deploy;
209   }
210 
211   public boolean shouldPowerOn() {
212      return powerOn;
213   }
214 
215   /**
216    * deploy the vapp after it is instantiated?
217    */
218   public InstantiateVAppTemplateOptions deploy(boolean deploy) {
219      this.deploy = deploy;
220      return this;
221   }
222 
223   /**
224    * powerOn the vapp after it is instantiated?
225    */
226   public InstantiateVAppTemplateOptions powerOn(boolean powerOn) {
227      this.powerOn = powerOn;
228      return this;
229   }
230 
231   /**
232    * block until instantiate or deployment operations complete?
233    */
234   public InstantiateVAppTemplateOptions block(boolean block) {
235      this.block = block;
236      return this;
237   }
238 
239   /**
240    * If true, then customization is executed for all children that include a
241    * GuestCustomizationSection.
242    */
243   public InstantiateVAppTemplateOptions customizeOnInstantiate(boolean customizeOnInstantiate) {
244      this.customizeOnInstantiate = customizeOnInstantiate;
245      return this;
246   }
247 
248   public InstantiateVAppTemplateOptions processorCount(int cpuCount) {
249      checkArgument(cpuCount >= 1, "cpuCount must be positive");
250      this.cpuCount = cpuCount + "";
251      return this;
252   }
253 
254   public InstantiateVAppTemplateOptions memory(long megabytes) {
255      checkArgument(megabytes >= 1, "megabytes must be positive");
256      this.memorySizeMegabytes = megabytes + "";
257      return this;
258   }
259 
260   /**
261    * {@networkConfig VAppTemplate}s have internal networks that can be
262    * connected in order to access the internet or other external networks.
263    * 
264    * <h4>default behaviour if you don't use this option</h4> By default, we
265    * connect the first internal {@networkConfig
266    * org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection network in the
267    * vapp template}to a default chosen from the org or specified via
268    * {@networkConfig
269    * org.jclouds.vcloud.reference.VCloudConstants#
270    * PROPERTY_VCLOUD_DEFAULT_NETWORK} using the {@networkConfig
271    *  org.jclouds.vcloud.domain.FenceMode#BRIDGED} or an
272    * override set by the property {@networkConfig
273    * org.jclouds.vcloud.reference.VCloudConstants#
274    * PROPERTY_VCLOUD_DEFAULT_FENCEMODE}.
275    */
276   public InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
277      this.networkConfig.add(checkNotNull(networkConfig, "networkConfig"));
278      return this;
279   }
280 
281   public Set<NetworkConfig> getNetworkConfig() {
282      return networkConfig;
283   }
284 
285   public String getCpuCount() {
286      return cpuCount;
287   }
288 
289   public Boolean shouldCustomizeOnInstantiate() {
290      return customizeOnInstantiate;
291   }
292 
293   public String getMemorySizeMegabytes() {
294      return memorySizeMegabytes;
295   }
296 
297   public static class Builder {
298 
299      /**
300       * @see InstantiateVAppTemplateOptions#block
301       */
302      public static InstantiateVAppTemplateOptions block(boolean block) {
303         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
304         return options.block(block);
305      }
306 
307      /**
308       * @see InstantiateVAppTemplateOptions#deploy
309       */
310      public static InstantiateVAppTemplateOptions deploy(boolean deploy) {
311         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
312         return options.deploy(deploy);
313      }
314 
315      /**
316       * @see InstantiateVAppTemplateOptions#powerOn
317       */
318      public static InstantiateVAppTemplateOptions powerOn(boolean powerOn) {
319         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
320         return options.powerOn(powerOn);
321      }
322 
323      /**
324       * @see InstantiateVAppTemplateOptions#processorCount(int)
325       */
326      public static InstantiateVAppTemplateOptions processorCount(int cpuCount) {
327         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
328         return options.processorCount(cpuCount);
329      }
330 
331      /**
332       * @see InstantiateVAppTemplateOptions#customizeOnInstantiate
333       */
334      public static InstantiateVAppTemplateOptions customizeOnInstantiate(Boolean customizeOnInstantiate) {
335         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
336         return options.customizeOnInstantiate(customizeOnInstantiate);
337      }
338 
339      /**
340       * @see InstantiateVAppTemplateOptions#memory(int)
341       */
342      public static InstantiateVAppTemplateOptions memory(int megabytes) {
343         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
344         return options.memory(megabytes);
345      }
346 
347      /**
348       * @see InstantiateVAppTemplateOptions#addNetworkConfig
349       */
350      public static InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
351         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
352         return options.addNetworkConfig(networkConfig);
353      }
354 
355      /**
356       * @see InstantiateVAppTemplateOptions#withPassword(String)
357       */
358      public static InstantiateVAppTemplateOptions withPassword(String password) {
359         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
360         return options.withPassword(password);
361      }
362 
363      /**
364       * @see InstantiateVAppTemplateOptions#inGroup(String)
365       */
366      public static InstantiateVAppTemplateOptions inGroup(String group) {
367         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
368         return options.inGroup(group);
369      }
370 
371      /**
372       * @see InstantiateVAppTemplateOptions#inRow(String)
373       */
374      public static InstantiateVAppTemplateOptions inRow(String row) {
375         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
376         return options.inRow(row);
377      }
378 
379      /**
380       * @see InstantiateVAppTemplateOptions#sshKeyFingerprint(String)
381       */
382      public static InstantiateVAppTemplateOptions sshKeyFingerprint(String sshKeyFingerprint) {
383         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
384         return options.sshKeyFingerprint(sshKeyFingerprint);
385      }
386 
387      /**
388       * @see InstantiateVAppTemplateOptions#primaryDNS(String)
389       */
390      public static InstantiateVAppTemplateOptions primaryDNS(String primaryDNS) {
391         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
392         return options.primaryDNS(primaryDNS);
393      }
394 
395      /**
396       * @see InstantiateVAppTemplateOptions#secondaryDNS(String)
397       */
398      public static InstantiateVAppTemplateOptions secondaryDNS(String secondaryDNS) {
399         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
400         return options.secondaryDNS(secondaryDNS);
401      }
402 
403      /**
404       * @see InstantiateVAppTemplateOptions#productProperty(String, String)
405       */
406      public static InstantiateVAppTemplateOptions productProperty(String key, String value) {
407         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
408         return (InstantiateVAppTemplateOptions) options.productProperty(key, value);
409      }
410 
411      /**
412       * @see InstantiateVAppTemplateOptions#productProperties(Map<String ,
413       *      String>)
414       */
415      public static InstantiateVAppTemplateOptions productProperties(Map<String, String> properties) {
416         InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
417         return (InstantiateVAppTemplateOptions) options.productProperties(properties);
418      }
419 
420   }
421 
422   @Override
423   public String toString() {
424      return "[cpuCount=" + cpuCount + ", memorySizeMegabytes=" + memorySizeMegabytes + ", networkConfig="
425            + networkConfig + ", customizeOnInstantiate=" + customizeOnInstantiate + ", deploy=" + (deploy)
426            + ", powerOn=" + (powerOn) + "]";
427   }
428 
429   @Override
430   public int hashCode() {
431      final int prime = 31;
432      int result = 1;
433      result = prime * result + (block ? 1231 : 1237);
434      result = prime * result + ((cpuCount == null) ? 0 : cpuCount.hashCode());
435      result = prime * result + ((customizeOnInstantiate == null) ? 0 : customizeOnInstantiate.hashCode());
436      result = prime * result + (deploy ? 1231 : 1237);
437      result = prime * result + ((memorySizeMegabytes == null) ? 0 : memorySizeMegabytes.hashCode());
438      result = prime * result + ((networkConfig == null) ? 0 : networkConfig.hashCode());
439      result = prime * result + (powerOn ? 1231 : 1237);
440      return result;
441   }
442 
443   @Override
444   public boolean equals(Object obj) {
445      if (this == obj)
446         return true;
447      if (obj == null)
448         return false;
449      if (getClass() != obj.getClass())
450         return false;
451      InstantiateVAppTemplateOptions other = (InstantiateVAppTemplateOptions) obj;
452      if (block != other.block)
453         return false;
454      if (cpuCount == null) {
455         if (other.cpuCount != null)
456            return false;
457      } else if (!cpuCount.equals(other.cpuCount))
458         return false;
459      if (customizeOnInstantiate == null) {
460         if (other.customizeOnInstantiate != null)
461            return false;
462      } else if (!customizeOnInstantiate.equals(other.customizeOnInstantiate))
463         return false;
464      if (deploy != other.deploy)
465         return false;
466      if (memorySizeMegabytes == null) {
467         if (other.memorySizeMegabytes != null)
468            return false;
469      } else if (!memorySizeMegabytes.equals(other.memorySizeMegabytes))
470         return false;
471      if (networkConfig == null) {
472         if (other.networkConfig != null)
473            return false;
474      } else if (!networkConfig.equals(other.networkConfig))
475         return false;
476      if (powerOn != other.powerOn)
477         return false;
478      return true;
479   }
480 
481}

[all classes][org.jclouds.trmk.vcloud_0_8.options]
EMMA 2.0.5312 (C) Vladimir Roubtsov