vcloud-walker 3.1.2 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ ## 3.2.0 (2014-05-14)
2
+
3
+ Features:
4
+
5
+ - Support v5.1 API over VCloud Director 5.5
6
+ - Require fog v1.21 to allow use of FOG_VCLOUD_TOKEN via ENV as an alternative to a .fog file
7
+
8
+ ## 3.1.2 (2014-02-07)
9
+
10
+ - First release of gem
data/README.md CHANGED
@@ -48,9 +48,13 @@ describes the entire organization, which includes edgegateway, catalogs, network
48
48
 
49
49
  ### Credentials
50
50
 
51
- You will need to specify the credentials for your VMware environment. As Vcloud-walker uses fog to query the VMware api, you will need to create a `.fog` file containing these credentials.
51
+ You will need to specify the credentials for your VMware environment. Vcloud-walker uses fog to query the VMware api,
52
+ which offers two ways to do this.
53
+
54
+ #### 1. Create a `.fog` file containing your credentials
52
55
 
53
56
  An example of .fog file is:
57
+
54
58
  ````
55
59
  default:
56
60
  vcloud_director_username: 'user_id@org_id'
@@ -60,6 +64,30 @@ default:
60
64
 
61
65
  To understand more about `.fog` files, visit the 'Credentials' section here => http://fog.io/about/getting_started.html.
62
66
 
67
+ ### 2. Log on externally and supply your session token
68
+
69
+ You can choose to log on externally by interacting independently with the API and supplying your session token to the
70
+ tool by setting the `FOG_VCLOUD_TOKEN` ENV variable. This option reduces the risk footprint by allowing the user to
71
+ store their credentials in safe storage. The default token lifetime is '30 minutes idle' - any activity extends the life by another 30 mins.
72
+
73
+ A basic example of this would be the following:
74
+
75
+ curl
76
+ -D-
77
+ -d ''
78
+ -H 'Accept: application/*+xml;version=5.1' -u '<user>@<org>'
79
+ https://host.com/api/sessions
80
+
81
+ This will prompt for your password.
82
+
83
+ From the headers returned, select the header below
84
+
85
+ x-vcloud-authorization: AAAABBBBBCCCCCCDDDDDDEEEEEEFFFFF=
86
+
87
+ Use token as ENV var FOG_VCLOUD_TOKEN
88
+
89
+ FOG_VCLOUD_TOKEN=AAAABBBBBCCCCCCDDDDDDEEEEEEFFFFF= vcloud-walk organization
90
+
63
91
  ### Output
64
92
 
65
93
  Walker can output data in JSON or YAML format. The default output format is JSON.
data/jenkins.sh CHANGED
@@ -6,4 +6,10 @@ git clean -fdx
6
6
 
7
7
  bundle install --path "${HOME}/bundles/${JOB_NAME}"
8
8
  bundle exec rake
9
+
10
+ ./scripts/generate_fog_conf_file.sh
11
+ export FOG_RC=fog_integration_test.config
12
+ bundle exec rake integration_test
13
+ rm fog_integration_test.config
14
+
9
15
  bundle exec rake publish_gem
@@ -58,10 +58,14 @@ module Vcloud
58
58
  def extract_disks(resources)
59
59
  disk_resources = resources.select { |element| element[:'rasd:ResourceType']== HARDWARE_RESOURCE_TYPES[:hard_disk] }
60
60
  @disks = disk_resources.collect do |d|
61
- {:name => d[:'rasd:ElementName'], :size => d[:'rasd:HostResource'][:'ns12_capacity'].to_i}
61
+ {:name => d[:'rasd:ElementName'], :size => extract_disk_capacity(d)}
62
62
  end
63
63
  end
64
64
 
65
+ def extract_disk_capacity(d)
66
+ (d[:"rasd:HostResource"][:ns12_capacity] || d[:"rasd:HostResource"][:vcloud_capacity]).to_i
67
+ end
68
+
65
69
  def extract_network_cards(resources)
66
70
  resources = resources.select {
67
71
  |element| element[:'rasd:ResourceType'] == HARDWARE_RESOURCE_TYPES[:network_adapter]
@@ -1,5 +1,5 @@
1
1
  module Vcloud
2
2
  module Walker
3
- VERSION = '3.1.2'
3
+ VERSION = '3.2.0'
4
4
  end
5
5
  end
@@ -66,14 +66,30 @@ module Fog
66
66
  RSpec::Mocks::Mock.new(:fog_vapp, :body => vapp_body)
67
67
  end
68
68
 
69
- def self.hardware_resources
69
+ def self.vcloud_director_five_one_ids
70
+ {
71
+ :disk_capacity_label => :ns12_capacity
72
+ }
73
+ end
74
+
75
+ def self.vcloud_director_5_5_with_v5_1_api_ids
76
+ {
77
+ :disk_capacity_label => :vcloud_capacity
78
+ }
79
+ end
80
+
81
+
82
+
83
+ def self.hardware_resources version_specific_ids
70
84
  [
71
85
  {
72
86
  :'rasd:ResourceType' =>:: Vcloud::Walker::Resource::Vm::HARDWARE_RESOURCE_TYPES[:hard_disk],
73
87
  :"rasd:AddressOnParent" => "0",
74
88
  :"rasd:Description" => "Hard disk",
75
89
  :"rasd:ElementName" => "Hard disk 1",
76
- :"rasd:HostResource" => {:ns12_capacity => "11265", :ns12_busSubType => "lsilogic", :ns12_busType => "6"},
90
+ :"rasd:HostResource" => {version_specific_ids[:disk_capacity_label] => "11265",
91
+ :ns12_busSubType => "lsilogic",
92
+ :ns12_busType => "6"},
77
93
  },
78
94
 
79
95
  {
@@ -81,7 +97,9 @@ module Fog
81
97
  :"rasd:AddressOnParent" => "1",
82
98
  :"rasd:Description" => "Hard disk",
83
99
  :"rasd:ElementName" => "Hard disk 2",
84
- :"rasd:HostResource" => {:ns12_capacity => "307200", :ns12_busSubType => "lsilogic", :ns12_busType => "6"}
100
+ :"rasd:HostResource" => {version_specific_ids[:disk_capacity_label] => "307200",
101
+ :ns12_busSubType => "lsilogic",
102
+ :ns12_busType => "6"}
85
103
  },
86
104
  {
87
105
  :'rasd:ResourceType' => ::Vcloud::Walker::Resource::Vm::HARDWARE_RESOURCE_TYPES[:cpu],
data/spec/walk/vm_spec.rb CHANGED
@@ -2,55 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe Vcloud::Walker::Resource::Vm do
4
4
 
5
- context 'populate summary vm model' do
5
+ context 'populate summary vm model for 5.1' do
6
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
- }
7
+ fog_vm = assemble_sample_vm_data Fog::ServiceLayerStub.vcloud_director_five_one_ids
51
8
 
52
9
  @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)
10
+ Vcloud::Core::Vm.should_receive(:get_metadata)
11
+ .with("vm-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
12
+ .and_return(@metadata)
54
13
 
55
14
  @vm_summary = Vcloud::Walker::Resource::Vm.new(fog_vm)
56
15
  end
@@ -118,5 +77,80 @@ describe Vcloud::Walker::Resource::Vm do
118
77
  end
119
78
 
120
79
  end
80
+
81
+
82
+ context 'populate summary vm model for 5.1 api on vcloud director 5.5' do
83
+ before(:each) do
84
+ fog_vm = assemble_sample_vm_data Fog::ServiceLayerStub.vcloud_director_5_5_with_v5_1_api_ids
85
+
86
+ @metadata = {:name => 'web-app-1', :shutdown => true}
87
+ Vcloud::Core::Vm.should_receive(:get_metadata)
88
+ .with("vm-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
89
+ .and_return(@metadata)
90
+
91
+ @vm_summary = Vcloud::Walker::Resource::Vm.new(fog_vm)
92
+ end
93
+
94
+ it "report disk info for 5.1 api on 5.5" do
95
+ @vm_summary.disks.count.should == 2
96
+ @vm_summary.disks.first.should == {:name => "Hard disk 1", :size => 11265}
97
+ @vm_summary.disks.last.should == {:name => "Hard disk 2", :size => 307200}
98
+ end
99
+
100
+ end
101
+
102
+ def assemble_sample_vm_data api_version
103
+ {
104
+ :deployed => "true",
105
+ :status => "8",
106
+ :name => "ubuntu-testing-template",
107
+ :id => "urn:vcloud:vm:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
108
+ :href => 'https://myvdc.carrenza.net/api/vApp/vm-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
109
+ :"ovf:VirtualHardwareSection" =>
110
+ {
111
+ :"ovf:Info" => "Virtual hardware requirements",
112
+ :"ovf:System" =>
113
+ {
114
+ :"vssd:ElementName" => "Virtual Hardware Family",
115
+ :"vssd:VirtualSystemType" => "vmx-08"
116
+ },
117
+ :'ovf:Item' => Fog::ServiceLayerStub.hardware_resources(api_version)
118
+ },
119
+ :"ovf:OperatingSystemSection" =>
120
+ {
121
+ :vmw_osType => "ubuntu64Guest",
122
+ :"ovf:Info" => "Specifies the operating system installed",
123
+ :"ovf:Description" => "Ubuntu Linux (64-bit)"
124
+ },
125
+ :NetworkConnectionSection =>
126
+ {
127
+ :type => "application/vnd.vmware.vcloud.networkConnectionSection+xml",
128
+ :ovf_required => "false",
129
+ :"ovf:Info" => "Specifies the available VM network connections",
130
+ :PrimaryNetworkConnectionIndex => "0",
131
+ :NetworkConnection =>
132
+ [
133
+ {
134
+ :network => "Default",
135
+ :needsCustomization => "true",
136
+ :NetworkConnectionIndex => "0",
137
+ :IpAddress => "192.168.254.100",
138
+ :IsConnected => "true",
139
+ :MACAddress => "00:50:56:00:00:01",
140
+ :IpAddressAllocationMode => "MANUAL"
141
+ },
142
+ ]
143
+ },
144
+ :RuntimeInfoSection => {:VMWareTools => {:version => "2147483647"}},
145
+ :StorageProfile =>
146
+ {
147
+ :type => "application/vnd.vmware.vcloud.vdcStorageProfile+xml",
148
+ :name => "TEST-STORAGE-PROFILE",
149
+ :href => "https://api.vcd.portal.examplecloud.com/api/vdcStorageProfile/00000000-aaaa-bbbb-aaaa-000000000000"
150
+ }
151
+ }
152
+ end
153
+
154
+
121
155
  end
122
156
 
@@ -24,8 +24,8 @@ Gem::Specification.new do |s|
24
24
  s.add_development_dependency 'json_spec', '~> 1.1.1'
25
25
  s.add_runtime_dependency 'json', '~> 1.8.0'
26
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'
27
+ s.add_runtime_dependency 'fog', '>= 1.21.0'
28
+ s.add_runtime_dependency 'vcloud-core', '>= 0.0.11'
29
29
  s.add_development_dependency 'simplecov', '~> 0.8.2'
30
30
  s.add_development_dependency 'gem_publisher', '1.2.0'
31
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcloud-walker
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.2.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-02-07 00:00:00.000000000 Z
12
+ date: 2014-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ! '>='
116
116
  - !ruby/object:Gem::Version
117
- version: 1.19.0
117
+ version: 1.21.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
- version: 1.19.0
125
+ version: 1.21.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: vcloud-core
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ! '>='
132
132
  - !ruby/object:Gem::Version
133
- version: 0.0.5
133
+ version: 0.0.11
134
134
  type: :runtime
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +138,7 @@ dependencies:
138
138
  requirements:
139
139
  - - ! '>='
140
140
  - !ruby/object:Gem::Version
141
- version: 0.0.5
141
+ version: 0.0.11
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: simplecov
144
144
  requirement: !ruby/object:Gem::Requirement
@@ -181,6 +181,7 @@ extensions: []
181
181
  extra_rdoc_files: []
182
182
  files:
183
183
  - .gitignore
184
+ - CHANGELOG.md
184
185
  - Gemfile
185
186
  - LICENSE
186
187
  - README.md
@@ -241,7 +242,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
241
242
  version: '0'
242
243
  segments:
243
244
  - 0
244
- hash: 1800387428395213455
245
+ hash: -3247384966975022659
245
246
  required_rubygems_version: !ruby/object:Gem::Requirement
246
247
  none: false
247
248
  requirements:
@@ -250,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
251
  version: '0'
251
252
  segments:
252
253
  - 0
253
- hash: 1800387428395213455
254
+ hash: -3247384966975022659
254
255
  requirements: []
255
256
  rubyforge_project:
256
257
  rubygems_version: 1.8.23