EMMA Coverage Report (generated Wed Aug 10 12:30:04 EDT 2011)
[all classes][org.jclouds.aws.ec2.compute]

COVERAGE SUMMARY FOR SOURCE FILE [AWSEC2TemplateOptions.java]

nameclass, %method, %block, %line, %
AWSEC2TemplateOptions.java100% (2/2)36%  (26/73)25%  (210/849)26%  (45.8/175)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AWSEC2TemplateOptions100% (1/1)31%  (15/48)18%  (117/645)19%  (24/127)
authorizePublicKey (Payload): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
blockDeviceMappings (Iterable): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
blockUntilRunning (boolean): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
clone (): AWSEC2TemplateOptions 0%   (0/1)0%   (0/9)0%   (0/3)
copyTo (TemplateOptions): void 0%   (0/1)0%   (0/65)0%   (0/18)
dontAuthorizePublicKey (): AWSEC2TemplateOptions 0%   (0/1)0%   (0/6)0%   (0/1)
equals (Object): boolean 0%   (0/1)0%   (0/101)0%   (0/32)
getPlacementGroup (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getSpotOptions (): RequestSpotInstancesOptions 0%   (0/1)0%   (0/3)0%   (0/1)
getSpotPrice (): Float 0%   (0/1)0%   (0/3)0%   (0/1)
getSubnetId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/81)0%   (0/9)
installPrivateKey (Payload): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
mapEBSSnapshotToDeviceName (String, String, Integer, boolean): AWSEC2Template... 0%   (0/1)0%   (0/10)0%   (0/1)
mapEphemeralDeviceToDeviceName (String, String): AWSEC2TemplateOptions 0%   (0/1)0%   (0/8)0%   (0/1)
mapNewVolumeToDeviceName (String, int, boolean): AWSEC2TemplateOptions 0%   (0/1)0%   (0/9)0%   (0/1)
nameTask (String): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
noPlacementGroup (): AWSEC2TemplateOptions 0%   (0/1)0%   (0/13)0%   (0/3)
overrideCredentialsWith (Credentials): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
placementGroup (String): AWSEC2TemplateOptions 0%   (0/1)0%   (0/20)0%   (0/5)
runAsRoot (boolean): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
runScript (Payload): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
runScript (Statement): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
runScript (byte []): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
setGroupIds (Set): void 0%   (0/1)0%   (0/4)0%   (0/2)
shouldAutomaticallyCreatePlacementGroup (): boolean 0%   (0/1)0%   (0/7)0%   (0/1)
spotOptions (RequestSpotInstancesOptions): AWSEC2TemplateOptions 0%   (0/1)0%   (0/9)0%   (0/2)
spotPrice (Float): AWSEC2TemplateOptions 0%   (0/1)0%   (0/5)0%   (0/2)
subnetId (String): AWSEC2TemplateOptions 0%   (0/1)0%   (0/12)0%   (0/4)
toString (): String 0%   (0/1)0%   (0/67)0%   (0/1)
unmapDeviceNamed (String): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
userData (byte []): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
withMetadata (): AWSEC2TemplateOptions 0%   (0/1)0%   (0/6)0%   (0/1)
<static initializer> 100% (1/1)100% (5/5)100% (1/1)
AWSEC2TemplateOptions (): void 100% (1/1)100% (12/12)100% (5/5)
authorizePublicKey (String): AWSEC2TemplateOptions 100% (1/1)100% (7/7)100% (1/1)
blockOnPort (int, int): AWSEC2TemplateOptions 100% (1/1)100% (8/8)100% (1/1)
enableMonitoring (): AWSEC2TemplateOptions 100% (1/1)100% (5/5)100% (2/2)
getGroupIds (): Set 100% (1/1)100% (3/3)100% (1/1)
inboundPorts (int []): AWSEC2TemplateOptions 100% (1/1)100% (7/7)100% (1/1)
installPrivateKey (String): AWSEC2TemplateOptions 100% (1/1)100% (7/7)100% (1/1)
isMonitoringEnabled (): boolean 100% (1/1)100% (3/3)100% (1/1)
keyPair (String): AWSEC2TemplateOptions 100% (1/1)100% (7/7)100% (1/1)
noKeyPair (): AWSEC2TemplateOptions 100% (1/1)100% (6/6)100% (1/1)
securityGroupIds (Iterable): AWSEC2TemplateOptions 100% (1/1)100% (28/28)100% (5/5)
securityGroupIds (String []): AWSEC2TemplateOptions 100% (1/1)100% (5/5)100% (1/1)
securityGroups (Iterable): AWSEC2TemplateOptions 100% (1/1)100% (7/7)100% (1/1)
securityGroups (String []): AWSEC2TemplateOptions 100% (1/1)100% (7/7)100% (1/1)
     
class AWSEC2TemplateOptions$Builder100% (1/1)44%  (11/25)46%  (93/204)45%  (22/49)
AWSEC2TemplateOptions$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
blockDeviceMappings (Set): AWSEC2TemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
mapEBSSnapshotToDeviceName (String, String, Integer, boolean): AWSEC2Template... 0%   (0/1)0%   (0/11)0%   (0/2)
mapEphemeralDeviceToDeviceName (String, String): AWSEC2TemplateOptions 0%   (0/1)0%   (0/9)0%   (0/2)
mapNewVolumeToDeviceName (String, int, boolean): AWSEC2TemplateOptions 0%   (0/1)0%   (0/10)0%   (0/2)
noPlacementGroup (): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/2)
placementGroup (String): AWSEC2TemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
runScript (byte []): AWSEC2TemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
spotOptions (RequestSpotInstancesOptions): AWSEC2TemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
spotPrice (Float): AWSEC2TemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
subnetId (String): AWSEC2TemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
unmapDeviceNamed (String): AWSEC2TemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
userData (byte []): AWSEC2TemplateOptions 0%   (0/1)0%   (0/8)0%   (0/2)
withDetails (): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/2)
authorizePublicKey (String): AWSEC2TemplateOptions 100% (1/1)100% (8/8)100% (2/2)
blockOnPort (int, int): AWSEC2TemplateOptions 100% (1/1)100% (9/9)100% (2/2)
enableMonitoring (): AWSEC2TemplateOptions 100% (1/1)100% (7/7)100% (2/2)
inboundPorts (int []): AWSEC2TemplateOptions 100% (1/1)100% (8/8)100% (2/2)
installPrivateKey (String): AWSEC2TemplateOptions 100% (1/1)100% (8/8)100% (2/2)
keyPair (String): AWSEC2TemplateOptions 100% (1/1)100% (8/8)100% (2/2)
noKeyPair (): AWSEC2TemplateOptions 100% (1/1)100% (7/7)100% (2/2)
securityGroupIds (Iterable): AWSEC2TemplateOptions 100% (1/1)100% (11/11)100% (2/2)
securityGroupIds (String []): AWSEC2TemplateOptions 100% (1/1)100% (11/11)100% (2/2)
securityGroups (Iterable): AWSEC2TemplateOptions 100% (1/1)100% (8/8)100% (2/2)
securityGroups (String []): AWSEC2TemplateOptions 100% (1/1)100% (8/8)100% (2/2)

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.aws.ec2.compute;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22import static com.google.common.base.Preconditions.checkNotNull;
23import static com.google.common.base.Preconditions.checkState;
24 
25import java.util.Arrays;
26import java.util.Set;
27 
28import javax.annotation.Nullable;
29 
30import org.jclouds.aws.ec2.options.RequestSpotInstancesOptions;
31import org.jclouds.compute.options.TemplateOptions;
32import org.jclouds.domain.Credentials;
33import org.jclouds.ec2.compute.options.EC2TemplateOptions;
34import org.jclouds.ec2.domain.BlockDeviceMapping;
35import org.jclouds.io.Payload;
36import org.jclouds.scriptbuilder.domain.Statement;
37import org.jclouds.util.Preconditions2;
38 
39import com.google.common.collect.ImmutableSet;
40import com.google.common.collect.Iterables;
41 
42/**
43 * Contains options supported in the {@code ComputeService#runNode} operation on the "ec2" provider.
44 * <h2>
45 * Usage</h2> The recommended way to instantiate a AWSEC2TemplateOptions object is to statically
46 * import AWSEC2TemplateOptions.* and invoke a static creation method followed by an instance
47 * mutator (if needed):
48 * <p/>
49 * <code>
50 * import static org.jclouds.aws.ec2.compute.options.AWSEC2TemplateOptions.Builder.*;
51 * <p/>
52 * ComputeService client = // get connection
53 * templateBuilder.options(inboundPorts(22, 80, 8080, 443));
54 * Set<? extends NodeMetadata> set = client.runNodesWithTag(tag, 2, templateBuilder.build());
55 * <code>
56 * 
57 * @author Adrian Cole
58 */
59public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneable {
60   @Override
61   public AWSEC2TemplateOptions clone() {
62      AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
63      copyTo(options);
64      return options;
65   }
66 
67   @Override
68   public void copyTo(TemplateOptions to) {
69      super.copyTo(to);
70      if (to instanceof AWSEC2TemplateOptions) {
71         AWSEC2TemplateOptions eTo = AWSEC2TemplateOptions.class.cast(to);
72         if (getSubnetId() != null)
73            eTo.subnetId(getSubnetId());
74         if (isMonitoringEnabled())
75            eTo.enableMonitoring();
76         if (!shouldAutomaticallyCreatePlacementGroup())
77            eTo.noPlacementGroup();
78         if (getPlacementGroup() != null)
79            eTo.placementGroup(getPlacementGroup());
80         if (getGroupIds().size() > 0)
81            eTo.securityGroupIds(getGroupIds());
82         if (getSpotPrice() != null)
83            eTo.spotPrice(getSpotPrice());
84         if (getSpotOptions() != null)
85            eTo.spotOptions(getSpotOptions());
86      }
87   }
88 
89   private boolean monitoringEnabled;
90   private String placementGroup = null;
91   private boolean noPlacementGroup;
92   private String subnetId;
93   private Float spotPrice;
94   private RequestSpotInstancesOptions spotOptions = RequestSpotInstancesOptions.NONE;
95   private Set<String> groupIds = ImmutableSet.of();
96 
97   public static final AWSEC2TemplateOptions NONE = new AWSEC2TemplateOptions();
98 
99   /**
100    * Enable Cloudwatch monitoring
101    * 
102    * @see CloudWatchClient
103    */
104   public AWSEC2TemplateOptions enableMonitoring() {
105      this.monitoringEnabled = true;
106      return this;
107   }
108 
109   /**
110    * Specifies the keypair used to run instances with
111    */
112   public AWSEC2TemplateOptions placementGroup(String placementGroup) {
113      checkNotNull(placementGroup, "use noPlacementGroup option to request boot without a keypair");
114      checkState(!noPlacementGroup, "you cannot specify both options placementGroup and noPlacementGroup");
115      Preconditions2.checkNotEmpty(placementGroup, "placementGroup must be non-empty");
116      this.placementGroup = placementGroup;
117      return this;
118   }
119 
120   /**
121    * Do not use a keypair on instances
122    */
123   public AWSEC2TemplateOptions noPlacementGroup() {
124      checkState(placementGroup == null, "you cannot specify both options placementGroup and noPlacementGroup");
125      this.noPlacementGroup = true;
126      return this;
127   }
128 
129   /**
130    * Specifies the subnetId used to run instances in
131    */
132   public AWSEC2TemplateOptions subnetId(String subnetId) {
133      checkNotNull(subnetId, "subnetId cannot be null");
134      Preconditions2.checkNotEmpty(subnetId, "subnetId must be non-empty");
135      this.subnetId = subnetId;
136      return this;
137   }
138 
139   /**
140    * Specifies the maximum spot price to use
141    */
142   public AWSEC2TemplateOptions spotPrice(Float spotPrice) {
143      this.spotPrice = spotPrice;
144      return this;
145   }
146 
147   /**
148    * Options for starting spot instances
149    */
150   public AWSEC2TemplateOptions spotOptions(RequestSpotInstancesOptions spotOptions) {
151      this.spotOptions = spotOptions != null ? spotOptions : RequestSpotInstancesOptions.NONE;
152      return this;
153   }
154 
155   /**
156    * 
157    * @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
158    */
159   public AWSEC2TemplateOptions securityGroupIds(String... groupIds) {
160      return securityGroupIds(ImmutableSet.copyOf(groupIds));
161   }
162 
163   /**
164    * Specifies the security group ids to be used for nodes with this template
165    */
166   public AWSEC2TemplateOptions securityGroupIds(Iterable<String> groupIds) {
167      checkArgument(Iterables.size(groupIds) > 0, "you must specify at least one security group");
168      for (String groupId : groupIds)
169         Preconditions2.checkNotEmpty(groupId, "all security groups must be non-empty");
170      this.groupIds = ImmutableSet.copyOf(groupIds);
171      return this;
172   }
173 
174   public Set<String> getGroupIds() {
175      return groupIds;
176   }
177 
178   public void setGroupIds(Set<String> groupIds) {
179      this.groupIds = groupIds;
180   }
181 
182   public static class Builder {
183 
184      /**
185       * @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
186       */
187      public static AWSEC2TemplateOptions securityGroupIds(String... groupNames) {
188         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
189         return AWSEC2TemplateOptions.class.cast(options.securityGroupIds(groupNames));
190      }
191 
192      /**
193       * @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
194       */
195      public static AWSEC2TemplateOptions securityGroupIds(Iterable<String> groupNames) {
196         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
197         return AWSEC2TemplateOptions.class.cast(options.securityGroupIds(groupNames));
198      }
199      
200      /**
201       * @see EC2TemplateOptions#blockDeviceMappings
202       */
203      public static AWSEC2TemplateOptions blockDeviceMappings(Set<? extends BlockDeviceMapping> blockDeviceMappings) {
204         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
205         return options.blockDeviceMappings(blockDeviceMappings);
206      }
207 
208      /**
209       * @see EC2TemplateOptions#mapEBSSnapshotToDeviceName
210       */
211      public static AWSEC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId,
212               @Nullable Integer sizeInGib, boolean deleteOnTermination) {
213         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
214         return options.mapEBSSnapshotToDeviceName(deviceName, snapshotId, sizeInGib, deleteOnTermination);
215      }
216 
217      /**
218       * @see EC2TemplateOptions#mapNewVolumeToDeviceName
219       */
220      public static AWSEC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib,
221               boolean deleteOnTermination) {
222         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
223         return options.mapNewVolumeToDeviceName(deviceName, sizeInGib, deleteOnTermination);
224      }
225 
226      /**
227       * @see EC2TemplateOptions#mapEphemeralDeviceToDeviceName
228       */
229      public static AWSEC2TemplateOptions mapEphemeralDeviceToDeviceName(String deviceName, String virtualName) {
230         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
231         return options.mapEphemeralDeviceToDeviceName(deviceName, virtualName);
232      }
233 
234      /**
235       * @see EC2TemplateOptions#unmapDeviceNamed
236       */
237      public static AWSEC2TemplateOptions unmapDeviceNamed(String deviceName) {
238         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
239         return options.unmapDeviceNamed(deviceName);
240      }
241 
242      /**
243       * @see AWSEC2TemplateOptions#securityGroups(Iterable<String>)
244       */
245      public static AWSEC2TemplateOptions securityGroups(String... groupIds) {
246         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
247         return options.securityGroups(groupIds);
248      }
249 
250      /**
251       * @see AWSEC2TemplateOptions#securityGroups(Iterable<String>)
252       */
253      public static AWSEC2TemplateOptions securityGroups(Iterable<String> groupIds) {
254         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
255         return options.securityGroups(groupIds);
256      }
257 
258      /**
259       * @see AWSEC2TemplateOptions#keyPair
260       */
261      public static AWSEC2TemplateOptions keyPair(String keyPair) {
262         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
263         return options.keyPair(keyPair);
264      }
265 
266      /**
267       * @see AWSEC2TemplateOptions#userData
268       */
269      public static AWSEC2TemplateOptions userData(byte[] unencodedData) {
270         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
271         return options.userData(unencodedData);
272      }
273 
274      /**
275       * @see AWSEC2TemplateOptions#noKeyPair
276       */
277      public static AWSEC2TemplateOptions noKeyPair() {
278         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
279         return options.noKeyPair();
280      }
281 
282      /**
283       * @see AWSEC2TemplateOptions#placementGroup
284       */
285      public static AWSEC2TemplateOptions placementGroup(String placementGroup) {
286         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
287         return options.placementGroup(placementGroup);
288      }
289 
290      /**
291       * @see AWSEC2TemplateOptions#noPlacementGroup
292       */
293      public static AWSEC2TemplateOptions noPlacementGroup() {
294         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
295         return options.noPlacementGroup();
296      }
297 
298      /**
299       * @see AWSEC2TemplateOptions#enableMonitoring
300       */
301      public static AWSEC2TemplateOptions enableMonitoring() {
302         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
303         return options.enableMonitoring();
304      }
305 
306      // methods that only facilitate returning the correct object type
307      /**
308       * @see TemplateOptions#inboundPorts
309       */
310      public static AWSEC2TemplateOptions inboundPorts(int... ports) {
311         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
312         return options.inboundPorts(ports);
313      }
314 
315      /**
316       * @see TemplateOptions#port
317       */
318      public static AWSEC2TemplateOptions blockOnPort(int port, int seconds) {
319         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
320         return options.blockOnPort(port, seconds);
321      }
322 
323      /**
324       * @see TemplateOptions#runScript
325       */
326      public static AWSEC2TemplateOptions runScript(byte[] script) {
327         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
328         return options.runScript(script);
329      }
330 
331      /**
332       * @see TemplateOptions#installPrivateKey
333       */
334      public static AWSEC2TemplateOptions installPrivateKey(String rsaKey) {
335         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
336         return options.installPrivateKey(rsaKey);
337      }
338 
339      /**
340       * @see TemplateOptions#authorizePublicKey
341       */
342      public static AWSEC2TemplateOptions authorizePublicKey(String rsaKey) {
343         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
344         return options.authorizePublicKey(rsaKey);
345      }
346 
347      /**
348       * @see TemplateOptions#withDetails
349       */
350      public static AWSEC2TemplateOptions withDetails() {
351         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
352         return options.withMetadata();
353      }
354 
355      /**
356       * @see TemplateOptions#spotPrice
357       */
358      public static AWSEC2TemplateOptions subnetId(String subnetId) {
359         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
360         return options.subnetId(subnetId);
361      }
362 
363      /**
364       * @see TemplateOptions#spotPrice
365       */
366      public static AWSEC2TemplateOptions spotPrice(Float spotPrice) {
367         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
368         return options.spotPrice(spotPrice);
369      }
370 
371      /**
372       * @see TemplateOptions#spotOptions
373       */
374      public static AWSEC2TemplateOptions spotOptions(RequestSpotInstancesOptions spotOptions) {
375         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
376         return options.spotOptions(spotOptions);
377      }
378   }
379 
380   // methods that only facilitate returning the correct object type
381 
382   /**
383    * {@inheritDoc}
384    */
385   @Override
386   public AWSEC2TemplateOptions blockDeviceMappings(Iterable<? extends BlockDeviceMapping> blockDeviceMappings) {
387      return AWSEC2TemplateOptions.class.cast(super.blockDeviceMappings(blockDeviceMappings));
388   }
389 
390   /**
391    * {@inheritDoc}
392    */
393   @Override
394   public AWSEC2TemplateOptions keyPair(String keyPair) {
395      return AWSEC2TemplateOptions.class.cast(super.keyPair(keyPair));
396   }
397 
398   /**
399    * {@inheritDoc}
400    */
401 
402   @Override
403   public AWSEC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId, Integer sizeInGib,
404            boolean deleteOnTermination) {
405      return AWSEC2TemplateOptions.class.cast(super.mapEBSSnapshotToDeviceName(deviceName, snapshotId, sizeInGib,
406               deleteOnTermination));
407   }
408 
409   /**
410    * {@inheritDoc}
411    */
412   @Override
413   public AWSEC2TemplateOptions mapEphemeralDeviceToDeviceName(String deviceName, String virtualName) {
414      return AWSEC2TemplateOptions.class.cast(super.mapEphemeralDeviceToDeviceName(deviceName, virtualName));
415   }
416 
417   /**
418    * {@inheritDoc}
419    */
420   @Override
421   public AWSEC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib, boolean deleteOnTermination) {
422      return AWSEC2TemplateOptions.class.cast(super
423               .mapNewVolumeToDeviceName(deviceName, sizeInGib, deleteOnTermination));
424   }
425 
426   /**
427    * {@inheritDoc}
428    */
429   @Override
430   public AWSEC2TemplateOptions noKeyPair() {
431      return AWSEC2TemplateOptions.class.cast(super.noKeyPair());
432   }
433 
434   /**
435    * {@inheritDoc}
436    */
437   @Override
438   public AWSEC2TemplateOptions securityGroups(Iterable<String> groupIds) {
439      return AWSEC2TemplateOptions.class.cast(super.securityGroups(groupIds));
440   }
441 
442   /**
443    * {@inheritDoc}
444    */
445   @Override
446   public AWSEC2TemplateOptions securityGroups(String... groupIds) {
447      return AWSEC2TemplateOptions.class.cast(super.securityGroups(groupIds));
448   }
449 
450   /**
451    * {@inheritDoc}
452    */
453   @Override
454   public AWSEC2TemplateOptions unmapDeviceNamed(String deviceName) {
455      return AWSEC2TemplateOptions.class.cast(super.unmapDeviceNamed(deviceName));
456   }
457 
458   /**
459    * {@inheritDoc}
460    */
461   @Override
462   public AWSEC2TemplateOptions userData(byte[] unencodedData) {
463      return AWSEC2TemplateOptions.class.cast(super.userData(unencodedData));
464   }
465 
466   /**
467    * {@inheritDoc}
468    */
469   @Override
470   public AWSEC2TemplateOptions blockOnPort(int port, int seconds) {
471      return AWSEC2TemplateOptions.class.cast(super.blockOnPort(port, seconds));
472   }
473 
474   /**
475    * {@inheritDoc}
476    */
477   @Override
478   public AWSEC2TemplateOptions inboundPorts(int... ports) {
479      return AWSEC2TemplateOptions.class.cast(super.inboundPorts(ports));
480   }
481 
482   /**
483    * {@inheritDoc}
484    */
485   @Override
486   public AWSEC2TemplateOptions authorizePublicKey(String publicKey) {
487      return AWSEC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
488   }
489 
490   /**
491    * {@inheritDoc}
492    */
493   @Override
494   @Deprecated
495   public AWSEC2TemplateOptions authorizePublicKey(Payload publicKey) {
496      return AWSEC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
497   }
498 
499   /**
500    * {@inheritDoc}
501    */
502   @Override
503   public AWSEC2TemplateOptions installPrivateKey(String privateKey) {
504      return AWSEC2TemplateOptions.class.cast(super.installPrivateKey(privateKey));
505   }
506 
507   /**
508    * {@inheritDoc}
509    */
510   @Override
511   @Deprecated
512   public AWSEC2TemplateOptions installPrivateKey(Payload privateKey) {
513      return AWSEC2TemplateOptions.class.cast(super.installPrivateKey(privateKey));
514   }
515 
516   /**
517    * {@inheritDoc}
518    */
519   @Override
520   public AWSEC2TemplateOptions runScript(Payload script) {
521      return AWSEC2TemplateOptions.class.cast(super.runScript(script));
522   }
523 
524   /**
525    * {@inheritDoc}
526    */
527   @Override
528   @Deprecated
529   public AWSEC2TemplateOptions runScript(byte[] script) {
530      return AWSEC2TemplateOptions.class.cast(super.runScript(script));
531   }
532 
533   /**
534    * {@inheritDoc}
535    */
536   @Override
537   public AWSEC2TemplateOptions withMetadata() {
538      return AWSEC2TemplateOptions.class.cast(super.withMetadata());
539   }
540 
541   /**
542    * {@inheritDoc}
543    */
544   @Override
545   public AWSEC2TemplateOptions blockUntilRunning(boolean blockUntilRunning) {
546      return AWSEC2TemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning));
547   }
548 
549   /**
550    * {@inheritDoc}
551    */
552   @Override
553   public AWSEC2TemplateOptions dontAuthorizePublicKey() {
554      return AWSEC2TemplateOptions.class.cast(super.dontAuthorizePublicKey());
555   }
556 
557   /**
558    * {@inheritDoc}
559    */
560   @Override
561   public AWSEC2TemplateOptions nameTask(String name) {
562      return AWSEC2TemplateOptions.class.cast(super.nameTask(name));
563   }
564 
565   /**
566    * {@inheritDoc}
567    */
568   @Override
569   public AWSEC2TemplateOptions runAsRoot(boolean runAsRoot) {
570      return AWSEC2TemplateOptions.class.cast(super.runAsRoot(runAsRoot));
571   }
572 
573   /**
574    * {@inheritDoc}
575    */
576   @Override
577   public AWSEC2TemplateOptions runScript(Statement script) {
578      return AWSEC2TemplateOptions.class.cast(super.runScript(script));
579   }
580 
581   /**
582    * {@inheritDoc}
583    */
584   @Override
585   public AWSEC2TemplateOptions overrideCredentialsWith(Credentials overridingCredentials) {
586      return AWSEC2TemplateOptions.class.cast(super.overrideCredentialsWith(overridingCredentials));
587   }
588 
589   /**
590    * @return placementGroup to use when running the instance or null, to generate a placementGroup.
591    */
592   public String getPlacementGroup() {
593      return placementGroup;
594   }
595 
596   /**
597    * @return true (default) if we are supposed to use a placementGroup
598    */
599   public boolean shouldAutomaticallyCreatePlacementGroup() {
600      return !noPlacementGroup;
601   }
602 
603   /**
604    * @return true (default) if we are supposed to enable cloudwatch
605    */
606   public boolean isMonitoringEnabled() {
607      return monitoringEnabled;
608   }
609 
610   /**
611    * @return subnetId to use when running the instance or null.
612    */
613   public String getSubnetId() {
614      return subnetId;
615   }
616 
617   /**
618    * @return maximum spot price or null.
619    */
620   public Float getSpotPrice() {
621      return spotPrice;
622   }
623 
624   /**
625    * @return options for controlling spot instance requests.
626    */
627   public RequestSpotInstancesOptions getSpotOptions() {
628      return spotOptions;
629   }
630 
631   @Override
632   public int hashCode() {
633      final int prime = 31;
634      int result = super.hashCode();
635      result = prime * result + (monitoringEnabled ? 1231 : 1237);
636      result = prime * result + (noPlacementGroup ? 1231 : 1237);
637      result = prime * result + ((placementGroup == null) ? 0 : placementGroup.hashCode());
638      result = prime * result + ((spotOptions == null) ? 0 : spotOptions.hashCode());
639      result = prime * result + ((spotPrice == null) ? 0 : spotPrice.hashCode());
640      result = prime * result + ((subnetId == null) ? 0 : subnetId.hashCode());
641      return result;
642   }
643 
644   @Override
645   public boolean equals(Object obj) {
646      if (this == obj)
647         return true;
648      if (!super.equals(obj))
649         return false;
650      if (getClass() != obj.getClass())
651         return false;
652      AWSEC2TemplateOptions other = (AWSEC2TemplateOptions) obj;
653      if (monitoringEnabled != other.monitoringEnabled)
654         return false;
655      if (noPlacementGroup != other.noPlacementGroup)
656         return false;
657      if (placementGroup == null) {
658         if (other.placementGroup != null)
659            return false;
660      } else if (!placementGroup.equals(other.placementGroup))
661         return false;
662      if (spotOptions == null) {
663         if (other.spotOptions != null)
664            return false;
665      } else if (!spotOptions.equals(other.spotOptions))
666         return false;
667      if (spotPrice == null) {
668         if (other.spotPrice != null)
669            return false;
670      } else if (!spotPrice.equals(other.spotPrice))
671         return false;
672      if (subnetId == null) {
673         if (other.subnetId != null)
674            return false;
675      } else if (!subnetId.equals(other.subnetId))
676         return false;
677      return true;
678   }
679 
680   @Override
681   public String toString() {
682 
683      return "[groupIds=" + getGroups() + ", keyPair=" + getKeyPair() + ", noKeyPair="
684               + !shouldAutomaticallyCreateKeyPair() + ", monitoringEnabled=" + monitoringEnabled + ", placementGroup="
685               + placementGroup + ", noPlacementGroup=" + noPlacementGroup + ", subnetId=" + subnetId + ", userData="
686               + Arrays.toString(getUserData()) + ", blockDeviceMappings=" + getBlockDeviceMappings() + ", spotPrice="
687               + spotPrice + ", spotOptions=" + spotOptions + "]";
688   }
689 
690}

[all classes][org.jclouds.aws.ec2.compute]
EMMA 2.0.5312 (C) Vladimir Roubtsov