Skip to content
This repository was archived by the owner on Nov 9, 2020. It is now read-only.

Add network config and additional logging for requests #49

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/vcloud-rest/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def send_request(params, payload=nil, content_type=nil)

handled_request(req_params) do
request = RestClient::Request.new(req_params)
@logger.debug "Request #{request.inspect}"

response = request.execute
if ![200, 201, 202, 204].include?(response.code)
Expand Down
17 changes: 16 additions & 1 deletion lib/vcloud-rest/vcloud/vapp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def poweron_vapp(vAppId)
# - vapp_name: name of the target vapp
# - vapp_description: description of the target vapp
# - vapp_templateid: ID of the vapp template
def create_vapp_from_template(vdc, vapp_name, vapp_description, vapp_templateid, poweron=false)
def create_vapp_from_template(vdc, vapp_name, vapp_description, vapp_templateid, poweron=false,network_config={})
builder = Nokogiri::XML::Builder.new do |xml|
xml.InstantiateVAppTemplateParams(
"xmlns" => "http://www.vmware.com/vcloud/v1.5",
Expand All @@ -214,6 +214,21 @@ def create_vapp_from_template(vdc, vapp_name, vapp_description, vapp_templateid,
"deploy" => "true",
"powerOn" => poweron) {
xml.Description vapp_description
if network_config[:name]
xml.InstantiationParams do
xml.NetworkConfigSection do
xml['ovf'].Info 'Configuration parameters for logical networks'
xml.NetworkConfig('networkName' => network_config[:name]) do
if network_config[:parent_network]
xml.Configuration do
xml.ParentNetwork('href' => "#{@api_url}/network/#{network_config[:parent_network]}")
xml.FenceMode network_config[:fence_mode]
end
end
end
end
end
end
xml.Source("href" => "#{@api_url}/vAppTemplate/#{vapp_templateid}")
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vcloud-rest/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module VCloudClient
VERSION = "1.4.0"
VERSION = "1.5"
end