chef-provisioning-fog 0.18.0 → 0.19.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: 7a903c7684ebc84d52a05fb774779952b1769d46
4
- data.tar.gz: 22c0d531e5664e6806e34b8401013afd77855125
3
+ metadata.gz: fb7a20a86bedac40466c9f1ef6f3ffe0e6f8ada8
4
+ data.tar.gz: e77ef8bf2a3f5a685e43495b4820c1d1c913c461
5
5
  SHA512:
6
- metadata.gz: 838ce6611ff9ee741f622345a60f8d00244612b11a23d4912e23d432948cc9d11f9ba698fe672a1bee74e2e1830bab9695a6ceafb1234a9e0e0a854def4c5d5b
7
- data.tar.gz: 31bbeddadc8045701cfb9e8d45873a99ab033bfe4a8592442a7db1b3fc728c6d09743648640de406da095ed5c2603e8a09496287ead31653e7166b67227f89ff
6
+ metadata.gz: a1d2ea4273853a0b71603e5b5e36abe234646cdf8d5bc6297bb3d12987988349af74e5f0f83e5df64532c1e8ce9e2058f8178bb17091e34465cc6172b2675334
7
+ data.tar.gz: e43836b5011677d59a494b3cf94115e9583e284e8f1fd0fce7321084afaf4b6f7bff891928e86af9804dc1916e2b2d95710355bb0fe8481e75a8ec8b49a43a3d
data/README.md CHANGED
@@ -37,9 +37,9 @@ For example:
37
37
  ```ruby
38
38
  driver 'fog:AWS:<account_id>:<region>'
39
39
  driver_options :compute_options => {
40
- :aws_access_key_id => 'YOUR-ACCESS-KEY-ID',
41
- :aws_secret_access_key => 'YOUR-SECRET-ACCESS-KEY',
42
- :region => 'THE-REGION-YOU-WANT-TO-PROVISION-IN'
40
+ :aws_access_key_id => 'YOUR-ACCESS-KEY-ID',
41
+ :aws_secret_access_key => 'YOUR-SECRET-ACCESS-KEY',
42
+ :region => 'THE-REGION-YOU-WANT-TO-PROVISION-IN'
43
43
  }
44
44
  ```
45
45
 
@@ -52,9 +52,9 @@ Update your `knife.rb` to contain your DigitalOcean API token and the driver:
52
52
 
53
53
  ```ruby
54
54
  driver 'fog:DigitalOcean'
55
- driver_options compute_options: {
56
- digitalocean_token: 'token'
57
- }
55
+ driver_options :compute_options => {
56
+ :digitalocean_token => 'token'
57
+ }
58
58
  ```
59
59
 
60
60
  For a full example see [examples/digitalocean/simple.rb](examples/digitalocean/simple.rb).
@@ -177,8 +177,19 @@ Docs TODO.
177
177
 
178
178
  ### XenServer
179
179
 
180
- Docs TODO.
180
+ You should configure XenServer driver with your credentials:
181
+
182
+ ```ruby
183
+ with_driver "fog:XenServer:<XEN-SERVER-IP/NAME>", compute_options: {
184
+ xenserver_username: 'MY-XEN-USER',
185
+ xenserver_password: 'MY-XEN-PASSWORD',
186
+ xenserver_defaults: {
187
+ 'template' => 'ubuntu-14.04'
188
+ }
189
+ }
190
+ ```
181
191
 
192
+ For a full example see [examples/xenserver/simple.rb](examples/xenserver/simple.rb).
182
193
 
183
194
  ### Cleaning up
184
195
 
@@ -134,7 +134,7 @@ module FogDriver
134
134
  if machine_options[:is_windows]
135
135
  Chef::Log.debug('Attaching WinRM data for user data.')
136
136
  # Enable WinRM basic auth, HTTP and open the firewall
137
- bootstrap_options[:user_data] = user_data
137
+ bootstrap_options[:user_data] = user_data if bootstrap_options[:user_data].nil?
138
138
  end
139
139
  bootstrap_options.delete(:tags) # we handle these separately for performance reasons
140
140
  bootstrap_options
@@ -18,6 +18,25 @@ module FogDriver
18
18
  super(machine_spec, machine_options)
19
19
  end
20
20
 
21
+ def create_winrm_transport(machine_spec, machine_options, server)
22
+ if machine_options[:winrm].nil?
23
+ fail "You must provide winrm settings in machine_options to use the winrm transport!"
24
+ end
25
+ remote_host = determine_remote_host machine_spec, server
26
+ Chef::Log::info("Connecting to server #{remote_host}")
27
+ port = machine_options[:winrm][:port] || 5985
28
+ endpoint = "http://#{remote_host}:#{port}/wsman"
29
+ type = machine_options[:winrm][:type] || :negotiate
30
+ decrypted_password = machine_options[:winrm][:password] || ''
31
+ options = {
32
+ :user => machine_options[:winrm][:username] || 'Administrator',
33
+ :pass => decrypted_password,
34
+ :disable_sspi => !!machine_options[:winrm][:disable_sspi] || false,
35
+ :basic_auth_only => !!machine_options[:winrm][:basic_auth_only] || false
36
+ }
37
+ Chef::Provisioning::Transport::WinRM.new(endpoint, type, options, {})
38
+ end
39
+
21
40
  def self.compute_options_for(provider, id, config)
22
41
  new_compute_options = {}
23
42
  new_compute_options[:provider] = provider
@@ -117,6 +136,32 @@ module FogDriver
117
136
  end
118
137
  end
119
138
 
139
+ def determine_remote_host(machine_spec, server)
140
+ transport_address_location = (machine_spec.reference['transport_address_location'] || :none).to_sym
141
+
142
+ if machine_spec.reference['use_private_ip_for_ssh']
143
+ # The machine_spec has the old config key, lets update it - a successful chef converge will save the machine_spec
144
+ # TODO in 2.0 get rid of this update
145
+ machine_spec.reference.delete('use_private_ip_for_ssh')
146
+ machine_spec.reference['transport_address_location'] = :private_ip
147
+ server.private_ip_address
148
+ elsif transport_address_location == :ip_addresses
149
+ server.ip_addresses.first
150
+ elsif transport_address_location == :private_ip
151
+ server.private_ip_address
152
+ elsif transport_address_location == :public_ip
153
+ server.public_ip_address
154
+ elsif !server.public_ip_address && server.private_ip_address
155
+ Chef::Log.warn("Server #{machine_spec.name} has no public floating_ip address. Using private floating_ip '#{server.private_ip_address}'. Set driver option 'transport_address_location' => :private_ip if this will always be the case ...")
156
+ server.private_ip_address
157
+ elsif server.public_ip_address
158
+ server.public_ip_address
159
+ else
160
+ raise "Server #{server.id} has no private or public IP address!"
161
+ # raise "Invalid 'transport_address_location'. They can only be 'public_ip', 'private_ip', or 'ip_addresses'."
162
+ end
163
+ end
164
+
120
165
  end
121
166
  end
122
167
  end
@@ -11,6 +11,19 @@ class Chef
11
11
  compute_options[:xenserver_username]
12
12
  end
13
13
 
14
+ def bootstrap_options_for(action_handler, machine_spec, machine_options)
15
+ bootstrap_options = super
16
+ bootstrap_options[:tags] = bootstrap_options[:tags].map {|k,v| "#{k}: #{v}" }
17
+ bootstrap_options
18
+ end
19
+
20
+ def ssh_options_for(machine_spec, machine_options, server)
21
+ { auth_methods: [ 'password' ],
22
+ timeout: (machine_options[:ssh_timeout] || 600),
23
+ password: machine_options[:ssh_password]
24
+ }.merge(machine_options[:ssh_options] || {})
25
+ end
26
+
14
27
  def self.compute_options_for(provider, id, config)
15
28
  new_compute_options = {}
16
29
  new_compute_options[:provider] = provider
@@ -57,20 +70,22 @@ class Chef
57
70
  end
58
71
  result
59
72
  end
60
-
73
+
61
74
  def create_many_servers(num_servers, bootstrap_options, parallelizer)
62
75
  parallelizer.parallelize(1.upto(num_servers)) do |i|
63
- server = compute.servers.new(bootstrap_options)
64
- server.save auto_start: false
76
+ compute.default_template = bootstrap_options[:template] if bootstrap_options[:template]
77
+ raise 'No server can be created without a template, please set a template name as bootstrap_options' unless compute.default_template
78
+ server = compute.default_template.clone bootstrap_options[:name]
65
79
 
66
80
  if bootstrap_options[:affinity]
67
81
  host = compute.hosts.all.select { |h| h.address == bootstrap_options[:affinity] }.first
68
82
  if !host
69
83
  raise "Host with ID #{bootstrap_options[:affinity]} not found."
70
84
  end
71
- server.set_attribute 'affinity', host.reference
85
+ server.affinity = host.reference
72
86
  end
73
87
 
88
+
74
89
  unless bootstrap_options[:memory].nil?
75
90
  mem = (bootstrap_options[:memory].to_i * 1024 * 1024).to_s
76
91
  server.set_attribute 'memory_limits', mem, mem, mem, mem
@@ -86,6 +101,13 @@ class Chef
86
101
  attrs = {}
87
102
  unless bootstrap_options[:network].nil?
88
103
  network = bootstrap_options[:network]
104
+ net_names = network[:vifs]
105
+ if net_names
106
+ server.vifs.each {|x| x.destroy }
107
+ compute.networks.select { |net| Array(net_names).include? net.name }.each do |net|
108
+ compute.vifs.create vm: server, network: net, device: "0"
109
+ end
110
+ end
89
111
  attrs['vm-data/ip'] = network[:vm_ip] if network[:vm_ip]
90
112
  attrs['vm-data/gw'] = network[:vm_gateway] if network[:vm_gateway]
91
113
  attrs['vm-data/nm'] = network[:vm_netmask] if network[:vm_netmask]
@@ -96,6 +118,28 @@ class Chef
96
118
  end
97
119
  end
98
120
 
121
+ userdevice = 1
122
+ (bootstrap_options[:additional_disks] || Hash.new).each do |name, data|
123
+ sr_name = data[:sr]
124
+ storage_repository = compute.storage_repositories.find { |sr| sr.name == sr_name }
125
+ raise 'You must specify sr name to add additional disks' unless storage_repository
126
+ raise 'You must specify size to add additional disk' unless data[:size]
127
+
128
+ gb = 1_073_741_824
129
+ size = data[:size].to_i * gb
130
+
131
+
132
+ vdi_params = { name: name}
133
+ vdi_params[:storage_repository] = storage_repository
134
+ vdi_params[:description] == data[:description] if data[:description]
135
+ vdi_params[:virtual_size] = size.to_s
136
+ vdi = compute.vdis.create vdi_params
137
+
138
+ compute.vbds.create vm: server, vdi: vdi, userdevice: userdevice.to_s, bootable: false
139
+ userdevice += 1
140
+
141
+ end
142
+
99
143
  server.provision
100
144
  yield server if block_given?
101
145
  server
@@ -127,31 +171,33 @@ require 'fog/compute/models/server'
127
171
  module Fog
128
172
  module Compute
129
173
  class XenServer
130
- class Server < Fog::Compute::Server
131
- def id
132
- uuid
133
- end
174
+ module Models
175
+ class Server < Fog::Compute::Server
176
+ def id
177
+ uuid
178
+ end
134
179
 
135
- def state
136
- attributes[:power_state]
137
- end
180
+ def state
181
+ attributes[:power_state]
182
+ end
138
183
 
139
- def public_ip_address
140
- if xenstore_data['vm-data/ip']
141
- xenstore_data['vm-data/ip']
142
- else
143
- wait_for { tools_installed? }
144
- if tools_installed?
145
- guest_metrics.networks.first[1]
184
+ def public_ip_address
185
+ if xenstore_data['vm-data/ip']
186
+ xenstore_data['vm-data/ip']
146
187
  else
147
- fail 'Unable to return IP address. Virtual machine does not ' \
148
- 'have XenTools installed or a timeout occurred.'
188
+ wait_for { tools_installed? }
189
+ if tools_installed?
190
+ guest_metrics.networks.first[1]
191
+ else
192
+ fail 'Unable to return IP address. Virtual machine does not ' \
193
+ 'have XenTools installed or a timeout occurred.'
194
+ end
149
195
  end
150
196
  end
151
- end
152
197
 
153
- def ready?
154
- running?
198
+ def ready?
199
+ running?
200
+ end
155
201
  end
156
202
  end
157
203
  end
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  module Provisioning
3
3
  module FogDriver
4
- VERSION = '0.18.0'
4
+ VERSION = '0.19.0'
5
5
  end
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ require 'chef/provisioning/fog_driver/providers/aws/credentials'
2
2
 
3
3
  describe Chef::Provisioning::FogDriver::Providers::AWS::Credentials do
4
4
  let(:credentials) { Chef::Provisioning::FogDriver::Providers::AWS::Credentials.new }
5
-
5
+
6
6
  describe "#load_inis" do
7
7
  let(:aws_credentials_ini_file) { File.join(File.expand_path('../../../../support', __FILE__), 'aws/ini-file.ini') }
8
8
 
@@ -15,7 +15,7 @@ describe Chef::Provisioning::FogDriver::Providers::AWS::Credentials do
15
15
  end
16
16
 
17
17
  it "should load the correct values" do
18
- expect(credentials['default'][:aws_access_key_id]).to eq "12345"
18
+ expect(credentials['default'][:aws_access_key_id]).to eq 12345
19
19
  expect(credentials['default'][:aws_secret_access_key]).to eq "abcde"
20
20
  expect(credentials['default'][:region]).to eq "us-east-1"
21
21
  expect(credentials['default'][:aws_session_token]).to eq "mysecret"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-provisioning-fog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-03-30 00:00:00.000000000 Z
15
+ date: 2016-06-02 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: chef-provisioning
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  requirements: []
191
191
  rubyforge_project:
192
- rubygems_version: 2.2.2
192
+ rubygems_version: 2.5.1
193
193
  signing_key:
194
194
  specification_version: 4
195
195
  summary: Driver for creating Fog instances in Chef Provisioning.