knife-google 3.3.7 → 4.1.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/google_service.rb +68 -40
- data/lib/chef/knife/cloud/google_service_helpers.rb +3 -3
- data/lib/chef/knife/google_disk_create.rb +1 -0
- data/lib/chef/knife/google_disk_delete.rb +1 -0
- data/lib/chef/knife/google_image_list.rb +59 -0
- data/lib/chef/knife/google_project_quotas.rb +1 -1
- data/lib/chef/knife/google_region_quotas.rb +1 -1
- data/lib/chef/knife/google_server_create.rb +30 -24
- data/lib/chef/knife/google_server_show.rb +1 -0
- data/lib/knife-google/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b39bef9d566a21cb4bcf0a0decb202b5b8905ad548335fd4f8eceea6408208a0
|
4
|
+
data.tar.gz: 4f75ba0bb858215fa19aa8566a18e93fbb6b3a01dfc89b774d1e0d9b03d20ab6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5454224647a87ffda86710c3fa6c494b8e8ff1bb05c773aa888190293ff84c08cf5f2c2ec746763efc9f3853d1e0f691e748d46d23e8cad6154d5ef960858d34
|
7
|
+
data.tar.gz: dedb9b64dde86e7678bd87ece3852a40c6832a83833e779a39339ac89efc51e568d3316264cbdc964679813744f11ebbef1b96b1969910accb378f73c003f862
|
@@ -32,50 +32,64 @@ class Chef::Knife::Cloud
|
|
32
32
|
attr_reader :project, :zone, :wait_time, :refresh_rate, :max_pages, :max_page_size
|
33
33
|
|
34
34
|
SCOPE_ALIAS_MAP = {
|
35
|
-
"bigquery"
|
36
|
-
"cloud-platform"
|
37
|
-
"compute-ro"
|
38
|
-
"compute-rw"
|
39
|
-
"datastore"
|
40
|
-
"logging-write"
|
41
|
-
"monitoring"
|
42
|
-
"monitoring-write"
|
43
|
-
"service-control"
|
35
|
+
"bigquery" => "bigquery",
|
36
|
+
"cloud-platform" => "cloud-platform",
|
37
|
+
"compute-ro" => "compute.readonly",
|
38
|
+
"compute-rw" => "compute",
|
39
|
+
"datastore" => "datastore",
|
40
|
+
"logging-write" => "logging.write",
|
41
|
+
"monitoring" => "monitoring",
|
42
|
+
"monitoring-write" => "monitoring.write",
|
43
|
+
"service-control" => "servicecontrol",
|
44
44
|
"service-management" => "service.management",
|
45
|
-
"sql"
|
46
|
-
"sql-admin"
|
47
|
-
"storage-full"
|
48
|
-
"storage-ro"
|
49
|
-
"storage-rw"
|
50
|
-
"taskqueue"
|
51
|
-
"useraccounts-ro"
|
52
|
-
"useraccounts-rw"
|
53
|
-
"userinfo-email"
|
45
|
+
"sql" => "sqlservice",
|
46
|
+
"sql-admin" => "sqlservice.admin",
|
47
|
+
"storage-full" => "devstorage.full_control",
|
48
|
+
"storage-ro" => "devstorage.read_only",
|
49
|
+
"storage-rw" => "devstorage.read_write",
|
50
|
+
"taskqueue" => "taskqueue",
|
51
|
+
"useraccounts-ro" => "cloud.useraccounts.readonly",
|
52
|
+
"useraccounts-rw" => "cloud.useraccounts",
|
53
|
+
"userinfo-email" => "userinfo.email",
|
54
54
|
}.freeze
|
55
55
|
|
56
56
|
IMAGE_ALIAS_MAP = {
|
57
|
-
"centos-6"
|
58
|
-
"centos-7"
|
59
|
-
"container-vm"
|
60
|
-
"coreos"
|
61
|
-
"debian-7"
|
62
|
-
"debian-7-backports" => { project: "debian-cloud",
|
63
|
-
"debian-8"
|
64
|
-
"opensuse-13"
|
65
|
-
"rhel-6"
|
66
|
-
"rhel-7"
|
67
|
-
"sles-11"
|
68
|
-
"sles-12"
|
69
|
-
"ubuntu-12-04"
|
70
|
-
"ubuntu-1204-lts"
|
71
|
-
"ubuntu-14-04"
|
72
|
-
"ubuntu-1404-lts"
|
73
|
-
"ubuntu-15-04"
|
74
|
-
"ubuntu-15-10"
|
75
|
-
"ubuntu-16-04"
|
76
|
-
"ubuntu-1604-lts"
|
77
|
-
"windows-2008-r2"
|
78
|
-
"windows-2012-r2"
|
57
|
+
"centos-6" => { project: "centos-cloud", prefix: "centos-6" },
|
58
|
+
"centos-7" => { project: "centos-cloud", prefix: "centos-7" },
|
59
|
+
"container-vm" => { project: "google-containers", prefix: "container-vm" },
|
60
|
+
"coreos" => { project: "coreos-cloud", prefix: "coreos-stable" },
|
61
|
+
"debian-7" => { project: "debian-cloud", prefix: "debian-7-wheezy" },
|
62
|
+
"debian-7-backports" => { project: "debian-cloud", prefix: "backports-debian-7-wheezy" },
|
63
|
+
"debian-8" => { project: "debian-cloud", prefix: "debian-8-jessie" },
|
64
|
+
"opensuse-13" => { project: "opensuse-cloud", prefix: "opensuse-13" },
|
65
|
+
"rhel-6" => { project: "rhel-cloud", prefix: "rhel-6" },
|
66
|
+
"rhel-7" => { project: "rhel-cloud", prefix: "rhel-7" },
|
67
|
+
"sles-11" => { project: "suse-cloud", prefix: "sles-11" },
|
68
|
+
"sles-12" => { project: "suse-cloud", prefix: "sles-12" },
|
69
|
+
"ubuntu-12-04" => { project: "ubuntu-os-cloud", prefix: "ubuntu-1204-precise" },
|
70
|
+
"ubuntu-1204-lts" => { project: "ubuntu-os-cloud", prefix: "ubuntu-1204-precise" },
|
71
|
+
"ubuntu-14-04" => { project: "ubuntu-os-cloud", prefix: "ubuntu-1404-trusty" },
|
72
|
+
"ubuntu-1404-lts" => { project: "ubuntu-os-cloud", prefix: "ubuntu-1404-trusty" },
|
73
|
+
"ubuntu-15-04" => { project: "ubuntu-os-cloud", prefix: "ubuntu-1504-vivid" },
|
74
|
+
"ubuntu-15-10" => { project: "ubuntu-os-cloud", prefix: "ubuntu-1510-wily" },
|
75
|
+
"ubuntu-16-04" => { project: "ubuntu-os-cloud", prefix: "ubuntu-1604-xenial" },
|
76
|
+
"ubuntu-1604-lts" => { project: "ubuntu-os-cloud", prefix: "ubuntu-1604-xenial" },
|
77
|
+
"windows-2008-r2" => { project: "windows-cloud", prefix: "windows-server-2008-r2" },
|
78
|
+
"windows-2012-r2" => { project: "windows-cloud", prefix: "windows-server-2012-r2" },
|
79
|
+
}.freeze
|
80
|
+
|
81
|
+
PUBLIC_PROJECTS = %w{
|
82
|
+
centos-cloud
|
83
|
+
coreos-cloud
|
84
|
+
debian-cloud
|
85
|
+
cos-cloud
|
86
|
+
rhel-cloud
|
87
|
+
rhel-sap-cloud
|
88
|
+
suse-cloud
|
89
|
+
suse-sap-cloud
|
90
|
+
ubuntu-os-cloud
|
91
|
+
windows-cloud
|
92
|
+
windows-sql-cloud
|
79
93
|
}.freeze
|
80
94
|
|
81
95
|
def initialize(options = {})
|
@@ -197,6 +211,12 @@ class Chef::Knife::Cloud
|
|
197
211
|
paginated_results(:list_zones, :items, project) || []
|
198
212
|
end
|
199
213
|
|
214
|
+
# Retrieves the list of custom images and public images.
|
215
|
+
# Custom images are images you create that belong to your project.
|
216
|
+
def list_images
|
217
|
+
available_projects.map { |project| paginated_results(:list_images, :items, project) || [] }.flatten
|
218
|
+
end
|
219
|
+
|
200
220
|
def list_disks
|
201
221
|
paginated_results(:list_disks, :items, project, zone) || []
|
202
222
|
end
|
@@ -227,16 +247,19 @@ class Chef::Knife::Cloud
|
|
227
247
|
|
228
248
|
def valid_machine_type?(machine_type)
|
229
249
|
return false if machine_type.nil?
|
250
|
+
|
230
251
|
check_api_call { connection.get_machine_type(project, zone, machine_type) }
|
231
252
|
end
|
232
253
|
|
233
254
|
def valid_network?(network)
|
234
255
|
return false if network.nil?
|
256
|
+
|
235
257
|
check_api_call { connection.get_network(project, network) }
|
236
258
|
end
|
237
259
|
|
238
260
|
def valid_subnet?(subnet)
|
239
261
|
return false if subnet.nil?
|
262
|
+
|
240
263
|
check_api_call { connection.get_subnetwork(project, region, subnet) }
|
241
264
|
end
|
242
265
|
|
@@ -451,6 +474,7 @@ class Chef::Knife::Cloud
|
|
451
474
|
|
452
475
|
def service_account_scope_url(scope)
|
453
476
|
return scope if scope.start_with?("https://www.googleapis.com/auth/")
|
477
|
+
|
454
478
|
"https://www.googleapis.com/auth/#{translate_scope_alias(scope)}"
|
455
479
|
end
|
456
480
|
|
@@ -599,5 +623,9 @@ class Chef::Knife::Cloud
|
|
599
623
|
|
600
624
|
operation.error.errors
|
601
625
|
end
|
626
|
+
|
627
|
+
def available_projects
|
628
|
+
[project] | PUBLIC_PROJECTS
|
629
|
+
end
|
602
630
|
end
|
603
631
|
end
|
@@ -27,8 +27,8 @@ class Chef::Knife::Cloud
|
|
27
27
|
zone: locate_config_value(:gce_zone),
|
28
28
|
wait_time: locate_config_value(:request_timeout),
|
29
29
|
refresh_rate: locate_config_value(:request_refresh_rate),
|
30
|
-
max_pages: locate_config_value(:
|
31
|
-
max_page_size: locate_config_value(:
|
30
|
+
max_pages: locate_config_value(:gce_max_pages),
|
31
|
+
max_page_size: locate_config_value(:gce_max_page_size)
|
32
32
|
)
|
33
33
|
end
|
34
34
|
|
@@ -38,7 +38,7 @@ class Chef::Knife::Cloud
|
|
38
38
|
missing = keys_to_check.select { |x| locate_config_value(x).nil? }
|
39
39
|
|
40
40
|
unless missing.empty?
|
41
|
-
message = "The following required parameters are missing: #{missing.join(
|
41
|
+
message = "The following required parameters are missing: #{missing.join(", ")}"
|
42
42
|
ui.error(message)
|
43
43
|
raise message
|
44
44
|
end
|
@@ -50,6 +50,7 @@ class Chef::Knife::Cloud
|
|
50
50
|
check_for_missing_config_values!(:gce_zone, :disk_size, :disk_type)
|
51
51
|
raise "Please specify a disk name." unless @name_args.first
|
52
52
|
raise "Disk size must be between 10 and 10,000" unless valid_disk_size?(locate_config_value(:disk_size))
|
53
|
+
|
53
54
|
super
|
54
55
|
end
|
55
56
|
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Kapil Chouhan (<kapil.chouhan@msystechnologies.com>)
|
3
|
+
# Copyright:: Copyright (c) 2018-2019 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require "chef/knife"
|
20
|
+
require "chef/knife/cloud/list_resource_command"
|
21
|
+
require "chef/knife/cloud/google_service"
|
22
|
+
require "chef/knife/cloud/google_service_helpers"
|
23
|
+
require "chef/knife/cloud/google_service_options"
|
24
|
+
|
25
|
+
class Chef::Knife::Cloud
|
26
|
+
class GoogleImageList < ResourceListCommand
|
27
|
+
include GoogleServiceHelpers
|
28
|
+
include GoogleServiceOptions
|
29
|
+
|
30
|
+
banner "knife google image list"
|
31
|
+
|
32
|
+
def validate_params!
|
33
|
+
check_for_missing_config_values!
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
def before_exec_command
|
38
|
+
@columns_with_info = [
|
39
|
+
{ label: "NAME", key: "name" },
|
40
|
+
{ label: "PROJECT", key: "self_link", value_callback: method(:find_project_name) },
|
41
|
+
{ label: "FAMILY", key: "family" },
|
42
|
+
{ label: "DISK SIZE", key: "disk_size_gb", value_callback: method(:format_disk_size_value) },
|
43
|
+
{ label: "STATUS", key: "status" },
|
44
|
+
]
|
45
|
+
end
|
46
|
+
|
47
|
+
def find_project_name(self_link)
|
48
|
+
self_link[%r{projects\/(.*?)\/}m, 1]
|
49
|
+
end
|
50
|
+
|
51
|
+
def format_disk_size_value(disk_size)
|
52
|
+
"#{disk_size} GB"
|
53
|
+
end
|
54
|
+
|
55
|
+
def query_resource
|
56
|
+
service.list_images
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -154,46 +154,51 @@ class Chef::Knife::Cloud
|
|
154
154
|
super
|
155
155
|
|
156
156
|
@create_options = {
|
157
|
-
name:
|
158
|
-
image:
|
159
|
-
image_project:
|
160
|
-
network:
|
161
|
-
subnet:
|
162
|
-
public_ip:
|
163
|
-
auto_migrate:
|
164
|
-
auto_restart:
|
165
|
-
preemptible:
|
166
|
-
boot_disk_autodelete:
|
167
|
-
boot_disk_name:
|
168
|
-
boot_disk_size:
|
169
|
-
boot_disk_ssd:
|
170
|
-
additional_disks:
|
171
|
-
can_ip_forward:
|
172
|
-
machine_type:
|
157
|
+
name: instance_name,
|
158
|
+
image: locate_config_value(:image),
|
159
|
+
image_project: locate_config_value(:image_project),
|
160
|
+
network: locate_config_value(:network),
|
161
|
+
subnet: locate_config_value(:subnet),
|
162
|
+
public_ip: locate_config_value(:public_ip),
|
163
|
+
auto_migrate: auto_migrate?,
|
164
|
+
auto_restart: auto_restart?,
|
165
|
+
preemptible: preemptible?,
|
166
|
+
boot_disk_autodelete: locate_config_value(:boot_disk_autodelete),
|
167
|
+
boot_disk_name: locate_config_value(:boot_disk_name),
|
168
|
+
boot_disk_size: boot_disk_size,
|
169
|
+
boot_disk_ssd: locate_config_value(:boot_disk_ssd),
|
170
|
+
additional_disks: locate_config_value(:additional_disks),
|
171
|
+
can_ip_forward: locate_config_value(:can_ip_forward),
|
172
|
+
machine_type: locate_config_value(:machine_type),
|
173
173
|
service_account_scopes: locate_config_value(:service_account_scopes),
|
174
|
-
service_account_name:
|
175
|
-
metadata:
|
176
|
-
tags:
|
174
|
+
service_account_name: locate_config_value(:service_account_name),
|
175
|
+
metadata: metadata,
|
176
|
+
tags: locate_config_value(:tags),
|
177
177
|
}
|
178
178
|
end
|
179
179
|
|
180
180
|
def set_default_config
|
181
181
|
# dumb hack for knife-cloud, which expects the user to pass in the WinRM password to use when bootstrapping.
|
182
182
|
# We won't know the password until the instance is created and we forceably reset it.
|
183
|
-
config[:
|
183
|
+
config[:connection_password] = "will_change_this_later"
|
184
184
|
end
|
185
185
|
|
186
186
|
def validate_params!
|
187
187
|
check_for_missing_config_values!(:gce_zone, :machine_type, :image, :boot_disk_size, :network)
|
188
188
|
raise "You must supply an instance name." if @name_args.first.nil?
|
189
189
|
raise "Boot disk size must be between 10 and 10,000" unless valid_disk_size?(boot_disk_size)
|
190
|
-
|
190
|
+
|
191
|
+
if locate_config_value(:connection_protocol) == "winrm" && locate_config_value(:gce_email).nil?
|
191
192
|
raise "Please provide your Google Cloud console email address via --gce-email. " \
|
192
193
|
"It is required when resetting passwords on Windows hosts."
|
193
194
|
end
|
194
195
|
|
196
|
+
raise "Please provide connection port via --connection-port." unless locate_config_value(:connection_port)
|
197
|
+
raise "Please provide image os type via --image-os-type." unless locate_config_value(:image_os_type)
|
198
|
+
|
195
199
|
ui.warn("Auto-migrate disabled for preemptible instance") if preemptible? && locate_config_value(:auto_migrate)
|
196
200
|
ui.warn("Auto-restart disabled for preemptible instance") if preemptible? && locate_config_value(:auto_restart)
|
201
|
+
|
197
202
|
super
|
198
203
|
end
|
199
204
|
|
@@ -203,9 +208,9 @@ class Chef::Knife::Cloud
|
|
203
208
|
config[:chef_node_name] = locate_config_value(:chef_node_name) ? locate_config_value(:chef_node_name) : instance_name
|
204
209
|
config[:bootstrap_ip_address] = ip_address_for_bootstrap
|
205
210
|
|
206
|
-
if locate_config_value(:
|
211
|
+
if locate_config_value(:image_os_type) == "windows"
|
207
212
|
ui.msg("Resetting the Windows login password so the bootstrap can continue...")
|
208
|
-
config[:
|
213
|
+
config[:connection_password] = reset_windows_password
|
209
214
|
end
|
210
215
|
end
|
211
216
|
|
@@ -247,6 +252,7 @@ class Chef::Knife::Cloud
|
|
247
252
|
ip = locate_config_value(:use_private_ip) ? private_ip_for(server) : public_ip_for(server)
|
248
253
|
|
249
254
|
raise "Unable to determine instance IP address for bootstrapping" if ip == "unknown"
|
255
|
+
|
250
256
|
ip
|
251
257
|
end
|
252
258
|
|
@@ -271,7 +277,7 @@ class Chef::Knife::Cloud
|
|
271
277
|
zone: zone,
|
272
278
|
instance_name: instance_name,
|
273
279
|
email: email,
|
274
|
-
username: locate_config_value(:
|
280
|
+
username: locate_config_value(:connection_user),
|
275
281
|
debug: gcewinpass_debug_mode
|
276
282
|
).new_password
|
277
283
|
end
|
data/lib/knife-google/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-google
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chiraq Jog
|
@@ -13,22 +13,22 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2019-09-25 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: knife-cloud
|
20
20
|
requirement: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
|
-
- - "
|
22
|
+
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version:
|
24
|
+
version: 2.0.0
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
|
-
- - "
|
29
|
+
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version:
|
31
|
+
version: 2.0.0
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
33
|
name: google-api-client
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/chef/knife/google_disk_create.rb
|
79
79
|
- lib/chef/knife/google_disk_delete.rb
|
80
80
|
- lib/chef/knife/google_disk_list.rb
|
81
|
+
- lib/chef/knife/google_image_list.rb
|
81
82
|
- lib/chef/knife/google_project_quotas.rb
|
82
83
|
- lib/chef/knife/google_region_list.rb
|
83
84
|
- lib/chef/knife/google_region_quotas.rb
|
@@ -106,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
107
|
- !ruby/object:Gem::Version
|
107
108
|
version: '0'
|
108
109
|
requirements: []
|
109
|
-
|
110
|
-
rubygems_version: 2.7.6
|
110
|
+
rubygems_version: 3.0.3
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Google Compute Engine Support for Chef's Knife Command
|