knife-vrealize 2.1.1 → 5.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/{LICENSE.txt → LICENSE} +0 -0
- data/lib/chef/knife/cloud/vra_service.rb +28 -29
- data/lib/chef/knife/cloud/vra_service_helpers.rb +9 -8
- data/lib/chef/knife/cloud/vra_service_options.rb +17 -16
- data/lib/chef/knife/vra_catalog_list.rb +19 -18
- data/lib/chef/knife/vra_server_create.rb +49 -48
- data/lib/chef/knife/vra_server_delete.rb +10 -9
- data/lib/chef/knife/vra_server_list.rb +16 -15
- data/lib/chef/knife/vra_server_show.rb +11 -10
- data/lib/chef/knife/vro_workflow_execute.rb +28 -27
- data/lib/knife-vrealize/version.rb +3 -2
- metadata +20 -114
- data/.github/ISSUE_TEMPLATE.md +0 -23
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -14
- data/.gitignore +0 -17
- data/.rubocop.yml +0 -18
- data/.travis.yml +0 -23
- data/CHANGELOG.md +0 -111
- data/Gemfile +0 -3
- data/Jenkinsfile +0 -28
- data/README.md +0 -217
- data/Rakefile +0 -21
- data/knife-vrealize.gemspec +0 -33
- data/spec/spec_helper.rb +0 -18
- data/spec/unit/cloud/vra_service_helpers_spec.rb +0 -153
- data/spec/unit/cloud/vra_service_spec.rb +0 -251
- data/spec/unit/vra_catalog_list_spec.rb +0 -44
- data/spec/unit/vra_server_create_spec.rb +0 -171
- data/spec/unit/vra_server_delete_spec.rb +0 -64
- data/spec/unit/vra_server_list_spec.rb +0 -51
- data/spec/unit/vra_server_show_spec.rb +0 -44
- data/spec/unit/vro_workflow_execute_spec.rb +0 -366
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fc3c96c272f00e8d5bc3922de2db7b6ae0955d9cb7520c18e8ab64c882ea3312
|
4
|
+
data.tar.gz: 7f74f3e6e96c360d807358fc4b3ecc29cea6d4b3758e9d2c3b752f44edad114b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05aee0b54656edde368d422c94957a8266e5d88170fbb033669b15a3a47f2b91dd4bf0961180e6565f5c3c8f0db52c3e5ec5b9be8b4220812b4c16397376806f
|
7
|
+
data.tar.gz: e5e1f2fcec20fb0af51ccac43d9923868220fdbdf748092c009b2a568d1a4cb302ae57f416564b81cf8e9a0180303dc4f5ab1d5f4b8aa762ba20cb791fda0180
|
data/{LICENSE.txt → LICENSE}
RENAMED
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::
|
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
|
21
|
-
require
|
22
|
-
require
|
23
|
-
|
24
|
-
require
|
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,
|
64
|
-
raise CloudExceptions::ServerCreateError,
|
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 ==
|
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(
|
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(
|
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(
|
106
|
-
msg_pair(
|
107
|
-
msg_pair(
|
108
|
-
msg_pair(
|
109
|
-
msg_pair(
|
110
|
-
msg_pair(
|
111
|
-
msg_pair(
|
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(
|
117
|
-
msg_pair(
|
118
|
-
msg_pair(
|
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::
|
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
|
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
|
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::
|
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:
|
30
|
-
description:
|
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:
|
35
|
-
description:
|
35
|
+
long: "--vra-username USERNAME",
|
36
|
+
description: "Username to use with the vRA API"
|
36
37
|
|
37
38
|
option :vra_password,
|
38
|
-
long:
|
39
|
-
description:
|
39
|
+
long: "--vra-password PASSWORD",
|
40
|
+
description: "Password to use with the vRA API"
|
40
41
|
|
41
42
|
option :vra_tenant,
|
42
|
-
long:
|
43
|
-
description:
|
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:
|
47
|
-
description:
|
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:
|
53
|
-
description:
|
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:
|
59
|
-
description:
|
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::
|
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
|
21
|
-
require
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
34
|
+
banner "knife vra catalog list"
|
34
35
|
|
35
36
|
option :entitled,
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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:
|
44
|
-
{ label:
|
45
|
-
{ label:
|
46
|
-
{ label:
|
47
|
-
{ label:
|
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 =
|
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 ==
|
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::
|
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
|
21
|
-
require
|
22
|
-
require
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
36
|
+
banner "knife vra server create CATALOG_ID (options)"
|
36
37
|
|
37
38
|
option :cpus,
|
38
|
-
|
39
|
-
|
39
|
+
long: "--cpus NUM_CPUS",
|
40
|
+
description: "Number of CPUs the server should have"
|
40
41
|
|
41
42
|
option :node_ssl_verify_mode,
|
42
|
-
|
43
|
-
|
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
|
-
|
46
|
-
|
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
|
-
|
50
|
-
|
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
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
64
|
-
|
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
|
-
|
68
|
-
|
68
|
+
long: "--notes NOTES",
|
69
|
+
description: "String of text to be included in the request notes."
|
69
70
|
|
70
71
|
option :extra_params,
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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(
|
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:
|
99
|
-
cpus:
|
100
|
-
memory:
|
101
|
-
requested_for:
|
102
|
-
subtenant_id:
|
103
|
-
lease_days:
|
104
|
-
notes:
|
105
|
-
extra_params:
|
106
|
-
wait_time:
|
107
|
-
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] ==
|
134
|
+
param[:type] == "string" || param[:type] == "integer"
|
134
135
|
end
|
135
136
|
end
|
136
137
|
|