kitchen-oci 1.12.3 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +9 -0
- data/lib/kitchen/driver/oci.rb +126 -0
- data/lib/kitchen/driver/oci_version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e1357de8069c06276801117608aa999544eee7db3af9f4829b65236600ef602
|
4
|
+
data.tar.gz: fe073de0b5ab64c48dbc706df628ce7e1fed54f865234732fc484778b68c6106
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 454e20b024cf7c4c1b2615db89b51b7897561484aa633a01c3b5a2332fcb989903cf556a3de1a589b5390ab8021940dc6840b7f8bb0955b5bc613713382b9df3
|
7
|
+
data.tar.gz: 141394aa371177bdfff43273d91e276879afc16159c1faa01bcdce5f4db527373a4d14abd70033d0d2f427ed8c46a44cbaa67557da65d654f396d412a8e4f70d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# kitchen-oci CHANGELOG
|
2
|
+
|
3
|
+
# 1.13.0
|
4
|
+
- feat: add Network Security Group support
|
5
|
+
- feat: add support for attaching multiple volumes
|
6
|
+
|
7
|
+
## 1.12.3
|
8
|
+
- feat: add support for specifying compartment by name
|
1
9
|
|
2
10
|
## 1.12.1
|
3
11
|
- Refactor `oci_config` method to account for `warning: Using the last argument as keyword parameters is deprecated` deprecation warning
|
data/README.md
CHANGED
@@ -92,6 +92,12 @@ These settings are optional:
|
|
92
92
|
- `ocpus`, number of CPUs requested
|
93
93
|
- `memory_in_gbs`, the amount of memory requested
|
94
94
|
- `baseline_ocpu_utilization`, the minimum CPU utilization, default `BASELINE_1_1`
|
95
|
+
- `volumes`, an array of hashes with configuration options of each volume
|
96
|
+
- `name`, the display name of the volume
|
97
|
+
- `size_in_gbs`, the size in Gbs for the volume. Can't be lower than 50Gbs (Oracle Limit)
|
98
|
+
- `type`, oracle only supports `iscsi` or `paravirtual` options (default: `paravirtual`)
|
99
|
+
- `vpus_per_gb`, vpus per gb. Make sure to consult the documentation for your shape to take advantage of UHP as MultiPath is enabled only with certain combinations of memory/cpus.
|
100
|
+
- `nsg_ids`, The option to connect up to 5 Network Security Groups to compute instance.
|
95
101
|
|
96
102
|
Optional settings for WinRM support in Windows:
|
97
103
|
|
@@ -119,6 +125,9 @@ If the `subnet_id` refers to a subnet configured to disallow public IPs on any a
|
|
119
125
|
oci_config_file: "~/.oci/config"
|
120
126
|
oci_profile_name: "DEFAULT"
|
121
127
|
ssh_keypath: "~/.ssh/id_rsa.pub"
|
128
|
+
nsg_ids:
|
129
|
+
- ocid1.networksecuritygroup.oc1.phx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
130
|
+
- ocid1.networksecuritygroup.oc1.phx.yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
122
131
|
post_create_script: >-
|
123
132
|
```
|
124
133
|
|
data/lib/kitchen/driver/oci.rb
CHANGED
@@ -70,6 +70,9 @@ module Kitchen
|
|
70
70
|
# dbaas config items
|
71
71
|
default_config :dbaas, {}
|
72
72
|
|
73
|
+
# blockstorage config items
|
74
|
+
default_config :volumes, {}
|
75
|
+
|
73
76
|
def create(state)
|
74
77
|
return if state[:server_id]
|
75
78
|
|
@@ -82,6 +85,9 @@ module Kitchen
|
|
82
85
|
|
83
86
|
instance.transport.connection(state).wait_until_ready
|
84
87
|
|
88
|
+
state[:volumes] = process_volumes_list(state)
|
89
|
+
state[:volume_attachments] = process_volume_attachments(state)
|
90
|
+
|
85
91
|
return unless config[:post_create_script]
|
86
92
|
|
87
93
|
info('Running post create script')
|
@@ -94,6 +100,18 @@ module Kitchen
|
|
94
100
|
|
95
101
|
instance.transport.connection(state).close
|
96
102
|
|
103
|
+
if state[:volume_attachments]
|
104
|
+
state[:volume_attachments].each do |attachment|
|
105
|
+
volume_detach(attachment)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
if state[:volumes]
|
110
|
+
state[:volumes].each do |vol|
|
111
|
+
volume_delete(vol[:id])
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
97
115
|
if instance_type == 'compute'
|
98
116
|
comp_api.terminate_instance(state[:server_id])
|
99
117
|
elsif instance_type == 'dbaas'
|
@@ -231,6 +249,10 @@ module Kitchen
|
|
231
249
|
generic_api(OCI::Identity::IdentityClient)
|
232
250
|
end
|
233
251
|
|
252
|
+
def blockstorage_api
|
253
|
+
generic_api(OCI::Core::BlockstorageClient)
|
254
|
+
end
|
255
|
+
|
234
256
|
##################
|
235
257
|
# Common methods #
|
236
258
|
##################
|
@@ -372,10 +394,13 @@ module Kitchen
|
|
372
394
|
end
|
373
395
|
|
374
396
|
def create_vnic_details(name)
|
397
|
+
nsg_ids = config[:nsg_ids] || []
|
398
|
+
raise 'nsg_ids cannot have more than 5 NSGs.' if nsg_ids.length > 5
|
375
399
|
OCI::Core::Models::CreateVnicDetails.new(
|
376
400
|
assign_public_ip: public_ip_allowed?,
|
377
401
|
display_name: name,
|
378
402
|
hostname_label: name,
|
403
|
+
nsg_ids: nsg_ids,
|
379
404
|
subnetId: config[:subnet_id]
|
380
405
|
)
|
381
406
|
end
|
@@ -461,6 +486,107 @@ module Kitchen
|
|
461
486
|
end
|
462
487
|
end
|
463
488
|
|
489
|
+
########################
|
490
|
+
# BlockStorage methods #
|
491
|
+
########################
|
492
|
+
def process_volumes_list(state)
|
493
|
+
created_vol = []
|
494
|
+
config[:volumes].each do |vol_settings|
|
495
|
+
# convert to hash because otherwise it's an an OCI API Object and won't load
|
496
|
+
volume_attachment_type = vol_settings[:type].downcase || 'paravirtual'
|
497
|
+
unless %w[iscsi paravirtual].include?(volume_attachment_type)
|
498
|
+
info("invalid volume attachment type: #{volume_attachment_type}")
|
499
|
+
next
|
500
|
+
end
|
501
|
+
volume = volume_create(
|
502
|
+
config[:availability_domain],
|
503
|
+
vol_settings[:name],
|
504
|
+
vol_settings[:size_in_gbs],
|
505
|
+
vol_settings[:vpus_per_gb] || 10
|
506
|
+
).to_hash
|
507
|
+
# convert to string otherwise it's a ruby datetime object and won't load
|
508
|
+
volume[:attachment_type] = volume_attachment_type
|
509
|
+
created_vol << volume
|
510
|
+
end
|
511
|
+
created_vol
|
512
|
+
end
|
513
|
+
|
514
|
+
def volume_create(availability_domain, display_name, size_in_gbs, vpus_per_gb)
|
515
|
+
info("Creating volume <#{display_name}>...")
|
516
|
+
result = blockstorage_api.create_volume(
|
517
|
+
OCI::Core::Models::CreateVolumeDetails.new(
|
518
|
+
compartment_id: compartment_id,
|
519
|
+
availability_domain: availability_domain,
|
520
|
+
display_name: display_name,
|
521
|
+
size_in_gbs: size_in_gbs,
|
522
|
+
vpus_per_gb: vpus_per_gb
|
523
|
+
)
|
524
|
+
)
|
525
|
+
get_volume_response = blockstorage_api.get_volume(result.data.id)
|
526
|
+
.wait_until(:lifecycle_state, OCI::Core::Models::Volume::LIFECYCLE_STATE_AVAILABLE)
|
527
|
+
info("Finished creating volume <#{display_name}>.")
|
528
|
+
state_data = {
|
529
|
+
:id => get_volume_response.data.id
|
530
|
+
}
|
531
|
+
end
|
532
|
+
|
533
|
+
def volume_delete(volume_id)
|
534
|
+
info("Deleting volume: <#{volume_id}>...")
|
535
|
+
blockstorage_api.delete_volume(volume_id)
|
536
|
+
blockstorage_api.get_volume(volume_id)
|
537
|
+
.wait_until(:lifecycle_state, OCI::Core::Models::Volume::LIFECYCLE_STATE_TERMINATED)
|
538
|
+
info("Deleted volume: <#{volume_id}>")
|
539
|
+
end
|
540
|
+
|
541
|
+
def process_volume_attachments(state)
|
542
|
+
attachments = []
|
543
|
+
state[:volumes].each do |volume|
|
544
|
+
info("Attaching Volume: #{volume[:displayName]} - #{volume[:attachment_type]}")
|
545
|
+
details = volume_create_attachment_details(volume, state[:server_id])
|
546
|
+
attachment = volume_attach(details).to_hash
|
547
|
+
attachments << attachment
|
548
|
+
info("Attached Volume #{volume[:displayName]} - #{volume[:attachment_type]}")
|
549
|
+
end
|
550
|
+
attachments
|
551
|
+
end
|
552
|
+
|
553
|
+
def volume_create_attachment_details(volume, instance_id)
|
554
|
+
if volume[:attachment_type].eql?('iscsi')
|
555
|
+
OCI::Core::Models::AttachIScsiVolumeDetails.new(
|
556
|
+
display_name: 'iSCSIAttachment',
|
557
|
+
volume_id: volume[:id],
|
558
|
+
instance_id: instance_id
|
559
|
+
)
|
560
|
+
elsif volume[:attachment_type].eq?('paravirtual')
|
561
|
+
OCI::Core::Models::AttachParavirtualizedVolumeDetails.new(
|
562
|
+
display_name: 'paravirtAttachment',
|
563
|
+
volume_id: volume[:id],
|
564
|
+
instance_id: instance_id
|
565
|
+
)
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
569
|
+
def volume_attach(volume_attachment_details)
|
570
|
+
result = comp_api.attach_volume(volume_attachment_details)
|
571
|
+
get_volume_attachment_response =
|
572
|
+
comp_api.get_volume_attachment(result.data.id)
|
573
|
+
.wait_until(:lifecycle_state, OCI::Core::Models::VolumeAttachment::LIFECYCLE_STATE_ATTACHED)
|
574
|
+
state_data = {
|
575
|
+
:id => get_volume_attachment_response.data.id,
|
576
|
+
:iqn_ipv4 => get_volume_attachment_response.data.ipv4,
|
577
|
+
:iqn => get_volume_attachment_response.data.iqn,
|
578
|
+
:port => get_volume_attachment_response.data.port,
|
579
|
+
}
|
580
|
+
end
|
581
|
+
|
582
|
+
def volume_detach(volume_attachment)
|
583
|
+
info("Detaching volume: #{volume_attachment[:id]}")
|
584
|
+
comp_api.detach_volume(volume_attachment[:id])
|
585
|
+
comp_api.get_volume_attachment(volume_attachment[:id])
|
586
|
+
.wait_until(:lifecycle_state, OCI::Core::Models::VolumeAttachment::LIFECYCLE_STATE_DETACHED)
|
587
|
+
info("Detached volume: #{volume_attachment[:id]}")
|
588
|
+
end
|
589
|
+
|
464
590
|
#################
|
465
591
|
# DBaaS methods #
|
466
592
|
#################
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-oci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Pearson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oci
|