lib/chef/knife/ec2_server_create.rb in knife-ec2-2.0.6 vs lib/chef/knife/ec2_server_create.rb in knife-ec2-2.1.0
- old
+ new
@@ -102,13 +102,15 @@
option :ebs_optimized,
long: "--ebs-optimized",
description: "Enabled optimized EBS I/O"
- option :ebs_no_delete_on_term,
- long: "--ebs-no-delete-on-term",
- description: "Do not delete EBS volume on instance termination"
+ option :ebs_delete_on_term,
+ long: "--ebs-delete-on-term",
+ description: "Delete EBS volume on instance termination",
+ boolean: true,
+ default: true
option :secret,
long: "--secret ",
description: "The secret key to use to encrypt data bag item values"
@@ -622,16 +624,22 @@
if (config[:ebs_volume_type] == "io1") && config[:ebs_provisioned_iops].nil?
ui.error("--provisioned-iops option is required when using volume type of 'io1'")
exit 1
end
- if config[:ebs_volume_type] && ! %w{gp2 io1 standard}.include?(config[:ebs_volume_type])
- ui.error("--ebs-volume-type must be 'standard' or 'io1' or 'gp2'")
+ if config[:ebs_volume_type] && ! %w{gp2 io1 standard st1 sc1}.include?(config[:ebs_volume_type])
+ ui.error("--ebs-volume-type must be 'standard' or 'io1' or 'gp2' or 'st1' or 'sc1'")
msg opt_parser
exit 1
end
+ # validation for ebs_size
+ if (%w{st1 sc1}.include?(config[:ebs_volume_type])) && ! config[:ebs_size].to_i.between?(500, 16384)
+ ui.error("--ebs-size should be in between 500-16384 for 'st1' or 'sc1' ebs volume type.")
+ exit 1
+ end
+
if config[:security_groups] && config[:security_groups].class == String
ui.error("Invalid value type for knife[:security_groups] in knife configuration file (i.e knife.rb/config.rb). Type should be array. e.g - knife[:security_groups] = ['sgroup1']")
exit 1
end
@@ -905,11 +913,11 @@
end
end
attributes[:ebs_optimized] = !!config[:ebs_optimized]
if ami.root_device_type == "ebs"
- if config[:ebs_encrypted]
+ if config[:ebs_encrypted] || %w{st1 sc1}.include?(config[:ebs_volume_type])
ami_map = ami.block_device_mappings[1]
else
ami_map = ami.block_device_mappings.first
end
@@ -922,14 +930,12 @@
rescue ArgumentError
puts "--ebs-size must be an integer"
msg opt_parser
exit 1
end
- delete_term = if config[:ebs_no_delete_on_term]
- "false"
- else
- ami_map.ebs.delete_on_termination if ami_map.ebs.respond_to?(:delete_on_termination)
- end
+
+ delete_term = config[:ebs_delete_on_term]
+
iops_rate = begin
if config[:ebs_provisioned_iops]
Integer(config[:ebs_provisioned_iops]).to_s
else
ami_map.ebs.iops.to_s if ami_map.ebs.respond_to?(:iops)