knife-vrealize 2.1.1 → 5.0.2

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