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

COVERAGE SUMMARY FOR SOURCE FILE [AWSEC2TemplateOptions.java]

nameclass, %method, %block, %line, %
AWSEC2TemplateOptions.java100% (2/2)38%  (28/74)26%  (223/870)27%  (47.8/176)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AWSEC2TemplateOptions100% (1/1)35%  (17/48)20%  (130/650)21%  (26/126)
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)
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)
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)
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)
userMetadata (Map): AWSEC2TemplateOptions 0%   (0/1)0%   (0/7)0%   (0/1)
userMetadata (String, String): AWSEC2TemplateOptions 0%   (0/1)0%   (0/8)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)
dontAuthorizePublicKey (): AWSEC2TemplateOptions 100% (1/1)100% (6/6)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)
overrideCredentialsWith (Credentials): AWSEC2TemplateOptions 100% (1/1)100% (7/7)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)42%  (11/26)42%  (93/220)43%  (22/51)
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)
userMetadata (Map): AWSEC2TemplateOptions 0%   (0/1)0%   (0/11)0%   (0/2)
userMetadata (String, String): AWSEC2TemplateOptions 0%   (0/1)0%   (0/12)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 * 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.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.Map;
27import java.util.Set;
28 
29import org.jclouds.aws.ec2.options.RequestSpotInstancesOptions;
30import org.jclouds.compute.options.TemplateOptions;
31import org.jclouds.domain.Credentials;
32import org.jclouds.ec2.compute.options.EC2TemplateOptions;
33import org.jclouds.ec2.domain.BlockDeviceMapping;
34import org.jclouds.io.Payload;
35import org.jclouds.javax.annotation.Nullable;
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
44 * the "ec2" provider. <h2>
45 * Usage</h2> The recommended way to instantiate a AWSEC2TemplateOptions object
46 * is to statically import AWSEC2TemplateOptions.* and invoke a static creation
47 * method followed by an instance 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 static class Builder {
179 
180      /**
181       * @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
182       */
183      public static AWSEC2TemplateOptions securityGroupIds(String... groupNames) {
184         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
185         return AWSEC2TemplateOptions.class.cast(options.securityGroupIds(groupNames));
186      }
187 
188      /**
189       * @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
190       */
191      public static AWSEC2TemplateOptions securityGroupIds(Iterable<String> groupNames) {
192         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
193         return AWSEC2TemplateOptions.class.cast(options.securityGroupIds(groupNames));
194      }
195 
196      /**
197       * @see EC2TemplateOptions#blockDeviceMappings
198       */
199      public static AWSEC2TemplateOptions blockDeviceMappings(Set<? extends BlockDeviceMapping> blockDeviceMappings) {
200         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
201         return options.blockDeviceMappings(blockDeviceMappings);
202      }
203 
204      /**
205       * @see EC2TemplateOptions#mapEBSSnapshotToDeviceName
206       */
207      public static AWSEC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId,
208            @Nullable Integer sizeInGib, boolean deleteOnTermination) {
209         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
210         return options.mapEBSSnapshotToDeviceName(deviceName, snapshotId, sizeInGib, deleteOnTermination);
211      }
212 
213      /**
214       * @see EC2TemplateOptions#mapNewVolumeToDeviceName
215       */
216      public static AWSEC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib,
217            boolean deleteOnTermination) {
218         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
219         return options.mapNewVolumeToDeviceName(deviceName, sizeInGib, deleteOnTermination);
220      }
221 
222      /**
223       * @see EC2TemplateOptions#mapEphemeralDeviceToDeviceName
224       */
225      public static AWSEC2TemplateOptions mapEphemeralDeviceToDeviceName(String deviceName, String virtualName) {
226         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
227         return options.mapEphemeralDeviceToDeviceName(deviceName, virtualName);
228      }
229 
230      /**
231       * @see EC2TemplateOptions#unmapDeviceNamed
232       */
233      public static AWSEC2TemplateOptions unmapDeviceNamed(String deviceName) {
234         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
235         return options.unmapDeviceNamed(deviceName);
236      }
237 
238      /**
239       * @see AWSEC2TemplateOptions#securityGroups(Iterable<String>)
240       */
241      public static AWSEC2TemplateOptions securityGroups(String... groupIds) {
242         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
243         return options.securityGroups(groupIds);
244      }
245 
246      /**
247       * @see AWSEC2TemplateOptions#securityGroups(Iterable<String>)
248       */
249      public static AWSEC2TemplateOptions securityGroups(Iterable<String> groupIds) {
250         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
251         return options.securityGroups(groupIds);
252      }
253 
254      /**
255       * @see AWSEC2TemplateOptions#keyPair
256       */
257      public static AWSEC2TemplateOptions keyPair(String keyPair) {
258         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
259         return options.keyPair(keyPair);
260      }
261 
262      /**
263       * @see AWSEC2TemplateOptions#userData
264       */
265      public static AWSEC2TemplateOptions userData(byte[] unencodedData) {
266         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
267         return options.userData(unencodedData);
268      }
269 
270      /**
271       * @see AWSEC2TemplateOptions#noKeyPair
272       */
273      public static AWSEC2TemplateOptions noKeyPair() {
274         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
275         return options.noKeyPair();
276      }
277 
278      /**
279       * @see AWSEC2TemplateOptions#placementGroup
280       */
281      public static AWSEC2TemplateOptions placementGroup(String placementGroup) {
282         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
283         return options.placementGroup(placementGroup);
284      }
285 
286      /**
287       * @see AWSEC2TemplateOptions#noPlacementGroup
288       */
289      public static AWSEC2TemplateOptions noPlacementGroup() {
290         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
291         return options.noPlacementGroup();
292      }
293 
294      /**
295       * @see AWSEC2TemplateOptions#enableMonitoring
296       */
297      public static AWSEC2TemplateOptions enableMonitoring() {
298         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
299         return options.enableMonitoring();
300      }
301 
302      // methods that only facilitate returning the correct object type
303      /**
304       * @see TemplateOptions#inboundPorts
305       */
306      public static AWSEC2TemplateOptions inboundPorts(int... ports) {
307         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
308         return options.inboundPorts(ports);
309      }
310 
311      /**
312       * @see TemplateOptions#port
313       */
314      public static AWSEC2TemplateOptions blockOnPort(int port, int seconds) {
315         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
316         return options.blockOnPort(port, seconds);
317      }
318 
319      /**
320       * @see TemplateOptions#runScript
321       */
322      public static AWSEC2TemplateOptions runScript(byte[] script) {
323         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
324         return options.runScript(script);
325      }
326 
327      /**
328       * @see TemplateOptions#installPrivateKey
329       */
330      public static AWSEC2TemplateOptions installPrivateKey(String rsaKey) {
331         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
332         return options.installPrivateKey(rsaKey);
333      }
334 
335      /**
336       * @see TemplateOptions#authorizePublicKey
337       */
338      public static AWSEC2TemplateOptions authorizePublicKey(String rsaKey) {
339         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
340         return options.authorizePublicKey(rsaKey);
341      }
342 
343      /**
344       * @see TemplateOptions#spotPrice
345       */
346      public static AWSEC2TemplateOptions subnetId(String subnetId) {
347         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
348         return options.subnetId(subnetId);
349      }
350 
351      /**
352       * @see TemplateOptions#spotPrice
353       */
354      public static AWSEC2TemplateOptions spotPrice(Float spotPrice) {
355         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
356         return options.spotPrice(spotPrice);
357      }
358 
359      /**
360       * @see TemplateOptions#spotOptions
361       */
362      public static AWSEC2TemplateOptions spotOptions(RequestSpotInstancesOptions spotOptions) {
363         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
364         return options.spotOptions(spotOptions);
365      }
366      
367      /**
368       * @see TemplateOptions#userMetadata(Map)
369       */
370      public static AWSEC2TemplateOptions userMetadata(Map<String, String> userMetadata) {
371         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
372         return AWSEC2TemplateOptions.class.cast(options.userMetadata(userMetadata));
373      }
374 
375      /**
376       * @see TemplateOptions#userMetadata(String, String)
377       */
378      public static AWSEC2TemplateOptions userMetadata(String key, String value) {
379         AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
380         return AWSEC2TemplateOptions.class.cast(options.userMetadata(key, value));
381      }
382   }
383 
384   // methods that only facilitate returning the correct object type
385 
386   /**
387    * {@inheritDoc}
388    */
389   @Override
390   public AWSEC2TemplateOptions blockDeviceMappings(Iterable<? extends BlockDeviceMapping> blockDeviceMappings) {
391      return AWSEC2TemplateOptions.class.cast(super.blockDeviceMappings(blockDeviceMappings));
392   }
393 
394   /**
395    * {@inheritDoc}
396    */
397   @Override
398   public AWSEC2TemplateOptions userMetadata(Map<String, String> userMetadata) {
399      return AWSEC2TemplateOptions.class.cast(super.userMetadata(userMetadata));
400   }
401 
402   /**
403    * {@inheritDoc}
404    */
405   @Override
406   public AWSEC2TemplateOptions userMetadata(String key, String value) {
407      return AWSEC2TemplateOptions.class.cast(super.userMetadata(key, value));
408   }
409 
410   /**
411    * {@inheritDoc}
412    */
413   @Override
414   public AWSEC2TemplateOptions keyPair(String keyPair) {
415      return AWSEC2TemplateOptions.class.cast(super.keyPair(keyPair));
416   }
417 
418   /**
419    * {@inheritDoc}
420    */
421 
422   @Override
423   public AWSEC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId, Integer sizeInGib,
424         boolean deleteOnTermination) {
425      return AWSEC2TemplateOptions.class.cast(super.mapEBSSnapshotToDeviceName(deviceName, snapshotId, sizeInGib,
426            deleteOnTermination));
427   }
428 
429   /**
430    * {@inheritDoc}
431    */
432   @Override
433   public AWSEC2TemplateOptions mapEphemeralDeviceToDeviceName(String deviceName, String virtualName) {
434      return AWSEC2TemplateOptions.class.cast(super.mapEphemeralDeviceToDeviceName(deviceName, virtualName));
435   }
436 
437   /**
438    * {@inheritDoc}
439    */
440   @Override
441   public AWSEC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib, boolean deleteOnTermination) {
442      return AWSEC2TemplateOptions.class.cast(super
443            .mapNewVolumeToDeviceName(deviceName, sizeInGib, deleteOnTermination));
444   }
445 
446   /**
447    * {@inheritDoc}
448    */
449   @Override
450   public AWSEC2TemplateOptions noKeyPair() {
451      return AWSEC2TemplateOptions.class.cast(super.noKeyPair());
452   }
453 
454   /**
455    * {@inheritDoc}
456    */
457   @Override
458   public AWSEC2TemplateOptions securityGroups(Iterable<String> groupIds) {
459      return AWSEC2TemplateOptions.class.cast(super.securityGroups(groupIds));
460   }
461 
462   /**
463    * {@inheritDoc}
464    */
465   @Override
466   public AWSEC2TemplateOptions securityGroups(String... groupIds) {
467      return AWSEC2TemplateOptions.class.cast(super.securityGroups(groupIds));
468   }
469 
470   /**
471    * {@inheritDoc}
472    */
473   @Override
474   public AWSEC2TemplateOptions unmapDeviceNamed(String deviceName) {
475      return AWSEC2TemplateOptions.class.cast(super.unmapDeviceNamed(deviceName));
476   }
477 
478   /**
479    * {@inheritDoc}
480    */
481   @Override
482   public AWSEC2TemplateOptions userData(byte[] unencodedData) {
483      return AWSEC2TemplateOptions.class.cast(super.userData(unencodedData));
484   }
485 
486   /**
487    * {@inheritDoc}
488    */
489   @Override
490   public AWSEC2TemplateOptions blockOnPort(int port, int seconds) {
491      return AWSEC2TemplateOptions.class.cast(super.blockOnPort(port, seconds));
492   }
493 
494   /**
495    * {@inheritDoc}
496    */
497   @Override
498   public AWSEC2TemplateOptions inboundPorts(int... ports) {
499      return AWSEC2TemplateOptions.class.cast(super.inboundPorts(ports));
500   }
501 
502   /**
503    * {@inheritDoc}
504    */
505   @Override
506   public AWSEC2TemplateOptions authorizePublicKey(String publicKey) {
507      return AWSEC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
508   }
509 
510   /**
511    * {@inheritDoc}
512    */
513   @Override
514   @Deprecated
515   public AWSEC2TemplateOptions authorizePublicKey(Payload publicKey) {
516      return AWSEC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
517   }
518 
519   /**
520    * {@inheritDoc}
521    */
522   @Override
523   public AWSEC2TemplateOptions installPrivateKey(String privateKey) {
524      return AWSEC2TemplateOptions.class.cast(super.installPrivateKey(privateKey));
525   }
526 
527   /**
528    * {@inheritDoc}
529    */
530   @Override
531   @Deprecated
532   public AWSEC2TemplateOptions installPrivateKey(Payload privateKey) {
533      return AWSEC2TemplateOptions.class.cast(super.installPrivateKey(privateKey));
534   }
535 
536   /**
537    * {@inheritDoc}
538    */
539   @Override
540   public AWSEC2TemplateOptions runScript(Payload script) {
541      return AWSEC2TemplateOptions.class.cast(super.runScript(script));
542   }
543 
544   /**
545    * {@inheritDoc}
546    */
547   @Override
548   @Deprecated
549   public AWSEC2TemplateOptions runScript(byte[] script) {
550      return AWSEC2TemplateOptions.class.cast(super.runScript(script));
551   }
552 
553   /**
554    * {@inheritDoc}
555    */
556   @Override
557   public AWSEC2TemplateOptions blockUntilRunning(boolean blockUntilRunning) {
558      return AWSEC2TemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning));
559   }
560 
561   /**
562    * {@inheritDoc}
563    */
564   @Override
565   public AWSEC2TemplateOptions dontAuthorizePublicKey() {
566      return AWSEC2TemplateOptions.class.cast(super.dontAuthorizePublicKey());
567   }
568 
569   /**
570    * {@inheritDoc}
571    */
572   @Override
573   public AWSEC2TemplateOptions nameTask(String name) {
574      return AWSEC2TemplateOptions.class.cast(super.nameTask(name));
575   }
576 
577   /**
578    * {@inheritDoc}
579    */
580   @Override
581   public AWSEC2TemplateOptions runAsRoot(boolean runAsRoot) {
582      return AWSEC2TemplateOptions.class.cast(super.runAsRoot(runAsRoot));
583   }
584 
585   /**
586    * {@inheritDoc}
587    */
588   @Override
589   public AWSEC2TemplateOptions runScript(Statement script) {
590      return AWSEC2TemplateOptions.class.cast(super.runScript(script));
591   }
592 
593   /**
594    * {@inheritDoc}
595    */
596   @Override
597   public AWSEC2TemplateOptions overrideCredentialsWith(Credentials overridingCredentials) {
598      return AWSEC2TemplateOptions.class.cast(super.overrideCredentialsWith(overridingCredentials));
599   }
600 
601   /**
602    * @return placementGroup to use when running the instance or null, to
603    *         generate a placementGroup.
604    */
605   public String getPlacementGroup() {
606      return placementGroup;
607   }
608 
609   /**
610    * @return true (default) if we are supposed to use a placementGroup
611    */
612   public boolean shouldAutomaticallyCreatePlacementGroup() {
613      return !noPlacementGroup;
614   }
615 
616   /**
617    * @return true (default) if we are supposed to enable cloudwatch
618    */
619   public boolean isMonitoringEnabled() {
620      return monitoringEnabled;
621   }
622 
623   /**
624    * @return subnetId to use when running the instance or null.
625    */
626   public String getSubnetId() {
627      return subnetId;
628   }
629 
630   /**
631    * @return maximum spot price or null.
632    */
633   public Float getSpotPrice() {
634      return spotPrice;
635   }
636 
637   /**
638    * @return options for controlling spot instance requests.
639    */
640   public RequestSpotInstancesOptions getSpotOptions() {
641      return spotOptions;
642   }
643 
644   @Override
645   public int hashCode() {
646      final int prime = 31;
647      int result = super.hashCode();
648      result = prime * result + (monitoringEnabled ? 1231 : 1237);
649      result = prime * result + (noPlacementGroup ? 1231 : 1237);
650      result = prime * result + ((placementGroup == null) ? 0 : placementGroup.hashCode());
651      result = prime * result + ((spotOptions == null) ? 0 : spotOptions.hashCode());
652      result = prime * result + ((spotPrice == null) ? 0 : spotPrice.hashCode());
653      result = prime * result + ((subnetId == null) ? 0 : subnetId.hashCode());
654      return result;
655   }
656 
657   @Override
658   public boolean equals(Object obj) {
659      if (this == obj)
660         return true;
661      if (!super.equals(obj))
662         return false;
663      if (getClass() != obj.getClass())
664         return false;
665      AWSEC2TemplateOptions other = (AWSEC2TemplateOptions) obj;
666      if (monitoringEnabled != other.monitoringEnabled)
667         return false;
668      if (noPlacementGroup != other.noPlacementGroup)
669         return false;
670      if (placementGroup == null) {
671         if (other.placementGroup != null)
672            return false;
673      } else if (!placementGroup.equals(other.placementGroup))
674         return false;
675      if (spotOptions == null) {
676         if (other.spotOptions != null)
677            return false;
678      } else if (!spotOptions.equals(other.spotOptions))
679         return false;
680      if (spotPrice == null) {
681         if (other.spotPrice != null)
682            return false;
683      } else if (!spotPrice.equals(other.spotPrice))
684         return false;
685      if (subnetId == null) {
686         if (other.subnetId != null)
687            return false;
688      } else if (!subnetId.equals(other.subnetId))
689         return false;
690      return true;
691   }
692 
693   @Override
694   public String toString() {
695 
696      return "[groupIds=" + getGroups() + ", keyPair=" + getKeyPair() + ", noKeyPair="
697            + !shouldAutomaticallyCreateKeyPair() + ", monitoringEnabled=" + monitoringEnabled + ", placementGroup="
698            + placementGroup + ", noPlacementGroup=" + noPlacementGroup + ", subnetId=" + subnetId + ", userData="
699            + Arrays.toString(getUserData()) + ", blockDeviceMappings=" + getBlockDeviceMappings() + ", spotPrice="
700            + spotPrice + ", spotOptions=" + spotOptions + "]";
701   }
702 
703}

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