kitchen-oci 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28a500ab2c3ac91b3fc827a78bfcb8c50cf1f1a2
4
- data.tar.gz: 97a476e7eeb9d8fb1c9fcc43ddbe9471b88915f3
3
+ metadata.gz: 19053062ba01105a50890aa5d147ac200c5c639d
4
+ data.tar.gz: b9bf3f786c59eff07986fa1f205aaa4cb289c6c8
5
5
  SHA512:
6
- metadata.gz: 6cbb83bc027ff4d4f66f5a48184749b7bdd08342a2a42adc3ca6e87f084501f7c1101011aa76310630eaee53c4fb7c0d2a2021bb8ec669dcac8e0483c2334278
7
- data.tar.gz: dfc1c9221d4d5f93af40d28805472c420cdadd81cfd6c6fb8412ec06edb067f6e34f65f1309c6f099bb7cfe72bd0451bc293e93ea2f90de9f28108138fefff90
6
+ metadata.gz: 51b060030ad9f2b53fde61fd7a4b053a3385f564bf349b6d6049df661a833ed088d14494c307da7322b57535f53128a4ab51bff175f7486865171162c2ec7960
7
+ data.tar.gz: 64b34c22ac500b3d7d7dca3fcc715a0b3e20fba1a680e04eee78289f4b25f558cf27da9e68f3aec8a6193fc17d593d5e9e0b4c455aef1c86220db1a581505ec7
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.swp
1
2
  *.gem
2
3
  *.rbc
3
4
  .bundle
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/README.md CHANGED
@@ -7,26 +7,38 @@ WARNING: This is alpha quality. Use at your own risk!
7
7
  ## Prerequisites
8
8
 
9
9
  You need an ssh keypair defined for your current user. By default the driver
10
- expects to find the public key in ~/.ssh/id_rsa.pub, but this can be
10
+ expects to find the public key in ~/.ssh/id\_rsa.pub, but this can be
11
11
  overridden in .kitchen.yml.
12
12
 
13
- You need to create suitable configuration for OCI in ~/.oci/config but this
13
+ You need to create suitable configuration for OCI in ~/.oci/config and this
14
14
  can be created using the CLI:
15
15
  ```
16
16
  oci setup config
17
17
  ```
18
18
 
19
19
  Ensure that you have a suitable compartment defined, an external subnet, and
20
- security rules that allow incoming SSH and outgoing HTTP (to allow Kitchen to
21
- pull the Chef binaries).
20
+ security rules that allow incoming SSH and outgoing HTTP to allow Kitchen to
21
+ pull the Chef binaries.
22
22
 
23
23
  ## Building the gem
24
24
 
25
- Ensure you have the ChefDK installed.
25
+ ```
26
+ rake build
27
+ ```
28
+
29
+ ## Installing the gem
30
+
31
+ You must install the gem into whatever Ruby is used to run knife. On a
32
+ workstation this will likely be the ChefDK environment. To switch to
33
+ ChefDK if you haven't already:
26
34
 
27
35
  ```
28
36
  eval "$(chef shell-init bash)"
29
- rake build
37
+ ```
38
+
39
+ Then install the package you built earlier:
40
+
41
+ ```
30
42
  gem install pkg/kitchen-oci-<VERSION>.gem
31
43
  ```
32
44
 
@@ -40,6 +52,8 @@ Adjust below template as required. The following configuration is mandatory:
40
52
  - shape
41
53
  - subnet\_id
42
54
 
55
+ 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.
56
+
43
57
  These settings are optional:
44
58
 
45
59
  - oci\_config\_file, by default this is ~/.oci/config
@@ -62,15 +76,22 @@ verifier:
62
76
  platforms:
63
77
  - name: ubuntu-16.04
64
78
  driver:
65
- availability_domain: "ad1"
79
+ # These are mandatory
66
80
  compartment_id: "ocid1.compartment.oc1..xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
81
+ availability_domain: "XyAb:US-ASHBURN-AD-1"
67
82
  image_id: "ocid1.image.oc1.phx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
68
83
  shape: "VM.Standard1.2"
69
84
  subnet_id: "ocid1.subnet.oc1.phx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
85
+
86
+ # These are optional
87
+ use_private_ip: false
88
+ oci_config_file: "~/.oci/config"
89
+ oci_profile_name: "DEFAULT"
90
+ ssh_keypath: "~/.ssh/id_rsa.pub"
70
91
  post_create_script: >-
71
92
  touch /tmp/example.txt;
72
93
  transport:
73
- username: "opc"
94
+ username: "ubuntu"
74
95
 
75
96
  suites:
76
97
  - name: default
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'cane/rake_task'
3
5
  require 'tailor/rake_task'
data/kitchen-oci.gemspec CHANGED
@@ -1,4 +1,6 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'kitchen/driver/oci_version'
4
6
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #
2
4
  # Author:: Stephen Pearson (<stevieweavie@gmail.com>)
3
5
  #
@@ -23,13 +25,14 @@ module Kitchen
23
25
  # Oracle OCI driver for Kitchen.
24
26
  #
25
27
  # @author Stephen Pearson <stevieweavie@gmail.com>
26
- class Oci < Kitchen::Driver::Base
28
+ class Oci < Kitchen::Driver::Base # rubocop:disable Metrics/ClassLength
27
29
  required_config :compartment_id
28
30
  required_config :availability_domain
29
31
  required_config :image_id
30
32
  required_config :shape
31
33
  required_config :subnet_id
32
34
 
35
+ default_config :use_private_ip, false
33
36
  default_config :oci_config_file, nil
34
37
  default_config :oci_profile_name, nil
35
38
  default_keypath = File.expand_path(File.join(%w[~ .ssh id_rsa.pub]))
@@ -41,7 +44,7 @@ module Kitchen
41
44
 
42
45
  instance_id = launch_instance(config)
43
46
  state[:server_id] = instance_id
44
- state[:hostname] = public_ip(config, instance_id)
47
+ state[:hostname] = instance_ip(config, instance_id)
45
48
 
46
49
  instance.transport.connection(state).wait_until_ready
47
50
 
@@ -97,13 +100,24 @@ module Kitchen
97
100
  instance_id
98
101
  end
99
102
 
100
- def public_ip(config, instance_id)
101
- vnics = comp_api(config).list_vnic_attachments(
103
+ def vnic_attachments(config, instance_id)
104
+ att = comp_api(config).list_vnic_attachments(
102
105
  config[:compartment_id],
103
106
  instance_id: instance_id
104
- )
105
- vnic_id = vnics.data.first.vnic_id
106
- net_api(config).get_vnic(vnic_id).data.public_ip
107
+ ).data
108
+ raise 'Could not find any VNIC attachments' unless att.any?
109
+ att
110
+ end
111
+
112
+ def vnics(config, instance_id)
113
+ vnic_attachments(config, instance_id).map do |att|
114
+ net_api(config).get_vnic(att.vnic_id).data
115
+ end
116
+ end
117
+
118
+ def instance_ip(config, instance_id)
119
+ vnic = vnics(config, instance_id).select(&:is_primary).first
120
+ config[:use_private_ip] ? vnic.private_ip : vnic.public_ip
107
121
  end
108
122
 
109
123
  def pubkey(config)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #
2
4
  # Author:: Stephen Pearson (<stevieweavie@gmail.com>)
3
5
  #
@@ -18,6 +20,6 @@
18
20
  module Kitchen
19
21
  module Driver
20
22
  # Version string for Oracle OCI Kitchen driver
21
- OCI_VERSION = '1.0.0'.freeze
23
+ OCI_VERSION = '1.1.0'
22
24
  end
23
25
  end
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.0.0
4
+ version: 1.1.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: 2017-12-05 00:00:00.000000000 Z
11
+ date: 2018-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oci