knife-openstack 1.3.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +21 -0
  3. data/.gitignore +5 -0
  4. data/.travis.yml +9 -7
  5. data/CHANGELOG.md +174 -92
  6. data/Gemfile +15 -3
  7. data/README.md +96 -68
  8. data/Rakefile +19 -6
  9. data/knife-openstack.gemspec +17 -15
  10. data/lib/chef/knife/cloud/openstack_server_create_options.rb +36 -35
  11. data/lib/chef/knife/cloud/openstack_service.rb +7 -6
  12. data/lib/chef/knife/cloud/openstack_service_options.rb +18 -17
  13. data/lib/chef/knife/openstack_flavor_list.rb +11 -10
  14. data/lib/chef/knife/openstack_floating_ip_allocate.rb +13 -12
  15. data/lib/chef/knife/openstack_floating_ip_associate.rb +9 -8
  16. data/lib/chef/knife/openstack_floating_ip_disassociate.rb +9 -8
  17. data/lib/chef/knife/openstack_floating_ip_list.rb +10 -9
  18. data/lib/chef/knife/openstack_floating_ip_release.rb +7 -6
  19. data/lib/chef/knife/openstack_group_list.rb +13 -12
  20. data/lib/chef/knife/openstack_helpers.rb +8 -7
  21. data/lib/chef/knife/openstack_image_list.rb +14 -13
  22. data/lib/chef/knife/openstack_network_list.rb +10 -9
  23. data/lib/chef/knife/openstack_server_create.rb +57 -56
  24. data/lib/chef/knife/openstack_server_delete.rb +7 -6
  25. data/lib/chef/knife/openstack_server_list.rb +16 -15
  26. data/lib/chef/knife/openstack_server_show.rb +17 -16
  27. data/lib/chef/knife/openstack_volume_list.rb +10 -9
  28. data/lib/knife-openstack/version.rb +3 -2
  29. data/spec/functional/flavor_list_func_spec.rb +13 -12
  30. data/spec/functional/floating_ip_list_func_spec.rb +14 -13
  31. data/spec/functional/group_list_func_spec.rb +29 -28
  32. data/spec/functional/image_list_func_spec.rb +15 -14
  33. data/spec/functional/network_list_func_spec.rb +13 -12
  34. data/spec/functional/server_create_func_spec.rb +29 -28
  35. data/spec/functional/server_delete_func_spec.rb +18 -17
  36. data/spec/functional/server_list_func_spec.rb +43 -42
  37. data/spec/functional/server_show_func_spec.rb +7 -6
  38. data/spec/functional/volume_list_func_spec.rb +12 -11
  39. data/spec/integration/cleanup.rb +6 -5
  40. data/spec/integration/openstack_spec.rb +287 -286
  41. data/spec/spec_context.rb +10 -9
  42. data/spec/spec_helper.rb +38 -37
  43. data/spec/unit/openstack_flavor_list_spec.rb +6 -5
  44. data/spec/unit/openstack_floating_ip_allocate_spec.rb +14 -13
  45. data/spec/unit/openstack_floating_ip_associate_spec.rb +11 -10
  46. data/spec/unit/openstack_floating_ip_disassociate_spec.rb +12 -11
  47. data/spec/unit/openstack_floating_ip_list_spec.rb +6 -5
  48. data/spec/unit/openstack_floating_ip_release_spec.rb +13 -12
  49. data/spec/unit/openstack_group_list_spec.rb +11 -10
  50. data/spec/unit/openstack_image_list_spec.rb +6 -5
  51. data/spec/unit/openstack_network_list_spec.rb +8 -7
  52. data/spec/unit/openstack_server_create_spec.rb +131 -130
  53. data/spec/unit/openstack_server_delete_spec.rb +8 -7
  54. data/spec/unit/openstack_server_list_spec.rb +6 -5
  55. data/spec/unit/openstack_server_show_spec.rb +10 -9
  56. data/spec/unit/openstack_service_spec.rb +26 -25
  57. data/spec/unit/openstack_volume_list_spec.rb +6 -5
  58. metadata +9 -105
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
2
3
  # Copyright:: Copyright (c) 2015 Chef Software, Inc.
3
4
 
4
- require 'chef/knife/cloud/list_resource_command'
5
- require 'chef/knife/openstack_helpers'
6
- require 'chef/knife/cloud/openstack_service_options'
5
+ require "chef/knife/cloud/list_resource_command"
6
+ require "chef/knife/openstack_helpers"
7
+ require "chef/knife/cloud/openstack_service_options"
7
8
 
8
9
  class Chef
9
10
  class Knife
@@ -12,16 +13,16 @@ class Chef
12
13
  include OpenstackHelpers
13
14
  include OpenstackServiceOptions
14
15
 
15
- banner 'knife openstack floating_ip list (options)'
16
+ banner "knife openstack floating_ip list (options)"
16
17
 
17
18
  def before_exec_command
18
19
  # set columns_with_info map
19
20
  @columns_with_info = [
20
- { label: 'ID', key: 'id' },
21
- { label: 'Instance ID', key: 'instance_id' },
22
- { label: 'IP Address', key: 'ip' },
23
- { label: 'Fixed IP', key: 'fixed_ip' },
24
- { label: 'Floating IP Pool', key: 'pool' }
21
+ { label: "ID", key: "id" },
22
+ { label: "Instance ID", key: "instance_id" },
23
+ { label: "IP Address", key: "ip" },
24
+ { label: "Fixed IP", key: "fixed_ip" },
25
+ { label: "Floating IP Pool", key: "pool" },
25
26
  ]
26
27
  end
27
28
 
@@ -1,11 +1,12 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
4
  # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
5
  #
5
6
 
6
- require 'chef/knife/openstack_helpers'
7
- require 'chef/knife/cloud/openstack_service_options'
8
- require 'chef/knife/cloud/command'
7
+ require "chef/knife/openstack_helpers"
8
+ require "chef/knife/cloud/openstack_service_options"
9
+ require "chef/knife/cloud/command"
9
10
 
10
11
  class Chef
11
12
  class Knife
@@ -14,16 +15,16 @@ class Chef
14
15
  include OpenstackServiceOptions
15
16
  include OpenstackHelpers
16
17
 
17
- banner 'knife openstack floating_ip release ID [ID] (options)'
18
+ banner "knife openstack floating_ip release ID [ID] (options)"
18
19
 
19
20
  def execute_command
20
21
  if @name_args[0]
21
22
  response = service.release_address(@name_args[0])
22
23
  if response && response.status == 202
23
- ui.info 'Floating IP released successfully.'
24
+ ui.info "Floating IP released successfully."
24
25
  end
25
26
  else
26
- ui.error 'Please provide Floating IP to release.'
27
+ ui.error "Please provide Floating IP to release."
27
28
  exit 1
28
29
  end
29
30
  end
@@ -1,6 +1,7 @@
1
- require 'chef/knife/cloud/list_resource_command'
2
- require 'chef/knife/openstack_helpers'
3
- require 'chef/knife/cloud/openstack_service_options'
1
+ # frozen_string_literal: true
2
+ require "chef/knife/cloud/list_resource_command"
3
+ require "chef/knife/openstack_helpers"
4
+ require "chef/knife/cloud/openstack_service_options"
4
5
 
5
6
  class Chef
6
7
  class Knife
@@ -9,7 +10,7 @@ class Chef
9
10
  include OpenstackHelpers
10
11
  include OpenstackServiceOptions
11
12
 
12
- banner 'knife openstack group list (options)'
13
+ banner "knife openstack group list (options)"
13
14
 
14
15
  def query_resource
15
16
  @service.connection.security_groups
@@ -20,14 +21,14 @@ class Chef
20
21
  end
21
22
 
22
23
  def list(security_groups)
23
- if (config[:format] == 'summary')
24
+ if config[:format] == "summary"
24
25
  group_list = [
25
- ui.color('Name', :bold),
26
- ui.color('Protocol', :bold),
27
- ui.color('From', :bold),
28
- ui.color('To', :bold),
29
- ui.color('CIDR', :bold),
30
- ui.color('Description', :bold)
26
+ ui.color("Name", :bold),
27
+ ui.color("Protocol", :bold),
28
+ ui.color("From", :bold),
29
+ ui.color("To", :bold),
30
+ ui.color("CIDR", :bold),
31
+ ui.color("Description", :bold),
31
32
  ]
32
33
  security_groups.sort_by(&:name).each do |group|
33
34
  group.security_group_rules.each do |rule|
@@ -36,7 +37,7 @@ class Chef
36
37
  group_list << rule.ip_protocol
37
38
  group_list << rule.from_port.to_s
38
39
  group_list << rule.to_port.to_s
39
- group_list << rule.ip_range['cidr']
40
+ group_list << rule.ip_range["cidr"]
40
41
  group_list << group.description
41
42
  end
42
43
  end
@@ -1,19 +1,20 @@
1
- require 'chef/knife/cloud/openstack_service_options'
1
+ # frozen_string_literal: true
2
+ require "chef/knife/cloud/openstack_service_options"
2
3
 
3
4
  class Chef
4
5
  class Knife
5
6
  class Cloud
6
7
  module OpenstackHelpers
7
8
  def primary_private_ip_address(addresses)
8
- primary_network_ip_address(addresses, 'private')
9
+ primary_network_ip_address(addresses, "private")
9
10
  end
10
11
 
11
12
  def primary_public_ip_address(addresses)
12
- primary_network_ip_address(addresses, 'public')
13
+ primary_network_ip_address(addresses, "public")
13
14
  end
14
15
 
15
16
  def primary_network_ip_address(addresses, network_name)
16
- addresses[network_name].last['addr'] if addresses[network_name] && !addresses[network_name].empty?
17
+ addresses[network_name].last["addr"] if addresses[network_name] && !addresses[network_name].empty?
17
18
  end
18
19
 
19
20
  def create_service_instance
@@ -29,12 +30,12 @@ class Chef
29
30
  if addresses[addresses.keys[0]] && addresses[addresses.keys[0]].size > 0
30
31
  ips = addresses[addresses.keys[0]]
31
32
  ips.each do |ip|
32
- version = 'IPv6' if ip['version'] == 6
33
- version = 'IPv4' if ip['version'] == 4
33
+ version = "IPv6" if ip["version"] == 6
34
+ version = "IPv4" if ip["version"] == 4
34
35
  info << "#{addresses.keys[0]}:#{version}: #{ip['addr']}"
35
36
  end
36
37
  end
37
- info.join(' ')
38
+ info.join(" ")
38
39
  end
39
40
  end
40
41
  end
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
2
3
  # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
4
 
4
- require 'chef/knife/cloud/list_resource_command'
5
- require 'chef/knife/openstack_helpers'
6
- require 'chef/knife/cloud/openstack_service_options'
5
+ require "chef/knife/cloud/list_resource_command"
6
+ require "chef/knife/openstack_helpers"
7
+ require "chef/knife/cloud/openstack_service_options"
7
8
 
8
9
  class Chef
9
10
  class Knife
@@ -12,10 +13,10 @@ class Chef
12
13
  include OpenstackHelpers
13
14
  include OpenstackServiceOptions
14
15
 
15
- banner 'knife openstack image list (options)'
16
+ banner "knife openstack image list (options)"
16
17
 
17
18
  option :disable_filter,
18
- long: '--disable-filter',
19
+ long: "--disable-filter",
19
20
  description: "Disable filtering of the image list. Currently filters names ending with 'initrd' or 'kernel'",
20
21
  boolean: true,
21
22
  default: false
@@ -23,15 +24,15 @@ class Chef
23
24
  def before_exec_command
24
25
  # set resource_filters
25
26
  unless config[:disable_filter]
26
- @resource_filters = [{ attribute: 'name', regex: /initrd$|kernel$|loader$|virtual$|vmlinuz$/ }]
27
+ @resource_filters = [{ attribute: "name", regex: /initrd$|kernel$|loader$|virtual$|vmlinuz$/ }]
27
28
  end
28
29
  # set columns_with_info map
29
30
  @columns_with_info = [
30
- { label: 'Name', key: 'name' },
31
- { label: 'ID', key: 'id' },
32
- { label: 'Snapshot', key: 'metadata', value_callback: method(:is_image_snapshot) }
31
+ { label: "Name", key: "name" },
32
+ { label: "ID", key: "id" },
33
+ { label: "Snapshot", key: "metadata", value_callback: method(:is_image_snapshot) },
33
34
  ]
34
- @sort_by_field = 'name'
35
+ @sort_by_field = "name"
35
36
  end
36
37
 
37
38
  def query_resource
@@ -39,10 +40,10 @@ class Chef
39
40
  end
40
41
 
41
42
  def is_image_snapshot(metadata)
42
- snapshot = 'no'
43
+ snapshot = "no"
43
44
  metadata.each do |datum|
44
- if (datum.key == 'image_type') && (datum.value == 'snapshot')
45
- snapshot = 'yes'
45
+ if (datum.key == "image_type") && (datum.value == "snapshot")
46
+ snapshot = "yes"
46
47
  end
47
48
  end
48
49
  snapshot
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
2
3
  # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
4
 
4
- require 'chef/knife/cloud/list_resource_command'
5
- require 'chef/knife/openstack_helpers'
6
- require 'chef/knife/cloud/openstack_service_options'
5
+ require "chef/knife/cloud/list_resource_command"
6
+ require "chef/knife/openstack_helpers"
7
+ require "chef/knife/cloud/openstack_service_options"
7
8
 
8
9
  class Chef
9
10
  class Knife
@@ -12,17 +13,17 @@ class Chef
12
13
  include OpenstackHelpers
13
14
  include OpenstackServiceOptions
14
15
 
15
- banner 'knife openstack network list (options)'
16
+ banner "knife openstack network list (options)"
16
17
 
17
18
  def before_exec_command
18
19
  # set columns_with_info map
19
20
  @columns_with_info = [
20
- { label: 'Name', key: 'name' },
21
- { label: 'ID', key: 'id' },
22
- { label: 'Tenant', key: 'tenant_id' },
23
- { label: 'Shared', key: 'shared' }
21
+ { label: "Name", key: "name" },
22
+ { label: "ID", key: "id" },
23
+ { label: "Tenant", key: "tenant_id" },
24
+ { label: "Shared", key: "shared" },
24
25
  ]
25
- @sort_by_field = 'name'
26
+ @sort_by_field = "name"
26
27
  end
27
28
 
28
29
  def query_resource
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Seth Chisamore (<schisamo@getchef.com>)
3
4
  # Author:: Matt Ray (<matt@getchef.com>)
@@ -18,12 +19,12 @@
18
19
  # limitations under the License.
19
20
  #
20
21
 
21
- require 'chef/knife/cloud/server/create_command'
22
- require 'chef/knife/openstack_helpers'
23
- require 'chef/knife/cloud/openstack_server_create_options'
24
- require 'chef/knife/cloud/openstack_service'
25
- require 'chef/knife/cloud/openstack_service_options'
26
- require 'chef/knife/cloud/exceptions'
22
+ require "chef/knife/cloud/server/create_command"
23
+ require "chef/knife/openstack_helpers"
24
+ require "chef/knife/cloud/openstack_server_create_options"
25
+ require "chef/knife/cloud/openstack_service"
26
+ require "chef/knife/cloud/openstack_service_options"
27
+ require "chef/knife/cloud/exceptions"
27
28
 
28
29
  class Chef
29
30
  class Knife
@@ -33,7 +34,7 @@ class Chef
33
34
  include OpenstackServerCreateOptions
34
35
  include OpenstackServiceOptions
35
36
 
36
- banner 'knife openstack server create (options)'
37
+ banner "knife openstack server create (options)"
37
38
 
38
39
  def before_exec_command
39
40
  super
@@ -46,11 +47,11 @@ class Chef
46
47
  :flavor_ref => service.get_flavor(locate_config_value(:flavor)).id,
47
48
  :security_groups => locate_config_value(:openstack_security_groups),
48
49
  :availability_zone => locate_config_value(:availability_zone),
49
- 'os:scheduler_hints' => locate_config_value(:openstack_scheduler_hints),
50
+ "os:scheduler_hints" => locate_config_value(:openstack_scheduler_hints),
50
51
  :metadata => locate_config_value(:metadata),
51
- :key_name => locate_config_value(:openstack_ssh_key_id)
52
+ :key_name => locate_config_value(:openstack_ssh_key_id),
52
53
  },
53
- server_create_timeout: locate_config_value(:server_create_timeout)
54
+ server_create_timeout: locate_config_value(:server_create_timeout),
54
55
  }
55
56
  unless locate_config_value(:openstack_volumes).nil?
56
57
  counter = 99
@@ -59,53 +60,53 @@ class Chef
59
60
  {
60
61
  volume_id: vol,
61
62
  delete_on_termination: false,
62
- device_name: '/dev/vd' + counter.chr,
63
- volume_size: nil
63
+ device_name: "/dev/vd" + counter.chr,
64
+ volume_size: nil,
64
65
  }
65
66
  end
66
67
  end
67
68
 
68
- @create_options[:server_def].merge!(user_data: locate_config_value(:user_data)) if locate_config_value(:user_data)
69
- @create_options[:server_def].merge!(nics: locate_config_value(:network_ids).map { |nic| nic_id = { 'net_id' => nic } }) if locate_config_value(:network_ids)
69
+ @create_options[:server_def][:user_data] = locate_config_value(:user_data) if locate_config_value(:user_data)
70
+ @create_options[:server_def][:nics] = locate_config_value(:network_ids).map { |nic| nic_id = { "net_id" => nic } } if locate_config_value(:network_ids)
70
71
 
71
72
  Chef::Log.debug("Create server params - server_def = #{@create_options[:server_def]}")
72
73
  # set columns_with_info map
73
74
  @columns_with_info = [
74
- { label: 'Instance ID', key: 'id' },
75
- { label: 'Name', key: 'name' },
76
- { label: 'Public IP', key: 'addresses', value_callback: method(:primary_public_ip_address) },
77
- { label: 'Private IP', key: 'addresses', value_callback: method(:primary_private_ip_address) },
78
- { label: 'Flavor', key: 'flavor', value_callback: method(:get_id) },
79
- { label: 'Image', key: 'image', value_callback: method(:get_id) },
80
- { label: 'Keypair', key: 'key_name' },
81
- { label: 'State', key: 'state' },
82
- { label: 'Availability Zone', key: 'availability_zone' }
75
+ { label: "Instance ID", key: "id" },
76
+ { label: "Name", key: "name" },
77
+ { label: "Public IP", key: "addresses", value_callback: method(:primary_public_ip_address) },
78
+ { label: "Private IP", key: "addresses", value_callback: method(:primary_private_ip_address) },
79
+ { label: "Flavor", key: "flavor", value_callback: method(:get_id) },
80
+ { label: "Image", key: "image", value_callback: method(:get_id) },
81
+ { label: "Keypair", key: "key_name" },
82
+ { label: "State", key: "state" },
83
+ { label: "Availability Zone", key: "availability_zone" },
83
84
  ]
84
85
  end
85
86
 
86
87
  def get_id(value)
87
- value['id']
88
+ value["id"]
88
89
  end
89
90
 
90
91
  # Setup the floating ip after server creation.
91
92
  def after_exec_command
92
93
  Chef::Log.debug("Addresses #{server.addresses}")
93
- msg_pair('Public IP Address', primary_public_ip_address(server.addresses)) if primary_public_ip_address(server.addresses)
94
- msg_pair('Private IP Address', primary_private_ip_address(server.addresses)) if primary_private_ip_address(server.addresses)
94
+ msg_pair("Public IP Address", primary_public_ip_address(server.addresses)) if primary_public_ip_address(server.addresses)
95
+ msg_pair("Private IP Address", primary_private_ip_address(server.addresses)) if primary_private_ip_address(server.addresses)
95
96
 
96
97
  floating_address = locate_config_value(:openstack_floating_ip)
97
98
  bind_ip = primary_network_ip_address(server.addresses, server.addresses.keys[0])
98
99
  Chef::Log.debug("Floating IP Address requested #{floating_address}")
99
- unless (floating_address == '-1') # no floating IP requested
100
+ unless floating_address == "-1" # no floating IP requested
100
101
  addresses = service.connection.addresses
101
102
  # floating requested without value
102
103
  if floating_address.nil?
103
104
  free_floating = addresses.find_index { |a| a.fixed_ip.nil? }
104
105
  begin
105
106
  if free_floating.nil? # no free floating IP found
106
- error_message = 'Unable to assign a Floating IP from allocated IPs.'
107
+ error_message = "Unable to assign a Floating IP from allocated IPs."
107
108
  ui.fatal(error_message)
108
- fail CloudExceptions::ServerSetupError, error_message
109
+ raise CloudExceptions::ServerSetupError, error_message
109
110
  else
110
111
  floating_address = addresses[free_floating].ip
111
112
  end
@@ -116,22 +117,22 @@ class Chef
116
117
  end
117
118
 
118
119
  # Pull the port_id for the associate_floating_ip
119
- port_id = @service.network.list_ports[:body]['ports'].find { |x| x['fixed_ips'][0]['ip_address'] == bind_ip }['id']
120
- fixed_ip_address = service.network.list_ports[:body]['ports'].find { |x| x['id'] == port_id }['fixed_ips'][0]['ip_address']
120
+ port_id = @service.network.list_ports[:body]["ports"].find { |x| x["fixed_ips"][0]["ip_address"] == bind_ip }["id"]
121
+ fixed_ip_address = service.network.list_ports[:body]["ports"].find { |x| x["id"] == port_id }["fixed_ips"][0]["ip_address"]
121
122
 
122
123
  floating_ip_id = get_floating_ip_id(floating_address)
123
124
  # Associate the floating ip via the neutron/network api
124
125
  @service.network.associate_floating_ip(floating_ip_id, port_id, fixed_ip_address: fixed_ip_address)
125
126
 
126
127
  # a bit of a hack, but server.reload takes a long time
127
- (server.addresses['public'] ||= []) << { 'version' => 4, 'addr' => floating_address }
128
- msg_pair('Floating IP Address', floating_address)
128
+ (server.addresses["public"] ||= []) << { "version" => 4, "addr" => floating_address }
129
+ msg_pair("Floating IP Address", floating_address)
129
130
  end
130
131
 
131
132
  Chef::Log.debug("Addresses #{server.addresses}")
132
133
  Chef::Log.debug("Public IP Address actual: #{primary_public_ip_address(server.addresses)}") if primary_public_ip_address(server.addresses)
133
134
 
134
- msg_pair('Private IP Address', primary_private_ip_address(server.addresses)) if primary_private_ip_address(server.addresses)
135
+ msg_pair("Private IP Address", primary_private_ip_address(server.addresses)) if primary_private_ip_address(server.addresses)
135
136
  super
136
137
  end
137
138
 
@@ -144,13 +145,13 @@ class Chef
144
145
  # The bootstrap network is always initialised to 'public' when a network name isn't specified. Therefore,
145
146
  # only set the bootstrap network to 'private' if still initialised to public and nothing was specified for
146
147
  # the private network name.
147
- config[:bootstrap_network] = 'private' if config[:private_network] && config[:bootstrap_network] == 'public'
148
+ config[:bootstrap_network] = "private" if config[:private_network] && config[:bootstrap_network] == "public"
148
149
 
149
150
  # Which IP address to bootstrap
150
151
  unless config[:network] # --no-network
151
152
  bootstrap_ip_address = primary_public_ip_address(server.addresses) ||
152
- primary_private_ip_address(server.addresses) ||
153
- server.addresses.first[1][0]['addr']
153
+ primary_private_ip_address(server.addresses) ||
154
+ server.addresses.first[1][0]["addr"]
154
155
  Chef::Log.debug("No Bootstrap Network: #{config[:bootstrap_network]}")
155
156
  else
156
157
  bootstrap_ip_address = primary_network_ip_address(server.addresses, config[:bootstrap_network])
@@ -159,14 +160,14 @@ class Chef
159
160
 
160
161
  Chef::Log.debug("Bootstrap IP Address: #{bootstrap_ip_address}")
161
162
  if bootstrap_ip_address.nil?
162
- error_message = 'No IP address available for bootstrapping.'
163
+ error_message = "No IP address available for bootstrapping."
163
164
  ui.error(error_message)
164
- fail CloudExceptions::BootstrapError, error_message
165
+ raise CloudExceptions::BootstrapError, error_message
165
166
  end
166
167
  config[:bootstrap_ip_address] = bootstrap_ip_address
167
168
 
168
169
  config[:hints] ||= {}
169
- config[:hints]['openstack'] ||= {}
170
+ config[:hints]["openstack"] ||= {}
170
171
  end
171
172
 
172
173
  def validate_params!
@@ -175,17 +176,17 @@ class Chef
175
176
 
176
177
  errors = []
177
178
 
178
- if locate_config_value(:bootstrap_protocol) == 'winrm'
179
+ if locate_config_value(:bootstrap_protocol) == "winrm"
179
180
  if locate_config_value(:winrm_password).nil?
180
- errors << 'You must provide Winrm Password.'
181
+ errors << "You must provide Winrm Password."
181
182
  end
182
- elsif locate_config_value(:bootstrap_protocol) != 'ssh'
183
- errors << 'You must provide a valid bootstrap protocol. options [ssh/winrm]. For linux type images, options [ssh]'
183
+ elsif locate_config_value(:bootstrap_protocol) != "ssh"
184
+ errors << "You must provide a valid bootstrap protocol. options [ssh/winrm]. For linux type images, options [ssh]"
184
185
  end
185
186
 
186
- errors << 'You must provide --image-os-type option [windows/linux]' unless %w(windows linux).include?(locate_config_value(:image_os_type))
187
- error_message = ''
188
- fail CloudExceptions::ValidationError, error_message if errors.each { |e| ui.error(e); error_message = "#{error_message} #{e}." }.any?
187
+ errors << "You must provide --image-os-type option [windows/linux]" unless %w{windows linux}.include?(locate_config_value(:image_os_type))
188
+ error_message = ""
189
+ raise CloudExceptions::ValidationError, error_message if errors.each { |e| ui.error(e); error_message = "#{error_message} #{e}." }.any?
189
190
  end
190
191
 
191
192
  def is_image_valid?
@@ -199,7 +200,7 @@ class Chef
199
200
  def is_floating_ip_valid?
200
201
  address = locate_config_value(:openstack_floating_ip)
201
202
 
202
- return true if address == '-1' # no floating IP requested
203
+ return true if address == "-1" # no floating IP requested
203
204
 
204
205
  addresses = service.connection.addresses
205
206
  return false if addresses.empty? # no floating IPs
@@ -222,20 +223,20 @@ class Chef
222
223
 
223
224
  def post_connection_validations
224
225
  errors = []
225
- errors << 'You have not provided a valid image ID. Please note the options for this value are -I or --image.' unless is_image_valid?
226
- errors << 'You have not provided a valid flavor ID. Please note the options for this value are -f or --flavor.' unless is_flavor_valid?
227
- errors << 'You have either requested an invalid floating IP address or none are available.' unless is_floating_ip_valid?
228
- error_message = ''
229
- fail CloudExceptions::ValidationError, error_message if errors.each { |e| ui.error(e); error_message = "#{error_message} #{e}." }.any?
226
+ errors << "You have not provided a valid image ID. Please note the options for this value are -I or --image." unless is_image_valid?
227
+ errors << "You have not provided a valid flavor ID. Please note the options for this value are -f or --flavor." unless is_flavor_valid?
228
+ errors << "You have either requested an invalid floating IP address or none are available." unless is_floating_ip_valid?
229
+ error_message = ""
230
+ raise CloudExceptions::ValidationError, error_message if errors.each { |e| ui.error(e); error_message = "#{error_message} #{e}." }.any?
230
231
  end
231
232
 
232
233
  def get_floating_ip_id(floating_address)
233
234
  # required for this method to work
234
235
  floating_ip_id = -1
235
236
  # Figure out the id for the port that the floating ip you requested
236
- @service.network.list_floating_ips[:body]['floatingips'].each do |x|
237
- if x['floating_ip_address'] == floating_address
238
- floating_ip_id = x['id']
237
+ @service.network.list_floating_ips[:body]["floatingips"].each do |x|
238
+ if x["floating_ip_address"] == floating_address
239
+ floating_ip_id = x["id"]
239
240
  end
240
241
  end
241
242
  floating_ip_id