class Fog::Compute::VcloudDirector::Mock

Attributes

api_version[R]
end_point[R]

Public Class Methods

new(options={}) click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 791
def initialize(options={})
  @vcloud_director_password = options[:vcloud_director_password]
  @vcloud_director_username = options[:vcloud_director_username]
  #@connection_options = options[:connection_options] || {}
  @host = options[:vcloud_director_host]
  @path = options[:path] || Fog::Compute::VcloudDirector::Defaults::PATH
  @persistent = options[:persistent] || false
  @port = options[:port] || Fog::Compute::VcloudDirector::Defaults::PORT
  @scheme = options[:scheme] || Fog::Compute::VcloudDirector::Defaults::SCHEME
  #@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
  @end_point    = "#{@scheme}://#{@host}#{@path}/"
  @api_version  = options[:vcloud_director_api_version] || Fog::Compute::VcloudDirector::Defaults::API_VERSION
  @vcloud_token = options[:vcloud_token]
end

Public Instance Methods

add_id_from_href!(data={}) click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 893
def add_id_from_href!(data={})
  data[:id] = data[:href].split('/').last
end
data() click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 527
def data
  @@data ||= Hash.new do |hash, key|

    vdc1_uuid = uuid
    vdc2_uuid = uuid
    uplink_network_uuid  = uuid
    isolated_vdc1_network_uuid = uuid
    isolated_vdc2_network_uuid = uuid
    vapp1_id = "vapp-#{uuid}"
    vapp2_id = "vapp-#{uuid}"
    vapp1vm1_id = "vm-#{uuid}"
    vapp2vm1_id = "vm-#{uuid}"
    vapp2vm2_id = "vm-#{uuid}"
    catalog_uuid = uuid
    template_uuid = uuid

    hash[key] = {
      :catalogs => {
        catalog_uuid => {
          :name => 'Default Catalog'
        }
      },
      :catalog_items => {
        uuid => {
          :type    => 'vAppTemplate',
          :name    => 'vAppTemplate 1',
          :catalog => catalog_uuid,
          :template_id => template_uuid
        }
      },
      :disks => {
        uuid => {
          :name => 'Hard Disk 1',
          :capacity => 10240,
          :parent_vm => vapp1vm1_id
        }
      },
      :edge_gateways => {
        uuid => {
          :name => 'MockEdgeGateway',
          :networks => [uplink_network_uuid, default_network_uuid],
          :vdc => vdc1_uuid,
          :Configuration => {
            :GatewayBackingConfig => "compact",
            :GatewayInterfaces => {
              :GatewayInterface => []},
            :EdgeGatewayServiceConfiguration => {
              :FirewallService => {
                :IsEnabled => "true",
                :DefaultAction => "drop",
                :LogDefaultAction => "false",
                :FirewallRule => []
              },
              :NatService => {:IsEnabled => "true"}},
            :HaEnabled => "false",
            :UseDefaultRouteForDnsRelay => "false"
          }
        }
      },

      :medias => {},

      :networks => {

        default_network_uuid => {
          :IsShared => true,
          :vdc => vdc1_uuid,
          :FenceMode => 'natRouted',
          :ApplyRateLimit => "false",
          :Description => 'Org Network for mocking',
          :Dns1 => '8.8.8.8',
          :Dns2 => '8.8.4.4',
          :DnsSuffix => 'example.com',
          :Gateway => '192.168.1.1',
          :InterfaceType => "internal",
          :IpRanges => [{
            :StartAddress=>'192.168.1.2',
            :EndAddress=>'192.168.1.254'
          }],
          :IsInherited => false,
          :Netmask => '255.255.255.0',
          :name => 'vDC1 Default Network',
          :SubnetParticipation => {
              :Gateway => "192.168.1.0",
              :Netmask => "255.255.0.0",
              :IpAddress => "192.168.1.0"
          },
          :UseForDefaultRoute => "false"
        },

        isolated_vdc1_network_uuid => {
          :IsShared => false,
          :vdc => vdc1_uuid,
          :ApplyRateLimit => "false",
          :FenceMode => 'isolated',
          :Description => 'Org Network for mocking',
          :Dns1 => '8.8.8.8',
          :Dns2 => '8.8.4.4',
          :DnsSuffix => 'example.com',
          :InterfaceType => "internal",
          :IpRanges => [{
            :StartAddress=>'10.1.0.100',
            :EndAddress=>'10.1.0.200'
          }],
          :IsInherited => false,
          :Netmask => '255.255.255.0',
          :name => 'vDC1 backend network',
          :SubnetParticipation => {
              :Gateway => "192.168.1.0",
              :Netmask => "255.255.0.0",
              :IpAddress => "192.168.1.0"
          },
          :UseForDefaultRoute => "false"
        },

        isolated_vdc2_network_uuid => {
          :IsShared => false,
          :vdc => vdc2_uuid,
          :ApplyRateLimit => "false",
          :Description => 'Org Network for mocking',
          :Dns1 => '8.8.8.8',
          :Dns2 => '8.8.4.4',
          :DnsSuffix => 'example.com',
          :InterfaceType => "internal",
          :IpRanges => [{
            :StartAddress=>'10.2.0.100',
            :EndAddress=>'10.2.0.200'
          }],
          :IsInherited => false,
          :Netmask => '255.255.255.0',
          :name => 'vDC2 backend network',
          :SubnetParticipation => {
              :Gateway => "192.168.1.0",
              :Netmask => "255.255.0.0",
              :IpAddress => "192.168.1.0"
          },
          :UseForDefaultRoute => "false"
        },

        uplink_network_uuid => {
          :IsShared => false,
          :vdc => vdc1_uuid,
          :ApplyRateLimit => "false",
          :FenceMode => 'bridged',
          :Description => 'Uplink Network for mocking',
          :Dns1 => '8.8.8.8',
          :Dns2 => '8.8.4.4',
          :DnsSuffix => 'example.com',
          :Gateway => '198.51.100.1',
          :InterfaceType => "uplink",
          :IpRanges => [{
            :StartAddress=>'198.51.100.2',
            :EndAddress=>'198.51.100.254'
          }],
          :IsInherited => false,
          :Netmask => '255.255.255.0',
          :name => 'uplink Network',
          :SubnetParticipation => {
            :Gateway => "198.51.100.81",
            :Netmask => "255.255.255.248",
            :IpAddress => "198.51.100.83",
            :IpRanges => {
              :IpRange => {
                :StartAddress => "198.51.100.84",
                :EndAddress => "198.51.100.86"
              }
            }
          },
          :UseForDefaultRoute => "true"
        }

      },
      :org => {
        :description => 'Organization for mocking',
        :full_name => 'Mock Organization',
        :name => org_name,
        :uuid => uuid
      },

      :tags => {},

      :tasks => {},

      :vapps => {
        vapp1_id => {
          :name => 'mock-vapp-1',
          :vdc_id => vdc1_uuid,
          :description => "Mock vApp 1",
          :networks => [
            { :parent_id => default_network_uuid, },
          ],
        },
        vapp2_id => {
          :name => 'mock-vapp-2',
          :vdc_id => vdc2_uuid,
          :description => "Mock vApp 2",
          :networks => [
            { :parent_id => default_network_uuid },
          ]
        },
      },

      :vdc_storage_classes => {
        uuid => {
          :default => true,
          :enabled => true,
          :limit => 2 * 1024 * 1024,
          :name => 'DefaultMockStorageClass',
          :units => 'MB',
          :vdc => vdc1_uuid,
        }
      },

      :vdcs => {
        vdc1_uuid => {
          :description => 'vDC1 for mocking',
          :name => 'MockVDC 1'
        },
        vdc2_uuid => {
          :description => 'vDC2 for mocking',
          :name => 'MockVDC 2'
        },
      },

      :vms => {
        vapp1vm1_id => {
          :name => 'mock-vm-1-1',
          :parent_vapp => vapp1_id,
          :nics => [
            {
              :network_name => 'Default Network',
              :mac_address => "00:50:56:aa:bb:01",
              :ip_address => "192.168.1.33",
            },
          ],
        },
        vapp2vm1_id => {
          :name => 'mock-vm-2-1',
          :parent_vapp => vapp2_id,
          :nics => [
            {
              :network_name => 'Default Network',
              :mac_address => "00:50:56:aa:bb:02",
              :ip_address => "192.168.1.34",
            },
          ],
        },
        vapp2vm2_id => {
          :name => 'mock-vm-2-2',
          :parent_vapp => vapp2_id,
          :nics => [
            {
              :network_name => 'Default Network',
              :mac_address => "00:50:56:aa:bb:03",
              :ip_address => "192.168.1.35",
            },
          ],
        },
      },

    }
  end[@vcloud_director_username]
end
default_network_uuid() click to toggle source

This is used in some mocks so it's a method rather than a variable

# File lib/fog/vcloud_director/compute.rb, line 523
def default_network_uuid
  @default_network_uuid ||= uuid
end
delete_disk(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/delete_disk.rb, line 27
def delete_disk(id)
  unless data[:disks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.disk:#{id})\""
    )
  end

  owner = {
    :href => make_href("disk/#{id}"),
    :type => 'application/vnd.vmware.vcloud.disk+xml'
  }
  task_id = enqueue_task(
    "Deleting Disk(#{id})", 'vdcDeleteDisk', owner,
    :on_success => lambda do
      data[:disks].delete(id)
    end
  )

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
delete_media(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/delete_media.rb, line 90
def delete_media(id)
  unless media = data[:medias][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.media:#{id})\""
    )
  end

  owner = {
    :href => make_href("media/#{id}"),
    :type => 'application/vnd.vmware.vcloud.media+xml'
  }
  task_id = enqueue_task(
    "Deleting Media File(#{media[:file][:uuid]})", 'vdcDeleteMedia', owner,
    :on_success => lambda do
      data[:medias].delete(id)
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
delete_network(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/delete_network.rb, line 29
def delete_network(id)
  unless data[:networks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.orgVdcNetwork:#{id})\""
    )
  end

  owner = {
    :href => make_href("network/#{id}"),
    :type => 'application/vnd.vmware.vcloud.network+xml'
  }
  task_id = enqueue_task(
    "Deleting Network(#{id})", 'DeleteNetwork', owner,
    :on_success => lambda do
      data[:networks].delete(id)
    end
  )

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
delete_vapp(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/delete_vapp.rb, line 28
def delete_vapp(id)
  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end
  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vApp+xml'
  }
  task_id = enqueue_task(
    "Deleting Virtual Application (#{id})", 'vdcDeleteVapp', owner,
    :on_success => lambda do
      data[:vapps].delete(id)
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
enqueue_task(operation, operation_name, owner, options={}) click to toggle source

Create a task.

@param [String] operation A message describing the operation that is

tracked by this task.

@param [String] operation_name The short name of the operation that

is tracked by this task.

@param [Hash] owner Reference to the owner of the task. This is

typically the object that the task is creating or updating.
* :href<~String> - Contains the URI to the entity.
* :type<~String> - Contains the MIME type of the entity.

@return [String] Object identifier of the task.

# File lib/fog/vcloud_director/compute.rb, line 846
def enqueue_task(operation, operation_name, owner, options={})
  task_id = uuid
  now = DateTime.now

  data[:tasks][task_id] = {
    :cancel_requested => false,
    :details => '',
    :expiry_time => now + 86400, # in 24 hours
    :name => 'task',
    :progress => 1,
    :service_namespace => 'com.vmware.vcloud',
    :start_time => now,
    :end_time => now + 86400,
    :status => 'running',
  }.merge(options).merge(
    :operation => operation,
    :operation_name => operation_name,
    :owner => owner
  )

  task_id
end
get_catalog(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_catalog.rb, line 29
def get_catalog(id)
  unless catalog = data[:catalogs][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.catalog:#{id})\"."
    )
  end
  
  items = data[:catalog_items].select {|_,v| v[:catalog] == id}
  
  body = {
    :href => make_href("catalog/#{id}"),
    :type => 'application/vnd.vmware.vcloud.catalog+xml',
    :id   => id,
    :name => catalog[:name],
    :CatalogItems => {
      :CatalogItem => items.map do |uuid,item|
        {
          :href => make_href("catalogItem/#{uuid}"),
          :id   => uuid,
          :name => item[:name],
          :type => 'application/vnd.vmware.vcloud.catalogItem+xml'
        }
      end
    },
  }
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_catalog_item(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_catalog_item.rb, line 24
def get_catalog_item(id)
  unless item = data[:catalog_items][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.catalogItem:#{id})\"."
    )
  end
  body = {
    :href => make_href("catalogItem/#{id}"),
    :id   => id,
    :name => item[:name],
    :type => 'application/vnd.vmware.vcloud.catalogItem+xml',
    :Entity => {
      :href => make_href("vAppTemplate/#{item[:template_id]}")              
    }
  }
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_cpu_rasd_item(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_cpu_rasd_item.rb, line 30
def get_cpu_rasd_item(id)
  type = 'application/vnd.vmware.vcloud.rasdItem+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_cpu_rasd_item_body(id, vm)
  )
end
get_cpu_rasd_item_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_cpu_rasd_item.rb, line 46
def get_cpu_rasd_item_body(id, vm)
  {
    :ns12_href => make_href("vApp/#{id}/virtualHardwareSection/cpu"),
    :ns12_type => "application/vnd.vmware.vcloud.rasdItem+xml",
    :"rasd:AllocationUnits"=>"hertz * 10^6",
    :"rasd:Description"=>"Number of Virtual CPUs",
    :"rasd:ElementName"=>"#{vm[:cpu_count]} virtual CPU(s)",
    :"rasd:InstanceID"=>"4",
    :"rasd:Reservation"=>"0",
    :"rasd:ResourceType"=>"3",
    :"rasd:VirtualQuantity"=>"#{vm[:cpu_count]}",
    :"rasd:Weight"=>"0",
  }
end
get_current_session() click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_current_session.rb, line 42
def get_current_session
  body =
    {:href => make_href('session/'),
     :type => 'application/vnd.vmware.vcloud.session+xml',
     :org => data[:org][:name],
     :user => user_name,
     :Link =>
      [{:href => make_href('org/'),
        :type => 'application/vnd.vmware.vcloud.orgList+xml',
        :rel => 'down'},
       {:href => make_href('admin/'),
        :type => 'application/vnd.vmware.admin.vcloud+xml',
        :rel => 'down'},
       {:href => make_href("org/#{data[:org][:uuid]}"),
        :name => data[:org][:name],
        :type => 'application/vnd.vmware.vcloud.org+xml',
        :rel => 'down'},
       {:href => make_href('query'),
        :type => 'application/vnd.vmware.vcloud.query.queryList+xml',
        :rel => 'down'},
       {:href => make_href('entity/'),
        :type => 'application/vnd.vmware.vcloud.entity+xml',
        :rel => 'entityResolver'}]}

  if @api_version.to_f >= 5.1
    body[:Link] << {
      :href => make_href('extensibility'),
      :type => 'application/vnd.vmware.vcloud.apiextensibility+xml',
      :rel => 'down:extensibility'
    }
  end

  Excon::Response.new(
    :body => body,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :status => 200
  )
end
get_disk(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_disk.rb, line 44
def get_disk(id)
  unless data[:disks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No access to entity "com.vmware.vcloud.entity.disk:%s".' % id
    )
  end

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location
  }.merge(disk_body(id))

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{@version}"},
    :body => body
  )
end
get_disk_owner(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_disk_owner.rb, line 38
def get_disk_owner(id)
  unless data[:disks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No access to entity "com.vmware.vcloud.entity.disk:%s".' % id
    )
  end

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
    :Link => {
      :href => make_href("disk/#{id}"),
      :type => 'application/vnd.vmware.vcloud.disk+xml',
      :rel => 'up'
    },
    :User => {
      :href => make_href("admin/user/#{user_uuid}"),
      :name => user_name,
      :type => 'application/vnd.vmware.admin.user+xml',
    }
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{@version}"},
    :body => body
  )
end
get_disks(vapp) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_template_vm.rb, line 65
def get_disks(vapp)
  hardware = vapp[:"ovf:VirtualHardwareSection"][:"ovf:Item"]
  disks = hardware.select {|h| h[:"rasd:ResourceType"].to_i == 17}
  disks.map {|d| {d[:"rasd:ElementName"] => d[:"rasd:HostResource"][:ns12_capacity].to_i}}
end
get_disks_rasd_items_list(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_disks_rasd_items_list.rb, line 27
def get_disks_rasd_items_list(id)
  type = 'application/vnd.vmware.vcloud.rasdItemsList+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :type => type,
    :href => make_href("vApp/#{id}/virtualHardwareSection/disks"),
    :Link => {
      :rel=>"edit",
      :type=>"application/vnd.vmware.vcloud.rasdItemsList+xml",
      :href=>make_href("vApp/#{id}/virtualHardwareSection/disks"),
    },
    :Item => [
      get_disks_rasd_items_list_body(id, vm),
      get_media_rasd_item_ide_controller_body(id, vm),
    ].flatten
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => body
  )
end
get_disks_rasd_items_list_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_disks_rasd_items_list.rb, line 57
def get_disks_rasd_items_list_body(id, vm)
  [
    {
      :"rasd:Address"=>"0",
      :"rasd:Description"=>"SCSI Controller",
      :"rasd:ElementName"=>"SCSI Controller 0",
      :"rasd:InstanceID"=>"2",
      :"rasd:ResourceSubType"=>"lsilogic",
      :"rasd:ResourceType"=>"6"
    },

    # TODO: Add support for adding disks
    {
      :"rasd:AddressOnParent"=>"0",
      :"rasd:Description"=>"Hard disk",
      :"rasd:ElementName"=>"Hard disk 1",
      :"rasd:HostResource"=>{
        :ns12_capacity=>"51200",
        :ns12_busSubType=>"lsilogic",
        :ns12_busType=>"6"
      },
      :"rasd:InstanceID"=>"2000",
      :"rasd:Parent"=>"2",
      :"rasd:ResourceType"=>"17"
    },

  ]
end
get_edge_gateway(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb, line 54
def get_edge_gateway(id)
  unless edge_gateway = data[:edge_gateways][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.gateway:#{id})\""
    )
  end

  vdc_id = edge_gateway[:vdc]
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :status => "1",
    :name => edge_gateway[:name],
    :id => "urn:vcloud:gateway:#{id}",
    :type => "application/vnd.vmware.admin.edgeGateway+xml",
    :href => make_href("admin/edgeGateway/#{id}"),
    :xsi_schemaLocation => xsi_schema_location,
    :Link =>[{:rel => "up",
              :type => "application/vnd.vmware.vcloud.vdc+xml",
              :href => make_href("vdc/#{vdc_id}")},
             {:rel => "edgeGateway:redeploy",
              :href => make_href("admin/edgeGateway/#{id}/action/redeploy")},
             {:rel => "edgeGateway:configureServices",
              :type => "application/vnd.vmware.admin.edgeGatewayServiceConfiguration+xml",
              :href => make_href("admin/edgeGateway/#{id}/action/configureServices")},
             {:rel => "edgeGateway:reapplyServices",
              :href => make_href("admin/edgeGateway/#{id}/action/reapplyServices")},
             {:rel => "edgeGateway:syncSyslogSettings",
              :href => make_href("admin/edgeGateway/#{id}/action/syncSyslogServerSettings")}],
    :Description => "vCloud CI (nft00052i2)",
    :Configuration => edge_gateway[:Configuration].dup
  }

  body[:Configuration][:GatewayInterfaces][:GatewayInterface] += edge_gateway[:networks].map do |network|
    extras = {
      :Network => {
        :type => "application/vnd.vmware.admin.network+xml",
        :name => "anything",
        :href => make_href("admin/network/#{network}")
      },
      :Name => data[:networks][network][:name],
      :DisplayName => data[:networks][network][:name]
    }
    data[:networks][network].merge extras
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_execute_query(type=nil, options={}) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_execute_query.rb, line 123
def get_execute_query(type=nil, options={})
  unless options[:fields].nil?
    Fog::Mock.not_implemented("Fields are not yet implemented in get_execute_query Mock for #{type}")
  end

  unless options[:format].nil? || options[:format] == 'records'
    Fog::Mock.not_implemented("Formats #{options[:format]} is not yet implemented in get_execute_query Mock for #{type}")
  end

  # NB: default is to sort by 'Database ID' (uuid?). Does this matter?
  unless options[:sortAsc].nil? && options[:sortDesc].nil?
    Fog::Mock.not_implemented("Sorting by field is not yet implemented in get_execute_query Mock for #{type}")
  end

  # NB: default offset is 0
  unless options[:offset].nil?
    Fog::Mock.not_implemented("Offset results are not yet implemented in get_execute_query Mock for #{type}")
  end

  # NB: default page is 1
  if options.key?(:page) && options[:page].to_i != 1
    Fog::Mock.not_implemented("Paginated results are not yet implemented in get_execute_query Mock for #{type}")
  end

  # NB: default pageSize is 25
  unless options[:pageSize].nil?
    Fog::Mock.not_implemented("Paginated results are not yet implemented in get_execute_query Mock for #{type}")
  end

  if type.nil?
    body = all_types
  else
    body = fetch_items(type, options)
  end

  Excon::Response.new(
    :status  => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body    => body
  )
end
get_guest_customization_system_section_vapp(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp.rb, line 25
def get_guest_customization_system_section_vapp(id)

  type = 'application/vnd.vmware.vcloud.guestCustomizationSection+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vm_guest_customization_section_body(id, vm)
  )
end
get_hardware(vapp, resource_type) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_template_vm.rb, line 55
def get_hardware(vapp, resource_type)
  hardware = vapp[:"ovf:VirtualHardwareSection"][:"ovf:Item"]
  item = hardware.find {|h| h[:"rasd:ResourceType"].to_i == resource_type}
  if item and item.key? :"rasd:VirtualQuantity"
    item[:"rasd:VirtualQuantity"].to_i
  else
    nil
  end
end
get_lease_settings_section_vapp(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp.rb, line 26
def get_lease_settings_section_vapp(id)

  type = 'application/vnd.vmware.vcloud.leaseSettingsSection+xml'

  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vapp_lease_settings_section_body(id)
  )

end
get_media(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_media.rb, line 29
def get_media(id)
  unless data[:medias][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.media:#{id})\"."
    )
  end

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location
  }.merge(media_body(id))

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=>#{@api_version}"},
    :body => body
  )
end
get_media_drives_rasd_items_list(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb, line 27
def get_media_drives_rasd_items_list(id)
  type = 'application/vnd.vmware.vcloud.rasdItemsList+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :type => type,
    :href => make_href("vApp/#{id}/virtualHardwareSection/media"),
    :Item => [
      get_media_rasd_item_ide_controller_body(id, vm),
      get_media_rasd_item_cdrom_body(id, vm),
      get_media_rasd_item_floppy_body(id, vm),
    ]
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => body
  )
end
get_media_owner(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_media_owner.rb, line 38
def get_media_owner(id)
  unless data[:medias][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No access to entity "com.vmware.vcloud.entity.media:%s".' % id
    )
  end

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
    :Link => {
      :href => make_href("media/#{id}"),
      :type => 'application/vnd.vmware.vcloud.media+xml',
      :rel => 'up'
    },
    :User => {
      :href => make_href("admin/user/#{user_uuid}"),
      :name => user_name,
      :type => 'application/vnd.vmware.admin.user+xml',
    }
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{@version}"},
    :body => body
  )
end
get_media_rasd_item_cdrom_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb, line 63
def get_media_rasd_item_cdrom_body(id, vm)
  {
    :"rasd:AddressOnParent"=>"1",
    :"rasd:AutomaticAllocation"=>"true",
    :"rasd:Description"=>"CD/DVD Drive",
    :"rasd:ElementName"=>"CD/DVD Drive 1",
    :"rasd:HostResource"=>"",
    :"rasd:InstanceID"=>"3000",
    :"rasd:Parent"=>"3",
    :"rasd:ResourceType"=>"15"
  }
end
get_media_rasd_item_floppy_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb, line 76
def get_media_rasd_item_floppy_body(id, vm)
  {
    :"rasd:AddressOnParent"=>"0",
    :"rasd:AutomaticAllocation"=>"false",
    :"rasd:Description"=>"Floppy Drive",
    :"rasd:ElementName"=>"Floppy Drive 1",
    :"rasd:HostResource"=>"",
    :"rasd:InstanceID"=>"8000",
    :"rasd:ResourceType"=>"14"
  }
end
get_media_rasd_item_ide_controller_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb, line 53
def get_media_rasd_item_ide_controller_body(id, vm)
  {
    :"rasd:Address"=>"0",
    :"rasd:Description"=>"IDE Controller",
    :"rasd:ElementName"=>"IDE Controller 0",
    :"rasd:InstanceID"=>"3",
    :"rasd:ResourceType"=>"5"
  }
end
get_memory_rasd_item(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_memory_rasd_item.rb, line 29
def get_memory_rasd_item(id)
  type = 'application/vnd.vmware.vcloud.rasdItem+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_memory_rasd_item_body(id, vm)
  )
end
get_memory_rasd_item_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_memory_rasd_item.rb, line 45
def get_memory_rasd_item_body(id, vm)
  {
    :ns12_href => make_href("vApp/#{id}/virtualHardwareSection/memory"),
    :ns12_type=>"application/vnd.vmware.vcloud.rasdItem+xml",
    :"rasd:AllocationUnits"=>"byte * 2^20",
    :"rasd:Description"=>"Memory Size",
    :"rasd:ElementName"=>"#{vm[:memory_in_mb]} MB of memory",
    :"rasd:InstanceID"=>"5",
    :"rasd:Reservation"=>"0",
    :"rasd:ResourceType"=>"4",
    :"rasd:VirtualQuantity"=>"#{vm[:memory_in_mb]}",
    :"rasd:Weight"=>"0",
  }
end
get_metadata(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_metadata.rb, line 29
def get_metadata(id)
  tags = data[:tags][id] || {}
  body = {:type => 'application/vnd.vmware.vcloud.metadata+xml', :metadata => tags}
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_mock_vapp_body(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp.rb, line 82
def get_mock_vapp_body(id)

  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :deployed => "true",
    :status => vapp[:status],
    :name => vapp[:name],
    :type => "application/vnd.vmware.vcloud.vApp+xml",
    :href => make_href("vApp/#{id}"),
    :LeaseSettingsSection => get_vapp_lease_settings_section_body(id),
    :"ovf:StartupSection" => get_vapp_ovf_startup_section_body(id, vapp),
    :"ovf:NetworkSection" => get_vapp_ovf_network_section_body(id, vapp),
    :NetworkConfigSection => get_vapp_network_config_section_body(id, vapp),
    :SnapshotSection      => get_snapshot_section_body(id),
    :DateCreated => vapp[:date_created], # eg "2014-03-16T10:52:31.874Z"
    :Owner => get_owner_section_body(id),
    :InMaintenanceMode => "false",
    :Children => {
      :Vm => get_vapp_children_vms_body(id)
    },
  }
  body
end
get_mock_vm_body(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp.rb, line 52
def get_mock_vm_body(id)
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :name => vm[:name],
    :href => make_href("vApp/#{id}"),
    :type => "application/application/vnd.vmware.vcloud.vm+xml",
    :status => vm[:status],
    :deployed => vm[:deployed],
    :needsCustomization => vm[:needs_customization],
    :Description => vm[:description],
    :"ovf:VirtualHardwareSection" => get_vm_virtual_hardware_section_body(id, vm),
    :"ovf:OperatingSystemSection" => get_vm_operating_system_section_body(id, vm),
    :NetworkConnectionSection     => get_vm_network_connection_section_body(id, vm),
    :GuestCustomizationSection    => get_vm_guest_customization_section_body(id, vm),
    :RuntimeInfoSection           => get_vm_runtime_info_section_body(id, vm),
    :SnapshotSection              => get_snapshot_section_body(id),
    :DateCreated       => vm[:date_created], # eg "2014-03-16T10:52:31.874Z"
    :VAppScopedLocalId => vm[:parent_vapp].split('-').last, # strip the vapp- prefix
    :"ovfenv:Environment" => get_vm_ovfenv_environment_section_body(id, vm),
    :VmCapabilities => get_vm_capabilities_section_body(id, vm),
    :StorageProfile => get_vm_storage_profile_section_body(id, vm),
  }
  body
end
get_network(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_network.rb, line 32
def get_network(id)
  Fog::Logger.deprecation("#{self} => #get_network is deprecated, use #get_network_complete instead [light_black](#{caller.first})[/]")
  unless network = data[:networks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body =
    {:name=>network[:name],
     :href=>make_href("network/#{id}"),
     :type=>"application/vnd.vmware.vcloud.orgNetwork+xml",
     :id=>id,
     :description=>nil,
     :is_inherited=>network[:IsInherited],
     :gateway=>network[:Gateway],
     :netmask=>network[:Netmask],
     :dns1=>network[:Dns1],
     :dns2=>network[:Dns2],
     :dns_suffix=>network[:DnsSuffix]}

  body[:ip_ranges] = network[:IpRanges].map do |ip_range|
    {:start_address=>ip_range[:StartAddress],
     :end_address=>ip_range[:EndAddress]}
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_network_cards_items_list(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_network_cards_items_list.rb, line 25
def get_network_cards_items_list(id)
  type = 'application/vnd.vmware.vcloud.rasdItemsList+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :type => type,
    :href => make_href("vApp/#{id}/virtualHardwareSection/networkCards"),
    :Link => {
      :rel=>"edit",
      :type=>"application/vnd.vmware.vcloud.rasdItemsList+xml",
      :href=>make_href("vApp/#{id}/virtualHardwareSection/networkCards"),
    },
    :Item => get_network_cards_rasd_items_list_body(id, vm)
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => body
  )

end
get_network_cards_rasd_items_list_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_network_cards_items_list.rb, line 53
def get_network_cards_rasd_items_list_body(id, vm)
  [{
    :"rasd:Address" => vm[:nics][0][:mac_address],
    :"rasd:AddressOnParent" => "0",
    :"rasd:AutomaticAllocation" => "true",
    :"rasd:Connection" => vm[:nics][0][:network_name],
    :"rasd:Description" => "E1000 ethernet adapter",
    :"rasd:ElementName" => "Network adapter 0",
    :"rasd:InstanceID" => "1",
    :"rasd:ResourceSubType" => "E1000",
    :"rasd:ResourceType" => "10"
  }]
end
get_network_complete(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_network_complete.rb, line 29
def get_network_complete(id)
  unless network = data[:networks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :name => network[:name],
    :href => make_href("network/#{id}"),
    :type => "application/vnd.vmware.vcloud.orgNetwork+xml",
    :id   => id,
    :Description => network[:Description],
    :Configuration => {
      :IpScopes => {
        :IpScope => {
          :IsInherited => network[:IsInherited].to_s,
          :Gateway     => network[:Gateway],
          :Netmask     => network[:Netmask],
          :Dns1        => network[:Dns1],
          :Dns2        => network[:Dns2],
          :DnsSuffix   => network[:DnsSuffix],
          :IsEnabled   => true.to_s,
          :IpRanges    => {
            :IpRange => [],
          },
        }
      },
      :FenceMode => network[:FenceMode],
      :RetainNetInfoAcrossDeployments => false.to_s,
    },
    :IsShared => network[:IsShared].to_s,
  }

  body[:Configuration][:IpScopes][:IpScope][:IpRanges][:IpRange] =
    network[:IpRanges].map do |ip_range|
      {:StartAddress => ip_range[:StartAddress],
       :EndAddress   => ip_range[:EndAddress]}
    end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_network_config_section_vapp(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp.rb, line 26
def get_network_config_section_vapp(id)

  type = 'application/vnd.vmware.vcloud.networkConfigSection+xml'

  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vapp_network_config_section_body(id, vapp)
  )

end
get_network_connection_system_section_vapp(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp.rb, line 26
def get_network_connection_system_section_vapp(id)
  type = 'application/vnd.vmware.vcloud.networkConnectionSection+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vm_network_connection_section_body(id, vm)
  )

end
get_operating_system_section(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_operating_system_section.rb, line 26
def get_operating_system_section(id)

  type = 'application/vnd.vmware.vcloud.operatingSystemSection+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vm_operating_system_section_body(id, vm)
  )

end
get_org_vdc_gateways(vdc_id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_org_vdc_gateways.rb, line 32
def get_org_vdc_gateways(vdc_id)
  unless data[:vdcs][vdc_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.vdc:#{vdc_id})\"."
    )
  end

  body =
    {:xmlns => xmlns,
     :xmlns_xsi => xmlns_xsi,
     :total => "1",
     :pageSize => "25",
     :page => "1",
     :name => "edgeGateways",
     :type => "application/vnd.vmware.vcloud.query.records+xml",
     :href => make_href("admin/vdc/#{vdc_id}edgeGateways?page=1&pageSize=25&format=records"),
     :xsi_schemaLocation => xsi_schema_location,
     :Link =>
      [{:rel => "alternate",
        :type => "application/vnd.vmware.vcloud.query.references+xml",
        :href => make_href("admin/vdc/#{vdc_id}edgeGateways?page=1&pageSize=25&format=references")},
       {:rel => "alternate",
        :type => "application/vnd.vmware.vcloud.query.idrecords+xml",
        :href => make_href("admin/vdc/#{vdc_id}edgeGateways?page=1&pageSize=25&format=records")}],
     :EdgeGatewayRecord => []}

  vdc_edge_gateways = data[:edge_gateways].select do |id, edge_gateway|
    edge_gateway[:vdc] == vdc_id
  end

  body[:EdgeGatewayRecord] += vdc_edge_gateways.map do |id, edge_gateway|
    {:vdc => make_href("vdc/#{vdc_id}"),
     :numberOfOrgNetworks => "1",
     :numberOfExtNetworks => "1",
     :name => edge_gateway[:name],
     :isBusy => "false",
     :haStatus => "DISABLED",
     :gatewayStatus => "READY",
     :href => make_href("admin/edgeGateway/#{id}"),
     :isSyslogServerSettingInSync => "true"}
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_organization(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_organization.rb, line 29
def get_organization(id)
  unless id == data[:org][:uuid]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"com.vmware.vcloud.entity.org:#{id}\""
    )
  end
  org = data[:org]

  body =
    {:href=>make_href("org/#{id}"),
     :type=>"application/vnd.vmware.vcloud.org+xml",
     :id=>"urn:vcloud:org:#{id}",
     :name=>org[:name],
     :Link=>
      [{:href=>make_href("tasksList/#{id}"),
        :type=>"application/vnd.vmware.vcloud.tasksList+xml",
        :rel=>"down"},
       {:href=>make_href("admin/org/#{id}/catalogs"),
        :type=>"application/vnd.vmware.admin.catalog+xml",
        :rel=>"add"},
       {:href=>make_href("org/#{id}/metadata"),
        :type=>"application/vnd.vmware.vcloud.metadata+xml",
        :rel=>"down"}],
     :Description=>org[:description]||'',
     :Tasks=>{:Task=>[]},
     :FullName=>org[:full_name]}

  body[:Link] += data[:catalogs].map do |catalog_id, catalog|
    [{:href=>make_href("catalog/#{catalog_id}"),
      :name=>catalog[:name],
      :type=>"application/vnd.vmware.vcloud.catalog+xml",
      :rel=>"down"},
     {:href=>make_href("org/#{id}/catalog/#{catalog_id}/controlAccess/"),
      :type=>"application/vnd.vmware.vcloud.controlAccess+xml",
      :rel=>"down"},
     {:href=>
       make_href("org/#{id}/catalog/#{catalog_id}/action/controlAccess"),
      :type=>"application/vnd.vmware.vcloud.controlAccess+xml",
      :rel=>"controlAccess"}]
  end.flatten

  body[:Link] += data[:networks].map do |network_id, network|
    {:href=>make_href("network/#{network_id}"),
     :name=>network[:name],
     :type=>"application/vnd.vmware.vcloud.orgNetwork+xml",
     :rel=>"down"}
  end

  body[:Link] += data[:vdcs].map do |vdc_id, vdc|
    {:href=>make_href("vdc/#{vdc_id}"),
     :name=>vdc[:name],
     :type=>"application/vnd.vmware.vcloud.vdc+xml",
     :rel=>"down"}
  end

  if api_version.to_f >= 5.1
    body[:Link] <<
      {:href=>make_href('supportedSystemsInfo/'),
       :type=>"application/vnd.vmware.vcloud.supportedSystemsInfo+xml",
       :rel=>"down"}
  end

  Excon::Response.new(
    :body    => body,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :status  => 200
  )
end
get_organizations() click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_organizations.rb, line 34
def get_organizations
  body =
    {:href=>make_href('org/'),
     :type=>"application/vnd.vmware.vcloud.orgList+xml",
     :Org=>
      [{:href=>make_href("org/#{data[:org][:uuid]}"),
        :name=>data[:org][:name],
        :type=>"application/vnd.vmware.vcloud.org+xml"}]}

  Excon::Response.new(
    :body => body,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :status => 200
  )
end
get_owner_section_body(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp_owner.rb, line 43
def get_owner_section_body(id)
  {
    :type => 'application/vnd.vmware.vcloud.owner+xml',
    :User => {
      :type => "application/vnd.vmware.admin.user+xml",
      :name => "mockuser",
      :href => make_href("user/12345678-1234-1234-1234-12345678df2b"),
    }
  }
end
get_runtime_info_section_type(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb, line 25
def get_runtime_info_section_type(id)

  type = 'application/vnd.vmware.vcloud.virtualHardwareSection+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vm_runtime_info_section_body(id, vm)
  )
end
get_snapshot_section(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_snapshot_section.rb, line 26
def get_snapshot_section(id)
  type = 'application/vnd.vmware.vcloud.snapshotSection+xml'

  unless data[:vms][id] || data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_snapshot_section_body(id)
  )
end
get_snapshot_section_body(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_snapshot_section.rb, line 42
def get_snapshot_section_body(id)
  {
    :type => "application/vnd.vmware.vcloud.snapshotSection+xml",
    :href => make_href("vApp/#{id}/snapshotSection"),
    :ovf_required => "false",
    :"ovf:Info"   => "Snapshot information section"
  }
end
get_startup_section(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_startup_section.rb, line 26
def get_startup_section(id)

  type = 'application/vnd.vmware.vcloud.startupSection+xml'

  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vapp_ovf_startup_section_body(id, vapp)
  )

end
get_supported_systems_info() click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_supported_systems_info.rb, line 25
def get_supported_systems_info
  body = # this is a subset of the full list
    {:xmlns=>xmlns,
     :xmlns_xsi=>xmlns_xsi,
     :type=>"application/vnd.vmware.vcloud.supportedSystemsInfo+xml",
     :href=>make_href('supportedSystemsInfo/'),
     :xsi_schemaLocation=>xsi_schema_location,
     :OperatingSystemFamilyInfo=>
      [{:Name=>"Microsoft Windows",
        :OperatingSystemFamilyId=>"1",
        :OperatingSystem=>
         [{:OperatingSystemId=>"85",
           :DefaultHardDiskAdapterType=>"4",
           :MinimumHardDiskSizeGigabytes=>"40",
           :MinimumMemoryMegabytes=>"512",
           :Name=>"Microsoft Windows Server 2012 (64-bit)",
           :InternalName=>"windows8Server64Guest",
           :Supported=>"true",
           :x64=>"true",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"8",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"true",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"74",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"3",
           :DefaultHardDiskAdapterType=>"4",
           :MinimumHardDiskSizeGigabytes=>"40",
           :MinimumMemoryMegabytes=>"512",
           :Name=>"Microsoft Windows Server 2008 R2 (64-bit)",
           :InternalName=>"windows7Server64Guest",
           :Supported=>"true",
           :x64=>"true",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"true",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"102",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"4",
           :DefaultHardDiskAdapterType=>"4",
           :MinimumHardDiskSizeGigabytes=>"40",
           :MinimumMemoryMegabytes=>"512",
           :Name=>"Microsoft Windows Server 2008 (32-bit)",
           :InternalName=>"winLonghornGuest",
           :Supported=>"true",
           :x64=>"false",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"true",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"73",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"}]},
       {:Name=>"Linux",
        :OperatingSystemFamilyId=>"2",
        :OperatingSystem=>
         [{:OperatingSystemId=>"48",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"64",
           :Name=>"Ubuntu Linux (64-bit)",
           :InternalName=>"ubuntu64Guest",
           :Supported=>"true",
           :x64=>"true",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"94",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"47",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"64",
           :Name=>"Ubuntu Linux (32-bit)",
           :InternalName=>"ubuntuGuest",
           :Supported=>"true",
           :x64=>"false",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"93",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"50",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"32",
           :Name=>"Other 2.6.x Linux (64-bit)",
           :InternalName=>"other26xLinux64Guest",
           :Supported=>"true",
           :x64=>"true",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"7",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"100",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"49",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"32",
           :Name=>"Other 2.6.x Linux (32-bit)",
           :InternalName=>"other26xLinuxGuest",
           :Supported=>"true",
           :x64=>"false",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"7",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"99",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"54",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"32",
           :Name=>"Other Linux (64-bit)",
           :InternalName=>"otherLinux64Guest",
           :Supported=>"true",
           :x64=>"true",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"false",
           :cimOsId=>"101",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"53",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"32",
           :Name=>"Other Linux (32-bit)",
           :InternalName=>"otherLinuxGuest",
           :Supported=>"true",
           :x64=>"false",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"true",
           :PersonalizationAuto=>"true",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"false",
           :cimOsId=>"36",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"}]},
       {:Name=>"Other",
        :OperatingSystemFamilyId=>"3",
        :OperatingSystem=>
         [{:OperatingSystemId=>"68",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"32",
           :Name=>"Other (64-bit)",
           :InternalName=>"otherGuest64",
           :Supported=>"true",
           :x64=>"true",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"false",
           :PersonalizationAuto=>"false",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"102",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"},
          {:OperatingSystemId=>"67",
           :DefaultHardDiskAdapterType=>"3",
           :MinimumHardDiskSizeGigabytes=>"8",
           :MinimumMemoryMegabytes=>"32",
           :Name=>"Other (32-bit)",
           :InternalName=>"otherGuest",
           :Supported=>"true",
           :x64=>"false",
           :MaximumCpuCount=>"64",
           :MinimumHardwareVersion=>"4",
           :PersonalizationEnabled=>"false",
           :PersonalizationAuto=>"false",
           :SysprepPackagingSupported=>"false",
           :SupportsMemHotAdd=>"true",
           :cimOsId=>"1",
           :CimVersion=>"0",
           :SupportedForCreate=>"true"}]}]}

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_supported_versions() click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_supported_versions.rb, line 24
def get_supported_versions
  body =
    {:xmlns=>"http://www.vmware.com/vcloud/versions",
     :xmlns_xsi=>xmlns_xsi,
     :xsi_schemaLocation=>xsi_schema_location,
     :VersionInfo=>
      [{:Version=>"1.5",
        :LoginUrl=>make_href("sessions"),
        :MediaTypeMapping=>
         [{:MediaType=>
            "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml",
           :ComplexTypeName=>"InstantiateVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwProviderVdcReferences+xml",
           :ComplexTypeName=>"VMWProviderVdcReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.customizationSection+xml",
           :ComplexTypeName=>"CustomizationSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.prepareHostParams+xml",
           :ComplexTypeName=>"PrepareHostParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.relocateVmParams+xml",
           :ComplexTypeName=>"RelocateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.org+xml",
           :ComplexTypeName=>"OrgType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.vmwExternalNetworkReferences+xml",
           :ComplexTypeName=>"VMWExternalNetworkReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.networkConnectionSection+xml",
           :ComplexTypeName=>"NetworkConnectionSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.host+xml",
           :ComplexTypeName=>"HostType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.catalogItem+xml",
           :ComplexTypeName=>"CatalogItemType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.owner+xml",
           :ComplexTypeName=>"OwnerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vdc+xml",
           :ComplexTypeName=>"VdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vdc+xml",
           :ComplexTypeName=>"AdminVdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.catalog+xml",
           :ComplexTypeName=>"AdminCatalogType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.recomposeVAppParams+xml",
           :ComplexTypeName=>"RecomposeVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.importVmIntoExistingVAppParams+xml",
           :ComplexTypeName=>"ImportVmIntoExistingVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.taskExtensionRequestUpdateProgressOperationParams+xml",
           :ComplexTypeName=>"TaskExtensionRequestUpdateProgressParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.catalog+xml",
           :ComplexTypeName=>"CatalogType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml",
           :ComplexTypeName=>"CloneVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.providervdc+xml",
           :ComplexTypeName=>"ProviderVdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmsObjectRefsList+xml",
           :ComplexTypeName=>"VmObjectRefsListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.undeployVAppParams+xml",
           :ComplexTypeName=>"UndeployVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vdcReferences+xml",
           :ComplexTypeName=>"VdcReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.systemPasswordPolicySettings+xml",
           :ComplexTypeName=>"SystemPasswordPolicySettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vApp+xml",
           :ComplexTypeName=>"VAppType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.taskExtensionRequest+xml",
           :ComplexTypeName=>"TaskExtensionRequestType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vimServerNetworks+xml",
           :ComplexTypeName=>"VimObjectRefListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwprovidervdc+xml",
           :ComplexTypeName=>"VMWProviderVdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.orgSettings+xml",
           :ComplexTypeName=>"OrgSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.captureVAppParams+xml",
           :ComplexTypeName=>"CaptureVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.screenTicket+xml",
           :ComplexTypeName=>"ScreenTicketType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.runtimeInfoSection+xml",
           :ComplexTypeName=>"RuntimeInfoSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.tasksList+xml",
           :ComplexTypeName=>"TasksListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.amqpSettingsTest+xml",
           :ComplexTypeName=>"AmqpSettingsTestType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.extensionSettings+xml",
           :ComplexTypeName=>"TaskExtensionSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.importVmAsVAppTemplateParams+xml",
           :ComplexTypeName=>"ImportVmAsVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationGeneralSettings+xml",
           :ComplexTypeName=>"OrgGeneralSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.registerVimServerParams+xml",
           :ComplexTypeName=>"RegisterVimServerParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.network+xml",
           :ComplexTypeName=>"OrgNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml",
           :ComplexTypeName=>"UploadVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.datastore+xml",
           :ComplexTypeName=>"DatastoreType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.metadata+xml",
           :ComplexTypeName=>"MetadataType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.licensingReportList+xml",
           :ComplexTypeName=>"LicensingReportListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwNetworkPool+xml",
           :ComplexTypeName=>"VMWNetworkPoolType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.systemSettings+xml",
           :ComplexTypeName=>"SystemSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwHostReferences+xml",
           :ComplexTypeName=>"VMWHostReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.taskExtensionRequestOperationParams+xml",
           :ComplexTypeName=>"TaskExtensionRequestOperationParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.metadata.value+xml",
           :ComplexTypeName=>"MetadataValueType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.taskOperationList+xml",
           :ComplexTypeName=>"TaskOperationListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.media+xml",
           :ComplexTypeName=>"MediaType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.productSections+xml",
           :ComplexTypeName=>"ProductSectionListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.amqpSettings+xml",
           :ComplexTypeName=>"AmqpSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vAppTemplate+xml",
           :ComplexTypeName=>"VAppTemplateType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.deployVAppParams+xml",
           :ComplexTypeName=>"DeployVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.importVmIntoExistingVAppTemplateParams+xml",
           :ComplexTypeName=>"ImportVmIntoExistingVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.resourcePoolList+xml",
           :ComplexTypeName=>"ResourcePoolListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.networkConfigSection+xml",
           :ComplexTypeName=>"NetworkConfigSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.OrganizationVdcResourcePoolSet+xml",
           :ComplexTypeName=>"OrganizationResourcePoolSetType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationPasswordPolicySettings+xml",
           :ComplexTypeName=>"OrgPasswordPolicySettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.publishCatalogParams+xml",
           :ComplexTypeName=>"PublishCatalogParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwExtension+xml",
           :ComplexTypeName=>"VMWExtensionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml",
           :ComplexTypeName=>"MediaInsertOrEjectParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vmPendingQuestion+xml",
           :ComplexTypeName=>"VmPendingQuestionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.notificationsSettings+xml",
           :ComplexTypeName=>"NotificationsSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.ldapUserSettings+xml",
           :ComplexTypeName=>"LdapUserAttributesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.right+xml",
           :ComplexTypeName=>"RightType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.ldapSettings+xml",
           :ComplexTypeName=>"LdapSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.organization+xml",
           :ComplexTypeName=>"AdminOrgType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.orgList+xml",
           :ComplexTypeName=>"OrgListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml",
           :ComplexTypeName=>"OrgVAppTemplateLeaseSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwVimServerReferences+xml",
           :ComplexTypeName=>"VMWVimServerReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwexternalnet+xml",
           :ComplexTypeName=>"VMWExternalNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.entity+xml",
           :ComplexTypeName=>"EntityType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.cloneMediaParams+xml",
           :ComplexTypeName=>"CloneMediaParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.licensingReport+xml",
           :ComplexTypeName=>"LicensingReportType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.importMediaParams+xml",
           :ComplexTypeName=>"ImportMediaParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.resourcePoolSetUpdateParams+xml",
           :ComplexTypeName=>"UpdateResourcePoolSetParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.taskExtensionRequestList+xml",
           :ComplexTypeName=>"ReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vmPendingAnswer+xml",
           :ComplexTypeName=>"VmQuestionAnswerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.rasdItemsList+xml",
           :ComplexTypeName=>"RasdItemsListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.generalSettings+xml",
           :ComplexTypeName=>"GeneralSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwNetworkPoolReferences+xml",
           :ComplexTypeName=>"VMWNetworkPoolReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.group+xml",
           :ComplexTypeName=>"GroupType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.controlAccess+xml",
           :ComplexTypeName=>"ControlAccessParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.ldapGroupSettings+xml",
           :ComplexTypeName=>"LdapGroupAttributesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.user+xml",
           :ComplexTypeName=>"UserType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vcloud+xml",
           :ComplexTypeName=>"VCloudType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.uberAdminSettings+xml",
           :ComplexTypeName=>"UberAdminSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwvirtualcenter+xml",
           :ComplexTypeName=>"VimServerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.leaseSettingsSection+xml",
           :ComplexTypeName=>"LeaseSettingsSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.composeVAppParams+xml",
           :ComplexTypeName=>"ComposeVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationEmailSettings+xml",
           :ComplexTypeName=>"OrgEmailSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vm+xml",
           :ComplexTypeName=>"VmType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.vmwProviderVdcResourcePoolSet+xml",
           :ComplexTypeName=>"VMWProviderVdcResourcePoolSetType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.cloneVAppParams+xml",
           :ComplexTypeName=>"CloneVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.guestCustomizationSection+xml",
           :ComplexTypeName=>"GuestCustomizationSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.task+xml",
           :ComplexTypeName=>"TaskType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.session+xml",
           :ComplexTypeName=>"SessionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vAppLeaseSettings+xml",
           :ComplexTypeName=>"OrgLeaseSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.importVmAsVAppParams+xml",
           :ComplexTypeName=>"ImportVmAsVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.role+xml",
           :ComplexTypeName=>"RoleType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.rasdItem+xml",
           :ComplexTypeName=>"RASD_Type",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.startupSection+xml",
           :ComplexTypeName=>"StartupSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.virtualHardwareSection+xml",
           :ComplexTypeName=>"VirtualHardwareSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.operatingSystemSection+xml",
           :ComplexTypeName=>"OperatingSystemSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.networkSection+xml",
           :ComplexTypeName=>"NetworkSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vAppNetwork+xml",
           :ComplexTypeName=>"VAppNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.network+xml",
           :ComplexTypeName=>"NetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.orgNetwork+xml",
           :ComplexTypeName=>"OrgNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwexternalnet+xml",
           :ComplexTypeName=>"VMWExternalNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"}]},
       {:Version=>"5.1",
        :LoginUrl=>make_href("sessions"),
        :MediaTypeMapping=>
         [{:MediaType=>
            "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml",
           :ComplexTypeName=>"InstantiateVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwprovidervdc+xml",
           :ComplexTypeName=>"MergeParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationFederationSettings+xml",
           :ComplexTypeName=>"OrgFederationSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.emailSettings+xml",
           :ComplexTypeName=>"EmailSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.prepareHostParams+xml",
           :ComplexTypeName=>"PrepareHostParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.org+xml",
           :ComplexTypeName=>"OrgType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.aclRule+xml",
           :ComplexTypeName=>"AclRuleType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.organizationLdapSettings+xml",
           :ComplexTypeName=>"OrgLdapSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.networkConnectionSection+xml",
           :ComplexTypeName=>"NetworkConnectionSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.owner+xml",
           :ComplexTypeName=>"OwnerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vdc+xml",
           :ComplexTypeName=>"AdminVdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.importVmIntoExistingVAppParams+xml",
           :ComplexTypeName=>"ImportVmIntoExistingVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.catalog+xml",
           :ComplexTypeName=>"CatalogType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml",
           :ComplexTypeName=>"CloneVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.createVdcParams+xml",
           :ComplexTypeName=>"CreateVdcParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmsObjectRefsList+xml",
           :ComplexTypeName=>"VmObjectRefsListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.undeployVAppParams+xml",
           :ComplexTypeName=>"UndeployVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.createSnapshotParams+xml",
           :ComplexTypeName=>"CreateSnapshotParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.blockingTask+xml",
           :ComplexTypeName=>"BlockingTaskType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwPvdcStorageProfile+xml",
           :ComplexTypeName=>"VMWProviderVdcStorageProfileType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.allocatedNetworkAddress+xml",
           :ComplexTypeName=>"AllocatedIpAddressesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vimServerNetworks+xml",
           :ComplexTypeName=>"VimObjectRefListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.blockingTaskOperationParams+xml",
           :ComplexTypeName=>"BlockingTaskOperationParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.updateProviderVdcStorageProfiles+xml",
           :ComplexTypeName=>"UpdateProviderVdcStorageProfilesParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.bundleUploadSocket+xml",
           :ComplexTypeName=>"BundleUploadSocketType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.gateway+xml",
           :ComplexTypeName=>"GatewayType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.screenTicket+xml",
           :ComplexTypeName=>"ScreenTicketType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.resourceClassAction+xml",
           :ComplexTypeName=>"ResourceClassActionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.event+xml",
           :ComplexTypeName=>"EventType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.tasksList+xml",
           :ComplexTypeName=>"TasksListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.migrateVmParams+xml",
           :ComplexTypeName=>"MigrateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.diskCreateParams+xml",
           :ComplexTypeName=>"DiskCreateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.registerVAppParams+xml",
           :ComplexTypeName=>"RegisterVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationGeneralSettings+xml",
           :ComplexTypeName=>"OrgGeneralSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.registerVimServerParams+xml",
           :ComplexTypeName=>"RegisterVimServerParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.datastore+xml",
           :ComplexTypeName=>"DatastoreType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.diskAttachOrDetachParams+xml",
           :ComplexTypeName=>"DiskAttachOrDetachParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.updateRightsParams+xml",
           :ComplexTypeName=>"UpdateRightsParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.metadata+xml",
           :ComplexTypeName=>"MetadataType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vdcStorageProfile+xml",
           :ComplexTypeName=>"AdminVdcStorageProfileType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.systemSettings+xml",
           :ComplexTypeName=>"SystemSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwHostReferences+xml",
           :ComplexTypeName=>"VMWHostReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.userEntityRights+xml",
           :ComplexTypeName=>"UserEntityRightsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.metadata.value+xml",
           :ComplexTypeName=>"MetadataValueType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.media+xml",
           :ComplexTypeName=>"MediaType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.brandingSettings+xml",
           :ComplexTypeName=>"BrandingSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.updateVdcStorageProfiles+xml",
           :ComplexTypeName=>"UpdateVdcStorageProfilesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.amqpSettings+xml",
           :ComplexTypeName=>"AmqpSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.resourceClass+xml",
           :ComplexTypeName=>"ResourceClassType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.deployVAppParams+xml",
           :ComplexTypeName=>"DeployVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.resourcePoolList+xml",
           :ComplexTypeName=>"ResourcePoolListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vdcStorageProfile+xml",
           :ComplexTypeName=>"VdcStorageProfileType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.networkConfigSection+xml",
           :ComplexTypeName=>"NetworkConfigSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.OrganizationVdcResourcePoolSet+xml",
           :ComplexTypeName=>"OrganizationResourcePoolSetType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.createProviderVdcParams+xml",
           :ComplexTypeName=>"VMWProviderVdcParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.publishCatalogParams+xml",
           :ComplexTypeName=>"PublishCatalogParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwExtension+xml",
           :ComplexTypeName=>"VMWExtensionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.notificationsSettings+xml",
           :ComplexTypeName=>"NotificationsSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.right+xml",
           :ComplexTypeName=>"RightType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.supportedSystemsInfo+xml",
           :ComplexTypeName=>"SupportedOperatingSystemsInfoType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vm.complianceResult+xml",
           :ComplexTypeName=>"ComplianceResultType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.orgList+xml",
           :ComplexTypeName=>"OrgListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwVimServerReferences+xml",
           :ComplexTypeName=>"VMWVimServerReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwexternalnet+xml",
           :ComplexTypeName=>"VMWExternalNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.entity+xml",
           :ComplexTypeName=>"EntityType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.cloneMediaParams+xml",
           :ComplexTypeName=>"CloneMediaParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.licensingReport+xml",
           :ComplexTypeName=>"LicensingReportType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.apiDefinition+xml",
           :ComplexTypeName=>"ApiDefinitionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vshieldmanager+xml",
           :ComplexTypeName=>"ShieldManagerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.blockingTaskList+xml",
           :ComplexTypeName=>"ReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vmPendingAnswer+xml",
           :ComplexTypeName=>"VmQuestionAnswerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.rasdItemsList+xml",
           :ComplexTypeName=>"RasdItemsListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.generalSettings+xml",
           :ComplexTypeName=>"GeneralSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.group+xml",
           :ComplexTypeName=>"GroupType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.controlAccess+xml",
           :ComplexTypeName=>"ControlAccessParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.user+xml",
           :ComplexTypeName=>"UserType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwvirtualcenter+xml",
           :ComplexTypeName=>"VimServerType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.strandedItem+xml",
           :ComplexTypeName=>"StrandedItemType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.leaseSettingsSection+xml",
           :ComplexTypeName=>"LeaseSettingsSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationEmailSettings+xml",
           :ComplexTypeName=>"OrgEmailSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.cloneVAppParams+xml",
           :ComplexTypeName=>"CloneVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.task+xml",
           :ComplexTypeName=>"TaskType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vAppLeaseSettings+xml",
           :ComplexTypeName=>"OrgLeaseSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.role+xml",
           :ComplexTypeName=>"RoleType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwProviderVdcReferences+xml",
           :ComplexTypeName=>"VMWProviderVdcReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.customizationSection+xml",
           :ComplexTypeName=>"CustomizationSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.service+xml",
           :ComplexTypeName=>"ServiceType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.relocateVmParams+xml",
           :ComplexTypeName=>"RelocateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.rights+xml",
           :ComplexTypeName=>"RightRefsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.vmwExternalNetworkReferences+xml",
           :ComplexTypeName=>"VMWExternalNetworkReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.disk+xml",
           :ComplexTypeName=>"DiskType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.kerberosSettings+xml",
           :ComplexTypeName=>"KerberosSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.operationLimitsSettings+xml",
           :ComplexTypeName=>"OrgOperationLimitsSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.host+xml",
           :ComplexTypeName=>"HostType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.catalogItem+xml",
           :ComplexTypeName=>"CatalogItemType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.entityReferences+xml",
           :ComplexTypeName=>"EntityReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vdc+xml",
           :ComplexTypeName=>"VdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.catalog+xml",
           :ComplexTypeName=>"AdminCatalogType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.recomposeVAppParams+xml",
           :ComplexTypeName=>"RecomposeVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.orgVdcNetwork+xml",
           :ComplexTypeName=>"OrgVdcNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.providervdc+xml",
           :ComplexTypeName=>"ProviderVdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.blockingTaskUpdateProgressOperationParams+xml",
           :ComplexTypeName=>"BlockingTaskUpdateProgressParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vdcReferences+xml",
           :ComplexTypeName=>"VdcReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.systemPasswordPolicySettings+xml",
           :ComplexTypeName=>"SystemPasswordPolicySettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vApp+xml",
           :ComplexTypeName=>"VAppType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwprovidervdc+xml",
           :ComplexTypeName=>"VMWProviderVdcType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vms+xml",
           :ComplexTypeName=>"VmsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.orgSettings+xml",
           :ComplexTypeName=>"OrgSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.apiFilter+xml",
           :ComplexTypeName=>"ApiFilterType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.captureVAppParams+xml",
           :ComplexTypeName=>"CaptureVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vmCapabilitiesSection+xml",
           :ComplexTypeName=>"VmCapabilitiesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.runtimeInfoSection+xml",
           :ComplexTypeName=>"RuntimeInfoSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.amqpSettingsTest+xml",
           :ComplexTypeName=>"AmqpSettingsTestType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.importVmAsVAppTemplateParams+xml",
           :ComplexTypeName=>"ImportVmAsVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.guestPersonalizationSettings+xml",
           :ComplexTypeName=>"OrgGuestPersonalizationSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.orgNetwork+xml",
           :ComplexTypeName=>"OrgNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.fileDescriptor+xml",
           :ComplexTypeName=>"FileDescriptorType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml",
           :ComplexTypeName=>"UploadVAppTemplateParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.licensingReportList+xml",
           :ComplexTypeName=>"LicensingReportListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwNetworkPool+xml",
           :ComplexTypeName=>"VMWNetworkPoolType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.taskOperationList+xml",
           :ComplexTypeName=>"TaskOperationListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vSphereWebClientUrl+xml",
           :ComplexTypeName=>"VSphereWebClientUrlType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.productSections+xml",
           :ComplexTypeName=>"ProductSectionListType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.blockingTaskSettings+xml",
           :ComplexTypeName=>"BlockingTaskSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vAppTemplate+xml",
           :ComplexTypeName=>"VAppTemplateType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.organizationPasswordPolicySettings+xml",
           :ComplexTypeName=>"OrgPasswordPolicySettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml",
           :ComplexTypeName=>"MediaInsertOrEjectParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vmPendingQuestion+xml",
           :ComplexTypeName=>"VmPendingQuestionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.organization+xml",
           :ComplexTypeName=>"AdminOrgType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.ldapSettings+xml",
           :ComplexTypeName=>"LdapSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.snapshotSection+xml",
           :ComplexTypeName=>"SnapshotSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml",
           :ComplexTypeName=>"OrgVAppTemplateLeaseSettingsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.importMediaParams+xml",
           :ComplexTypeName=>"ImportMediaParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.resourcePoolSetUpdateParams+xml",
           :ComplexTypeName=>"UpdateResourcePoolSetParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.licenseSettings+xml",
           :ComplexTypeName=>"LicenseType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.bundleUploadParams+xml",
           :ComplexTypeName=>"BundleUploadParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwNetworkPoolReferences+xml",
           :ComplexTypeName=>"VMWNetworkPoolReferencesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vcloud+xml",
           :ComplexTypeName=>"VCloudType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.serviceResource+xml",
           :ComplexTypeName=>"ServiceResourceType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.composeVAppParams+xml",
           :ComplexTypeName=>"ComposeVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.admin.vmwProviderVdcResourcePool+xml",
           :ComplexTypeName=>"VMWProviderVdcResourcePoolSetType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vm+xml",
           :ComplexTypeName=>"VmType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>
            "application/vnd.vmware.vcloud.guestCustomizationSection+xml",
           :ComplexTypeName=>"GuestCustomizationSectionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.session+xml",
           :ComplexTypeName=>"SessionType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.pvdcStorageProfile+xml",
           :ComplexTypeName=>"ProviderVdcStorageProfileType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwStorageProfiles+xml",
           :ComplexTypeName=>"VMWStorageProfilesType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.importVmAsVAppParams+xml",
           :ComplexTypeName=>"ImportVmAsVAppParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.serviceLink+xml",
           :ComplexTypeName=>"ServiceLinkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.enableDownloadParams+xml",
           :ComplexTypeName=>"EnableDownloadParamsType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.rasdItem+xml",
           :ComplexTypeName=>"RASD_Type",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.startupSection+xml",
           :ComplexTypeName=>"StartupSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.virtualHardwareSection+xml",
           :ComplexTypeName=>"VirtualHardwareSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.operatingSystemSection+xml",
           :ComplexTypeName=>"OperatingSystemSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.networkSection+xml",
           :ComplexTypeName=>"NetworkSection_Type",
           :SchemaLocation=>
            "http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.vAppNetwork+xml",
           :ComplexTypeName=>"VAppNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.network+xml",
           :ComplexTypeName=>"NetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.vcloud.orgNetwork+xml",
           :ComplexTypeName=>"OrgNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/master.xsd"},
          {:MediaType=>"application/vnd.vmware.admin.vmwexternalnet+xml",
           :ComplexTypeName=>"VMWExternalNetworkType",
           :SchemaLocation=>
            "http://#{@host}#{@path}/v1.5/schema/vmwextensions.xsd"}]}]}

  Excon::Response.new(
    :body => body,
    :headers => {'Content-Type' => 'text/xml'},
    :status => 200
  )
end
get_task(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_task.rb, line 98
def get_task(id)
  unless data[:tasks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location
  }.merge(task_body(id))

  Excon::Response.new(
    :status => 200,
    :headers => {'Type' => "application/#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_task_list(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_task_list.rb, line 104
def get_task_list(id)
  unless id == data[:org][:uuid]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"com.vmware.vcloud.entity.org:#{id}\"."
    )
  end

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
    :href => make_href("tasksList/#{id}"),
    :type => "application/vnd.vmware.vcloud.tasksList+xml",
    :name => "Tasks Lists",
    :Task => data[:tasks].keys.map {|task_id| task_body(task_id)}
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_vapp(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp.rb, line 28
def get_vapp(id)

  # Retrieve a vApp or VM.
  #

  case id
  when /^vapp-/
    body = get_mock_vapp_body(id)
  when /^vm-/
    body = get_mock_vm_body(id)
  else
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )

end
get_vapp_children_vms_body(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp.rb, line 115
def get_vapp_children_vms_body(id)
  child_vms = data[:vms].select do |vm_id, vm_details|
    vm_details[:parent_vapp] == id
  end
  child_vms.keys.collect do |vm_id|
    get_mock_vm_body(vm_id)
  end
end
get_vapp_lease_settings_section_body(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp.rb, line 44
def get_vapp_lease_settings_section_body(id)
  {
    :type => "application/vnd.vmware.vcloud.leaseSettingsSection+xml",
    :href => make_href("vApp/#{id}/leaseSettingsSection/"),
    :ovf_required=>"false",
    :"ovf:Info"=>"Lease settings section",
    :DeploymentLeaseInSeconds=>"0",
    :StorageLeaseInSeconds=>"0",
  }
end
get_vapp_metadata(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp_metadata.rb, line 28
def get_vapp_metadata(id)
  unless vm_or_vapp = data[:vapps][id] || vm_or_vapp = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  body = {
    :xmlns=>xmlns,
    :xmlns_xsi=>xmlns_xsi,
    :type=>"application/vnd.vmware.vcloud.metadata+xml",
    :href=>make_href("vApp/#{id}/metadata"),
    :xsi_schemaLocation=>xsi_schema_location,
    :Link=>
     [{:rel=>"up",
       :type=>"application/vnd.vmware.vcloud.vApp+xml",
       :href=>make_href("/vApp/#{id}")},
      {:rel=>"add",
       :type=>"application/vnd.vmware.vcloud.metadata+xml",
       :href=>make_href("vApp/#{id}/metadata")}],
    :MetadataEntry=>get_metadata_entries(vm_or_vapp[:metadata], id)
  }

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_vapp_network_config_section_body(id, vapp) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp.rb, line 44
def get_vapp_network_config_section_body(id, vapp)
  # TODO: This is effectively hardcoding a vAppNetwork configuration
  #       into here, but this is sufficient for initial testing.
  #       This network configuration has no networks.

  {
    :type => "application/vnd.vmware.vcloud.networkConfigSection+xml",
    :href => make_href("vApp/#{id}/networkConfigSection/"),
    :ovf_required => "false",
    :"ovf:Info" => "The configuration parameters for logical networks",
    :NetworkConfig => [],
  }
end
get_vapp_ovf_network_section_body(id, vapp) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp.rb, line 111
def get_vapp_ovf_network_section_body(id, vapp)
  {}
end
get_vapp_ovf_startup_section_body(id, vapp) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_startup_section.rb, line 44
def get_vapp_ovf_startup_section_body(id, vapp)
  {
    :xmlns_ns12 => "http://www.vmware.com/vcloud/v1.5",
    :ns12_href => make_href("vApp/#{id}"),
    :ns12_type => "application/vnd.vmware.vcloud.startupSection+xml",
    :"ovf:Info" => "VApp startup section",
    :"ovf:Item" => {
      :ovf_stopDelay => "0",
      :ovf_stopAction => "powerOff",
      :ovf_startDelay => "0",
      :ovf_startAction => "powerOn",
      :ovf_order => "0",
      :ovf_id => vapp[:name],
    },
  }
end
get_vapp_owner(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp_owner.rb, line 25
def get_vapp_owner(id)

  type = 'application/vnd.vmware.vcloud.owner+xml'

  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_owner_section_body(id)
  )

end
get_vapps_in_this_vdc(vdc_id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vdc.rb, line 165
def get_vapps_in_this_vdc(vdc_id)
  data[:vapps].select do |vapp_id, vapp|
    vapp[:vdc_id] == vdc_id
  end
end
get_vcloud() click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vcloud.rb, line 50
def get_vcloud
  body =
    {:href=>make_href('admin/'),
     :type=>"application/vnd.vmware.admin.vcloud+xml",
     :name=>'VMware vCloud Director',
     :Description=>'5.1.2.1377223 Tue Oct 15 20:56:05 GMT 2013',
     :Tasks=>{:Task=>[]},
     :OrganizationReferences=>
      {:OrganizationReference=>
       [{:type=>"application/vnd.vmware.admin.organization+xml",
         :name=>data[:org][:name],
         :href=>make_href("api/admin/org/#{data[:org][:uuid]}")}]},
     :ProviderVdcReferences=>{:ProviderVdcReference=>[]},
     :RightReferences=>{:RightReference=>[]},
     :RoleReferences=>{:RoleReference=>[]},
     :Networks=>{:Network=>[]}}

  Excon::Response.new(
    :body    => body,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :status  => 200
  )
end
get_vdc(vdc_id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vdc.rb, line 31
def get_vdc(vdc_id)
  response = Excon::Response.new

  unless vdc = data[:vdcs][vdc_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"com.vmware.vcloud.entity.vdc:#{vdc_id}\"."
    )
  end

  body =
    {:xmlns=>xmlns,
     :xmlns_xsi=>xmlns_xsi,
     :status=>"1",
     :name=>vdc[:name],
     :id=>"urn:vcloud:vdc:#{vdc_id}",
     :type=>"application/vnd.vmware.vcloud.vdc+xml",
     :href=>make_href("vdc/#{vdc_id}"),
     :xsi_schemaLocation=>xsi_schema_location,
     :Link=>
      [{:rel=>"up",
        :type=>"application/vnd.vmware.vcloud.org+xml",
        :href=>make_href("org/#{data[:org][:uuid]}")},
       {:rel=>"down",
        :type=>"application/vnd.vmware.vcloud.metadata+xml",
        :href=>make_href("vdc/#{vdc_id}/metadata")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml",
        :href=>
         make_href("vdc/#{vdc_id}/action/uploadVAppTemplate")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.media+xml",
        :href=>make_href("vdc/#{vdc_id}/media")},
       {:rel=>"add",
        :type=>
         "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml",
        :href=>
         make_href("vdc/#{vdc_id}/action/instantiateVAppTemplate")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.cloneVAppParams+xml",
        :href=>make_href("vdc/#{vdc_id}/action/cloneVApp")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml",
        :href=>
         make_href("vdc/#{vdc_id}/action/cloneVAppTemplate")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.cloneMediaParams+xml",
        :href=>make_href("vdc/#{vdc_id}/action/cloneMedia")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.captureVAppParams+xml",
        :href=>make_href("vdc/#{vdc_id}/action/captureVApp")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.composeVAppParams+xml",
        :href=>make_href("vdc/#{vdc_id}/action/composeVApp")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.diskCreateParams+xml",
        :href=>make_href("vdc/#{vdc_id}/disk")},
       {:rel=>"edgeGateways",
        :type=>"application/vnd.vmware.vcloud.query.records+xml",
        :href=>make_href("admin/vdc/#{vdc_id}/edgeGateways")},
       {:rel=>"add",
        :type=>"application/vnd.vmware.vcloud.orgVdcNetwork+xml",
        :href=>make_href("admin/vdc/#{vdc_id}/networks")},
       {:rel=>"orgVdcNetworks",
        :type=>"application/vnd.vmware.vcloud.query.records+xml",
        :href=>make_href("admin/vdc/#{vdc_id}/networks")}],
     :Description=>vdc[:description]||'',
     :AllocationModel=>"AllocationVApp",
     :ComputeCapacity=>
      {:Cpu=>
       {:Units=>"MHz",
        :Allocated=>"0",
        :Limit=>"0",
        :Reserved=>"0",
        :Used=>"0",
        :Overhead=>"0"},
      :Memory=>
       {:Units=>"MB",
        :Allocated=>"0",
        :Limit=>"0",
        :Reserved=>"0",
        :Used=>"0",
        :Overhead=>"0"}},
     :ResourceEntities => {
       :ResourceEntity => []
     },
     :AvailableNetworks => {},
     :Capabilities=>
      {:SupportedHardwareVersions=>
       {:SupportedHardwareVersion=>"vmx-08"}},
     :NicQuota=>"0",
     :NetworkQuota=>"20",
     :UsedNetworkCount=>"0",
     :VmQuota=>"100",
     :IsEnabled=>"true"}

  body[:ResourceEntities][:ResourceEntity] =
    data[:catalog_items].map do |id, item|
      {:type=>"application/vnd.vmware.vcloud.#{item[:type]}+xml",
       :name=>item[:name],
       :href=>make_href("#{item[:type]}/#{item[:type]}-#{id}")}
    end

  body[:ResourceEntities][:ResourceEntity] +=
    get_vapps_in_this_vdc(vdc_id).map do |vapp_id, vapp|
      {:type => "application/vnd.vmware.vcloud.vApp+xml",
       :name => vapp[:name],
       :href => make_href("vApp/#{vapp_id}")}
    end      

  body[:AvailableNetworks][:Network] =
    data[:networks].map do |id, network|
      {:type=>"application/vnd.vmware.vcloud.network+xml",
       :name=>network[:name],
       :href=>make_href("network/#{id}")}
  end

  if api_version.to_f >= 5.1
    body[:VdcStorageProfiles] = {}
    body[:VdcStorageProfiles][:VdcStorageProfile] =
      data[:vdc_storage_classes].select do |id, storage_class|
        storage_class[:vdc] == vdc_id
      end.map do |id, storage_class|
        {:type => 'application/vnd.vmware.vcloud.vdcStorageProfile+xml',
         :name => storage_class[:name],
         :href => make_href("vdcStorageProfile/#{id}")}
      end
  end

  response.status = 200
  response.headers = {'Content-Type' => "#{body[:type]};version=#{api_version}"}
  response.body = body
  response
end
get_vdc_storage_class(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vdc_storage_class.rb, line 47
def get_vdc_storage_class(id)
  unless vdc_storage_class = data[:vdc_storage_classes][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.vdcstorageProfile:#{id})\"."
    )
  end

  body =
    {:xmlns=>xmlns,
     :xmlns_xsi=>xmlns_xsi,
     :name=>vdc_storage_class[:name],
     :id=>"urn:vcloud:vdcstorageProfile:#{id}",
     :type=>"application/vnd.vmware.vcloud.vdcStorageProfile+xml",
     :href=>make_href("api/vdcStorageProfile/#{id}"),
     :xsi_schemaLocation=>xsi_schema_location,
     :Link=>
      [{:rel=>"up",
        :type=>"application/vnd.vmware.vcloud.vdc+xml",
        :href=>make_href("vdc/#{vdc_storage_class[:vdc]}")},
       {:rel=>"down",
        :type=>"application/vnd.vmware.vcloud.metadata+xml",
        :href=>make_href("vdcStorageProfile/#{id}/metadata")}],
     :Enabled=>vdc_storage_class[:enabled].to_s,
     :Units=>vdc_storage_class[:units],
     :Limit=>vdc_storage_class[:limit].to_s,
     :Default=>vdc_storage_class[:default].to_s}

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_vm(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_template_vm.rb, line 27
def get_vm(id)
  vapp = get_vapp(id).body
  vm = parse_vapp_to_vm(vapp)
  body = {:type => vapp[:type], :vm => vm}
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_vm_capabilities(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vm_capabilities.rb, line 31
def get_vm_capabilities(id)

  type = 'application/vnd.vmware.vcloud.vmCapabilitiesSection+xml'

  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{type};version=#{api_version}"},
    :body => get_vm_capabilities_section_body(id, vm)
  )

end
get_vm_capabilities_section_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vm_capabilities.rb, line 49
def get_vm_capabilities_section_body(id, vm)
  {
    :type => "application/vnd.vmware.vcloud.vmCapabilitiesSection+xml",
    :href => make_href("vApp/#{id}/vmCapabilities/"),
    :MemoryHotAddEnabled => "false",
    :CpuHotAddEnabled => "false",
  }
end
get_vm_disks(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vm_disks.rb, line 30
def get_vm_disks(id)
  disks = data[:disks].values.select {|d| d[:parent_vm] == id}.each_with_index.map do |disk, i|
    {
      :address => i,
      :description => disk[:description],
      :name => disk[:name],
      :id => (i+1)*1000,
      :resource_type => 17,
      :capacity => disk[:capacity],
    }
  end
  body = {:type => 'application/vnd.vmware.vcloud.rasditemslist+xml', :disks => disks}
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_vm_guest_customization_section_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp.rb, line 42
def get_vm_guest_customization_section_body(id, vm)
  {
    :type => "application/vnd.vmware.vcloud.guestCustomizationSection+xml",
    :href => make_href("vApp/#{id}/guestCustomizationSection/"),
    :ovf_required => "false",
    :"ovf:Info" => "Specifies Guest OS Customization Settings",
    :Enabled => "true",
    :ChangeSid => "false",
    :VirtualMachineId => id.split('-').last, # strip the 'vm-' prefix
    :JoinDomainEnabled => "false",
    :UseOrgSettings => "false",
    :AdminPasswordEnabled => "false",
    :AdminPasswordAuto => "true",
    :ResetPasswordRequired => "false",
    :CustomizationScript => vm[:customization_script] || "",
    :ComputerName => vm[:computer_name] || vm[:name],
    :Link => {
      :rel=>"edit",
      :type=>"application/vnd.vmware.vcloud.guestCustomizationSection+xml",
      :href=>make_href("vApp/#{id}"),
    },
  }
end
get_vm_network(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vm_network.rb, line 30
def get_vm_network(id)
  vapp    = get_vapp(id).body
  network = vapp[:NetworkConnectionSection]
  connection = network[:NetworkConnection]
  body = {
    :type => network[:type],
    :id   => network[:href].split('/')[-2],
    :href => network[:href],
    :info => network[:"ovf:Info"],
    :primary_network_connection_index => network[:PrimaryNetworkConnectionIndex],
    :network => connection[:network],
    :needs_customization => connection[:needsCustomization],
    :network_connection_index => connection[:NetworkConnectionIndex],
    :is_connected => connection[:IsConnected],
    :mac_address => connection[:MACAddress],
    :ip_address_allocation_mode => connection[:IpAddressAllocationMode]
  }
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_vm_network_connection_section_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp.rb, line 43
def get_vm_network_connection_section_body(id, vm)
  # TODO: Needs work - does not handle multiple NIC case yet, or
  #       DHCP/POOL allocations
  {
    :type => "application/vnd.vmware.vcloud.networkConnectionSection+xml",
    :href => make_href("vApp/#{id}/networkConnectionSection/"),
    :ovf_required => "false",
    :"ovf:Info" => "Specifies the available VM network connections",
    :PrimaryNetworkConnectionIndex => "0",
    :NetworkConnection => {
      :network => vm[:nics][0][:network_name],
      :needsCustomization => "false",
      :NetworkConnectionIndex => "0",
      :IpAddress => vm[:nics][0][:ip_address],
      :IsConnected => "true",
      :MACAddress => vm[:nics][0][:mac_address],
      :IpAddressAllocationMode => "MANUAL"
    }
  }
end
get_vm_operating_system_section_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_operating_system_section.rb, line 44
def get_vm_operating_system_section_body(id, vm)
  {
    :xmlns_ns12=>"http://www.vmware.com/vcloud/v1.5",
    :ovf_id => "94", # TODO: What is this?
    :ns12_href => make_href("vApp/#{id}/operatingSystemSection/"),
    :ns12_type => "application/vnd.vmware.vcloud.operatingSystemSection+xml",
    :vmw_osType => vm[:guest_os_type], # eg "ubuntu64Guest"
    :"ovf:Info"=>"Specifies the operating system installed",
    :"ovf:Description"=> vm[:guest_os_description], # eg "Ubuntu Linux (64-bit)",
  }
end
get_vm_ovf_item_list(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp.rb, line 156
def get_vm_ovf_item_list(id, vm)
  [
    get_network_cards_rasd_items_list_body(id, vm),
    get_disks_rasd_items_list_body(id, vm),
    get_media_rasd_item_cdrom_body(id, vm),
    get_media_rasd_item_floppy_body(id, vm),
    get_cpu_rasd_item_body(id, vm),
    get_memory_rasd_item_body(id, vm),
  ].compact.flatten
end
get_vm_ovfenv_environment_section_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp.rb, line 124
def get_vm_ovfenv_environment_section_body(id, vm)
  # TODO: I'm pretty sure this is just repeating info in other
  # sections, and the OVF part of VMs is extremely verbose. It's
  # likely to not be needed in Mock mode
  {}
end
get_vm_runtime_info_section_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb, line 42
def get_vm_runtime_info_section_body(id, vm)
  {
    :xmlns_ns12 => "http://www.vmware.com/vcloud/v1.5",
    :ns12_href => make_href("vApp/#{id}/runtimeInfoSection"),
    :ns12_type => "application/vnd.vmware.vcloud.virtualHardwareSection+xml",
    :"ovf:Info" => "Specifies Runtime info",
    :VMWareTools => {
      :version => "9282",
    }
  }
end
get_vm_storage_profile_section_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp.rb, line 131
def get_vm_storage_profile_section_body(id, vm)
  {
    :type => "application/vnd.vmware.vcloud.vdcStorageProfile+xml",
    :name => "Mock Storage Profile",
    :href => make_href("vdcStorageProfile/12345678-1234-1234-1234-1234500e49a8"),
  }
end
get_vm_virtual_hardware_section_body(id, vm) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp.rb, line 139
def get_vm_virtual_hardware_section_body(id, vm)

  {:xmlns_ns12=>"http://www.vmware.com/vcloud/v1.5",
   :ovf_transport=>"",
   :ns12_href => make_href("vApp/#{id}/virtualHardwareSection/"),
   :ns12_type=>"application/vnd.vmware.vcloud.virtualHardwareSection+xml",
   :"ovf:Info"=>"Virtual hardware requirements",
   :"ovf:System"=>{
     :"vssd:ElementName"=>"Virtual Hardware Family",
     :"vssd:InstanceID"=>"0",
     :"vssd:VirtualSystemIdentifier" => vm[:name],
     :"vssd:VirtualSystemType"=>"vmx-08"
   },
   :"ovf:Item" => get_vm_ovf_item_list(id, vm),
  }
end
get_vms(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_template_vms.rb, line 27
def get_vms(id)
  vapptemplate = get_vapp(id).body
  parser = Fog::Parsers::Compute::VcloudDirector::Vms.new
  vms  = vapp[:Children][:Vm].map {|child| parse_vapp_to_vm(child) }
  body = {:type => vapp[:type], :vms => vms}
  Excon::Response.new(
    :status => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
get_vms_disk_attached_to(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vms_disk_attached_to.rb, line 27
def get_vms_disk_attached_to(id)
  unless data[:disks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No access to entity "com.vmware.vcloud.entity.disk:%s".' % id
    )
  end

  Fog::Mock.not_implemented
end
get_vms_in_lease_from_query(options={}) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vms_in_lease_from_query.rb, line 96
def get_vms_in_lease_from_query(options={})

  if options.key?(:filter) && options[:filter] =~ /^href==([^;,]+)$/
    href = $1
    id = href.split('/').last
  else
    Fog::Mock.not_implemented("Filter by href is currently the only option implemented in get_vms_in_lease_from_query Mock")
  end

  vm = data[:vms][id]
  parent_vapp_id = vm[:parent_vapp]
  vdc_id = data[:vapps][parent_vapp_id][:vdc_id]

  body = {
    :xmlns=>xmlns,
    :xmlns_xsi=>xmlns_xsi,
    :href=>make_href('query'),
    :name=>"vm",
    :type=>"application/vnd.vmware.vcloud.query.records+xml",
    :xsi_schemaLocation=>xsi_schema_location,
    :total=>"1",
    :pageSize=>"25",
    :page=>"1",
    :Link=>
      [{:rel=>"alternate",
        :type=>"application/vnd.vmware.vcloud.query.references+xml",
        :href=>make_href('query')},
       {:rel=>"alternate",
        :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
        :href=>make_href('query')}],
    :VMRecord=>
      [{:vdc=>make_href(vdc_id),
        :numberOfCpus=>vm[:cpu_count],
        :name=>vm[:name],
        :containerName=>data[:vapps][parent_vapp_id][:name],
        :memoryMB=>vm[:memory_in_mb],
        :isVAppTemplate=>"false",
        :href=>make_href(id),
        :taskStatus=>"success",
        :task=>make_href("task/#{uuid}"),
        :taskDetails=>" ",
        :taskStatusName=>"vappUpdateVm"}]
  }

  Excon::Response.new(
    :status  => 200,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body    => body
  )
end
instantiate_vapp_template(vapp_name, template_id, options={}) click to toggle source

Assume the template is a single VM with one network interface and one disk.

# File lib/fog/vcloud_director/requests/compute/instantiate_vapp_template.rb, line 104
def instantiate_vapp_template(vapp_name, template_id, options={})
  unless data[:catalog_items].values.find {|i| i[:template_id] == template_id}
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No such template.'
    )
  end
  unless vdc = data[:vdcs][options[:vdc_id]]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No such VDC.'
    )
  end

  vapp_uuid = uuid
  vapp_id   = "vapp-#{vapp_uuid}"
  owner = {
    :href => make_href("vApp/#{vapp_id}"),
    :type => 'application/vnd.vmware.vcloud.vm+xml'
  }
  task_id = enqueue_task(
    "Creating Virtual Application #{vapp_name}(#{vapp_uuid})", 'vdcInstantiateVapp', owner,
    :on_success => lambda do
      # Add to the VDC
      data[:vapps][vapp_id] = {
        :name => vapp_name,
        :vdc_id => options[:vdc_id],
        :description => 'From Template',
        :networks => [
          {:parent_id => default_network_uuid }
        ]
      }
      vm_id = "vm-#{uuid}"
      data[:vms][vm_id] = {
        :name => vapp_name,
        :parent_vapp => vapp_id,
        :nics => [
          {
            :network_name => 'Default Network',
            :mac_address  => '7d:68:a2:a0:a4:f8',
            :ip_address   => nil
          }
        ]
      }
      data[:disks][uuid] = {
        :name => 'Hard Disk 1',
        :capacity => 10240,
        :parent_vm => vm_id
      }
    end
  )
  body = {
    :href => make_href("vApp/#{vapp_id}"),
    :Tasks => {
      :Task => {
        :xmlns => xmlns,
        :xmlns_xsi => xmlns_xsi,
        :xsi_schemaLocation => xsi_schema_location,
      }.merge(task_body(task_id))
    }
  }

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
org_name() click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 810
def org_name
  @org_name ||=
    begin
      username = @vcloud_director_username.split('@')
      if username.size >= 2 # may be 'email_address@org_name'
        username.last
      else
        Fog::Logger.warning('vcloud_director_username should be in the form user@org_name')
        'vcd_org_name'
      end
    end
end
parse_vapp_to_vm(vapp) click to toggle source

Mock equivalent of Fog::Parsers::Compute::VcloudDirector::Vm

# File lib/fog/vcloud_director/requests/compute/get_template_vm.rb, line 39
def parse_vapp_to_vm(vapp)
  parser = Fog::Parsers::Compute::VcloudDirector::Vm.new
  vm = vapp.select {|k| [:href, :name, :status, :type].include? k}
  network = vapp[:NetworkConnectionSection]
  vm.merge({
    :id => vapp[:href].split('/').last,
    :status => parser.human_status(vapp[:status]),
    :ip_address => network[:NetworkConnection][:IpAddress],
    :description => vapp[:Description],
    :cpu => get_hardware(vapp, 3),
    :memory => get_hardware(vapp, 4),
    :disks => get_disks(vapp),
    :links => [vapp[:GuestCustomizationSection][:Link]],
  })
end
post_cancel_task(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/post_cancel_task.rb, line 25
def post_cancel_task(id)
  unless task = data[:tasks][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No access to entity "com.vmware.vcloud.entity.task:%s"' % id
    )
  end

  # @note Tasks don't actually get cancelled (confirmed VCloud Director
  #   bug) so we'll emulate that. Set the flag and we're done!
  task[:cancel_requested] = true

  Excon::Response.new(
    :status => 204
  )
end
post_clone_media(vdc_id, source_id, options={}) click to toggle source
# File lib/fog/vcloud_director/requests/compute/post_clone_media.rb, line 53
def post_clone_media(vdc_id, source_id, options={})
  # TODO: check this happens.
  unless source_media = data[:medias][source_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.media:#{source_id})\"."
    )
  end
  unless data[:vdcs][vdc_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.vdc:#{vdc_id})\"."
    )
  end

  media_id = uuid
  media_name = "#{source_media[:name]}-copy-#{uuid}"

  owner = {
    :href => make_href("media/#{media_id}"),
    :type => 'application/vnd.vmware.vcloud.media+xml'
  }
  task_id = enqueue_task(
    "Copy Media File #{media_name}(#{media_id})", 'vdcCopyMedia', owner,
    :on_success => lambda do
      data[:medias][media_id][:status] = 1
    end
  )

  media = source_media.dup.merge(
    :name => media_name,
    :status => 0,
    :tasks => [task_id]
  )
  data[:medias][media_id] = media

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location
  }.merge(media_body(media_id))

  Excon::Response.new(
    :status => 201,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
post_configure_edge_gateway_services(id, configuration) click to toggle source
# File lib/fog/vcloud_director/requests/compute/post_configure_edge_gateway_services.rb, line 37
def post_configure_edge_gateway_services(id, configuration)
  unless data[:edge_gateways][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
              "No access to entity \"(com.vmware.vcloud.entity.edgegateway:#{id})\"."
          )
  end

  owner = {
    :href => make_href("admin/edgeGateway/#{id}"),
    :type => 'application/vnd.vmware.vcloud.gateway+xml'
  }
  task_id = enqueue_task(
      "Configuring edgegateway(#{id})", 'networkConfigureEdgeGatewayServices', owner,
      :on_success => lambda do
        data[:edge_gateways][id][:Configuration][:EdgeGatewayServiceConfiguration] = configuration
      end
  )

  task = task_body(task_id)
  task.delete(:Owner)  # known bug - admin tasks do not return Owner

  body = {
      :xmlns => xmlns,
      :xmlns_xsi => xmlns_xsi,
      :xsi_schemaLocation => xsi_schema_location,
  }.merge(task)

  Excon::Response.new(
      :status => 202,
      :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
      :body => body
  )
end
post_create_org_vdc_network(vdc_id, name, options={}) click to toggle source
# File lib/fog/vcloud_director/requests/compute/post_create_org_vdc_network.rb, line 68
def post_create_org_vdc_network(vdc_id, name, options={})
  unless data[:vdcs][vdc_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.vdc:#{vdc_id})\"."
    )
  end

  type = 'network'
  id = uuid

  # Description
  # Configuration
  #   IpScopes
  #     IpScope
  #       IsInherited
  #       Gateway
  #       Netmask
  #       Dns1
  #       Dns2
  #       DnsSuffix
  #       IsEnabled
  #       IpRanges
  #         IpRange
  #           StartAddress
  #           EndAddress
  #   FenceMode
  # EdgeGateway
  # IsShared

  network_body = {
    :name           => name,
    :vdc            => vdc_id,
  }

  [:Description, :IsShared].each do |key|
    network_body[key] = options[key] if options.key?(key)
  end

  if options.key?(:EdgeGateway)
    network_body[:EdgeGateway] =
      options[:EdgeGateway][:href].split('/').last
  end

  if configuration = options[:Configuration]
    if ip_scopes = configuration[:IpScopes]
      if ip_scope = ip_scopes[:IpScope]
        [:IsInherited, :Gateway, :Netmask,
          :Dns1, :Dns2, :DnsSuffix, :IsEnabled].each do |key|
            network_body[key] = ip_scope[key] if ip_scope.key?(key)
        end
        if ip_ranges = ip_scope[:IpRanges]
          network_body[:IpRanges] = []
          ip_ranges.each do |ipr|
            network_body[:IpRanges] << {
              :StartAddress => ipr[:IpRange][:StartAddress],
              :EndAddress   => ipr[:IpRange][:EndAddress]
            }
          end
        end
      end
    end
    network_body[:FenceMode] = configuration[:FenceMode] if ip_scope.key?(:FenceMode)
  end

  owner = {
    :href => make_href("#{type}/#{id}"),
    :type => "application/vnd.vmware.vcloud.#{type}+xml"
  }
  task_id = enqueue_task(
    "Adding #{type} #{name} (#{id})", 'CreateOrgVdcNetwork', owner,
    :on_success => lambda do
      data[:networks][id] = network_body
    end
  )

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
    :href => make_href("admin/network/#{id}"),
    :name => name,
    :id => "urn:vcloud:network:#{id}",
    :type => "application/vnd.vmware.vcloud.orgVdcNetwork+xml",
    :Link => [
      {:rel=>"up", :type=>"application/vnd.vmware.vcloud.vdc+xml", :href=>make_href("vdc/#{vdc_id}")},
      {:rel=>"down", :type=>"application/vnd.vmware.vcloud.metadata+xml", :href=>make_href("admin/network/#{id}/metadata")},
      {:rel=>"down", :type=>"application/vnd.vmware.vcloud.allocatedNetworkAddress+xml", :href=>make_href("admin/network/#{id}/allocatedAddresses/")},
    ],
  }.merge(options)

  body[:Tasks] = {
    :Task => task_body(task_id)
  }

  Excon::Response.new(
    :status => 201,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
post_instantiate_vapp_template(vdc_id, vapp_template_id, name, options={}) click to toggle source
# File lib/fog/vcloud_director/requests/compute/post_instantiate_vapp_template.rb, line 134
def post_instantiate_vapp_template(vdc_id, vapp_template_id, name, options={})
  unless data[:vdcs][vdc_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.vdc:#{vdc_id})\"."
    )
  end

  type = 'vApp'
  vapp_id = "vapp-#{uuid}"
  vm_id = "vm-#{uuid}"

  data[:vapps][vapp_id] = {
    :name => name,
    :vdc_id => vdc_id,
    :description => options.fetch(:description, "vApp created from #{vapp_template_id}"),
    :networks => [],
    :metadata => {:'vapp_key' => 'vapp_value'},
    :status => "0",
  }

  data[:vms][vm_id] = {
    :name => 'vm-template-name',
    :parent_vapp => vapp_id,
    :memory_in_mb => "1024",
    :cpu_count => "2",
    :metadata => {:'vm_key' => 'vm_value'},
    :nics => [
      {
      :network_name => 'Default Network',
      :mac_address => "00:50:56:00:00:00",
      :ip_address => "192.168.0.1",
      }
    ],
  }

  owner = {
    :href => make_href("#{type}/#{vapp_id}"),
    :type => "application/vnd.vmware.vcloud.#{type}+xml"
  }
  task_id = enqueue_task(
    "Creating Virtual Application #{name}(#{vapp_id})", 'vdcInstantiateVapp', owner,
    :on_success => lambda do
      data[:vapps][vapp_id][:status] = "8"
    end
  )

  body = get_vapp(vapp_id).body

  body[:Tasks] = {
    :Task => task_body(task_id)
  }

  Excon::Response.new(
    :status => 201,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
post_power_on_vapp(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/post_power_on_vapp.rb, line 35
def post_power_on_vapp(id)
  unless vapp = data[:vapps][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end
  
  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vApp+xml'
  }
  task_id = enqueue_task(
    "Starting Virtual Application #{data[:vapps][id]} vapp(#{id})", 'vappDeploy', owner,
    :on_success => lambda do
      data[:vms].values.each do |vm|
        if vm[:parent_vapp] == id
          vm[:status] = '4' # on
        end
      end
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
post_reconfigure_vm(id, options={}) click to toggle source
# File lib/fog/vcloud_director/requests/compute/post_reconfigure_vm.rb, line 83
def post_reconfigure_vm(id, options={})
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end
  
  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vApp+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{data[:vms][id][:name]}(#{id})", 'vappUpdateVm', owner,
    :on_success => lambda do
      data[:vms][id][:name] = options[:name]
      data[:vms][id][:description] = options[:description] if options[:description]
      data[:vms][id][:cpu_count] = options[:cpu] if options[:cpu]
      data[:vms][id][:memory_in_mb] = options[:memory] if options[:memory]
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
post_update_vapp_metadata(id, metadata={}) click to toggle source
# File lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb, line 51
def post_update_vapp_metadata(id, metadata={})
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end
  
  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vApp+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{data[:vms][id][:name]}(#{id})", 'vappUpdateVm', owner,
    :on_success => lambda do
      metadata.each do |k,v|
        data[:tags][id] ||= {}
        data[:tags][id][k] = v
      end
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
post_upload_disk(id, name, size, options={}) click to toggle source
# File lib/fog/vcloud_director/requests/compute/post_upload_disk.rb, line 82
def post_upload_disk(id, name, size, options={})
  unless size.to_s =~ /^\d+$/
    raise Fog::Compute::VcloudDirector::BadRequest.new(
      "validation error on field 'diskSpec.sizeBytes': must be greater than or equal to 0"
    )
  end
  unless data[:vdcs][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'No access to entity "(com.vmware.vcloud.entity.vdc:%s)".' % id
    )
  end

  disk_id = uuid

  owner = {
    :href => make_href("disk/#{disk_id}"),
    :type => 'application/vnd.vmware.vcloud.disk+xml'
  }
  task_id = enqueue_task(
    "Creating Disk #{name}(#{disk_id})", 'vdcCreateDisk', owner,
    :on_success => lambda do
      data[:disks][disk_id][:status] = 1
    end
  )

  disk = {
    :description => options[:Description],
    :name => name,
    :size => size.to_i,
    :status => 0,
    :tasks => [task_id],
    :vdc_id => id,
    :vdc_storage_class => data[:vdc_storage_classes].find {|k,v| v[:default]}.first
  }
  data[:disks][disk_id] = disk

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location
  }.merge(disk_body(disk_id))

  Excon::Response.new(
    :status => 201,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
post_upload_media(vdc_id, name, image_type, size, options={}) click to toggle source
# File lib/fog/vcloud_director/requests/compute/post_upload_media.rb, line 56
def post_upload_media(vdc_id, name, image_type, size, options={})
  unless ['iso','floppy'].include?(image_type)
    raise Fog::Compute::VcloudDirector::BadRequest.new(
      'The value of parameter imageType is incorrect.'
    )
  end
  unless size.to_s =~ /^\d+$/
    raise Fog::Compute::VcloudDirector::BadRequest.new(
      'validation error on field \'size\': must be greater than or equal to 0'
    )
  end
  unless data[:vdcs][vdc_id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.vdc:#{vdc_id})\"."
    )
  end

  media_id = uuid
  file_id = uuid

  owner = {
    :href => make_href("media/#{media_id}"),
    :type => 'application/vnd.vmware.vcloud.media+xml'
  }
  task_id = enqueue_task(
    "Importing Media File #{name}(#{file_id})", 'vdcUploadMedia', owner,
    :on_success => lambda do
      media = data[:medias][media_id]
      media[:file][:bytes_transferred] = media[:size]
      media[:status] = 1
    end
  )

  media = {
    :description => options[:Description],
    :file => {
      :bytes_transferred => 0,
      :uuid => file_id
    },
    :image_type => image_type,
    :name => name,
    :size => size.to_i,
    :status => 0,
    :tasks => [task_id],
    :vdc_id => vdc_id,
    :vdc_storage_class => data[:vdc_storage_classes].find {|k,v| v[:default]}.first
  }
  data[:medias][media_id] = media

  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location
  }.merge(media_body(media_id))

  Excon::Response.new(
    :status => 201,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
process_task(response_body) click to toggle source

@note As far as this method is concerned, the only possible task

states are 'running' and 'success'.

@param [Hash] response_body @return [Boolean]

# File lib/fog/vcloud_director/compute.rb, line 874
def process_task(response_body)
  task_id = response_body[:href].split('/').last
  task = data[:tasks][task_id]

  if task[:status] == 'running'
    task[:end_time] = DateTime.now
    task[:progress] = 100
    task[:status] = 'success'

    if task[:on_success]
      task[:on_success].call
      task.delete(:on_success)
    end
  end

  return true if task[:status] == 'success'
  raise TaskError.new "status: #{task[:status]}, error: #{task[:Error]}"
end
put_cpu(id, num_cpus) click to toggle source
# File lib/fog/vcloud_director/requests/compute/put_cpu.rb, line 55
def put_cpu(id, num_cpus)
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vm+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{data[:vms][id][:name]}(#{id})", 'vappUpdateVm', owner,
    :on_success => lambda do
      data[:vms][id][:cpu_count] = num_cpus
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
put_memory(id, memory) click to toggle source
# File lib/fog/vcloud_director/requests/compute/put_memory.rb, line 55
def put_memory(id, memory)
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vm+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{data[:vms][id][:name]}(#{id})", 'vappUpdateVm', owner,
    :on_success => lambda do
      data[:vms][id][:memory_in_mb] = memory
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )

end
put_network(id, name, options={}) click to toggle source
# File lib/fog/vcloud_director/requests/compute/put_network.rb, line 68
def put_network(id, name, options={})
  original_network = data[:networks][id]
  unless original_network
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      "No access to entity \"(com.vmware.vcloud.entity.orgVdcNetwork:#{id})\"."
    )
  end

  type = 'network'

  # Description
  # Configuration
  #   IpScopes
  #     IpScope
  #       IsInherited
  #       Gateway
  #       Netmask
  #       Dns1
  #       Dns2
  #       DnsSuffix
  #       IsEnabled
  #       IpRanges
  #         IpRange
  #           StartAddress
  #           EndAddress
  #   FenceMode
  # EdgeGateway
  # IsShared
  #
  vdc_id = original_network[:vdc],

  network_body = {
    :name => name,
    :vdc  => vdc_id,
  }

  [:Description, :IsShared].each do |key|
    network_body[key] = options[key] if options.key?(key)
  end

  if options.key?(:EdgeGateway)
    network_body[:EdgeGateway] =
      options[:EdgeGateway][:href].split('/').last
  end

  if configuration = options[:Configuration]
    if ip_scopes = configuration[:IpScopes]
      if ip_scope = ip_scopes[:IpScope]
        [:IsInherited, :Gateway, :Netmask,
          :Dns1, :Dns2, :DnsSuffix, :IsEnabled].each do |key|
            network_body[key] = ip_scope[key] if ip_scope.key?(key)
        end
        if ip_ranges = ip_scope[:IpRanges]
          network_body[:IpRanges] = []
          ip_ranges.each do |ipr|
            network_body[:IpRanges] << {
              :StartAddress => ipr[:IpRange][:StartAddress],
              :EndAddress   => ipr[:IpRange][:EndAddress]
            }
          end
        end
      end
    end
    network_body[:FenceMode] = configuration[:FenceMode] if ip_scope.key?(:FenceMode)
  end

  owner = {
    :href => make_href("#{type}/#{id}"),
    :type => "application/vnd.vmware.vcloud.#{type}+xml"
  }
  task_id = enqueue_task(
    "Updating #{type} #{name} (#{id})", 'networkUpdateNetwork', owner,
    :on_success => lambda do
      data[:networks][id] = network_body
    end
  )
  task = task_body(task_id)
  task.delete(:Owner) #known-bug: admin-api does not return owner.
  body = {
      :xmlns => xmlns,
      :xmlns_xsi => xmlns_xsi,
      :xsi_schemaLocation => xsi_schema_location,
  }.merge(task)

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )

end
put_network_connection_system_section_vapp(id, options={}) click to toggle source
# File lib/fog/vcloud_director/requests/compute/put_network_connection_system_section_vapp.rb, line 120
def put_network_connection_system_section_vapp(id, options={})
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end
  
  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vApp+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{data[:vms][id][:name]}(#{id})", 'vappUpdateVm', owner,
    :on_success => lambda do
      data[:vms][id][:nics].first[:network_name] = options[:network]
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
put_vapp_metadata_item_metadata(id, key, value) click to toggle source
# File lib/fog/vcloud_director/requests/compute/put_vapp_metadata_item_metadata.rb, line 51
def put_vapp_metadata_item_metadata(id, key, value)
  unless vm_or_vapp = data[:vapps][id] || vm_or_vapp = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vm+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{vm_or_vapp[:name]}(#{id})", 'vappUpdateVm', owner,
    :on_success => lambda do
      vm_or_vapp[:metadata][key] = value
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )

end
put_vm(id, name, options) click to toggle source
# File lib/fog/vcloud_director/requests/compute/put_vm.rb, line 39
def put_vm(id, name, options)
  unless vm = data[:vms][id]
    raise Fog::Compute::VcloudDirector::Forbidden.new(
      'This operation is denied.'
    )
  end

  owner = {
    :href => make_href("vApp/#{id}"),
    :type => 'application/vnd.vmware.vcloud.vm+xml'
  }
  task_id = enqueue_task(
    "Updating Virtual Machine #{data[:vms][id][:name]}(#{id})", 'vappUpdateVm', owner,
      :on_success => lambda do
        data[:vms][id][:name] = name
    end
  )
  body = {
    :xmlns => xmlns,
    :xmlns_xsi => xmlns_xsi,
    :xsi_schemaLocation => xsi_schema_location,
  }.merge(task_body(task_id))

  Excon::Response.new(
    :status => 202,
    :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
    :body => body
  )
end
user_name() click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 823
def user_name
  @user_name ||= @vcloud_director_username.split('@').first
end
user_uuid() click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 827
def user_uuid
  @user_uuid ||= uuid
end
uuid() click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 831
def uuid
  [8,4,4,4,12].map {|i| Fog::Mock.random_hex(i)}.join('-')
end
vcloud_token() click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 806
def vcloud_token
  @vcloud_token || Fog::Mock.random_base64(32)
end

Private Instance Methods

all_types() click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_execute_query.rb, line 402
def all_types
  {:xmlns=>xmlns,
   :xmlns_xsi=>xmlns_xsi,
   :type=>"application/vnd.vmware.vcloud.query.queryList+xml",
   :href=>make_href('query'),
   :xsi_schemaLocation=>xsi_schema_location,
   :Link=>
    [{:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"organization",
      :href=>make_href('query?type=organization&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"organization",
      :href=>make_href('query?type=organization&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"organization",
      :href=>make_href('query?type=organization&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"orgVdc",
      :href=>make_href('query?type=orgVdc&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"orgVdc",
      :href=>make_href('query?type=orgVdc&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"orgVdc",
      :href=>make_href('query?type=orgVdc&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"media",
      :href=>make_href('query?type=media&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"media",
      :href=>make_href('query?type=media&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"media",
      :href=>make_href('query?type=media&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"vAppTemplate",
      :href=>make_href('query?type=vAppTemplate&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"vAppTemplate",
      :href=>make_href('query?type=vAppTemplate&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"vAppTemplate",
      :href=>make_href('query?type=vAppTemplate&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"vApp",
      :href=>make_href('query?type=vApp&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"vApp",
      :href=>make_href('query?type=vApp&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"vApp",
      :href=>make_href('query?type=vApp&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"vm",
      :href=>make_href('query?type=vm&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"vm",
      :href=>make_href('query?type=vm&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"vm",
      :href=>make_href('query?type=vm&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"orgNetwork",
      :href=>make_href('query?type=orgNetwork&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"orgNetwork",
      :href=>make_href('query?type=orgNetwork&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"orgNetwork",
      :href=>make_href('query?type=orgNetwork&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"vAppNetwork",
      :href=>make_href('query?type=vAppNetwork&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"vAppNetwork",
      :href=>make_href('query?type=vAppNetwork&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"vAppNetwork",
      :href=>make_href('query?type=vAppNetwork&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"catalog",
      :href=>make_href('query?type=catalog&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"catalog",
      :href=>make_href('query?type=catalog&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"catalog",
      :href=>make_href('query?type=catalog&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"group",
      :href=>make_href('query?type=group&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"group",
      :href=>make_href('query?type=group&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"group",
      :href=>make_href('query?type=group&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"user",
      :href=>make_href('query?type=user&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"user",
      :href=>make_href('query?type=user&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"user",
      :href=>make_href('query?type=user&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"strandedUser",
      :href=>make_href('query?type=strandedUser&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"strandedUser",
      :href=>make_href('query?type=strandedUser&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"strandedUser",
      :href=>make_href('query?type=strandedUser&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"role",
      :href=>make_href('query?type=role&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"role",
      :href=>make_href('query?type=role&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"role",
      :href=>make_href('query?type=role&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"allocatedExternalAddress",
      :href=>make_href('query?type=allocatedExternalAddress&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"allocatedExternalAddress",
      :href=>make_href('query?type=allocatedExternalAddress&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"event",
      :href=>make_href('query?type=event&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"event",
      :href=>make_href('query?type=event&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"right",
      :href=>make_href('query?type=right&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"right",
      :href=>make_href('query?type=right&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"right",
      :href=>make_href('query?type=right&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"vAppOrgNetworkRelation",
      :href=>make_href('query?type=vAppOrgNetworkRelation&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"vAppOrgNetworkRelation",
      :href=>make_href('query?type=vAppOrgNetworkRelation&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"vAppOrgNetworkRelation",
      :href=>make_href('query?type=vAppOrgNetworkRelation&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"catalogItem",
      :href=>make_href('query?type=catalogItem&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"catalogItem",
      :href=>make_href('query?type=catalogItem&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"catalogItem",
      :href=>make_href('query?type=catalogItem&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"task",
      :href=>make_href('query?type=task&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"task",
      :href=>make_href('query?type=task&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"task",
      :href=>make_href('query?type=task&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"disk",
      :href=>make_href('query?type=disk&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"disk",
      :href=>make_href('query?type=disk&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"disk",
      :href=>make_href('query?type=disk&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"vmDiskRelation",
      :href=>make_href('query?type=vmDiskRelation&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"vmDiskRelation",
      :href=>make_href('query?type=vmDiskRelation&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"service",
      :href=>make_href('query?type=service&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"service",
      :href=>make_href('query?type=service&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"service",
      :href=>make_href('query?type=service&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"orgVdcStorageProfile",
      :href=>make_href('query?type=orgVdcStorageProfile&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"orgVdcStorageProfile",
      :href=>make_href('query?type=orgVdcStorageProfile&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"orgVdcStorageProfile",
      :href=>make_href('query?type=orgVdcStorageProfile&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"apiDefinition",
      :href=>make_href('query?type=apiDefinition&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"apiDefinition",
      :href=>make_href('query?type=apiDefinition&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"apiDefinition",
      :href=>make_href('query?type=apiDefinition&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"fileDescriptor",
      :href=>make_href('query?type=fileDescriptor&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"fileDescriptor",
      :href=>make_href('query?type=fileDescriptor&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"edgeGateway",
      :href=>make_href('query?type=edgeGateway&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"edgeGateway",
      :href=>make_href('query?type=edgeGateway&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"edgeGateway",
      :href=>make_href('query?type=edgeGateway&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"orgVdcNetwork",
      :href=>make_href('query?type=orgVdcNetwork&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"orgVdcNetwork",
      :href=>make_href('query?type=orgVdcNetwork&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"orgVdcNetwork",
      :href=>make_href('query?type=orgVdcNetwork&#38;format=idrecords')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.references+xml",
      :name=>"vAppOrgVdcNetworkRelation",
      :href=>make_href('query?type=vAppOrgVdcNetworkRelation&#38;format=references')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.records+xml",
      :name=>"vAppOrgVdcNetworkRelation",
      :href=>make_href('query?type=vAppOrgVdcNetworkRelation&#38;format=records')},
     {:rel=>"down",
      :type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
      :name=>"vAppOrgVdcNetworkRelation",
      :href=>make_href('query?type=vAppOrgVdcNetworkRelation&#38;format=idrecords')}
    ]
  }
end
disk_body(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_disk.rb, line 66
def disk_body(id)
  disk = data[:disks][id]
  storage_class_id = disk[:vdc_storage_class]

  body = {
    :href => make_href("disk/#{id}"),
    :type => 'application/vnd.vmware.vcloud.disk+xml',
    :id => "urn:vcloud:disk:#{id}",
    :name => disk[:name],
    :status => disk[:status].to_s,
    :busSubType => disk[:bus_sub_type],
    :busType => disk[:bus_type],
    :size => disk[:size].to_s,
    :Link => [
      {
        :href => make_href("vdc/#{disk[:vdc_id]}"),
        :rel => 'up',
        :type => 'application/vnd.vmware.vcloud.vdc+xml'
      }
    ],
    :Description => disk[:description],
    :Tasks => {
      # FIXME: there's only one for now
      :Task => disk[:tasks].map {|task_id| task_body(task_id)}.first
    },
    :Files => {
      :File => []
    },
    :StorageProfile => {
      :href => make_href("vdcStorageProfile/#{storage_class_id}"),
      :name => data[:vdc_storage_classes][storage_class_id][:name],
      :type => 'application/vnd.vmware.vcloud.vdcStorageProfile+xml',
    },
    :Owner => {
      :type => 'application/vnd.vmware.vcloud.owner+xml',
      :User => {
        :href => make_href("admin/user/#{user_uuid}"),
        :name => user_name,
        :type => 'application/vnd.vmware.admin.user+xml',
      }
    }
  }

  if api_version.to_f >= 5.1
    storage_class_id = disk[:vdc_storage_class]
    body[:VdcStorageProfile] = {
      :href => make_href("vdcStorageProfile/#{storage_class_id}"),
      :name => data[:vdc_storage_classes][storage_class_id][:name],
      :type => 'application/vnd.vmware.vcloud.vdcStorageProfile+xml',
    }
  end

  body
end
fetch_items(type, opts) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_execute_query.rb, line 167
def fetch_items(type, opts)
  if opts.key?(:filter) && opts[:filter] =~ /^name==([^;,]+)$/
    name = $1
  elsif type == 'vAppTemplate' && opts.key?(:filter) &&
    opts[:filter] =~ /^name==([^;,]+);catalogName==([^;,]+)$/ #TODO also match in other order
    name = $1
    catalog_name = $2
  elsif opts.key?(:filter)
    Fog::Mock.not_implemented("Complex filters are not yet implemented in get_execute_query Mock for #{type}: #{opts[:filter]}")
  end

  body = {
    :xmlns=>xmlns,
    :xmlns_xsi=>xmlns_xsi,
    :href=>make_href('query'),
    :name=>type,
    :type=>"application/vnd.vmware.vcloud.query.records+xml",
    :xsi_schemaLocation=>xsi_schema_location,
  }

  records = []
  record_type = nil

  if type == 'orgVdc'
    record_type = :OrgVdcRecord
    vdc_id = data[:vdcs].keys[0]
    vdc_name = data[:vdcs][vdc_id][:name]
    records = [{
      :storageUsedMB=>"123967",
      :storageLimitMB=>"8388608",
      :storageAllocationMB=>"0",
      :status=>"READY",
      :orgName=>"orgName",
      :name=>vdc_name,
      :memoryUsedMB=>"0",
      :memoryLimitMB=>"0",
      :memoryAllocationMB=>"0",
      :isSystemVdc=>"false",
      :isEnabled=>"true",
      :isBusy=>"false",
      :href=>make_href("vdc/#{vdc_id}"),
    }]
    body[:page]     = 1.to_s             # TODO: Support pagination
    body[:pageSize] = records.size.to_s  # TODO: Support pagination
    body[:total]    = records.size.to_s
    body[record_type] = records

  elsif type == 'orgVdcNetwork'
    record_type = :OrgVdcNetworkRecords
    data_type = :networks
    data[data_type].each do |id, dr|
      r = {}
      if name.nil? || dr[:name] == name
        vdc_id = dr[:vdc]
        if data[:vdcs][vdc_id] && data[:vdcs][vdc_id].key?(:name)
          r[:vdcName] = data[:vdcs][vdc_id][:name]
        end
        r[:name] = dr[:name]
        r[:vdc]  = make_href("vdc/#{vdc_id}") if vdc_id
        r[:href] = make_href("admin/network/#{id}")
        mapping = {
          :description    => :Description,
          :netmask        => :Netmask,
          :linkType       => :LinkType,
          :dns1           => :Dns1,
          :dns2           => :Dns2,
          :dnsSuffix      => :DnsSuffix,
          :defaultGateway => :Gateway,
          :isShared       => :IsShared,
          :isBusy         => :IsBusy,
          :isIpScopeInherited => :IsIpScopeInherited,
        }

        mapping.each do |k,v|
          r[k] = dr[v] if dr.key?(v)
        end

        records << r
      end
    end
    body[:page]     = 1.to_s             # TODO: Support pagination
    body[:pageSize] = records.size.to_s  # TODO: Support pagination
    body[:total]    = records.size.to_s
    body[record_type] = records

  elsif type == 'edgeGateway'
    record_type = :EdgeGatewayRecord
    edge_gateway_id = data[:edge_gateways].keys[0]
    vdc_id = data[:edge_gateways][edge_gateway_id][:vdc]
    records = [{
      :vdc=>make_href("vdc/#{vdc_id}"),
      :numberOfOrgNetworks=>"1",
      :numberOfExtNetworks=>"1",
      :name=>"Test EdgeGateway Name",
      :isBusy=>"false",
      :haStatus=>"DISABLED",
      :gatewayStatus=>"READY",
      :href=>make_href("edgeGateway/#{edge_gateway_id}"),
      :taskStatus=>"success",
      :taskOperation=>"networkConfigureEdgeGatewayServices",
      :task=>make_href("task/#{uuid}"),
      :taskDetails=>" "
    }]
    body[:page]     = 1.to_s             # TODO: Support pagination
    body[:pageSize] = records.size.to_s  # TODO: Support pagination
    body[:total]    = records.size.to_s
    body[record_type] = records

  elsif type == 'vAppTemplate'
    record_type = :VAappTemplateRecord
    records = [{
      :vdcName=>"Bogus vDC",
      :vdc=>make_href("vdc/#{uuid}"),
      :storageProfileName=>"*",
      :status=>"RESOLVED",
      :ownerName=>"system",
      :org=> make_href("org/#{data[:org][:uuid]}"),
      :name=> name,
      :isPublished=>"true",
      :isGoldMaster=>"false",
      :isExpired=>"false",
      :isEnabled=>"true",
      :isDeployed=>"false",
      :isBusy=>"false",
      :creationDate=>"2013-09-19T22:55:30.257+01:00",
      :catalogName=> catalog_name,
      :href=> make_href("vAppTemplate/vappTemplate-#{uuid}"),
      :honorBootOrder=>"false",
      :isVdcEnabled=>"true",
      :isInCatalog=>"true",
      :cpuAllocationMhz=>"8",
      :cpuAllocationInMhz=>"16000",
      :storageKB=>"52428800",
      :numberOfShadowVMs=>"0",
      :numberOfVMs=>"1",
      :isAutoDeleteNotified=>"false",
      :numberOfCpus=>"8",
      :isAutoUndeployNotified=>"false",
      :memoryAllocationMB=>"32768"
    }]
    body[:page]     = 1.to_s             # TODO: Support pagination
    body[:pageSize] = records.size.to_s  # TODO: Support pagination
    body[:total]    = records.size.to_s
    body[record_type] = records

  elsif type == 'vApp'
    record_type = :VAppRecord
    all_records = data[:vapps].map do |vapp_id, vapp|
      {
        :vdcName => data.fetch(:vdcs).fetch(vapp[:vdc_id]).fetch(:name),
        :vdc => make_href("vdc/#{vapp[:vdc_id]}"),
        :storageProfileName => "*",
        :ownerName => "system",
        :name => vapp.fetch(:name),
        :status => 'POWERED_OFF',
        :isInMaintenanceMode=> 'false',
        :isPublic => 'false',
        :isExpired =>"false",
        :isEnabled =>"true",
        :isDeployed =>"false",
        :isBusy => "false",
        :pvdcHighestSupportedHardwareVersion => '8',
        :lowestHardwareVersionInVApp => '8',
        :creationDate => "2013-09-19T22:55:30.257+01:00",
        :href => make_href("vApp/#{vapp_id}"),
        :honorBootOrder => "false",
        :isVdcEnabled => "true",
        :cpuAllocationMhz => "8",
        :cpuAllocationInMhz => "16000",
        :storageKB => "52428800",
        :numberOfVMs => "1",
        :isAutoDeleteNotified => "false",
        :numberOfCpus => "8",
        :isAutoUndeployNotified => "false",
        :memoryAllocationMB => "32768",
        :task => make_href("task/#{uuid}"),
        :taskStatusName => 'vdcInstantiateVapp',
        :taskStatus => 'success',
        :taskDetails => " ",
      }
    end
    records = all_records.select do |record|
      record[:name] == name
    end

    body[:page]     = 1.to_s             # TODO: Support pagination
    body[:pageSize] = records.size.to_s  # TODO: Support pagination
    body[:total]    = records.size.to_s
    body[record_type] = records

  elsif type == 'task'

    record_type = :TaskRecord
    data_type = :tasks
    data[data_type].each do |id, dr|
      r = {}
      if name.nil? || dr.fetch(:operation_name) == name
        r[:name] = dr.fetch(:operation_name)
        r[:href] = make_href("task/#{id}")
        if dr.key?(:end_time)
          r[:endDate] = dr.fetch(:end_time).strftime('%Y-%m-%dT%H:%M:%S%z')
        else
          r[:endDate] = nil
        end
        if dr.key?(:start_time)
          r[:startDate] = dr.fetch(:start_time).strftime('%Y-%m-%dT%H:%M:%S%z')
        else
          r[:startDate] = nil
        end
        r[:status] = dr.fetch(:status)
        r[:serviceNamespace] = 'com.vmware.vcloud'
        r[:ownerName] = '000.0.000000'
        r[:orgName] = data.fetch(:org).fetch(:name)
        r[:org] = make_href("org/#{data[:org][:uuid]}")
        r[:objectType] = dr.fetch(:owner).fetch(:type).split(/\./).last.split(/\+/).first
        r[:objectName] = dr.fetch(:owner).fetch(:name, '') # objectName is optional
        r[:object] = dr.fetch(:owner).fetch(:href)
        r[:details] = '! []'

        records << r
      end
    end

  else
    Fog::Mock.not_implemented("No 'get by name' get_execute_query Mock for #{type} (#{name})")
  end

  body[:page]     = 1.to_s             # TODO: Support pagination
  body[:pageSize] = records.size.to_s  # TODO: Support pagination
  body[:total]    = records.size.to_s
  body[record_type] = records

  body
end
get_metadata_entries(metadata, id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_vapp_metadata.rb, line 60
def get_metadata_entries(metadata, id)
  metadata_entries = []

  for key, value in metadata do
  metadata_entries << {:type=>"application/vnd.vmware.vcloud.metadata.value+xml",
      :href=>make_href("vApp/#{id}/metadata/#{key}"),
      :Link=>
        [{:rel=>"up",
          :type=>"application/vnd.vmware.vcloud.metadata+xml",
          :href=>make_href("vApp/#{id}/metadata")},
         {:rel=>"edit",
          :type=>"application/vnd.vmware.vcloud.metadata.value+xml",
          :href=>make_href("vApp/#{id}/metadata/#{key}")},
         {:rel=>"remove",
          :href=>make_href("vApp/#{id}/metadata/#{key}")}],
      :Key=>"#{key}",
      :TypedValue=>{:xsi_type=>"MetadataStringValue", :Value=>"#{metadata[key]}"}}
  end
  metadata_entries
end
make_href(path) click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 899
def make_href(path)
  "#{@end_point}#{path}"
end
media_body(id) click to toggle source
# File lib/fog/vcloud_director/requests/compute/get_media.rb, line 51
def media_body(id)
  media = data[:medias][id]

  body = {
    :size => media[:size].to_s,
    :imageType => media[:image_type],
    :status => media[:status].to_s,
    :name => media[:name],
    :id => "urn:vcloud:media:#{id}",
    :type => 'application/vnd.vmware.vcloud.media+xml',
    :href => make_href("media/#{id}"),
    :Link => {
      :href => make_href("vdc/#{media[:vdc_id]}"),
      :type => 'application/vnd.vmware.vcloud.vdc+xml',
      :rel => 'up'
    },
    :Description => media[:description] || '',
    :Tasks => {
      # FIXME: there's only one for now
      :Task => media[:tasks].map {|task_id| task_body(task_id)}.first
    },
    :Files => {
      :File => []
    },
    :Owner => {
      :type => 'application/vnd.vmware.vcloud.owner+xml',
      :User => {
        :href => make_href("admin/user/#{user_uuid}"),
        :name => user_uuid,
        :type => 'application/vnd.vmware.admin.user+xml',
      }
    }
  }

  if media[:status] == 0
    body[:Files][:File] << {
      :size => media[:size].to_s,
      :bytesTransferred => media[:file][:bytes_transferred].to_s,
      :name => 'file',
      :Link=> {
        :href => make_href("transfer/#{media[:file][:uuid]}/file"),
        :rel => 'upload:default'
      }
    }
  end

  if api_version.to_f >= 5.1
    storage_class_id = media[:vdc_storage_class]
    body[:VdcStorageProfile] = {
      :href => make_href("vdcStorageProfile/#{storage_class_id}"),
      :name => data[:vdc_storage_classes][storage_class_id][:name],
      :type => 'application/vnd.vmware.vcloud.vdcStorageProfile+xml',
    }
  end

  body
end
task_body(id) click to toggle source

@param [String] id Object identifier of the task. @return [Hash]

# File lib/fog/vcloud_director/requests/compute/get_task.rb, line 122
def task_body(id)
  task = data[:tasks][id]

  body = {
    :href => make_href("tasks/#{id}"),
    :type => 'application/vnd.vmware.vcloud.task+xml',
    :id => "urn:vcloud:tasl:#{id}",
    :name => task[:name],
    :cancelRequested => task[:cancel_requested].to_s,
    :expiryTime => task[:expiry_time].strftime('%Y-%m-%dT%H:%M:%S%z'),
    :operation => task[:operation],
    :operationName => task[:operation_name],
    :serviceNamespace => task[:service_namespace],
    :status => task[:status],
    :Link => [],
    :Owner => task[:owner],
    :User => { # for now, always the current user
      :href => make_href("admin/user/#{user_uuid}"),
      :name => user_name,
      :type => 'application/vnd.vmware.admin.user+xml',
    },
    :Organization => { # for now, always the current org
      :href => make_href("org/#{data[:org][:uuid]}"),
      :name => data[:org][:name],
      :type => 'application/vnd.vmware.vcloud.org+xml',
    },
    :Progress => task[:progress].to_s,
    :Details => task[:details] || '',
  }
  body[:endTime] = task[:end_time].strftime('%Y-%m-%dT%H:%M:%S%z') if task[:end_time]
  body[:startTime] = task[:start_time].strftime('%Y-%m-%dT%H:%M:%S%z') if task[:start_time]
  body[:Description] = task[:description] if task[:description]

  if task[:status] == 'running'
    body[:Link] << {
      :href => make_href("task/#{id}/action/cancel"),
      :type => 'application/vnd.vmware.vcloud.task+xml',
      :rel => 'cancel',
    }
  end

  body
end
xmlns() click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 903
def xmlns
  'http://www.vmware.com/vcloud/v1.5'
end
xmlns_xsi() click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 907
def xmlns_xsi
  'http://www.w3.org/2001/XMLSchema-instance'
end
xsi_schema_location() click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 911
def xsi_schema_location
  "http://www.vmware.com/vcloud/v1.5 http://#{@host}#{@path}/v1.5/schema/master.xsd"
end