kitchen-vmpool 0.1.0 → 0.1.1

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: 47a09fa8754874d175c4f371a901d36e6ee860c5
4
- data.tar.gz: f5c5345cd9933b589f26c06d03954709e40a1ab3
3
+ metadata.gz: ba43fce6af2f6b5d3e8169ce88c85b23264cf443
4
+ data.tar.gz: 47cfe3bc7f7d189cbe64a9208d0e21fcb06a42d4
5
5
  SHA512:
6
- metadata.gz: 9f8c6d51d87c3cb4e9f1eb06c894c0632e24804c4dbf8b634a3c74929434a49c84ee3b21f749e255244a0c68ecda083c79f1590e3a77d20d149e5f09674e0b3a
7
- data.tar.gz: bc99c8c6fd5ceddb516c587ecc16da6384179f0c1997cdbcb7be08b43512e5923e57eeaafc1f72911b2ac1b37e459406e24f90d3dfb10f07c0803eac7cbd09fa
6
+ metadata.gz: dc037d0dfb9125d2ebaba3d776e17b8ff8ac5954358e2e5e90f1d17ec0d827ba7eb7eacdb1b06a145482c1c4421b89dc408468a64971ae02a33cdb6ddaf31e2c
7
+ data.tar.gz: ccc435a6f48212d3b3cfc8cf6d743aacca971d134900d2dbe20b25aabb684a3ca42fb2f5be94c681592af68ea0d19149c6ba2d716e9472cf1280b8a8adba2cb8
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "kitchen-vmpool"
7
- spec.version = "0.1.0"
7
+ spec.version = "0.1.1"
8
8
  spec.authors = ["Corey Osman"]
9
9
  spec.email = ["corey@nwops.io"]
10
10
 
@@ -22,15 +22,18 @@ require "kitchen/version"
22
22
  require 'kitchen/driver/base'
23
23
  module Kitchen
24
24
  module Driver
25
+
26
+ class PoolMemberNotFound < Exception; end
27
+
25
28
  class Vmpool < Kitchen::Driver::Base
26
- plugin_version "0.1.0"
29
+ plugin_version "0.1.1"
27
30
 
28
31
  default_config :pool_name, 'pool1'
29
32
  default_config :pool_file, 'vmpool.yaml'
30
33
  default_config :state_store, 'file'
31
34
  default_config :store_options, {}
32
-
33
- required_config :create_command
35
+ default_config :reuse_instances, false
36
+ default_config :create_command, nil
34
37
  default_config :destroy_command, nil
35
38
 
36
39
  no_parallel_for :create, :destroy
@@ -52,6 +55,7 @@ module Kitchen
52
55
  # @return [String] - a random host from the list of systems
53
56
  def pool_member
54
57
  sample = pool_hosts.sample
58
+ raise PoolMemberNotFound.new("No pool members exist for #{config[:pool_name]}, please create some pool members") unless sample
55
59
  member = pool_hosts.delete(sample)
56
60
  mark_used(member)
57
61
  return member
@@ -76,7 +80,11 @@ module Kitchen
76
80
 
77
81
  # @return Array[String] - a list of host names in the pool
78
82
  def pool_hosts
79
- pool['pool_instances']
83
+ if config[:reuse_instances]
84
+ pool['pool_instances'] + pool['used_instances'].to_a
85
+ else
86
+ pool['pool_instances']
87
+ end
80
88
  end
81
89
 
82
90
  # @param name [String] - the hostname to mark not used
@@ -106,7 +114,7 @@ module Kitchen
106
114
  klass = Object.const_get("Kitchen::Driver::VmpoolStores::#{store}")
107
115
  # create a new instance of the store with the provided options
108
116
  store_opts = config[:store_options]
109
- # convert everything key to strings
117
+ # convert everything key to strings
110
118
  store_opts.tap do |h|
111
119
  h.keys.each { |k| h[k.to_s] = h.delete(k) }
112
120
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-vmpool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Osman