lib/vcloud-rest/vcloud/vapp.rb
def create_vapp_from_template(vdc, vapp_name, vapp_description, vapp_templateid, poweron=false)
      builder = Nokogiri::XML::Builder.new do |xml|
      xml.InstantiateVAppTemplateParams(
        "xmlns" => "http://www.vmware.com/vcloud/v1.5",
        "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
        "xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1",
        "name" => vapp_name,
        "deploy" => "true",
        "powerOn" => poweron) {
        xml.Description vapp_description
        xml.Source("href" => "#{@api_url}/vAppTemplate/#{vapp_templateid}")
      }
      end

      params = {
        "method" => :post,
        "command" => "/vdc/#{vdc}/action/instantiateVAppTemplate"
      }

      response, headers = send_request(params, builder.to_xml, "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")

      vapp_id = headers[:location].gsub(/.*\/vApp\/vapp\-/, "")
      task = response.css("VApp Task[operationName='vdcInstantiateVapp']").first
      task_id = task["href"].gsub(/.*\/task\//, "")

      { :vapp_id => vapp_id, :task_id => task_id }
    end
def create_vapp_from_template(vdc, vapp_name, vapp_description, vapp_templateid, poweron=false)
      builder = Nokogiri::XML::Builder.new do |xml|
      xml.InstantiateVAppTemplateParams(
        "xmlns" => "http://www.vmware.com/vcloud/v1.5",
        "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
        "xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1",
        "name" => vapp_name,
        "deploy" => "true",
        "powerOn" => poweron) {
        xml.Description vapp_description
        xml.Source("href" => "#{@api_url}/vAppTemplate/#{vapp_templateid}")
      }
      end

      params = {
        "method" => :post,
        "command" => "/vdc/#{vdc}/action/instantiateVAppTemplate"
      }

      response, headers = send_request(params, builder.to_xml, "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")

      vapp_id = headers[:location].gsub(/.*\/vApp\/vapp\-/, "")
      task = response.css("VApp Task[operationName='vdcInstantiateVapp']").first
      task_id = task["href"].gsub(/.*\/task\//, "")

      { :vapp_id => vapp_id, :task_id => task_id }
    end
def create_vapp_from_template ( vdc , vapp_name , vapp_description , vapp_templateid , poweron = false ) builder = Nokogiri :: XML :: Builder . new do | xml | xml . InstantiateVAppTemplateParams ( "xmlns" => "http://www.vmware.com/vcloud/v1.5" , "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance" , "xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1" , "name" => vapp_name , "deploy" => "true" , "powerOn" => poweron ) { xml . Description vapp_description xml . Source ( "href" => "#{@api_url}/vAppTemplate/#{vapp_templateid}" ) } end params = { "method" => :post , "command" => "/vdc/#{vdc}/action/instantiateVAppTemplate" } response , headers = send_request ( params , builder . to_xml , "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml" ) vapp_id = headers [ :location ] . gsub ( / \/ \/ \- / , "" ) task = response . css ( "VApp Task[operationName='vdcInstantiateVapp']" ) . first task_id = task [ "href" ] . gsub ( / \/ \/ / , "" ) { :vapp_id => vapp_id , :task_id => task_id } end
Create a vapp starting from a template

 Params:
 - vdc: the associated VDC
 - vapp_name: name of the target vapp
 - vapp_description: description of the target vapp
 - vapp_templateid: ID of the vapp template
Create a vapp starting from a template