knife-vrealize 6.0.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/knife/cloud/vra_service.rb +27 -24
- data/lib/chef/knife/vra_catalog_list.rb +6 -3
- data/lib/chef/knife/vra_server_create.rb +25 -36
- data/lib/chef/knife/vra_server_delete.rb +1 -1
- data/lib/chef/knife/vra_server_list.rb +5 -4
- data/lib/chef/knife/vra_server_show.rb +3 -3
- data/lib/knife-vrealize/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82a3ba6a329237518849cf8dd289a8bb419a44a0625bd4cb2749fc5703b96cac
|
4
|
+
data.tar.gz: '0835ab33c89a8c15910ad3a413cd32e6fe561a052fb4dc6591005290a6f71577'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb42ddad92fa6beb58a3f8147bc7c0d10e6f85cbbdc42ccb88cb365252aa4a16fed10233c895ee5b6e01a195df5c08efc3b2b84c043c2558f9a53fd03cf4f2e0
|
7
|
+
data.tar.gz: b2a456df3b78bf29156eaab3d35b09a9286c7624c24de77dd580e9f5870025ac787ead37ac296ff05527a4fccb7b528c8619078c9557557d6073f899176f13ad
|
@@ -54,11 +54,11 @@ class Chef
|
|
54
54
|
def create_server(options = {})
|
55
55
|
submitted_request = catalog_request(options).submit
|
56
56
|
ui.msg("Catalog request #{submitted_request.id} submitted.")
|
57
|
-
wait_for_request(submitted_request, options[:wait_time].to_i, options[:refresh_rate])
|
57
|
+
wait_for_request(submitted_request, (options[:wait_time] || 600).to_i, options[:refresh_rate] || 2)
|
58
58
|
ui.msg("Catalog request complete.\n")
|
59
59
|
request_summary(submitted_request)
|
60
60
|
|
61
|
-
raise CloudExceptions::ServerCreateError
|
61
|
+
raise CloudExceptions::ServerCreateError if submitted_request.failed?
|
62
62
|
|
63
63
|
servers = submitted_request.resources.select(&:vm?)
|
64
64
|
raise CloudExceptions::ServerCreateError, "The vRA request created more than one server, but we were only expecting 1" if servers.length > 1
|
@@ -67,8 +67,9 @@ class Chef
|
|
67
67
|
servers.first
|
68
68
|
end
|
69
69
|
|
70
|
-
def delete_server(
|
71
|
-
|
70
|
+
def delete_server(deployment_id)
|
71
|
+
deployment = get_deployment(deployment_id)
|
72
|
+
server = deployment.resources.select(&:vm?).first
|
72
73
|
server_summary(server)
|
73
74
|
ui.msg("")
|
74
75
|
|
@@ -79,7 +80,7 @@ class Chef
|
|
79
80
|
|
80
81
|
ui.confirm("Do you really want to delete this server")
|
81
82
|
|
82
|
-
destroy_request =
|
83
|
+
destroy_request = deployment.destroy
|
83
84
|
ui.msg("Destroy request #{destroy_request.id} submitted.")
|
84
85
|
wait_for_request(destroy_request)
|
85
86
|
ui.msg("Destroy request complete.")
|
@@ -87,48 +88,50 @@ class Chef
|
|
87
88
|
end
|
88
89
|
|
89
90
|
def list_servers
|
90
|
-
connection.
|
91
|
+
connection.deployments.all
|
91
92
|
end
|
92
93
|
|
93
|
-
def list_catalog_items(entitled)
|
94
|
+
def list_catalog_items(project_id, entitled)
|
94
95
|
if entitled
|
95
|
-
connection.catalog.entitled_items
|
96
|
+
connection.catalog.entitled_items(project_id)
|
96
97
|
else
|
97
98
|
connection.catalog.all_items
|
98
99
|
end
|
99
100
|
end
|
100
101
|
|
101
|
-
def
|
102
|
-
connection.
|
102
|
+
def get_deployment(deployment_id)
|
103
|
+
connection.deployments.by_id(deployment_id)
|
104
|
+
end
|
105
|
+
|
106
|
+
def get_server(deployment_id)
|
107
|
+
deployment = connection.deployments.by_id(deployment_id)
|
108
|
+
deployment.resources.select(&:vm?).first
|
103
109
|
end
|
104
110
|
|
105
111
|
def server_summary(server, _columns_with_info = nil)
|
106
|
-
|
107
|
-
msg_pair("
|
108
|
-
msg_pair("
|
112
|
+
deployment = connection.deployments.by_id(server.deployment_id)
|
113
|
+
msg_pair("Deployment ID", deployment.id)
|
114
|
+
msg_pair("Deployment Name", deployment.name)
|
115
|
+
msg_pair("IP Address", server.ip_address.nil? ? "none" : server.ip_address)
|
109
116
|
msg_pair("Status", server.status)
|
110
|
-
msg_pair("
|
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(", "))
|
117
|
+
msg_pair("Owner Names", server.owner_names.empty? ? "none" : server.owner_names)
|
113
118
|
end
|
114
119
|
|
115
120
|
def request_summary(request)
|
116
121
|
ui.msg("")
|
117
122
|
msg_pair("Request Status", request.status)
|
118
|
-
msg_pair("Completion State", request.completion_state)
|
119
|
-
msg_pair("Completion Details", request.completion_details)
|
120
123
|
ui.msg("")
|
121
124
|
end
|
122
125
|
|
123
126
|
def catalog_request(options)
|
124
127
|
catalog_request = connection.catalog.request(options[:catalog_id])
|
125
128
|
|
126
|
-
catalog_request.
|
127
|
-
catalog_request.
|
128
|
-
catalog_request.
|
129
|
-
catalog_request.
|
130
|
-
catalog_request.
|
131
|
-
|
129
|
+
catalog_request.image_mapping = options[:image_mapping]
|
130
|
+
catalog_request.flavor_mapping = options[:flavor_mapping]
|
131
|
+
catalog_request.name = options[:name]
|
132
|
+
catalog_request.project_id = options[:project_id]
|
133
|
+
catalog_request.version = options[:version] unless options[:version].nil?
|
134
|
+
|
132
135
|
options[:extra_params]&.each do |param|
|
133
136
|
catalog_request.set_parameter(param[:key], param[:type], param[:value])
|
134
137
|
end
|
@@ -36,6 +36,10 @@ class Chef
|
|
36
36
|
include VraServiceHelpers
|
37
37
|
end
|
38
38
|
|
39
|
+
option :project_id,
|
40
|
+
long: "--project-id",
|
41
|
+
description: "Catalogs are retrieved using the Project ID"
|
42
|
+
|
39
43
|
option :entitled,
|
40
44
|
long: "--entitled-only",
|
41
45
|
description: "only list entitled vRA catalog entries",
|
@@ -47,15 +51,14 @@ class Chef
|
|
47
51
|
{ label: "Catalog ID", key: "id" },
|
48
52
|
{ label: "Name", key: "name" },
|
49
53
|
{ label: "Description", key: "description" },
|
50
|
-
{ label: "
|
51
|
-
{ label: "Subtenant", key: "subtenant_name" },
|
54
|
+
{ label: "Source", key: "source_name" },
|
52
55
|
]
|
53
56
|
|
54
57
|
@sort_by_field = "name"
|
55
58
|
end
|
56
59
|
|
57
60
|
def query_resource
|
58
|
-
@service.list_catalog_items(config[:entitled])
|
61
|
+
@service.list_catalog_items(config[:project_id], config[:entitled])
|
59
62
|
end
|
60
63
|
|
61
64
|
def format_status_value(status)
|
@@ -22,54 +22,46 @@ require "chef/knife"
|
|
22
22
|
require "chef/knife/cloud/server/create_command"
|
23
23
|
require "chef/knife/cloud/server/create_options"
|
24
24
|
require_relative "cloud/vra_service_options"
|
25
|
+
require_relative "cloud/vra_service_helpers"
|
25
26
|
|
26
27
|
class Chef
|
27
28
|
class Knife
|
28
29
|
class Cloud
|
29
30
|
class VraServerCreate < ServerCreateCommand
|
30
|
-
include VraServiceHelpers
|
31
31
|
include VraServiceOptions
|
32
32
|
include ServerCreateOptions
|
33
|
+
include VraServiceHelpers
|
33
34
|
|
34
35
|
banner "knife vra server create CATALOG_ID (options)"
|
35
36
|
|
36
37
|
deps do
|
37
38
|
require_relative "cloud/vra_service"
|
38
|
-
require_relative "cloud/vra_service_helpers"
|
39
39
|
end
|
40
40
|
|
41
|
-
option :
|
42
|
-
long: "--
|
43
|
-
description: "
|
44
|
-
|
45
|
-
option :node_ssl_verify_mode,
|
46
|
-
long: "--node-ssl-verify-mode [peer|none]",
|
47
|
-
description: "Whether or not to verify the SSL cert for all HTTPS requests when bootstrapping"
|
48
|
-
option :memory,
|
49
|
-
long: "--memory RAM_IN_MB",
|
50
|
-
description: "Amount of RAM, in MB, the server should have"
|
41
|
+
option :project_id,
|
42
|
+
long: "--project-id PROJECT_ID",
|
43
|
+
description: "ID of the project"
|
51
44
|
|
52
|
-
option :
|
53
|
-
long: "--
|
54
|
-
description: "
|
45
|
+
option :image_mapping,
|
46
|
+
long: "--image-mapping IMAGE_MAPPING",
|
47
|
+
description: "Specifies the OS image for the new VM"
|
55
48
|
|
56
49
|
option :server_create_timeout,
|
57
50
|
long: "--server-create-timeout SECONDS",
|
58
51
|
description: "number of seconds to wait for the server to complete",
|
59
52
|
default: 600
|
60
53
|
|
61
|
-
option :
|
62
|
-
long: "--
|
63
|
-
description:
|
64
|
-
"Will default to the blueprint subtenant if it exists."
|
54
|
+
option :flavor_mapping,
|
55
|
+
long: "--flavor-mapping FLAVOR_MAPPING",
|
56
|
+
description: "Specifies the CPU count and RAM for the new VM"
|
65
57
|
|
66
|
-
option :
|
67
|
-
long: "--
|
68
|
-
description: "
|
58
|
+
option :version,
|
59
|
+
long: "--version VERSION",
|
60
|
+
description: "Specifies the version of the catalog to be used. By default the latest version will be used."
|
69
61
|
|
70
|
-
option :
|
71
|
-
long: "--
|
72
|
-
description: "
|
62
|
+
option :name,
|
63
|
+
long: "--name NAME",
|
64
|
+
description: "Name for the newly created deployment"
|
73
65
|
|
74
66
|
option :extra_params,
|
75
67
|
long: "--extra-param KEY=TYPE:VALUE",
|
@@ -90,7 +82,7 @@ class Chef
|
|
90
82
|
exit 1
|
91
83
|
end
|
92
84
|
|
93
|
-
check_for_missing_config_values!(:
|
85
|
+
check_for_missing_config_values!(:name, :flavor_mapping, :image_mapping, :project_id)
|
94
86
|
|
95
87
|
validate_extra_params!
|
96
88
|
end
|
@@ -100,22 +92,19 @@ class Chef
|
|
100
92
|
|
101
93
|
@create_options = {
|
102
94
|
catalog_id: @name_args.first,
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
notes: config[:notes],
|
95
|
+
project_id: config[:project_id],
|
96
|
+
image_mapping: config[:image_mapping],
|
97
|
+
flavor_mapping: config[:flavor_mapping],
|
98
|
+
version: config[:version],
|
99
|
+
name: config[:name],
|
109
100
|
extra_params: extra_params,
|
110
|
-
wait_time: config[:server_create_timeout],
|
111
|
-
refresh_rate: config[:request_refresh_rate],
|
112
101
|
}
|
113
102
|
end
|
114
103
|
|
115
104
|
def before_bootstrap
|
116
105
|
super
|
117
106
|
|
118
|
-
config[:chef_node_name]
|
107
|
+
config[:chef_node_name] ||= server.name
|
119
108
|
config[:bootstrap_ip_address] = hostname_for_server
|
120
109
|
end
|
121
110
|
|
@@ -139,7 +128,7 @@ class Chef
|
|
139
128
|
end
|
140
129
|
|
141
130
|
def hostname_for_server
|
142
|
-
ip_address = server.
|
131
|
+
ip_address = server.ip_address
|
143
132
|
|
144
133
|
ip_address.nil? ? server.name : ip_address
|
145
134
|
end
|
@@ -30,7 +30,7 @@ class Chef
|
|
30
30
|
include ServerDeleteOptions
|
31
31
|
include VraServiceOptions
|
32
32
|
|
33
|
-
banner "knife vra server delete
|
33
|
+
banner "knife vra server delete DEPLOYMENT_ID [DEPLOYMENT_ID] (options)"
|
34
34
|
|
35
35
|
deps do
|
36
36
|
require_relative "cloud/vra_service"
|
@@ -39,10 +39,11 @@ class Chef
|
|
39
39
|
|
40
40
|
def before_exec_command
|
41
41
|
@columns_with_info = [
|
42
|
-
{ label: "
|
43
|
-
{ label: "Name",
|
44
|
-
{ label: "Status",
|
45
|
-
{ label: "
|
42
|
+
{ label: "Deployment ID", key: "id" },
|
43
|
+
{ label: "Name", key: "name" },
|
44
|
+
{ label: "Status", key: "status", value_callback: method(:format_status_value) },
|
45
|
+
{ label: "Owner", key: "owner" },
|
46
|
+
{ label: "Description", key: "description" },
|
46
47
|
]
|
47
48
|
|
48
49
|
@sort_by_field = "name"
|
@@ -30,7 +30,7 @@ class Chef
|
|
30
30
|
include ServerShowOptions
|
31
31
|
include VraServiceOptions
|
32
32
|
|
33
|
-
banner "knife vra server show
|
33
|
+
banner "knife vra server show DEPLOYMENT_ID (options)"
|
34
34
|
|
35
35
|
deps do
|
36
36
|
require_relative "cloud/vra_service"
|
@@ -40,12 +40,12 @@ class Chef
|
|
40
40
|
|
41
41
|
def validate_params!
|
42
42
|
if @name_args.empty?
|
43
|
-
ui.error("You must supply a
|
43
|
+
ui.error("You must supply a Deployment ID for a server to display.")
|
44
44
|
exit 1
|
45
45
|
end
|
46
46
|
|
47
47
|
if @name_args.size > 1
|
48
|
-
ui.error("You may only supply one
|
48
|
+
ui.error("You may only supply one Deployment ID.")
|
49
49
|
exit 1
|
50
50
|
end
|
51
51
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-vrealize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: knife
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: knife-cloud
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -36,14 +50,14 @@ dependencies:
|
|
36
50
|
requirements:
|
37
51
|
- - "~>"
|
38
52
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
53
|
+
version: '3'
|
40
54
|
type: :runtime
|
41
55
|
prerelease: false
|
42
56
|
version_requirements: !ruby/object:Gem::Requirement
|
43
57
|
requirements:
|
44
58
|
- - "~>"
|
45
59
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
60
|
+
version: '3'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: vcoworkflows
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,14 +116,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
116
|
requirements:
|
103
117
|
- - ">="
|
104
118
|
- !ruby/object:Gem::Version
|
105
|
-
version: '2.
|
119
|
+
version: '2.7'
|
106
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
126
|
+
rubygems_version: 3.1.4
|
113
127
|
signing_key:
|
114
128
|
specification_version: 4
|
115
129
|
summary: Chef Infra Knife plugin to interact with VMware vRealize.
|