dopv 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04b5fc85ce634cdb291b2a38bb329278f5124764
4
- data.tar.gz: 2907715f813769b45dfdeb1cce85c569e6d146b5
3
+ metadata.gz: 1efa5fc9e9c48829ffa021a943dcf8cd4b989e99
4
+ data.tar.gz: f17df818250d5f25586c42bfa9565bea1fd8af43
5
5
  SHA512:
6
- metadata.gz: d2ebca4cb926ef33f761f860d1b854ce7201e2bfc64c909ef691f4754c021f0b2385f4716214b4838ec0896fbfddfea76e458fef97ab6c2a0c075105a1f84562
7
- data.tar.gz: 7e0d5be2228cd57889fff41bca94d606d767c53edb875a615ac5ef614b6a4138a677566b703c9b6c7ded73256380286cbdd03c2a52487eda5da5263ec9ac6fc0
6
+ metadata.gz: 2c664c03979578a689f4acef0786a9588c1212c67d1dc5a250c64e8c17af79b00bb93f97cf839683d2bdac6f9359573666f4863fc09ef38b1998bc980f5d68a0
7
+ data.tar.gz: cc23756967cf69347c3254c6ce091915d1894efabf5cf3a24c8bb044377ae85c5d5d7108e762505140807f7387beb8cdc172b258535b938cb22b7daa4a1db327
@@ -1,3 +1,16 @@
1
+ # 0.12.0 07.04.2017
2
+ ## [vsphere]
3
+ * Improve `destroy_node`
4
+ * Waiting for poweredOff vm state
5
+ * Improve `get_node_ip_addresses`
6
+ * Filtering apipa and ipv6
7
+ * Skipping if vm tools unmanaged or has no connected guest network interface
8
+ * Improve `customize_node_instance` windows sysprep
9
+ * Add possibility to join domain or workgroup
10
+ * Some minor fixes and improvements
11
+ * `@wait_params` to instance
12
+ * Handling of properties thin/thick provisioning, timezone and product_id
13
+
1
14
  # 0.11.0 29.03.2017
2
15
  ## [general]
3
16
  * Split log files by nodes
@@ -23,7 +23,7 @@ GEM
23
23
  coderay (1.1.1)
24
24
  diff-lcs (1.3)
25
25
  docile (1.1.5)
26
- domain_name (0.5.20170223)
26
+ domain_name (0.5.20170404)
27
27
  unf (>= 0.0.5, < 1.0.0)
28
28
  dop_common (0.13.0)
29
29
  hashdiff (~> 0.3, >= 0.3.1)
@@ -68,7 +68,7 @@ GEM
68
68
  fog-atmos (0.1.0)
69
69
  fog-core
70
70
  fog-xml
71
- fog-aws (1.2.1)
71
+ fog-aws (1.3.0)
72
72
  fog-core (~> 1.38)
73
73
  fog-json (~> 1.0)
74
74
  fog-xml (~> 0.1)
@@ -137,9 +137,9 @@ GEM
137
137
  fog-xenserver (0.3.0)
138
138
  fog-core
139
139
  fog-xml
140
- fog-xml (0.1.2)
140
+ fog-xml (0.1.3)
141
141
  fog-core
142
- nokogiri (~> 1.5, >= 1.5.11)
142
+ nokogiri (>= 1.5.11, < 2.0.0)
143
143
  formatador (0.2.5)
144
144
  gli (2.13.4)
145
145
  guard (2.14.1)
@@ -8,9 +8,9 @@ module Dopv
8
8
  class Vsphere < Base
9
9
  extend Forwardable
10
10
 
11
- def_delegators :@plan, :product_id, :organization_name
11
+ def_delegators :@plan, :product_id, :organization_name, :domain, :workgroup
12
12
 
13
- def initialize(node_config, data_disks_db)
13
+ def initialize(node_config, data_disks_db, wait_params={})
14
14
  super(node_config, data_disks_db)
15
15
 
16
16
  @compute_connection_opts = {
@@ -30,6 +30,11 @@ module Dopv
30
30
  'numCPUs' => cores,
31
31
  'memoryMB' => memory.mebibytes.to_i
32
32
  }
33
+
34
+ @wait_params = {
35
+ :maxtime => 300,
36
+ :delay => 10
37
+ }.merge(wait_params)
33
38
  end
34
39
 
35
40
  private
@@ -42,6 +47,20 @@ module Dopv
42
47
  super || '085'
43
48
  end
44
49
 
50
+ def timezone_to_index(timezone)
51
+ lookup_table = {
52
+ 'Europe/Zurich' => 110,
53
+ :default => 110
54
+ }
55
+
56
+ unless timezone.match(/^[1-9][0-9][0-9]$/)
57
+ (lookup_table.key? timezone) ?
58
+ lookup_table[timezone].to_s : lookup_table[:default].to_s
59
+ else
60
+ timezone
61
+ end
62
+ end
63
+
45
64
  def node_instance_stopped?(node_instance)
46
65
  !node_instance.ready?
47
66
  end
@@ -55,6 +74,25 @@ module Dopv
55
74
  compute_provider.servers.get(vm['new_vm']['id'])
56
75
  end
57
76
 
77
+ def customization_domain_credential(domain)
78
+ credentials.find { |c| c.type == :username_password && c.username.start_with?(domain) }
79
+ end
80
+
81
+ def customization_domain?(domain)
82
+ cred = customization_domain_credential(domain)
83
+ !cred.nil?
84
+ end
85
+
86
+ def customization_domain_password(domain)
87
+ cred = customization_domain_credential(domain)
88
+ cred.nil? ? nil : cred.password
89
+ end
90
+
91
+ def customization_domain_username(domain)
92
+ cred = customization_domain_credential(domain)
93
+ cred.nil? ? nil : cred.username.split('\\').last
94
+ end
95
+
58
96
  def customize_node_instance(node_instance)
59
97
  ::Dopv::log.info("Node #{nodename}: Customizing node.")
60
98
  # Settings related to each network interface
@@ -81,35 +119,61 @@ module Dopv
81
119
 
82
120
  # Identity settings
83
121
  identity_settings = case guest_id_to_os_family(node_instance)
122
+
84
123
  when :linux
124
+
85
125
  RbVmomi::VIM::CustomizationLinuxPrep.new(
86
126
  :domain => domainname,
87
127
  :hostName => RbVmomi::VIM::CustomizationFixedName.new(:name => hostname)
88
128
  )
129
+
89
130
  when :windows
131
+
90
132
  password_settings = (RbVmomi::VIM::CustomizationPassword.new(
91
133
  :plainText => true,
92
134
  :value => administrator_password
93
135
  ) rescue nil)
136
+
137
+ # Declare identification
138
+ domain ||= customization_domain?(domainname) ? domainname : nil
139
+ workgroup ||= nil
140
+ if domain
141
+ customization_domain_password_settings = (RbVmomi::VIM::CustomizationPassword.new(
142
+ :plainText => true,
143
+ :value => customize_domain_password(domain)
144
+ ) rescue nil)
145
+ customization_id = RbVmomi::VIM::CustomizationIdentification.new(
146
+ :joinDomain => domain,
147
+ :domainAdmin => customization_domain_username(domain),
148
+ :domainAdminPassword => customization_domain_password_settings
149
+ )
150
+ elsif workgroup
151
+ customization_id = RbVmomi::VIM::CustomizationIdentification.new(
152
+ :joinWorkgroup => workgroup
153
+ )
154
+ else
155
+ customization_id = RbVmomi::VIM::CustomizationIdentification.new(
156
+ :domainAdmin => nil,
157
+ :domainAdminPassword => nil,
158
+ :joinDomain => nil
159
+ )
160
+ end
161
+
94
162
  RbVmomi::VIM::CustomizationSysprep.new(
95
163
  :guiRunOnce => nil,
96
164
  :guiUnattended => RbVmomi::VIM::CustomizationGuiUnattended.new(
97
165
  :autoLogon => false,
98
166
  :autoLogonCount => 1,
99
167
  :password => password_settings,
100
- :timeZone => timezone
101
- ),
102
- :identification => RbVmomi::VIM::CustomizationIdentification.new(
103
- :domainAdmin => nil,
104
- :domainAdminPassword => nil,
105
- :joinDomain => nil
106
- ),
168
+ :timeZone => timezone_to_index(timezone)
169
+ ),
170
+ :identification => customization_id,
107
171
  :userData => RbVmomi::VIM::CustomizationUserData.new(
108
172
  :computerName => RbVmomi::VIM::CustomizationFixedName.new(:name => hostname),
109
173
  :fullName => administrator_fullname,
110
174
  :orgName => organization_name,
111
- :productId => product_id
112
- )
175
+ :productId => (!product_id ? '' : product_id)
176
+ )
113
177
  )
114
178
  else
115
179
  raise ProviderError, "Unsupported guest OS type"
@@ -134,6 +198,11 @@ module Dopv
134
198
  node_instance.start
135
199
  end
136
200
 
201
+ def stop_node_instance(node_instance)
202
+ super(node_instance)
203
+ node_instance.wait_for(@wait_params[:maxtime]){power_state.to_sym == :poweredOff}
204
+ end
205
+
137
206
  def add_node_nics(node_instance)
138
207
  ::Dopv::log.info("Node #{nodename}: Trying to add interfaces.")
139
208
 
@@ -162,7 +231,7 @@ module Dopv
162
231
  :datastore => config.pool,
163
232
  :size => config.size.kibibytes.to_i,
164
233
  :mode => 'persistent',
165
- :thin => true
234
+ :thin => config.thin?
166
235
  )
167
236
  node_instance.volumes.reload
168
237
  volume.name = config.name
@@ -290,30 +359,41 @@ module Dopv
290
359
  @provider_pubkey_hash
291
360
  end
292
361
 
293
- def get_node_ip_addresses(node_instance, params={})
362
+ def get_node_ip_addresses(node_instance)
294
363
  begin
295
364
  raise ProviderError, "VMware Tools not installed" unless node_instance.tools_installed?
296
- params = {:maxtime => 300, :delay => 10}.merge(params)
297
- ::Dopv::log.debug("Node #{nodename}: Waiting on VMware Tools for #{params[:maxtime]} seconds.")
365
+
366
+ ::Dopv::log.debug("Node #{nodename}: Waiting on VMware Tools for #{@wait_params[:maxtime]} seconds.")
298
367
  reload_node_instance(node_instance)
299
- node_instance.wait_for(params[:maxtime]){|vm| vm.ready?}
300
- node_instance.wait_for(params[:maxtime]){|vm| vm.tools_running?}
368
+ node_instance.wait_for(@wait_params[:maxtime]){ready?}
369
+ node_instance.wait_for(@wait_params[:maxtime]){tools_running?}
370
+ raise ProviderError, "VMware Tools Version not supported" if node_instance.tools_version.to_sym == :guestToolsUnmanaged
371
+
301
372
  node_ref = compute_provider.send(:get_vm_ref, node_instance.id)
302
373
  node_ref_guest_net = nil
303
374
  start_time = Time.now.to_f
304
- while (Time.now.to_f - start_time) < params[:maxtime]
375
+ is_connected = false
376
+ is_windows = guest_id_to_os_family(node_instance) == :windows
377
+ node_ref.guest.net.each do |i| is_connected ||= i.connected end
378
+ raise ProviderError, "No connected network interface available" unless is_connected
379
+
380
+ while (Time.now.to_f - start_time) < @wait_params[:maxtime]
305
381
  unless node_ref.guest_ip
306
- sleep params[:delay]
382
+ sleep @wait_params[:delay]
307
383
  else
308
- node_ref_guest_net = node_ref.guest.net
309
- break
384
+ node_ref_guest_net = node_ref.guest.net.map(&:ipAddress).flatten.uniq.compact.select{|i| i.match(Resolv::IPv4::Regex) && !(i.start_with?('169.254.') && is_windows)}
385
+ unless node_ref_guest_net.any?
386
+ sleep @wait_params[:delay]
387
+ else
388
+ break
389
+ end
310
390
  end
311
391
  end
312
392
  raise ProviderError, "VMware Tools not ready yet" unless node_ref_guest_net
313
- node_ref_guest_net.map(&:ipAddress).flatten.uniq.compact
393
+ node_ref_guest_net
314
394
 
315
395
  rescue Exception => e
316
- ::Dopv::log.debug("Node #{nodename}: Unable to get all IP Addresses, Error: #{e.message}.")
396
+ ::Dopv::log.debug("Node #{nodename}: Unable to obtain IP Addresses, Error: #{e.message}.")
317
397
  [node_instance.public_ip_address].compact
318
398
  end
319
399
  end
@@ -1,3 +1,3 @@
1
1
  module Dopv
2
- VERSION = '0.11.0'
2
+ VERSION = '0.12.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dopv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavol Dilung
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-29 00:00:00.000000000 Z
12
+ date: 2017-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -386,7 +386,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
386
386
  version: '0'
387
387
  requirements: []
388
388
  rubyforge_project:
389
- rubygems_version: 2.6.10
389
+ rubygems_version: 2.4.5
390
390
  signing_key:
391
391
  specification_version: 4
392
392
  summary: Deployment orchestrator for VMs