kitchen-oci 1.9.0 → 1.11.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ac8fb8a6a0caaf9b86de1a6178009101fa642e4c6912acb6774fde2f664ae26
4
- data.tar.gz: 4a635fbcff0cec7a548709f65e780fe24628733b61441f6feafdf9e988900166
3
+ metadata.gz: 8f75760b2f60bf730fd95a92c2168cbf2323b92527dba60dd68dd12c4fa3856f
4
+ data.tar.gz: cd36c7e116e0bad6b37b51b0d37193c4a660dc3d29c5e3bd2365753c52ce59aa
5
5
  SHA512:
6
- metadata.gz: 96e29112bec4d1f0dad5fbbe46e9accf959b27c63b6ca86e81bb32f9e89e7f646aaf720b7185072f9d9c04f45681172d0e6f5bfd14b212fbeee4e87cd9f6cc3f
7
- data.tar.gz: cc7f3a9dce9e3b7470ba8480551baa908e0b3880e5a17bfbceec0b0cdea9f2c6c7d9191438b4dbd0248416954d2bd26021748b9148be1c055c477b60448a5dcc
6
+ metadata.gz: 4831c6af3af0244569f6197392e2ab07a570e31be2a950b3e2c4fe36d502892c426839cab79b27e88013102229fcbf13733b809577d85f81be1841cdc9c184b6
7
+ data.tar.gz: 547b9d645e83164eb3a12df3e3cb0ea06aeec8c8c715f8b58b9be7c185002e91031e1185ba4d1fdf7c505d1cef15de0a51dfb1c1a6959010a908ebc4d22e4838
@@ -0,0 +1,5 @@
1
+ Layout/LineLength:
2
+ Max : 150
3
+
4
+ Style/NumericLiterals:
5
+ Enabled : false
@@ -1,4 +1,23 @@
1
1
 
2
+ ## 1.11.2
3
+ - Set dependency on oci gem to 2.10.0
4
+
5
+ ## 1.11.1
6
+ - Removed characters from password string known to break winrm
7
+
8
+ ## 1.11.0
9
+ - Added support for user_data raw string
10
+
11
+ ## 1.10.1 Issue 22
12
+ - Added safeguard for cluster_name length restriction in DBaaS.
13
+
14
+ ## 1.10.0 DBaaS support
15
+ - Added support for DBaaS.
16
+ - instance_type is new optional parameter (compute or dbaas)
17
+
18
+ ## 1.9.0 Use instance principals
19
+ - Added support for `use_instance_principals`
20
+
2
21
  ## 1.8.0 Freeform tags
3
22
  - Added optional parameter `freeform_tags`
4
23
 
@@ -10,4 +29,3 @@
10
29
  - Added cloud-init support.
11
30
  - Added support for Windows targets.
12
31
  - Can inject powershell script to set a random password and enable WinRM
13
-
data/Gemfile CHANGED
@@ -1,5 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Copyright 2020 Stephen Pearson <stephen.pearson@oracle.com>
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
3
17
  source 'https://rubygems.org'
4
18
 
5
19
  gemspec
data/LICENSE CHANGED
@@ -1,15 +1,182 @@
1
1
  Author:: Stephen Pearson (<stephen.pearson@oracle.com>)
2
2
 
3
- Copyright (C) 2019, Stephen Pearson
3
+ Copyright (C) 2020, Stephen Pearson
4
4
 
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
5
 
9
- http://www.apache.org/licenses/LICENSE-2.0
10
6
 
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
7
+ Apache License
8
+ Version 2.0, January 2004
9
+ http://www.apache.org/licenses/
10
+
11
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
12
+
13
+ 1. Definitions.
14
+
15
+ "License" shall mean the terms and conditions for use, reproduction,
16
+ and distribution as defined by Sections 1 through 9 of this document.
17
+
18
+ "Licensor" shall mean the copyright owner or entity authorized by
19
+ the copyright owner that is granting the License.
20
+
21
+ "Legal Entity" shall mean the union of the acting entity and all
22
+ other entities that control, are controlled by, or are under common
23
+ control with that entity. For the purposes of this definition,
24
+ "control" means (i) the power, direct or indirect, to cause the
25
+ direction or management of such entity, whether by contract or
26
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
27
+ outstanding shares, or (iii) beneficial ownership of such entity.
28
+
29
+ "You" (or "Your") shall mean an individual or Legal Entity
30
+ exercising permissions granted by this License.
31
+
32
+ "Source" form shall mean the preferred form for making modifications,
33
+ including but not limited to software source code, documentation
34
+ source, and configuration files.
35
+
36
+ "Object" form shall mean any form resulting from mechanical
37
+ transformation or translation of a Source form, including but
38
+ not limited to compiled object code, generated documentation,
39
+ and conversions to other media types.
40
+
41
+ "Work" shall mean the work of authorship, whether in Source or
42
+ Object form, made available under the License, as indicated by a
43
+ copyright notice that is included in or attached to the work
44
+ (an example is provided in the Appendix below).
45
+
46
+ "Derivative Works" shall mean any work, whether in Source or Object
47
+ form, that is based on (or derived from) the Work and for which the
48
+ editorial revisions, annotations, elaborations, or other modifications
49
+ represent, as a whole, an original work of authorship. For the purposes
50
+ of this License, Derivative Works shall not include works that remain
51
+ separable from, or merely link (or bind by name) to the interfaces of,
52
+ the Work and Derivative Works thereof.
53
+
54
+ "Contribution" shall mean any work of authorship, including
55
+ the original version of the Work and any modifications or additions
56
+ to that Work or Derivative Works thereof, that is intentionally
57
+ submitted to Licensor for inclusion in the Work by the copyright owner
58
+ or by an individual or Legal Entity authorized to submit on behalf of
59
+ the copyright owner. For the purposes of this definition, "submitted"
60
+ means any form of electronic, verbal, or written communication sent
61
+ to the Licensor or its representatives, including but not limited to
62
+ communication on electronic mailing lists, source code control systems,
63
+ and issue tracking systems that are managed by, or on behalf of, the
64
+ Licensor for the purpose of discussing and improving the Work, but
65
+ excluding communication that is conspicuously marked or otherwise
66
+ designated in writing by the copyright owner as "Not a Contribution."
67
+
68
+ "Contributor" shall mean Licensor and any individual or Legal Entity
69
+ on behalf of whom a Contribution has been received by Licensor and
70
+ subsequently incorporated within the Work.
71
+
72
+ 2. Grant of Copyright License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ copyright license to reproduce, prepare Derivative Works of,
76
+ publicly display, publicly perform, sublicense, and distribute the
77
+ Work and such Derivative Works in Source or Object form.
78
+
79
+ 3. Grant of Patent License. Subject to the terms and conditions of
80
+ this License, each Contributor hereby grants to You a perpetual,
81
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
82
+ (except as stated in this section) patent license to make, have made,
83
+ use, offer to sell, sell, import, and otherwise transfer the Work,
84
+ where such license applies only to those patent claims licensable
85
+ by such Contributor that are necessarily infringed by their
86
+ Contribution(s) alone or by combination of their Contribution(s)
87
+ with the Work to which such Contribution(s) was submitted. If You
88
+ institute patent litigation against any entity (including a
89
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
90
+ or a Contribution incorporated within the Work constitutes direct
91
+ or contributory patent infringement, then any patent licenses
92
+ granted to You under this License for that Work shall terminate
93
+ as of the date such litigation is filed.
94
+
95
+ 4. Redistribution. You may reproduce and distribute copies of the
96
+ Work or Derivative Works thereof in any medium, with or without
97
+ modifications, and in Source or Object form, provided that You
98
+ meet the following conditions:
99
+
100
+ (a) You must give any other recipients of the Work or
101
+ Derivative Works a copy of this License; and
102
+
103
+ (b) You must cause any modified files to carry prominent notices
104
+ stating that You changed the files; and
105
+
106
+ (c) You must retain, in the Source form of any Derivative Works
107
+ that You distribute, all copyright, patent, trademark, and
108
+ attribution notices from the Source form of the Work,
109
+ excluding those notices that do not pertain to any part of
110
+ the Derivative Works; and
111
+
112
+ (d) If the Work includes a "NOTICE" text file as part of its
113
+ distribution, then any Derivative Works that You distribute must
114
+ include a readable copy of the attribution notices contained
115
+ within such NOTICE file, excluding those notices that do not
116
+ pertain to any part of the Derivative Works, in at least one
117
+ of the following places: within a NOTICE text file distributed
118
+ as part of the Derivative Works; within the Source form or
119
+ documentation, if provided along with the Derivative Works; or,
120
+ within a display generated by the Derivative Works, if and
121
+ wherever such third-party notices normally appear. The contents
122
+ of the NOTICE file are for informational purposes only and
123
+ do not modify the License. You may add Your own attribution
124
+ notices within Derivative Works that You distribute, alongside
125
+ or as an addendum to the NOTICE text from the Work, provided
126
+ that such additional attribution notices cannot be construed
127
+ as modifying the License.
128
+
129
+ You may add Your own copyright statement to Your modifications and
130
+ may provide additional or different license terms and conditions
131
+ for use, reproduction, or distribution of Your modifications, or
132
+ for any such Derivative Works as a whole, provided Your use,
133
+ reproduction, and distribution of the Work otherwise complies with
134
+ the conditions stated in this License.
135
+
136
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
137
+ any Contribution intentionally submitted for inclusion in the Work
138
+ by You to the Licensor shall be under the terms and conditions of
139
+ this License, without any additional terms or conditions.
140
+ Notwithstanding the above, nothing herein shall supersede or modify
141
+ the terms of any separate license agreement you may have executed
142
+ with Licensor regarding such Contributions.
143
+
144
+ 6. Trademarks. This License does not grant permission to use the trade
145
+ names, trademarks, service marks, or product names of the Licensor,
146
+ except as required for reasonable and customary use in describing the
147
+ origin of the Work and reproducing the content of the NOTICE file.
148
+
149
+ 7. Disclaimer of Warranty. Unless required by applicable law or
150
+ agreed to in writing, Licensor provides the Work (and each
151
+ Contributor provides its Contributions) on an "AS IS" BASIS,
152
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
153
+ implied, including, without limitation, any warranties or conditions
154
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
155
+ PARTICULAR PURPOSE. You are solely responsible for determining the
156
+ appropriateness of using or redistributing the Work and assume any
157
+ risks associated with Your exercise of permissions under this License.
158
+
159
+ 8. Limitation of Liability. In no event and under no legal theory,
160
+ whether in tort (including negligence), contract, or otherwise,
161
+ unless required by applicable law (such as deliberate and grossly
162
+ negligent acts) or agreed to in writing, shall any Contributor be
163
+ liable to You for damages, including any direct, indirect, special,
164
+ incidental, or consequential damages of any character arising as a
165
+ result of this License or out of the use or inability to use the
166
+ Work (including but not limited to damages for loss of goodwill,
167
+ work stoppage, computer failure or malfunction, or any and all
168
+ other commercial damages or losses), even if such Contributor
169
+ has been advised of the possibility of such damages.
170
+
171
+ 9. Accepting Warranty or Additional Liability. While redistributing
172
+ the Work or Derivative Works thereof, You may choose to offer,
173
+ and charge a fee for, acceptance of support, warranty, indemnity,
174
+ or other liability obligations and/or rights consistent with this
175
+ License. However, in accepting such obligations, You may act only
176
+ on Your own behalf and on Your sole responsibility, not on behalf
177
+ of any other Contributor, and only if You agree to indemnify,
178
+ defend, and hold each Contributor harmless for any liability
179
+ incurred by, or claims asserted against, such Contributor by reason
180
+ of your accepting any such warranty or additional liability.
181
+
182
+ END OF TERMS AND CONDITIONS
data/NOTICE ADDED
@@ -0,0 +1,96 @@
1
+ LICENSING INFORMATION
2
+ ---------------------
3
+
4
+ This code has dependencies upon oci-ruby-sdk and Chef Kitchen
5
+
6
+ oci-ruby-sdk: https://github.com/oracle/oci-ruby-sdk (Universal Permissive License, or Apache License 2.0)
7
+ chef-dk : https://github.com/chef/chef-dk (Apache License 2.0)
8
+
9
+ LICENSES
10
+ --------
11
+
12
+ Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
13
+
14
+ This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 or Apache License 2.0. See below for license terms. You may choose either license.
15
+ ____________________________
16
+ The Universal Permissive License (UPL), Version 1.0
17
+ Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
18
+
19
+ Subject to the condition set forth below, permission is hereby granted to any person obtaining a copy of this software, associated documentation and/or data (collectively the "Software"), free of charge and under any and all copyright rights in the Software, and any and all patent rights owned or freely licensable by each licensor hereunder covering either (i) the unmodified Software as contributed to or provided by such licensor, or (ii) the Larger Works (as defined below), to deal in both
20
+
21
+ (a) the Software, and
22
+ (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if one is included with the Software (each a "Larger Work" to which the Software is contributed by such licensors),
23
+
24
+ without restriction, including without limitation the rights to copy, create derivative works of, display, perform, and distribute the Software and make, use, sell, offer for sale, import, export, have made, and have sold the Software and the Larger Work(s), and to sublicense the foregoing rights on either these or other terms.
25
+
26
+ This license is subject to the following condition:
27
+
28
+ The above copyright notice and either this complete permission notice or at a minimum a reference to the UPL must be included in all copies or substantial portions of the Software.
29
+
30
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
+
32
+ The Apache Software License, Version 2.0
33
+ Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
34
+
35
+ Licensed under the Apache License, Version 2.0 (the "License"); You may not use this product except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
36
+
37
+ Apache License
38
+
39
+ Version 2.0, January 2004
40
+
41
+ http://www.apache.org/licenses/
42
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
43
+ 1. Definitions.
44
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
45
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
46
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
47
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
48
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
49
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
50
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
51
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
52
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
53
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
55
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
56
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
57
+ You must give any other recipients of the Work or Derivative Works a copy of this License; and
58
+ You must cause any modified files to carry prominent notices stating that You changed the files; and
59
+ You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
60
+ If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
61
+
62
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
63
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
64
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
65
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
66
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
67
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
68
+ END OF TERMS AND CONDITIONS
69
+
70
+ APPENDIX: How to apply the Apache License to your work.
71
+
72
+ To apply the Apache License to your work, attach the following
73
+ boilerplate notice, with the fields enclosed by brackets "[]"
74
+ replaced with your own identifying information. (Don't include
75
+ the brackets!) The text should be enclosed in the appropriate
76
+ comment syntax for the file format. We also recommend that a
77
+ file or class name and description of purpose be included on the
78
+ same "printed page" as the copyright notice for easier
79
+ identification within third-party archives.
80
+
81
+ Copyright [yyyy] [name of copyright owner]
82
+
83
+ Licensed under the Apache License, Version 2.0 (the "License");
84
+ you may not use this file except in compliance with the License.
85
+ You may obtain a copy of the License at
86
+
87
+ http://www.apache.org/licenses/LICENSE-2.0
88
+
89
+ Unless required by applicable law or agreed to in writing, software
90
+ distributed under the License is distributed on an "AS IS" BASIS,
91
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
92
+ See the License for the specific language governing permissions and
93
+ limitations under the License.
94
+
95
+
96
+
data/README.md CHANGED
@@ -51,79 +51,100 @@ gem install pkg/kitchen-oci-<VERSION>.gem
51
51
 
52
52
  ## Example .kitchen.yml
53
53
 
54
- Adjust below template as required. The following configuration is mandatory:
54
+ Adjust below template as required. The following configuration is mandatory for all instance types:
55
55
 
56
- - compartment\_id
57
- - availability\_domain
58
- - image\_id
59
- - shape
60
- - subnet\_id
56
+ - `compartment_id`
57
+ - `availability_domain`
58
+ - `shape`
59
+ - `subnet_id`
60
+
61
+ There is an additional configuration item that allows for toggling instance types. If this item is not included, it defaults to `compute`.
62
+
63
+ - Permitted values of `instance_type`:
64
+ - compute
65
+ - dbaas
61
66
 
62
67
  Note: The availability domain should be the full AD name including the tenancy specific prefix. For example: "AaBb:US-ASHBURN-AD-1". Look in the OCI console to get your tenancy specific string.
63
68
 
69
+ ### Compute Instance Type
70
+
71
+ The following configuration is mandatory:
72
+
73
+ - `image_id`
74
+
64
75
  These settings are optional:
65
76
 
66
- - use\_private\_ip, Whether to connect to the instance using a private IP, default is false (public ip)
67
- - oci\_config\_file, OCI configuration file, by default this is ~/.oci/config
68
- - oci\_profile\_name, OCI profile to use, default value is "DEFAULT"
69
- - ssh\_keypath, SSH public key, default is ~/.ssh/id\_rsa.pub
70
- - post\_create\_script, run a script on compute\_instance after deployment
71
- - proxy\_url, Connect via the specified proxy URL
72
- - user\_data, Add user data scripts
73
- - hostname\_prefix, Prefix for the generated hostnames (note that OCI doesn't like underscores)
74
- - freeform\_tags, Hash containing tag name(s) and values(s)
75
- - use\_instance\_principals, Boolean flag indicated whether Instance Principals should be used as credentials (see below)
77
+ - `use_private_ip`, Whether to connect to the instance using a private IP, default is false (public ip)
78
+ - `oci_config_file`, OCI configuration file, by default this is ~/.oci/config
79
+ - `oci_profile_name`, OCI profile to use, default value is "DEFAULT"
80
+ - `ssh_keypath`, SSH public key, default is ~/.ssh/id\_rsa.pub
81
+ - `post_create_script`, run a script on compute\_instance after deployment
82
+ - `proxy_url`, Connect via the specified proxy URL
83
+ - `user_data`, Add user data scripts
84
+ - `hostname_prefix`, Prefix for the generated hostnames (note that OCI doesn't like underscores)
85
+ - `freeform_tags`, Hash containing tag name(s) and values(s)
86
+ - `use_instance_principals`, Boolean flag indicated whether Instance Principals should be used as credentials (see below)
76
87
 
77
88
  Optional settings for WinRM support in Windows:
78
89
 
79
- - setup\_winrm, Inject Windows powershell to set password and enable WinRM, default false.
80
- - winrm\_username, Used to set the WinRM transport username, defaults to 'opc'.
81
- - winrm\_password, Set the winrm password. By default a randomly generated password will be used, so don't set this unless you have to. Beware that the password must meet the Windows password complexity requirements otherwise the bootstrapping procedure will fail silently and Kitchen will eventually time out.
90
+ - `setup_winrm`, Inject Windows powershell to set password and enable WinRM, default false.
91
+ - `winrm_username`, Used to set the WinRM transport username, defaults to 'opc'.
92
+ - `winrm_password`, Set the winrm password. By default a randomly generated password will be used, so don't set this unless you have to. Beware that the password must meet the Windows password complexity requirements otherwise the bootstrapping procedure will fail silently and Kitchen will eventually time out.
82
93
 
83
- The use\_private\_ip influences whether the public or private IP will be used by Kitchen to connect to the instance. If it is set to false (the default) then it will connect to the public IP, otherwise it'll use the private IP.
94
+ The `use_private_ip` influences whether the public or private IP will be used by Kitchen to connect to the instance. If it is set to false (the default) then it will connect to the public IP, otherwise it'll use the private IP.
84
95
 
85
- If the subnet\_id refers to a subnet configured to disallow public IPs on any attached VNICs, then the VNIC will be created without a public IP and the use\_private\_ip flag will assumed to be true irrespective of the config setting. On subnets that do allow a public IP a public IP will be allocated to the VNIC, but the use\_private\_ip flag can still be used to override whether the private or public IP will be used.
96
+ If the `subnet_id` refers to a subnet configured to disallow public IPs on any attached VNICs, then the VNIC will be created without a public IP and the `use_private_ip` flag will assumed to be true irrespective of the config setting. On subnets that do allow a public IP a public IP will be allocated to the VNIC, but the `use_private_ip` flag can still be used to override whether the private or public IP will be used.
86
97
 
87
98
  ```yml
88
99
  ---
89
- driver:
90
- name: oci
100
+ driver:
101
+ name: oci
102
+ # These are mandatory
103
+ compartment_id: "ocid1.compartment.oc1..xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
104
+ availability_domain: "XyAb:US-ASHBURN-AD-1"
105
+ image_id: "ocid1.image.oc1.phx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
106
+ shape: "VM.Standard1.2"
107
+ subnet_id: "ocid1.subnet.oc1.phx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
108
+
109
+ # These are optional
110
+ use_private_ip: false
111
+ oci_config_file: "~/.oci/config"
112
+ oci_profile_name: "DEFAULT"
113
+ ssh_keypath: "~/.ssh/id_rsa.pub"
114
+ post_create_script: >-
115
+ ```
91
116
 
92
- provisioner:
93
- name: chef_zero
94
- always_update_cookbooks: true
117
+ ### DBaaS Instance Type
95
118
 
96
- verifier:
97
- name: inspec
119
+ The DBaaS instance type configuration should be written in a hash beginning with `dbaas`.
98
120
 
99
- platforms:
100
- - name: ubuntu-18.04
101
- driver:
102
- # These are mandatory
103
- compartment_id: "ocid1.compartment.oc1..xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
104
- availability_domain: "XyAb:US-ASHBURN-AD-1"
105
- image_id: "ocid1.image.oc1.phx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
106
- shape: "VM.Standard1.2"
107
- subnet_id: "ocid1.subnet.oc1.phx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
121
+ The following configuration item is mandatory for the DBaaS `instance_type`:
108
122
 
109
- # These are optional
110
- use_private_ip: false
111
- oci_config_file: "~/.oci/config"
112
- oci_profile_name: "DEFAULT"
113
- ssh_keypath: "~/.ssh/id_rsa.pub"
114
- post_create_script: >-
115
- touch /tmp/example.txt;
116
- transport:
117
- username: "ubuntu"
123
+ - `db_version`, The specific version of the Oracle database software to be installed. Values can be at either the major version level (eg. 12.1.0.2) or at a PSU level (eg. 12.1.0.2.191015). If no PSU is provided, the latest available will be installed.
118
124
 
119
- suites:
120
- - name: default
121
- run_list:
122
- - recipe[my_cookbook::default]
123
- verifier:
124
- inspec_tests:
125
- - test/smoke/default
126
- attributes:
125
+ The following is a list of optional items for the DBaaS `instance_type`:
126
+
127
+ - `cpu_core_count`, CPU core count for DBaaS nodes. Default value is 2
128
+ - `database_edition`, The edition of the Oracle database software to be installed. Default value is ENTERPRISE_EDITION
129
+ - `license_model`, The licensing model for the Oracle database software. Default value is BRING_YOUR_OWN_LICENSE
130
+ - `db_name`, The name of the database to be provisioned. Must be 8 characters or less, alphanumeric. Default value is `dbaas1`.
131
+ - `pdb_name`, The name of the pdb to be provisioned. Only valid if `db_version` is 12cR1 or higher. Default value is nil (OCI will create a single pdb with the name `db_name`\_PDB1)
132
+ - `admin_password`, The SYS password of the database to be provisioned. Password must be 9 to 30 characters and contain at least 2 uppercase, 2 lowercase, 2 special, and 2 numeric characters. The special characters must be `_`, `#`, or `-`. Default value will be a randomly generated password
133
+ - `initial_data_storage_size_in_gb`, The desired amount of database storage in GB. Default value is 256
134
+ - `character_set`, The characterset of the database. Default value is AL32UTF8
135
+ - `ncharacter_set`, The national characterset of the database. Default value is AL16UTF16
136
+ - `db_workload`, The desired workload configuration for the database. Acceptable values are 'OLTP' and 'DSS'. Default value is 'OLTP'
137
+
138
+ Note: At this time, `node_count` is forced to be 1. RAC provisioning is not supported.
139
+
140
+ ```yml
141
+ ---
142
+ driver:
143
+ name: oci
144
+ instance_type: dbaas
145
+ ...
146
+ dbaas:
147
+ db_version: "12.1.0.2.191015"
127
148
  ```
128
149
 
129
150
  ## Instance Principals
@@ -152,21 +173,30 @@ This will allow the OCI lib to retrieve the certificate, key and ca-chain from t
152
173
  The driver has support for adding user data that can be executed as scripts by cloud-init. These can either be specified inline or by referencing a file. Examples:
153
174
 
154
175
  ```yml
155
- user_data:
156
- - type: x-shellscript
157
- inline: |
158
- #!/bin/bash
159
- touch /tmp/foo.txt
160
- filename: init.sh
161
- - type: x-shellscript
162
- path: myscript.sh
163
- filename: myscript.sh
176
+ user_data:
177
+ - type: x-shellscript
178
+ inline: |
179
+ #!/bin/bash
180
+ touch /tmp/foo.txt
181
+ filename: init.sh
182
+ - type: x-shellscript
183
+ path: myscript.sh
184
+ filename: myscript.sh
164
185
  ```
165
186
 
166
187
  The `filename` parameter must be specified for each entry, and determines the destination filename for the script. If the user data is to be read from a file then the `path` parameter should be specified to indicate where the file is to be read from.
167
188
 
168
189
  The scripts will be encoded into a gzipped, base64 encoded multipart mime message and added as user data when launching the instance.
169
190
 
191
+ Alternately, if you simply pass a string to the user_data, it will be base64 encoded and add as user data when launching the instance.
192
+
193
+ ```yml
194
+ user_data: |
195
+ login: user1
196
+ uid: 1000
197
+ gid: 1000
198
+ ```
199
+
170
200
  ## Proxy support
171
201
 
172
202
  If running Kitchen on a private subnet with no public IPs permitted, it may be necessary to connect to the OCI API via a web proxy. The proxy URL can either be specified on the command line:
@@ -198,7 +228,7 @@ See also the section above on Instance Principals if you plan to use a proxy in
198
228
 
199
229
  ## Windows Support
200
230
 
201
- When launching Oracle provided Windows images, it may be helpful to allow Kitchen-oci to inject powershell to configure WinRM and to set a randomized password that does not need to be changed on first login. If the `setup_winrm` parameter is set to true then the following steps will happen:
231
+ When launching Oracle provided Windows images, it may be helpful to allow kitchen-oci to inject powershell to configure WinRM and to set a randomized password that does not need to be changed on first login. If the `setup_winrm` parameter is set to true then the following steps will happen:
202
232
 
203
233
  - A random password will be generated and stored into the Kitchen state
204
234
  - A powershell script will be generated which sets the password for whatever username is defined in the transport section.
data/Rakefile CHANGED
@@ -1,5 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Copyright 2020 Stephen Pearson <stephen.pearson@oracle.com>
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
3
17
  require 'bundler/gem_tasks'
4
18
  require 'cane/rake_task'
5
19
  require 'tailor/rake_task'
@@ -1,5 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Copyright 2020 Stephen Pearson <stephen.pearson@oracle.com>
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
3
17
  lib = File.expand_path('lib', __dir__)
4
18
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
19
  require 'kitchen/driver/oci_version'
@@ -21,7 +35,7 @@ Gem::Specification.new do |spec|
21
35
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
36
  spec.require_paths = ['lib']
23
37
 
24
- spec.add_dependency 'oci', '~> 2.5.9'
38
+ spec.add_dependency 'oci', '~> 2.10.0'
25
39
  spec.add_dependency 'test-kitchen'
26
40
 
27
41
  spec.add_development_dependency 'bundler'
@@ -21,7 +21,6 @@
21
21
 
22
22
  # This require fixes bug in ChefDK 4.0.60-1 on Linux.
23
23
  require 'forwardable'
24
-
25
24
  require 'base64'
26
25
  require 'erb'
27
26
  require 'kitchen'
@@ -35,48 +34,34 @@ module Kitchen
35
34
  #
36
35
  # @author Stephen Pearson <stephen.pearson@oracle.com>
37
36
  class Oci < Kitchen::Driver::Base # rubocop:disable Metrics/ClassLength
37
+ # required config items
38
38
  required_config :compartment_id
39
39
  required_config :availability_domain
40
- required_config :image_id
41
40
  required_config :shape
42
41
  required_config :subnet_id
43
42
 
44
- default_config :use_private_ip, false
45
- default_config :oci_config_file, nil
46
- default_config :oci_profile_name, nil
43
+ # common config items
44
+ default_config :instance_type, 'compute'
47
45
  default_config :hostname_prefix, nil
48
46
  default_keypath = File.expand_path(File.join(%w[~ .ssh id_rsa.pub]))
49
47
  default_config :ssh_keypath, default_keypath
50
48
  default_config :post_create_script, nil
51
49
  default_config :proxy_url, nil
52
- default_config :user_data, []
50
+ default_config :user_data, nil
53
51
  default_config :freeform_tags, {}
52
+
53
+ # compute config items
54
+ default_config :image_id
55
+ default_config :use_private_ip, false
56
+ default_config :oci_config_file, nil
57
+ default_config :oci_profile_name, nil
54
58
  default_config :setup_winrm, false
55
59
  default_config :winrm_user, 'opc'
56
60
  default_config :winrm_password, nil
57
61
  default_config :use_instance_principals, false
58
62
 
59
- def process_freeform_tags(freeform_tags)
60
- prov = instance.provisioner.instance_variable_get(:@config)
61
- tags = %w[run_list policyfile]
62
- tags.each do |tag|
63
- unless prov[tag.to_sym].nil? || prov[tag.to_sym].empty?
64
- freeform_tags[tag] = prov[tag.to_sym].join(',')
65
- end
66
- end
67
- freeform_tags[:kitchen] = true
68
- freeform_tags
69
- end
70
-
71
- def process_windows_options(state)
72
- state[:username] = config[:winrm_user] if config[:setup_winrm]
73
- if config[:setup_winrm] == true &&
74
- config[:password].nil? &&
75
- state[:password].nil?
76
- state[:password] = config[:winrm_password] || random_password
77
- end
78
- state
79
- end
63
+ # dbaas config items
64
+ default_config :dbaas, {}
80
65
 
81
66
  def create(state)
82
67
  return if state[:server_id]
@@ -84,6 +69,7 @@ module Kitchen
84
69
  state = process_windows_options(state)
85
70
 
86
71
  instance_id = launch_instance(state)
72
+
87
73
  state[:server_id] = instance_id
88
74
  state[:hostname] = instance_ip(instance_id)
89
75
 
@@ -100,23 +86,53 @@ module Kitchen
100
86
  return unless state[:server_id]
101
87
 
102
88
  instance.transport.connection(state).close
103
- comp_api.terminate_instance(state[:server_id])
89
+
90
+ if instance_type == 'compute'
91
+ comp_api.terminate_instance(state[:server_id])
92
+ elsif instance_type == 'dbaas'
93
+ dbaas_api.terminate_db_system(state[:server_id])
94
+ end
104
95
 
105
96
  state.delete(:server_id)
106
97
  state.delete(:hostname)
107
98
  end
108
99
 
100
+ def process_freeform_tags(freeform_tags)
101
+ prov = instance.provisioner.instance_variable_get(:@config)
102
+ tags = %w[run_list policyfile]
103
+ tags.each do |tag|
104
+ freeform_tags[tag] = prov[tag.to_sym].join(',') unless prov[tag.to_sym].nil? || prov[tag.to_sym].empty?
105
+ end
106
+ freeform_tags[:kitchen] = true
107
+ freeform_tags
108
+ end
109
+
110
+ def process_windows_options(state)
111
+ state[:username] = config[:winrm_user] if config[:setup_winrm]
112
+ if config[:setup_winrm] == true &&
113
+ config[:password].nil? &&
114
+ state[:password].nil?
115
+ state[:password] = config[:winrm_password] || random_password
116
+ end
117
+ state
118
+ end
119
+
109
120
  private
110
121
 
122
+ def instance_type
123
+ raise 'instance_type must be either compute or dbaas!' unless %w[compute dbaas].include?(config[:instance_type].downcase)
124
+
125
+ config[:instance_type].downcase
126
+ end
127
+
128
+ ####################
129
+ # OCI config setup #
130
+ ####################
111
131
  def oci_config
112
132
  params = [:load_config]
113
133
  opts = {}
114
- if config[:oci_config_file]
115
- opts[:config_file_location] = config[:oci_config_file]
116
- end
117
- if config[:oci_profile_name]
118
- opts[:profile_name] = config[:oci_profile_name]
119
- end
134
+ opts[:config_file_location] = config[:oci_config_file] if config[:oci_config_file]
135
+ opts[:profile_name] = config[:oci_profile_name] if config[:oci_profile_name]
120
136
  params << opts
121
137
  OCI::ConfigFileLoader.send(*params)
122
138
  end
@@ -141,6 +157,9 @@ module Kitchen
141
157
  end
142
158
  end
143
159
 
160
+ #############
161
+ # API setup #
162
+ #############
144
163
  def generic_api(klass)
145
164
  api_prx = api_proxy
146
165
  if config[:use_instance_principals]
@@ -161,11 +180,90 @@ module Kitchen
161
180
  generic_api(OCI::Core::VirtualNetworkClient)
162
181
  end
163
182
 
183
+ def dbaas_api
184
+ generic_api(OCI::Database::DatabaseClient)
185
+ end
186
+
187
+ ##################
188
+ # Common methods #
189
+ ##################
164
190
  def launch_instance(state)
165
- request = compute_instance_request(state)
191
+ if instance_type == 'compute'
192
+ launch_compute_instance(state)
193
+ elsif instance_type == 'dbaas'
194
+ launch_dbaas_instance
195
+ end
196
+ end
197
+
198
+ def public_ip_allowed?
199
+ subnet = net_api.get_subnet(config[:subnet_id]).data
200
+ !subnet.prohibit_public_ip_on_vnic
201
+ end
202
+
203
+ def instance_ip(instance_id)
204
+ if instance_type == 'compute'
205
+ compute_instance_ip(instance_id)
206
+ elsif instance_type == 'dbaas'
207
+ dbaas_instance_ip(instance_id)
208
+ end
209
+ end
210
+
211
+ def pubkey
212
+ if instance_type == 'compute'
213
+ File.readlines(config[:ssh_keypath]).first.chomp
214
+ elsif instance_type == 'dbaas'
215
+ result = []
216
+ result << File.readlines(config[:ssh_keypath]).first.chomp
217
+ end
218
+ end
166
219
 
220
+ def generate_hostname
221
+ prefix = config[:hostname_prefix]
222
+ if instance_type == 'compute'
223
+ [prefix, random_hostname(instance.name)].compact.join('-')
224
+ elsif instance_type == 'dbaas'
225
+ # 30 character limit for hostname in DBaaS
226
+ if prefix.length >= 30
227
+ [prefix[0, 26], 'db1'].compact.join('-')
228
+ else
229
+ [prefix, random_string(25 - prefix.length), 'db1'].compact.join('-')
230
+ end
231
+ end
232
+ end
233
+
234
+ def random_hostname(prefix)
235
+ "#{prefix}-#{random_string(6)}"
236
+ end
237
+
238
+ def random_password
239
+ if instance_type == 'compute'
240
+ special_chars = %w[! " & ( ) * + , - . /]
241
+ elsif instance_type == 'dbaas'
242
+ special_chars = %w[# _ -]
243
+ end
244
+
245
+ (Array.new(5) { special_chars.sample } +
246
+ Array.new(5) { ('a'..'z').to_a.sample } +
247
+ Array.new(5) { ('A'..'Z').to_a.sample } +
248
+ Array.new(5) { ('0'..'9').to_a.sample }).shuffle.join
249
+ end
250
+
251
+ def random_string(length)
252
+ Array.new(length) { ('a'..'z').to_a.sample }.join
253
+ end
254
+
255
+ def random_number(length)
256
+ Array.new(length) { ('0'..'9').to_a.sample }.join
257
+ end
258
+
259
+ ###################
260
+ # Compute methods #
261
+ ###################
262
+ def launch_compute_instance(state)
263
+ request = compute_instance_request(state)
167
264
  response = comp_api.launch_instance(request)
168
265
  instance_id = response.data.id
266
+
169
267
  comp_api.get_instance(instance_id).wait_until(
170
268
  :lifecycle_state,
171
269
  OCI::Core::Models::Instance::LIFECYCLE_STATE_RUNNING
@@ -173,36 +271,32 @@ module Kitchen
173
271
  instance_id
174
272
  end
175
273
 
176
- def vnic_attachments(instance_id)
177
- att = comp_api.list_vnic_attachments(
178
- config[:compartment_id],
179
- instance_id: instance_id
180
- ).data
181
-
182
- raise 'Could not find any VNIC attachments' unless att.any?
274
+ def compute_instance_request(state)
275
+ request = compute_launch_details
183
276
 
184
- att
185
- end
277
+ inject_powershell(state) if config[:setup_winrm] == true
186
278
 
187
- def vnics(instance_id)
188
- vnic_attachments(instance_id).map do |att|
189
- net_api.get_vnic(att.vnic_id).data
190
- end
279
+ metadata = {}
280
+ metadata.store('ssh_authorized_keys', pubkey)
281
+ data = user_data
282
+ metadata.store('user_data', data) if config[:user_data] && !config[:user_data].empty?
283
+ request.metadata = metadata
284
+ request
191
285
  end
192
286
 
193
- def instance_ip(instance_id)
194
- vnic = vnics(instance_id).select(&:is_primary).first
195
- if public_ip_allowed?
196
- config[:use_private_ip] ? vnic.private_ip : vnic.public_ip
197
- else
198
- vnic.private_ip
287
+ def compute_launch_details
288
+ OCI::Core::Models::LaunchInstanceDetails.new.tap do |l|
289
+ hostname = generate_hostname
290
+ l.availability_domain = config[:availability_domain]
291
+ l.compartment_id = config[:compartment_id]
292
+ l.display_name = hostname
293
+ l.source_details = instance_source_details
294
+ l.shape = config[:shape]
295
+ l.create_vnic_details = create_vnic_details(hostname)
296
+ l.freeform_tags = process_freeform_tags(config[:freeform_tags])
199
297
  end
200
298
  end
201
299
 
202
- def pubkey
203
- File.readlines(config[:ssh_keypath]).first.chomp
204
- end
205
-
206
300
  def instance_source_details
207
301
  OCI::Core::Models::InstanceSourceViaImageDetails.new(
208
302
  sourceType: 'image',
@@ -210,11 +304,6 @@ module Kitchen
210
304
  )
211
305
  end
212
306
 
213
- def public_ip_allowed?
214
- subnet = net_api.get_subnet(config[:subnet_id]).data
215
- !subnet.prohibit_public_ip_on_vnic
216
- end
217
-
218
307
  def create_vnic_details(name)
219
308
  OCI::Core::Models::CreateVnicDetails.new(
220
309
  assign_public_ip: public_ip_allowed?,
@@ -224,12 +313,48 @@ module Kitchen
224
313
  )
225
314
  end
226
315
 
316
+ def vnics(instance_id)
317
+ vnic_attachments(instance_id).map do |att|
318
+ net_api.get_vnic(att.vnic_id).data
319
+ end
320
+ end
321
+
322
+ def vnic_attachments(instance_id)
323
+ att = comp_api.list_vnic_attachments(
324
+ config[:compartment_id],
325
+ instance_id: instance_id
326
+ ).data
327
+
328
+ raise 'Could not find any VNIC attachments' unless att.any?
329
+
330
+ att
331
+ end
332
+
333
+ def compute_instance_ip(instance_id)
334
+ vnic = vnics(instance_id).select(&:is_primary).first
335
+ if public_ip_allowed?
336
+ config[:use_private_ip] ? vnic.private_ip : vnic.public_ip
337
+ else
338
+ vnic.private_ip
339
+ end
340
+ end
341
+
227
342
  def winrm_ps1(state)
228
343
  filename = File.join(__dir__, %w[.. .. .. tpl setup_winrm.ps1.erb])
229
344
  tpl = ERB.new(File.read(filename))
230
345
  tpl.result(binding)
231
346
  end
232
347
 
348
+ def inject_powershell(state)
349
+ data = winrm_ps1(state)
350
+ config[:user_data] ||= []
351
+ config[:user_data] << {
352
+ type: 'x-shellscript',
353
+ inline: data,
354
+ filename: 'setup_winrm.ps1'
355
+ }
356
+ end
357
+
233
358
  def read_part(part)
234
359
  if part[:path]
235
360
  content = File.read part[:path]
@@ -254,71 +379,125 @@ module Kitchen
254
379
  msg
255
380
  end
256
381
 
257
- def user_data
258
- boundary = "MIMEBOUNDARY_#{random_string(20)}"
259
- msg = ["Content-Type: multipart/mixed; boundary=\"#{boundary}\"",
260
- 'MIME-Version: 1.0', '']
261
- msg += mime_parts(boundary)
262
- txt = msg.join("\n") + "\n"
263
- gzip = Zlib::GzipWriter.new(StringIO.new)
264
- gzip << txt
265
- Base64.encode64(gzip.close.string).delete("\n")
382
+ def user_data # rubocop:disable Metrics/MethodLength
383
+ if config[:user_data].is_a? Array
384
+ boundary = "MIMEBOUNDARY_#{random_string(20)}"
385
+ msg = ["Content-Type: multipart/mixed; boundary=\"#{boundary}\"",
386
+ 'MIME-Version: 1.0', '']
387
+ msg += mime_parts(boundary)
388
+ txt = msg.join("\n") + "\n"
389
+ gzip = Zlib::GzipWriter.new(StringIO.new)
390
+ gzip << txt
391
+ Base64.encode64(gzip.close.string).delete("\n")
392
+ elsif config[:user_data].is_a? String
393
+ Base64.encode64(config[:user_data]).delete("\n")
394
+ end
266
395
  end
267
396
 
268
- def inject_powershell(state)
269
- data = winrm_ps1(state)
270
- config[:user_data] ||= []
271
- config[:user_data] << {
272
- type: 'x-shellscript',
273
- inline: data,
274
- filename: 'setup_winrm.ps1'
275
- }
276
- end
397
+ #################
398
+ # DBaaS methods #
399
+ #################
400
+ def launch_dbaas_instance
401
+ request = dbaas_launch_details
402
+ response = dbaas_api.launch_db_system(request)
403
+ instance_id = response.data.id
277
404
 
278
- def generate_hostname
279
- prefix = config[:hostname_prefix]
280
- [prefix, random_hostname(instance.name)].compact.join('-')
405
+ dbaas_api.get_db_system(instance_id).wait_until(
406
+ :lifecycle_state,
407
+ OCI::Database::Models::DbSystem::LIFECYCLE_STATE_AVAILABLE,
408
+ max_interval_seconds: 900,
409
+ max_wait_seconds: 21600
410
+ )
411
+ instance_id
281
412
  end
282
413
 
283
- def base_oci_launch_details
284
- OCI::Core::Models::LaunchInstanceDetails.new.tap do |l|
285
- hostname = generate_hostname
414
+ def dbaas_launch_details # rubocop:disable Metrics/MethodLength
415
+ cpu_core_count = config[:dbaas][:cpu_core_count] ||= 2
416
+ database_edition = config[:dbaas][:database_edition] ||= OCI::Database::Models::DbSystem::DATABASE_EDITION_ENTERPRISE_EDITION
417
+ initial_data_storage_size_in_gb = config[:dbaas][:initial_data_storage_size_in_gb] ||= 256
418
+ license_model = config[:dbaas][:license_model] ||= OCI::Database::Models::DbSystem::LICENSE_MODEL_BRING_YOUR_OWN_LICENSE
419
+
420
+ OCI::Database::Models::LaunchDbSystemDetails.new.tap do |l|
286
421
  l.availability_domain = config[:availability_domain]
287
422
  l.compartment_id = config[:compartment_id]
288
- l.display_name = hostname
289
- l.source_details = instance_source_details
423
+ l.cpu_core_count = cpu_core_count
424
+ l.database_edition = database_edition
425
+ l.db_home = create_db_home_details
426
+ l.display_name = [config[:hostname_prefix], random_string(4), random_number(2)].compact.join('-')
427
+ l.hostname = generate_hostname
290
428
  l.shape = config[:shape]
291
- l.create_vnic_details = create_vnic_details(hostname)
429
+ l.ssh_public_keys = pubkey
430
+ l.cluster_name = generate_cluster_name
431
+ l.initial_data_storage_size_in_gb = initial_data_storage_size_in_gb
432
+ l.node_count = 1
433
+ l.license_model = license_model
434
+ l.subnet_id = config[:subnet_id]
292
435
  l.freeform_tags = process_freeform_tags(config[:freeform_tags])
293
436
  end
294
437
  end
295
438
 
296
- def compute_instance_request(state)
297
- request = base_oci_launch_details
439
+ def create_db_home_details
440
+ raise 'db_version cannot be nil!' if config[:dbaas][:db_version].nil?
298
441
 
299
- inject_powershell(state) if config[:setup_winrm] == true
442
+ OCI::Database::Models::CreateDbHomeDetails.new.tap do |l|
443
+ l.database = create_database_details
444
+ l.db_version = config[:dbaas][:db_version]
445
+ l.display_name = ['dbhome', random_number(10)].compact.join('')
446
+ end
447
+ end
300
448
 
301
- metadata = {}
302
- metadata.store('ssh_authorized_keys', pubkey)
303
- data = user_data
304
- metadata.store('user_data', data) if config[:user_data].any?
305
- request.metadata = metadata
306
- request
449
+ def create_database_details # rubocop:disable Metrics/MethodLength
450
+ character_set = config[:dbaas][:character_set] ||= 'AL32UTF8'
451
+ ncharacter_set = config[:dbaas][:ncharacter_set] ||= 'AL16UTF16'
452
+ db_workload = config[:dbaas][:db_workload] ||= OCI::Database::Models::CreateDatabaseDetails::DB_WORKLOAD_OLTP
453
+ admin_password = config[:dbaas][:admin_password] ||= random_password
454
+ db_name = config[:dbaas][:db_name] ||= 'dbaas1'
455
+
456
+ OCI::Database::Models::CreateDatabaseDetails.new.tap do |l|
457
+ l.admin_password = admin_password
458
+ l.character_set = character_set
459
+ l.db_name = db_name
460
+ l.db_workload = db_workload
461
+ l.ncharacter_set = ncharacter_set
462
+ l.pdb_name = config[:dbaas][:pdb_name]
463
+ l.db_backup_config = db_backup_config
464
+ end
307
465
  end
308
466
 
309
- def random_hostname(prefix)
310
- "#{prefix}-#{random_string(6)}"
467
+ def db_backup_config
468
+ OCI::Database::Models::DbBackupConfig.new.tap do |l|
469
+ l.auto_backup_enabled = false
470
+ end
311
471
  end
312
472
 
313
- def random_password
314
- (Array.new(5) { %w[! " # & ( ) * + , - . /].sample } +
315
- Array.new(5) { ('a'..'z').to_a.sample } +
316
- Array.new(5) { ('A'..'Z').to_a.sample } +
317
- Array.new(5) { ('0'..'9').to_a.sample }).shuffle.join
473
+ def generate_cluster_name
474
+ prefix = config[:hostname_prefix].split('-')[0]
475
+ # 11 character limit for cluster_name in DBaaS
476
+ if prefix.length >= 11
477
+ prefix[0, 11]
478
+ else
479
+ [prefix, random_string(10 - prefix.length)].compact.join('-')
480
+ end
318
481
  end
319
482
 
320
- def random_string(length)
321
- Array.new(length) { ('a'..'z').to_a.sample }.join
483
+ def dbaas_node(instance_id)
484
+ dbaas_api.list_db_nodes(
485
+ config[:compartment_id],
486
+ db_system_id: instance_id
487
+ ).data
488
+ end
489
+
490
+ def dbaas_vnic(node_ocid)
491
+ dbaas_api.get_db_node(node_ocid).data
492
+ end
493
+
494
+ def dbaas_instance_ip(instance_id)
495
+ vnic = dbaas_node(instance_id).select(&:vnic_id).first.vnic_id
496
+ if public_ip_allowed?
497
+ net_api.get_vnic(vnic).data.public_ip
498
+ else
499
+ net_api.get_vnic(vnic).data.private_ip
500
+ end
322
501
  end
323
502
  end
324
503
  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.9.0'
23
+ OCI_VERSION = '1.11.2'
24
24
  end
25
25
  end
@@ -1,5 +1,19 @@
1
1
  #ps1_sysnative
2
2
 
3
+ # Copyright 2020 Stephen Pearson <stephen.pearson@oracle.com>
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
3
17
  Write-Output "Setting <%= state[:username] %> password"
4
18
  net user <%= state[:username] %> '<%= state[:password] %>'
5
19
 
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.9.0
4
+ version: 1.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Pearson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-10 00:00:00.000000000 Z
11
+ date: 2020-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oci
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.5.9
19
+ version: 2.10.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.5.9
26
+ version: 2.10.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: test-kitchen
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -117,10 +117,12 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - ".cane"
119
119
  - ".gitignore"
120
+ - ".rubocop.yml"
120
121
  - ".travis.yml"
121
122
  - CHANGELOG.md
122
123
  - Gemfile
123
124
  - LICENSE
125
+ - NOTICE
124
126
  - README.md
125
127
  - Rakefile
126
128
  - kitchen-oci.gemspec
@@ -146,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
148
  - !ruby/object:Gem::Version
147
149
  version: '0'
148
150
  requirements: []
149
- rubygems_version: 3.0.1
151
+ rubygems_version: 3.0.3
150
152
  signing_key:
151
153
  specification_version: 4
152
154
  summary: A Test Kitchen Driver for Oracle OCI