Sha256: f5ce6a742b2aa97a3d78e644c1f2b8b23422ca93202c381acc4f011251df263b

Contents?: true

Size: 1.32 KB

Versions: 12

Compression:

Stored size: 1.32 KB

Contents

module Fog
  module Compute
    class Ecloud
      class Real

        def validate_clone_vapp_options(options)
          valid_opts = [:name, :poweron]
          unless valid_opts.all? { |opt| options.has_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.has_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

12 entries across 12 versions & 5 rubygems

Version Path
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/requests/compute/clone_vapp.rb
michiels-fog-1.3.1 lib/fog/ecloud/requests/compute/clone_vapp.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/ecloud/requests/compute/clone_vapp.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/requests/compute/clone_vapp.rb
fog-1.3.1 lib/fog/ecloud/requests/compute/clone_vapp.rb
fog-1.3.0 lib/fog/ecloud/requests/compute/clone_vapp.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/requests/compute/clone_vapp.rb
fog-1.2.0 lib/fog/ecloud/requests/compute/clone_vapp.rb
ktheory-fog-1.1.2 lib/fog/ecloud/requests/compute/clone_vapp.rb
brightbox-cli-0.17.4 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/requests/compute/clone_vapp.rb
brightbox-cli-0.17.3 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/requests/compute/clone_vapp.rb
brightbox-cli-0.17.2 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/requests/compute/clone_vapp.rb