kitchen-oci 1.26.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 +64 -20
- 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 +21 -6
- data/lib/kitchen/driver/oci/instance.rb +63 -17
- 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 +76 -7
- data/lib/kitchen/driver/oci/models/dbaas.rb +28 -11
- data/lib/kitchen/driver/oci/models/iscsi.rb +14 -4
- data/lib/kitchen/driver/oci/models/paravirtual.rb +14 -4
- data/lib/kitchen/driver/oci.rb +21 -46
- data/lib/kitchen/driver/oci_version.rb +3 -1
- metadata +26 -5
- data/lib/kitchen/driver/oci/models.rb +0 -48
- data/lib/kitchen/driver/oci/volumes.rb +0 -54
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,7 +19,9 @@
|
|
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"
|
@@ -38,53 +40,45 @@ module Kitchen
|
|
38
40
|
oci.compartment if opts[:action] == :create
|
39
41
|
end
|
40
42
|
|
41
|
-
#
|
42
|
-
# The config provided by the driver
|
43
|
+
# The config provided by the driver.
|
43
44
|
#
|
44
45
|
# @return [Kitchen::LazyHash]
|
45
|
-
#
|
46
46
|
attr_accessor :config
|
47
47
|
|
48
|
-
#
|
49
|
-
# The definition of the state of the instance from the statefile
|
48
|
+
# The definition of the state of the instance from the statefile.
|
50
49
|
#
|
51
50
|
# @return [Hash]
|
52
|
-
#
|
53
51
|
attr_accessor :state
|
54
52
|
|
55
|
-
#
|
56
|
-
# The config object that contains properties of the authentication to OCI
|
53
|
+
# The config object that contains properties of the authentication to OCI.
|
57
54
|
#
|
58
55
|
# @return [Kitchen::Driver::Oci::Config]
|
59
|
-
#
|
60
56
|
attr_accessor :oci
|
61
57
|
|
62
|
-
#
|
63
|
-
# 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.
|
64
59
|
#
|
65
60
|
# @return [Kitchen::Driver::Oci::Api]
|
66
|
-
#
|
67
61
|
attr_accessor :api
|
68
62
|
|
69
|
-
#
|
70
|
-
# The instance of Kitchen::Logger in use by the active Kitchen::Instance
|
63
|
+
# The instance of Kitchen::Logger in use by the active Kitchen::Instance.
|
71
64
|
#
|
72
65
|
# @return [Kitchen::Logger]
|
73
|
-
#
|
74
66
|
attr_accessor :logger
|
75
67
|
|
76
|
-
# The definition of the state of a volume
|
68
|
+
# The definition of the state of a volume.
|
77
69
|
#
|
78
70
|
# @return [Hash]
|
79
|
-
#
|
80
71
|
attr_accessor :volume_state
|
81
72
|
|
82
|
-
# The definition of the state of a volume attachment
|
73
|
+
# The definition of the state of a volume attachment.
|
83
74
|
#
|
84
75
|
# @return [Hash]
|
85
|
-
#
|
86
76
|
attr_accessor :volume_attachment_state
|
87
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.
|
88
82
|
def create_volume(volume)
|
89
83
|
logger.info("Creating <#{volume[:name]}>...")
|
90
84
|
result = api.blockstorage.create_volume(volume_details(volume))
|
@@ -93,6 +87,10 @@ module Kitchen
|
|
93
87
|
[response, final_state(response)]
|
94
88
|
end
|
95
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.
|
96
94
|
def create_clone_volume(volume)
|
97
95
|
clone_volume_name = clone_volume_display_name(volume[:volume_id])
|
98
96
|
logger.info("Creating <#{clone_volume_name}>...")
|
@@ -102,6 +100,11 @@ module Kitchen
|
|
102
100
|
[response, final_state(response)]
|
103
101
|
end
|
104
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.
|
105
108
|
def attach_volume(volume_details, server_id, volume_config)
|
106
109
|
logger.info("Attaching <#{volume_details.display_name}>...")
|
107
110
|
attach_volume = api.compute.attach_volume(attachment_details(volume_details, server_id, volume_config))
|
@@ -110,6 +113,9 @@ module Kitchen
|
|
110
113
|
final_state(response)
|
111
114
|
end
|
112
115
|
|
116
|
+
# Deletes the specified volume.
|
117
|
+
#
|
118
|
+
# @param volume [Hash] the state of the current volume being deleted from the state file.
|
113
119
|
def delete_volume(volume)
|
114
120
|
logger.info("Deleting <#{volume[:display_name]}>...")
|
115
121
|
api.blockstorage.delete_volume(volume[:id])
|
@@ -118,6 +124,9 @@ module Kitchen
|
|
118
124
|
logger.info("Finished deleting <#{volume[:display_name]}>.")
|
119
125
|
end
|
120
126
|
|
127
|
+
# Detaches the specified volume.
|
128
|
+
#
|
129
|
+
# @param volume_attachment [Hash] the state of the current volume being deleted from the state file.
|
121
130
|
def detatch_volume(volume_attachment)
|
122
131
|
logger.info("Detaching <#{attachment_name(volume_attachment)}>...")
|
123
132
|
api.compute.detach_volume(volume_attachment[:id])
|
@@ -126,6 +135,10 @@ module Kitchen
|
|
126
135
|
logger.info("Finished detaching <#{attachment_name(volume_attachment)}>.")
|
127
136
|
end
|
128
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]
|
129
142
|
def final_state(response)
|
130
143
|
case response
|
131
144
|
when OCI::Core::Models::Volume
|
@@ -137,16 +150,26 @@ module Kitchen
|
|
137
150
|
|
138
151
|
private
|
139
152
|
|
153
|
+
# The response from creating a volume.
|
154
|
+
#
|
155
|
+
# @return [OCI::Core::Models::Volume]
|
140
156
|
def volume_response(volume_id)
|
141
157
|
api.blockstorage.get_volume(volume_id)
|
142
158
|
.wait_until(:lifecycle_state, OCI::Core::Models::Volume::LIFECYCLE_STATE_AVAILABLE).data
|
143
159
|
end
|
144
160
|
|
161
|
+
# The response from attaching a volume.
|
162
|
+
#
|
163
|
+
# @return [OCI::Core::Models::VolumeAttachment]
|
145
164
|
def attachment_response(attachment_id)
|
146
165
|
api.compute.get_volume_attachment(attachment_id)
|
147
166
|
.wait_until(:lifecycle_state, OCI::Core::Models::VolumeAttachment::LIFECYCLE_STATE_ATTACHED).data
|
148
167
|
end
|
149
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]
|
150
173
|
def volume_details(volume)
|
151
174
|
OCI::Core::Models::CreateVolumeDetails.new(
|
152
175
|
compartment_id: oci.compartment,
|
@@ -158,6 +181,11 @@ module Kitchen
|
|
158
181
|
)
|
159
182
|
end
|
160
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]
|
161
189
|
def volume_clone_details(volume, clone_volume_name)
|
162
190
|
OCI::Core::Models::CreateVolumeDetails.new(
|
163
191
|
compartment_id: oci.compartment,
|
@@ -170,21 +198,37 @@ module Kitchen
|
|
170
198
|
)
|
171
199
|
end
|
172
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]
|
173
205
|
def attachment_name(attachment)
|
174
206
|
attachment[:display_name].gsub(/(?:paravirtual|iscsi)-/, "")
|
175
207
|
end
|
176
208
|
|
209
|
+
# Returns the operating system from the instance.
|
210
|
+
#
|
211
|
+
# @param server_id [String] the ocid of the compute instance.
|
212
|
+
# @return [String]
|
177
213
|
def server_os(server_id)
|
178
214
|
image_id = api.compute.get_instance(server_id).data.image_id
|
179
215
|
api.compute.get_image(image_id).data.operating_system
|
180
216
|
end
|
181
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]
|
182
222
|
def final_volume_state(response)
|
183
223
|
volume_state.store(:id, response.id)
|
184
224
|
volume_state.store(:display_name, response.display_name)
|
185
225
|
volume_state
|
186
226
|
end
|
187
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.
|
188
232
|
def clone_volume_display_name(volume_id)
|
189
233
|
"#{api.blockstorage.get_volume(volume_id).data.to_hash[:displayName]} (Clone)"
|
190
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
|