knife-vrealize 3.0.0 → 4.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 267c713a407cd2265caf2e14a8fe31cfd9b5014e
4
- data.tar.gz: b84bf831de2c95d2c302ff5bd1fcadf6ad8aafa1
2
+ SHA256:
3
+ metadata.gz: fc49e40f8108c889eeefee0e36abd650d75360e0d684428dc73fbe0f5343bdb7
4
+ data.tar.gz: 804f29de229fb86018eec056a4823ce7467acc6c926213555f21c0a31594dc96
5
5
  SHA512:
6
- metadata.gz: 2b50faa246e6875d2f9d25b3612236943a316c759e5dc65adb6a78fc260eab8347d0ed44a334b719982ef51fbaf9600afa954aa401f10c4a9df64681f552a19c
7
- data.tar.gz: 0b83282bc5280d5d7e79d0bf8424d12b0ee9270c683da89937385c94f85261a9d301cbf10e156c6ecd7f702f03a2488a456b44bb6d28fbb9f4b235ec8f11fb85
6
+ metadata.gz: 7e049bf4c9c8bf7ebcba24120ed1af301cdd768950254f7df570190ea1e39427067ebabe7c1ec848f59f5801eef44d8c5d2f577539ffacd65a98d4490ec21bfa
7
+ data.tar.gz: a0a23e3c51faa889ae4198cc4f5631425f73cb6a33caa8095a2ed52b59dd025bb1732466d2906595f72cdcaad80b98f031c5e5ac0f94eceb0084ba945fc553fb
File without changes
@@ -2,7 +2,7 @@
2
2
 
3
3
  #
4
4
  # Author:: Chef Partner Engineering (<partnereng@chef.io>)
5
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
5
+ # Copyright:: 2015-2019, 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,18 +18,18 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- require 'chef/knife/cloud/exceptions'
22
- require 'chef/knife/cloud/service'
23
- require 'chef/knife/cloud/helpers'
24
- require 'chef/knife/cloud/vra_service_helpers'
25
- require 'vra'
21
+ require "chef/knife/cloud/exceptions"
22
+ require "chef/knife/cloud/service"
23
+ require "chef/knife/cloud/helpers"
24
+ require "chef/knife/cloud/vra_service_helpers"
25
+ require "vra"
26
26
 
27
27
  class Chef
28
28
  class Knife
29
29
  class Cloud
30
30
  class VraService < Service
31
31
  include VraServiceHelpers
32
- def initialize(options={})
32
+ def initialize(options = {})
33
33
  super(options)
34
34
 
35
35
  @username = options[:username]
@@ -51,7 +51,7 @@ class Chef
51
51
  )
52
52
  end
53
53
 
54
- def create_server(options={})
54
+ def create_server(options = {})
55
55
  submitted_request = catalog_request(options).submit
56
56
  ui.msg("Catalog request #{submitted_request.id} submitted.")
57
57
  wait_for_request(submitted_request, options[:wait_time].to_i, options[:refresh_rate])
@@ -61,8 +61,8 @@ class Chef
61
61
  raise CloudExceptions::ServerCreateError, submitted_request.completion_details if submitted_request.failed?
62
62
 
63
63
  servers = submitted_request.resources.select(&:vm?)
64
- raise CloudExceptions::ServerCreateError, 'The vRA request created more than one server, but we were only expecting 1' if servers.length > 1
65
- raise CloudExceptions::ServerCreateError, 'The vRA request did not create any servers' if servers.length.zero?
64
+ raise CloudExceptions::ServerCreateError, "The vRA request created more than one server, but we were only expecting 1" if servers.length > 1
65
+ raise CloudExceptions::ServerCreateError, "The vRA request did not create any servers" if servers.length == 0
66
66
 
67
67
  servers.first
68
68
  end
@@ -70,19 +70,19 @@ class Chef
70
70
  def delete_server(instance_id)
71
71
  server = get_server(instance_id)
72
72
  server_summary(server)
73
- ui.msg('')
73
+ ui.msg("")
74
74
 
75
- if server.status == 'DELETED'
75
+ if server.status == "DELETED"
76
76
  ui.warn("Server is already deleted.\n")
77
77
  return
78
78
  end
79
79
 
80
- ui.confirm('Do you really want to delete this server')
80
+ ui.confirm("Do you really want to delete this server")
81
81
 
82
82
  destroy_request = server.destroy
83
83
  ui.msg("Destroy request #{destroy_request.id} submitted.")
84
84
  wait_for_request(destroy_request)
85
- ui.msg('Destroy request complete.')
85
+ ui.msg("Destroy request complete.")
86
86
  request_summary(destroy_request)
87
87
  end
88
88
 
@@ -102,22 +102,22 @@ class Chef
102
102
  connection.resources.by_id(instance_id)
103
103
  end
104
104
 
105
- def server_summary(server, _columns_with_info=nil)
106
- msg_pair('Server ID', server.id)
107
- msg_pair('Server Name', server.name)
108
- msg_pair('IP Addresses', server.ip_addresses.nil? ? 'none' : server.ip_addresses.join(', '))
109
- msg_pair('Status', server.status)
110
- msg_pair('Catalog Name', server.catalog_name)
111
- msg_pair('Owner IDs', server.owner_ids.empty? ? 'none' : server.owner_ids.join(', '))
112
- msg_pair('Owner Names', server.owner_names.empty? ? 'none' : server.owner_names.join(', '))
105
+ def server_summary(server, _columns_with_info = nil)
106
+ msg_pair("Server ID", server.id)
107
+ msg_pair("Server Name", server.name)
108
+ msg_pair("IP Addresses", server.ip_addresses.nil? ? "none" : server.ip_addresses.join(", "))
109
+ msg_pair("Status", server.status)
110
+ msg_pair("Catalog Name", server.catalog_name)
111
+ msg_pair("Owner IDs", server.owner_ids.empty? ? "none" : server.owner_ids.join(", "))
112
+ msg_pair("Owner Names", server.owner_names.empty? ? "none" : server.owner_names.join(", "))
113
113
  end
114
114
 
115
115
  def request_summary(request)
116
- ui.msg('')
117
- msg_pair('Request Status', request.status)
118
- msg_pair('Completion State', request.completion_state)
119
- msg_pair('Completion Details', request.completion_details)
120
- ui.msg('')
116
+ ui.msg("")
117
+ msg_pair("Request Status", request.status)
118
+ msg_pair("Completion State", request.completion_state)
119
+ msg_pair("Completion Details", request.completion_details)
120
+ ui.msg("")
121
121
  end
122
122
 
123
123
  def catalog_request(options)
@@ -2,7 +2,7 @@
2
2
 
3
3
  #
4
4
  # Author:: Chef Partner Engineering (<partnereng@chef.io>)
5
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
5
+ # Copyright:: 2015-2019, 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 'chef/knife/cloud/helpers'
21
+ require "chef/knife/cloud/helpers"
22
22
 
23
23
  class Chef
24
24
  class Knife
@@ -39,10 +39,10 @@ class Chef
39
39
  !locate_config_value(:vra_disable_ssl_verify)
40
40
  end
41
41
 
42
- def wait_for_request(request, wait_time=600, refresh_rate=2)
43
- print 'Waiting for request to complete.'
42
+ def wait_for_request(request, wait_time = 600, refresh_rate = 2)
43
+ print "Waiting for request to complete."
44
44
 
45
- last_status = ''
45
+ last_status = ""
46
46
 
47
47
  begin
48
48
  Timeout.timeout(wait_time) do
@@ -55,7 +55,7 @@ class Chef
55
55
  end
56
56
 
57
57
  if last_status == request.status
58
- print '.'
58
+ print "."
59
59
  else
60
60
  last_status = request.status
61
61
  print "\n"
@@ -66,7 +66,7 @@ class Chef
66
66
  end
67
67
  end
68
68
  rescue Timeout::Error
69
- ui.msg('')
69
+ ui.msg("")
70
70
  ui.error("Request did not complete in #{wait_time} seconds. Check the Requests tab in the vRA UI for more information.")
71
71
  exit 1
72
72
  end
@@ -81,7 +81,7 @@ class Chef
81
81
  missing = keys.select { |x| locate_config_value(x).nil? }
82
82
 
83
83
  unless missing.empty?
84
- ui.error("The following required parameters are missing: #{missing.join(', ')}")
84
+ ui.error("The following required parameters are missing: #{missing.join(", ")}")
85
85
  exit(1)
86
86
  end
87
87
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  #
4
4
  # Author:: Chef Partner Engineering (<partnereng@chef.io>)
5
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
5
+ # Copyright:: 2015-2019, 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");
@@ -27,37 +27,37 @@ class Chef
27
27
  def self.included(includer)
28
28
  includer.class_eval do
29
29
  option :vra_base_url,
30
- long: '--vra-base-url API_URL',
31
- description: 'URL for the vRA server',
32
- proc: proc { |url| url.sub(%r{/(\/)+$/}, '') }
30
+ long: "--vra-base-url API_URL",
31
+ description: "URL for the vRA server",
32
+ proc: proc { |url| url.sub(%r{/(\/)+$/}, "") }
33
33
 
34
34
  option :vra_username,
35
- long: '--vra-username USERNAME',
36
- description: 'Username to use with the vRA API'
35
+ long: "--vra-username USERNAME",
36
+ description: "Username to use with the vRA API"
37
37
 
38
38
  option :vra_password,
39
- long: '--vra-password PASSWORD',
40
- description: 'Password to use with the vRA API'
39
+ long: "--vra-password PASSWORD",
40
+ description: "Password to use with the vRA API"
41
41
 
42
42
  option :vra_tenant,
43
- long: '--vra-tenant TENANT',
44
- description: 'Tenant name (organization) to use with the vRA API'
43
+ long: "--vra-tenant TENANT",
44
+ description: "Tenant name (organization) to use with the vRA API"
45
45
 
46
46
  option :vra_disable_ssl_verify,
47
- long: '--vra-disable-ssl-verify',
48
- description: 'Skip any SSL verification for the vRA API',
47
+ long: "--vra-disable-ssl-verify",
48
+ description: "Skip any SSL verification for the vRA API",
49
49
  boolean: true,
50
50
  default: false
51
51
 
52
52
  option :vra_page_size,
53
- long: '--page-size NUM_OF_ITEMS',
54
- description: 'Maximum number of items to fetch from the vRA API when pagination is forced',
53
+ long: "--page-size NUM_OF_ITEMS",
54
+ description: "Maximum number of items to fetch from the vRA API when pagination is forced",
55
55
  default: 200,
56
56
  proc: proc { |page_size| page_size.to_i }
57
57
 
58
58
  option :request_refresh_rate,
59
- long: '--request-refresh-rate SECS',
60
- description: 'Number of seconds to sleep between each check of the request status, defaults to 2',
59
+ long: "--request-refresh-rate SECS",
60
+ description: "Number of seconds to sleep between each check of the request status, defaults to 2",
61
61
  default: 2,
62
62
  proc: proc { |secs| secs.to_i }
63
63
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  #
4
4
  # Author:: Chef Partner Engineering (<partnereng@chef.io>)
5
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
5
+ # Copyright:: 2015-2019, 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,11 +18,11 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- require 'chef/knife'
22
- require 'chef/knife/cloud/list_resource_command'
23
- require 'chef/knife/cloud/vra_service'
24
- require 'chef/knife/cloud/vra_service_helpers'
25
- require 'chef/knife/cloud/vra_service_options'
21
+ require "chef/knife"
22
+ require "chef/knife/cloud/list_resource_command"
23
+ require "chef/knife/cloud/vra_service"
24
+ require "chef/knife/cloud/vra_service_helpers"
25
+ require "chef/knife/cloud/vra_service_options"
26
26
 
27
27
  class Chef
28
28
  class Knife
@@ -31,24 +31,24 @@ class Chef
31
31
  include VraServiceHelpers
32
32
  include VraServiceOptions
33
33
 
34
- banner 'knife vra catalog list'
34
+ banner "knife vra catalog list"
35
35
 
36
36
  option :entitled,
37
- long: '--entitled-only',
38
- description: 'only list entitled vRA catalog entries',
39
- boolean: true,
40
- default: false
37
+ long: "--entitled-only",
38
+ description: "only list entitled vRA catalog entries",
39
+ boolean: true,
40
+ default: false
41
41
 
42
42
  def before_exec_command
43
43
  @columns_with_info = [
44
- { label: 'Catalog ID', key: 'id' },
45
- { label: 'Name', key: 'name' },
46
- { label: 'Description', key: 'description' },
47
- { label: 'Status', key: 'status', value_callback: method(:format_status_value) },
48
- { label: 'Subtenant', key: 'subtenant_name' }
44
+ { label: "Catalog ID", key: "id" },
45
+ { label: "Name", key: "name" },
46
+ { label: "Description", key: "description" },
47
+ { label: "Status", key: "status", value_callback: method(:format_status_value) },
48
+ { label: "Subtenant", key: "subtenant_name" },
49
49
  ]
50
50
 
51
- @sort_by_field = 'name'
51
+ @sort_by_field = "name"
52
52
  end
53
53
 
54
54
  def query_resource
@@ -57,7 +57,7 @@ class Chef
57
57
 
58
58
  def format_status_value(status)
59
59
  status = status.downcase
60
- color = if status == 'published'
60
+ color = if status == "published"
61
61
  :green
62
62
  else
63
63
  :red
@@ -2,7 +2,7 @@
2
2
 
3
3
  #
4
4
  # Author:: Chef Partner Engineering (<partnereng@chef.io>)
5
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
5
+ # Copyright:: 2015-2019, 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,12 +18,12 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- require 'chef/knife'
22
- require 'chef/knife/cloud/server/create_command'
23
- require 'chef/knife/cloud/server/create_options'
24
- require 'chef/knife/cloud/vra_service'
25
- require 'chef/knife/cloud/vra_service_helpers'
26
- require 'chef/knife/cloud/vra_service_options'
21
+ require "chef/knife"
22
+ require "chef/knife/cloud/server/create_command"
23
+ require "chef/knife/cloud/server/create_options"
24
+ require "chef/knife/cloud/vra_service"
25
+ require "chef/knife/cloud/vra_service_helpers"
26
+ require "chef/knife/cloud/vra_service_options"
27
27
 
28
28
  class Chef
29
29
  class Knife
@@ -33,57 +33,57 @@ class Chef
33
33
  include VraServiceOptions
34
34
  include ServerCreateOptions
35
35
 
36
- banner 'knife vra server create CATALOG_ID (options)'
36
+ banner "knife vra server create CATALOG_ID (options)"
37
37
 
38
38
  option :cpus,
39
- long: '--cpus NUM_CPUS',
40
- description: 'Number of CPUs the server should have'
39
+ long: "--cpus NUM_CPUS",
40
+ description: "Number of CPUs the server should have"
41
41
 
42
42
  option :node_ssl_verify_mode,
43
- long: '--node-ssl-verify-mode [peer|none]',
44
- description: 'Whether or not to verify the SSL cert for all HTTPS requests when bootstrapping'
43
+ long: "--node-ssl-verify-mode [peer|none]",
44
+ description: "Whether or not to verify the SSL cert for all HTTPS requests when bootstrapping"
45
45
  option :memory,
46
- long: '--memory RAM_IN_MB',
47
- description: 'Amount of RAM, in MB, the server should have'
46
+ long: "--memory RAM_IN_MB",
47
+ description: "Amount of RAM, in MB, the server should have"
48
48
 
49
49
  option :requested_for,
50
- long: '--requested-for LOGIN',
51
- description: 'The login to list as the owner of this resource. Will default to the vra_username parameter'
50
+ long: "--requested-for LOGIN",
51
+ description: "The login to list as the owner of this resource. Will default to the vra_username parameter"
52
52
 
53
53
  option :server_create_timeout,
54
- long: '--server-create-timeout SECONDS',
55
- description: 'number of seconds to wait for the server to complete',
56
- default: 600
54
+ long: "--server-create-timeout SECONDS",
55
+ description: "number of seconds to wait for the server to complete",
56
+ default: 600
57
57
 
58
58
  option :subtenant_id,
59
- long: '--subtenant-id ID',
60
- description: 'The subtenant ID (a.k.a "business group") to list as the owner of this resource. ' \
61
- 'Will default to the blueprint subtenant if it exists.'
59
+ long: "--subtenant-id ID",
60
+ description: 'The subtenant ID (a.k.a "business group") to list as the owner of this resource. ' \
61
+ "Will default to the blueprint subtenant if it exists."
62
62
 
63
63
  option :lease_days,
64
- long: '--lease-days NUM_DAYS',
65
- description: 'Number of days requested for the server lease, provided the blueprint allows this to be specified'
64
+ long: "--lease-days NUM_DAYS",
65
+ description: "Number of days requested for the server lease, provided the blueprint allows this to be specified"
66
66
 
67
67
  option :notes,
68
- long: '--notes NOTES',
69
- description: 'String of text to be included in the request notes.'
68
+ long: "--notes NOTES",
69
+ description: "String of text to be included in the request notes."
70
70
 
71
71
  option :extra_params,
72
- long: '--extra-param KEY=TYPE:VALUE',
73
- description: 'Additional parameters to pass to vRA for this catalog request. TYPE must be "string" or "integer". ' \
74
- 'Can be used multiple times.',
75
- default: {},
76
- proc: proc { |param|
77
- Chef::Config[:knife][:vra_extra_params] ||= {}
78
- key, value_str = param.split('=')
79
- Chef::Config[:knife][:vra_extra_params].merge!(key => value_str)
80
- }
72
+ long: "--extra-param KEY=TYPE:VALUE",
73
+ description: 'Additional parameters to pass to vRA for this catalog request. TYPE must be "string" or "integer". ' \
74
+ "Can be used multiple times.",
75
+ default: {},
76
+ proc: proc { |param|
77
+ Chef::Config[:knife][:vra_extra_params] ||= {}
78
+ key, value_str = param.split("=")
79
+ Chef::Config[:knife][:vra_extra_params].merge!(key => value_str)
80
+ }
81
81
 
82
82
  def validate_params!
83
83
  super
84
84
 
85
85
  if @name_args.empty?
86
- ui.error('You must supply a Catalog ID to use for your new server.')
86
+ ui.error("You must supply a Catalog ID to use for your new server.")
87
87
  exit 1
88
88
  end
89
89
 
@@ -96,16 +96,16 @@ class Chef
96
96
  super
97
97
 
98
98
  @create_options = {
99
- catalog_id: @name_args.first,
100
- cpus: locate_config_value(:cpus),
101
- memory: locate_config_value(:memory),
102
- requested_for: locate_config_value(:requested_for),
103
- subtenant_id: locate_config_value(:subtenant_id),
104
- lease_days: locate_config_value(:lease_days),
105
- notes: locate_config_value(:notes),
106
- extra_params: extra_params,
107
- wait_time: locate_config_value(:server_create_timeout),
108
- refresh_rate: locate_config_value(:request_refresh_rate)
99
+ catalog_id: @name_args.first,
100
+ cpus: locate_config_value(:cpus),
101
+ memory: locate_config_value(:memory),
102
+ requested_for: locate_config_value(:requested_for),
103
+ subtenant_id: locate_config_value(:subtenant_id),
104
+ lease_days: locate_config_value(:lease_days),
105
+ notes: locate_config_value(:notes),
106
+ extra_params: extra_params,
107
+ wait_time: locate_config_value(:server_create_timeout),
108
+ refresh_rate: locate_config_value(:request_refresh_rate),
109
109
  }
110
110
  end
111
111
 
@@ -120,7 +120,7 @@ class Chef
120
120
  return if Chef::Config[:knife][:vra_extra_params].nil? || Chef::Config[:knife][:vra_extra_params].empty?
121
121
 
122
122
  Chef::Config[:knife][:vra_extra_params].each_with_object([]) do |(key, value_str), memo|
123
- type, value = value_str.split(':')
123
+ type, value = value_str.split(":")
124
124
  memo << { key: key, type: type, value: value }
125
125
  end
126
126
  end
@@ -131,7 +131,7 @@ class Chef
131
131
  extra_params.each do |param|
132
132
  raise ArgumentError, "No type and value set for extra parameter #{param[:key]}" if param[:type].nil? || param[:value].nil?
133
133
  raise ArgumentError, "Invalid parameter type for #{param[:key]} - must be string or integer" unless
134
- param[:type] == 'string' || param[:type] == 'integer'
134
+ param[:type] == "string" || param[:type] == "integer"
135
135
  end
136
136
  end
137
137