kitchen-oci 1.25.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kitchen/driver/oci/api.rb +36 -7
- data/lib/kitchen/driver/oci/blockstorage.rb +85 -33
- data/lib/kitchen/driver/oci/config.rb +29 -4
- data/lib/kitchen/driver/oci/instance/common.rb +8 -2
- data/lib/kitchen/driver/oci/instance/compute.rb +13 -1
- data/lib/kitchen/driver/oci/instance/database.rb +12 -1
- data/lib/kitchen/driver/oci/instance/db_home.rb +9 -1
- data/lib/kitchen/driver/oci/instance/dbaas.rb +22 -7
- data/lib/kitchen/driver/oci/instance.rb +110 -19
- data/lib/kitchen/driver/oci/mixin/actions.rb +99 -0
- data/lib/kitchen/driver/oci/mixin/models.rb +70 -0
- data/lib/kitchen/driver/oci/mixin/volumes.rb +88 -0
- data/lib/kitchen/driver/oci/models/compute.rb +90 -13
- data/lib/kitchen/driver/oci/models/dbaas.rb +37 -12
- data/lib/kitchen/driver/oci/models/iscsi.rb +15 -5
- data/lib/kitchen/driver/oci/models/paravirtual.rb +15 -5
- data/lib/kitchen/driver/oci.rb +23 -68
- data/lib/kitchen/driver/oci_version.rb +3 -1
- metadata +26 -4
- data/lib/kitchen/driver/oci/models.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 287b9951ec283147d4c090e18ad45ee304e5cd88afaf2d1d4adc91de0c6c55e5
|
4
|
+
data.tar.gz: 8f1c4c1018de62ca0c293dfa83b29182e999092fb561a36c77329643fd99e20b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5eca7e04ff35aba43ab2993e73134a6961cf665cf44a7b39f8c650051faba78aadcf841894f1887f145093557fae2d00a0ff00d4283de7f77ba17c4175bf5236
|
7
|
+
data.tar.gz: 435f87755bdcdcb3b5c79e9d04b66c86386d213d3ea3af5a80dea93d35d12aa00ea87ffa1889b5eff07cd21746f791302eaa5e1ecdd3294995838f82d5f815ce
|
@@ -20,49 +20,66 @@
|
|
20
20
|
module Kitchen
|
21
21
|
module Driver
|
22
22
|
class Oci
|
23
|
-
#
|
23
|
+
# Defines the various API classes used to interact with OCI.
|
24
|
+
#
|
25
|
+
# @author Justin Steele <justin.steele@oracle.com>
|
24
26
|
class Api
|
25
27
|
def initialize(oci_config, config)
|
26
28
|
@oci_config = oci_config
|
27
29
|
@config = config
|
28
30
|
end
|
29
31
|
|
30
|
-
#
|
31
|
-
# The config used to authenticate to OCI
|
32
|
+
# The config used to authenticate to OCI.
|
32
33
|
#
|
33
34
|
# @return [OCI::Config]
|
34
|
-
#
|
35
35
|
attr_reader :oci_config
|
36
36
|
|
37
|
-
#
|
38
|
-
# The config provided by the driver
|
37
|
+
# The config provided by the driver.
|
39
38
|
#
|
40
39
|
# @return [Kitchen::LazyHash]
|
41
|
-
#
|
42
40
|
attr_reader :config
|
43
41
|
|
42
|
+
# Creates a Compute API client.
|
43
|
+
#
|
44
|
+
# @return [OCI::Core::ComputeClient]
|
44
45
|
def compute
|
45
46
|
generic_api(OCI::Core::ComputeClient)
|
46
47
|
end
|
47
48
|
|
49
|
+
# Creates a Network API client.
|
50
|
+
#
|
51
|
+
# @return [OCI::Core::VirtualNetworkClient]
|
48
52
|
def network
|
49
53
|
generic_api(OCI::Core::VirtualNetworkClient)
|
50
54
|
end
|
51
55
|
|
56
|
+
# Creates a Database API client.
|
57
|
+
#
|
58
|
+
# @return [OCI::Core::DatabaseClient]
|
52
59
|
def dbaas
|
53
60
|
generic_api(OCI::Database::DatabaseClient)
|
54
61
|
end
|
55
62
|
|
63
|
+
# Creates an Identity API client.
|
64
|
+
#
|
65
|
+
# @return [OCI::Core::IdentityClient]
|
56
66
|
def identity
|
57
67
|
generic_api(OCI::Identity::IdentityClient)
|
58
68
|
end
|
59
69
|
|
70
|
+
# Creates a Blockstorage API client.
|
71
|
+
#
|
72
|
+
# @return [OCI::Core::BlockstorageClient]
|
60
73
|
def blockstorage
|
61
74
|
generic_api(OCI::Core::BlockstorageClient)
|
62
75
|
end
|
63
76
|
|
64
77
|
private
|
65
78
|
|
79
|
+
# Instantiates the specified client class.
|
80
|
+
#
|
81
|
+
# @param klass [Class] The client class to instantiate.
|
82
|
+
# @return [Object] an instance of <b>klass</b>.
|
66
83
|
def generic_api(klass)
|
67
84
|
params = {}
|
68
85
|
params[:proxy_settings] = api_proxy if api_proxy
|
@@ -73,6 +90,9 @@ module Kitchen
|
|
73
90
|
klass.new(**params)
|
74
91
|
end
|
75
92
|
|
93
|
+
# Determines the signing method if one is specified.
|
94
|
+
#
|
95
|
+
# @return [OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner, OCI::Auth::Signers::SecurityTokenSigner] an instance of the specified token signer.
|
76
96
|
def signer
|
77
97
|
if config[:use_instance_principals]
|
78
98
|
OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner.new
|
@@ -81,6 +101,9 @@ module Kitchen
|
|
81
101
|
end
|
82
102
|
end
|
83
103
|
|
104
|
+
# Creates the token signer with a provided key.
|
105
|
+
#
|
106
|
+
# @return [OCI::Auth::Signers::SecurityTokenSigner]
|
84
107
|
def token_signer
|
85
108
|
pkey_content = oci_config.key_content || File.read(oci_config.key_file).strip
|
86
109
|
pkey = OpenSSL::PKey::RSA.new(pkey_content, oci_config.pass_phrase)
|
@@ -89,6 +112,9 @@ module Kitchen
|
|
89
112
|
OCI::Auth::Signers::SecurityTokenSigner.new(token, pkey)
|
90
113
|
end
|
91
114
|
|
115
|
+
# Parse any specified proxy from either the kitchen config or the environment.
|
116
|
+
#
|
117
|
+
# @return [URI] a parsed proxy host.
|
92
118
|
def proxy_config
|
93
119
|
if config[:proxy_url]
|
94
120
|
URI.parse(config[:proxy_url])
|
@@ -97,6 +123,9 @@ module Kitchen
|
|
97
123
|
end
|
98
124
|
end
|
99
125
|
|
126
|
+
# Create the proxy settings for the OCI API.
|
127
|
+
#
|
128
|
+
# @return [OCI::ApiClientProxySettings]
|
100
129
|
def api_proxy
|
101
130
|
prx = proxy_config
|
102
131
|
return unless prx
|
@@ -19,105 +19,126 @@
|
|
19
19
|
module Kitchen
|
20
20
|
module Driver
|
21
21
|
class Oci
|
22
|
-
#
|
22
|
+
# Base class for blockstorage models.
|
23
|
+
#
|
24
|
+
# @author Justin Steele <justin.steele@oracle.com>
|
23
25
|
class Blockstorage < Oci # rubocop:disable Metrics/ClassLength
|
24
26
|
require_relative "api"
|
25
27
|
require_relative "config"
|
26
28
|
require_relative "models/iscsi"
|
27
29
|
require_relative "models/paravirtual"
|
28
30
|
|
29
|
-
def initialize(
|
31
|
+
def initialize(opts = {})
|
30
32
|
super()
|
31
|
-
@config = config
|
32
|
-
@state = state
|
33
|
-
@oci = oci
|
34
|
-
@api = api
|
33
|
+
@config = opts[:config]
|
34
|
+
@state = opts[:state]
|
35
|
+
@oci = opts[:oci]
|
36
|
+
@api = opts[:api]
|
37
|
+
@logger = opts[:logger]
|
35
38
|
@volume_state = {}
|
36
39
|
@volume_attachment_state = {}
|
37
|
-
oci.compartment if action == :create
|
40
|
+
oci.compartment if opts[:action] == :create
|
38
41
|
end
|
39
42
|
|
40
|
-
#
|
41
|
-
# The config provided by the driver
|
43
|
+
# The config provided by the driver.
|
42
44
|
#
|
43
45
|
# @return [Kitchen::LazyHash]
|
44
|
-
#
|
45
46
|
attr_accessor :config
|
46
47
|
|
47
|
-
#
|
48
|
-
# The definition of the state of the instance from the statefile
|
48
|
+
# The definition of the state of the instance from the statefile.
|
49
49
|
#
|
50
50
|
# @return [Hash]
|
51
|
-
#
|
52
51
|
attr_accessor :state
|
53
52
|
|
54
|
-
#
|
55
|
-
# The config object that contains properties of the authentication to OCI
|
53
|
+
# The config object that contains properties of the authentication to OCI.
|
56
54
|
#
|
57
55
|
# @return [Kitchen::Driver::Oci::Config]
|
58
|
-
#
|
59
56
|
attr_accessor :oci
|
60
57
|
|
61
|
-
#
|
62
|
-
# The API object that contains each of the authenticated clients for interfacing with OCI
|
58
|
+
# The API object that contains each of the authenticated clients for interfacing with OCI.
|
63
59
|
#
|
64
60
|
# @return [Kitchen::Driver::Oci::Api]
|
65
|
-
#
|
66
61
|
attr_accessor :api
|
67
62
|
|
68
|
-
# The
|
63
|
+
# The instance of Kitchen::Logger in use by the active Kitchen::Instance.
|
69
64
|
#
|
70
|
-
# @return [
|
65
|
+
# @return [Kitchen::Logger]
|
66
|
+
attr_accessor :logger
|
67
|
+
|
68
|
+
# The definition of the state of a volume.
|
71
69
|
#
|
70
|
+
# @return [Hash]
|
72
71
|
attr_accessor :volume_state
|
73
72
|
|
74
|
-
# The definition of the state of a volume attachment
|
73
|
+
# The definition of the state of a volume attachment.
|
75
74
|
#
|
76
75
|
# @return [Hash]
|
77
|
-
#
|
78
76
|
attr_accessor :volume_attachment_state
|
79
77
|
|
78
|
+
# Create the volume as specified in the kitchen config.
|
79
|
+
#
|
80
|
+
# @param volume [Hash] the state of the current volume being created.
|
81
|
+
# @return [Array(OCI::Core::Models::Volume, Hash)] returns the actual volume response from OCI for the created volume and the state hash.
|
80
82
|
def create_volume(volume)
|
81
|
-
info("Creating <#{volume[:name]}>...")
|
83
|
+
logger.info("Creating <#{volume[:name]}>...")
|
82
84
|
result = api.blockstorage.create_volume(volume_details(volume))
|
83
85
|
response = volume_response(result.data.id)
|
84
|
-
info("Finished creating <#{volume[:name]}>.")
|
86
|
+
logger.info("Finished creating <#{volume[:name]}>.")
|
85
87
|
[response, final_state(response)]
|
86
88
|
end
|
87
89
|
|
90
|
+
# Clones the specified volume.
|
91
|
+
#
|
92
|
+
# @param volume [Hash] the state of the current volume being cloned.
|
93
|
+
# @return [Array(OCI::Core::Models::Volume, Hash)] returns the actual volume response from OCI for the cloned volume and the state hash.
|
88
94
|
def create_clone_volume(volume)
|
89
95
|
clone_volume_name = clone_volume_display_name(volume[:volume_id])
|
90
|
-
info("Creating <#{clone_volume_name}>...")
|
96
|
+
logger.info("Creating <#{clone_volume_name}>...")
|
91
97
|
result = api.blockstorage.create_volume(volume_clone_details(volume, clone_volume_name))
|
92
98
|
response = volume_response(result.data.id)
|
93
|
-
info("Finished creating <#{clone_volume_name}>.")
|
99
|
+
logger.info("Finished creating <#{clone_volume_name}>.")
|
94
100
|
[response, final_state(response)]
|
95
101
|
end
|
96
102
|
|
103
|
+
# Attaches the volume to the instance.
|
104
|
+
#
|
105
|
+
# @param volume_details [OCI::Core::Models::Volume]
|
106
|
+
# @param server_id [String] the ocid of the compute instance we are attaching the volume to.
|
107
|
+
# @return [Hash] the updated state hash.
|
97
108
|
def attach_volume(volume_details, server_id, volume_config)
|
98
|
-
info("Attaching <#{volume_details.display_name}>...")
|
109
|
+
logger.info("Attaching <#{volume_details.display_name}>...")
|
99
110
|
attach_volume = api.compute.attach_volume(attachment_details(volume_details, server_id, volume_config))
|
100
111
|
response = attachment_response(attach_volume.data.id)
|
101
|
-
info("Finished attaching <#{volume_details.display_name}>.")
|
112
|
+
logger.info("Finished attaching <#{volume_details.display_name}>.")
|
102
113
|
final_state(response)
|
103
114
|
end
|
104
115
|
|
116
|
+
# Deletes the specified volume.
|
117
|
+
#
|
118
|
+
# @param volume [Hash] the state of the current volume being deleted from the state file.
|
105
119
|
def delete_volume(volume)
|
106
|
-
info("Deleting <#{volume[:display_name]}>...")
|
120
|
+
logger.info("Deleting <#{volume[:display_name]}>...")
|
107
121
|
api.blockstorage.delete_volume(volume[:id])
|
108
122
|
api.blockstorage.get_volume(volume[:id])
|
109
123
|
.wait_until(:lifecycle_state, OCI::Core::Models::Volume::LIFECYCLE_STATE_TERMINATED)
|
110
|
-
info("Finished deleting <#{volume[:display_name]}>.")
|
124
|
+
logger.info("Finished deleting <#{volume[:display_name]}>.")
|
111
125
|
end
|
112
126
|
|
127
|
+
# Detaches the specified volume.
|
128
|
+
#
|
129
|
+
# @param volume_attachment [Hash] the state of the current volume being deleted from the state file.
|
113
130
|
def detatch_volume(volume_attachment)
|
114
|
-
info("Detaching <#{attachment_name(volume_attachment)}>...")
|
131
|
+
logger.info("Detaching <#{attachment_name(volume_attachment)}>...")
|
115
132
|
api.compute.detach_volume(volume_attachment[:id])
|
116
133
|
api.compute.get_volume_attachment(volume_attachment[:id])
|
117
134
|
.wait_until(:lifecycle_state, OCI::Core::Models::VolumeAttachment::LIFECYCLE_STATE_DETACHED)
|
118
|
-
info("Finished detaching <#{attachment_name(volume_attachment)}>.")
|
135
|
+
logger.info("Finished detaching <#{attachment_name(volume_attachment)}>.")
|
119
136
|
end
|
120
137
|
|
138
|
+
# Adds the volume and attachment info into the state.
|
139
|
+
#
|
140
|
+
# @param response [OCI::Core::Models::Volume, OCI::Core::Models::VolumeAttachment] The response from volume creation or attachment.
|
141
|
+
# @return [Hash]
|
121
142
|
def final_state(response)
|
122
143
|
case response
|
123
144
|
when OCI::Core::Models::Volume
|
@@ -129,16 +150,26 @@ module Kitchen
|
|
129
150
|
|
130
151
|
private
|
131
152
|
|
153
|
+
# The response from creating a volume.
|
154
|
+
#
|
155
|
+
# @return [OCI::Core::Models::Volume]
|
132
156
|
def volume_response(volume_id)
|
133
157
|
api.blockstorage.get_volume(volume_id)
|
134
158
|
.wait_until(:lifecycle_state, OCI::Core::Models::Volume::LIFECYCLE_STATE_AVAILABLE).data
|
135
159
|
end
|
136
160
|
|
161
|
+
# The response from attaching a volume.
|
162
|
+
#
|
163
|
+
# @return [OCI::Core::Models::VolumeAttachment]
|
137
164
|
def attachment_response(attachment_id)
|
138
165
|
api.compute.get_volume_attachment(attachment_id)
|
139
166
|
.wait_until(:lifecycle_state, OCI::Core::Models::VolumeAttachment::LIFECYCLE_STATE_ATTACHED).data
|
140
167
|
end
|
141
168
|
|
169
|
+
# The details of the volume that is being created.
|
170
|
+
#
|
171
|
+
# @param volume [Hash] the state of the current volume being created.
|
172
|
+
# @return [OCI::Core::Models::CreateVolumeDetails]
|
142
173
|
def volume_details(volume)
|
143
174
|
OCI::Core::Models::CreateVolumeDetails.new(
|
144
175
|
compartment_id: oci.compartment,
|
@@ -150,6 +181,11 @@ module Kitchen
|
|
150
181
|
)
|
151
182
|
end
|
152
183
|
|
184
|
+
# The details of a volume that is being created as a clone of an existing volume.
|
185
|
+
#
|
186
|
+
# @param volume [Hash] the state of the current volume being cloned.
|
187
|
+
# @param clone_volume_name [String] the desired name of the new volume.
|
188
|
+
# @return [OCI::Core::Models::CreateVolumeDetails]
|
153
189
|
def volume_clone_details(volume, clone_volume_name)
|
154
190
|
OCI::Core::Models::CreateVolumeDetails.new(
|
155
191
|
compartment_id: oci.compartment,
|
@@ -162,21 +198,37 @@ module Kitchen
|
|
162
198
|
)
|
163
199
|
end
|
164
200
|
|
201
|
+
# Returns a somewhat prettier display name for the volume attachment.
|
202
|
+
#
|
203
|
+
# @param attachment [Hash] the state of the current volume attachment being created.
|
204
|
+
# @return [String]
|
165
205
|
def attachment_name(attachment)
|
166
206
|
attachment[:display_name].gsub(/(?:paravirtual|iscsi)-/, "")
|
167
207
|
end
|
168
208
|
|
209
|
+
# Returns the operating system from the instance.
|
210
|
+
#
|
211
|
+
# @param server_id [String] the ocid of the compute instance.
|
212
|
+
# @return [String]
|
169
213
|
def server_os(server_id)
|
170
214
|
image_id = api.compute.get_instance(server_id).data.image_id
|
171
215
|
api.compute.get_image(image_id).data.operating_system
|
172
216
|
end
|
173
217
|
|
218
|
+
# Adds the ocid and display name of the volume to the state.
|
219
|
+
#
|
220
|
+
# @param response [OCI::Core::Models::Volume]
|
221
|
+
# @return [Hash]
|
174
222
|
def final_volume_state(response)
|
175
223
|
volume_state.store(:id, response.id)
|
176
224
|
volume_state.store(:display_name, response.display_name)
|
177
225
|
volume_state
|
178
226
|
end
|
179
227
|
|
228
|
+
# Appends the (Clone) string to the display name of the block volume that is being cloned.
|
229
|
+
#
|
230
|
+
# @param volume_id [String] the ocid of the volume being cloned.
|
231
|
+
# @return [String] the display name of the cloned volume.
|
180
232
|
def clone_volume_display_name(volume_id)
|
181
233
|
"#{api.blockstorage.get_volume(volume_id).data.to_hash[:displayName]} (Clone)"
|
182
234
|
end
|
@@ -22,20 +22,23 @@ require_relative "api"
|
|
22
22
|
module Kitchen
|
23
23
|
module Driver
|
24
24
|
class Oci
|
25
|
-
# Config class that defines the oci config that will be used for the API calls
|
25
|
+
# Config class that defines the oci config that will be used for the API calls.
|
26
|
+
#
|
27
|
+
# @author Justin Steele <justin.steele@oracle.com>
|
26
28
|
class Config
|
27
29
|
def initialize(driver_config)
|
28
30
|
setup_driver_config(driver_config)
|
29
31
|
@config = oci_config
|
30
32
|
end
|
31
33
|
|
32
|
-
#
|
33
|
-
# The config used to authenticate to OCI
|
34
|
+
# The config used to authenticate to OCI.
|
34
35
|
#
|
35
36
|
# @return [OCI::Config]
|
36
|
-
#
|
37
37
|
attr_reader :config
|
38
38
|
|
39
|
+
# Creates a new instance of OCI::Config to be used to authenticate to OCI.
|
40
|
+
#
|
41
|
+
# @return [OCI::Config]
|
39
42
|
def oci_config
|
40
43
|
# OCI::Config is missing this
|
41
44
|
OCI::Config.class_eval { attr_accessor :security_token_file } if @driver_config[:use_token_auth]
|
@@ -46,6 +49,12 @@ module Kitchen
|
|
46
49
|
conf
|
47
50
|
end
|
48
51
|
|
52
|
+
# The ocid of the compartment where the Kitchen instance will be created.
|
53
|
+
# * If <b>compartment_id</b> is specified in the kitchen.yml, that will be returned.
|
54
|
+
# * If <b>compartment_name</b> is specified in the kitchen.yml, lookup with the Identity API to find the ocid by the compartment name.
|
55
|
+
#
|
56
|
+
# @return [String] the ocid of the compartment where instances will be created.
|
57
|
+
# @raise [StandardError] if neither <b>compartment_id</b> nor <b>compartment_name</b> are specified OR if lookup by name fails to find a match.
|
49
58
|
def compartment
|
50
59
|
@compartment ||= @compartment_id
|
51
60
|
return @compartment if @compartment
|
@@ -58,12 +67,19 @@ module Kitchen
|
|
58
67
|
|
59
68
|
private
|
60
69
|
|
70
|
+
# Sets up instance variables from the driver config (parsed kitchen.yml) and compartment.
|
71
|
+
#
|
72
|
+
# @param config [Hash] the parsed config from the kitchen.yml.
|
61
73
|
def setup_driver_config(config)
|
62
74
|
@driver_config = config
|
63
75
|
@compartment_id = config[:compartment_id]
|
64
76
|
@compartment_name = config[:compartment_name]
|
65
77
|
end
|
66
78
|
|
79
|
+
# Creates a new instance of OCI::Config either by loading the config from a file or returning a new instance that will be set.
|
80
|
+
#
|
81
|
+
# @param opts [Hash]
|
82
|
+
# @return [OCI::Config]
|
67
83
|
def config_loader(opts = {})
|
68
84
|
# this is to accommodate old versions of ruby that do not have a compact method on a Hash
|
69
85
|
opts.reject! { |_, v| v.nil? }
|
@@ -72,6 +88,9 @@ module Kitchen
|
|
72
88
|
OCI::Config.new
|
73
89
|
end
|
74
90
|
|
91
|
+
# Returns the ocid of the tenancy from either the provided ocid or from your instance principals.
|
92
|
+
#
|
93
|
+
# @return [String]
|
75
94
|
def tenancy
|
76
95
|
if @driver_config[:use_instance_principals]
|
77
96
|
sign = OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner.new
|
@@ -81,11 +100,17 @@ module Kitchen
|
|
81
100
|
end
|
82
101
|
end
|
83
102
|
|
103
|
+
# Looks up the compartment ocid by name by recursively querying the list of compartments with the Identity API.
|
104
|
+
#
|
105
|
+
# @return [String] the ocid of the compartment.
|
84
106
|
def compartment_id_by_name(name)
|
85
107
|
api = Oci::Api.new(config, @driver_config).identity
|
86
108
|
all_compartments(api, config.tenancy).select { |c| c.name == name }&.first&.id
|
87
109
|
end
|
88
110
|
|
111
|
+
# Pages through all of the compartments in the tenancy. This has to be a recursive process because the list_compartments API only returns 99 entries at a time.
|
112
|
+
#
|
113
|
+
# @return [Array] An array of OCI::Identity::Models::Compartment
|
89
114
|
def all_compartments(api, tenancy, compartments = [], page = nil)
|
90
115
|
current_compartments = api.list_compartments(tenancy, page: page)
|
91
116
|
next_page = current_compartments.next_page
|
@@ -20,24 +20,31 @@ module Kitchen
|
|
20
20
|
module Driver
|
21
21
|
class Oci
|
22
22
|
class Instance
|
23
|
-
#
|
23
|
+
# Setter methods that populate launch details common to all instance models.
|
24
|
+
#
|
25
|
+
# @author Justin Steele <justin.steele@oracle.com>
|
24
26
|
module CommonLaunchDetails
|
27
|
+
# Assigns the ocid of the compartment to the launch details.
|
25
28
|
def compartment_id
|
26
29
|
launch_details.compartment_id = oci.compartment
|
27
30
|
end
|
28
31
|
|
32
|
+
# Assigns the availability_domain to the launch details.
|
29
33
|
def availability_domain
|
30
34
|
launch_details.availability_domain = config[:availability_domain]
|
31
35
|
end
|
32
36
|
|
37
|
+
# Assigns the defined_tags to the launch details.
|
33
38
|
def defined_tags
|
34
39
|
launch_details.defined_tags = config[:defined_tags]
|
35
40
|
end
|
36
41
|
|
42
|
+
# Assigns the shape to the launch_details.
|
37
43
|
def shape
|
38
44
|
launch_details.shape = config[:shape]
|
39
45
|
end
|
40
46
|
|
47
|
+
# Assigns the freeform_tags to the launch_details.
|
41
48
|
def freeform_tags
|
42
49
|
launch_details.freeform_tags = process_freeform_tags
|
43
50
|
end
|
@@ -46,4 +53,3 @@ module Kitchen
|
|
46
53
|
end
|
47
54
|
end
|
48
55
|
end
|
49
|
-
|
@@ -20,14 +20,20 @@ module Kitchen
|
|
20
20
|
module Driver
|
21
21
|
class Oci
|
22
22
|
class Instance
|
23
|
-
#
|
23
|
+
# Setter methods that populate the details of OCI::Core::Models::LaunchInstanceDetails.
|
24
|
+
#
|
25
|
+
# @author Justin Steele <justin.steele@oracle.com>
|
24
26
|
module ComputeLaunchDetails
|
27
|
+
# Assigns the display_name and create_vnic_details to the launch_details.
|
28
|
+
# * display_name is either the literal display_name provided in the kitchen config or a randomly generated one.
|
29
|
+
# * create_vnic_details is a populated instance of OCI::Core::Models::CreateVnicDetails.
|
25
30
|
def hostname_display_name
|
26
31
|
display_name = config[:display_name] || hostname
|
27
32
|
launch_details.display_name = display_name
|
28
33
|
launch_details.create_vnic_details = create_vnic_details(display_name)
|
29
34
|
end
|
30
35
|
|
36
|
+
# Adds the preemptible_instance_config property tot he launch_details by creating a new instance of OCI::Core::Models::PreemptibleInstanceConfigDetails.
|
31
37
|
def preemptible_instance_config
|
32
38
|
return unless config[:preemptible_instance]
|
33
39
|
|
@@ -39,6 +45,7 @@ module Kitchen
|
|
39
45
|
)
|
40
46
|
end
|
41
47
|
|
48
|
+
# Adds the shape_config property to the launch_details by creating a new instance of OCI::Core::Models::LaunchInstanceShapeConfigDetails.
|
42
49
|
def shape_config
|
43
50
|
return if config[:shape_config].empty?
|
44
51
|
|
@@ -49,10 +56,12 @@ module Kitchen
|
|
49
56
|
)
|
50
57
|
end
|
51
58
|
|
59
|
+
# Adds the capacity_reservation_id property to the launch_details if an ocid is provided.
|
52
60
|
def capacity_reservation
|
53
61
|
launch_details.capacity_reservation_id = config[:capacity_reservation_id]
|
54
62
|
end
|
55
63
|
|
64
|
+
# Adds the agent_config property to the launch_details.
|
56
65
|
def agent_config
|
57
66
|
launch_details.agent_config = OCI::Core::Models::LaunchInstanceAgentConfigDetails.new(
|
58
67
|
are_all_plugins_disabled: config[:all_plugins_disabled],
|
@@ -61,6 +70,7 @@ module Kitchen
|
|
61
70
|
)
|
62
71
|
end
|
63
72
|
|
73
|
+
# Adds the source_details property to the launch_details for an instance that is being created from an image.
|
64
74
|
def instance_source_via_image
|
65
75
|
return if config[:boot_volume_id]
|
66
76
|
|
@@ -71,6 +81,7 @@ module Kitchen
|
|
71
81
|
)
|
72
82
|
end
|
73
83
|
|
84
|
+
# Adds the source_details property to the launch_details for an instance that is being created from a boot volume.
|
74
85
|
def instance_source_via_boot_volume
|
75
86
|
return unless config[:boot_volume_id]
|
76
87
|
|
@@ -80,6 +91,7 @@ module Kitchen
|
|
80
91
|
)
|
81
92
|
end
|
82
93
|
|
94
|
+
# Adds the metadata property to the launch_details.
|
83
95
|
def instance_metadata
|
84
96
|
launch_details.metadata = metadata
|
85
97
|
end
|
@@ -20,39 +20,49 @@ module Kitchen
|
|
20
20
|
module Driver
|
21
21
|
class Oci
|
22
22
|
class Instance
|
23
|
-
#
|
23
|
+
# Setter methods that populate the details of OCI::Database::Models::CreateDatabaseDetails.
|
24
|
+
#
|
25
|
+
# @author Justin Steele <justin.steele@oracle.com>
|
24
26
|
module DatabaseDetails
|
27
|
+
# Adds the database_software_image_id property to the database_details if provided.
|
25
28
|
def database_software_image
|
26
29
|
return unless config[:dbaas][:db_software_image_id]
|
27
30
|
|
28
31
|
database_details.database_software_image_id = config[:dbaas][:db_software_image_id]
|
29
32
|
end
|
30
33
|
|
34
|
+
# Adds the character_set property to the database_details.
|
31
35
|
def character_set
|
32
36
|
database_details.character_set = config[:dbaas][:character_set] ||= "AL32UTF8"
|
33
37
|
end
|
34
38
|
|
39
|
+
# Adds the ncharacter_set property to the database_details.
|
35
40
|
def ncharacter_set
|
36
41
|
database_details.ncharacter_set = config[:dbaas][:ncharacter_set] ||= "AL16UTF16"
|
37
42
|
end
|
38
43
|
|
44
|
+
# Adds the db_workload property to the database details.
|
39
45
|
def db_workload
|
40
46
|
workload = config[:dbaas][:db_workload] ||= OCI::Database::Models::CreateDatabaseDetails::DB_WORKLOAD_OLTP
|
41
47
|
database_details.db_workload = workload
|
42
48
|
end
|
43
49
|
|
50
|
+
# Adds the admin_password property to the database details.
|
44
51
|
def admin_password
|
45
52
|
database_details.admin_password = config[:dbaas][:admin_password] ||= random_password(%w{# _ -})
|
46
53
|
end
|
47
54
|
|
55
|
+
# Adds the db_name property to the database_details.
|
48
56
|
def db_name
|
49
57
|
database_details.db_name = config[:dbaas][:db_name] ||= "dbaas1"
|
50
58
|
end
|
51
59
|
|
60
|
+
# Adds the pdb_name property to the database_details.
|
52
61
|
def pdb_name
|
53
62
|
database_details.pdb_name = config[:dbaas][:pdb_name]
|
54
63
|
end
|
55
64
|
|
65
|
+
# Adds the db_backup_config property to the database_details by creating a new instance of OCI::Database::Models::DbBackupConfig.
|
56
66
|
def db_backup_config
|
57
67
|
database_details.db_backup_config = OCI::Database::Models::DbBackupConfig.new.tap do |l|
|
58
68
|
l.auto_backup_enabled = false
|
@@ -60,6 +70,7 @@ module Kitchen
|
|
60
70
|
database_details
|
61
71
|
end
|
62
72
|
|
73
|
+
# Adds the defined tags property to the database_details.
|
63
74
|
def db_defined_tags
|
64
75
|
database_details.defined_tags = config[:defined_tags]
|
65
76
|
end
|
@@ -20,28 +20,36 @@ module Kitchen
|
|
20
20
|
module Driver
|
21
21
|
class Oci
|
22
22
|
class Instance
|
23
|
-
#
|
23
|
+
# Setter methods that populate the details of OCI::Database::Models::CreateDbHomeDetails.
|
24
|
+
#
|
25
|
+
# @author Justin Steele <justin.steele@oracle.com>
|
24
26
|
module DbHomeDetails
|
27
|
+
# Adds the database property to the db_home_details.
|
25
28
|
def database
|
26
29
|
db_home_details.database = database_details
|
27
30
|
end
|
28
31
|
|
32
|
+
# Adds the db_version property to the db_home_details.
|
33
|
+
# @raise [StandardError] if a version has not been provided.
|
29
34
|
def db_version
|
30
35
|
raise "db_version cannot be nil!" if config[:dbaas][:db_version].nil?
|
31
36
|
|
32
37
|
db_home_details.db_version = config[:dbaas][:db_version]
|
33
38
|
end
|
34
39
|
|
40
|
+
# Adds the display_name property to db_home_details.
|
35
41
|
def db_home_display_name
|
36
42
|
db_home_details.display_name = ["dbhome", random_number(10)].compact.join
|
37
43
|
end
|
38
44
|
|
45
|
+
# Adds the database_software_image_id to the db_home_details.
|
39
46
|
def db_home_software_image
|
40
47
|
return unless config[:dbaas][:db_software_image_id]
|
41
48
|
|
42
49
|
db_home_details.database_software_image_id = config[:dbaas][:db_software_image_id]
|
43
50
|
end
|
44
51
|
|
52
|
+
# Adds the defined_tags to the db_home_details.
|
45
53
|
def db_home_defined_tags
|
46
54
|
db_home_details.defined_tags = config[:defined_tags]
|
47
55
|
end
|