bosh_vsphere_cpi 1.5.0.pre.1525 → 1.5.0.pre.1612
Sign up to get free protection for your applications and to get access to all the features.
data/lib/cloud/vsphere/cloud.rb
CHANGED
@@ -4,6 +4,7 @@ require 'ruby_vim_sdk'
|
|
4
4
|
require 'cloud'
|
5
5
|
require 'cloud/vsphere/client'
|
6
6
|
require 'cloud/vsphere/config'
|
7
|
+
require 'cloud/vsphere/lease_obtainer'
|
7
8
|
require 'cloud/vsphere/lease_updater'
|
8
9
|
require 'cloud/vsphere/resources'
|
9
10
|
require 'cloud/vsphere/resources/cluster'
|
@@ -84,16 +85,16 @@ module VSphereCloud
|
|
84
85
|
@logger.info("Deploying to: #{cluster.mob} / #{datastore.mob}")
|
85
86
|
|
86
87
|
import_spec_result = import_ovf(name, ovf_file, cluster.resource_pool.mob, datastore.mob)
|
87
|
-
lease = obtain_nfc_lease(cluster.resource_pool.mob, import_spec_result.import_spec,
|
88
|
-
cluster.datacenter.template_folder.mob)
|
89
|
-
@logger.info('Waiting for NFC lease')
|
90
|
-
state = wait_for_nfc_lease(lease)
|
91
88
|
|
92
|
-
|
93
|
-
|
89
|
+
lease_obtainer = LeaseObtainer.new(@client, @logger)
|
90
|
+
nfc_lease = lease_obtainer.obtain(
|
91
|
+
cluster.resource_pool,
|
92
|
+
import_spec_result.import_spec,
|
93
|
+
cluster.datacenter.template_folder,
|
94
|
+
)
|
94
95
|
|
95
96
|
@logger.info('Uploading')
|
96
|
-
vm = upload_ovf(ovf_file,
|
97
|
+
vm = upload_ovf(ovf_file, nfc_lease, import_spec_result.file_item)
|
97
98
|
result = name
|
98
99
|
|
99
100
|
@logger.info('Removing NICs')
|
@@ -1146,8 +1147,12 @@ module VSphereCloud
|
|
1146
1147
|
private
|
1147
1148
|
|
1148
1149
|
def raise_nfc_lease_error(lease)
|
1149
|
-
|
1150
|
-
raise "Could not acquire HTTP NFC lease, message is:
|
1150
|
+
error = client.get_property(lease, Vim::HttpNfcLease, 'error')
|
1151
|
+
raise "Could not acquire HTTP NFC lease, message is: '#{error.msg}' " +
|
1152
|
+
"fault cause is: '#{error.fault_cause}', " +
|
1153
|
+
"fault message is: #{error.fault_message}, " +
|
1154
|
+
"dynamic type is '#{error.dynamic_type}', " +
|
1155
|
+
"dynamic property is #{error.dynamic_property}"
|
1151
1156
|
end
|
1152
1157
|
end
|
1153
1158
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'ruby_vim_sdk'
|
2
|
+
|
3
|
+
module VSphereCloud
|
4
|
+
class LeaseObtainer
|
5
|
+
include VimSdk
|
6
|
+
|
7
|
+
def initialize(client, logger)
|
8
|
+
@client = client
|
9
|
+
@logger = logger
|
10
|
+
end
|
11
|
+
|
12
|
+
def obtain(resource_pool, import_spec, template_folder)
|
13
|
+
@logger.info('Importing VApp')
|
14
|
+
nfc_lease = resource_pool.mob.import_vapp(import_spec, template_folder.mob, nil)
|
15
|
+
|
16
|
+
@logger.info('Waiting for NFC lease to become ready')
|
17
|
+
state = wait_for_nfc_lease(nfc_lease)
|
18
|
+
|
19
|
+
if state == Vim::HttpNfcLease::State::ERROR
|
20
|
+
raise_nfc_lease_error(nfc_lease)
|
21
|
+
end
|
22
|
+
|
23
|
+
if state != Vim::HttpNfcLease::State::READY
|
24
|
+
raise "Could not acquire HTTP NFC lease (state is: '#{state}')"
|
25
|
+
end
|
26
|
+
|
27
|
+
nfc_lease
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def wait_for_nfc_lease(nfc_lease)
|
33
|
+
loop do
|
34
|
+
state = @client.get_property(nfc_lease, Vim::HttpNfcLease, 'state')
|
35
|
+
return state unless state == Vim::HttpNfcLease::State::INITIALIZING
|
36
|
+
sleep(1.0)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def raise_nfc_lease_error(nfc_lease)
|
41
|
+
error = @client.get_property(nfc_lease, Vim::HttpNfcLease, 'error')
|
42
|
+
raise "Could not acquire HTTP NFC lease, message is: '#{error.msg}' " +
|
43
|
+
"fault cause is: '#{error.fault_cause}', " +
|
44
|
+
"fault message is: #{error.fault_message}, " +
|
45
|
+
"dynamic type is '#{error.dynamic_type}', " +
|
46
|
+
"dynamic property is #{error.dynamic_property}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh_vsphere_cpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.0.pre.
|
4
|
+
version: 1.5.0.pre.1612
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bosh_common
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.5.0.pre.
|
21
|
+
version: 1.5.0.pre.1612
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.5.0.pre.
|
29
|
+
version: 1.5.0.pre.1612
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: bosh_cpi
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.5.0.pre.
|
37
|
+
version: 1.5.0.pre.1612
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.5.0.pre.
|
45
|
+
version: 1.5.0.pre.1612
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: membrane
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
description: ! 'BOSH VSphere CPI
|
111
111
|
|
112
|
-
|
112
|
+
a13d7a'
|
113
113
|
email: support@cloudfoundry.com
|
114
114
|
executables:
|
115
115
|
- vsphere_cpi_console
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/cloud/vsphere/client.rb
|
123
123
|
- lib/cloud/vsphere/cloud.rb
|
124
124
|
- lib/cloud/vsphere/config.rb
|
125
|
+
- lib/cloud/vsphere/lease_obtainer.rb
|
125
126
|
- lib/cloud/vsphere/lease_updater.rb
|
126
127
|
- lib/cloud/vsphere/models/disk.rb
|
127
128
|
- lib/cloud/vsphere/path_finder.rb
|