clc-fork-chef-metal 0.14.alpha.3 → 0.14.alpha.4

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: 463b696be54f5c633a09a341dff4ac59c9e4b1ce
4
- data.tar.gz: 6a8a78fddaecdf692b4bc497a117119ff09fff67
3
+ metadata.gz: c08de5313597e7139143246a94138fee6fca9a84
4
+ data.tar.gz: 6de6e645deaa776b7aab8a46ef8306b16046e3fb
5
5
  SHA512:
6
- metadata.gz: dc004647dead731f50c3e4ddfb310afb1b5599ca4fd8931786fcbfbe1a26a1c1bfbd1b96df3296bd45eb83e1b29a6b7b617297538d88fbe25f89dfa67fbeb528
7
- data.tar.gz: 161ed94aa16b10eccc916602c6fdd8593a5a088600e5845913c175f0ead6f502dff9a6a0ad071b0002191ed465a642e1fb74a4c004b0ccd559e3354b0f71a839
6
+ metadata.gz: 4d17679c6572756d466c8cfa14c7a07256c9e58d058b086800f4f18f23057f851e721de28af47e2e207cd46ab27f3c5d58a15bdc47fa2762b420be8921c7b12d
7
+ data.tar.gz: d86b7d85497dfe688385af9418e41438fd6a66b9ab18a4773122452dc438e45a2505b9fbde5d134798ffa0a570f886d9967ceab951b98da903c3f2d89526a4c1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Chef Metal Changelog
2
2
 
3
+ ## 0.14.2 (9/2/2014)
4
+
5
+ - Disable auto batching
6
+ - Fix for with_machine_options context hash
7
+ - Pass timeout from execution_options to winrm set_timeout
8
+ - Add better error message when driver does not specify driver_url
9
+ - Add info that location.driver_url is required
10
+ - Remove Chef 11.14 alpha note in readme
11
+ - Gracefully handle Host Down and Network Unreachable
12
+
3
13
  ## 0.14.1 (8/18/2014)
4
14
 
5
15
  - Fix "metal execute mario ls" to work again
data/README.md CHANGED
@@ -15,6 +15,7 @@ Date | Blog
15
15
 
16
16
  Documentation
17
17
  -------------
18
+ * [Frequently Asked Questions](https://github.com/opscode/chef-metal/blog/master/docs/faq.md)
18
19
  * [Configuration](https://github.com/opscode/chef-metal/blob/master/docs/configuration.md#configuring-and-using-metal-drivers)
19
20
  * [Writing Drivers](https://github.com/opscode/chef-metal/blob/master/docs/building_drivers.md#writing-drivers)
20
21
  * [Embedding](https://github.com/opscode/chef-metal/blob/master/docs/embedding.md)
@@ -124,7 +125,7 @@ Drivers each have their own repository. Current drivers:
124
125
 
125
126
  **Containers:**
126
127
  - [LXC](https://github.com/opscode/chef-metal-lxc) (not yet up to date with 0.11)
127
- - [Docker](https://github.com/opscode/chef-metal-docker) (not yet up to date with 0.11)
128
+ - [Docker](https://github.com/opscode/chef-metal-docker)
128
129
 
129
130
  **Bare Metal:**
130
131
  - [SSH (no PXE)](https://github.com/double-z/chef-metal-ssh) (not yet up to date with 0.11)
@@ -4,7 +4,9 @@ require 'openssl'
4
4
  require 'chef_metal/chef_provider_action_handler'
5
5
  require 'chef_metal/chef_machine_spec'
6
6
 
7
- class Chef::Provider::Machine < Chef::Provider::LWRPBase
7
+ class Chef
8
+ class Provider
9
+ class Machine < Chef::Provider::LWRPBase
8
10
 
9
11
  def action_handler
10
12
  @action_handler ||= ChefMetal::ChefProviderActionHandler.new(self)
@@ -133,6 +135,7 @@ class Chef::Provider::Machine < Chef::Provider::LWRPBase
133
135
  result
134
136
  end
135
137
  }
138
+
136
139
  configs << new_resource.machine_options if new_resource.machine_options
137
140
  configs << driver.config[:machine_options] if driver.config[:machine_options]
138
141
  Cheffish::MergedConfig.new(*configs)
@@ -167,4 +170,7 @@ class Chef::Provider::Machine < Chef::Provider::LWRPBase
167
170
  def upload_files(machine)
168
171
  Machine.upload_files(action_handler, machine, new_resource.files)
169
172
  end
173
+
174
+ end
175
+ end
170
176
  end
@@ -6,7 +6,9 @@ require 'chef_metal/add_prefix_action_handler'
6
6
  require 'chef_metal/machine_spec'
7
7
  require 'chef_metal/chef_machine_spec'
8
8
 
9
- class Chef::Provider::MachineBatch < Chef::Provider::LWRPBase
9
+ class Chef
10
+ class Provider
11
+ class MachineBatch < Chef::Provider::LWRPBase
10
12
 
11
13
  def action_handler
12
14
  @action_handler ||= ChefMetal::ChefProviderActionHandler.new(self)
@@ -183,4 +185,7 @@ class Chef::Provider::MachineBatch < Chef::Provider::LWRPBase
183
185
  result = Chef::Mixin::DeepMerge.hash_only_merge(result, new_resource.machine_options)
184
186
  result
185
187
  end
188
+
189
+ end
190
+ end
186
191
  end
@@ -2,7 +2,9 @@ require 'chef/provider/lwrp_base'
2
2
  require 'chef_metal/chef_provider_action_handler'
3
3
  require 'chef_metal/machine'
4
4
 
5
- class Chef::Provider::MachineExecute < Chef::Provider::LWRPBase
5
+ class Chef
6
+ class Provider
7
+ class MachineExecute < Chef::Provider::LWRPBase
6
8
 
7
9
  def action_handler
8
10
  @action_handler ||= ChefMetal::ChefProviderActionHandler.new(self)
@@ -27,4 +29,7 @@ class Chef::Provider::MachineExecute < Chef::Provider::LWRPBase
27
29
  action :run do
28
30
  machine.execute(action_handler, new_resource.command)
29
31
  end
32
+
33
+ end
34
+ end
30
35
  end
@@ -2,7 +2,9 @@ require 'chef/provider/lwrp_base'
2
2
  require 'chef_metal/chef_provider_action_handler'
3
3
  require 'chef_metal/machine'
4
4
 
5
- class Chef::Provider::MachineFile < Chef::Provider::LWRPBase
5
+ class Chef
6
+ class Provider
7
+ class MachineFile < Chef::Provider::LWRPBase
6
8
 
7
9
  def action_handler
8
10
  @action_handler ||= ChefMetal::ChefProviderActionHandler.new(self)
@@ -46,4 +48,7 @@ class Chef::Provider::MachineFile < Chef::Provider::LWRPBase
46
48
  action :delete do
47
49
  machine.delete_file(action_handler, new_resource.path)
48
50
  end
51
+
52
+ end
53
+ end
49
54
  end
@@ -4,7 +4,10 @@ require 'openssl'
4
4
  require 'chef_metal/chef_provider_action_handler'
5
5
  require 'chef_metal/chef_image_spec'
6
6
 
7
- class Chef::Provider::MachineImage < Chef::Provider::LWRPBase
7
+ class Chef
8
+ class Provider
9
+ class MachineImage < Chef::Provider::LWRPBase
10
+
8
11
  def action_handler
9
12
  @action_handler ||= ChefMetal::ChefProviderActionHandler.new(self)
10
13
  end
@@ -51,4 +54,7 @@ class Chef::Provider::MachineImage < Chef::Provider::LWRPBase
51
54
  # 4. Wait for image to be ready
52
55
  new_driver.ready_image(action_handler, image_spec, new_resource.image_options)
53
56
  end
57
+
58
+ end
54
59
  end
60
+ end
@@ -3,7 +3,10 @@ require 'cheffish'
3
3
  require 'chef_metal'
4
4
  require 'cheffish/merged_config'
5
5
 
6
- class Chef::Resource::Machine < Chef::Resource::LWRPBase
6
+ class Chef
7
+ class Resource
8
+ class Machine < Chef::Resource::LWRPBase
9
+
7
10
  self.resource_name = 'machine'
8
11
 
9
12
  def initialize(*args)
@@ -19,8 +22,10 @@ class Chef::Resource::Machine < Chef::Resource::LWRPBase
19
22
 
20
23
  # Driver attributes
21
24
  attribute :driver
22
- attribute :machine_options
23
25
 
26
+ # Machine options
27
+ attribute :machine_options
28
+
24
29
  # Node attributes
25
30
  Cheffish.node_attributes(self)
26
31
 
@@ -92,8 +97,28 @@ class Chef::Resource::Machine < Chef::Resource::LWRPBase
92
97
  @machine_options = Cheffish::MergedConfig.new(options, @machine_options)
93
98
  end
94
99
 
100
+
101
+ # This is here because metal users will probably want to do things like:
102
+ # machine "foo"
103
+ # action :destroy
104
+ # end
105
+ #
106
+ # @example
107
+ # with_machine_options :bootstrap_options => { ... }
108
+ # machine "foo"
109
+ # converge true
110
+ # end
111
+ #
112
+ # Without this, the first resource's machine options will obliterate the second
113
+ # resource's machine options, and then unexpected (and undesired) things happen.
114
+ def load_prior_resource
115
+ Chef::Log.debug "Overloading #{self.resource_name} load_prior_resource with NOOP"
116
+ end
117
+
95
118
  # chef client version and omnibus
96
119
  # chef-zero boot method?
97
120
  # chef-client -z boot method?
98
121
  # pushy boot method?
99
122
  end
123
+ end
124
+ end
@@ -1,7 +1,10 @@
1
1
  require 'chef/resource/lwrp_base'
2
2
  require 'chef/mixin/deep_merge'
3
3
 
4
- class Chef::Resource::MachineBatch < Chef::Resource::LWRPBase
4
+ class Chef
5
+ class Resource
6
+ class MachineBatch < Chef::Resource::LWRPBase
7
+
5
8
  self.resource_name = 'machine_batch'
6
9
 
7
10
  def initialize(*args)
@@ -69,4 +72,7 @@ class Chef::Resource::MachineBatch < Chef::Resource::LWRPBase
69
72
  end
70
73
  text << "end\n"
71
74
  end
75
+
76
+ end
77
+ end
72
78
  end
@@ -3,7 +3,10 @@ require 'chef_metal'
3
3
  require 'chef_metal/machine'
4
4
  require 'chef_metal/driver'
5
5
 
6
- class Chef::Resource::MachineExecute < Chef::Resource::LWRPBase
6
+ class Chef
7
+ class Resource
8
+ class MachineExecute < Chef::Resource::LWRPBase
9
+
7
10
  self.resource_name = 'machine_execute'
8
11
 
9
12
  def initialize(*args)
@@ -19,4 +22,7 @@ class Chef::Resource::MachineExecute < Chef::Resource::LWRPBase
19
22
 
20
23
  attribute :chef_server, :kind_of => Hash
21
24
  attribute :driver, :kind_of => ChefMetal::Driver
25
+
26
+ end
22
27
  end
28
+ end
@@ -3,7 +3,10 @@ require 'chef_metal'
3
3
  require 'chef_metal/machine'
4
4
  require 'chef_metal/driver'
5
5
 
6
- class Chef::Resource::MachineFile < Chef::Resource::LWRPBase
6
+ class Chef
7
+ class Resource
8
+ class MachineFile < Chef::Resource::LWRPBase
9
+
7
10
  self.resource_name = 'machine_file'
8
11
 
9
12
  def initialize(*args)
@@ -25,4 +28,7 @@ class Chef::Resource::MachineFile < Chef::Resource::LWRPBase
25
28
 
26
29
  attribute :chef_server, :kind_of => Hash
27
30
  attribute :driver, :kind_of => ChefMetal::Driver
31
+
32
+ end
28
33
  end
34
+ end
@@ -3,7 +3,10 @@ require 'cheffish'
3
3
  require 'chef_metal'
4
4
  require 'cheffish/merged_config'
5
5
 
6
- class Chef::Resource::MachineImage < Chef::Resource::Machine
6
+ class Chef
7
+ class Resource
8
+ class MachineImage < Chef::Resource::Machine
9
+
7
10
  self.resource_name = 'machine_image'
8
11
 
9
12
  def initialize(*args)
@@ -26,4 +29,7 @@ class Chef::Resource::MachineImage < Chef::Resource::Machine
26
29
  # - ability to rebuild new image based on the previous image
27
30
  # - ability to specify whether and how to keep the image-building machine around
28
31
  # - ability to specify whether to leave the chef config around or not
32
+
33
+ end
34
+ end
29
35
  end
@@ -1,11 +1,10 @@
1
1
  require 'chef/mixin/deep_merge'
2
- require 'cheffish/with_pattern'
3
2
  require 'cheffish/merged_config'
4
3
  require 'chef_metal/chef_machine_spec'
5
4
 
6
5
  module ChefMetal
7
6
  class ChefRunData
8
- extend Cheffish::WithPattern
7
+
9
8
  def initialize(config)
10
9
  @config = config
11
10
  @drivers = {}
@@ -14,9 +13,32 @@ module ChefMetal
14
13
  attr_reader :config
15
14
  attr_reader :drivers
16
15
  attr_reader :current_driver
16
+ attr_accessor :current_machine_options
17
+ attr_accessor :current_image_options
17
18
 
18
- with :machine_options
19
- with :image_options
19
+ def with_machine_options(value)
20
+ old_value = self.current_machine_options
21
+ self.current_machine_options = value
22
+ if block_given?
23
+ begin
24
+ yield
25
+ ensure
26
+ self.current_machine_options = old_value
27
+ end
28
+ end
29
+ end
30
+
31
+ def with_image_options(value)
32
+ old_value = self.current_image_options
33
+ self.current_image_options = value
34
+ if block_given?
35
+ begin
36
+ yield
37
+ ensure
38
+ self.current_image_options = old_value
39
+ end
40
+ end
41
+ end
20
42
 
21
43
  def with_driver(driver, options = nil, &block)
22
44
  if drivers[driver] && options
@@ -26,18 +48,6 @@ module ChefMetal
26
48
  @current_driver_options = options
27
49
  end
28
50
 
29
- def auto_batch_machines
30
- if !@auto_batch_machines.nil?
31
- @auto_batch_machines
32
- else
33
- config[:auto_batch_machines]
34
- end
35
- end
36
-
37
- def auto_batch_machines=(value)
38
- @auto_batch_machines = value
39
- end
40
-
41
51
  def current_driver
42
52
  @current_driver || config[:driver]
43
53
  end
@@ -3,6 +3,7 @@ require 'pathname'
3
3
  require 'fileutils'
4
4
  require 'digest/md5'
5
5
  require 'thread'
6
+ require 'chef/http/simple'
6
7
 
7
8
  module ChefMetal
8
9
  class ConvergenceStrategy
@@ -118,11 +119,7 @@ module ChefMetal
118
119
  # Download and parse the metadata
119
120
  Chef::Log.debug("Getting metadata for machine #{machine.node['name']}: #{metadata_url}")
120
121
  uri = URI(metadata_url)
121
- http = Net::HTTP.new(uri.host, uri.port)
122
- http.use_ssl = use_ssl
123
- request = Net::HTTP::Get.new(uri.request_uri)
124
- response = http.request(request)
125
- metadata_str = response.body
122
+ metadata_str = Chef::HTTP::Simple.new(uri).get(uri)
126
123
  metadata = {}
127
124
  metadata_str.each_line do |line|
128
125
  key, value = line.split("\t", 2)
@@ -173,7 +173,7 @@ module ChefMetal
173
173
  chef_server_url #{chef_server_url.inspect}
174
174
  node_name #{node_name.inspect}
175
175
  client_key #{convergence_options[:client_pem_path].inspect}
176
- ssl_verify_mode :verify_none
176
+ ssl_verify_mode :verify_peer
177
177
  EOM
178
178
  end
179
179
  end
@@ -6,25 +6,23 @@ module ChefMetal
6
6
  # For AWS, a Driver instance corresponds to a single account.
7
7
  # For Vagrant, it is a directory where VM files are found.
8
8
  #
9
- # == How to Make a Driver
9
+ # = How to Make a Driver
10
10
  #
11
11
  # To implement a Driver, you must implement the following methods:
12
12
  #
13
- # - initialize(driver_url) - create a new driver with the given URL
14
- # - driver_url - a URL representing everything unique about your driver.
15
- # But NOT credentials.
16
- # - allocate_machine - ask the driver to allocate a machine to you.
17
- # - ready_machine - get the machine "ready" - wait for it to be booted and
18
- # accessible (for example, accessible via SSH transport).
19
- # - stop_machine - stop the machine.
20
- # - destroy_machine - delete the machine.
21
- # - connect_to_machine - connect to the given machine.
13
+ # * initialize(driver_url) - create a new driver with the given URL
14
+ # * driver_url - a URL representing everything unique about your driver. (NOT credentials)
15
+ # * allocate_machine - ask the driver to allocate a machine to you.
16
+ # * ready_machine - get the machine "ready" - wait for it to be booted and accessible (for example, accessible via SSH transport).
17
+ # * stop_machine - stop the machine.
18
+ # * destroy_machine - delete the machine.
19
+ # * connect_to_machine - connect to the given machine.
22
20
  #
23
21
  # Optionally, you can also implement:
24
- # - allocate_machines - allocate an entire group of machines.
25
- # - ready_machines - get a group of machines warm and booted.
26
- # - stop_machines - stop a group of machines.
27
- # - destroy_machines - delete a group of machines.
22
+ # * allocate_machines - allocate an entire group of machines.
23
+ # * ready_machines - get a group of machines warm and booted.
24
+ # * stop_machines - stop a group of machines.
25
+ # * destroy_machines - delete a group of machines.
28
26
  #
29
27
  # Additionally, you must create a file named `chef_metal/driver_init/<scheme>.rb`,
30
28
  # where <scheme> is the name of the scheme you chose for your driver_url. This
@@ -39,8 +37,8 @@ module ChefMetal
39
37
  #
40
38
  # Inflate a driver from a driver URL.
41
39
  #
42
- # == Parameters
43
- # driver_url - the URL to inflate the driver
40
+ #
41
+ # @param [String] driver_url the URL to inflate the driver
44
42
  # config - a configuration hash. See "config" for a list of known keys.
45
43
  #
46
44
  # == Returns
@@ -61,7 +59,7 @@ module ChefMetal
61
59
  #
62
60
  # A URL representing the driver and the place where machines come from.
63
61
  # This will be stuffed in machine_spec.location['driver_url'] so that the
64
- # machine can be reinflated. URLs must have a unique scheme identifying the
62
+ # machine can be re-inflated. URLs must have a unique scheme identifying the
65
63
  # driver class, and enough information to identify the place where created
66
64
  # machines can be found. For AWS, this is the account number; for lxc and
67
65
  # vagrant, it is the directory in which VMs and containers are.
@@ -92,8 +90,8 @@ module ChefMetal
92
90
  config[:driver_options] || {}
93
91
  end
94
92
 
95
- #
96
- # Allocate a machine from the PXE/cloud/VM/container driver. This method
93
+
94
+ # Allocate a machine from the underlying service. This method
97
95
  # does not need to wait for the machine to boot or have an IP, but it must
98
96
  # store enough information in machine_spec.location to find the machine
99
97
  # later in ready_machine.
@@ -102,103 +100,91 @@ module ChefMetal
102
100
  # it, but does not need to wait until it is started. The idea is to get the
103
101
  # gears moving, but the job doesn't need to be done :)
104
102
  #
105
- # ## Parameters
106
- # action_handler - the action_handler object that is calling this method; this
107
- # is generally a driver, but could be anything that can support the
108
- # interface (i.e., in the case of the test kitchen metal driver for
109
- # acquiring and destroying VMs).
110
- #
111
- # existing_machine - a MachineSpec representing the existing machine (if any).
112
- #
113
- # machine_options - a set of options representing the desired provisioning
114
- # state of the machine (image name, bootstrap ssh credentials,
115
- # etc.). This will NOT be stored in the machine_spec, and is
116
- # ephemeral.
103
+ # @param [ChefMetal::ActionHandler] action_handler The action_handler object that is calling this method
104
+ # @param [ChefMetal::MachineSpec] machine_spec A machine specification representing this machine.
105
+ # @param [Hash] machine_options A set of options representing the desired options when
106
+ # constructing the machine
117
107
  #
118
- # ## Returns
119
- #
120
- # Modifies the passed-in machine_spec. Anything in here will be saved
108
+ # @return [ChefMetal::MachineSpec] Modifies the passed-in machine_spec. Anything in here will be saved
121
109
  # back after allocate_machine completes.
122
110
  #
123
111
  def allocate_machine(action_handler, machine_spec, machine_options)
124
112
  raise "#{self.class} does not implement allocate_machine"
125
113
  end
126
114
 
127
- #
128
115
  # Ready a machine, to the point where it is running and accessible via a
129
116
  # transport. This will NOT allocate a machine, but may kick it if it is down.
130
117
  # This method waits for the machine to be usable, returning a Machine object
131
118
  # pointing at the machine, allowing useful actions like setup, converge,
132
119
  # execute, file and directory.
133
120
  #
134
- # ## Parameters
135
- # action_handler - the action_handler object that is calling this method; this
136
- # is generally a driver, but could be anything that can support the
137
- # interface (i.e., in the case of the test kitchen metal driver for
138
- # acquiring and destroying VMs).
139
- # machine_spec - MachineSpec representing this machine.
140
- # machine_options - a set of options representing the desired provisioning
141
- # state of the machine (image name, bootstrap ssh credentials,
142
- # etc.). This will NOT be stored in the machine_spec, and is
143
- # ephemeral.
144
121
  #
145
- # ## Returns
122
+ # @param [ChefMetal::ActionHandler] action_handler The action_handler object that is calling this method
123
+ # @param [ChefMetal::MachineSpec] machine_spec A machine specification representing this machine.
124
+ # @param [Hash] machine_options A set of options representing the desired state of the machine
146
125
  #
147
- # Machine object pointing at the machine, allowing useful actions like setup,
126
+ # @return [Machine] A machine object pointing at the machine, allowing useful actions like setup,
148
127
  # converge, execute, file and directory.
149
128
  #
150
129
  def ready_machine(action_handler, machine_spec, machine_options)
151
130
  raise "#{self.class} does not implement ready_machine"
152
131
  end
153
132
 
154
- #
155
133
  # Connect to a machine without allocating or readying it. This method will
156
134
  # NOT make any changes to anything, or attempt to wait.
157
135
  #
158
- # ## Parameters
159
- # machine_spec - MachineSpec representing this machine.
160
- #
161
- # ## Returns
162
- #
163
- # Machine object pointing at the machine, allowing useful actions like setup,
136
+ # @param [ChefMetal::MachineSpec] machine_spec MachineSpec representing this machine.
137
+ # @param [Hash] machine_options
138
+ # @return [Machine] A machine object pointing at the machine, allowing useful actions like setup,
164
139
  # converge, execute, file and directory.
165
140
  #
166
141
  def connect_to_machine(machine_spec, machine_options)
167
142
  raise "#{self.class} does not implement connect_to_machine"
168
143
  end
169
144
 
170
- #
171
- # Delete the given machine (idempotent). Should destroy the machine,
145
+
146
+ # Delete the given machine -- destroy the machine,
172
147
  # returning things to the state before allocate_machine was called.
173
148
  #
149
+ # @param [ChefMetal::ActionHandler] action_handler The action_handler object that is calling this method
150
+ # @param [ChefMetal::MachineSpec] machine_spec A machine specification representing this machine.
151
+ # @param [Hash] machine_options A set of options representing the desired state of the machine
174
152
  def destroy_machine(action_handler, machine_spec, machine_options)
175
153
  raise "#{self.class} does not implement destroy_machine"
176
154
  end
177
155
 
178
- #
179
156
  # Stop the given machine.
180
157
  #
158
+ # @param [ChefMetal::ActionHandler] action_handler The action_handler object that is calling this method
159
+ # @param [ChefMetal::MachineSpec] machine_spec A machine specification representing this machine.
160
+ # @param [Hash] machine_options A set of options representing the desired state of the machine
181
161
  def stop_machine(action_handler, machine_spec, machine_options)
182
162
  raise "#{self.class} does not implement stop_machine"
183
163
  end
184
164
 
185
- #
186
165
  # Allocate an image. Returns quickly with an ID that tracks the image.
187
166
  #
167
+ # @param [ChefMetal::ActionHandler] action_handler The action_handler object that is calling this method
168
+ # @param [ChefMetal::ImageSpec] image_spec A machine specification representing this machine.
169
+ # @param [Hash] image_options A set of options representing the desired state of the machine
188
170
  def allocate_image(action_handler, image_spec, image_options, machine_spec)
189
171
  raise "#{self.class} does not implement create_image"
190
172
  end
191
173
 
192
- #
193
174
  # Ready an image, waiting till the point where it is ready to be used.
194
175
  #
176
+ # @param [ChefMetal::ActionHandler] action_handler The action_handler object that is calling this method
177
+ # @param [ChefMetal::ImageSpec] image_spec A machine specification representing this machine.
178
+ # @param [Hash] image_options A set of options representing the desired state of the machine
195
179
  def ready_image(action_handler, image_spec, image_options)
196
180
  raise "#{self.class} does not implement ready_image"
197
181
  end
198
182
 
183
+ # Destroy an image using this service.
199
184
  #
200
- # Destroy an image.
201
- #
185
+ # @param [ChefMetal::ActionHandler] action_handler The action_handler object that is calling this method
186
+ # @param [ChefMetal::ImageSpec] image_spec A machine specification representing this machine.
187
+ # @param [Hash] image_options A set of options representing the desired state of the machine
202
188
  def destroy_image(action_handler, image_spec, image_options)
203
189
  raise "#{self.class} does not implement destroy_image"
204
190
  end
@@ -214,15 +200,10 @@ module ChefMetal
214
200
  # Drivers do not need to implement this; the default implementation
215
201
  # calls acquire_machine in parallel.
216
202
  #
217
- # ## Parameters
218
- # action_handler - the action_handler object that is calling this method; this
219
- # is generally a driver, but could be anything that can support the
220
- # interface (i.e., in the case of the test kitchen metal driver for
221
- # acquiring and destroying VMs).
222
- # specs_and_options - a hash of machine_spec -> machine_options representing the
223
- # machines to allocate.
224
- # parallelizer - an object with a parallelize() method that works like this:
203
+ # == Parallelizing
225
204
  #
205
+ # The parallelizer must implement #parallelize
206
+ # @example Example parallelizer
226
207
  # parallelizer.parallelize(specs_and_options) do |machine_spec|
227
208
  # allocate_machine(action_handler, machine_spec)
228
209
  # end.to_a
@@ -232,16 +213,25 @@ module ChefMetal
232
213
  # not go over parallelization limits set by the user. Use of the parallelizer
233
214
  # to parallelizer machines is not required.
234
215
  #
235
- # ## Block
216
+ # == Passing a block
236
217
  #
237
218
  # If you pass a block to this function, each machine will be yielded to you
238
219
  # as it completes, and then the function will return when all machines are
239
220
  # yielded.
240
221
  #
222
+ # @example Passing a block
241
223
  # allocate_machines(action_handler, specs_and_options, parallelizer) do |machine_spec|
242
224
  # ...
243
225
  # end
244
226
  #
227
+ # @param [ChefMetal::ActionHandler] action_handler The action_handler object that is calling this method; this
228
+ # is generally a driver, but could be anything that can support the
229
+ # interface (i.e., in the case of the test kitchen metal driver for
230
+ # acquiring and destroying VMs).
231
+ # @param [Hash] specs_and_options A hash of machine_spec -> machine_options representing the
232
+ # machines to allocate.
233
+ # @param [Parallelizer] parallelizer an object with a parallelize() method that works like this:
234
+ # @return [Array<Machine>] An array of machine objects created
245
235
  def allocate_machines(action_handler, specs_and_options, parallelizer)
246
236
  parallelizer.parallelize(specs_and_options) do |machine_spec, machine_options|
247
237
  allocate_machine(add_prefix(machine_spec, action_handler), machine_spec, machine_options)
@@ -275,6 +265,7 @@ module ChefMetal
275
265
  end.to_a
276
266
  end
277
267
 
268
+
278
269
  protected
279
270
 
280
271
  def add_prefix(machine_spec, action_handler)
@@ -102,7 +102,7 @@ module ChefMetal
102
102
  # Returns a triplet:
103
103
  # platform, platform_version, machine_architecture = machine.detect_os(action_handler)
104
104
  # This triplet is suitable for passing to the Chef metadata API:
105
- # https://www.opscode.com/chef/metadata?p=#{platform}&pv=#{platform_version}&m=#{machine_architecture}
105
+ # https://www.opscode.com/chef/metadata?p=PLATFORM&pv=PLATFORM_VERSION&m=MACHINE_ARCHITECTURE
106
106
  def detect_os(action_handler)
107
107
  raise "detect_os not overridden on #{self.class}"
108
108
  end
@@ -15,6 +15,7 @@ require 'chef/provider/machine_image'
15
15
  class Chef
16
16
  module DSL
17
17
  module Recipe
18
+
18
19
  def with_driver(driver, options = nil, &block)
19
20
  run_context.chef_metal.with_driver(driver, options, &block)
20
21
  end
@@ -41,14 +42,6 @@ class Chef
41
42
 
42
43
  NOT_PASSED = Object.new
43
44
 
44
- def auto_batch_machines(value = NOT_PASSED)
45
- if value == NOT_PASSED
46
- run_context.chef_metal.auto_batch_machines
47
- else
48
- run_context.chef_metal.auto_batch_machines = value
49
- end
50
- end
51
-
52
45
  @@next_machine_batch_index = 0
53
46
 
54
47
  def machine_batch_default_name
@@ -69,47 +62,11 @@ class Chef
69
62
  end
70
63
  end
71
64
 
72
- # When the machine resource is first declared, create a machine_batch (if there
73
- # isn't one already)
74
- def machine(name, &block)
75
- resource = build_resource(:machine, name, caller[0], &block)
76
-
77
- # Grab the previous resource so we can decide whether to batch this or make it its own resource.
78
- previous_index = run_context.resource_collection.previous_index
79
- previous = previous_index >= 0 ? run_context.resource_collection[previous_index] : nil
80
- if run_context.chef_metal.auto_batch_machines &&
81
- previous &&
82
- Array(resource.action).size == 1 &&
83
- Array(previous.action) == Array(resource.action)
84
-
85
- # Handle batching similar machines (with similar actions)
86
- if previous.is_a?(Chef::Resource::MachineBatch)
87
- # If we see a machine declared after a previous machine_batch with the same action, add it to the batch.
88
- previous.machines << resource
89
- elsif previous.is_a?(Chef::Resource::Machine)
90
- # If we see two machines in a row with the same action, batch them.
91
- _self = self
92
- batch = build_resource(:machine_batch, machine_batch_default_name) do
93
- action resource.action
94
- machines [ previous, resource ]
95
- end
96
- batch.from_recipe self
97
- run_context.resource_collection[previous_index] = batch
98
- else
99
- run_context.resource_collection.insert(resource)
100
- end
101
-
102
- else
103
- run_context.resource_collection.insert(resource)
104
- end
105
- resource
106
- end
107
65
  end
108
66
  end
109
67
 
110
68
  class Config
111
69
  default(:driver) { ENV['CHEF_DRIVER'] }
112
- default(:auto_batch_machines) { true }
113
70
  # config_context :drivers do
114
71
  # # each key is a driver_url, and each value can have driver, driver_options and machine_options
115
72
  # config_strict_mode false
@@ -10,6 +10,26 @@ require 'net/ssh/gateway'
10
10
  module ChefMetal
11
11
  class Transport
12
12
  class SSH < ChefMetal::Transport
13
+ #
14
+ # Create a new SSH transport.
15
+ #
16
+ # == Arguments
17
+ #
18
+ # - host: the host to connect to, e.g. '145.14.51.45'
19
+ # - username: the username to connect with
20
+ # - ssh_options: a list of options to Net::SSH.start
21
+ # - options: a hash of options for the transport itself, including:
22
+ # - :prefix: a prefix to send before each command (e.g. "sudo ")
23
+ # - :ssh_pty_enable: set to false to disable pty (some instances don't
24
+ # support this, most do)
25
+ # - :ssh_gateway: the gateway to use, e.g. "jkeiser@145.14.51.45:222".
26
+ # nil (the default) means no gateway.
27
+ # - global_config: an options hash that looks suspiciously similar to
28
+ # Chef::Config, containing at least the key :log_level.
29
+ #
30
+ # The options are used in
31
+ # Net::SSH.start(host, username, ssh_options)
32
+
13
33
  def initialize(host, username, ssh_options, options, global_config)
14
34
  @host = host
15
35
  @username = username
@@ -224,7 +244,7 @@ module ChefMetal
224
244
  end
225
245
 
226
246
  def gateway
227
- gw_host, gw_user = options[:ssh_gateway].split('@').reverse
247
+ gw_user, gw_host = options[:ssh_gateway].split('@')
228
248
  gw_host, gw_port = gw_host.split(':')
229
249
  gw_user = ssh_options[:ssh_username] unless gw_user
230
250
 
@@ -4,7 +4,22 @@ require 'timeout'
4
4
 
5
5
  module ChefMetal
6
6
  class Transport
7
+ # Transport to handle the WinRM connection protocol.
7
8
  class WinRM < ChefMetal::Transport
9
+ #
10
+ # Create a new WinRM transport.
11
+ #
12
+ # == Arguments
13
+ # - endpoint: the WinRM endpoint, e.g. http://145.14.51.45:5985/wsman.
14
+ # - type: the connection type, e.g. :plaintext.
15
+ # - options: options hash, including both WinRM options and transport options.
16
+ # For transport options, see the Transport.options definition. WinRM
17
+ # options include :user, :pass, :disable_sspi => true, among others.
18
+ # - global_config: an options hash that looks suspiciously similar to
19
+ # Chef::Config, containing at least the key :log_level.
20
+ #
21
+ # The actual connection is made as ::WinRM::WinRMWebService.new(endpoint, type, options)
22
+ #
8
23
  def initialize(endpoint, type, options, global_config)
9
24
  @endpoint = endpoint
10
25
  @type = type
@@ -7,14 +7,19 @@ module ChefMetal
7
7
  # Execute a program on the remote host.
8
8
  #
9
9
  # == Arguments
10
- # command: command to run. May be a shell-escaped string or a pre-split array containing [PROGRAM, ARG1, ARG2, ...].
10
+ # command: command to run. May be a shell-escaped string or a pre-split
11
+ # array containing [PROGRAM, ARG1, ARG2, ...].
11
12
  # options: hash of options, including but not limited to:
12
- # :timeout => NUM_SECONDS - time to wait before program finishes (throws an exception otherwise). Set to nil or 0 to run with no timeout. Defaults to 15 minutes.
13
+ # :timeout => NUM_SECONDS - time to wait before program finishes
14
+ # (throws an exception otherwise). Set to nil or 0 to
15
+ # run with no timeout. Defaults to 15 minutes.
13
16
  # :stream => BOOLEAN - true to stream stdout and stderr to the console.
14
- # :stream => BLOCK - block to stream stdout and stderr to (block.call(stdout_chunk, stderr_chunk))
17
+ # :stream => BLOCK - block to stream stdout and stderr to
18
+ # (block.call(stdout_chunk, stderr_chunk))
15
19
  # :stream_stdout => FD - FD to stream stdout to (defaults to IO.stdout)
16
20
  # :stream_stderr => FD - FD to stream stderr to (defaults to IO.stderr)
17
- # :read_only => BOOLEAN - true if command is guaranteed not to change system state (useful for Docker)
21
+ # :read_only => BOOLEAN - true if command is guaranteed not to
22
+ # change system state (useful for Docker)
18
23
  def execute(command, options = {})
19
24
  raise "execute not overridden on #{self.class}"
20
25
  end
@@ -1,3 +1,3 @@
1
1
  module ChefMetal
2
- VERSION = '0.14.alpha.3'
2
+ VERSION = '0.14.alpha.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clc-fork-chef-metal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.alpha.3
4
+ version: 0.14.alpha.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-08 00:00:00.000000000 Z
11
+ date: 2014-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -81,33 +81,33 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: clc-cheffish
84
+ name: cheffish
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.8.clc
89
+ version: '0.8'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.8.clc
96
+ version: '0.8'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: winrm
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.1.3
103
+ version: 1.2.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.1.3
110
+ version: 1.2.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement