kitchen-oci 1.18.1 → 1.20.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: dc3416b97957d72c5262acfed751b388a1387a5e18b85fc02193bc88c2283c72
4
- data.tar.gz: 2946ba6f22ac36f50e6699c8d20acbf628ba19ad0d6f80b042d89f3e269aff20
3
+ metadata.gz: d605c9336d53fbeff2b9b87b00a3c862615d4f46d301ec2fe1deafa43922c39c
4
+ data.tar.gz: ad8c34ef492edc7b2b6912726cc7978d50ac4a370a624e3640f1fb3931cbbf37
5
5
  SHA512:
6
- metadata.gz: 5c260f31d16ba17bfdffb4384b93263d7ffe415e45c65a1f6c7b432ca78aa0cc89f14140988cbe9918c01b2c7b2496b2126d3584bc8792e4a31c954b2a6164e0
7
- data.tar.gz: d7ba936db2bc7d265bab692250a595b2b94bfe9f5fe85dd9536e5d6b583bb68454c56d5d8240df5042b27b667d5c94063a4f2f3fa14d6ba4db31769e1904ad4c
6
+ metadata.gz: 27b2cd8c880fd1faff1012abbcaa2a703813841051962c3653c02b2503e07565718a101595dbe1affcba513cd86bd6adcd2a700af97212da9ba420f16cda8921
7
+ data.tar.gz: 7bc6d52865dd933e2c4fdf896bc11649af610c92e74782821da6bf7cd6525bffabffb0735c9e30261a538d36c82f2c48f5e1e333c356cf1a7712dc6636847d90
@@ -57,7 +57,9 @@ module Kitchen
57
57
  )
58
58
  end
59
59
 
60
- def instance_source_details
60
+ def instance_source_via_image
61
+ return if config[:boot_volume_id]
62
+
61
63
  launch_details.source_details = OCI::Core::Models::InstanceSourceViaImageDetails.new(
62
64
  sourceType: "image",
63
65
  imageId: image_id,
@@ -65,6 +67,15 @@ module Kitchen
65
67
  )
66
68
  end
67
69
 
70
+ def instance_source_via_boot_volume
71
+ return unless config[:boot_volume_id]
72
+
73
+ launch_details.source_details = OCI::Core::Models::InstanceSourceViaBootVolumeDetails.new(
74
+ boot_volume_id: clone_boot_volume,
75
+ sourceType: "bootVolume"
76
+ )
77
+ end
78
+
68
79
  def instance_metadata
69
80
  launch_details.metadata = metadata
70
81
  end
@@ -22,6 +22,12 @@ module Kitchen
22
22
  class Instance
23
23
  # setter methods that populate the details of OCI::Database::Models::CreateDatabaseDetails
24
24
  module DatabaseDetails
25
+ def database_software_image
26
+ return unless config[:dbaas][:db_software_image_id]
27
+
28
+ database_details.database_software_image_id = config[:dbaas][:db_software_image_id]
29
+ end
30
+
25
31
  def character_set
26
32
  database_details.character_set = config[:dbaas][:character_set] ||= "AL32UTF8"
27
33
  end
@@ -35,6 +35,12 @@ module Kitchen
35
35
  def db_home_display_name
36
36
  db_home_details.display_name = ["dbhome", random_number(10)].compact.join
37
37
  end
38
+
39
+ def db_home_software_image
40
+ return unless config[:dbaas][:db_software_image_id]
41
+
42
+ db_home_details.database_software_image_id = config[:dbaas][:db_software_image_id]
43
+ end
38
44
  end
39
45
  end
40
46
  end
@@ -29,7 +29,6 @@ module Kitchen
29
29
  include DbHomeDetails
30
30
  #
31
31
  # TODO: add support for the #domain property
32
- # add support for #database_software_image_id property
33
32
  #
34
33
  def db_home
35
34
  launch_details.db_home = db_home_details
@@ -42,7 +42,7 @@ module Kitchen
42
42
  process_windows_options
43
43
  response = api.compute.launch_instance(launch_instance_details)
44
44
  instance_id = response.data.id
45
- api.compute.get_instance(instance_id).wait_until(:lifecycle_state, OCI::Core::Models::Instance::LIFECYCLE_STATE_RUNNING )
45
+ api.compute.get_instance(instance_id).wait_until(:lifecycle_state, OCI::Core::Models::Instance::LIFECYCLE_STATE_RUNNING)
46
46
  final_state(state, instance_id)
47
47
  end
48
48
 
@@ -51,6 +51,11 @@ module Kitchen
51
51
  api.compute.get_instance(state[:server_id]).wait_until(:lifecycle_state, OCI::Core::Models::Instance::LIFECYCLE_STATE_TERMINATING)
52
52
  end
53
53
 
54
+ def reboot
55
+ api.compute.instance_action(state[:server_id], "SOFTRESET")
56
+ api.compute.get_instance(state[:server_id]).wait_until(:lifecycle_state, OCI::Core::Models::Instance::LIFECYCLE_STATE_RUNNING)
57
+ end
58
+
54
59
  private
55
60
 
56
61
  def image_id
@@ -88,6 +93,28 @@ module Kitchen
88
93
  image_list.flatten
89
94
  end
90
95
 
96
+ def clone_boot_volume
97
+ info("Cloning boot volume...")
98
+ cbv = api.blockstorage.create_boot_volume(clone_boot_volume_details)
99
+ api.blockstorage.get_boot_volume(cbv.data.id).wait_until(:lifecycle_state, OCI::Core::Models::BootVolume::LIFECYCLE_STATE_AVAILABLE)
100
+ info("Finished cloning boot volume.")
101
+ cbv.data.id
102
+ end
103
+
104
+ def clone_boot_volume_details
105
+ OCI::Core::Models::CreateBootVolumeDetails.new(
106
+ source_details: OCI::Core::Models::BootVolumeSourceFromBootVolumeDetails.new(
107
+ id: config[:boot_volume_id]
108
+ ),
109
+ display_name: boot_volume_display_name,
110
+ compartment_id: oci.compartment
111
+ )
112
+ end
113
+
114
+ def boot_volume_display_name
115
+ "#{api.blockstorage.get_boot_volume(config[:boot_volume_id]).data.display_name} (Clone)"
116
+ end
117
+
91
118
  def instance_ip(instance_id)
92
119
  vnic = vnics(instance_id).select(&:is_primary).first
93
120
  if public_ip_allowed?
@@ -109,7 +136,7 @@ module Kitchen
109
136
  end
110
137
 
111
138
  def hostname
112
- [config[:hostname_prefix], random_string(6)].compact.join("-")
139
+ %W{#{config[:hostname_prefix]} #{config[:instance_name]} #{random_string(6)}}.uniq.compact.join("-")
113
140
  end
114
141
 
115
142
  def create_vnic_details(name)
@@ -69,6 +69,12 @@ module Kitchen
69
69
  max_interval_seconds: 900, max_wait_seconds: 21_600)
70
70
  end
71
71
 
72
+ def reboot
73
+ db_node_id = dbaas_node(state[:server_id]).first.id
74
+ api.dbaas.db_node_action(db_node_id, "SOFTRESET")
75
+ api.dbaas.get_db_node(db_node_id).wait_until(:lifecycle_state, OCI::Database::Models::DbNode::LIFECYCLE_STATE_AVAILABLE)
76
+ end
77
+
72
78
  private
73
79
 
74
80
  def instance_ip(instance_id)
@@ -52,10 +52,14 @@ module Kitchen
52
52
  default_config :compartment_name, nil
53
53
  default_config :instance_type, "compute"
54
54
  default_config :image_id, nil
55
+ default_config :boot_volume_id, nil
55
56
  default_config :image_name, nil
56
57
  default_config :hostname_prefix do |hnp|
57
58
  hnp.instance.name
58
59
  end
60
+ default_config :instance_name do |inst|
61
+ inst.instance.name
62
+ end
59
63
  default_keypath = File.expand_path(File.join(%w{~ .ssh id_rsa.pub}))
60
64
  default_config :ssh_keypath, default_keypath
61
65
  default_config :post_create_script, nil
@@ -71,6 +75,7 @@ module Kitchen
71
75
  default_config :all_plugins_disabled, false
72
76
  default_config :management_disabled, false
73
77
  default_config :monitoring_disabled, false
78
+ default_config :post_create_reboot, false
74
79
 
75
80
  # compute only configs
76
81
  default_config :setup_winrm, false
@@ -112,21 +117,19 @@ module Kitchen
112
117
  validate_config!
113
118
  oci, api = auth(__method__)
114
119
  inst = instance_class(config, state, oci, api, __method__)
115
- state_details = inst.launch
116
- state.merge!(state_details)
117
- instance.transport.connection(state).wait_until_ready
120
+ launch(state, inst)
118
121
  create_and_attach_volumes(config, state, oci, api)
119
122
  process_post_script(state)
123
+ reboot(state, inst)
120
124
  end
121
125
 
122
126
  def destroy(state)
123
127
  return unless state[:server_id]
124
128
 
125
129
  oci, api = auth(__method__)
126
- instance.transport.connection(state).close
127
- detatch_and_delete_volumes(state, oci, api) if state[:volumes]
128
130
  inst = instance_class(config, state, oci, api, __method__)
129
- inst.terminate
131
+ detatch_and_delete_volumes(state, oci, api)
132
+ terminate(state, inst)
130
133
  end
131
134
 
132
135
  private
@@ -138,6 +141,12 @@ module Kitchen
138
141
  [oci, api]
139
142
  end
140
143
 
144
+ def launch(state, inst)
145
+ state_details = inst.launch
146
+ state.merge!(state_details)
147
+ instance.transport.connection(state).wait_until_ready
148
+ end
149
+
141
150
  def create_and_attach_volumes(config, state, oci, api)
142
151
  return if config[:volumes].empty?
143
152
 
@@ -152,12 +161,6 @@ module Kitchen
152
161
  state.merge!(volume_state)
153
162
  end
154
163
 
155
- def detatch_and_delete_volumes(state, oci, api)
156
- bls = Blockstorage.new(config, state, oci, api, :destroy)
157
- state[:volume_attachments].each { |att| bls.detatch_volume(att) }
158
- state[:volumes].each { |vol| bls.delete_volume(vol) }
159
- end
160
-
161
164
  def process_post_script(state)
162
165
  return if config[:post_create_script].nil?
163
166
 
@@ -165,6 +168,27 @@ module Kitchen
165
168
  script = config[:post_create_script]
166
169
  instance.transport.connection(state).execute(script)
167
170
  end
171
+
172
+ def reboot(state, inst)
173
+ return unless config[:post_create_reboot]
174
+
175
+ instance.transport.connection(state).close
176
+ inst.reboot
177
+ instance.transport.connection(state).wait_until_ready
178
+ end
179
+
180
+ def detatch_and_delete_volumes(state, oci, api)
181
+ return unless state[:volumes]
182
+
183
+ bls = Blockstorage.new(config, state, oci, api, :destroy)
184
+ state[:volume_attachments].each { |att| bls.detatch_volume(att) }
185
+ state[:volumes].each { |vol| bls.delete_volume(vol) }
186
+ end
187
+
188
+ def terminate(state, inst)
189
+ instance.transport.connection(state).close
190
+ inst.terminate
191
+ end
168
192
  end
169
193
  end
170
194
  end
@@ -20,6 +20,6 @@
20
20
  module Kitchen
21
21
  module Driver
22
22
  # Version string for Oracle OCI Kitchen driver
23
- OCI_VERSION = "1.18.1"
23
+ OCI_VERSION = "1.20.0"
24
24
  end
25
25
  end
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.18.1
4
+ version: 1.20.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-04-06 00:00:00.000000000 Z
12
+ date: 2024-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oci
@@ -109,7 +109,7 @@ dependencies:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
- description: A Test Kitchen Driver for Oracle OCI
112
+ description: A Test Kitchen Driver for Oracle Cloud Infrastructure
113
113
  email:
114
114
  - stephen.pearson@oracle.com
115
115
  - justin.steele@oracle.com
@@ -157,5 +157,5 @@ requirements: []
157
157
  rubygems_version: 3.3.7
158
158
  signing_key:
159
159
  specification_version: 4
160
- summary: A Test Kitchen Driver for Oracle OCI
160
+ summary: A Test Kitchen Driver for Oracle Cloud Infrastructure
161
161
  test_files: []