kitchen-oci 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +34 -1
- data/kitchen-oci.gemspec +1 -1
- data/lib/kitchen/driver/oci.rb +64 -30
- data/lib/kitchen/driver/oci_version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f381c61062ca55422131f8087c2da907305d5041
|
4
|
+
data.tar.gz: 2f55fc92fe1d2130ab7918948b97871f58af72c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9fbf9676d4fa352232c552204f2bc826fb97a5b422f55759ba06a51b94cf1f9fee477a77f00a09e32a853fd4f0bf3ffa5bf3b3fccc3f72c283e732dce824969
|
7
|
+
data.tar.gz: b577428531a407ea618c42f568ba18647c17fe15cec6071190f29272b65057cac521cbde9c2bb24e12062611c9659f3e163f711052f5ba3bbc513667f7d68187
|
data/README.md
CHANGED
@@ -54,10 +54,16 @@ Note: The availability domain should be the full AD name including the tenancy s
|
|
54
54
|
|
55
55
|
These settings are optional:
|
56
56
|
|
57
|
+
- use\_private\_ip, Whether to connect to the instance using a private IP, default is false (public ip)
|
57
58
|
- oci\_config\_file, OCI configuration file, by default this is ~/.oci/config
|
58
59
|
- oci\_profile\_name, OCI profile to use, default value is "DEFAULT"
|
59
60
|
- ssh\_keypath, SSH public key, default is ~/.ssh/id\_rsa.pub
|
60
|
-
- post\_create\_script, run a script on
|
61
|
+
- post\_create\_script, run a script on compute\_instance after deployment
|
62
|
+
- proxy\_url, Connect via the specified proxy URL
|
63
|
+
|
64
|
+
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.
|
65
|
+
|
66
|
+
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.
|
61
67
|
|
62
68
|
```
|
63
69
|
---
|
@@ -101,6 +107,33 @@ suites:
|
|
101
107
|
attributes:
|
102
108
|
```
|
103
109
|
|
110
|
+
## Proxy support
|
111
|
+
|
112
|
+
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:
|
113
|
+
```
|
114
|
+
# With authentication
|
115
|
+
export http_proxy=http://<proxy_user>:<proxy_password>@<proxy_host>:<proxy_port>"
|
116
|
+
# Without authentication
|
117
|
+
export http_proxy=http://<proxy_host>:<proxy_port>"
|
118
|
+
```
|
119
|
+
.. or if preferred in the cookbook's .kitchen.yml file.
|
120
|
+
```
|
121
|
+
driver:
|
122
|
+
...
|
123
|
+
proxy_url: "http://<proxy_user>:<proxy_password>@<proxy_host>:<proxy_port>"
|
124
|
+
```
|
125
|
+
|
126
|
+
The SSH transport can also be tunneled via the web proxy using the CONNECT http method, but note that this is not handled by the kitchen-oci gem. Configuration is provided here for convenience only:
|
127
|
+
|
128
|
+
```
|
129
|
+
transport:
|
130
|
+
username: "<os_username>"
|
131
|
+
ssh_http_proxy: "<proxy_host>"
|
132
|
+
ssh_http_proxy_port: <proxy_port>
|
133
|
+
ssh_http_proxy_user: <proxy_user>
|
134
|
+
ssh_http_proxy_password: <proxy_password>
|
135
|
+
```
|
136
|
+
|
104
137
|
Created and maintained by Stephen Pearson (<stevieweavie@gmail.com>)
|
105
138
|
|
106
139
|
## License
|
data/kitchen-oci.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.add_dependency 'oci', '2.1
|
24
|
+
spec.add_dependency 'oci', '~> 2.1'
|
25
25
|
spec.add_dependency 'test-kitchen'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'bundler'
|
data/lib/kitchen/driver/oci.rb
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
|
20
20
|
require 'kitchen'
|
21
21
|
require 'oci'
|
22
|
+
require 'uri'
|
22
23
|
|
23
24
|
module Kitchen
|
24
25
|
module Driver
|
@@ -38,13 +39,14 @@ module Kitchen
|
|
38
39
|
default_keypath = File.expand_path(File.join(%w[~ .ssh id_rsa.pub]))
|
39
40
|
default_config :ssh_keypath, default_keypath
|
40
41
|
default_config :post_create_script, nil
|
42
|
+
default_config :proxy_url, nil
|
41
43
|
|
42
44
|
def create(state) # rubocop:disable Metrics/AbcSize
|
43
45
|
return if state[:server_id]
|
44
46
|
|
45
|
-
instance_id = launch_instance
|
47
|
+
instance_id = launch_instance
|
46
48
|
state[:server_id] = instance_id
|
47
|
-
state[:hostname] = instance_ip(
|
49
|
+
state[:hostname] = instance_ip(instance_id)
|
48
50
|
|
49
51
|
instance.transport.connection(state).wait_until_ready
|
50
52
|
|
@@ -59,7 +61,7 @@ module Kitchen
|
|
59
61
|
return unless state[:server_id]
|
60
62
|
|
61
63
|
instance.transport.connection(state).close
|
62
|
-
comp_api
|
64
|
+
comp_api.terminate_instance(state[:server_id])
|
63
65
|
|
64
66
|
state.delete(:server_id)
|
65
67
|
state.delete(:hostname)
|
@@ -67,7 +69,7 @@ module Kitchen
|
|
67
69
|
|
68
70
|
private
|
69
71
|
|
70
|
-
def oci_config
|
72
|
+
def oci_config
|
71
73
|
params = [:load_config]
|
72
74
|
opts = {}
|
73
75
|
if config[:oci_config_file]
|
@@ -80,28 +82,56 @@ module Kitchen
|
|
80
82
|
OCI::ConfigFileLoader.send(*params)
|
81
83
|
end
|
82
84
|
|
83
|
-
def
|
84
|
-
|
85
|
+
def proxy_config
|
86
|
+
if config[:proxy_url]
|
87
|
+
URI.parse(config[:proxy_url])
|
88
|
+
else
|
89
|
+
URI.parse('http://').find_proxy
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def api_proxy
|
94
|
+
prx = proxy_config
|
95
|
+
return nil unless prx
|
96
|
+
if prx.user
|
97
|
+
OCI::ApiClientProxySettings.new(prx.host, prx.port, prx.user,
|
98
|
+
prx.password)
|
99
|
+
else
|
100
|
+
OCI::ApiClientProxySettings.new(prx.host, prx.port)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def generic_api(klass)
|
105
|
+
api_prx = api_proxy
|
106
|
+
if api_prx
|
107
|
+
klass.new(config: oci_config, proxy_settings: api_prx)
|
108
|
+
else
|
109
|
+
klass.new(config: oci_config)
|
110
|
+
end
|
85
111
|
end
|
86
112
|
|
87
|
-
def
|
88
|
-
OCI::Core::
|
113
|
+
def comp_api
|
114
|
+
generic_api(OCI::Core::ComputeClient)
|
89
115
|
end
|
90
116
|
|
91
|
-
def
|
92
|
-
|
117
|
+
def net_api
|
118
|
+
generic_api(OCI::Core::VirtualNetworkClient)
|
119
|
+
end
|
93
120
|
|
94
|
-
|
121
|
+
def launch_instance
|
122
|
+
request = compute_instance_request
|
123
|
+
|
124
|
+
response = comp_api.launch_instance(request)
|
95
125
|
instance_id = response.data.id
|
96
|
-
comp_api
|
126
|
+
comp_api.get_instance(instance_id).wait_until(
|
97
127
|
:lifecycle_state,
|
98
128
|
OCI::Core::Models::Instance::LIFECYCLE_STATE_RUNNING
|
99
129
|
)
|
100
130
|
instance_id
|
101
131
|
end
|
102
132
|
|
103
|
-
def vnic_attachments(
|
104
|
-
att = comp_api
|
133
|
+
def vnic_attachments(instance_id)
|
134
|
+
att = comp_api.list_vnic_attachments(
|
105
135
|
config[:compartment_id],
|
106
136
|
instance_id: instance_id
|
107
137
|
).data
|
@@ -109,50 +139,54 @@ module Kitchen
|
|
109
139
|
att
|
110
140
|
end
|
111
141
|
|
112
|
-
def vnics(
|
113
|
-
vnic_attachments(
|
114
|
-
net_api
|
142
|
+
def vnics(instance_id)
|
143
|
+
vnic_attachments(instance_id).map do |att|
|
144
|
+
net_api.get_vnic(att.vnic_id).data
|
115
145
|
end
|
116
146
|
end
|
117
147
|
|
118
|
-
def instance_ip(
|
119
|
-
vnic = vnics(
|
120
|
-
|
148
|
+
def instance_ip(instance_id)
|
149
|
+
vnic = vnics(instance_id).select(&:is_primary).first
|
150
|
+
if public_ip_allowed?
|
151
|
+
config[:use_private_ip] ? vnic.private_ip : vnic.public_ip
|
152
|
+
else
|
153
|
+
vnic.private_ip
|
154
|
+
end
|
121
155
|
end
|
122
156
|
|
123
|
-
def pubkey
|
157
|
+
def pubkey
|
124
158
|
File.readlines(config[:ssh_keypath]).first.chomp
|
125
159
|
end
|
126
160
|
|
127
|
-
def instance_source_details
|
161
|
+
def instance_source_details
|
128
162
|
OCI::Core::Models::InstanceSourceViaImageDetails.new(
|
129
163
|
sourceType: 'image',
|
130
164
|
imageId: config[:image_id]
|
131
165
|
)
|
132
166
|
end
|
133
167
|
|
134
|
-
def public_ip_allowed?
|
135
|
-
subnet = net_api
|
168
|
+
def public_ip_allowed?
|
169
|
+
subnet = net_api.get_subnet(config[:subnet_id]).data
|
136
170
|
!subnet.prohibit_public_ip_on_vnic
|
137
171
|
end
|
138
172
|
|
139
|
-
def create_vnic_details
|
173
|
+
def create_vnic_details
|
140
174
|
OCI::Core::Models::CreateVnicDetails.new(
|
141
|
-
assign_public_ip: public_ip_allowed
|
175
|
+
assign_public_ip: public_ip_allowed?,
|
142
176
|
display_name: 'primary_nic',
|
143
177
|
subnetId: config[:subnet_id]
|
144
178
|
)
|
145
179
|
end
|
146
180
|
|
147
|
-
def compute_instance_request
|
181
|
+
def compute_instance_request # rubocop:disable Metrics/AbcSize
|
148
182
|
request = OCI::Core::Models::LaunchInstanceDetails.new
|
149
183
|
request.availability_domain = config[:availability_domain]
|
150
184
|
request.compartment_id = config[:compartment_id]
|
151
185
|
request.display_name = random_hostname(instance.name)
|
152
|
-
request.source_details = instance_source_details
|
186
|
+
request.source_details = instance_source_details
|
153
187
|
request.shape = config[:shape]
|
154
|
-
request.create_vnic_details = create_vnic_details
|
155
|
-
request.metadata = { 'ssh_authorized_keys' => pubkey
|
188
|
+
request.create_vnic_details = create_vnic_details
|
189
|
+
request.metadata = { 'ssh_authorized_keys' => pubkey }
|
156
190
|
request
|
157
191
|
end
|
158
192
|
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-oci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Pearson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oci
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.1
|
19
|
+
version: '2.1'
|
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.1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: test-kitchen
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.
|
149
|
+
rubygems_version: 2.6.13
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: A Test Kitchen Driver for Oracle OCI
|