knife-azure 1.8.7 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/azure/azure_interface.rb +79 -81
  3. data/lib/azure/custom_errors.rb +34 -35
  4. data/lib/azure/helpers.rb +43 -44
  5. data/lib/azure/resource_management/ARM_deployment_template.rb +679 -678
  6. data/lib/azure/resource_management/ARM_interface.rb +513 -515
  7. data/lib/azure/resource_management/vnet_config.rb +43 -43
  8. data/lib/azure/resource_management/windows_credentials.rb +181 -184
  9. data/lib/azure/service_management/ASM_interface.rb +309 -317
  10. data/lib/azure/service_management/ag.rb +16 -16
  11. data/lib/azure/service_management/certificate.rb +30 -31
  12. data/lib/azure/service_management/connection.rb +31 -31
  13. data/lib/azure/service_management/deploy.rb +40 -38
  14. data/lib/azure/service_management/disk.rb +14 -10
  15. data/lib/azure/service_management/host.rb +28 -24
  16. data/lib/azure/service_management/image.rb +23 -22
  17. data/lib/azure/service_management/loadbalancer.rb +12 -12
  18. data/lib/azure/service_management/rest.rb +20 -19
  19. data/lib/azure/service_management/role.rb +274 -273
  20. data/lib/azure/service_management/storageaccount.rb +29 -25
  21. data/lib/azure/service_management/utility.rb +6 -7
  22. data/lib/azure/service_management/vnet.rb +44 -44
  23. data/lib/chef/knife/azure_ag_create.rb +18 -18
  24. data/lib/chef/knife/azure_ag_list.rb +3 -3
  25. data/lib/chef/knife/azure_base.rb +56 -56
  26. data/lib/chef/knife/azure_image_list.rb +8 -10
  27. data/lib/chef/knife/azure_internal-lb_create.rb +15 -15
  28. data/lib/chef/knife/azure_internal-lb_list.rb +3 -3
  29. data/lib/chef/knife/azure_server_create.rb +49 -50
  30. data/lib/chef/knife/azure_server_delete.rb +22 -24
  31. data/lib/chef/knife/azure_server_list.rb +4 -4
  32. data/lib/chef/knife/azure_server_show.rb +5 -5
  33. data/lib/chef/knife/azure_vnet_create.rb +17 -17
  34. data/lib/chef/knife/azure_vnet_list.rb +3 -3
  35. data/lib/chef/knife/azurerm_base.rb +58 -60
  36. data/lib/chef/knife/azurerm_server_create.rb +23 -22
  37. data/lib/chef/knife/azurerm_server_delete.rb +30 -34
  38. data/lib/chef/knife/azurerm_server_list.rb +42 -42
  39. data/lib/chef/knife/azurerm_server_show.rb +1 -1
  40. data/lib/chef/knife/bootstrap/bootstrap_options.rb +7 -8
  41. data/lib/chef/knife/bootstrap/bootstrapper.rb +65 -65
  42. data/lib/chef/knife/bootstrap/common_bootstrap_options.rb +3 -4
  43. data/lib/chef/knife/bootstrap_azure.rb +13 -13
  44. data/lib/chef/knife/bootstrap_azurerm.rb +106 -106
  45. data/lib/knife-azure/version.rb +2 -2
  46. metadata +43 -76
  47. data/lib/azure/resource_management/ARM_base.rb +0 -29
@@ -1,8 +1,8 @@
1
1
  #
2
2
  # Author:: Barry Davis (barryd@jetstreamsoftware.com)
3
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
4
- # Author:: Adam Jacob (<adam@opscode.com>)
5
- # Copyright:: Copyright (c) 2010-2011 Opscode, Inc.
3
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
4
+ # Author:: Adam Jacob (<adam@chef.io>)
5
+ # Copyright:: Copyright 2010-2018 Chef Software, Inc.
6
6
  # License:: Apache License, Version 2.0
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +18,7 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- require File.expand_path('../azure_base', __FILE__)
21
+ require File.expand_path("../azure_base", __FILE__)
22
22
 
23
23
  class Chef
24
24
  class Knife
@@ -1,8 +1,8 @@
1
1
  #
2
2
  # Author:: Barry Davis (barryd@jetstreamsoftware.com)
3
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
4
- # Author:: Adam Jacob (<adam@opscode.com>)
5
- # Copyright:: Copyright (c) 2010-2011 Opscode, Inc.
3
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
4
+ # Author:: Adam Jacob (<adam@chef.io>)
5
+ # Copyright:: Copyright 2010-2018 Chef Software, Inc.
6
6
  # License:: Apache License, Version 2.0
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +18,7 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- require File.expand_path('../azure_base', __FILE__)
21
+ require File.expand_path("../azure_base", __FILE__)
22
22
 
23
23
  class Chef
24
24
  class Knife
@@ -26,7 +26,7 @@ class Chef
26
26
 
27
27
  include Knife::AzureBase
28
28
 
29
- banner "knife azure server show SERVER [SERVER]"
29
+ banner "knife azure server show SERVER [SERVER]"
30
30
 
31
31
  def run
32
32
  $stdout.sync = true
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Jeff Mendoza (jeffmendoza@live.com)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
3
+ # Copyright:: Copyright 2013-2018 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,41 +16,41 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path('../azure_base', __FILE__)
19
+ require File.expand_path("../azure_base", __FILE__)
20
20
 
21
21
  class Chef
22
22
  class Knife
23
23
  class AzureVnetCreate < Knife
24
24
  include Knife::AzureBase
25
25
 
26
- banner 'knife azure vnet create (options)'
26
+ banner "knife azure vnet create (options)"
27
27
 
28
28
  option :azure_network_name,
29
- :short => '-n NETWORK_NAME',
30
- :long => '--azure-network-name NETWORK_NAME',
29
+ :short => "-n NETWORK_NAME",
30
+ :long => "--azure-network-name NETWORK_NAME",
31
31
  :description =>
32
- 'Specifies the name of the virtual network to create.'
32
+ "Specifies the name of the virtual network to create."
33
33
 
34
34
  option :azure_affinity_group,
35
- :short => '-a GROUP',
36
- :long => '--azure-affinity-group GROUP',
35
+ :short => "-a GROUP",
36
+ :long => "--azure-affinity-group GROUP",
37
37
  :description =>
38
- 'Specifies the affinity group to associate with the vnet.'
38
+ "Specifies the affinity group to associate with the vnet."
39
39
 
40
40
  option :azure_address_space,
41
- :long => '--azure-address-space CIDR',
41
+ :long => "--azure-address-space CIDR",
42
42
  :description =>
43
- 'Specifies the address space of the vnet using CIDR notation.'
43
+ "Specifies the address space of the vnet using CIDR notation."
44
44
 
45
45
  option :azure_subnet_name,
46
- :long => '--azure-subnet-name CIDR',
46
+ :long => "--azure-subnet-name CIDR",
47
47
  :description =>
48
- 'Specifies the Subnet Name.'
48
+ "Specifies the Subnet Name."
49
49
 
50
50
  def run
51
51
  $stdout.sync = true
52
52
 
53
- Chef::Log.info('validating...')
53
+ Chef::Log.info("validating...")
54
54
  validate_asm_keys!(:azure_network_name, :azure_affinity_group, :azure_address_space)
55
55
 
56
56
  params = {
@@ -62,9 +62,9 @@ class Chef
62
62
 
63
63
  rsp = service.create_vnet(params)
64
64
  print "\n"
65
- if rsp.at_css('Status').nil?
66
- if rsp.at_css('Code').nil? || rsp.at_css('Message').nil?
67
- puts 'Unknown Error. try -VV'
65
+ if rsp.at_css("Status").nil?
66
+ if rsp.at_css("Code").nil? || rsp.at_css("Message").nil?
67
+ puts "Unknown Error. try -VV"
68
68
  else
69
69
  puts "#{rsp.at_css('Code').content}: "\
70
70
  "#{rsp.at_css('Message').content}"
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Jeff Mendoza (jeffmendoza@live.com)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
3
+ # Copyright:: Copyright 2013-2018 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,14 +16,14 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path('../azure_base', __FILE__)
19
+ require File.expand_path("../azure_base", __FILE__)
20
20
 
21
21
  class Chef
22
22
  class Knife
23
23
  class AzureVnetList < Knife
24
24
  include Knife::AzureBase
25
25
 
26
- banner 'knife azure vnet list (options)'
26
+ banner "knife azure vnet list (options)"
27
27
 
28
28
  def run
29
29
  $stdout.sync = true
@@ -1,4 +1,4 @@
1
-
1
+ #
2
2
  # Author:: Aliasgar Batterywala (aliasgar.batterywala@clogeny.com)
3
3
  #
4
4
  # Copyright:: Copyright 2009-2018, Chef Software Inc.
@@ -17,12 +17,12 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require 'chef/knife'
21
- require 'azure/resource_management/ARM_interface'
22
- require 'mixlib/shellout'
23
- require 'chef/mixin/shell_out'
24
- require 'time'
25
- require 'json'
20
+ require "chef/knife"
21
+ require "azure/resource_management/ARM_interface"
22
+ require "mixlib/shellout"
23
+ require "chef/mixin/shell_out"
24
+ require "time"
25
+ require "json"
26
26
 
27
27
  class Chef
28
28
  class Knife
@@ -34,15 +34,15 @@ class Chef
34
34
  XPLAT_VERSION_WITH_WCM_DEPRECATED ||= "0.10.5"
35
35
 
36
36
  if Chef::Platform.windows?
37
- require 'azure/resource_management/windows_credentials'
37
+ require "azure/resource_management/windows_credentials"
38
38
  include Azure::ARM::WindowsCredentials
39
39
  end
40
40
 
41
41
  def self.included(includer)
42
42
  includer.class_eval do
43
43
  deps do
44
- require 'readline'
45
- require 'chef/json_compat'
44
+ require "readline"
45
+ require "chef/json_compat"
46
46
  end
47
47
 
48
48
  option :azure_resource_group_name,
@@ -64,7 +64,7 @@ class Chef
64
64
 
65
65
  def locate_config_value(key)
66
66
  key = key.to_sym
67
- config[key] || Chef::Config[:knife][key] || default_config[key]
67
+ config[key] || Chef::Config[:knife][key] || default_config[key]
68
68
  end
69
69
 
70
70
  # validates ARM mandatory keys
@@ -84,14 +84,14 @@ class Chef
84
84
  errors << "You did not provide a valid '#{pretty_key(k)}' value. Please set knife[:#{k}] in your knife.rb."
85
85
  end
86
86
  end
87
- if errors.each{|e| ui.error(e)}.any?
87
+ if errors.each { |e| ui.error(e) }.any?
88
88
  exit 1
89
89
  end
90
90
  end
91
91
 
92
92
  def authentication_details
93
93
  if is_azure_cred?
94
- return {:azure_tenant_id => locate_config_value(:azure_tenant_id), :azure_client_id => locate_config_value(:azure_client_id), :azure_client_secret => locate_config_value(:azure_client_secret)}
94
+ return { :azure_tenant_id => locate_config_value(:azure_tenant_id), :azure_client_id => locate_config_value(:azure_client_id), :azure_client_secret => locate_config_value(:azure_client_secret) }
95
95
  elsif Chef::Platform.windows?
96
96
  token_details = token_details_for_windows()
97
97
  else
@@ -102,9 +102,9 @@ class Chef
102
102
  end
103
103
 
104
104
  def get_azure_cli_version
105
- if @azure_version != ""
105
+ if @azure_version != ""
106
106
  get_version = shell_out!("azure -v || az -v | grep azure-cli", { returns: [0] }).stdout
107
- @azure_version = get_version.gsub(/[^0-9.]/, '')
107
+ @azure_version = get_version.gsub(/[^0-9.]/, "")
108
108
  end
109
109
  @azure_prefix = @azure_version.to_i < 2 ? "azure" : "az"
110
110
  @azure_version
@@ -123,10 +123,10 @@ class Chef
123
123
  end
124
124
 
125
125
  def token_details_from_accessToken_file
126
- home_dir = File.expand_path('~')
127
- file = File.read(home_dir + '/.azure/accessTokens.json')
126
+ home_dir = File.expand_path("~")
127
+ file = File.read(home_dir + "/.azure/accessTokens.json")
128
128
  file = JSON.parse(file)
129
- token_details = {:tokentype => file[-1]["tokenType"], :user => file[-1]["userId"], :token => file[-1]["accessToken"], :clientid => file[-1]["_clientId"], :expiry_time => file[-1]["expiresOn"], :refreshtoken => file[-1]["refreshToken"]}
129
+ token_details = { :tokentype => file[-1]["tokenType"], :user => file[-1]["userId"], :token => file[-1]["accessToken"], :clientid => file[-1]["_clientId"], :expiry_time => file[-1]["expiresOn"], :refreshtoken => file[-1]["refreshToken"] }
130
130
  token_details
131
131
  end
132
132
 
@@ -148,13 +148,11 @@ class Chef
148
148
  end
149
149
 
150
150
  def azure_authentication
151
- begin
152
- ui.log("Authenticating...")
153
- Mixlib::ShellOut.new("#{@azure_prefix} vm show 'knifetest@resourcegroup' testvm", :timeout => 30).run_command
154
- rescue Mixlib::ShellOut::CommandTimeout
155
- rescue Exception
156
- raise_azure_status
157
- end
151
+ ui.log("Authenticating...")
152
+ Mixlib::ShellOut.new("#{@azure_prefix} vm show 'knifetest@resourcegroup' testvm", :timeout => 30).run_command
153
+ rescue Mixlib::ShellOut::CommandTimeout
154
+ rescue Exception
155
+ raise_azure_status
158
156
  end
159
157
 
160
158
  def check_token_validity(token_details)
@@ -176,18 +174,18 @@ class Chef
176
174
  raise login_message
177
175
  end
178
176
  else
179
- home_dir = File.expand_path('~')
180
- if !File.exists?(home_dir + "/.azure/accessTokens.json") || File.size?(home_dir + '/.azure/accessTokens.json') <= 2
177
+ home_dir = File.expand_path("~")
178
+ if !File.exist?(home_dir + "/.azure/accessTokens.json") || File.size?(home_dir + "/.azure/accessTokens.json") <= 2
181
179
  raise login_message
182
180
  end
183
181
  end
184
182
  end
185
183
 
186
184
  def parse_publish_settings_file(filename)
187
- require 'nokogiri'
188
- require 'base64'
189
- require 'openssl'
190
- require 'uri'
185
+ require "nokogiri"
186
+ require "base64"
187
+ require "openssl"
188
+ require "uri"
191
189
  begin
192
190
  doc = Nokogiri::XML(File.open(find_file(filename)))
193
191
  profile = doc.at_css("PublishProfile")
@@ -204,7 +202,7 @@ class Chef
204
202
  end
205
203
  Chef::Config[:knife][:azure_mgmt_cert] = management_cert.certificate.to_pem + management_cert.key.to_pem
206
204
  Chef::Config[:knife][:azure_subscription_id] = doc.at_css("Subscription").attribute("Id").value
207
- rescue=> error
205
+ rescue => error
208
206
  puts "#{error.class} and #{error.message}"
209
207
  exit 1
210
208
  end
@@ -217,10 +215,10 @@ class Chef
217
215
  file = name
218
216
  elsif config_dir && File.exist?(File.join(config_dir, name))
219
217
  file = File.join(config_dir, name)
220
- elsif File.exist?(File.join(ENV['HOME'], '.chef', name))
221
- file = File.join(ENV['HOME'], '.chef', name)
218
+ elsif File.exist?(File.join(ENV["HOME"], ".chef", name))
219
+ file = File.join(ENV["HOME"], ".chef", name)
222
220
  else
223
- ui.error('Unable to find file - ' + name)
221
+ ui.error("Unable to find file - " + name)
224
222
  exit 1
225
223
  end
226
224
  file
@@ -228,37 +226,37 @@ class Chef
228
226
 
229
227
  def msg_server_summary(server)
230
228
  puts "\n\n"
231
- if server.provisioningstate == 'Succeeded'
229
+ if server.provisioningstate == "Succeeded"
232
230
  Chef::Log.info("Server creation went successfull.")
233
231
  puts "\nServer Details are:\n"
234
232
 
235
- msg_pair('Server ID', server.id)
236
- msg_pair('Server Name', server.name)
237
- msg_pair('Server Public IP Address', server.publicipaddress)
233
+ msg_pair("Server ID", server.id)
234
+ msg_pair("Server Name", server.name)
235
+ msg_pair("Server Public IP Address", server.publicipaddress)
238
236
  if is_image_windows?
239
- msg_pair('Server RDP Port', server.rdpport)
237
+ msg_pair("Server RDP Port", server.rdpport)
240
238
  else
241
- msg_pair('Server SSH Port', server.sshport)
239
+ msg_pair("Server SSH Port", server.sshport)
242
240
  end
243
- msg_pair('Server Location', server.locationname)
244
- msg_pair('Server OS Type', server.ostype)
245
- msg_pair('Server Provisioning State', server.provisioningstate)
241
+ msg_pair("Server Location", server.locationname)
242
+ msg_pair("Server OS Type", server.ostype)
243
+ msg_pair("Server Provisioning State", server.provisioningstate)
246
244
  else
247
245
  Chef::Log.info("Server Creation Failed.")
248
246
  end
249
247
 
250
248
  puts "\n\n"
251
249
 
252
- if server.resources.provisioning_state == 'Succeeded'
250
+ if server.resources.provisioning_state == "Succeeded"
253
251
  Chef::Log.info("Server Extension creation went successfull.")
254
252
  puts "\nServer Extension Details are:\n"
255
253
 
256
- msg_pair('Server Extension ID', server.resources.id)
257
- msg_pair('Server Extension Name', server.resources.name)
258
- msg_pair('Server Extension Publisher', server.resources.publisher)
259
- msg_pair('Server Extension Type', server.resources.type)
260
- msg_pair('Server Extension Type Handler Version', server.resources.type_handler_version)
261
- msg_pair('Server Extension Provisioning State', server.resources.provisioning_state)
254
+ msg_pair("Server Extension ID", server.resources.id)
255
+ msg_pair("Server Extension Name", server.resources.name)
256
+ msg_pair("Server Extension Publisher", server.resources.publisher)
257
+ msg_pair("Server Extension Type", server.resources.type)
258
+ msg_pair("Server Extension Type Handler Version", server.resources.type_handler_version)
259
+ msg_pair("Server Extension Provisioning State", server.resources.provisioning_state)
262
260
  else
263
261
  Chef::Log.info("Server Extension Creation Failed.")
264
262
  end
@@ -270,16 +268,16 @@ class Chef
270
268
  raise ArgumentError, "When --azure-vnet-subnet-name is specified, the --azure-vnet-name must also be specified."
271
269
  end
272
270
 
273
- if locate_config_value(:azure_vnet_subnet_name) == 'GatewaySubnet'
274
- raise ArgumentError, 'GatewaySubnet cannot be used as the name for --azure-vnet-subnet-name option. GatewaySubnet can only be used for virtual network gateways.'
271
+ if locate_config_value(:azure_vnet_subnet_name) == "GatewaySubnet"
272
+ raise ArgumentError, "GatewaySubnet cannot be used as the name for --azure-vnet-subnet-name option. GatewaySubnet can only be used for virtual network gateways."
275
273
  end
276
274
 
277
- if locate_config_value(:node_ssl_verify_mode) && !["none", "peer"].include?(locate_config_value(:node_ssl_verify_mode))
275
+ if locate_config_value(:node_ssl_verify_mode) && !%w{none peer}.include?(locate_config_value(:node_ssl_verify_mode))
278
276
  raise ArgumentError, "Invalid value '#{locate_config_value(:node_ssl_verify_mode)}' for --node-ssl-verify-mode. Use Valid values i.e 'none', 'peer'."
279
277
  end
280
278
 
281
279
  if is_image_windows?
282
- if locate_config_value(:winrm_user).nil? || locate_config_value(:winrm_password).nil?
280
+ if locate_config_value(:winrm_user).nil? || locate_config_value(:winrm_password).nil?
283
281
  raise ArgumentError, "Please provide --winrm-user and --winrm-password options for Windows option."
284
282
  end
285
283
  end
@@ -307,19 +305,19 @@ class Chef
307
305
  end
308
306
 
309
307
  config[:ohai_hints] = format_ohai_hints(locate_config_value(:ohai_hints))
310
- validate_ohai_hints if ! locate_config_value(:ohai_hints).casecmp('default').zero?
308
+ validate_ohai_hints if ! locate_config_value(:ohai_hints).casecmp("default").zero?
311
309
  end
312
310
 
313
- private
311
+ private
314
312
 
315
- def msg_pair(label, value, color=:cyan)
313
+ def msg_pair(label, value, color = :cyan)
316
314
  if value && !value.to_s.empty?
317
315
  puts "#{ui.color(label, color)}: #{value}"
318
316
  end
319
317
  end
320
318
 
321
319
  def pretty_key(key)
322
- key.to_s.gsub(/_/, ' ').gsub(/\w+/){ |w| (w =~ /(ssh)|(aws)/i) ? w.upcase : w.capitalize }
320
+ key.to_s.tr("_", " ").gsub(/\w+/) { |w| (w =~ /(ssh)|(aws)/i) ? w.upcase : w.capitalize }
323
321
  end
324
322
 
325
323
  def is_image_windows?
@@ -340,7 +338,7 @@ class Chef
340
338
  end
341
339
 
342
340
  def is_WCM_env_var_set?
343
- ENV['AZURE_USE_SECURE_TOKEN_STORAGE'].nil? ? false : true
341
+ ENV["AZURE_USE_SECURE_TOKEN_STORAGE"].nil? ? false : true
344
342
  end
345
343
 
346
344
  def raise_azure_status
@@ -17,10 +17,10 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require 'chef/knife/azurerm_base'
21
- require 'securerandom'
22
- require 'chef/knife/bootstrap/common_bootstrap_options'
23
- require 'chef/knife/bootstrap/bootstrapper'
20
+ require "chef/knife/azurerm_base"
21
+ require "securerandom"
22
+ require "chef/knife/bootstrap/common_bootstrap_options"
23
+ require "chef/knife/bootstrap/bootstrapper"
24
24
 
25
25
  class Chef
26
26
  class Knife
@@ -83,7 +83,7 @@ class Chef
83
83
  Standard_GRS (Standard Geo-redundant storage)
84
84
  Standard_RAGRS (Standard Read access geo-redundant storage)
85
85
  Premium_LRS (Premium Locally-redundant storage)",
86
- :default => 'Standard_GRS'
86
+ :default => "Standard_GRS"
87
87
 
88
88
  option :azure_vm_name,
89
89
  :long => "--azure-vm-name NAME",
@@ -121,7 +121,7 @@ class Chef
121
121
  :long => "--azure-image-reference-version VERSION",
122
122
  :description => "Optional. Specifies the version of the image used to create the virtual machine.
123
123
  Default value is 'latest'",
124
- :default => 'latest'
124
+ :default => "latest"
125
125
 
126
126
  option :azure_image_os_type,
127
127
  :long => "--azure-image-os-type OSTYPE",
@@ -130,8 +130,9 @@ class Chef
130
130
  option :azure_vm_size,
131
131
  :short => "-z SIZE",
132
132
  :long => "--azure-vm-size SIZE",
133
- :description => "Optional. Size of virtual machine (ExtraSmall, Small, Medium, Large, ExtraLarge)",
134
- :default => 'Small',
133
+ :description => "Optional. Size of virtual machine. Default is Standard_A1_v2.
134
+ Eg: Standard_A2, Standard_F2, Standard_G1 etc.",
135
+ :default => "Standard_A1_v2",
135
136
  :proc => Proc.new { |si| Chef::Config[:knife][:azure_vm_size] = si }
136
137
 
137
138
  option :azure_availability_set,
@@ -188,7 +189,7 @@ class Chef
188
189
  Supported values are: vm_name, public_fqdn and platform.
189
190
  User can pass any comma separated combination of these values like 'vm_name,public_fqdn'.
190
191
  Default value is 'default' which corresponds to the supported values list mentioned here.",
191
- :default => 'default'
192
+ :default => "default"
192
193
 
193
194
  def run
194
195
  $stdout.sync = true
@@ -241,12 +242,12 @@ class Chef
241
242
 
242
243
  # We assign azure_vm_name to chef_node_name If node name is nill because storage account name is combination of hash value and node name.
243
244
  config[:chef_node_name] ||= locate_config_value(:azure_vm_name)
244
-
245
+
245
246
  server_def[:azure_storage_account] = locate_config_value(:azure_vm_name) if server_def[:azure_storage_account].nil?
246
- server_def[:azure_storage_account] = server_def[:azure_storage_account].gsub(/[!@#$%^&*()_-]/,'')
247
+ server_def[:azure_storage_account] = server_def[:azure_storage_account].gsub(/[!@#$%^&*()_-]/, "")
247
248
 
248
249
  server_def[:azure_os_disk_name] = locate_config_value(:azure_vm_name) if server_def[:azure_os_disk_name].nil?
249
- server_def[:azure_os_disk_name] = server_def[:azure_os_disk_name].gsub(/[!@#$%^&*()_-]/,'')
250
+ server_def[:azure_os_disk_name] = server_def[:azure_os_disk_name].gsub(/[!@#$%^&*()_-]/, "")
250
251
 
251
252
  server_def[:azure_vnet_name] = locate_config_value(:azure_vm_name) if server_def[:azure_vnet_name].nil?
252
253
  server_def[:azure_vnet_subnet_name] = locate_config_value(:azure_vm_name) if locate_config_value(:azure_vnet_subnet_name).nil?
@@ -274,16 +275,16 @@ class Chef
274
275
  end
275
276
 
276
277
  def supported_ohai_hints
277
- [
278
- 'vm_name',
279
- 'public_fqdn',
280
- 'platform'
281
- ]
278
+ %w{
279
+ vm_name
280
+ public_fqdn
281
+ platform
282
+ }
282
283
  end
283
284
 
284
285
  def format_ohai_hints(ohai_hints)
285
- ohai_hints = ohai_hints.split(',').each { |hint| hint.strip! }
286
- ohai_hints.join(',')
286
+ ohai_hints = ohai_hints.split(",").each { |hint| hint.strip! }
287
+ ohai_hints.join(",")
287
288
  end
288
289
 
289
290
  def is_supported_ohai_hint?(hint)
@@ -291,7 +292,7 @@ class Chef
291
292
  end
292
293
 
293
294
  def validate_ohai_hints
294
- hint_values = locate_config_value(:ohai_hints).split(',')
295
+ hint_values = locate_config_value(:ohai_hints).split(",")
295
296
  hint_values.each do |hint|
296
297
  if ! is_supported_ohai_hint?(hint)
297
298
  raise ArgumentError, "Ohai Hint name #{hint} passed is not supported. Please run the command help to see the list of supported values."
@@ -332,7 +333,7 @@ class Chef
332
333
  when "windows"
333
334
  set_os_image("MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter")
334
335
  else
335
- raise ArgumentError, 'Invalid value of --azure-image-os-type. Accepted values ubuntu|centos|windows'
336
+ raise ArgumentError, "Invalid value of --azure-image-os-type. Accepted values ubuntu|centos|windows"
336
337
  end
337
338
  else
338
339
  validate_arm_keys!(:azure_image_os_type) unless is_image_os_type?
@@ -360,7 +361,7 @@ class Chef
360
361
  end
361
362
 
362
363
  def validate_publisher_and_offer
363
- if (locate_config_value(:azure_image_reference_publisher) || locate_config_value(:azure_image_reference_offer))
364
+ if locate_config_value(:azure_image_reference_publisher) || locate_config_value(:azure_image_reference_offer)
364
365
  # if azure_image_os_type is given and any of the other image reference parameters like publisher or offer are also given,
365
366
  # raise error
366
367
  raise ArgumentError, 'Please specify either --azure-image-os-type OR --azure-image-os-type with --azure-image-reference-sku or 4 image reference parameters i.e.