-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request fog#2210 from nosborn/vcloud_director_get_ovf_desc…
…riptor [vcloud_director] Add get_*_ovf_descriptor methods.
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
lib/fog/vcloud_director/requests/compute/get_vapp_ovf_descriptor.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Fog | ||
module Compute | ||
class VcloudDirector | ||
class Real | ||
# Retrieve the OVF descriptor of a vApp directly. | ||
# | ||
# @param [String] id Object identifier of the vApp. | ||
# @return [Excon::Response] | ||
# * body<~String> - | ||
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-VAppOvfDescriptor.html | ||
# vCloud API Documentation | ||
# @since vCloud API version 5.1 | ||
def get_vapp_ovf_descriptor(id) | ||
request( | ||
:expects => 200, | ||
:idempotent => true, | ||
:method => 'GET', | ||
:path => "vApp/#{id}/ovf" | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
lib/fog/vcloud_director/requests/compute/get_vapp_template_ovf_descriptor.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Fog | ||
module Compute | ||
class VcloudDirector | ||
class Real | ||
# Retrieve the OVF descriptor of a vApp template. | ||
# | ||
# @param [String] id Object identifier of the vAppTemplate. | ||
# @return [Excon::Response] | ||
# * body<~String> - | ||
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-VAppTemplateOvfDescriptor.html | ||
# vCloud API Documentation | ||
# @since vCloud API version 0.9 | ||
def get_vapp_template_ovf_descriptor(id) | ||
request( | ||
:expects => 200, | ||
:idempotent => true, | ||
:method => 'GET', | ||
:path => "vAppTemplate/#{id}/ovf" | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
44 changes: 44 additions & 0 deletions
44
tests/vcloud_director/requests/compute/ovf_descriptor_tests.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Shindo.tests('Compute::VcloudDirector | ovf requests', ['vclouddirector']) do | ||
|
||
@service = Fog::Compute::VcloudDirector.new | ||
|
||
tests('Get current organization') do | ||
session = @service.get_current_session.body | ||
link = session[:Link].detect do |l| | ||
l[:type] == 'application/vnd.vmware.vcloud.org+xml' | ||
end | ||
@org = @service.get_organization(link[:href].split('/').last).body | ||
end | ||
|
||
tests('Get first vDC') do | ||
session = @service.get_current_session.body | ||
link = @org[:Link].detect do |l| | ||
l[:type] == 'application/vnd.vmware.vcloud.vdc+xml' | ||
end | ||
@vdc = @service.get_vdc(link[:href].split('/').last).body | ||
@vdc[:ResourceEntities][:ResourceEntity] = [@vdc[:ResourceEntities][:ResourceEntity]] if @vdc[:ResourceEntities][:ResourceEntity].is_a?(Hash) | ||
end | ||
|
||
# 'Envelope' is the outer type of the parsed XML document. | ||
tests('#get_vapp_ovf_descriptor').returns('Envelope') do | ||
pending if Fog.mocking? | ||
link = @vdc[:ResourceEntities][:ResourceEntity].detect do |l| | ||
l[:type] == 'application/vnd.vmware.vcloud.vApp+xml' | ||
end | ||
pending if link.nil? | ||
body = @service.get_vapp_ovf_descriptor(link[:href].split('/').last).body | ||
Nokogiri::XML::Document.parse(body).children.first.name | ||
end | ||
|
||
# 'Envelope' is the outer type of the parsed XML document. | ||
tests('#get_vapp_template_ovf_descriptor').returns('Envelope') do | ||
pending if Fog.mocking? | ||
link = @vdc[:ResourceEntities][:ResourceEntity].detect do |l| | ||
l[:type] == 'application/vnd.vmware.vcloud.vAppTemplate+xml' | ||
end | ||
pending if link.nil? | ||
body = @service.get_vapp_template_ovf_descriptor(link[:href].split('/').last).body | ||
Nokogiri::XML::Document.parse(body).children.first.name | ||
end | ||
|
||
end |