knife-rackspace 2.0.0 → 2.0.2

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
  SHA256:
3
- metadata.gz: 3799ca445b0f7ba27563c830cbf6650a780c57a46807431c342a100924d9167e
4
- data.tar.gz: 9d2580b66da6812bcad820e2eb11f3ea4c07eaf792166949dff98d518421d03d
3
+ metadata.gz: 4d076b1123a47563c50cc2113b132fcad24792de369fefda5d879af3def6b6fb
4
+ data.tar.gz: 55fb1c587e13f2a029783891c9cce1585e120fb6f3eb9df2fe5779775fd44982
5
5
  SHA512:
6
- metadata.gz: 96e95c86c1f6d6081ad501a9a8c47d0d2fefb3e26937cc2af73ebdd31f52ac3bc53c514dbb6bc2110a3756504de75502b7acd74b05dc06aac420eadbd690ce49
7
- data.tar.gz: 4ac56dd985fd2fda28c1117c99c63e31bb440e498a728ffc52be9c90279f06741cae50236294341cb848a1c7ef51810ec43c350989dc1df6c6424c378c516759
6
+ metadata.gz: 445fe503b0d35b9c07151dc45ab08167ed565ff68ad060e83582976ca5b86bbf517640b76e504fc2209fa8e00a009de863382040fe7cf4eaeb985a973214a48f
7
+ data.tar.gz: c9936580b82f1d82cc204697c0644c38cf772ea135aee27b24af1ec00bd9b69e1545d5361ffde45095d569e35640b4fc6ccfad74ebf5e1be6dfa9e07aa6020b6
@@ -37,37 +37,37 @@ class Chef
37
37
  end
38
38
 
39
39
  option :rackspace_api_key,
40
- :short => "-K KEY",
41
- :long => "--rackspace-api-key KEY",
42
- :description => "Your rackspace API key",
43
- :proc => Proc.new { |key| Chef::Config[:knife][:rackspace_api_key] = key }
40
+ short: "-K KEY",
41
+ long: "--rackspace-api-key KEY",
42
+ description: "Your rackspace API key",
43
+ proc: Proc.new { |key| Chef::Config[:knife][:rackspace_api_key] = key }
44
44
 
45
45
  option :rackspace_username,
46
- :short => "-A USERNAME",
47
- :long => "--rackspace-username USERNAME",
48
- :description => "Your rackspace API username",
49
- :proc => Proc.new { |username| Chef::Config[:knife][:rackspace_username] = username }
46
+ short: "-A USERNAME",
47
+ long: "--rackspace-username USERNAME",
48
+ description: "Your rackspace API username",
49
+ proc: Proc.new { |username| Chef::Config[:knife][:rackspace_username] = username }
50
50
 
51
51
  option :rackspace_version,
52
- :long => "--rackspace-version VERSION",
53
- :description => "Rackspace Cloud Servers API version",
54
- :default => "v2",
55
- :proc => Proc.new { |version| Chef::Config[:knife][:rackspace_version] = version }
52
+ long: "--rackspace-version VERSION",
53
+ description: "Rackspace Cloud Servers API version",
54
+ default: "v2",
55
+ proc: Proc.new { |version| Chef::Config[:knife][:rackspace_version] = version }
56
56
 
57
57
  option :rackspace_auth_url,
58
- :long => "--rackspace-auth-url URL",
59
- :description => "Your rackspace API auth url",
60
- :proc => Proc.new { |url| Chef::Config[:knife][:rackspace_auth_url] = url }
58
+ long: "--rackspace-auth-url URL",
59
+ description: "Your rackspace API auth url",
60
+ proc: Proc.new { |url| Chef::Config[:knife][:rackspace_auth_url] = url }
61
61
 
62
62
  option :rackspace_region,
63
- :long => "--rackspace-region REGION",
64
- :description => "Your rackspace region",
65
- :proc => Proc.new { |region| Chef::Config[:knife][:rackspace_region] = region }
63
+ long: "--rackspace-region REGION",
64
+ description: "Your rackspace region",
65
+ proc: Proc.new { |region| Chef::Config[:knife][:rackspace_region] = region }
66
66
 
67
67
  option :file,
68
- :long => "--file DESTINATION-PATH=SOURCE-PATH",
69
- :description => "File to inject on node",
70
- :proc => Proc.new {|arg|
68
+ long: "--file DESTINATION-PATH=SOURCE-PATH",
69
+ description: "File to inject on node",
70
+ proc: Proc.new { |arg|
71
71
  Chef::Config[:knife][:file] ||= []
72
72
  Chef::Config[:knife][:file] << arg
73
73
  }
@@ -94,14 +94,14 @@ class Chef
94
94
  region_warning_for_v1
95
95
  @connection ||= begin
96
96
  connection = Fog::Compute.new(connection_params({
97
- :version => "v1",
97
+ version: "v1",
98
98
  }))
99
99
  end
100
100
  else
101
101
  Chef::Log.debug("rackspace v2")
102
102
  @connection ||= begin
103
103
  connection = Fog::Compute.new(connection_params({
104
- :version => "v2",
104
+ version: "v2",
105
105
  }))
106
106
  end
107
107
  end
@@ -131,22 +131,22 @@ class Chef
131
131
  end
132
132
 
133
133
  hash = options.merge({
134
- :provider => "Rackspace",
135
- :rackspace_api_key => locate_config_value(:rackspace_api_key),
136
- :rackspace_username => username,
137
- :rackspace_auth_url => auth_endpoint,
138
- :rackspace_region => locate_config_value(:rackspace_region),
134
+ provider: "Rackspace",
135
+ rackspace_api_key: locate_config_value(:rackspace_api_key),
136
+ rackspace_username: username,
137
+ rackspace_auth_url: auth_endpoint,
138
+ rackspace_region: locate_config_value(:rackspace_region),
139
139
  })
140
140
 
141
141
  hash[:connection_options] ||= {}
142
- Chef::Log.debug("https_proxy #{ Chef::Config[:https_proxy] || "<not specified>"} (config)")
143
- Chef::Log.debug("http_proxy #{ Chef::Config[:http_proxy] || "<not specified>"} (config)")
144
- if Chef::Config.has_key?(:https_proxy) || Chef::Config.has_key?(:http_proxy)
145
- hash[:connection_options] = { :proxy => Chef::Config[:https_proxy] || Chef::Config[:http_proxy] }
142
+ Chef::Log.debug("https_proxy #{Chef::Config[:https_proxy] || "<not specified>"} (config)")
143
+ Chef::Log.debug("http_proxy #{Chef::Config[:http_proxy] || "<not specified>"} (config)")
144
+ if Chef::Config.key?(:https_proxy) || Chef::Config.key?(:http_proxy)
145
+ hash[:connection_options] = { proxy: Chef::Config[:https_proxy] || Chef::Config[:http_proxy] }
146
146
  end
147
147
  Chef::Log.debug("using proxy #{hash[:connection_options][:proxy] || "<none>"} (config)")
148
- Chef::Log.debug("ssl_verify_peer #{Chef::Config[:knife].has_key?(:ssl_verify_peer) ? Chef::Config[:knife][:ssl_verify_peer] : "<not specified>"} (config)")
149
- hash[:connection_options][:ssl_verify_peer] = Chef::Config[:knife][:ssl_verify_peer] if Chef::Config[:knife].has_key?(:ssl_verify_peer)
148
+ Chef::Log.debug("ssl_verify_peer #{Chef::Config[:knife].key?(:ssl_verify_peer) ? Chef::Config[:knife][:ssl_verify_peer] : "<not specified>"} (config)")
149
+ hash[:connection_options][:ssl_verify_peer] = Chef::Config[:knife][:ssl_verify_peer] if Chef::Config[:knife].key?(:ssl_verify_peer)
150
150
 
151
151
  hash
152
152
  end
@@ -154,6 +154,7 @@ class Chef
154
154
  def auth_endpoint
155
155
  url = locate_config_value(:rackspace_auth_url)
156
156
  return url if url
157
+
157
158
  (locate_config_value(:rackspace_region) == "lon") ? ::Fog::Rackspace::UK_AUTH_ENDPOINT : ::Fog::Rackspace::US_AUTH_ENDPOINT
158
159
  end
159
160
 
@@ -188,8 +189,8 @@ class Chef
188
189
  if public_ip_address = ip_address(server, "public")
189
190
  @public_dns_name ||= begin
190
191
  Resolv.getname(public_ip_address)
191
- rescue
192
- "#{public_ip_address}.xip.io"
192
+ rescue
193
+ "#{public_ip_address}.xip.io"
193
194
  end
194
195
  end
195
196
  end
@@ -206,11 +207,11 @@ class Chef
206
207
  end
207
208
 
208
209
  def v1_public_ip(server)
209
- server.public_ip_address == nil ? "" : server.public_ip_address
210
+ server.public_ip_address.nil? ? "" : server.public_ip_address
210
211
  end
211
212
 
212
213
  def v1_private_ip(server)
213
- server.addresses["private"].first == nil ? "" : server.addresses["private"].first
214
+ server.addresses["private"].first.nil? ? "" : server.addresses["private"].first
214
215
  end
215
216
 
216
217
  def v2_ip_address(server, network)
@@ -219,7 +220,7 @@ class Chef
219
220
  end
220
221
 
221
222
  def v2_access_ip(server)
222
- server.access_ipv4_address == nil ? "" : server.access_ipv4_address
223
+ server.access_ipv4_address.nil? ? "" : server.access_ipv4_address
223
224
  end
224
225
 
225
226
  def extract_ipv4_address(ip_addresses)
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/knife/rackspace_base"
19
+ require_relative "rackspace_base"
20
20
 
21
21
  class Chef
22
22
  class Knife
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/knife/rackspace_base"
19
+ require_relative "rackspace_base"
20
20
 
21
21
  class Chef
22
22
  class Knife
@@ -1,4 +1,4 @@
1
- require "chef/knife/rackspace_base"
1
+ require_relative "rackspace_base"
2
2
 
3
3
  class Chef
4
4
  class Knife
@@ -9,16 +9,16 @@ class Chef
9
9
  banner "knife rackspace network create (options)"
10
10
 
11
11
  option :label,
12
- :short => "-L LABEL",
13
- :long => "--label LABEL",
14
- :description => "Label for the network",
15
- :required => true
12
+ short: "-L LABEL",
13
+ long: "--label LABEL",
14
+ description: "Label for the network",
15
+ required: true
16
16
 
17
17
  option :cidr,
18
- :short => "-C CIDR",
19
- :long => "--cidr CIDR",
20
- :description => "CIDR for the network",
21
- :required => true
18
+ short: "-C CIDR",
19
+ long: "--cidr CIDR",
20
+ description: "CIDR for the network",
21
+ required: true
22
22
 
23
23
  def run
24
24
  if version_one?
@@ -32,7 +32,7 @@ class Chef
32
32
  ]
33
33
  end
34
34
  options = {}
35
- [:cidr, :label].each do |key|
35
+ %i{cidr label}.each do |key|
36
36
  options[key] = config[key]
37
37
  end
38
38
  net = connection.networks.create(options)
@@ -1,4 +1,4 @@
1
- require "chef/knife/rackspace_base"
1
+ require_relative "rackspace_base"
2
2
 
3
3
  class Chef
4
4
  class Knife
@@ -1,4 +1,4 @@
1
- require "chef/knife/rackspace_base"
1
+ require_relative "rackspace_base"
2
2
 
3
3
  class Chef
4
4
  class Knife
@@ -17,7 +17,7 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require "chef/knife/rackspace_base"
20
+ require_relative "rackspace_base"
21
21
  require "chef/knife/winrm_base"
22
22
  require "chef/knife"
23
23
 
@@ -41,256 +41,256 @@ class Chef
41
41
  attr_accessor :initial_sleep_delay
42
42
 
43
43
  option :flavor,
44
- :short => "-f FLAVOR",
45
- :long => "--flavor FLAVOR",
46
- :description => "The flavor of server; default is 2 (512 MB)",
47
- :proc => Proc.new { |f| Chef::Config[:knife][:flavor] = f.to_s },
48
- :default => "2"
44
+ short: "-f FLAVOR",
45
+ long: "--flavor FLAVOR",
46
+ description: "The flavor of server; default is 2 (512 MB)",
47
+ proc: Proc.new { |f| Chef::Config[:knife][:flavor] = f.to_s },
48
+ default: "2"
49
49
 
50
50
  option :image,
51
- :short => "-I IMAGE",
52
- :long => "--image IMAGE",
53
- :description => "The image of the server",
54
- :proc => Proc.new { |i| Chef::Config[:knife][:image] = i.to_s }
51
+ short: "-I IMAGE",
52
+ long: "--image IMAGE",
53
+ description: "The image of the server",
54
+ proc: Proc.new { |i| Chef::Config[:knife][:image] = i.to_s }
55
55
 
56
56
  option :boot_volume_size,
57
- :long => "--boot-volume-size GB",
58
- :description => "The size of the CBS to use as the server's boot device",
59
- :proc => Proc.new { |i| Chef::Config[:knife][:boot_volume_size] = i.to_s },
60
- :default => 100
57
+ long: "--boot-volume-size GB",
58
+ description: "The size of the CBS to use as the server's boot device",
59
+ proc: Proc.new { |i| Chef::Config[:knife][:boot_volume_size] = i.to_s },
60
+ default: 100
61
61
 
62
62
  option :boot_volume_id,
63
- :short => "-B BOOT_VOLUME_ID",
64
- :long => "--boot-volume-id UUID",
65
- :description => "The image CBS UUID to use as the server's boot device",
66
- :proc => Proc.new { |i| Chef::Config[:knife][:boot_volume_id] = i.to_s }
63
+ short: "-B BOOT_VOLUME_ID",
64
+ long: "--boot-volume-id UUID",
65
+ description: "The image CBS UUID to use as the server's boot device",
66
+ proc: Proc.new { |i| Chef::Config[:knife][:boot_volume_id] = i.to_s }
67
67
 
68
68
  option :server_name,
69
- :short => "-S NAME",
70
- :long => "--server-name NAME",
71
- :description => "The server name"
69
+ short: "-S NAME",
70
+ long: "--server-name NAME",
71
+ description: "The server name"
72
72
 
73
73
  option :chef_node_name,
74
- :short => "-N NAME",
75
- :long => "--node-name NAME",
76
- :description => "The Chef node name for your new node"
74
+ short: "-N NAME",
75
+ long: "--node-name NAME",
76
+ description: "The Chef node name for your new node"
77
77
 
78
78
  option :bootstrap_network,
79
- :long => "--bootstrap-network LABEL",
80
- :description => "Use IP address on this network for bootstrap",
81
- :default => "public"
79
+ long: "--bootstrap-network LABEL",
80
+ description: "Use IP address on this network for bootstrap",
81
+ default: "public"
82
82
 
83
83
  option :private_network,
84
- :long => "--private-network",
85
- :description => "Equivalent to --bootstrap-network private",
86
- :boolean => true,
87
- :default => false
84
+ long: "--private-network",
85
+ description: "Equivalent to --bootstrap-network private",
86
+ boolean: true,
87
+ default: false
88
88
 
89
89
  option :ssh_user,
90
- :short => "-x USERNAME",
91
- :long => "--ssh-user USERNAME",
92
- :description => "The ssh username; default is 'root'",
93
- :default => "root"
90
+ short: "-x USERNAME",
91
+ long: "--ssh-user USERNAME",
92
+ description: "The ssh username; default is 'root'",
93
+ default: "root"
94
94
 
95
95
  option :ssh_password,
96
- :short => "-P PASSWORD",
97
- :long => "--ssh-password PASSWORD",
98
- :description => "The ssh password"
96
+ short: "-P PASSWORD",
97
+ long: "--ssh-password PASSWORD",
98
+ description: "The ssh password"
99
99
 
100
100
  option :ssh_port,
101
- :short => "-p PORT",
102
- :long => "--ssh-port PORT",
103
- :description => "The ssh port",
104
- :default => "22",
105
- :proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
101
+ short: "-p PORT",
102
+ long: "--ssh-port PORT",
103
+ description: "The ssh port",
104
+ default: "22",
105
+ proc: Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
106
106
 
107
107
  option :identity_file,
108
- :short => "-i IDENTITY_FILE",
109
- :long => "--identity-file IDENTITY_FILE",
110
- :description => "The SSH identity file used for authentication"
108
+ short: "-i IDENTITY_FILE",
109
+ long: "--identity-file IDENTITY_FILE",
110
+ description: "The SSH identity file used for authentication"
111
111
 
112
112
  option :prerelease,
113
- :long => "--prerelease",
114
- :description => "Install the pre-release chef gems",
115
- :default => false
113
+ long: "--prerelease",
114
+ description: "Install the pre-release chef gems",
115
+ default: false
116
116
 
117
117
  option :bootstrap_version,
118
- :long => "--bootstrap-version VERSION",
119
- :description => "The version of Chef to install",
120
- :proc => Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
118
+ long: "--bootstrap-version VERSION",
119
+ description: "The version of Chef to install",
120
+ proc: Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
121
121
 
122
122
  option :distro,
123
- :short => "-d DISTRO",
124
- :long => "--distro DISTRO",
125
- :description => "Bootstrap a distro using a template. [DEPRECATED] Use -t / --bootstrap-template option instead.",
126
- :proc => Proc.new { |v|
123
+ short: "-d DISTRO",
124
+ long: "--distro DISTRO",
125
+ description: "Bootstrap a distro using a template. [DEPRECATED] Use -t / --bootstrap-template option instead.",
126
+ proc: Proc.new { |v|
127
127
  Chef::Log.fatal("[DEPRECATED] -d / --distro option is deprecated. Use --bootstrap-template option instead.")
128
128
  v
129
129
  }
130
130
 
131
131
  # @todo When we no longer support Chef 13 this can just go away
132
132
  option :template_file,
133
- :long => "--template-file TEMPLATE",
134
- :description => "Full path to location of template to use. [DEPRECATED] Use -t / --bootstrap-template option instead.",
135
- :proc => Proc.new { |v|
133
+ long: "--template-file TEMPLATE",
134
+ description: "Full path to location of template to use. [DEPRECATED] Use -t / --bootstrap-template option instead.",
135
+ proc: Proc.new { |v|
136
136
  Chef::Log.fatal("[DEPRECATED] --template-file option is deprecated. Use --bootstrap-template option instead.")
137
137
  v
138
138
  }
139
139
 
140
140
  option :bootstrap_template,
141
- :short => "-t TEMPLATE",
142
- :long => "--bootstrap-template TEMPLATE",
143
- :description => "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates."
141
+ short: "-t TEMPLATE",
142
+ long: "--bootstrap-template TEMPLATE",
143
+ description: "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates."
144
144
 
145
145
  option :run_list,
146
- :short => "-r RUN_LIST",
147
- :long => "--run-list RUN_LIST",
148
- :description => "Comma separated list of roles/recipes to apply",
149
- :proc => lambda { |o| o.split(/[\s,]+/) },
150
- :default => []
146
+ short: "-r RUN_LIST",
147
+ long: "--run-list RUN_LIST",
148
+ description: "Comma separated list of roles/recipes to apply",
149
+ proc: lambda { |o| o.split(/[\s,]+/) },
150
+ default: []
151
151
 
152
152
  option :first_boot_attributes,
153
- :short => "-j JSON_ATTRIBS",
154
- :long => "--json-attributes",
155
- :description => "A JSON string to be added to the first run of chef-client",
156
- :proc => lambda { |o| JSON.parse(o) },
157
- :default => {}
153
+ short: "-j JSON_ATTRIBS",
154
+ long: "--json-attributes",
155
+ description: "A JSON string to be added to the first run of chef-client",
156
+ proc: lambda { |o| JSON.parse(o) },
157
+ default: {}
158
158
 
159
159
  option :rackspace_metadata,
160
- :short => "-M JSON",
161
- :long => "--rackspace-metadata JSON",
162
- :description => "JSON string version of metadata hash to be supplied with the server create call",
163
- :proc => lambda { |m| JSON.parse(m) },
164
- :default => {}
160
+ short: "-M JSON",
161
+ long: "--rackspace-metadata JSON",
162
+ description: "JSON string version of metadata hash to be supplied with the server create call",
163
+ proc: lambda { |m| JSON.parse(m) },
164
+ default: {}
165
165
 
166
166
  option :rackconnect_wait,
167
- :long => "--rackconnect-wait",
168
- :description => "Wait until the Rackconnect automation setup is complete before bootstrapping chef",
169
- :boolean => true,
170
- :default => false
167
+ long: "--rackconnect-wait",
168
+ description: "Wait until the Rackconnect automation setup is complete before bootstrapping chef",
169
+ boolean: true,
170
+ default: false
171
171
 
172
172
  option :rackconnect_v3_network_id,
173
- :long => "--rackconnect-v3-network-id ID",
174
- :description => "Rackconnect V3 ONLY: Link a new server to an existing network",
175
- :proc => lambda { |o| Chef::Config[:knife][:rackconnect_v3_network_id] = o },
176
- :default => nil
173
+ long: "--rackconnect-v3-network-id ID",
174
+ description: "Rackconnect V3 ONLY: Link a new server to an existing network",
175
+ proc: lambda { |o| Chef::Config[:knife][:rackconnect_v3_network_id] = o },
176
+ default: nil
177
177
 
178
178
  option :rackspace_servicelevel_wait,
179
- :long => "--rackspace-servicelevel-wait",
180
- :description => "Wait until the Rackspace service level automation setup is complete before bootstrapping chef",
181
- :boolean => true,
182
- :default => false
179
+ long: "--rackspace-servicelevel-wait",
180
+ description: "Wait until the Rackspace service level automation setup is complete before bootstrapping chef",
181
+ boolean: true,
182
+ default: false
183
183
 
184
184
  option :hint,
185
- :long => "--hint HINT_NAME[=HINT_FILE]",
186
- :description => "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
187
- :proc => Proc.new { |h|
185
+ long: "--hint HINT_NAME[=HINT_FILE]",
186
+ description: "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
187
+ proc: Proc.new { |h|
188
188
  Chef::Config[:knife][:hints] ||= {}
189
189
  name, path = h.split("=")
190
- Chef::Config[:knife][:hints][name] = path ? JSON.parse(::File.read(path)) : Hash.new
190
+ Chef::Config[:knife][:hints][name] = path ? JSON.parse(::File.read(path)) : {}
191
191
  }
192
192
 
193
193
  option :host_key_verify,
194
- :long => "--[no-]host-key-verify",
195
- :description => "Verify host key, enabled by default",
196
- :boolean => true,
197
- :default => true
194
+ long: "--[no-]host-key-verify",
195
+ description: "Verify host key, enabled by default",
196
+ boolean: true,
197
+ default: true
198
198
 
199
199
  option :tcp_test_ssh,
200
- :long => "--[no-]tcp-test-ssh",
201
- :description => "Check that SSH is available using a TCP check directly on port 22, enabled by default",
202
- :boolean => true,
203
- :default => true
200
+ long: "--[no-]tcp-test-ssh",
201
+ description: "Check that SSH is available using a TCP check directly on port 22, enabled by default",
202
+ boolean: true,
203
+ default: true
204
204
 
205
205
  option :ssh_wait_timeout,
206
- :long => "--ssh-wait-timeout TIMEOUT",
207
- :description => "The ssh wait timeout, before attempting ssh",
208
- :default => "0"
206
+ long: "--ssh-wait-timeout TIMEOUT",
207
+ description: "The ssh wait timeout, before attempting ssh",
208
+ default: "0"
209
209
 
210
210
  option :retry_ssh_every,
211
- :long => "--retry-ssh-every TIMEOUT",
212
- :description => "Retry SSH after n seconds (retry each period)",
213
- :default => "5"
211
+ long: "--retry-ssh-every TIMEOUT",
212
+ description: "Retry SSH after n seconds (retry each period)",
213
+ default: "5"
214
214
 
215
215
  option :retry_ssh_limit,
216
- :long => "--retry-ssh-limit COUNT",
217
- :description => "Retry SSH at most this number of times",
218
- :default => "5"
216
+ long: "--retry-ssh-limit COUNT",
217
+ description: "Retry SSH at most this number of times",
218
+ default: "5"
219
219
 
220
220
  option :default_networks,
221
- :long => "--[no-]default-networks",
222
- :description => "Include public and service networks, enabled by default",
223
- :boolean => true,
224
- :default => true
221
+ long: "--[no-]default-networks",
222
+ description: "Include public and service networks, enabled by default",
223
+ boolean: true,
224
+ default: true
225
225
 
226
226
  option :network,
227
- :long => "--network [LABEL_OR_ID]",
228
- :description => "Add private network. Use multiple --network options to specify multiple networks.",
229
- :proc => Proc.new{ |name|
227
+ long: "--network [LABEL_OR_ID]",
228
+ description: "Add private network. Use multiple --network options to specify multiple networks.",
229
+ proc: Proc.new { |name|
230
230
  Chef::Config[:knife][:rackspace_networks] ||= []
231
231
  (Chef::Config[:knife][:rackspace_networks] << name).uniq!
232
232
  }
233
233
 
234
234
  option :bootstrap_protocol,
235
- :long => "--bootstrap-protocol protocol",
236
- :description => "Protocol to bootstrap Windows servers. options: winrm",
237
- :default => nil
235
+ long: "--bootstrap-protocol protocol",
236
+ description: "Protocol to bootstrap Windows servers. options: winrm",
237
+ default: nil
238
238
 
239
239
  option :server_create_timeout,
240
- :long => "--server-create-timeout timeout",
241
- :description => "How long to wait until the server is ready; default is 1200 seconds",
242
- :default => 1200,
243
- :proc => Proc.new { |v| Chef::Config[:knife][:server_create_timeout] = v }
240
+ long: "--server-create-timeout timeout",
241
+ description: "How long to wait until the server is ready; default is 1200 seconds",
242
+ default: 1200,
243
+ proc: Proc.new { |v| Chef::Config[:knife][:server_create_timeout] = v }
244
244
 
245
245
  option :bootstrap_proxy,
246
- :long => "--bootstrap-proxy PROXY_URL",
247
- :description => "The proxy server for the node being bootstrapped",
248
- :proc => Proc.new { |v| Chef::Config[:knife][:bootstrap_proxy] = v }
246
+ long: "--bootstrap-proxy PROXY_URL",
247
+ description: "The proxy server for the node being bootstrapped",
248
+ proc: Proc.new { |v| Chef::Config[:knife][:bootstrap_proxy] = v }
249
249
 
250
250
  option :rackspace_disk_config,
251
- :long => "--rackspace-disk-config DISKCONFIG",
252
- :description => "Specify if want to manage your own disk partitioning scheme (AUTO or MANUAL)",
253
- :proc => Proc.new { |k| Chef::Config[:knife][:rackspace_disk_config] = k }
251
+ long: "--rackspace-disk-config DISKCONFIG",
252
+ description: "Specify if want to manage your own disk partitioning scheme (AUTO or MANUAL)",
253
+ proc: Proc.new { |k| Chef::Config[:knife][:rackspace_disk_config] = k }
254
254
 
255
255
  option :rackspace_config_drive,
256
- :long => "--rackspace_config_drive CONFIGDRIVE",
257
- :description => "Creates a config drive device in /dev/disk/by-label/config-2 if set to TRUE",
258
- :proc => Proc.new { |k| Chef::Config[:knife][:rackspace_config_drive] = k },
259
- :default => "false"
256
+ long: "--rackspace_config_drive CONFIGDRIVE",
257
+ description: "Creates a config drive device in /dev/disk/by-label/config-2 if set to TRUE",
258
+ proc: Proc.new { |k| Chef::Config[:knife][:rackspace_config_drive] = k },
259
+ default: "false"
260
260
 
261
261
  option :rackspace_user_data_file,
262
- :long => "--rackspace_user_data_file USERDATA",
263
- :description => "User data file will be placed in the openstack/latest/user_data directory on the config drive",
264
- :proc => Proc.new { |k| Chef::Config[:knife][:rackspace_user_data] = k }
262
+ long: "--rackspace_user_data_file USERDATA",
263
+ description: "User data file will be placed in the openstack/latest/user_data directory on the config drive",
264
+ proc: Proc.new { |k| Chef::Config[:knife][:rackspace_user_data] = k }
265
265
 
266
266
  option :ssh_keypair,
267
- :long => "--ssh-keypair KEYPAIR_NAME",
268
- :description => "Name of existing nova SSH keypair. Public key will be injected into the instance.",
269
- :proc => Proc.new { |v| Chef::Config[:knife][:rackspace_ssh_keypair] = v },
270
- :default => nil
267
+ long: "--ssh-keypair KEYPAIR_NAME",
268
+ description: "Name of existing nova SSH keypair. Public key will be injected into the instance.",
269
+ proc: Proc.new { |v| Chef::Config[:knife][:rackspace_ssh_keypair] = v },
270
+ default: nil
271
271
 
272
272
  option :secret,
273
- :long => "--secret",
274
- :description => "The secret key to us to encrypt data bag item values",
275
- :proc => lambda { |s| Chef::Config[:knife][:secret] = s }
273
+ long: "--secret",
274
+ description: "The secret key to us to encrypt data bag item values",
275
+ proc: lambda { |s| Chef::Config[:knife][:secret] = s }
276
276
 
277
277
  option :secret_file,
278
- :long => "--secret-file SECRET_FILE",
279
- :description => "A file containing the secret key to use to encrypt data bag item values",
280
- :proc => lambda { |sf| Chef::Config[:knife][:secret_file] = sf }
278
+ long: "--secret-file SECRET_FILE",
279
+ description: "A file containing the secret key to use to encrypt data bag item values",
280
+ proc: lambda { |sf| Chef::Config[:knife][:secret_file] = sf }
281
281
 
282
282
  option :bootstrap_vault_file,
283
- :long => "--bootstrap-vault-file VAULT_FILE",
284
- :description => "A JSON file with a list of vault(s) and item(s) to be updated"
283
+ long: "--bootstrap-vault-file VAULT_FILE",
284
+ description: "A JSON file with a list of vault(s) and item(s) to be updated"
285
285
 
286
286
  option :bootstrap_vault_json,
287
- :long => "--bootstrap-vault-json VAULT_JSON",
288
- :description => "A JSON string with the vault(s) and item(s) to be updated"
287
+ long: "--bootstrap-vault-json VAULT_JSON",
288
+ description: "A JSON string with the vault(s) and item(s) to be updated"
289
289
 
290
290
  option :bootstrap_vault_item,
291
- :long => "--bootstrap-vault-item VAULT_ITEM",
292
- :description => 'A single vault and item to update as "vault:item"',
293
- :proc => Proc.new { |i|
291
+ long: "--bootstrap-vault-item VAULT_ITEM",
292
+ description: 'A single vault and item to update as "vault:item"',
293
+ proc: Proc.new { |i|
294
294
  (vault, item) = i.split(/:/)
295
295
  Chef::Config[:knife][:bootstrap_vault_item] ||= {}
296
296
  Chef::Config[:knife][:bootstrap_vault_item][vault] ||= []
@@ -306,13 +306,13 @@ class Chef
306
306
  end
307
307
 
308
308
  def tcp_test_ssh(server, bootstrap_ip)
309
- return true unless locate_config_value(:tcp_test_ssh) != nil
309
+ return true if locate_config_value(:tcp_test_ssh).nil?
310
310
 
311
311
  limit = locate_config_value(:retry_ssh_limit).to_i
312
312
  count = 0
313
313
 
314
314
  begin
315
- Net::SSH.start(bootstrap_ip, "root", :password => server.password ) do |ssh|
315
+ Net::SSH.start(bootstrap_ip, "root", password: server.password ) do |ssh|
316
316
  Chef::Log.debug("sshd accepting connections on #{bootstrap_ip}")
317
317
  break
318
318
  end
@@ -358,8 +358,8 @@ class Chef
358
358
  dest, src = parse_file_argument(arg)
359
359
  Chef::Log.debug("Inject file #{src} into #{dest}")
360
360
  files << {
361
- :path => dest,
362
- :contents => encode_file(src),
361
+ path: dest,
362
+ contents: encode_file(src),
363
363
  }
364
364
  end
365
365
  files
@@ -391,14 +391,14 @@ class Chef
391
391
  $stdout.sync = true
392
392
 
393
393
  server_create_options = {
394
- :metadata => locate_config_value(:rackspace_metadata),
395
- :disk_config => locate_config_value(:rackspace_disk_config),
396
- :user_data => user_data,
397
- :config_drive => locate_config_value(:rackspace_config_drive) || false,
398
- :personality => files,
399
- :key_name => locate_config_value(:rackspace_ssh_keypair),
400
- :name => get_node_name(config[:chef_node_name] || config[:server_name]),
401
- :networks => get_networks(locate_config_value(:rackspace_networks), locate_config_value(:rackconnect_v3_network_id)),
394
+ metadata: locate_config_value(:rackspace_metadata),
395
+ disk_config: locate_config_value(:rackspace_disk_config),
396
+ user_data: user_data,
397
+ config_drive: locate_config_value(:rackspace_config_drive) || false,
398
+ personality: files,
399
+ key_name: locate_config_value(:rackspace_ssh_keypair),
400
+ name: get_node_name(config[:chef_node_name] || config[:server_name]),
401
+ networks: get_networks(locate_config_value(:rackspace_networks), locate_config_value(:rackconnect_v3_network_id)),
402
402
  }
403
403
 
404
404
  # Maybe deprecate this option at some point
@@ -431,7 +431,7 @@ class Chef
431
431
  else
432
432
  server_create_options[:image_id] = locate_config_value(:image)
433
433
 
434
- if !server_create_options[:image_id]
434
+ unless server_create_options[:image_id]
435
435
  ui.error("Please specify an Image ID for the server with --image (-I)")
436
436
  exit 1
437
437
  end
@@ -446,7 +446,7 @@ class Chef
446
446
  if version_one?
447
447
  server.save
448
448
  else
449
- server.save(:networks => server_create_options[:networks])
449
+ server.save(networks: server_create_options[:networks])
450
450
  end
451
451
 
452
452
  rackconnect_wait = locate_config_value(:rackconnect_wait)
@@ -469,18 +469,18 @@ class Chef
469
469
  # wait for it to be ready to do stuff
470
470
  begin
471
471
  server.wait_for(Integer(locate_config_value(:server_create_timeout))) do
472
- print ".";
472
+ print "."
473
473
  Chef::Log.debug("#{progress}%")
474
474
 
475
475
  if rackconnect_wait && rackspace_servicelevel_wait
476
- Chef::Log.debug("rackconnect_automation_status: #{metadata.all['rackconnect_automation_status']}")
477
- Chef::Log.debug("rax_service_level_automation: #{metadata.all['rax_service_level_automation']}")
476
+ Chef::Log.debug("rackconnect_automation_status: #{metadata.all["rackconnect_automation_status"]}")
477
+ Chef::Log.debug("rax_service_level_automation: #{metadata.all["rax_service_level_automation"]}")
478
478
  ready? && metadata.all["rackconnect_automation_status"] == "DEPLOYED" && metadata.all["rax_service_level_automation"] == "Complete"
479
479
  elsif rackconnect_wait
480
- Chef::Log.debug("rackconnect_automation_status: #{metadata.all['rackconnect_automation_status']}")
480
+ Chef::Log.debug("rackconnect_automation_status: #{metadata.all["rackconnect_automation_status"]}")
481
481
  ready? && metadata.all["rackconnect_automation_status"] == "DEPLOYED"
482
482
  elsif rackspace_servicelevel_wait
483
- Chef::Log.debug("rax_service_level_automation: #{metadata.all['rax_service_level_automation']}")
483
+ Chef::Log.debug("rax_service_level_automation: #{metadata.all["rax_service_level_automation"]}")
484
484
  ready? && metadata.all["rax_service_level_automation"] == "Complete"
485
485
  else
486
486
  ready?
@@ -491,7 +491,7 @@ class Chef
491
491
  msg_pair("Progress", "#{server.progress}%")
492
492
  msg_pair("rackconnect_automation_status", server.metadata.all["rackconnect_automation_status"])
493
493
  msg_pair("rax_service_level_automation", server.metadata.all["rax_service_level_automation"])
494
- Chef::Application.fatal! 'Server didn\'t finish on time'
494
+ Chef::Application.fatal! "Server didn't finish on time"
495
495
  end
496
496
 
497
497
  msg_pair("Metadata", server.metadata)
@@ -638,10 +638,11 @@ class Chef
638
638
  end
639
639
 
640
640
  end
641
- #v2 servers require a name, random if chef_node_name is empty, empty if v1
641
+ # v2 servers require a name, random if chef_node_name is empty, empty if v1
642
642
  def get_node_name(chef_node_name)
643
643
  return chef_node_name unless chef_node_name.nil?
644
- #lazy uuids
644
+
645
+ # lazy uuids
645
646
  chef_node_name = "rs-" + rand.to_s.split(".")[1] unless version_one?
646
647
  end
647
648
 
@@ -652,10 +653,10 @@ class Chef
652
653
  nets = if rackconnect3
653
654
  [locate_config_value(:rackconnect_v3_network_id)]
654
655
  elsif locate_config_value(:default_networks)
655
- [
656
- "00000000-0000-0000-0000-000000000000",
657
- "11111111-1111-1111-1111-111111111111",
658
- ]
656
+ %w{
657
+ 00000000-0000-0000-0000-000000000000
658
+ 11111111-1111-1111-1111-111111111111
659
+ }
659
660
  else
660
661
  []
661
662
  end
@@ -17,7 +17,7 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require "chef/knife/rackspace_base"
20
+ require_relative "rackspace_base"
21
21
 
22
22
  # These two are needed for the '--purge' deletion case
23
23
  require "chef/node"
@@ -32,16 +32,16 @@ class Chef
32
32
  banner "knife rackspace server delete SERVER_ID [SERVER_ID] (options)"
33
33
 
34
34
  option :purge,
35
- :short => "-P",
36
- :long => "--purge",
37
- :boolean => true,
38
- :default => false,
39
- :description => "Destroy corresponding node and client on the Chef Server, in addition to destroying the Rackspace node itself. Assumes node and client have the same name as the server (if not, add the '--node-name' option)."
35
+ short: "-P",
36
+ long: "--purge",
37
+ boolean: true,
38
+ default: false,
39
+ description: "Destroy corresponding node and client on the Chef Server, in addition to destroying the Rackspace node itself. Assumes node and client have the same name as the server (if not, add the '--node-name' option)."
40
40
 
41
41
  option :chef_node_name,
42
- :short => "-N NAME",
43
- :long => "--node-name NAME",
44
- :description => "The name of the node and client to delete, if it differs from the server name. Only has meaning when used with the '--purge' option."
42
+ short: "-N NAME",
43
+ long: "--node-name NAME",
44
+ description: "The name of the node and client to delete, if it differs from the server name. Only has meaning when used with the '--purge' option."
45
45
 
46
46
  # Extracted from Chef::Knife.delete_object, because it has a
47
47
  # confirmation step built in... By specifying the '--purge'
@@ -49,13 +49,11 @@ class Chef
49
49
  # the user is already making their intent known. It is not
50
50
  # necessary to make them confirm two more times.
51
51
  def destroy_item(klass, name, type_name)
52
- begin
53
- object = klass.load(name)
54
- object.destroy
55
- ui.warn("Deleted #{type_name} #{name}")
56
- rescue Net::HTTPServerException
57
- ui.warn("Could not find a #{type_name} named #{name} to delete!")
58
- end
52
+ object = klass.load(name)
53
+ object.destroy
54
+ ui.warn("Deleted #{type_name} #{name}")
55
+ rescue Net::HTTPServerException
56
+ ui.warn("Could not find a #{type_name} named #{name} to delete!")
59
57
  end
60
58
 
61
59
  def run
@@ -84,7 +82,7 @@ class Chef
84
82
  destroy_item(Chef::Node, thing_to_delete, "node")
85
83
  destroy_item(Chef::ApiClient, thing_to_delete, "client")
86
84
  else
87
- #v2 nodes may be named automatically
85
+ # v2 nodes may be named automatically
88
86
  thing_to_delete = config[:chef_node_name] || server.name
89
87
  destroy_item(Chef::Node, thing_to_delete, "node")
90
88
  destroy_item(Chef::ApiClient, thing_to_delete, "client")
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/knife/rackspace_base"
19
+ require_relative "rackspace_base"
20
20
 
21
21
  class Chef
22
22
  class Knife
@@ -39,7 +39,7 @@ class Chef
39
39
  if version_one?
40
40
  network_list = %w{public private}
41
41
  else
42
- network_list = connection.networks.sort_by(&:label).collect { |t| t.label }
42
+ network_list = connection.networks.sort_by(&:label).collect(&:label)
43
43
  end
44
44
  server_list.insert(2, network_list.collect { |n| ui.color("#{n.capitalize} IP", :bold) }).flatten!
45
45
  num_columns_across = server_list.length
@@ -48,8 +48,8 @@ class Chef
48
48
  server_list << server.id.to_s
49
49
  server_list << server.name
50
50
  server_list += network_list.collect { |n| ip_address(server, n) }
51
- server_list << (server.flavor_id == nil ? "" : server.flavor_id.to_s)
52
- server_list << (server.image_id == nil ? "" : server.image_id.to_s)
51
+ server_list << (server.flavor_id.nil? ? "" : server.flavor_id.to_s)
52
+ server_list << (server.image_id.nil? ? "" : server.image_id.to_s)
53
53
  server_list << begin
54
54
  case server.state.downcase
55
55
  when "deleted", "suspended"
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Rackspace
3
- VERSION = "2.0.0"
3
+ VERSION = "2.0.2".freeze
4
4
  MAJOR, MINOR, TINY = VERSION.split(".")
5
5
  end
6
6
  end
@@ -3,8 +3,8 @@ require "vcr"
3
3
  require "ansi/code"
4
4
  require "ansi/diff"
5
5
 
6
- Chef::Config[:knife][:rackspace_api_username] = "#{ENV['OS_USERNAME']}"
7
- Chef::Config[:knife][:rackspace_api_key] = "#{ENV['OS_PASSWORD']}"
6
+ Chef::Config[:knife][:rackspace_api_username] = "#{ENV["OS_USERNAME"]}"
7
+ Chef::Config[:knife][:rackspace_api_key] = "#{ENV["OS_PASSWORD"]}"
8
8
  Chef::Config[:knife][:ssl_verify_peer] = false
9
9
  # Chef::Config[:knife][:rackspace_version] = "#{ENV['RS_VERSION']}"
10
10
 
@@ -45,9 +45,9 @@ VCR.configure do |c|
45
45
  c.default_cassette_options = {
46
46
  # :record => :none,
47
47
  # Ignores cache busting parameters.
48
- :match_requests_on => [:host, :path],
48
+ match_requests_on: %i{host path},
49
49
  }
50
- c.default_cassette_options.merge!({ :record => :all }) if ENV["INTEGRATION_TESTS"] == "live"
50
+ c.default_cassette_options.merge!({ record: :all }) if ENV["INTEGRATION_TESTS"] == "live"
51
51
  end
52
52
 
53
53
  def filter_headers(interaction, pattern, placeholder)
@@ -124,7 +124,7 @@ def knife_capture(command, args = [], input = nil)
124
124
  $VERBOSE = warn
125
125
 
126
126
  status = Chef::Knife::DSL::Support.run_knife(command, args)
127
- return $stdout.string, $stderr.string, status
127
+ [$stdout.string, $stderr.string, status]
128
128
  ensure
129
129
  warn = $VERBOSE
130
130
  $VERBOSE = nil
@@ -18,7 +18,7 @@ describe "auth_endpoint" do
18
18
  expect(tester.auth_endpoint).to eq(test_url)
19
19
  end
20
20
 
21
- [:dfw, :ord, :syd].each do |region|
21
+ %i{dfw ord syd}.each do |region|
22
22
  it "should pick the US endpoint if the region is #{region}" do
23
23
  tester = RackspaceBaseTester.new
24
24
  Chef::Config[:knife][:rackspace_auth_url] = nil
@@ -38,7 +38,7 @@ describe "auth_endpoint" do
38
38
  end
39
39
 
40
40
  describe "locate_config_value" do
41
- it 'with cli options' do
41
+ it "with cli options" do
42
42
  # CLI
43
43
  tester = RackspaceBaseTester.new
44
44
  tester.parse_options([ "--rackspace-api-key", "12345" ])
@@ -50,7 +50,7 @@ describe "locate_config_value" do
50
50
  expect(tester.locate_config_value(:rackspace_api_key)).to eq("12345")
51
51
  end
52
52
 
53
- it 'without cli options' do
53
+ it "without cli options" do
54
54
  # CLI
55
55
  tester = RackspaceBaseTester.new
56
56
  tester.parse_options([])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-rackspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-11-28 00:00:00.000000000 Z
15
+ date: 2019-12-30 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: knife-windows
@@ -104,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.7.6
107
+ rubygems_version: 3.0.3
109
108
  signing_key:
110
109
  specification_version: 4
111
110
  summary: Rackspace Support for Chef's Knife Command