knife-google 4.1.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b39bef9d566a21cb4bcf0a0decb202b5b8905ad548335fd4f8eceea6408208a0
4
- data.tar.gz: 4f75ba0bb858215fa19aa8566a18e93fbb6b3a01dfc89b774d1e0d9b03d20ab6
3
+ metadata.gz: c820682e78767b815e84461ae0b564b16724f27f01276333c084e28cf9bf0667
4
+ data.tar.gz: f2c23f4b66cd3300f6c2f0d59b1872eafbab64ba7c7262890539c042279d10d2
5
5
  SHA512:
6
- metadata.gz: 5454224647a87ffda86710c3fa6c494b8e8ff1bb05c773aa888190293ff84c08cf5f2c2ec746763efc9f3853d1e0f691e748d46d23e8cad6154d5ef960858d34
7
- data.tar.gz: dedb9b64dde86e7678bd87ece3852a40c6832a83833e779a39339ac89efc51e568d3316264cbdc964679813744f11ebbef1b96b1969910accb378f73c003f862
6
+ metadata.gz: 8ed855d4c2501f9f19435f2ada289e5b8a00b0024f2428b247c3ce3d70b433f294f391572dbd4b9b9f498d5ac1eed43c835765903885df74e785cc0d4f1fa4d9
7
+ data.tar.gz: 81e86ece3515be3586caebc47bb8620af9e94904c5a4a3e9f9cfe05d8c6b97339aea5d3ab4453a8c2c9f784ae6a5296c5ced1ecc62022b1b8a7b820a299b1fe8
@@ -235,6 +235,7 @@ class Chef::Knife::Cloud
235
235
  raise "Invalid subnet: #{options[:subnet]}" if options[:subnet] && !valid_subnet?(options[:subnet])
236
236
  raise "Invalid Public IP setting: #{options[:public_ip]}" unless valid_public_ip_setting?(options[:public_ip])
237
237
  raise "Invalid image: #{options[:image]} - check your image name, or set an image project if needed" if boot_disk_source_image(options[:image], options[:image_project]).nil?
238
+ raise "Maximum number of local SSDs for an instance should be 8, while #{options[:number_of_local_ssd]} is requested." if options[:number_of_local_ssd].to_i > 8
238
239
  end
239
240
 
240
241
  def check_api_call
@@ -308,6 +309,7 @@ class Chef::Knife::Cloud
308
309
  def instance_disks_for(options)
309
310
  disks = []
310
311
  disks << instance_boot_disk_for(options)
312
+ options[:number_of_local_ssd].to_i.times { disks << adding_local_ssd(options) } if options[:local_ssd]
311
313
  options[:additional_disks].each do |disk_name|
312
314
  begin
313
315
  disk = connection.get_disk(project, zone, disk_name)
@@ -323,20 +325,34 @@ class Chef::Knife::Cloud
323
325
  end
324
326
 
325
327
  def instance_boot_disk_for(options)
326
- disk = Google::Apis::ComputeV1::AttachedDisk.new
327
- params = Google::Apis::ComputeV1::AttachedDiskInitializeParams.new
328
-
328
+ disk, params = common_operation(options, boot_disk_type_for(options))
329
329
  disk.boot = true
330
- disk.auto_delete = options[:boot_disk_autodelete]
331
330
  params.disk_name = boot_disk_name_for(options)
332
331
  params.disk_size_gb = options[:boot_disk_size]
333
- params.disk_type = disk_type_url_for(boot_disk_type_for(options))
334
332
  params.source_image = boot_disk_source_image(options[:image], options[:image_project])
335
333
 
336
334
  disk.initialize_params = params
337
335
  disk
338
336
  end
339
337
 
338
+ # To create a instance with an attached local SSD
339
+ def adding_local_ssd(options)
340
+ disk, params = common_operation(options, "local-ssd")
341
+ disk.type = "SCRATCH"
342
+ disk.interface = options[:interface]
343
+
344
+ disk.initialize_params = params
345
+ disk
346
+ end
347
+
348
+ def common_operation(options, disk_type)
349
+ disk = Google::Apis::ComputeV1::AttachedDisk.new
350
+ params = Google::Apis::ComputeV1::AttachedDiskInitializeParams.new
351
+ disk.auto_delete = options[:boot_disk_autodelete]
352
+ params.disk_type = disk_type_url_for(disk_type)
353
+ [disk, params]
354
+ end
355
+
340
356
  def boot_disk_type_for(options)
341
357
  options[:boot_disk_ssd] ? "pd-ssd" : "pd-standard"
342
358
  end
@@ -146,6 +146,23 @@ class Chef::Knife::Cloud
146
146
  long: "--gce-email EMAIL_ADDRESS",
147
147
  description: "email address of the logged-in Google Cloud user; required for bootstrapping windows hosts"
148
148
 
149
+ option :local_ssd,
150
+ long: "--gce-local-ssd",
151
+ description: "Local SSDs are physically attached to the server that hosts your VM instance. Local SSDs have higher throughput and lower latency than standard persistent disks or SSD persistent disks.",
152
+ boolean: true,
153
+ default: false
154
+
155
+ option :interface,
156
+ long: "--gce-interface INTERFACE",
157
+ description: "The kind of disk interface exposed to the VM for this SSD. Valid values are SCSI and NVME. SCSI is the default and is supported by more guest operating systems. NVME may provide higher performance.",
158
+ default: "scsi",
159
+ in: %w{scsi nvme}
160
+
161
+ option :number_of_local_ssd,
162
+ long: "--gce-number-of-local-ssd NUMBER_OF_DISKS",
163
+ description: "Specifies the number of local SSDs to be created per node. Each local SSD is 375 GB in size, but you can attach up to eight local SSD devices for 3 TB of total local SSD storage space per instance.",
164
+ default: "1"
165
+
149
166
  deps do
150
167
  require "gcewinpass"
151
168
  end
@@ -168,6 +185,9 @@ class Chef::Knife::Cloud
168
185
  boot_disk_size: boot_disk_size,
169
186
  boot_disk_ssd: locate_config_value(:boot_disk_ssd),
170
187
  additional_disks: locate_config_value(:additional_disks),
188
+ local_ssd: locate_config_value(:local_ssd),
189
+ interface: locate_config_value(:interface),
190
+ number_of_local_ssd: number_of_local_ssd,
171
191
  can_ip_forward: locate_config_value(:can_ip_forward),
172
192
  machine_type: locate_config_value(:machine_type),
173
193
  service_account_scopes: locate_config_value(:service_account_scopes),
@@ -271,6 +291,10 @@ class Chef::Knife::Cloud
271
291
  locate_config_value(:boot_disk_size).to_i
272
292
  end
273
293
 
294
+ def number_of_local_ssd
295
+ locate_config_value(:number_of_local_ssd).to_i
296
+ end
297
+
274
298
  def reset_windows_password
275
299
  GoogleComputeWindowsPassword.new(
276
300
  project: project,
@@ -15,7 +15,7 @@
15
15
  #
16
16
  module Knife
17
17
  module Google
18
- VERSION = "4.1.0"
18
+ VERSION = "4.2.0"
19
19
  MAJOR, MINOR, TINY = VERSION.split(".")
20
20
  end
21
21
  end
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.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chiraq Jog
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2019-09-25 00:00:00.000000000 Z
16
+ date: 2019-10-10 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: knife-cloud