This repository has been archived by the owner on Jul 25, 2020. It is now read-only.
/
AWSEC2TemplateOptions.java
810 lines (712 loc) · 26.9 KB
/
AWSEC2TemplateOptions.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.aws.ec2.compute;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Strings.emptyToNull;
import java.util.Map;
import java.util.Set;
import org.jclouds.aws.ec2.options.RequestSpotInstancesOptions;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.ec2.compute.options.EC2TemplateOptions;
import org.jclouds.ec2.domain.BlockDeviceMapping;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.rest.annotations.SinceApiVersion;
import org.jclouds.scriptbuilder.domain.Statement;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
/**
* Contains options supported in the {@code ComputeService#runNode} operation on
* the "ec2" provider. <h2>
* Usage</h2> The recommended way to instantiate a AWSEC2TemplateOptions object
* is to statically import AWSEC2TemplateOptions.* and invoke a static creation
* method followed by an instance mutator (if needed):
* <p/>
* <code>
* import static org.jclouds.aws.ec2.compute.options.AWSEC2TemplateOptions.Builder.*;
* <p/>
* ComputeService client = // get connection
* templateBuilder.options(inboundPorts(22, 80, 8080, 443));
* Set<? extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build());
* <code>
*/
public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneable {
@Override
public AWSEC2TemplateOptions clone() {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
copyTo(options);
return options;
}
@Override
public void copyTo(TemplateOptions to) {
super.copyTo(to);
if (to instanceof AWSEC2TemplateOptions) {
AWSEC2TemplateOptions eTo = AWSEC2TemplateOptions.class.cast(to);
if (getSubnetId() != null)
eTo.subnetId(getSubnetId());
if (getIAMInstanceProfileArn() != null)
eTo.iamInstanceProfileArn(getIAMInstanceProfileArn());
if (getIAMInstanceProfileName() != null)
eTo.iamInstanceProfileName(getIAMInstanceProfileName());
if (isMonitoringEnabled())
eTo.enableMonitoring();
if (!shouldAutomaticallyCreatePlacementGroup())
eTo.noPlacementGroup();
if (getPlacementGroup() != null)
eTo.placementGroup(getPlacementGroup());
if (!getGroupIds().isEmpty())
eTo.securityGroupIds(getGroupIds());
if (getSpotPrice() != null)
eTo.spotPrice(getSpotPrice());
if (getSpotOptions() != null)
eTo.spotOptions(getSpotOptions());
if (getPrivateIpAddress() != null)
eTo.privateIpAddress(getPrivateIpAddress());
}
}
private boolean monitoringEnabled;
private String placementGroup = null;
private boolean noPlacementGroup;
private String subnetId;
private Float spotPrice;
private RequestSpotInstancesOptions spotOptions = RequestSpotInstancesOptions.NONE;
private Set<String> groupIds = ImmutableSet.of();
private String iamInstanceProfileArn;
private String iamInstanceProfileName;
private String privateIpAddress;
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
AWSEC2TemplateOptions that = AWSEC2TemplateOptions.class.cast(o);
return super.equals(that) && equal(this.monitoringEnabled, that.monitoringEnabled)
&& equal(this.placementGroup, that.placementGroup)
&& equal(this.noPlacementGroup, that.noPlacementGroup) && equal(this.subnetId, that.subnetId)
&& equal(this.spotPrice, that.spotPrice) && equal(this.spotOptions, that.spotOptions)
&& equal(this.groupIds, that.groupIds) && equal(this.iamInstanceProfileArn, that.iamInstanceProfileArn)
&& equal(this.iamInstanceProfileName, that.iamInstanceProfileName)
&& equal(this.privateIpAddress, that.privateIpAddress);
}
@Override
public int hashCode() {
return Objects.hashCode(super.hashCode(), monitoringEnabled, placementGroup, noPlacementGroup, subnetId,
spotPrice, spotOptions, groupIds, iamInstanceProfileArn, iamInstanceProfileName, privateIpAddress);
}
@Override
public ToStringHelper string() {
ToStringHelper toString = super.string();
if (monitoringEnabled)
toString.add("monitoringEnabled", monitoringEnabled);
toString.add("placementGroup", placementGroup);
if (noPlacementGroup)
toString.add("noPlacementGroup", noPlacementGroup);
toString.add("subnetId", subnetId);
toString.add("spotPrice", spotPrice);
if (spotOptions != RequestSpotInstancesOptions.NONE)
toString.add("spotOptions", spotOptions);
if (!groupIds.isEmpty())
toString.add("groupIds", groupIds);
toString.add("iamInstanceProfileArn", iamInstanceProfileArn);
toString.add("iamInstanceProfileName", iamInstanceProfileName);
toString.add("privateIpAddress", privateIpAddress);
return toString;
}
public static final AWSEC2TemplateOptions NONE = new AWSEC2TemplateOptions();
/**
* Enable Cloudwatch monitoring
*
* @see CloudWatchClient
*/
public AWSEC2TemplateOptions enableMonitoring() {
this.monitoringEnabled = true;
return this;
}
/**
* Specifies the keypair used to run instances with
*/
public AWSEC2TemplateOptions placementGroup(String placementGroup) {
checkNotNull(emptyToNull(placementGroup), "use noPlacementGroup option instead of passing null");
checkState(!noPlacementGroup, "you cannot specify both options placementGroup and noPlacementGroup");
this.placementGroup = placementGroup;
return this;
}
/**
* Do not use a keypair on instances
*/
public AWSEC2TemplateOptions noPlacementGroup() {
checkState(placementGroup == null, "you cannot specify both options placementGroup and noPlacementGroup");
this.noPlacementGroup = true;
return this;
}
/**
* Specifies the subnetId used to run instances in
*/
public AWSEC2TemplateOptions subnetId(String subnetId) {
this.subnetId = checkNotNull(emptyToNull(subnetId), "subnetId must be defined");
return this;
}
/**
* @see org.jclouds.aws.ec2.options.AWSRunInstancesOptions#withIAMInstanceProfileArn(String)
*/
@SinceApiVersion("2012-06-01")
public AWSEC2TemplateOptions iamInstanceProfileArn(String arn) {
this.iamInstanceProfileArn = checkNotNull(emptyToNull(arn), "arn must be defined");
return this;
}
/**
* @see org.jclouds.aws.ec2.options.AWSRunInstancesOptions#withIAMInstanceProfileName(String)
*/
@SinceApiVersion("2012-06-01")
public AWSEC2TemplateOptions iamInstanceProfileName(String name) {
this.iamInstanceProfileName = checkNotNull(emptyToNull(name), "name must be defined");
return this;
}
public AWSEC2TemplateOptions privateIpAddress(String address) {
this.privateIpAddress = checkNotNull(emptyToNull(address), "address must be defined");
return this;
}
/**
* Specifies the maximum spot price to use
*/
public AWSEC2TemplateOptions spotPrice(Float spotPrice) {
this.spotPrice = spotPrice;
return this;
}
/**
* Options for starting spot instances
*/
public AWSEC2TemplateOptions spotOptions(RequestSpotInstancesOptions spotOptions) {
this.spotOptions = spotOptions != null ? spotOptions : RequestSpotInstancesOptions.NONE;
return this;
}
/**
*
* @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
*/
public AWSEC2TemplateOptions securityGroupIds(String... groupIds) {
return securityGroupIds(ImmutableSet.copyOf(groupIds));
}
/**
* Specifies the security group ids to be used for nodes with this template
*/
public AWSEC2TemplateOptions securityGroupIds(Iterable<String> groupIds) {
checkArgument(!Iterables.isEmpty(groupIds), "you must specify at least one security group");
for (String groupId : groupIds)
checkNotNull(emptyToNull(groupId), "all security groups must be non-empty");
this.groupIds = ImmutableSet.copyOf(groupIds);
return this;
}
public Set<String> getGroupIds() {
return groupIds;
}
public static class Builder {
public static AWSEC2TemplateOptions overrideLoginUser(String user) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.overrideLoginUser(user);
}
public static AWSEC2TemplateOptions overrideLoginPassword(String password) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.overrideLoginPassword(password);
}
public static AWSEC2TemplateOptions overrideLoginPrivateKey(String privateKey) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.overrideLoginPrivateKey(privateKey);
}
public static AWSEC2TemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.overrideAuthenticateSudo(authenticateSudo);
}
public static AWSEC2TemplateOptions overrideLoginCredentials(LoginCredentials credentials) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.overrideLoginCredentials(credentials);
}
/**
* @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
*/
public static AWSEC2TemplateOptions securityGroupIds(String... groupNames) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return AWSEC2TemplateOptions.class.cast(options.securityGroupIds(groupNames));
}
/**
* @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
*/
public static AWSEC2TemplateOptions securityGroupIds(Iterable<String> groupNames) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return AWSEC2TemplateOptions.class.cast(options.securityGroupIds(groupNames));
}
/**
* @see EC2TemplateOptions#blockDeviceMappings
*/
public static AWSEC2TemplateOptions blockDeviceMappings(Set<? extends BlockDeviceMapping> blockDeviceMappings) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.blockDeviceMappings(blockDeviceMappings);
}
/**
* @see EC2TemplateOptions#mapEBSSnapshotToDeviceName
*/
public static AWSEC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId,
@Nullable Integer sizeInGib, boolean deleteOnTermination) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.mapEBSSnapshotToDeviceName(deviceName, snapshotId, sizeInGib, deleteOnTermination);
}
/**
* @see EC2TemplateOptions#mapNewVolumeToDeviceName
*/
public static AWSEC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib,
boolean deleteOnTermination) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.mapNewVolumeToDeviceName(deviceName, sizeInGib, deleteOnTermination);
}
/**
* @see EC2TemplateOptions#mapEphemeralDeviceToDeviceName
*/
public static AWSEC2TemplateOptions mapEphemeralDeviceToDeviceName(String deviceName, String virtualName) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.mapEphemeralDeviceToDeviceName(deviceName, virtualName);
}
/**
* @see EC2TemplateOptions#unmapDeviceNamed
*/
public static AWSEC2TemplateOptions unmapDeviceNamed(String deviceName) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.unmapDeviceNamed(deviceName);
}
/**
* @see AWSEC2TemplateOptions#securityGroups(Iterable<String>)
*/
public static AWSEC2TemplateOptions securityGroups(String... groupIds) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.securityGroups(groupIds);
}
/**
* @see AWSEC2TemplateOptions#securityGroups(Iterable<String>)
*/
public static AWSEC2TemplateOptions securityGroups(Iterable<String> groupIds) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.securityGroups(groupIds);
}
/**
* @see AWSEC2TemplateOptions#keyPair
*/
public static AWSEC2TemplateOptions keyPair(String keyPair) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.keyPair(keyPair);
}
/**
* @see AWSEC2TemplateOptions#userData
*/
public static AWSEC2TemplateOptions userData(byte[] unencodedData) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.userData(unencodedData);
}
/**
* @see AWSEC2TemplateOptions#noKeyPair
*/
public static AWSEC2TemplateOptions noKeyPair() {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.noKeyPair();
}
/**
* @see AWSEC2TemplateOptions#placementGroup
*/
public static AWSEC2TemplateOptions placementGroup(String placementGroup) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.placementGroup(placementGroup);
}
/**
* @see AWSEC2TemplateOptions#noPlacementGroup
*/
public static AWSEC2TemplateOptions noPlacementGroup() {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.noPlacementGroup();
}
/**
* @see AWSEC2TemplateOptions#enableMonitoring
*/
public static AWSEC2TemplateOptions enableMonitoring() {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.enableMonitoring();
}
// methods that only facilitate returning the correct object type
/**
* @see TemplateOptions#inboundPorts
*/
public static AWSEC2TemplateOptions inboundPorts(int... ports) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.inboundPorts(ports);
}
/**
* @see TemplateOptions#port
*/
public static AWSEC2TemplateOptions blockOnPort(int port, int seconds) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.blockOnPort(port, seconds);
}
/**
* @see TemplateOptions#installPrivateKey
*/
public static AWSEC2TemplateOptions installPrivateKey(String rsaKey) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.installPrivateKey(rsaKey);
}
/**
* @see TemplateOptions#authorizePublicKey
*/
public static AWSEC2TemplateOptions authorizePublicKey(String rsaKey) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.authorizePublicKey(rsaKey);
}
/**
* @see AWSEC2TemplateOptions#subnetId
*/
public static AWSEC2TemplateOptions subnetId(String subnetId) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.subnetId(subnetId);
}
/**
* @see AWSEC2TemplateOptions#iamInstanceProfileArn
*/
@SinceApiVersion("2012-06-01")
public static AWSEC2TemplateOptions iamInstanceProfileArn(String arn) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.iamInstanceProfileArn(arn);
}
/**
* @see AWSEC2TemplateOptions#iamInstanceProfileName
*/
@SinceApiVersion("2012-06-01")
public static AWSEC2TemplateOptions iamInstanceProfileName(String name) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.iamInstanceProfileName(name);
}
public static AWSEC2TemplateOptions privateIpAddress(String address) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.privateIpAddress(address);
}
/**
* @see AWSEC2TemplateOptions#spotPrice
*/
public static AWSEC2TemplateOptions spotPrice(Float spotPrice) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.spotPrice(spotPrice);
}
/**
* @see AWSEC2TemplateOptions#spotOptions
*/
public static AWSEC2TemplateOptions spotOptions(RequestSpotInstancesOptions spotOptions) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.spotOptions(spotOptions);
}
/**
* @see TemplateOptions#userMetadata(Map)
*/
public static AWSEC2TemplateOptions userMetadata(Map<String, String> userMetadata) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return AWSEC2TemplateOptions.class.cast(options.userMetadata(userMetadata));
}
/**
* @see TemplateOptions#userMetadata(String, String)
*/
public static AWSEC2TemplateOptions userMetadata(String key, String value) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return AWSEC2TemplateOptions.class.cast(options.userMetadata(key, value));
}
public static AWSEC2TemplateOptions blockUntilRunning(boolean blockUntilRunning) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.blockUntilRunning(blockUntilRunning);
}
/**
* @see TemplateOptions#nodeNames(Iterable)
*/
public static AWSEC2TemplateOptions nodeNames(Iterable<String> nodeNames) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return AWSEC2TemplateOptions.class.cast(options.nodeNames(nodeNames));
}
/**
* @see TemplateOptions#networks(Iterable)
*/
public static AWSEC2TemplateOptions networks(Iterable<String> networks) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return AWSEC2TemplateOptions.class.cast(options.networks(networks));
}
}
// methods that only facilitate returning the correct object type
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions blockDeviceMappings(Iterable<? extends BlockDeviceMapping> blockDeviceMappings) {
return AWSEC2TemplateOptions.class.cast(super.blockDeviceMappings(blockDeviceMappings));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions userMetadata(Map<String, String> userMetadata) {
return AWSEC2TemplateOptions.class.cast(super.userMetadata(userMetadata));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions userMetadata(String key, String value) {
return AWSEC2TemplateOptions.class.cast(super.userMetadata(key, value));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions nodeNames(Iterable<String> nodeNames) {
return AWSEC2TemplateOptions.class.cast(super.nodeNames(nodeNames));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions networks(Iterable<String> networks) {
return AWSEC2TemplateOptions.class.cast(super.networks(networks));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions keyPair(String keyPair) {
return AWSEC2TemplateOptions.class.cast(super.keyPair(keyPair));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId, Integer sizeInGib,
boolean deleteOnTermination) {
return AWSEC2TemplateOptions.class.cast(super.mapEBSSnapshotToDeviceName(deviceName, snapshotId, sizeInGib,
deleteOnTermination));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions mapEphemeralDeviceToDeviceName(String deviceName, String virtualName) {
return AWSEC2TemplateOptions.class.cast(super.mapEphemeralDeviceToDeviceName(deviceName, virtualName));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib, boolean deleteOnTermination) {
return AWSEC2TemplateOptions.class.cast(super
.mapNewVolumeToDeviceName(deviceName, sizeInGib, deleteOnTermination));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions noKeyPair() {
return AWSEC2TemplateOptions.class.cast(super.noKeyPair());
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions securityGroups(Iterable<String> groupIds) {
return AWSEC2TemplateOptions.class.cast(super.securityGroups(groupIds));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions securityGroups(String... groupIds) {
return AWSEC2TemplateOptions.class.cast(super.securityGroups(groupIds));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions unmapDeviceNamed(String deviceName) {
return AWSEC2TemplateOptions.class.cast(super.unmapDeviceNamed(deviceName));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions userData(byte[] unencodedData) {
return AWSEC2TemplateOptions.class.cast(super.userData(unencodedData));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions blockOnPort(int port, int seconds) {
return AWSEC2TemplateOptions.class.cast(super.blockOnPort(port, seconds));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions inboundPorts(int... ports) {
return AWSEC2TemplateOptions.class.cast(super.inboundPorts(ports));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions authorizePublicKey(String publicKey) {
return AWSEC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions installPrivateKey(String privateKey) {
return AWSEC2TemplateOptions.class.cast(super.installPrivateKey(privateKey));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions blockUntilRunning(boolean blockUntilRunning) {
return AWSEC2TemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions dontAuthorizePublicKey() {
return AWSEC2TemplateOptions.class.cast(super.dontAuthorizePublicKey());
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions nameTask(String name) {
return AWSEC2TemplateOptions.class.cast(super.nameTask(name));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions runAsRoot(boolean runAsRoot) {
return AWSEC2TemplateOptions.class.cast(super.runAsRoot(runAsRoot));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions runScript(Statement script) {
return AWSEC2TemplateOptions.class.cast(super.runScript(script));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials) {
return AWSEC2TemplateOptions.class.cast(super.overrideLoginCredentials(overridingCredentials));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions overrideLoginPassword(String password) {
return AWSEC2TemplateOptions.class.cast(super.overrideLoginPassword(password));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions overrideLoginPrivateKey(String privateKey) {
return AWSEC2TemplateOptions.class.cast(super.overrideLoginPrivateKey(privateKey));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions overrideLoginUser(String loginUser) {
return AWSEC2TemplateOptions.class.cast(super.overrideLoginUser(loginUser));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) {
return AWSEC2TemplateOptions.class.cast(super.overrideAuthenticateSudo(authenticateSudo));
}
/**
* @return placementGroup to use when running the instance or null, to
* generate a placementGroup.
*/
public String getPlacementGroup() {
return placementGroup;
}
/**
* @return true (default) if we are supposed to use a placementGroup
*/
public boolean shouldAutomaticallyCreatePlacementGroup() {
return !noPlacementGroup;
}
/**
* @return true (default) if we are supposed to enable cloudwatch
*/
public boolean isMonitoringEnabled() {
return monitoringEnabled;
}
/**
* @return subnetId to use when running the instance or null.
*/
public String getSubnetId() {
return subnetId;
}
/**
* @return maximum spot price or null.
*/
public Float getSpotPrice() {
return spotPrice;
}
/**
* @return options for controlling spot instance requests.
*/
public RequestSpotInstancesOptions getSpotOptions() {
return spotOptions;
}
/**
* The Amazon resource name (ARN) of the IAM Instance Profile (IIP) to associate with the instance.
*
* @see org.jclouds.aws.ec2.options.AWSRunInstancesOptions#withIAMInstanceProfileArn(String)
*/
@SinceApiVersion("2012-06-01")
public String getIAMInstanceProfileArn() {
return iamInstanceProfileArn;
}
/**
* The name of the IAM Instance Profile (IIP) to associate with the instance.
*
* @see org.jclouds.aws.ec2.options.AWSRunInstancesOptions#withIAMInstanceProfileName(String)
*/
@SinceApiVersion("2012-06-01")
public String getIAMInstanceProfileName() {
return iamInstanceProfileName;
}
public String getPrivateIpAddress() {
return privateIpAddress;
}
}