vcloud-core 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/CHANGELOG.md +12 -0
- data/lib/vcloud/core.rb +2 -1
- data/lib/vcloud/core/api_interface.rb +35 -0
- data/lib/vcloud/core/compute_metadata.rb +1 -1
- data/lib/vcloud/core/edge_gateway.rb +2 -2
- data/lib/vcloud/core/fog.rb +40 -0
- data/lib/vcloud/core/fog/fog_constants.rb +35 -0
- data/lib/vcloud/core/fog/login.rb +40 -0
- data/lib/vcloud/core/fog/model_interface.rb +41 -0
- data/lib/vcloud/core/fog/service_interface.rb +253 -0
- data/lib/vcloud/core/login_cli.rb +1 -1
- data/lib/vcloud/core/metadata_helper.rb +1 -1
- data/lib/vcloud/core/org_vdc_network.rb +3 -3
- data/lib/vcloud/core/query_runner.rb +1 -1
- data/lib/vcloud/core/vapp.rb +6 -6
- data/lib/vcloud/core/vapp_template.rb +1 -1
- data/lib/vcloud/core/vdc.rb +1 -1
- data/lib/vcloud/core/version.rb +1 -1
- data/lib/vcloud/core/vm.rb +9 -9
- data/lib/vcloud/fog.rb +2 -39
- data/lib/vcloud/temporary_fog_classes.rb +11 -0
- data/spec/integration/{fog → core/fog}/login_manual.rb +1 -1
- data/spec/integration/{fog → core/fog}/login_spec.rb +13 -9
- data/spec/integration/core/vm_spec.rb +1 -1
- data/spec/support/integration_helper.rb +1 -1
- data/spec/vcloud/core/edge_gateway_spec.rb +1 -1
- data/spec/vcloud/{fog → core/fog}/fog_model_interface_spec.rb +2 -2
- data/spec/vcloud/{fog → core/fog}/login_spec.rb +4 -4
- data/spec/vcloud/core/fog/service_interface_spec.rb +53 -0
- data/spec/vcloud/{fog_spec.rb → core/fog_spec.rb} +2 -2
- data/spec/vcloud/core/login_cli_spec.rb +6 -6
- data/spec/vcloud/core/org_vdc_network_spec.rb +1 -1
- data/spec/vcloud/core/query_runner_spec.rb +1 -1
- data/spec/vcloud/core/vapp_spec.rb +1 -1
- data/spec/vcloud/core/vapp_template_spec.rb +1 -1
- data/spec/vcloud/core/vdc_spec.rb +1 -1
- data/spec/vcloud/core/vm_spec.rb +1 -1
- metadata +22 -21
- data/jenkins_integration_tests.sh +0 -5
- data/lib/vcloud/fog/content_types.rb +0 -18
- data/lib/vcloud/fog/login.rb +0 -38
- data/lib/vcloud/fog/model_interface.rb +0 -33
- data/lib/vcloud/fog/relation.rb +0 -8
- data/lib/vcloud/fog/service_interface.rb +0 -245
- data/spec/vcloud/fog/service_interface_spec.rb +0 -51
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Vcloud::Fog do
|
3
|
+
describe Vcloud::Core::Fog do
|
4
4
|
describe "fog_credentials_pass" do
|
5
|
-
let(:subject) { Vcloud::Fog::fog_credentials_pass }
|
5
|
+
let(:subject) { Vcloud::Core::Fog::fog_credentials_pass }
|
6
6
|
|
7
7
|
context "vcloud_director_password not set" do
|
8
8
|
it "should return nil" do
|
@@ -50,7 +50,7 @@ describe Vcloud::Core::LoginCli do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should prompt on stderr so that stdout can be scripted and mask password input" do
|
53
|
-
expect(Vcloud::Fog::Login).to receive(:token_export).with(pass)
|
53
|
+
expect(Vcloud::Core::Fog::Login).to receive(:token_export).with(pass)
|
54
54
|
expect(subject.stderr).to eq("vCloud password: " + "*" * pass.size)
|
55
55
|
end
|
56
56
|
end
|
@@ -61,7 +61,7 @@ describe Vcloud::Core::LoginCli do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should write stderr message to say that it's reading from pipe and not echo any input" do
|
64
|
-
expect(Vcloud::Fog::Login).to receive(:token_export).with(pass)
|
64
|
+
expect(Vcloud::Core::Fog::Login).to receive(:token_export).with(pass)
|
65
65
|
expect(subject.stderr).to eq("Reading password from pipe..")
|
66
66
|
end
|
67
67
|
end
|
@@ -71,7 +71,7 @@ describe Vcloud::Core::LoginCli do
|
|
71
71
|
let(:args) { %w{--version} }
|
72
72
|
|
73
73
|
it "should not call Login" do
|
74
|
-
expect(Vcloud::Fog::Login).not_to receive(:token_export)
|
74
|
+
expect(Vcloud::Core::Fog::Login).not_to receive(:token_export)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should print version and exit normally" do
|
@@ -84,7 +84,7 @@ describe Vcloud::Core::LoginCli do
|
|
84
84
|
let(:args) { %w{--help} }
|
85
85
|
|
86
86
|
it "should not call Login" do
|
87
|
-
expect(Vcloud::Fog::Login).not_to receive(:token_export)
|
87
|
+
expect(Vcloud::Core::Fog::Login).not_to receive(:token_export)
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should print usage and exit normally" do
|
@@ -97,7 +97,7 @@ describe Vcloud::Core::LoginCli do
|
|
97
97
|
describe "incorrect usage" do
|
98
98
|
shared_examples "print usage and exit abnormally" do |error|
|
99
99
|
it "should not call Login" do
|
100
|
-
expect(Vcloud::Fog::Login).not_to receive(:token_export)
|
100
|
+
expect(Vcloud::Core::Fog::Login).not_to receive(:token_export)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should print error message and usage" do
|
@@ -133,7 +133,7 @@ describe Vcloud::Core::LoginCli do
|
|
133
133
|
let(:exception_string) { 'something went horribly wrong' }
|
134
134
|
|
135
135
|
it "should print error without backtrace and exit abnormally" do
|
136
|
-
expect(Vcloud::Fog::Login).to receive(:token_export).
|
136
|
+
expect(Vcloud::Core::Fog::Login).to receive(:token_export).
|
137
137
|
and_raise(exception_string)
|
138
138
|
if STDIN.tty?
|
139
139
|
expect(subject.stderr).to eq("vCloud password: #{'*' * pass.size}\n#{exception_string}")
|
@@ -11,7 +11,7 @@ module Vcloud
|
|
11
11
|
@vdc_name = 'test-vdc-1'
|
12
12
|
@net_name = 'test-net-1'
|
13
13
|
@mock_fog_interface = StubFogInterface.new
|
14
|
-
allow(Vcloud::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
14
|
+
allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
15
15
|
allow_any_instance_of(Vdc).to receive(:id).and_return(@vdc_id)
|
16
16
|
@mock_vdc = double(:vdc, :id => @vdc_id)
|
17
17
|
allow(Vdc).to receive(:get_by_name).and_return(@mock_vdc)
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Vcloud::Core::QueryRunner do
|
4
4
|
before(:each) do
|
5
5
|
@mock_fog_interface = StubFogInterface.new
|
6
|
-
allow(Vcloud::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
6
|
+
allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
7
7
|
@query_runner = Vcloud::Core::QueryRunner.new()
|
8
8
|
end
|
9
9
|
|
@@ -6,7 +6,7 @@ module Vcloud
|
|
6
6
|
before(:each) do
|
7
7
|
@vapp_id = 'vapp-12345678-1234-1234-1234-000000111111'
|
8
8
|
@mock_fog_interface = StubFogInterface.new
|
9
|
-
allow(Vcloud::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
9
|
+
allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
10
10
|
end
|
11
11
|
|
12
12
|
context "Class public interface" do
|
@@ -7,7 +7,7 @@ module Vcloud
|
|
7
7
|
before(:each) do
|
8
8
|
@id = 'vappTemplate-12345678-1234-1234-1234-000000234121'
|
9
9
|
@mock_fog_interface = StubFogInterface.new
|
10
|
-
allow(Vcloud::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
10
|
+
allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
11
11
|
end
|
12
12
|
|
13
13
|
context "Class public interface" do
|
@@ -7,7 +7,7 @@ module Vcloud
|
|
7
7
|
before(:each) do
|
8
8
|
@vdc_id = '12345678-1234-1234-1234-000000111232'
|
9
9
|
@mock_fog_interface = StubFogInterface.new
|
10
|
-
allow(Vcloud::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
10
|
+
allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
11
11
|
end
|
12
12
|
|
13
13
|
context "Class public interface" do
|
data/spec/vcloud/core/vm_spec.rb
CHANGED
@@ -21,7 +21,7 @@ module Vcloud
|
|
21
21
|
@mock_vm_cpu_count = 1
|
22
22
|
@fog_interface = StubFogInterface.new
|
23
23
|
@mock_vapp = double(:vappm, :name => @vapp_name, :id => @vapp_id)
|
24
|
-
allow(Vcloud::Fog::ServiceInterface).to receive(:new).and_return(@fog_interface)
|
24
|
+
allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@fog_interface)
|
25
25
|
allow(@fog_interface).to receive(:get_vapp).with(@vm_id).and_return({
|
26
26
|
:name => "#{@vm_name}",
|
27
27
|
:href => "vm-href/#{@vm_id}",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcloud-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
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: 2014-07
|
12
|
+
date: 2014-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -192,15 +192,20 @@ files:
|
|
192
192
|
- bin/vcloud-login
|
193
193
|
- bin/vcloud-query
|
194
194
|
- jenkins.sh
|
195
|
-
- jenkins_integration_tests.sh
|
196
195
|
- jenkins_tests.sh
|
197
196
|
- lib/vcloud/core.rb
|
197
|
+
- lib/vcloud/core/api_interface.rb
|
198
198
|
- lib/vcloud/core/compute_metadata.rb
|
199
199
|
- lib/vcloud/core/config_loader.rb
|
200
200
|
- lib/vcloud/core/config_validator.rb
|
201
201
|
- lib/vcloud/core/edge_gateway.rb
|
202
202
|
- lib/vcloud/core/edge_gateway_interface.rb
|
203
203
|
- lib/vcloud/core/entity.rb
|
204
|
+
- lib/vcloud/core/fog.rb
|
205
|
+
- lib/vcloud/core/fog/fog_constants.rb
|
206
|
+
- lib/vcloud/core/fog/login.rb
|
207
|
+
- lib/vcloud/core/fog/model_interface.rb
|
208
|
+
- lib/vcloud/core/fog/service_interface.rb
|
204
209
|
- lib/vcloud/core/login_cli.rb
|
205
210
|
- lib/vcloud/core/metadata_helper.rb
|
206
211
|
- lib/vcloud/core/org_vdc_network.rb
|
@@ -213,19 +218,15 @@ files:
|
|
213
218
|
- lib/vcloud/core/version.rb
|
214
219
|
- lib/vcloud/core/vm.rb
|
215
220
|
- lib/vcloud/fog.rb
|
216
|
-
- lib/vcloud/
|
217
|
-
- lib/vcloud/fog/login.rb
|
218
|
-
- lib/vcloud/fog/model_interface.rb
|
219
|
-
- lib/vcloud/fog/relation.rb
|
220
|
-
- lib/vcloud/fog/service_interface.rb
|
221
|
+
- lib/vcloud/temporary_fog_classes.rb
|
221
222
|
- spec/integration/README.md
|
222
223
|
- spec/integration/core/edge_gateway_spec.rb
|
224
|
+
- spec/integration/core/fog/login_manual.rb
|
225
|
+
- spec/integration/core/fog/login_spec.rb
|
223
226
|
- spec/integration/core/query_runner_spec.rb
|
224
227
|
- spec/integration/core/vapp_spec.rb
|
225
228
|
- spec/integration/core/vdc_spec.rb
|
226
229
|
- spec/integration/core/vm_spec.rb
|
227
|
-
- spec/integration/fog/login_manual.rb
|
228
|
-
- spec/integration/fog/login_spec.rb
|
229
230
|
- spec/integration/vcloud_tools_testing_config.yaml.template
|
230
231
|
- spec/spec_helper.rb
|
231
232
|
- spec/support/integration_helper.rb
|
@@ -242,6 +243,10 @@ files:
|
|
242
243
|
- spec/vcloud/core/data/working_with_defaults.yaml
|
243
244
|
- spec/vcloud/core/edge_gateway_interface_spec.rb
|
244
245
|
- spec/vcloud/core/edge_gateway_spec.rb
|
246
|
+
- spec/vcloud/core/fog/fog_model_interface_spec.rb
|
247
|
+
- spec/vcloud/core/fog/login_spec.rb
|
248
|
+
- spec/vcloud/core/fog/service_interface_spec.rb
|
249
|
+
- spec/vcloud/core/fog_spec.rb
|
245
250
|
- spec/vcloud/core/login_cli_spec.rb
|
246
251
|
- spec/vcloud/core/metadata_helper_spec.rb
|
247
252
|
- spec/vcloud/core/org_vdc_network_spec.rb
|
@@ -252,10 +257,6 @@ files:
|
|
252
257
|
- spec/vcloud/core/vapp_template_spec.rb
|
253
258
|
- spec/vcloud/core/vdc_spec.rb
|
254
259
|
- spec/vcloud/core/vm_spec.rb
|
255
|
-
- spec/vcloud/fog/fog_model_interface_spec.rb
|
256
|
-
- spec/vcloud/fog/login_spec.rb
|
257
|
-
- spec/vcloud/fog/service_interface_spec.rb
|
258
|
-
- spec/vcloud/fog_spec.rb
|
259
260
|
- vcloud-core.gemspec
|
260
261
|
homepage: http://github.com/gds-operations/vcloud-core
|
261
262
|
licenses:
|
@@ -278,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
278
279
|
version: '0'
|
279
280
|
segments:
|
280
281
|
- 0
|
281
|
-
hash:
|
282
|
+
hash: 2495951714182978305
|
282
283
|
requirements: []
|
283
284
|
rubyforge_project:
|
284
285
|
rubygems_version: 1.8.23
|
@@ -288,12 +289,12 @@ summary: Core tools for interacting with VMware vCloud Director
|
|
288
289
|
test_files:
|
289
290
|
- spec/integration/README.md
|
290
291
|
- spec/integration/core/edge_gateway_spec.rb
|
292
|
+
- spec/integration/core/fog/login_manual.rb
|
293
|
+
- spec/integration/core/fog/login_spec.rb
|
291
294
|
- spec/integration/core/query_runner_spec.rb
|
292
295
|
- spec/integration/core/vapp_spec.rb
|
293
296
|
- spec/integration/core/vdc_spec.rb
|
294
297
|
- spec/integration/core/vm_spec.rb
|
295
|
-
- spec/integration/fog/login_manual.rb
|
296
|
-
- spec/integration/fog/login_spec.rb
|
297
298
|
- spec/integration/vcloud_tools_testing_config.yaml.template
|
298
299
|
- spec/spec_helper.rb
|
299
300
|
- spec/support/integration_helper.rb
|
@@ -310,6 +311,10 @@ test_files:
|
|
310
311
|
- spec/vcloud/core/data/working_with_defaults.yaml
|
311
312
|
- spec/vcloud/core/edge_gateway_interface_spec.rb
|
312
313
|
- spec/vcloud/core/edge_gateway_spec.rb
|
314
|
+
- spec/vcloud/core/fog/fog_model_interface_spec.rb
|
315
|
+
- spec/vcloud/core/fog/login_spec.rb
|
316
|
+
- spec/vcloud/core/fog/service_interface_spec.rb
|
317
|
+
- spec/vcloud/core/fog_spec.rb
|
313
318
|
- spec/vcloud/core/login_cli_spec.rb
|
314
319
|
- spec/vcloud/core/metadata_helper_spec.rb
|
315
320
|
- spec/vcloud/core/org_vdc_network_spec.rb
|
@@ -320,7 +325,3 @@ test_files:
|
|
320
325
|
- spec/vcloud/core/vapp_template_spec.rb
|
321
326
|
- spec/vcloud/core/vdc_spec.rb
|
322
327
|
- spec/vcloud/core/vm_spec.rb
|
323
|
-
- spec/vcloud/fog/fog_model_interface_spec.rb
|
324
|
-
- spec/vcloud/fog/login_spec.rb
|
325
|
-
- spec/vcloud/fog/service_interface_spec.rb
|
326
|
-
- spec/vcloud/fog_spec.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Vcloud
|
2
|
-
module Fog
|
3
|
-
module ContentTypes
|
4
|
-
ORG = 'application/vnd.vmware.vcloud.org+xml'
|
5
|
-
VDC = 'application/vnd.vmware.vcloud.vdc+xml'
|
6
|
-
NETWORK = 'application/vnd.vmware.vcloud.network+xml'
|
7
|
-
METADATA = 'application/vnd.vmware.vcloud.metadata.value+xml'
|
8
|
-
end
|
9
|
-
|
10
|
-
module MetadataValueType
|
11
|
-
String = 'MetadataStringValue'
|
12
|
-
Number = 'MetadataNumberValue'
|
13
|
-
DateTime = 'MetadataDateTimeValue'
|
14
|
-
Boolean = 'MetadataBooleanValue'
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
data/lib/vcloud/fog/login.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'fog'
|
2
|
-
|
3
|
-
module Vcloud
|
4
|
-
module Fog
|
5
|
-
module Login
|
6
|
-
class << self
|
7
|
-
def token(pass)
|
8
|
-
check_plaintext_pass
|
9
|
-
token = get_token(pass)
|
10
|
-
|
11
|
-
return token
|
12
|
-
end
|
13
|
-
|
14
|
-
def token_export(*args)
|
15
|
-
return "export #{Vcloud::Fog::TOKEN_ENV_VAR_NAME}=#{token(*args)}"
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def check_plaintext_pass
|
21
|
-
pass = Vcloud::Fog::fog_credentials_pass
|
22
|
-
unless pass.nil? || pass.empty?
|
23
|
-
raise "Found plaintext #{Vcloud::Fog::FOG_CREDS_PASS_NAME} entry. Please set it to an empty string"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def get_token(pass)
|
28
|
-
ENV.delete(Vcloud::Fog::TOKEN_ENV_VAR_NAME)
|
29
|
-
vcloud = ::Fog::Compute::VcloudDirector.new({
|
30
|
-
Vcloud::Fog::FOG_CREDS_PASS_NAME => pass,
|
31
|
-
})
|
32
|
-
|
33
|
-
return vcloud.vcloud_token
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Vcloud
|
2
|
-
module Fog
|
3
|
-
class ModelInterface
|
4
|
-
def initialize
|
5
|
-
@vcloud = ::Fog::Compute::VcloudDirector.new
|
6
|
-
end
|
7
|
-
|
8
|
-
def org_name
|
9
|
-
@vcloud.org_name
|
10
|
-
end
|
11
|
-
|
12
|
-
def current_organization
|
13
|
-
@vcloud.organizations.get_by_name org_name
|
14
|
-
end
|
15
|
-
|
16
|
-
def current_vdc vdc_id
|
17
|
-
current_organization.vdcs.detect { |v| v.id == vdc_id }
|
18
|
-
end
|
19
|
-
|
20
|
-
def get_vm_by_href href
|
21
|
-
vm = @vcloud.get_vms_in_lease_from_query(
|
22
|
-
{
|
23
|
-
:filter => "href==#{href}"
|
24
|
-
}).body[:VMRecord].first
|
25
|
-
return nil unless vm
|
26
|
-
vdc = current_vdc(vm[:vdc].split('/').last)
|
27
|
-
vapp = vdc.vapps.get_by_name(vm[:containerName])
|
28
|
-
vapp.vms.first
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/vcloud/fog/relation.rb
DELETED
@@ -1,245 +0,0 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
module Vcloud
|
4
|
-
module Fog
|
5
|
-
class ServiceInterface
|
6
|
-
extend Forwardable
|
7
|
-
|
8
|
-
def_delegators :@fog, :get_vapp, :organizations, :org_name, :delete_vapp, :vcloud_token, :end_point,
|
9
|
-
:get_execute_query, :get_vapp_metadata, :power_off_vapp, :shutdown_vapp, :session,
|
10
|
-
:post_instantiate_vapp_template, :put_memory, :put_cpu, :power_on_vapp, :put_vapp_metadata_value,
|
11
|
-
:put_vm, :get_edge_gateway, :get_network_complete, :delete_network, :post_create_org_vdc_network,
|
12
|
-
:post_configure_edge_gateway_services, :get_vdc, :post_undeploy_vapp
|
13
|
-
|
14
|
-
#########################
|
15
|
-
# FogFacade Inner class to represent a logic free facade over our interactions with Fog
|
16
|
-
|
17
|
-
class FogFacade
|
18
|
-
def initialize
|
19
|
-
@vcloud = ::Fog::Compute::VcloudDirector.new
|
20
|
-
end
|
21
|
-
|
22
|
-
def get_vdc(id)
|
23
|
-
@vcloud.get_vdc(id).body
|
24
|
-
end
|
25
|
-
|
26
|
-
def get_organization (id)
|
27
|
-
@vcloud.get_organization(id).body
|
28
|
-
end
|
29
|
-
|
30
|
-
def session
|
31
|
-
@vcloud.get_current_session.body
|
32
|
-
end
|
33
|
-
|
34
|
-
def get_vapps_in_lease_from_query(options)
|
35
|
-
@vcloud.get_vapps_in_lease_from_query(options).body
|
36
|
-
end
|
37
|
-
|
38
|
-
def post_instantiate_vapp_template(vdc, template, name, params)
|
39
|
-
Vcloud::Core.logger.debug("instantiating #{name} vapp in #{vdc[:name]}")
|
40
|
-
vapp = @vcloud.post_instantiate_vapp_template(extract_id(vdc), template, name, params).body
|
41
|
-
@vcloud.process_task(vapp[:Tasks][:Task])
|
42
|
-
@vcloud.get_vapp(extract_id(vapp)).body
|
43
|
-
end
|
44
|
-
|
45
|
-
def put_memory(vm_id, memory)
|
46
|
-
Vcloud::Core.logger.debug("putting #{memory}MB memory into VM #{vm_id}")
|
47
|
-
task = @vcloud.put_memory(vm_id, memory).body
|
48
|
-
@vcloud.process_task(task)
|
49
|
-
end
|
50
|
-
|
51
|
-
def get_vapp(id)
|
52
|
-
@vcloud.get_vapp(id).body
|
53
|
-
end
|
54
|
-
|
55
|
-
def put_network_connection_system_section_vapp(vm_id, section)
|
56
|
-
task = @vcloud.put_network_connection_system_section_vapp(vm_id, section).body
|
57
|
-
@vcloud.process_task(task)
|
58
|
-
end
|
59
|
-
|
60
|
-
def put_cpu(vm_id, cpu)
|
61
|
-
Vcloud::Core.logger.debug("putting #{cpu} CPU(s) into VM #{vm_id}")
|
62
|
-
task = @vcloud.put_cpu(vm_id, cpu).body
|
63
|
-
@vcloud.process_task(task)
|
64
|
-
end
|
65
|
-
|
66
|
-
def put_vm(id, name, options={})
|
67
|
-
Vcloud::Core.logger.debug("updating name : #{name}, :options => #{options} in vm : #{id}")
|
68
|
-
task = @vcloud.put_vm(id, name, options).body
|
69
|
-
@vcloud.process_task(task)
|
70
|
-
end
|
71
|
-
|
72
|
-
def vcloud_token
|
73
|
-
@vcloud.vcloud_token
|
74
|
-
end
|
75
|
-
|
76
|
-
def end_point
|
77
|
-
@vcloud.end_point
|
78
|
-
end
|
79
|
-
|
80
|
-
def put_guest_customization_section_vapp(vm_id, customization_req)
|
81
|
-
task = @vcloud.put_guest_customization_section_vapp(vm_id, customization_req).body
|
82
|
-
@vcloud.process_task(task)
|
83
|
-
end
|
84
|
-
|
85
|
-
def get_execute_query(type=nil, options={})
|
86
|
-
@vcloud.get_execute_query(type, options).body
|
87
|
-
end
|
88
|
-
|
89
|
-
def get_vapp_metadata(id)
|
90
|
-
@vcloud.get_vapp_metadata(id).body
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
def organizations
|
95
|
-
@vcloud.organizations
|
96
|
-
end
|
97
|
-
|
98
|
-
def org_name
|
99
|
-
@vcloud.org_name
|
100
|
-
end
|
101
|
-
|
102
|
-
def post_undeploy_vapp(vapp_id)
|
103
|
-
task = @vcloud.post_undeploy_vapp(vapp_id).body
|
104
|
-
@vcloud.process_task(task)
|
105
|
-
end
|
106
|
-
|
107
|
-
def delete_vapp(vapp_id)
|
108
|
-
task = @vcloud.delete_vapp(vapp_id).body
|
109
|
-
@vcloud.process_task(task)
|
110
|
-
end
|
111
|
-
|
112
|
-
def get_network_complete(id)
|
113
|
-
@vcloud.get_network_complete(id).body
|
114
|
-
end
|
115
|
-
|
116
|
-
def delete_network(id)
|
117
|
-
task = @vcloud.delete_network(id).body
|
118
|
-
@vcloud.process_task(task)
|
119
|
-
end
|
120
|
-
|
121
|
-
def post_create_org_vdc_network(vdc_id, name, options)
|
122
|
-
Vcloud::Core.logger.debug("creating #{options[:fence_mode]} OrgVdcNetwork #{name} in vDC #{vdc_id}")
|
123
|
-
attrs = @vcloud.post_create_org_vdc_network(vdc_id, name, options).body
|
124
|
-
@vcloud.process_task(attrs[:Tasks][:Task])
|
125
|
-
get_network_complete(extract_id(attrs))
|
126
|
-
end
|
127
|
-
|
128
|
-
def post_configure_edge_gateway_services(edgegw_id, config)
|
129
|
-
Vcloud::Core.logger.info("Updating EdgeGateway #{edgegw_id}")
|
130
|
-
begin
|
131
|
-
task = @vcloud.post_configure_edge_gateway_services(edgegw_id, config).body
|
132
|
-
@vcloud.process_task(task)
|
133
|
-
rescue => ex
|
134
|
-
Vcloud::Core.logger.error("Could not update EdgeGateway #{edgegw_id} : #{ex}")
|
135
|
-
raise
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def power_off_vapp(vapp_id)
|
140
|
-
task = @vcloud.post_power_off_vapp(vapp_id).body
|
141
|
-
@vcloud.process_task(task)
|
142
|
-
end
|
143
|
-
|
144
|
-
def power_on_vapp(vapp_id)
|
145
|
-
Vcloud::Core.logger.debug("Powering on vApp #{vapp_id}")
|
146
|
-
task = @vcloud.post_power_on_vapp(vapp_id).body
|
147
|
-
@vcloud.process_task(task)
|
148
|
-
end
|
149
|
-
|
150
|
-
def shutdown_vapp(vapp_id)
|
151
|
-
task = @vcloud.post_shutdown_vapp(vapp_id).body
|
152
|
-
@vcloud.process_task(task)
|
153
|
-
end
|
154
|
-
|
155
|
-
def put_vapp_metadata_value(id, k, v)
|
156
|
-
Vcloud::Core.logger.debug("putting metadata pair '#{k}'=>'#{v}' to #{id}")
|
157
|
-
# need to convert key to_s since Fog 0.17 borks on symbol key
|
158
|
-
task = @vcloud.put_vapp_metadata_item_metadata(id, k.to_s, v).body
|
159
|
-
@vcloud.process_task(task)
|
160
|
-
end
|
161
|
-
|
162
|
-
def get_edge_gateway(id)
|
163
|
-
@vcloud.get_edge_gateway(id).body
|
164
|
-
end
|
165
|
-
|
166
|
-
private
|
167
|
-
def extract_id(link)
|
168
|
-
link[:href].split('/').last
|
169
|
-
end
|
170
|
-
end
|
171
|
-
#
|
172
|
-
#########################
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
def initialize (fog = FogFacade.new)
|
177
|
-
@fog = fog
|
178
|
-
end
|
179
|
-
|
180
|
-
def org
|
181
|
-
link = session[:Link].select { |l| l[:rel] == RELATION::CHILD }.detect do |l|
|
182
|
-
l[:type] == ContentTypes::ORG
|
183
|
-
end
|
184
|
-
@fog.get_organization(link[:href].split('/').last)
|
185
|
-
end
|
186
|
-
|
187
|
-
def get_vapp_by_name_and_vdc_name name, vdc_name
|
188
|
-
response_body = @fog.get_vapps_in_lease_from_query({:filter => "name==#{name}"})
|
189
|
-
response_body[:VAppRecord].detect { |record| record[:vdcName] == vdc_name }
|
190
|
-
end
|
191
|
-
|
192
|
-
def vdc(name)
|
193
|
-
link = org[:Link].select { |l| l[:rel] == RELATION::CHILD }.detect do |l|
|
194
|
-
l[:type] == ContentTypes::VDC && l[:name] == name
|
195
|
-
end
|
196
|
-
raise "vdc #{name} cannot be found" unless link
|
197
|
-
@fog.get_vdc(link[:href].split('/').last)
|
198
|
-
|
199
|
-
end
|
200
|
-
|
201
|
-
def put_network_connection_system_section_vapp(vm_id, section)
|
202
|
-
begin
|
203
|
-
Vcloud::Core.logger.debug("adding NIC into VM #{vm_id}")
|
204
|
-
@fog.put_network_connection_system_section_vapp(vm_id, section)
|
205
|
-
rescue => ex
|
206
|
-
Vcloud::Core.logger.error("failed to put_network_connection_system_section_vapp for vm #{vm_id}: #{ex}")
|
207
|
-
Vcloud::Core.logger.debug("requested network section : #{section.inspect}")
|
208
|
-
raise
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
def find_networks(network_names, vdc_name)
|
213
|
-
network_names.collect do |network|
|
214
|
-
vdc(vdc_name)[:AvailableNetworks][:Network].detect do |l|
|
215
|
-
l[:type] == ContentTypes::NETWORK && l[:name] == network
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
def put_guest_customization_section(vm_id, vm_name, script)
|
221
|
-
begin
|
222
|
-
Vcloud::Core.logger.debug("configuring guest customization section for vm : #{vm_id}")
|
223
|
-
customization_req = {
|
224
|
-
:Enabled => true,
|
225
|
-
:CustomizationScript => script,
|
226
|
-
:ComputerName => vm_name
|
227
|
-
}
|
228
|
-
@fog.put_guest_customization_section_vapp(vm_id, customization_req)
|
229
|
-
rescue => ex
|
230
|
-
Vcloud::Core.logger.error("Failed to update guest customization section: #{ex}")
|
231
|
-
Vcloud::Core.logger.debug("=== interpolated preamble:")
|
232
|
-
Vcloud::Core.logger.debug(script)
|
233
|
-
raise
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
private
|
238
|
-
def extract_id(link)
|
239
|
-
link[:href].split('/').last
|
240
|
-
end
|
241
|
-
|
242
|
-
end
|
243
|
-
|
244
|
-
end
|
245
|
-
end
|