knife-ec2 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cdaebe8b7719446fee4ccf08e113714a64097e57
4
- data.tar.gz: 7dcf7fdc5ac57a4ce35baba78abeb67941d1c5bb
3
+ metadata.gz: 238f0a88ecd9813d5239ad922e42cb1428acd542
4
+ data.tar.gz: c6c9b3452ba8d207c85b82aa7bd2e879e2af6eeb
5
5
  SHA512:
6
- metadata.gz: d1dab754a4f35b7bb25f86a3d26623c0862d054ee242d11aef7fcdfaadc5ef02eb03bd38c7331542c70921c2d211c69c1afed3960b86a96845f71aeb7c8f4335
7
- data.tar.gz: 922f6bc7592ca622417475ceab90c54e1f43cfcf5c7797a1bb10708a19aaf8b1efedcc34857d2067bb22bc6b44af9cafba44bb6024eae7a4943c0418ecd4be88
6
+ metadata.gz: 7558bd27ec67e545fee9fb18c5f1be43aeea4cbeac604d8992daa9dec7359c34a42ca90981575dc1370f4066f4104ee1e43b8e89f846b958de18fff827a77bbc
7
+ data.tar.gz: d10d4bdb2174a1880814da08469bd279b9da1546778a48f60dde3589c9bf39dd8bb7085f4baad4574f929072a27ad1f0e87dc5e85f9e4d92192b8deeb51efd68
data/.travis.yml CHANGED
@@ -9,6 +9,6 @@ before_install:
9
9
  - rm -f .bundle/config
10
10
 
11
11
  rvm:
12
- - 2.1
13
- - 2.2
14
- script: bundle exec rspec --color --format progress
12
+ - 2.2.5
13
+ - 2.3.1
14
+ script: bundle exec rake spec
data/CHANGELOG.md CHANGED
@@ -4,7 +4,11 @@ Note: this log contains only changes from knife-ec2 release 0.8.0 and later
4
4
  -- it does not contain the changes from prior releases. To view change history
5
5
  prior to release 0.8.0, please visit the [source repository](https://github.com/chef/knife-ec2/commits).
6
6
 
7
- ## Latest Release 0.13.0 (2016-08-05)
7
+ ## Latest Release 0.14.0 (2016-12-02)
8
+ * [knife-ec2:#442](https://github.com/chef/knife-ec2/pull/442) Added support to show flavor list in json format.
9
+ * [knife-ec2:#439](https://github.com/chef/knife-ec2/pull/439) Allow to accept multiple security group ids using --security-group-id option multiple times and added deprecated message for comma seprated --security-group-ids option.
10
+
11
+ ## Release 0.13.0 (2016-08-05)
8
12
  * [knife-ec2:#438](https://github.com/chef/knife-ec2/pull/438) Specs for ec2 server list
9
13
  * [knife-ec2:#437](https://github.com/chef/knife-ec2/pull/437) Fix --aws-credential-file issues
10
14
  * [knife-ec2:#436](https://github.com/chef/knife-ec2/pull/436) basic is not a valid setting for winrm_ssl_verify_mode
@@ -40,8 +44,7 @@ prior to release 0.8.0, please visit the [source repository](https://github.com/
40
44
  * [knife-ec2:#363](https://github.com/chef/knife-ec2/pull/363) Add ssl config user data for ssl transport, if required append to user\_data script specified by user.
41
45
  * [knife-ec2:#319](https://github.com/chef/knife-ec2/pull/319) Pointing docs at itself. This is better then the non-existent chef.io docs.
42
46
 
43
- ## Latest Release: 0.12.0 (2015-10-1)
44
-
47
+ ## Release: 0.12.0 (2015-10-1)
45
48
  * [knife-ec2:#305](https://github.com/chef/knife-ec2/pull/305) Updates to support standard .aws/credentials file
46
49
  * [knife-ec2 #354](https://github.com/chef/knife-ec2/pull/354) knife-windows 1.0.0 dependency, support for validatorless bootstrap, other Chef 12 bootstrap options
47
50
  * [knife-ec2 #356](https://github.com/chef/knife-ec2/pull/356) Added --forward-agent option
data/CONTRIBUTIONS.md CHANGED
@@ -4,7 +4,3 @@ This file is reset every time a new release is done. The contents of this file a
4
4
  Example Contribution:
5
5
  * **kalistec**: Improved file resource greatly.
6
6
  -->
7
- # knife-ec2 0.13.0:
8
-
9
- * **quentindemetz**: Added ability to use `Classic Link`.
10
- * **eherot**: Added ability to attach `Network Interfaces`.
data/DOC_CHANGES.md CHANGED
@@ -4,33 +4,14 @@ This file is reset everytime when a new release is done. Contents of this file i
4
4
 
5
5
  # knife-ec2 doc changes
6
6
 
7
- Documentation changes are given below for **kn9fe-ec2 version 0.13.0**.
8
-
9
- ## `--aws-config-file` option for all commands
10
-
11
- The `--aws-config-file` option allows users to reuse configuration settings from the AWS command line tools so that `knife` can access EC2 resources.
7
+ Documentation changes are given below for **knife-ec2 version 0.14.0**.
12
8
 
13
9
  ## `knife ec2 server create` subcommand changes
14
10
 
15
- ### `--spot-wait-mode` option
16
-
17
- The `--spot-wait-mode` option allows knife to respond in different ways when the `server create` subcommand is used to create a spot instance that is not immediately created when the subcommand is executed. Possible options are:
18
-
19
- * `wait` -- waits indefinitely for the instance to be created
20
- * `exit` -- exits if the instance is not yet created (it may be bootstrapped via the `knife bootstrap` command at a later time).
21
- * `prompt` (default) -- interactively prompts the user for one of the above options.
22
-
23
- ### `--create-ssl-listener`
24
- The `--create-ssl-listener` option is applicable only when creating a Windows instance. When specified, the subcommand will create a `WinRM` listener on the new instance that uses the SSL transport, and will attempt to bootstrap the node using that listener. The default behavior is to use the SSL transport, the `--no-create-ssl-listener` option can be used to override the default and instead use a less secure plaintext listener.
25
-
26
- ### `--attach-network-interface`
27
- The `--attach-network-interface` option allows the user to specify a list of network interfaces in the form `ENI1,ENI2,...` as additional interfaces to attach to the instance when it is created.
11
+ ### `--security-group-id` option
28
12
 
29
- ### `--classic-link-vpc-id`
30
- The `--classic-link-vpc-id` option allows the user to specify a VPC that is [ClassicLink](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/vpc-classiclink.html)-enabled by specifying the VPC's ID as an argument. The created instance will be linked to that VPC.
13
+ The `--security-group-id` option allows the user to specify the security group id for server and is required when using VPC. Multiple security groups may be specified by using this option multiple times, e.g. `-g sg-e985168d -g sg-e7f06383 -g sg-ec1b7e88`.
31
14
 
32
- ### `--classic-link-vpc-security-groups-ids`
33
- The `--classic-link-vpc-security-groups-ids` option allows the user to specify AWS security groups for the VPC specified with the `--classic-link-vpc-id` option.
15
+ ### `--security-group-ids` option
34
16
 
35
- ### `--disable-api-termination`
36
- The `--disable-api-termination` option allows the user to disable the termination of the instance using the Amazon EC2 console, CLI and API. However, this option won't work for `spot instances` as `termination protection` cannot be enabled for `spot instances`.
17
+ The previous option for specifying security groups, `--security-group-ids` (plural), is deprecated in favor of the `--security-group-id` option which mimics the more standard behavior for supplying multiple arguments across the ecosystem. This option will be removed in future release.
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- gem "rack", "< 2.0" # 2.0 requires Ruby 2.2+
5
- gem 'rb-readline'
4
+ gem 'rb-readline'
data/RELEASE_NOTES.md CHANGED
@@ -6,31 +6,15 @@ Example Note:
6
6
  ## Example Heading
7
7
  Details about the thing that changed that needs to get included in the Release Notes in markdown.
8
8
  -->
9
- # knife-ec2 0.13.0 release notes:
10
9
 
11
- This release of `knife-ec2` adds feature to bootstrap Windows instances over SSL without the need for users to provide the `user-data`. Also, it adds support for users to pass `AWS config file` option on the `CLI` containing the `AWS configurations` to read the config like `region` information.
10
+ # knife-ec2 0.14.0 release notes:
12
11
 
13
- ***Note:*** The bootstrap (over SSL without the `user-data`) feature for Windows is available only for Windows 2012 R2 and above platform.
12
+ This release of `knife-ec2` contains minor bug fixes.
14
13
 
14
+ ## Features added in knife-ec2 0.14.0
15
15
 
16
- ## Features added in knife-ec2 0.13.0
16
+ * Added support to `flavor list` in json format using `--format json` option.
17
17
 
18
- * `--[no-]create-ssl-listener` option to add `ssl listener` on Windows instance to bootstrap the instance through `winrm ssl transport` without the need for users to pass the `user-data`. Default value of this option is `true`.
19
- * Support for `~/.aws/config` file for reading aws configurations. Use `--aws-config-file` option for the same.
20
- * Support to read `aws_session_token` from `~/.aws/credentials` file.
21
- * Support for `ec2 classic link`, options are `--classic-link-vpc-id` and `--classic-link-vpc-security-groups-ids`.
22
- * Support for `m4`, `d2`, `t2` and `g2` ebs encryption flavors.
23
- * Use `--format json` option to list the `ec2 servers` in the json format. Default output format is `summary` though.
24
- * Use `--attach-network-interface` option to attach additional `network interfaces` to the instance.
25
- * Added `--disable-api-termination` option to allow users to disable the termination of the instance using the Amazon EC2 console, CLI and API. However, this option won't work for `spot instances` as `termination protection` cannot be enabled for `spot instances`.
26
- * Added `--spot-wait-mode` option to enable users to give their decision on CLI whether to `wait` for the `spot request fulfillment` or to `exit` before the `spot request fulfillment`. Default value for this option is `prompt` which will prompt the user to give their choice.
18
+ * `--security-group-id` option to specify security groups for the server. This opiton can be used multiple times when specifying multiple security groups. e.g. `-g sg-e985168d -g sg-e7f06383 -g sg-ec1b7e88`.
27
19
 
28
- ## Acknowledgements
29
-
30
- Our thanks go to contributor **Quentin de Metz** for adding
31
- [knife-ec2:#322](https://github.com/chef/knife-ec2/pull/322). This
32
- enables the support for `Classic Link` in the `knife ec2 server create` command.
33
-
34
- Our thanks go to contributor **Eric Herot** for adding
35
- [knife-ec2:#375](https://github.com/chef/knife-ec2/pull/375). This
36
- enables the users to add additional `Network Interfaces` to the instance before the bootstrap process.
20
+ ***Note:*** The `--security-group-ids` option will be removed in a future release. Use the new `--security-group-id` option.
data/knife-ec2.gemspec CHANGED
@@ -1,29 +1,30 @@
1
- # -*- encoding: utf-8 -*-
2
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
- require 'knife-ec2/version'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'knife-ec2'
7
- s.version = Knife::Ec2::VERSION
8
- s.authors = ['Adam Jacob', 'Seth Chisamore']
9
- s.email = ['adam@chef.io', 'schisamo@chef.io']
10
- s.homepage = 'https://github.com/chef/knife-ec2'
11
- s.summary = "EC2 Support for Chef's Knife Command"
12
- s.description = s.summary
13
- s.license = 'Apache-2.0'
14
-
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
18
-
19
- s.add_dependency 'fog-aws', '~> 0.7'
20
- s.add_dependency 'mime-types'
21
- s.add_dependency 'knife-windows', '~> 1.0'
22
-
23
- s.add_development_dependency 'chef', '~> 12.0', '>= 12.2.1'
24
- s.add_development_dependency 'rspec', '~> 3.0'
25
- s.add_development_dependency 'rake', '~> 10.1'
26
- s.add_development_dependency 'sdoc', '~> 0.3'
27
-
28
- s.require_paths = ['lib']
29
- end
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'knife-ec2/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'knife-ec2'
7
+ s.version = Knife::Ec2::VERSION
8
+ s.authors = ['Adam Jacob', 'Seth Chisamore']
9
+ s.email = ['adam@chef.io', 'schisamo@chef.io']
10
+ s.homepage = 'https://github.com/chef/knife-ec2'
11
+ s.summary = "EC2 Support for Chef's Knife Command"
12
+ s.description = s.summary
13
+ s.license = 'Apache-2.0'
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
18
+ s.required_ruby_version = ">= 2.2.2"
19
+
20
+ s.add_dependency 'fog-aws', '~> 0.7'
21
+ s.add_dependency 'mime-types'
22
+ s.add_dependency 'knife-windows', '~> 1.0'
23
+
24
+ s.add_development_dependency 'chef', '~> 12.0', '>= 12.2.1'
25
+ s.add_development_dependency 'rspec', '~> 3.0'
26
+ s.add_development_dependency 'rake', '~> 11.0'
27
+ s.add_development_dependency 'sdoc', '~> 0.3'
28
+
29
+ s.require_paths = ['lib']
30
+ end
@@ -1,53 +1,58 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@chef.io>)
3
- # Copyright:: Copyright (c) 2012-2015 Chef Software, Inc.
4
- # License:: Apache License, Version 2.0
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
-
19
- require 'chef/knife/ec2_base'
20
-
21
- class Chef
22
- class Knife
23
- class Ec2FlavorList < Knife
24
-
25
- include Knife::Ec2Base
26
-
27
- banner "knife ec2 flavor list (options)"
28
-
29
- def run
30
-
31
- validate!
32
-
33
- flavor_list = [
34
- ui.color('ID', :bold),
35
- ui.color('Name', :bold),
36
- ui.color('Architecture', :bold),
37
- ui.color('RAM', :bold),
38
- ui.color('Disk', :bold),
39
- ui.color('Cores', :bold)
40
- ]
41
- connection.flavors.sort_by(&:id).each do |flavor|
42
- flavor_list << flavor.id.to_s
43
- flavor_list << flavor.name
44
- flavor_list << "#{flavor.bits.to_s}-bit"
45
- flavor_list << "#{flavor.ram.to_s}"
46
- flavor_list << "#{flavor.disk.to_s} GB"
47
- flavor_list << flavor.cores.to_s
48
- end
49
- puts ui.list(flavor_list, :columns_across, 6)
50
- end
51
- end
52
- end
53
- end
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
+ # Copyright:: Copyright (c) 2012-2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
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
+
19
+ require 'chef/knife/ec2_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class Ec2FlavorList < Knife
24
+
25
+ include Knife::Ec2Base
26
+
27
+ banner "knife ec2 flavor list (options)"
28
+
29
+ def run
30
+
31
+ validate!
32
+
33
+ flavor_list = [
34
+ ui.color('ID', :bold),
35
+ ui.color('Name', :bold),
36
+ ui.color('Architecture', :bold),
37
+ ui.color('RAM', :bold),
38
+ ui.color('Disk', :bold),
39
+ ui.color('Cores', :bold)
40
+ ]
41
+ flavors = connection.flavors.sort_by(&:id)
42
+ if (config[:format] == 'summary')
43
+ flavors.each do |flavor|
44
+ flavor_list << flavor.id.to_s
45
+ flavor_list << flavor.name
46
+ flavor_list << "#{flavor.bits.to_s}-bit"
47
+ flavor_list << "#{flavor.ram.to_s}"
48
+ flavor_list << "#{flavor.disk.to_s} GB"
49
+ flavor_list << flavor.cores.to_s
50
+ end
51
+ puts ui.list(flavor_list, :columns_across, 6)
52
+ else
53
+ output(format_for_display(flavors))
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -67,10 +67,28 @@ class Chef
67
67
  :proc => Proc.new { |groups| groups.split(',') }
68
68
 
69
69
  option :security_group_ids,
70
- :short => "-g 'X,Y,Z'",
71
70
  :long => "--security-group-ids 'X,Y,Z'",
72
- :description => "The security group ids for this server; required when using VPC,Please provide values in format --security-group-ids 'X,Y,Z'",
73
- :proc => Proc.new { |security_group_ids| security_group_ids.split(',') }
71
+ :description => "The security group ids for this server; required when using VPC. Provide values in format --security-group-ids 'X,Y,Z'. [DEPRECATED] This option will be removed in future release. Use the new --security-group-id option. ",
72
+ :proc => Proc.new { |security_group_ids|
73
+ ui.warn('[DEPRECATED] This option will be removed in future release. Use the new --security-group-id option multiple times when specifying multiple groups for e.g. -g sg-e985168d -g sg-e7f06383 -g sg-ec1b7e88.')
74
+ if security_group_ids.gsub(' ', '').split(',').size > 1
75
+ Chef::Config[:knife][:security_group_ids] = security_group_ids.gsub(' ', '').split(',')
76
+ else
77
+ Chef::Config[:knife][:security_group_ids] ||= []
78
+ Chef::Config[:knife][:security_group_ids].push(security_group_ids)
79
+ Chef::Config[:knife][:security_group_ids]
80
+ end
81
+ }
82
+
83
+ option :security_group_id,
84
+ :short => "-g SECURITY_GROUP_ID",
85
+ :long => "--security-group-id ID",
86
+ :description => "The security group id for this server; required when using VPC. Use the --security-group-id option multiple times when specifying multiple groups for e.g. -g sg-e985168d -g sg-e7f06383 -g sg-ec1b7e88.",
87
+ :proc => Proc.new { |security_group_id|
88
+ Chef::Config[:knife][:security_group_ids] ||= []
89
+ Chef::Config[:knife][:security_group_ids].push(security_group_id)
90
+ Chef::Config[:knife][:security_group_ids]
91
+ }
74
92
 
75
93
  option :associate_eip,
76
94
  :long => "--associate-eip IP_ADDRESS",
@@ -426,7 +444,6 @@ class Chef
426
444
 
427
445
  def run
428
446
  $stdout.sync = true
429
-
430
447
  validate!
431
448
 
432
449
  requested_elastic_ip = config[:associate_eip] if config[:associate_eip]
@@ -436,7 +453,7 @@ class Chef
436
453
 
437
454
  if locate_config_value(:spot_price)
438
455
  server_def = create_server_def
439
- server_def[:groups] = config[:security_group_ids] if vpc_mode?
456
+ server_def[:groups] = server_def[:security_group_ids] if vpc_mode?
440
457
  spot_request = connection.spot_requests.create(server_def)
441
458
  msg_pair("Spot Request ID", spot_request.id)
442
459
  msg_pair("Spot Request Type", spot_request.request_type)
@@ -469,7 +486,13 @@ class Chef
469
486
  puts("\n")
470
487
  @server = connection.servers.get(spot_request.instance_id)
471
488
  else
472
- @server = connection.servers.create(create_server_def)
489
+ begin
490
+ @server = connection.servers.create(create_server_def)
491
+ rescue => error
492
+ ui.error error.message
493
+ Chef::Log.debug("#{error.backtrace.join("\n")}")
494
+ exit
495
+ end
473
496
  end
474
497
 
475
498
  hashed_tags={}
@@ -696,7 +719,7 @@ class Chef
696
719
  bootstrap.config[:encrypted_data_bag_secret] = s3_secret || locate_config_value(:secret)
697
720
  bootstrap.config[:encrypted_data_bag_secret_file] = locate_config_value(:secret_file)
698
721
  # retrieving the secret from S3 is unique to knife-ec2, so we need to set "command line secret" to the value fetched from S3
699
- # When linux vm is spawned, the chef's secret option proc function sets the value "command line secret" and this value is used by
722
+ # When linux vm is spawned, the chef's secret option proc function sets the value "command line secret" and this value is used by
700
723
  # chef's code to check if secret option is passed through command line or not
701
724
  Chef::Knife::DataBagSecretOptions.set_cl_secret(s3_secret) if locate_config_value(:s3_secret)
702
725
  bootstrap.config[:secret] = s3_secret || locate_config_value(:secret)
@@ -852,7 +875,8 @@ class Chef
852
875
  exit 1
853
876
  end
854
877
 
855
- if config[:security_group_ids] && config[:security_group_ids].class == String
878
+ # Validation for security_group_ids passed through knife.rb. It will raise error if values are not provided in Array.
879
+ if locate_config_value(:security_group_ids) && locate_config_value(:security_group_ids).class == String
856
880
  ui.error("Invalid value type for knife[:security_group_ids] in knife configuration file (i.e knife.rb). Type should be array. e.g - knife[:security_group_ids] = ['sgroup1']")
857
881
  exit 1
858
882
  end
@@ -932,10 +956,10 @@ class Chef
932
956
 
933
957
  def ssl_config_user_data
934
958
  user_related_commands = ""
935
- winrm_user = locate_config_value(:winrm_user).split("\\")
959
+ winrm_user = locate_config_value(:winrm_user).split("\\")
936
960
  if (winrm_user[0] == ".") || (winrm_user[0] == "") ||(winrm_user.length == 1)
937
961
  user_related_commands = <<-EOH
938
- net user /add #{locate_config_value(:winrm_user).delete('.\\')} #{windows_password};
962
+ net user /add #{locate_config_value(:winrm_user).delete('.\\')} #{windows_password};
939
963
  net localgroup Administrators /add #{locate_config_value(:winrm_user).delete('.\\')};
940
964
  EOH
941
965
  end
@@ -985,13 +1009,14 @@ EOH
985
1009
  server_def = {
986
1010
  :image_id => locate_config_value(:image),
987
1011
  :groups => config[:security_groups],
988
- :security_group_ids => locate_config_value(:security_group_ids),
989
1012
  :flavor_id => locate_config_value(:flavor),
990
1013
  :key_name => locate_config_value(:ssh_key_name),
991
1014
  :availability_zone => locate_config_value(:availability_zone),
992
1015
  :price => locate_config_value(:spot_price),
993
1016
  :request_type => locate_config_value(:spot_request_type)
994
1017
  }
1018
+
1019
+ server_def[:security_group_ids] = locate_config_value(:security_group_ids)
995
1020
  server_def[:subnet_id] = locate_config_value(:subnet_id) if vpc_mode?
996
1021
  server_def[:private_ip_address] = locate_config_value(:private_ip_address) if vpc_mode?
997
1022
  server_def[:placement_group] = locate_config_value(:placement_group)
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Ec2
3
- VERSION = "0.13.0"
3
+ VERSION = "0.14.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
@@ -0,0 +1,74 @@
1
+ # License:: Apache License, Version 2.0
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+
16
+ require File.expand_path('../../spec_helper', __FILE__)
17
+ require 'fog/aws'
18
+ require 'chef/knife/ec2_flavor_list'
19
+
20
+ describe Chef::Knife::Ec2FlavorList do
21
+
22
+ describe '#run' do
23
+ let(:knife_flavor_list) { Chef::Knife::Ec2FlavorList.new }
24
+ let(:ec2_connection) { double(Fog::Compute::AWS) }
25
+ before do
26
+ allow(knife_flavor_list).to receive(:connection).and_return(ec2_connection)
27
+ @flavor1 = double("flavor1", :name => "High-CPU Medium", :architecture => "32-bit-bit", :id => "c1.medium", :bits => "32-bit", :cores => "5", :disk => "1740.8 GB", :ram => "350 GB", :ebs_optimized_available => "false", :instance_store_volumes => "0")
28
+
29
+ allow(ec2_connection).to receive(:flavors).and_return([@flavor1])
30
+
31
+ end
32
+
33
+ it 'invokes validate!' do
34
+ ec2_flavors = double(:sort_by => [])
35
+
36
+ allow(ec2_connection).to receive(:flavors).and_return(ec2_flavors)
37
+ allow(knife_flavor_list.ui).to receive(:warn)
38
+ expect(knife_flavor_list).to receive(:validate!)
39
+ knife_flavor_list.run
40
+ end
41
+
42
+
43
+ context '--format option' do
44
+ context 'when format=summary' do
45
+ before do
46
+ @output_s=["ID", "Name", "Architecture", "RAM", "Disk", "Cores", "c1.medium", "High-CPU Medium", "32-bit-bit", "350 GB", "1740.8 GB GB", "5"]
47
+ knife_flavor_list.config[:format] = 'summary'
48
+ allow(knife_flavor_list.ui).to receive(:warn)
49
+ allow(knife_flavor_list).to receive(:validate!)
50
+ end
51
+
52
+ it 'shows the output in summary format' do
53
+ expect(knife_flavor_list.ui).to receive(:list).with(@output_s,:columns_across,6)
54
+ knife_flavor_list.run
55
+ end
56
+ end
57
+
58
+ context 'when format=json' do
59
+ before do
60
+ knife_flavor_list.config[:format] = 'json'
61
+ allow(knife_flavor_list.ui).to receive(:warn)
62
+ end
63
+
64
+ it 'shows the output in json format' do
65
+ allow(ec2_connection).to receive(:flavors).and_return([])
66
+ allow(knife_flavor_list).to receive(:validate!)
67
+ allow(knife_flavor_list).to receive(:format_for_display)
68
+ expect(knife_flavor_list).to receive(:output)
69
+ knife_flavor_list.run
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end