kitchen-oci 1.21.0 → 1.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kitchen/driver/oci/blockstorage.rb +33 -3
- data/lib/kitchen/driver/oci/instance/compute.rb +4 -0
- data/lib/kitchen/driver/oci/models/iscsi.rb +4 -2
- data/lib/kitchen/driver/oci/models/paravirtual.rb +4 -2
- data/lib/kitchen/driver/oci.rb +17 -3
- data/lib/kitchen/driver/oci_version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfb66c27ceadfa20413cbe9cf5adfed0ee3e1c8143d385c4831c74d0cddf7f2a
|
4
|
+
data.tar.gz: 5f52b6cf9894d2409f8449425932d922724191112212a31ccde89becaa8af9ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cf50ea82775012662cc8d6d90e4cc0c35d751e4f901ce8643c9fac406bf2fe5228b5b909f58e60852391a0c2abbe6b267e4be2044368241742551804b1231f6
|
7
|
+
data.tar.gz: 85f69da22e935aec15d1928f32564aedf398a85f3d749c96dfdd52029c75c214d2239f131115067509a1d84ffa8085d4f2c9e25c1c02952ae36a254917752f98
|
@@ -20,7 +20,7 @@ module Kitchen
|
|
20
20
|
module Driver
|
21
21
|
class Oci
|
22
22
|
# generic class for blockstorage
|
23
|
-
class Blockstorage < Oci
|
23
|
+
class Blockstorage < Oci # rubocop:disable Metrics/ClassLength
|
24
24
|
require_relative "api"
|
25
25
|
require_relative "config"
|
26
26
|
require_relative "models/iscsi"
|
@@ -85,9 +85,18 @@ module Kitchen
|
|
85
85
|
[response, final_state(response)]
|
86
86
|
end
|
87
87
|
|
88
|
-
def
|
88
|
+
def create_clone_volume(volume)
|
89
|
+
clone_volume_name = clone_volume_display_name(volume[:volume_id])
|
90
|
+
info("Creating <#{clone_volume_name}>...")
|
91
|
+
result = api.blockstorage.create_volume(volume_clone_details(volume, clone_volume_name))
|
92
|
+
response = volume_response(result.data.id)
|
93
|
+
info("Finished creating <#{clone_volume_name}>.")
|
94
|
+
[response, final_state(response)]
|
95
|
+
end
|
96
|
+
|
97
|
+
def attach_volume(volume_details, server_id, volume_config)
|
89
98
|
info("Attaching <#{volume_details.display_name}>...")
|
90
|
-
attach_volume = api.compute.attach_volume(attachment_details(volume_details, server_id))
|
99
|
+
attach_volume = api.compute.attach_volume(attachment_details(volume_details, server_id, volume_config))
|
91
100
|
response = attachment_response(attach_volume.data.id)
|
92
101
|
info("Finished attaching <#{volume_details.display_name}>.")
|
93
102
|
final_state(response)
|
@@ -141,15 +150,36 @@ module Kitchen
|
|
141
150
|
)
|
142
151
|
end
|
143
152
|
|
153
|
+
def volume_clone_details(volume, clone_volume_name)
|
154
|
+
OCI::Core::Models::CreateVolumeDetails.new(
|
155
|
+
compartment_id: oci.compartment,
|
156
|
+
availability_domain: config[:availability_domain],
|
157
|
+
display_name: clone_volume_name,
|
158
|
+
defined_tags: config[:defined_tags],
|
159
|
+
size_in_gbs: volume[:size_in_gbs],
|
160
|
+
vpus_per_gb: volume[:vpus_per_gb],
|
161
|
+
source_details: OCI::Core::Models::VolumeSourceFromVolumeDetails.new(id: volume[:volume_id])
|
162
|
+
)
|
163
|
+
end
|
164
|
+
|
144
165
|
def attachment_name(attachment)
|
145
166
|
attachment[:display_name].gsub(/(?:paravirtual|iscsi)-/, "")
|
146
167
|
end
|
147
168
|
|
169
|
+
def server_os(server_id)
|
170
|
+
image_id = api.compute.get_instance(server_id).data.image_id
|
171
|
+
api.compute.get_image(image_id).data.operating_system
|
172
|
+
end
|
173
|
+
|
148
174
|
def final_volume_state(response)
|
149
175
|
volume_state.store(:id, response.id)
|
150
176
|
volume_state.store(:display_name, response.display_name)
|
151
177
|
volume_state
|
152
178
|
end
|
179
|
+
|
180
|
+
def clone_volume_display_name(volume_id)
|
181
|
+
"#{api.blockstorage.get_volume(volume_id).data.to_hash[:displayName]} (Clone)"
|
182
|
+
end
|
153
183
|
end
|
154
184
|
end
|
155
185
|
end
|
@@ -49,6 +49,10 @@ module Kitchen
|
|
49
49
|
)
|
50
50
|
end
|
51
51
|
|
52
|
+
def capacity_reservation
|
53
|
+
launch_details.capacity_reservation_id = config[:capacity_reservation_id]
|
54
|
+
end
|
55
|
+
|
52
56
|
def agent_config
|
53
57
|
launch_details.agent_config = OCI::Core::Models::LaunchInstanceAgentConfigDetails.new(
|
54
58
|
are_all_plugins_disabled: config[:all_plugins_disabled],
|
@@ -35,11 +35,13 @@ module Kitchen
|
|
35
35
|
#
|
36
36
|
attr_reader :attachment_type
|
37
37
|
|
38
|
-
def attachment_details(volume_details, server_id)
|
38
|
+
def attachment_details(volume_details, server_id, volume_config)
|
39
|
+
device = volume_config[:device] unless server_os(server_id).downcase =~ /windows/
|
39
40
|
OCI::Core::Models::AttachIScsiVolumeDetails.new(
|
40
41
|
display_name: "#{attachment_type}-#{volume_details.display_name}",
|
41
42
|
volume_id: volume_details.id,
|
42
|
-
instance_id: server_id
|
43
|
+
instance_id: server_id,
|
44
|
+
device: device
|
43
45
|
)
|
44
46
|
end
|
45
47
|
|
@@ -35,11 +35,13 @@ module Kitchen
|
|
35
35
|
#
|
36
36
|
attr_reader :attachment_type
|
37
37
|
|
38
|
-
def attachment_details(volume_details, server_id)
|
38
|
+
def attachment_details(volume_details, server_id, volume_config)
|
39
|
+
device = volume_config[:device] unless server_os(server_id).downcase =~ /windows/
|
39
40
|
OCI::Core::Models::AttachParavirtualizedVolumeDetails.new(
|
40
41
|
display_name: "#{attachment_type}-#{volume_details.display_name}",
|
41
42
|
volume_id: volume_details.id,
|
42
|
-
instance_id: server_id
|
43
|
+
instance_id: server_id,
|
44
|
+
device: device
|
43
45
|
)
|
44
46
|
end
|
45
47
|
|
data/lib/kitchen/driver/oci.rb
CHANGED
@@ -79,6 +79,7 @@ module Kitchen
|
|
79
79
|
default_config :post_create_reboot, false
|
80
80
|
|
81
81
|
# compute only configs
|
82
|
+
default_config :capacity_reservation_id
|
82
83
|
default_config :setup_winrm, false
|
83
84
|
default_config :winrm_user, "opc"
|
84
85
|
default_config :winrm_password, nil
|
@@ -153,15 +154,28 @@ module Kitchen
|
|
153
154
|
def create_and_attach_volumes(config, state, oci, api)
|
154
155
|
return if config[:volumes].empty?
|
155
156
|
|
157
|
+
volume_state = process_volumes(config, state, oci, api)
|
158
|
+
state.merge!(volume_state)
|
159
|
+
end
|
160
|
+
|
161
|
+
def process_volumes(config, state, oci, api)
|
156
162
|
volume_state = { volumes: [], volume_attachments: [] }
|
157
163
|
config[:volumes].each do |volume|
|
158
164
|
vol = volume_class(volume[:type], config, state, oci, api)
|
159
|
-
volume_details, vol_state =
|
160
|
-
attach_state = vol.attach_volume(volume_details, state[:server_id])
|
165
|
+
volume_details, vol_state = create_volume(vol, volume)
|
166
|
+
attach_state = vol.attach_volume(volume_details, state[:server_id], volume)
|
161
167
|
volume_state[:volumes] << vol_state
|
162
168
|
volume_state[:volume_attachments] << attach_state
|
163
169
|
end
|
164
|
-
|
170
|
+
volume_state
|
171
|
+
end
|
172
|
+
|
173
|
+
def create_volume(vol, volume)
|
174
|
+
if volume.key?(:volume_id)
|
175
|
+
vol.create_clone_volume(volume)
|
176
|
+
else
|
177
|
+
vol.create_volume(volume)
|
178
|
+
end
|
165
179
|
end
|
166
180
|
|
167
181
|
def process_post_script(state)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-oci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Pearson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oci
|
@@ -135,7 +135,7 @@ files:
|
|
135
135
|
- lib/kitchen/driver/oci/models/paravirtual.rb
|
136
136
|
- lib/kitchen/driver/oci_version.rb
|
137
137
|
- tpl/setup_winrm.ps1.erb
|
138
|
-
homepage:
|
138
|
+
homepage: https://github.com/stephenpearson/kitchen-oci
|
139
139
|
licenses:
|
140
140
|
- Apache-2.0
|
141
141
|
metadata: {}
|