vcloud-walker 3.1.1
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.
- data/.gitignore +9 -0
- data/Gemfile +12 -0
- data/LICENSE +20 -0
- data/README.md +55 -0
- data/Rakefile +21 -0
- data/bin/vcloud-walk +41 -0
- data/docs/examples/catalogs.json +40 -0
- data/docs/examples/edgegateways.json +285 -0
- data/docs/examples/networks.json +53 -0
- data/docs/examples/vdcs.json +221 -0
- data/jenkins.sh +9 -0
- data/jenkins_integration_tests.sh +11 -0
- data/lib/vcloud/walker/fog_interface.rb +48 -0
- data/lib/vcloud/walker/resource/catalog.rb +29 -0
- data/lib/vcloud/walker/resource/catalog_item.rb +25 -0
- data/lib/vcloud/walker/resource/collection.rb +13 -0
- data/lib/vcloud/walker/resource/entity.rb +27 -0
- data/lib/vcloud/walker/resource/gateway_ipsec_vpn_service.rb +46 -0
- data/lib/vcloud/walker/resource/network.rb +38 -0
- data/lib/vcloud/walker/resource/organization.rb +45 -0
- data/lib/vcloud/walker/resource/vapp.rb +46 -0
- data/lib/vcloud/walker/resource/vdc.rb +35 -0
- data/lib/vcloud/walker/resource/vm.rb +85 -0
- data/lib/vcloud/walker/resource.rb +11 -0
- data/lib/vcloud/walker/vcloud_session.rb +13 -0
- data/lib/vcloud/walker/version.rb +5 -0
- data/lib/vcloud/walker.rb +23 -0
- data/scripts/configure_walker_ci_vse.rb +31 -0
- data/scripts/data/walker_ci/carrenza.yaml +17 -0
- data/scripts/data/walker_ci/skyscape.yaml +17 -0
- data/scripts/generate_fog_conf_file.sh +6 -0
- data/spec/fog_interface_spec.rb +93 -0
- data/spec/integration/vcloud_walker_spec.rb +74 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/stubs/service_layer_stub.rb +109 -0
- data/spec/stubs/stubs.rb +46 -0
- data/spec/vcloud/walker_spec.rb +59 -0
- data/spec/walk/catalogs_spec.rb +31 -0
- data/spec/walk/entity_spec.rb +69 -0
- data/spec/walk/gateway_ipsec_vpn_service_spec.rb +157 -0
- data/spec/walk/network_spec.rb +70 -0
- data/spec/walk/organization_spec.rb +53 -0
- data/spec/walk/vapp_spec.rb +24 -0
- data/spec/walk/vdcs_spec.rb +30 -0
- data/spec/walk/vm_spec.rb +122 -0
- data/vcloud-walker.gemspec +31 -0
- metadata +274 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/mocks'
|
3
|
+
|
4
|
+
describe Vcloud::Walker::Resource::Catalogs do
|
5
|
+
|
6
|
+
it "should summarize catalogs" do
|
7
|
+
set_login_credential
|
8
|
+
mock_fog_item = double(:catalog_item,
|
9
|
+
:id => "12345",
|
10
|
+
:name => 'ubuntu 11.04',
|
11
|
+
:description => 'image for ubuntu 11.04',
|
12
|
+
:vapp_template_id => 'vapp-template-01')
|
13
|
+
mock_fog_catalog = double(:catalog,
|
14
|
+
:id => 'catalog_id_1',
|
15
|
+
:name => 'Default catalog',
|
16
|
+
:description => 'default catalog for infrastructure',
|
17
|
+
:catalog_items => double(:catalog_items, :all => [mock_fog_item]))
|
18
|
+
|
19
|
+
catalog_summary = Vcloud::Walker::Resource::Catalogs.new([mock_fog_catalog]).to_summary
|
20
|
+
catalog_summary.count.should == 1
|
21
|
+
catalog_summary.first[:items].count.should == 1
|
22
|
+
catalog_summary.should == [{
|
23
|
+
:id => "catalog_id_1",
|
24
|
+
:name => "Default catalog",
|
25
|
+
:description => "default catalog for infrastructure",
|
26
|
+
:items => [
|
27
|
+
{:id => "12345", :name => "ubuntu 11.04", :description => "image for ubuntu 11.04", :vapp_template_id => "vapp-template-01"}
|
28
|
+
]
|
29
|
+
}]
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Vcloud
|
4
|
+
module Walker
|
5
|
+
module Resource
|
6
|
+
|
7
|
+
class TestData < Entity
|
8
|
+
attr_accessor :name
|
9
|
+
|
10
|
+
def initialize data
|
11
|
+
self.name = data.name
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class TestDataCollection < Collection
|
16
|
+
def initialize coll
|
17
|
+
coll.each do |c|
|
18
|
+
self << Vcloud::Walker::Resource::TestData.new(c)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
class TestClass < Entity
|
25
|
+
attr_accessor :test_data
|
26
|
+
attr_accessor :description
|
27
|
+
|
28
|
+
def initialize test
|
29
|
+
self.test_data = TestDataCollection.new(test.collection)
|
30
|
+
self.description = test.description
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class TestNestedEntity < Entity
|
35
|
+
attr_accessor :test_data
|
36
|
+
def initialize data
|
37
|
+
self.test_data = TestData.new(data)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe Vcloud::Walker::Resource::Entity do
|
45
|
+
it 'should be able to nested collections inside entities' do
|
46
|
+
collection = [double(:name => 'collection 1'), double(:name => 'collection 2')]
|
47
|
+
test_class = Vcloud::Walker::Resource::TestClass.new(double(:description => 'test class desc', :collection => collection))
|
48
|
+
|
49
|
+
test_class.to_summary.should == {:test_data => [{:name => "collection 1"}, {:name => "collection 2"}], :description => "test class desc"}
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should summaries a class as a hash and remove @ from the symbol names' do
|
53
|
+
collection = [double(:name => 'collection 1'), double(:name => 'collection 2')]
|
54
|
+
test_class = Vcloud::Walker::Resource::TestClass.new(double(:description => 'test class desc', :collection => collection))
|
55
|
+
test_class.instance_variables.should eq([:@test_data, :@description])
|
56
|
+
test_summary = test_class.to_summary
|
57
|
+
test_summary.keys.should eq([:test_data, :description])
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should be able to nest entity inside entity' do
|
61
|
+
nested_entities = Vcloud::Walker::Resource::TestNestedEntity.new(double(:data, :name => 'Data 1'))
|
62
|
+
expect(nested_entities.to_summary).to eq({:test_data=>{:name=>"Data 1"}})
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vcloud::Walker::Resource::GatewayIpsecVpnService do
|
4
|
+
context "vpn service with single tunnel" do
|
5
|
+
before(:all) do
|
6
|
+
fog_vpn_service = {
|
7
|
+
IsEnabled: true,
|
8
|
+
Tunnel: {
|
9
|
+
Name: "ss_one",
|
10
|
+
Description: "desc one",
|
11
|
+
IpsecVpnThirdPartyPeer: {
|
12
|
+
PeerId: "1"
|
13
|
+
},
|
14
|
+
PeerIpAddress: "8.8.8.8",
|
15
|
+
PeerId: "1",
|
16
|
+
LocalIpAddress: "192.0.2.1",
|
17
|
+
LocalId: "1",
|
18
|
+
LocalSubnet: {
|
19
|
+
Name: "Default",
|
20
|
+
Gateway: "192.168.0.1",
|
21
|
+
Netmask: "255.255.0.0"
|
22
|
+
},
|
23
|
+
PeerSubnet: {
|
24
|
+
Name: "8.8.8.0/8",
|
25
|
+
Gateway: "8.8.8.0",
|
26
|
+
Netmask: "255.0.0.0"
|
27
|
+
},
|
28
|
+
SharedSecret: "DoNotDiscloseDoNotDiscloseDoNotDiscloseDoNotDiscloseDoNotDisclose",
|
29
|
+
SharedSecretEncrypted: "false",
|
30
|
+
EncryptionProtocol: "AES256",
|
31
|
+
Mtu: "1500",
|
32
|
+
AdditionalDetails: {
|
33
|
+
shared_network: true
|
34
|
+
},
|
35
|
+
IsEnabled: "true",
|
36
|
+
IsOperational: "false"
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
@gateway_vpn_service = Vcloud::Walker::Resource::GatewayIpsecVpnService.new(fog_vpn_service)
|
41
|
+
end
|
42
|
+
it "should report status of vpn service" do
|
43
|
+
expect(@gateway_vpn_service.IsEnabled).to eq(true)
|
44
|
+
expect(@gateway_vpn_service.Tunnels).not_to be_empty
|
45
|
+
end
|
46
|
+
|
47
|
+
context "report tunnel info" do
|
48
|
+
before(:all) do
|
49
|
+
@tunnel = @gateway_vpn_service.Tunnels.first
|
50
|
+
end
|
51
|
+
|
52
|
+
it "with peer details" do
|
53
|
+
expect(@tunnel[:PeerId]).to eq('1')
|
54
|
+
expect(@tunnel[:PeerIpAddress]).to eq('8.8.8.8')
|
55
|
+
expect(@tunnel[:PeerSubnet]).to eq({
|
56
|
+
Name: "8.8.8.0/8",
|
57
|
+
Gateway: "8.8.8.0",
|
58
|
+
Netmask: "255.0.0.0"
|
59
|
+
})
|
60
|
+
end
|
61
|
+
|
62
|
+
it "with local network details" do
|
63
|
+
expect(@tunnel[:LocalId]).to eq('1')
|
64
|
+
expect(@tunnel[:LocalIpAddress]).to eq('192.0.2.1')
|
65
|
+
expect(@tunnel[:LocalSubnet]).to eq({
|
66
|
+
Name: "Default",
|
67
|
+
Gateway: "192.168.0.1",
|
68
|
+
Netmask: "255.255.0.0"
|
69
|
+
})
|
70
|
+
end
|
71
|
+
|
72
|
+
it "with maximum transmission unit" do
|
73
|
+
expect(@tunnel[:Mtu]).to eq('1500')
|
74
|
+
end
|
75
|
+
|
76
|
+
it "with masked vpn shared secret information" do
|
77
|
+
expect(@tunnel[:SharedSecret]).to eq("*" * 65)
|
78
|
+
expect(@tunnel[:SharedSecretEncrypted]).to eq("******")
|
79
|
+
expect(@tunnel[:EncryptionProtocol]).to eq("******")
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should skip any addditional vpn details provided by fog" do
|
83
|
+
expect(@tunnel[:AdditionalDetails]).to be_nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should report vpn service with multiple tunnels" do
|
90
|
+
fog_vpn_service = {
|
91
|
+
IsEnabled: true,
|
92
|
+
Tunnel: [
|
93
|
+
{
|
94
|
+
Name: "remove vpn 1",
|
95
|
+
Description: "describe me",
|
96
|
+
IpsecVpnThirdPartyPeer: {
|
97
|
+
PeerId: "1"
|
98
|
+
},
|
99
|
+
PeerIpAddress: "8.8.8.8",
|
100
|
+
PeerId: "1",
|
101
|
+
LocalIpAddress: "192.0.2.1",
|
102
|
+
LocalId: "1",
|
103
|
+
LocalSubnet: {
|
104
|
+
Name: "Default",
|
105
|
+
Gateway: "192.168.0.1",
|
106
|
+
Netmask: "255.255.0.0"
|
107
|
+
},
|
108
|
+
PeerSubnet: {
|
109
|
+
Name: "8.8.8.0/8",
|
110
|
+
Gateway: "8.8.8.0",
|
111
|
+
Netmask: "255.0.0.0"
|
112
|
+
},
|
113
|
+
SharedSecret: "DoNotDiscloseDoNotDiscloseDoNotDiscloseDoNotDiscloseDoNotDisclose",
|
114
|
+
SharedSecretEncrypted: "false",
|
115
|
+
EncryptionProtocol: "AES256",
|
116
|
+
Mtu: "1500",
|
117
|
+
AdditionalDetails: {
|
118
|
+
shared_network: true
|
119
|
+
},
|
120
|
+
IsEnabled: "true",
|
121
|
+
IsOperational: "false"
|
122
|
+
},
|
123
|
+
{
|
124
|
+
Name: "remote vpn 2",
|
125
|
+
Description: "describe me",
|
126
|
+
IpsecVpnThirdPartyPeer: {
|
127
|
+
PeerId: "2"
|
128
|
+
},
|
129
|
+
PeerIpAddress: "8.8.4.4",
|
130
|
+
PeerId: "2",
|
131
|
+
LocalIpAddress: "172.26.2.3",
|
132
|
+
LocalId: "2",
|
133
|
+
LocalSubnet: {
|
134
|
+
Name: "Default",
|
135
|
+
Gateway: "192.168.0.1",
|
136
|
+
Netmask: "255.255.0.0"
|
137
|
+
},
|
138
|
+
PeerSubnet: {
|
139
|
+
Name: "8.8.4.4/8",
|
140
|
+
Gateway: "8.8.4.4",
|
141
|
+
Netmask: "255.0.0.0"
|
142
|
+
},
|
143
|
+
SharedSecret: "PrivyPrivyPrivyPrivyPrivyPrivyPrivyPrivyPrivyPrivy",
|
144
|
+
SharedSecretEncrypted: "false",
|
145
|
+
EncryptionProtocol: "AES256",
|
146
|
+
Mtu: "1500",
|
147
|
+
IsEnabled: "true",
|
148
|
+
IsOperational: "false"
|
149
|
+
}
|
150
|
+
]
|
151
|
+
}
|
152
|
+
|
153
|
+
gateway_vpn_service = Vcloud::Walker::Resource::GatewayIpsecVpnService.new(fog_vpn_service)
|
154
|
+
expect(gateway_vpn_service.Tunnels.count).to eq(2)
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/mocks'
|
3
|
+
require 'fog'
|
4
|
+
|
5
|
+
describe Vcloud::Walker::Resource::Networks do
|
6
|
+
|
7
|
+
context "Summary" do
|
8
|
+
before(:each) do
|
9
|
+
set_login_credential
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should walk all networks within given org" do
|
13
|
+
|
14
|
+
mock_fog_network = mock_fog_network_object
|
15
|
+
|
16
|
+
networks = Vcloud::Walker::Resource::Networks.new([mock_fog_network, mock_fog_network])
|
17
|
+
|
18
|
+
networks.count.should == 2
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
it "should be happy with one network" do
|
23
|
+
|
24
|
+
mock_fog_network = mock_fog_network_object
|
25
|
+
|
26
|
+
networks = Vcloud::Walker::Resource::Networks.new([mock_fog_network])
|
27
|
+
|
28
|
+
networks.count.should == 1
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should handle having no networks" do
|
32
|
+
networks = Vcloud::Walker::Resource::Networks.new([])
|
33
|
+
|
34
|
+
networks.count.should == 0
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
it "should map parameters of a network to the local entity" do
|
39
|
+
mock_fog_network = mock_fog_network_object
|
40
|
+
expect(mock_fog_network).to receive(:dns1).and_return('sausage')
|
41
|
+
|
42
|
+
networks = Vcloud::Walker::Resource::Networks.new([mock_fog_network])
|
43
|
+
|
44
|
+
networks.count.should == 1
|
45
|
+
networks.first.id.should == :network_id_1
|
46
|
+
networks.first.name.should == :name
|
47
|
+
networks.first.dns_suffix == :dns_suffix
|
48
|
+
networks.first.dns1 == 'sausage'
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def mock_fog_network_object
|
56
|
+
double(:fog_network,
|
57
|
+
:id => :network_id_1,
|
58
|
+
:name => :name,
|
59
|
+
:description => :default,
|
60
|
+
:is_inherited => false,
|
61
|
+
:gateway => false,
|
62
|
+
:netmask => :default,
|
63
|
+
:dns_suffix => :dns_suffix,
|
64
|
+
:dns2 => :default,
|
65
|
+
:dns1 => :default,
|
66
|
+
:ip_ranges => :default)
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vcloud::Walker::Resource::Organization do
|
4
|
+
|
5
|
+
it "should retrieve networks" do
|
6
|
+
fog_networks = double(:fog_networks)
|
7
|
+
Vcloud::Walker::FogInterface.should_receive(:get_networks).and_return(fog_networks)
|
8
|
+
Vcloud::Walker::Resource::Networks.should_receive(:new).with(fog_networks).and_return(double(:walker_networks, :to_summary => [:network => "Network 1"]))
|
9
|
+
Vcloud::Walker::Resource::Organization.networks.should == [:network => "Network 1"]
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should retrieve catalogs" do
|
13
|
+
fog_catalogs = double(:fog_catalogs)
|
14
|
+
Vcloud::Walker::FogInterface.should_receive(:get_catalogs).and_return(fog_catalogs)
|
15
|
+
Vcloud::Walker::Resource::Catalogs.should_receive(:new).with(fog_catalogs).and_return(double(:walker_catalogs, :to_summary => [:catalog => "Catalog 1"]))
|
16
|
+
Vcloud::Walker::Resource::Organization.catalogs.should == [:catalog => "Catalog 1"]
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should retrieve vdcs" do
|
20
|
+
fog_vdcs = double(:fog_vdcs)
|
21
|
+
Vcloud::Walker::FogInterface.should_receive(:get_vdcs).and_return(fog_vdcs)
|
22
|
+
Vcloud::Walker::Resource::Vdcs.should_receive(:new).with(fog_vdcs).and_return(double(:walker_vdcs, :to_summary => [:vdc => "VDC 1"]))
|
23
|
+
Vcloud::Walker::Resource::Organization.vdcs.should == [:vdc => "VDC 1"]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should retrieve edgegateways" do
|
27
|
+
fog_edgegateways = [{:id => 'urn:vcloud:gateway:1', :href => 'host/1', :name => 'Gateway 1',
|
28
|
+
:Configuration => { :EdgeGatewayServiceConfiguration => {}}}]
|
29
|
+
Vcloud::Walker::FogInterface.should_receive(:get_edge_gateways).and_return(fog_edgegateways)
|
30
|
+
|
31
|
+
Vcloud::Walker::Resource::Organization.edgegateways.should == [{:id => '1',
|
32
|
+
name: 'Gateway 1',
|
33
|
+
:href => 'host/1',
|
34
|
+
:Configuration => {
|
35
|
+
:EdgeGatewayServiceConfiguration => {}}
|
36
|
+
}]
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should retrive entire organization" do
|
40
|
+
Vcloud::Walker::Resource::Organization.should_receive(:edgegateways).and_return([:edgegateway => 'Gateway 1'])
|
41
|
+
Vcloud::Walker::Resource::Organization.should_receive(:vdcs).and_return([:vdc => "VDC 1"])
|
42
|
+
Vcloud::Walker::Resource::Organization.should_receive(:catalogs).and_return([:catalog => "Catalog 1"])
|
43
|
+
Vcloud::Walker::Resource::Organization.should_receive(:networks).and_return([:network => "Network 1"])
|
44
|
+
|
45
|
+
Vcloud::Walker::Resource::Organization.organization.should == {
|
46
|
+
:vdcs => [{ :vdc => "VDC 1" }],
|
47
|
+
:networks => [{ :network => "Network 1" }],
|
48
|
+
:catalogs => [{ :catalog => "Catalog 1" }],
|
49
|
+
:edgegateways => [{ :edgegateway => "Gateway 1" }]
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vcloud::Walker::Resource::VApp do
|
4
|
+
|
5
|
+
context 'populate summary vapp model' do
|
6
|
+
before(:each) do
|
7
|
+
fog_vapp = Fog::ServiceLayerStub.vapp_body
|
8
|
+
@metadata = {:name => 'web-app-1', :shutdown => true}
|
9
|
+
Vcloud::Core::Vapp.should_receive(:get_metadata).with("vapp-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee").and_return(@metadata)
|
10
|
+
Vcloud::Walker::Resource::Vms.should_receive(:new).with(fog_vapp[:Children][:Vm])
|
11
|
+
|
12
|
+
@vapp_summary = Vcloud::Walker::Resource::VApp.new(fog_vapp)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should report id from the href' do
|
16
|
+
@vapp_summary.id.should == 'vapp-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should report metadata" do
|
20
|
+
@vapp_summary.metadata.count.should == 2
|
21
|
+
@vapp_summary.metadata.should == @metadata
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fog'
|
3
|
+
|
4
|
+
describe Vcloud::Walker::Resource::Vdcs do
|
5
|
+
let(:api_session) { double(:fog_session) }
|
6
|
+
|
7
|
+
context 'vdcs' do
|
8
|
+
|
9
|
+
it "should summarize vdcs" do
|
10
|
+
Fog::Compute::VcloudDirector.should_receive(:new).with(any_args()).and_return(api_session)
|
11
|
+
mock_fog_vdcs = StubCollectionBuilders.vdcs(StubVdc.new.vapps([mock_vapp]).build)
|
12
|
+
api_session.should_receive(:get_vapp).with(1).and_return(Fog::ServiceLayerStub.mock_vapp)
|
13
|
+
Vcloud::Core::Vm.should_receive(:get_metadata).with("vm-d19d84a5-c950-4497-a638-23eccc4226a5").and_return({})
|
14
|
+
Vcloud::Core::Vapp.should_receive(:get_metadata).with("vapp-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee").and_return({})
|
15
|
+
|
16
|
+
vdcs_summary = Vcloud::Walker::Resource::Vdcs.new(mock_fog_vdcs).to_summary
|
17
|
+
|
18
|
+
vdc_summary = vdcs_summary.first
|
19
|
+
vdc_summary[:vapps].count.should == 1
|
20
|
+
vdc_summary[:vapps].first[:vms].count == 1
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def mock_vapp
|
26
|
+
double(:vapp, :id => 1)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vcloud::Walker::Resource::Vm do
|
4
|
+
|
5
|
+
context 'populate summary vm model' do
|
6
|
+
before(:each) do
|
7
|
+
fog_vm = {
|
8
|
+
:deployed => "true",
|
9
|
+
:status => "8",
|
10
|
+
:name => "ubuntu-testing-template",
|
11
|
+
:id => "urn:vcloud:vm:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
|
12
|
+
:href => 'https://myvdc.carrenza.net/api/vApp/vm-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
|
13
|
+
:"ovf:VirtualHardwareSection" =>
|
14
|
+
{:"ovf:Info" => "Virtual hardware requirements",
|
15
|
+
:"ovf:System" => {:"vssd:ElementName" => "Virtual Hardware Family", :"vssd:VirtualSystemType" => "vmx-08"},
|
16
|
+
:'ovf:Item' => Fog::ServiceLayerStub.hardware_resources
|
17
|
+
},
|
18
|
+
:"ovf:OperatingSystemSection" =>
|
19
|
+
{
|
20
|
+
:vmw_osType => "ubuntu64Guest",
|
21
|
+
:"ovf:Info" => "Specifies the operating system installed",
|
22
|
+
:"ovf:Description" => "Ubuntu Linux (64-bit)"
|
23
|
+
},
|
24
|
+
:NetworkConnectionSection =>
|
25
|
+
{
|
26
|
+
:type => "application/vnd.vmware.vcloud.networkConnectionSection+xml",
|
27
|
+
:ovf_required => "false",
|
28
|
+
:"ovf:Info" => "Specifies the available VM network connections",
|
29
|
+
:PrimaryNetworkConnectionIndex => "0",
|
30
|
+
:NetworkConnection =>
|
31
|
+
[
|
32
|
+
{
|
33
|
+
:network => "Default",
|
34
|
+
:needsCustomization => "true",
|
35
|
+
:NetworkConnectionIndex => "0",
|
36
|
+
:IpAddress => "192.168.254.100",
|
37
|
+
:IsConnected => "true",
|
38
|
+
:MACAddress => "00:50:56:00:00:01",
|
39
|
+
:IpAddressAllocationMode => "MANUAL"
|
40
|
+
},
|
41
|
+
]
|
42
|
+
},
|
43
|
+
:RuntimeInfoSection => {:VMWareTools => {:version => "2147483647"}},
|
44
|
+
:StorageProfile =>
|
45
|
+
{
|
46
|
+
:type=>"application/vnd.vmware.vcloud.vdcStorageProfile+xml",
|
47
|
+
:name=>"TEST-STORAGE-PROFILE",
|
48
|
+
:href=>"https://api.vcd.portal.examplecloud.com/api/vdcStorageProfile/00000000-aaaa-bbbb-aaaa-000000000000"
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
@metadata = {:name => 'web-app-1', :shutdown => true}
|
53
|
+
Vcloud::Core::Vm.should_receive(:get_metadata).with("vm-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee").and_return(@metadata)
|
54
|
+
|
55
|
+
@vm_summary = Vcloud::Walker::Resource::Vm.new(fog_vm)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should report id from the href' do
|
59
|
+
@vm_summary.id.should == 'vm-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should populate vmware tool version" do
|
63
|
+
@vm_summary.vmware_tools.should == {:version => "2147483647"}
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should populate virtual system type" do
|
67
|
+
@vm_summary.virtual_system_type.should == "vmx-08"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should populate operating system" do
|
71
|
+
@vm_summary.operating_system.should == 'Ubuntu Linux (64-bit)'
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should populate network connection interface" do
|
75
|
+
@vm_summary.primary_network_connection_index.should == '0'
|
76
|
+
@vm_summary.network_connections.count.should == 1
|
77
|
+
@vm_summary.network_connections.first[:network].should == 'Default'
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should populate storage profile" do
|
81
|
+
@vm_summary.storage_profile[:name].should == "TEST-STORAGE-PROFILE"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should populate storage profile id" do
|
85
|
+
@vm_summary.storage_profile[:id].should == "00000000-aaaa-bbbb-aaaa-000000000000"
|
86
|
+
end
|
87
|
+
|
88
|
+
context "hardware resource info" do
|
89
|
+
|
90
|
+
it "report cpu" do
|
91
|
+
@vm_summary.cpu.should == '2 virtual CPU(s)'
|
92
|
+
end
|
93
|
+
|
94
|
+
it "report memory" do
|
95
|
+
@vm_summary.memory.should == '4096 MB of memory'
|
96
|
+
end
|
97
|
+
|
98
|
+
it "report disk info" do
|
99
|
+
@vm_summary.disks.count.should == 2
|
100
|
+
@vm_summary.disks.first.should == {:name => "Hard disk 1", :size => 11265}
|
101
|
+
@vm_summary.disks.last.should == {:name => "Hard disk 2", :size => 307200}
|
102
|
+
end
|
103
|
+
|
104
|
+
it "report network card info" do
|
105
|
+
@vm_summary.network_cards.count.should == 1
|
106
|
+
@vm_summary.network_cards[0].should == {
|
107
|
+
:mac_address => '00:50:56:00:00:01',
|
108
|
+
:name => "Network adapter 0",
|
109
|
+
:type => "E1000"
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
it "report metadata" do
|
116
|
+
@vm_summary.metadata.count.should == 2
|
117
|
+
@vm_summary.metadata.should == @metadata
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "vcloud/walker/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'vcloud-walker'
|
7
|
+
s.version = Vcloud::Walker::VERSION
|
8
|
+
s.authors = ['Government Digital Service']
|
9
|
+
s.homepage = 'https://github.com/alphagov/vcloud-walker'
|
10
|
+
s.summary = %q{Command line tool to describe vCloud entities}
|
11
|
+
s.description = %q{Vcloud-walker is a command line tool to describe different vCloud entities.
|
12
|
+
This tool is a thin layer around fog api, which exposes summarized vCloud entities
|
13
|
+
in the form of JSON}
|
14
|
+
s.license = 'MIT'
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename(f)}
|
18
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency 'rake'
|
22
|
+
s.add_development_dependency 'rspec', '~> 2.14.1'
|
23
|
+
s.add_development_dependency 'rspec-mocks', '~> 2.14.3'
|
24
|
+
s.add_development_dependency 'json_spec', '~> 1.1.1'
|
25
|
+
s.add_runtime_dependency 'json', '~> 1.8.0'
|
26
|
+
s.add_runtime_dependency 'methadone'
|
27
|
+
s.add_runtime_dependency 'fog', '>= 1.19.0'
|
28
|
+
s.add_runtime_dependency 'vcloud-core', '>= 0.0.5'
|
29
|
+
s.add_development_dependency 'simplecov', '~> 0.8.2'
|
30
|
+
s.add_development_dependency 'gem_publisher', '1.2.0'
|
31
|
+
end
|