lib/vcloud-rest/vcloud/vapp.rb
def clone_vapp(vdc_id, source_vapp_id, name, deploy="true", poweron="false", linked="false", delete_source="false")
      params = {
          "method" => :post,
          "command" => "/vdc/#{vdc_id}/action/cloneVApp"
      }
      builder = Nokogiri::XML::Builder.new do |xml|
        xml.CloneVAppParams(
            "xmlns" => "http://www.vmware.com/vcloud/v1.5",
            "name" => name,
            "deploy"=>  deploy,
            "linkedClone"=> linked,
            "powerOn"=> poweron
        ) {
          xml.Source "href" => "#{@api_url}/vApp/vapp-#{source_vapp_id}"
          xml.IsSourceDelete delete_source
        }
      end
      response, headers = send_request(params, builder.to_xml, "application/vnd.vmware.vcloud.cloneVAppParams+xml")

      vapp_id = headers[:location].gsub(/.*\/vApp\/vapp\-/, "")

      task = response.css("VApp Task[operationName='vdcCopyVapp']").first
      task_id = task["href"].gsub(/.*\/task\//, "")

      {:vapp_id => vapp_id, :task_id => task_id}
    end
def clone_vapp(vdc_id, source_vapp_id, name, deploy="true", poweron="false", linked="false", delete_source="false")
      params = {
          "method" => :post,
          "command" => "/vdc/#{vdc_id}/action/cloneVApp"
      }
      builder = Nokogiri::XML::Builder.new do |xml|
        xml.CloneVAppParams(
            "xmlns" => "http://www.vmware.com/vcloud/v1.5",
            "name" => name,
            "deploy"=>  deploy,
            "linkedClone"=> linked,
            "powerOn"=> poweron
        ) {
          xml.Source "href" => "#{@api_url}/vApp/vapp-#{source_vapp_id}"
          xml.IsSourceDelete delete_source
        }
      end
      response, headers = send_request(params, builder.to_xml, "application/vnd.vmware.vcloud.cloneVAppParams+xml")

      vapp_id = headers[:location].gsub(/.*\/vApp\/vapp\-/, "")

      task = response.css("VApp Task[operationName='vdcCopyVapp']").first
      task_id = task["href"].gsub(/.*\/task\//, "")

      {:vapp_id => vapp_id, :task_id => task_id}
    end
def clone_vapp ( vdc_id , source_vapp_id , name , deploy = "true" , poweron = "false" , linked = "false" , delete_source = "false" ) params = { "method" => :post , "command" => "/vdc/#{vdc_id}/action/cloneVApp" } builder = Nokogiri :: XML :: Builder . new do | xml | xml . CloneVAppParams ( "xmlns" => "http://www.vmware.com/vcloud/v1.5" , "name" => name , "deploy" => deploy , "linkedClone" => linked , "powerOn" => poweron ) { xml . Source "href" => "#{@api_url}/vApp/vapp-#{source_vapp_id}" xml . IsSourceDelete delete_source } end response , headers = send_request ( params , builder . to_xml , "application/vnd.vmware.vcloud.cloneVAppParams+xml" ) vapp_id = headers [ :location ] . gsub ( / \/ \/ \- / , "" ) task = response . css ( "VApp Task[operationName='vdcCopyVapp']" ) . first task_id = task [ "href" ] . gsub ( / \/ \/ / , "" ) { :vapp_id => vapp_id , :task_id => task_id } end
Clone a vapp in a given VDC to a new Vapp
Clone a vapp in a given VDC to a new Vapp