knife-openstack 1.3.2.pre → 1.3.2.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile +1 -1
  4. data/Rakefile +7 -28
  5. data/knife-openstack.gemspec +16 -16
  6. data/lib/chef/knife/cloud/openstack_server_create_options.rb +44 -44
  7. data/lib/chef/knife/cloud/openstack_service.rb +27 -31
  8. data/lib/chef/knife/cloud/openstack_service_options.rb +25 -26
  9. data/lib/chef/knife/openstack_flavor_list.rb +9 -10
  10. data/lib/chef/knife/openstack_floating_ip_allocate.rb +4 -4
  11. data/lib/chef/knife/openstack_floating_ip_associate.rb +5 -5
  12. data/lib/chef/knife/openstack_floating_ip_disassociate.rb +4 -4
  13. data/lib/chef/knife/openstack_group_list.rb +9 -11
  14. data/lib/chef/knife/openstack_helpers.rb +14 -2
  15. data/lib/chef/knife/openstack_image_list.rb +14 -15
  16. data/lib/chef/knife/openstack_network_list.rb +8 -9
  17. data/lib/chef/knife/openstack_server_create.rb +81 -84
  18. data/lib/chef/knife/openstack_server_delete.rb +25 -26
  19. data/lib/chef/knife/openstack_server_list.rb +13 -19
  20. data/lib/chef/knife/openstack_server_show.rb +11 -12
  21. data/lib/chef/knife/openstack_volume_list.rb +10 -12
  22. data/lib/knife-openstack/version.rb +1 -1
  23. data/spec/functional/flavor_list_func_spec.rb +11 -11
  24. data/spec/functional/floating_ip_list_func_spec.rb +11 -11
  25. data/spec/functional/group_list_func_spec.rb +27 -31
  26. data/spec/functional/image_list_func_spec.rb +14 -14
  27. data/spec/functional/network_list_func_spec.rb +10 -10
  28. data/spec/functional/server_create_func_spec.rb +23 -24
  29. data/spec/functional/server_delete_func_spec.rb +16 -17
  30. data/spec/functional/server_list_func_spec.rb +39 -39
  31. data/spec/functional/server_show_func_spec.rb +4 -5
  32. data/spec/functional/volume_list_func_spec.rb +9 -9
  33. data/spec/integration/cleanup.rb +8 -11
  34. data/spec/integration/openstack_spec.rb +377 -347
  35. data/spec/spec_context.rb +10 -10
  36. data/spec/spec_helper.rb +23 -27
  37. data/spec/unit/openstack_flavor_list_spec.rb +1 -1
  38. data/spec/unit/openstack_floating_ip_allocate_spec.rb +2 -3
  39. data/spec/unit/openstack_floating_ip_associate_spec.rb +2 -2
  40. data/spec/unit/openstack_floating_ip_disassociate_spec.rb +3 -3
  41. data/spec/unit/openstack_floating_ip_release_spec.rb +1 -1
  42. data/spec/unit/openstack_group_list_spec.rb +7 -7
  43. data/spec/unit/openstack_image_list_spec.rb +2 -2
  44. data/spec/unit/openstack_network_list_spec.rb +4 -4
  45. data/spec/unit/openstack_server_create_spec.rb +117 -118
  46. data/spec/unit/openstack_server_delete_spec.rb +4 -4
  47. data/spec/unit/openstack_server_list_spec.rb +2 -2
  48. data/spec/unit/openstack_server_show_spec.rb +6 -6
  49. data/spec/unit/openstack_service_spec.rb +20 -20
  50. data/spec/unit/openstack_volume_list_spec.rb +1 -1
  51. metadata +30 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 261ad74f7d4dd9418c60d6b6e744c20cb0c7cf4e
4
- data.tar.gz: 29b8fac9abe06d9e13f62daa3bc47a38577ae5d5
3
+ metadata.gz: b05331ec3545a48444fc877d7889747529f0d7e3
4
+ data.tar.gz: 92baa1e81349f00f1e7f58df5b2d297b15a2f51f
5
5
  SHA512:
6
- metadata.gz: af0598ea940d2ff7da0d956aafb55935e87e5d92b23689e04474d93372af89a092aa4e9f5473addb0470c8b39f2aa500450c9b1ae229b0d40cd3293fe541969a
7
- data.tar.gz: 1388e094ba739d98c3219dfa8ac4b50eeebc0ce3042514e03393f7aebeea1800766e61054dc0676cc1e5b256fb3e05fbac7b7067238ab0bdbb3947d1def60705
6
+ metadata.gz: b2adbd1e48f537165d606ac669515a0d39f26a34e345656a88b4623a4a05ca265d8f5f36f59d1b59bd0f7adbef392286836cae918f07a9da28b9380b1ef89511
7
+ data.tar.gz: 20d830cb5e373c9ba05020678c41385cb1d87758ca14777bb858b140c743e0ee244de71410194c9119021c4c5f0ce7544d6c569f4caf6f48f9dddad955eddaf0
@@ -1,3 +1,7 @@
1
+ ## v1.3.2.pre
2
+ * Fix cloud command class loading #174
3
+ * Fix for #178 for the listing of ips with `knife openstack server list`
4
+
1
5
  ## v1.2.0
2
6
  * Allow users to specify alternate private networks. #163
3
7
  * Vol sched 1.0.0work #142
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in knife-openstack.gemspec
4
4
  gemspec
data/Rakefile CHANGED
@@ -2,34 +2,13 @@
2
2
  # Copyright:: Copyright (c) 2013 Chef Software, Inc.
3
3
 
4
4
  require 'bundler'
5
- Bundler::GemHelper.install_tasks
5
+ require 'bundler/setup'
6
+ require 'bundler/gem_tasks'
7
+ require 'rubocop/rake_task'
8
+ require 'rspec/core/rake_task'
6
9
 
7
- require 'rubygems'
8
- require 'rubygems/package_task'
10
+ RuboCop::RakeTask.new
9
11
 
10
- task :default => :all
11
- task :all => [:spec, :uninstall, :install]
12
+ RSpec::Core::RakeTask.new(:spec)
12
13
 
13
- # Packaging
14
- GEM_NAME = "knife-openstack"
15
- require File.dirname(__FILE__) + '/lib/knife-openstack/version'
16
- spec = eval(File.read("knife-openstack.gemspec"))
17
- Gem::PackageTask.new(spec) do |pkg|
18
- pkg.gem_spec = spec
19
- end
20
-
21
- desc "uninstall #{GEM_NAME}-#{Knife::OpenStack::VERSION}.gem from system..."
22
- task :uninstall do
23
- sh %{gem uninstall #{GEM_NAME} -x -v #{Knife::OpenStack::VERSION} }
24
- end
25
-
26
- # rspec
27
- begin
28
- require 'rspec/core/rake_task'
29
- desc "Run all specs in spec directory"
30
- RSpec::Core::RakeTask.new(:spec) do |t|
31
- t.pattern = 'spec/unit/**/*_spec.rb'
32
- end
33
- rescue LoadError
34
- STDERR.puts "\n*** RSpec not available. (sudo) gem install rspec to run unit tests. ***\n\n"
35
- end
14
+ task default: [:rubocop, :spec]
@@ -1,28 +1,28 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "knife-openstack/version"
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'knife-openstack/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "knife-openstack"
6
+ s.name = 'knife-openstack'
7
7
  s.version = Knife::OpenStack::VERSION
8
8
  s.version = "#{s.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
9
- s.platform = Gem::Platform::RUBY
9
+ s.platform = Gem::Platform::RUBY
10
10
  s.has_rdoc = true
11
- s.extra_rdoc_files = ["README.md", "LICENSE" ]
12
- s.authors = ["JJ Asghar"]
13
- s.email = ["jj@chef.io"]
14
- s.homepage = "https://github.com/chef/knife-openstack"
15
- s.summary = %q{A Chef knife plugin for OpenStack clouds.}
16
- s.description = %q{A Chef knife plugin for OpenStack clouds.}
11
+ s.extra_rdoc_files = ['README.md', 'LICENSE']
12
+ s.authors = ['JJ Asghar']
13
+ s.email = ['jj@chef.io']
14
+ s.homepage = 'https://github.com/chef/knife-openstack'
15
+ s.summary = 'A Chef knife plugin for OpenStack clouds.'
16
+ s.description = 'A Chef knife plugin for OpenStack clouds.'
17
17
 
18
18
  s.files = `git ls-files`.split("\n")
19
19
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
- s.require_paths = ["lib"]
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
21
+ s.require_paths = ['lib']
22
22
 
23
- s.add_dependency "fog", "~> 1.23"
24
- s.add_dependency "chef", ">= 11"
25
- s.add_dependency "knife-cloud", "~> 1.2.0"
23
+ s.add_dependency 'fog', '~> 1.23'
24
+ s.add_dependency 'chef', '>= 11'
25
+ s.add_dependency 'knife-cloud', '~> 1.2.0'
26
26
 
27
- %w(rake rspec-core rspec-expectations rspec-mocks rspec_junit_formatter).each { |gem| s.add_development_dependency gem }
27
+ %w(bundler rubocop rake rspec-core rspec-expectations rspec-mocks rspec_junit_formatter).each { |gem| s.add_development_dependency gem }
28
28
  end
@@ -11,72 +11,72 @@ class Chef
11
11
 
12
12
  # Openstack Server create params.
13
13
  option :private_network,
14
- :long => "--openstack-private-network",
15
- :description => "Use the private IP for bootstrapping rather than the public IP",
16
- :boolean => true,
17
- :default => false
14
+ long: '--openstack-private-network',
15
+ description: 'Use the private IP for bootstrapping rather than the public IP',
16
+ boolean: true,
17
+ default: false
18
18
 
19
19
  option :openstack_floating_ip,
20
- :short => "-a [IP]",
21
- :long => "--openstack-floating-ip [IP]",
22
- :default => "-1",
23
- :description => "Request to associate a floating IP address to the new OpenStack node. Assumes IPs have been allocated to the project. Specific IP is optional."
20
+ short: '-a [IP]',
21
+ long: '--openstack-floating-ip [IP]',
22
+ default: '-1',
23
+ description: 'Request to associate a floating IP address to the new OpenStack node. Assumes IPs have been allocated to the project. Specific IP is optional.'
24
24
 
25
25
  option :openstack_volumes,
26
- :long => "--openstack-volumes VOLUME1,VOLUME2,VOLUME3",
27
- :description => "Comma separated list of the UUID(s) of the volume(s) to attach to the server",
28
- :proc => Proc.new { |volumes| volumes.split(',') }
26
+ long: '--openstack-volumes VOLUME1,VOLUME2,VOLUME3',
27
+ description: 'Comma separated list of the UUID(s) of the volume(s) to attach to the server',
28
+ proc: proc { |volumes| volumes.split(',') }
29
29
 
30
30
  option :openstack_scheduler_hints,
31
- :long => "--scheduler-hints HINTS",
32
- :description => "A scheduler group hint to OpenStack",
33
- :proc => Proc.new { |i| Chef::Config[:knife][:openstack_scheduler_hints] = i }
31
+ long: '--scheduler-hints HINTS',
32
+ description: 'A scheduler group hint to OpenStack',
33
+ proc: proc { |i| Chef::Config[:knife][:openstack_scheduler_hints] = i }
34
34
 
35
35
  option :openstack_security_groups,
36
- :short => "-G X,Y,Z",
37
- :long => "--openstack-groups X,Y,Z",
38
- :description => "The security groups for this server",
39
- :default => ["default"],
40
- :proc => Proc.new { |groups| groups.split(',') }
36
+ short: '-G X,Y,Z',
37
+ long: '--openstack-groups X,Y,Z',
38
+ description: 'The security groups for this server',
39
+ default: ['default'],
40
+ proc: proc { |groups| groups.split(',') }
41
41
 
42
42
  option :openstack_ssh_key_id,
43
- :short => "-S KEY",
44
- :long => "--openstack-ssh-key-id KEY",
45
- :description => "The OpenStack SSH keypair id",
46
- :proc => Proc.new { |key| Chef::Config[:knife][:openstack_ssh_key_id] = key }
43
+ short: '-S KEY',
44
+ long: '--openstack-ssh-key-id KEY',
45
+ description: 'The OpenStack SSH keypair id',
46
+ proc: proc { |key| Chef::Config[:knife][:openstack_ssh_key_id] = key }
47
47
 
48
48
  option :user_data,
49
- :long => "--user-data USER_DATA",
50
- :description => "The file path containing user data information for this server",
51
- :proc => Proc.new { |user_data| open(user_data) { |f| f.read } }
49
+ long: '--user-data USER_DATA',
50
+ description: 'The file path containing user data information for this server',
51
+ proc: proc { |user_data| open(user_data, &:read) }
52
52
 
53
53
  option :bootstrap_network,
54
- :long => '--bootstrap-network NAME',
55
- :default => 'public',
56
- :description => "Specify network for bootstrapping. Default is 'public'."
54
+ long: '--bootstrap-network NAME',
55
+ default: 'public',
56
+ description: "Specify network for bootstrapping. Default is 'public'."
57
57
 
58
58
  option :network,
59
- :long => "--no-network",
60
- :boolean => true,
61
- :default => true,
62
- :description => "Use first available network for bootstrapping if 'public' and 'private' are unavailable."
59
+ long: '--no-network',
60
+ boolean: true,
61
+ default: true,
62
+ description: "Use first available network for bootstrapping if 'public' and 'private' are unavailable."
63
63
 
64
64
  option :network_ids,
65
- :long => "--network-ids NETWORK_ID_1,NETWORK_ID_2,NETWORK_ID_3",
66
- :description => "Comma separated list of the UUID(s) of the network(s) for the server to attach",
67
- :proc => Proc.new { |networks| networks.split(',') }
65
+ long: '--network-ids NETWORK_ID_1,NETWORK_ID_2,NETWORK_ID_3',
66
+ description: 'Comma separated list of the UUID(s) of the network(s) for the server to attach',
67
+ proc: proc { |networks| networks.split(',') }
68
68
 
69
69
  option :availability_zone,
70
- :short => "-Z ZONE_NAME",
71
- :long => "--availability-zone ZONE_NAME",
72
- :description => "The availability zone for this server",
73
- :proc => Proc.new { |z| Chef::Config[:knife][:availability_zone] = z }
70
+ short: '-Z ZONE_NAME',
71
+ long: '--availability-zone ZONE_NAME',
72
+ description: 'The availability zone for this server',
73
+ proc: proc { |z| Chef::Config[:knife][:availability_zone] = z }
74
74
 
75
75
  option :metadata,
76
- :short => "-M X=1",
77
- :long => "--metadata X=1",
78
- :description => "Metadata information for this server (may pass multiple times)",
79
- :proc => Proc.new { |data| Chef::Config[:knife][:metadata] ||= {}; Chef::Config[:knife][:metadata].merge!({data.split('=')[0]=>data.split('=')[1]})}
76
+ short: '-M X=1',
77
+ long: '--metadata X=1',
78
+ description: 'Metadata information for this server (may pass multiple times)',
79
+ proc: proc { |data| Chef::Config[:knife][:metadata] ||= {}; Chef::Config[:knife][:metadata].merge!(data.split('=')[0] => data.split('=')[1]) }
80
80
  end
81
81
  end
82
82
  end
@@ -10,53 +10,49 @@ class Chef
10
10
  class Knife
11
11
  class Cloud
12
12
  class OpenstackService < FogService
13
-
14
13
  def initialize(options = {})
15
14
  Chef::Log.debug("openstack_username #{Chef::Config[:knife][:openstack_username]}")
16
15
  Chef::Log.debug("openstack_auth_url #{Chef::Config[:knife][:openstack_auth_url]}")
17
16
  Chef::Log.debug("openstack_tenant #{Chef::Config[:knife][:openstack_tenant]}")
18
- Chef::Log.debug("openstack_endpoint_type #{Chef::Config[:knife][:openstack_endpoint_type] || 'publicURL' }")
19
- Chef::Log.debug("openstack_insecure #{Chef::Config[:knife][:openstack_insecure].to_s}")
20
- Chef::Log.debug("openstack_region #{Chef::Config[:knife][:openstack_region].to_s}")
17
+ Chef::Log.debug("openstack_endpoint_type #{Chef::Config[:knife][:openstack_endpoint_type] || 'publicURL'}")
18
+ Chef::Log.debug("openstack_insecure #{Chef::Config[:knife][:openstack_insecure]}")
19
+ Chef::Log.debug("openstack_region #{Chef::Config[:knife][:openstack_region]}")
21
20
 
22
- super(options.merge({
23
- :auth_params => {
24
- :provider => 'OpenStack',
25
- :openstack_username => Chef::Config[:knife][:openstack_username],
26
- :openstack_api_key => Chef::Config[:knife][:openstack_password],
27
- :openstack_auth_url => Chef::Config[:knife][:openstack_auth_url],
28
- :openstack_endpoint_type => Chef::Config[:knife][:openstack_endpoint_type],
29
- :openstack_tenant => Chef::Config[:knife][:openstack_tenant],
30
- :openstack_region => Chef::Config[:knife][:openstack_region],
31
- :connection_options => {
32
- :ssl_verify_peer => !Chef::Config[:knife][:openstack_insecure]
21
+ super(options.merge(auth_params: {
22
+ provider: 'OpenStack',
23
+ openstack_username: Chef::Config[:knife][:openstack_username],
24
+ openstack_api_key: Chef::Config[:knife][:openstack_password],
25
+ openstack_auth_url: Chef::Config[:knife][:openstack_auth_url],
26
+ openstack_endpoint_type: Chef::Config[:knife][:openstack_endpoint_type],
27
+ openstack_tenant: Chef::Config[:knife][:openstack_tenant],
28
+ openstack_region: Chef::Config[:knife][:openstack_region],
29
+ connection_options: {
30
+ ssl_verify_peer: !Chef::Config[:knife][:openstack_insecure]
33
31
  }
34
- }}))
32
+ }))
35
33
  end
36
34
 
37
35
  # add alternate user defined api_endpoint value.
38
36
  def add_api_endpoint
39
- @auth_params.merge!({:openstack_auth_url => Chef::Config[:knife][:api_endpoint]}) unless Chef::Config[:knife][:api_endpoint].nil?
37
+ @auth_params.merge!(openstack_auth_url: Chef::Config[:knife][:api_endpoint]) unless Chef::Config[:knife][:api_endpoint].nil?
40
38
  end
41
39
 
42
40
  def get_server(search_term)
43
- begin
44
- if server = connection.servers.get(search_term)
45
- return server
46
- end
41
+ if server = connection.servers.get(search_term)
42
+ return server
43
+ end
47
44
 
48
- if servers = connection.servers.all(:name => search_term)
49
- if servers.length > 1
50
- error_message = "Multiple server matches found for '#{search_term}', use an instance_id to be more specific."
51
- ui.fatal(error_message)
52
- raise CloudExceptions::ValidationError, error_message
53
- else
54
- servers.first
55
- end
45
+ if servers = connection.servers.all(name: search_term)
46
+ if servers.length > 1
47
+ error_message = "Multiple server matches found for '#{search_term}', use an instance_id to be more specific."
48
+ ui.fatal(error_message)
49
+ fail CloudExceptions::ValidationError, error_message
50
+ else
51
+ servers.first
56
52
  end
57
- rescue Excon::Errors::BadRequest => e
58
- handle_excon_exception(CloudExceptions::KnifeCloudError, e)
59
53
  end
54
+ rescue Excon::Errors::BadRequest => e
55
+ handle_excon_exception(CloudExceptions::KnifeCloudError, e)
60
56
  end
61
57
  end
62
58
  end
@@ -3,47 +3,46 @@ class Chef
3
3
  class Knife
4
4
  class Cloud
5
5
  module OpenstackServiceOptions
6
-
7
- def self.included(includer)
6
+ def self.included(includer)
8
7
  includer.class_eval do
9
8
  include FogOptions
10
9
  # Openstack Connection params.
11
10
  option :openstack_username,
12
- :short => "-A USERNAME",
13
- :long => "--openstack-username KEY",
14
- :description => "Your OpenStack Username",
15
- :proc => Proc.new { |key| Chef::Config[:knife][:openstack_username] = key }
11
+ short: '-A USERNAME',
12
+ long: '--openstack-username KEY',
13
+ description: 'Your OpenStack Username',
14
+ proc: proc { |key| Chef::Config[:knife][:openstack_username] = key }
16
15
 
17
16
  option :openstack_password,
18
- :short => "-K SECRET",
19
- :long => "--openstack-password SECRET",
20
- :description => "Your OpenStack Password",
21
- :proc => Proc.new { |key| Chef::Config[:knife][:openstack_password] = key }
17
+ short: '-K SECRET',
18
+ long: '--openstack-password SECRET',
19
+ description: 'Your OpenStack Password',
20
+ proc: proc { |key| Chef::Config[:knife][:openstack_password] = key }
22
21
 
23
22
  option :openstack_tenant,
24
- :short => "-T NAME",
25
- :long => "--openstack-tenant NAME",
26
- :description => "Your OpenStack Tenant NAME",
27
- :proc => Proc.new { |key| Chef::Config[:knife][:openstack_tenant] = key }
23
+ short: '-T NAME',
24
+ long: '--openstack-tenant NAME',
25
+ description: 'Your OpenStack Tenant NAME',
26
+ proc: proc { |key| Chef::Config[:knife][:openstack_tenant] = key }
28
27
 
29
28
  option :openstack_auth_url,
30
- :long => "--openstack-api-endpoint ENDPOINT",
31
- :description => "Your OpenStack API endpoint",
32
- :proc => Proc.new { |endpoint| Chef::Config[:knife][:openstack_auth_url] = endpoint }
29
+ long: '--openstack-api-endpoint ENDPOINT',
30
+ description: 'Your OpenStack API endpoint',
31
+ proc: proc { |endpoint| Chef::Config[:knife][:openstack_auth_url] = endpoint }
33
32
 
34
33
  option :openstack_endpoint_type,
35
- :long => "--openstack-endpoint-type ENDPOINT_TYPE",
36
- :description => "OpenStack endpoint type to use (publicURL, internalURL, adminURL)",
37
- :proc => Proc.new { |type| Chef::Config[:knife][:openstack_endpoint_type] = type }
34
+ long: '--openstack-endpoint-type ENDPOINT_TYPE',
35
+ description: 'OpenStack endpoint type to use (publicURL, internalURL, adminURL)',
36
+ proc: proc { |type| Chef::Config[:knife][:openstack_endpoint_type] = type }
38
37
 
39
38
  option :openstack_insecure,
40
- :long => "--insecure",
41
- :description => "Ignore SSL certificate on the Auth URL",
42
- :boolean => true,
43
- :default => false,
44
- :proc => Proc.new { |key| Chef::Config[:knife][:openstack_insecure] = key }
39
+ long: '--insecure',
40
+ description: 'Ignore SSL certificate on the Auth URL',
41
+ boolean: true,
42
+ default: false,
43
+ proc: proc { |key| Chef::Config[:knife][:openstack_insecure] = key }
45
44
  end
46
- end
45
+ end
47
46
  end
48
47
  end
49
48
  end
@@ -12,18 +12,18 @@ class Chef
12
12
  include OpenstackHelpers
13
13
  include OpenstackServiceOptions
14
14
 
15
- banner "knife openstack flavor list (options)"
15
+ banner 'knife openstack flavor list (options)'
16
16
 
17
17
  def before_exec_command
18
- #set columns_with_info map
18
+ # set columns_with_info map
19
19
  @columns_with_info = [
20
- {:label => 'Name', :key => 'name'},
21
- {:label => 'ID', :key => 'id'},
22
- {:label => 'Virtual CPUs', :key => 'vcpus'},
23
- {:label => 'RAM', :key => 'ram', :value_callback => method(:ram_in_mb)},
24
- {:label => 'Disk', :key => 'disk', :value_callback => method(:disk_in_gb)}
20
+ { label: 'Name', key: 'name' },
21
+ { label: 'ID', key: 'id' },
22
+ { label: 'Virtual CPUs', key: 'vcpus' },
23
+ { label: 'RAM', key: 'ram', value_callback: method(:ram_in_mb) },
24
+ { label: 'Disk', key: 'disk', value_callback: method(:disk_in_gb) }
25
25
  ]
26
- @sort_by_field = "name"
26
+ @sort_by_field = 'name'
27
27
  end
28
28
 
29
29
  def query_resource
@@ -37,8 +37,7 @@ class Chef
37
37
  def disk_in_gb(disk)
38
38
  "#{disk} GB"
39
39
  end
40
-
41
40
  end
42
41
  end
43
42
  end
44
- end
43
+ end
@@ -15,10 +15,10 @@ class Chef
15
15
  banner 'knife openstack floating_ip allocate (options)'
16
16
 
17
17
  option :pool,
18
- :short => '-p POOL',
19
- :long => '--pool POOL',
20
- :description => 'Floating IP pool to allocate from.',
21
- :proc => Proc.new { |key| Chef::Config[:knife][:pool] = key }
18
+ short: '-p POOL',
19
+ long: '--pool POOL',
20
+ description: 'Floating IP pool to allocate from.',
21
+ proc: proc { |key| Chef::Config[:knife][:pool] = key }
22
22
 
23
23
  def execute_command
24
24
  @resource = @service.allocate_address(locate_config_value(:pool))
@@ -16,16 +16,16 @@ class Chef
16
16
  banner 'knife openstack floating_ip associate IP (options)'
17
17
 
18
18
  option :instance_id,
19
- :long => '--instance-id ID',
20
- :description => 'Instance id to associate it with.',
21
- :proc => Proc.new { |key| Chef::Config[:knife][:instance_id] = key },
22
- :required => true
19
+ long: '--instance-id ID',
20
+ description: 'Instance id to associate it with.',
21
+ proc: proc { |key| Chef::Config[:knife][:instance_id] = key },
22
+ required: true
23
23
 
24
24
  def execute_command
25
25
  if @name_args[0]
26
26
  floating_ip = @name_args[0]
27
27
  else
28
- ui.error "Please provide Floating IP to associate with."
28
+ ui.error 'Please provide Floating IP to associate with.'
29
29
  exit 1
30
30
  end
31
31