Sha256: 875293003e4daf81ed5b0c99bfe6970b97faa35ea7c41ad30f7f7f50b6a823e4

Contents?: true

Size: 1.31 KB

Versions: 43

Compression:

Stored size: 1.31 KB

Contents

module Fog
  module Vcloud
    class Compute
      class Real
        def validate_clone_vapp_options(options)
          valid_opts = [:name, :poweron]
          unless valid_opts.all? { |opt| options.key?(opt) }
            raise ArgumentError.new("Required data missing: #{(valid_opts - options.keys).map(&:inspect).join(", ")}")
          end
        end

        def generate_clone_vapp_request(uri, options)
          xml = Builder::XmlMarkup.new
          xml.CloneVAppParams(xmlns.merge!(:name => options[:name], :deploy => "true", :powerOn => options[:poweron])) {
            xml.VApp( :href => uri, :type => "application/vnd.vmware.vcloud.vApp+xml",
                      :xmlns => "http://www.vmware.com/vcloud/v0.8")
          }
        end

        def clone_vapp(vdc_uri, vapp_uri, options = {})
          unless options.key?(:poweron)
            options[:poweron] = "false"
          end

          validate_clone_vapp_options(options)

          request(
            :body     => generate_clone_vapp_request(vapp_uri, options),
            :expects  => 202,
            :headers  => {'Content-Type' => 'application/vnd.vmware.vcloud.cloneVAppParams+xml'},
            :method   => 'POST',
            :uri      => vdc_uri + '/action/clonevapp',
            :parse    => true
          )
        end
      end
    end
  end
end

Version data entries

43 entries across 41 versions & 6 rubygems

Version Path
fog-1.33.0 lib/fog/vcloud/requests/compute/clone_vapp.rb
fog-1.32.0 lib/fog/vcloud/requests/compute/clone_vapp.rb
fog-1.31.0 lib/fog/vcloud/requests/compute/clone_vapp.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/vcloud/requests/compute/clone_vapp.rb
fog-1.30.0 lib/fog/vcloud/requests/compute/clone_vapp.rb
fog-1.29.0 lib/fog/vcloud/requests/compute/clone_vapp.rb
fog-1.28.0 lib/fog/vcloud/requests/compute/clone_vapp.rb
fog-1.27.0 lib/fog/vcloud/requests/compute/clone_vapp.rb
fog-1.26.0 lib/fog/vcloud/requests/compute/clone_vapp.rb
fog-1.25.0 lib/fog/vcloud/requests/compute/clone_vapp.rb
nsidc-fog-1.24.1 lib/fog/vcloud/requests/compute/clone_vapp.rb
fog-1.24.0 lib/fog/vcloud/requests/compute/clone_vapp.rb
ns-fog-1.22.11 lib/fog/vcloud/requests/compute/clone_vapp.rb
ns-fog-1.22.10 lib/fog/vcloud/requests/compute/clone_vapp.rb
ns-fog-1.22.9 lib/fog/vcloud/requests/compute/clone_vapp.rb
ns-fog-1.22.8 lib/fog/vcloud/requests/compute/clone_vapp.rb
ns-fog-1.22.7 lib/fog/vcloud/requests/compute/clone_vapp.rb
ns-fog-1.22.6 lib/fog/vcloud/requests/compute/clone_vapp.rb
fog-1.23.0 lib/fog/vcloud/requests/compute/clone_vapp.rb
ns-fog-1.22.4 lib/fog/vcloud/requests/compute/clone_vapp.rb