Merge pull request #934 from chirag-jog/master

Update the terremark driver to work with the latest vcloud express 0.8-ext1.6
This commit is contained in:
Wesley Beary 2012-08-12 10:51:02 -07:00
commit 22b6a11218
25 changed files with 639 additions and 66 deletions

View File

@ -1,4 +1,6 @@
require 'rubygems'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'bundler/setup'
require 'date'
require File.dirname(__FILE__) + '/lib/fog'
@ -44,6 +46,7 @@ end
#
#############################################################################
GEM_NAME = "#{name}"
task :default => :test
namespace :test do

View File

@ -0,0 +1,22 @@
require 'fog/core/model'
module Fog
module Terremark
module Shared
class Image < Fog::Model
identity :id
attribute :name
end
private
def href=(new_href)
self.id = new_href.split('/').last.to_i
end
end
end
end

View File

@ -0,0 +1,48 @@
require 'fog/core/collection'
require 'fog/terremark/models/shared/image'
module Fog
module Terremark
module Shared
module Mock
def images(options = {})
Fog::Terremark::Shared::Images.new(options.merge(:connection => self))
end
end
module Real
def images(options = {})
Fog::Terremark::Shared::Images.new(options.merge(:connection => self))
end
end
class Images < Fog::Collection
model Fog::Terremark::Shared::Image
def all
data = connection.get_catalog(vdc_id).body['CatalogItems'].select do |entity|
entity['type'] == "application/vnd.vmware.vcloud.catalogItem+xml"
end
load(data)
end
def vdc_id
@vdc_id ||= connection.default_vdc_id
end
private
def vdc_id=(new_vdc_id)
@vdc_id = new_vdc_id
end
end
end
end
end

View File

@ -0,0 +1,67 @@
require 'fog/core/model'
module Fog
module Terremark
module Shared
class InternetService < Fog::Model
identity :Id
attribute :Name
attribute :Port
attribute :Protocol
attribute :Description
attribute :PublicIpAddress
attribute :public_ip_address_id
def destroy(delete_public_ip=true)
connection.delete_internet_service(self.Id)
connection.delete_public_ip(self.PublicIpAddress["Id"]) if delete_public_ip
true
end
def save
requires :Name, :Protocol, :Port
if not public_ip_address_id
#Create the first internet service and allocate public IP
data = connection.create_internet_service(
vdc = connection.default_vdc_id,
name = self.Name,
protocol = self.Protocol,
port = self.Port,
options = {
'Enabled' => 'true',
"Description" => self.Name
}
)
else
#create additional services to existing Public IP
data = connection.add_internet_service(
ip_id = public_ip_address_id,
name = self.Name,
protocol = self.Protocol,
port = self.Port,
options = {
'Enabled' => 'true',
"Description" => self.Name
}
)
end
merge_attributes(data.body)
true
end
private
def href=(new_href)
self.id = new_href.split('/').last.to_i
end
def type=(new_type); @type = new_type; end
def size=(new_size); @size = new_size; end
def Links=(new_links); @Links = new_links; end
end
end
end
end

View File

@ -0,0 +1,42 @@
require 'fog/core/collection'
require 'fog/terremark/models/shared/internetservice'
module Fog
module Terremark
module Shared
module Mock
def internetservices(options = {})
Fog::Terremark::Shared::Servers.new(options.merge(:connection => self))
end
end
module Real
def internetservices(options = {})
Fog::Terremark::Shared::InternetServices.new(options.merge(:connection => self))
end
end
class InternetServices < Fog::Collection
model Fog::Terremark::Shared::InternetService
def all
data = connection.get_internet_services(vdc_id).body["InternetServices"]
load(data)
end
def get(service_id)
data = connection.get_internet_services(vdc_id)
internet_service = services.body["InternetServices"].select {|item| item["Id"] == service_id}
new(internetservice)
end
def vdc_id
@vdc_id ||= connection.default_vdc_id
end
end
end
end
end

View File

@ -0,0 +1,52 @@
require 'fog/core/model'
module Fog
module Terremark
module Shared
class NodeService < Fog::Model
identity :Id
attribute :Name
attribute :Href
attribute :Port
attribute :Description
attribute :IpAddress
attribute :Enabled
attribute :InternetServiceId
def destroy
connection.delete_node_service(self.Id)
end
def save
requires :Name, :Port, :InternetServiceId
data = connection.add_node_service(
service_id = self.InternetServiceId,
ip = self.IpAddress,
name = self.Name,
port = self.Port,
options = {"Enabled" => 'true',
"Description" => self.Name,
}
)
merge_attributes(data.body)
true
end
private
def href=(new_href)
self.id = new_href.split('/').last.to_i
end
def type=(new_type); @type = new_type; end
def size=(new_size); @size = new_size; end
def Links=(new_links); @Links = new_links; end
end
end
end
end

View File

@ -0,0 +1,32 @@
require 'fog/core/collection'
require 'fog/terremark/models/shared/nodeservice'
module Fog
module Terremark
module Shared
module Mock
def nodeservices(options = {})
Fog::Terremark::Shared::Servers.new(options.merge(:connection => self))
end
end
module Real
def nodeservices(options = {})
Fog::Terremark::Shared::NodeServices.new(options.merge(:connection => self))
end
end
class NodeServices < Fog::Collection
model Fog::Terremark::Shared::NodeService
def all(internet_service_id)
data = connection.get_node_services(internet_service_id).body["NodeServices"]
load(data)
end
end
end
end
end

View File

@ -1,4 +1,15 @@
require 'fog/core/model'
require 'fog/terremark/models/shared/nodeservices'
require 'fog/terremark/models/shared/internetservices'
# { '0' => 'Being created', '1' => 'Being Deployed, '2' => 'Powered Off', '4' => 'Powered On'}
module VAppStatus
BEING_CREATED = "0"
BEING_DEPLOYED = "1"
POWERED_OFF = "2"
POWERED_ON = "4"
end
module Fog
module Terremark
@ -9,30 +20,68 @@ module Fog
identity :id
attribute :name
attribute :image
attribute :vcpus
attribute :memory
attribute :sshkeyFingerPrint
attribute :powerOn
attribute :status
attribute :OperatingSystem
attribute :VirtualHardware
attribute :IpAddress
def reload
merge_attributes(connection.get_vapp(id).body)
end
def destroy
requires :id
data = connection.power_off(id).body
task = connection.tasks.new(data)
task.wait_for { ready? }
connection.delete_vapp(id)
case self.status
when VAppStatus::BEING_CREATED, VAppStatus::BEING_DEPLOYED
return false
when VAppStatus::POWERED_ON
data = connection.power_off(self.id).body
wait_for { off? }
end
connection.delete_vapp(self.id)
true
end
def PublicIpAddress
@PublicIpAddress ||=
if internet_services.size > 0
internet_services[0].PublicIpAddress["Name"]
end
@PublicIpAddress
end
def internet_services
@internet_services ||= connection.internetservices.all.select {|item| item.Name == self.name}
end
def delete_internet_services
#Find the internet service
while (service = internet_services.pop) do
nodes = connection.nodeservices.all(service.Id)
#Delete all the associated nodes
nodes.select { |item| item.destroy }
#Clear out the services
service.destroy(delete_public_ip = !(internet_services.size > 0))
end
true
end
# { '0' => 'Being created', '2' => 'Powered Off', '4' => 'Powered On'}
def ready?
status == '2'
status == VAppStatus::POWERED_OFF
end
def on?
status == '4'
status == VAppStatus::POWERED_ON
end
def off?
status == '2'
status == VAppStatus::POWERED_OFF
end
def power_on(options = {})
@ -81,14 +130,66 @@ module Fog
power_on
end
def create_internet_services(internet_spec)
public_ip_info = nil
internet_service_id = nil
internet_spec.each do |proto, ports|
for port in ports
if not public_ip_info
#Create the first internet service and allocate public IP
inet_services = connection.internetservices.create({
"Name" => self.name,
"Protocol" => proto,
"Port" => port,
})
internet_service_id = inet_services.Id
public_ip_info = inet_services.PublicIpAddress
else
#create additional services to existing Public IP
inet_services = connection.internetservices.create({
"public_ip_address_id" => public_ip_info["Id"],
"Name" => self.name,
"Protocol" => proto,
"Port" => port,
}
)
internet_service_id = inet_services.Id
end
#Create the associate node service to the server
connection.nodeservices.create({"Name" => self.name,
"IpAddress" => self.IpAddress,
"Port" => port,
"InternetServiceId" => internet_service_id
})
end
end
true
end
def save
requires :name
data = connection.instantiate_vapp(name)
if powerOn
end
data = connection.instantiate_vapp_template(
server_name=name,
vapp_template=image,
options={
'ssh_key_fingerprint' => sshkeyFingerPrint,
'cpus' => vcpus,
'memory' => memory
})
merge_attributes(data.body)
task = connection.deploy_vapp(id)
task.wait_for { ready? }
task = connection.power_on(id)
task.wait_for { ready? }
wait_for { ready? }
#Optional, incase further configuration required.
if powerOn
power_on
wait_for { ready? }
end
true
end
@ -100,11 +201,9 @@ module Fog
def type=(new_type); @type = new_type; end
def size=(new_size); @size = new_size; end
def IpAddress=(new_ipaddress); @IpAddress = new_ipaddress; end
def Links=(new_links); @Links = new_links; end
end
end
end
end

View File

@ -22,20 +22,19 @@ module Fog
model Fog::Terremark::Shared::Server
def all
data = connection.get_vdc(vdc_id).body['ResourceEntities'].select do |entity|
entity['type'] == 'application/vnd.vmware.vcloud.vApp+xml'
data = []
connection.get_vdc(vdc_id).body['ResourceEntities'].select do |entity|
data << connection.servers.get(entity["href"].split('/').last)
end
load(data)
data
end
def get(server_id)
if server_id && server = connection.get_vapp(server_id).body
new(server)
elsif !server_id
if server_id
new(connection.get_vapp(server_id).body)
else
nil
end
rescue Excon::Errors::Forbidden
nil
end
def vdc_id

View File

@ -9,7 +9,9 @@ module Fog
identity :id
attribute :name
attribute :ResourceEntities
attribute :AvailableNetworks
attribute :links
def networks
connection.networks(:vdc_id => id)
end
@ -22,6 +24,9 @@ module Fog
connection.servers(:vdc_id => id)
end
def images
connection.images(:vdc_id => id)
end
private
def href=(new_href)

View File

@ -14,8 +14,13 @@ module Fog
case name
when 'CatalogItem'
catalog_item = {}
until attributes.empty?
catalog_item[attributes.shift] = attributes.shift
attributes.each do |attrib|
i = 0
while i < attrib.size
catalog_item[attrib[i]] = attrib[i+1]
i += 2
end
catalog_item["id"] = catalog_item["href"].split('/').last
end
@response['CatalogItems'] << catalog_item
when 'Catalog'

View File

@ -0,0 +1,56 @@
module Fog
module Parsers
module Terremark
module Shared
class GetKeysList < Fog::Parsers::Base
def reset
@response = { 'Keys' => [] }
@key = {}
end
def start_element(name, attributes)
super
case name
when 'Id', 'Href', 'Name', 'IsDefault','FingerPrint'
data = {}
until attributes.empty?
data[attributes.shift] = attributes.shift
end
@key[name] = data
when 'Key'
until attributes.empty?
@key[attributes.shift] = attributes.shift
end
when 'Keys'
keys_list = {}
until attributes.empty?
if attributes.first.is_a?(Array)
attribute = attributes.shift
keys_list[attribute.first] = attribute.last
else
keys_list[attributes.shift] = attributes.shift
end
end
@response['href'] = keys_list['href']
end
end
def end_element(name)
case name
when 'Id', 'Href', 'Name', 'IsDefault','FingerPrint'
@key[name] = value
when 'Key'
@response['Keys'] << @key
@key = {}
end
end
end
end
end
end
end

View File

@ -31,21 +31,22 @@ module Fog
options['Enabled'] = true
end
data = <<-DATA
<InternetService xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:tmrk:vCloudExpress-1.0:request:createInternetService">
<Name>#{name}</Name>
<Protocol>#{protocol.upcase}</Protocol>
<Port>#{port}</Port>
<Enabled>#{options['Enabled']}</Enabled>
<Description>#{options['Description']}</Description>
</InternetService>
DATA
<CreateInternetServiceRequest xml:lang="en" xmlns="urn:tmrk:vCloudExpressExtensions-1.6" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>#{name}</Name>
<Protocol>#{protocol.upcase}</Protocol>
<Port>#{port}</Port>
<Enabled>#{options['Enabled']}</Enabled>
<Description>#{options['Description']}</Description>
</CreateInternetServiceRequest>
DATA
request(
:body => data,
:expects => 200,
:headers => {'Content-Type' => 'application/xml'},
:method => 'POST',
:parser => Fog::Parsers::Terremark::Shared::InternetService.new,
:path => "publicIps/#{ip_id}/internetServices"
:path => "api/extensions/v1.6/publicIp/#{ip_id}/internetServices",
:override_path => true
)
end

View File

@ -30,23 +30,21 @@ module Fog
unless options.has_key?('Enabled')
options['Enabled'] = true
end
data = <<-DATA
<NodeService xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:tmrk:vCloudExpress-1.0:request:createNodeService">
<IpAddress>#{ip}</IpAddress>
<Name>#{name}</Name>
<Port>#{port}</Port>
<Enabled>#{options['Enabled']}</Enabled>
<Description>#{options['Description']}</Description>
</NodeService>
DATA
request(
<CreateNodeServiceRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:tmrk:vCloudExpressExtensions-1.6"><IpAddress>#{ip}</IpAddress><Name>#{name}</Name><Port>#{port}</Port><Enabled>#{options['Enabled']}</Enabled><Description>#{options['Description']}</Description></CreateNodeServiceRequest>
DATA
response = request(
:body => data,
:expects => 200,
:headers => {'Content-Type' => 'application/xml'},
:headers => {'Content-Type' => 'application/vnd.tmrk.vCloud.nodeService+xml'},
:method => 'POST',
:parser => Fog::Parsers::Terremark::Shared::InternetService.new,
:path => "internetServices/#{service_id}/nodes"
:parser => Fog::Parsers::Terremark::Shared::NodeService.new,
:path => "api/extensions/v1.6/internetService/#{service_id}/nodeServices",
:override_path => true
)
response
end
end

View File

@ -0,0 +1,61 @@
module Fog
module Terremark
module Shared
module Real
include Common
def configure_vapp(vapp_id, vapp_name, options = {})
items = ""
vapp_uri = [@host, @path, "vApp", vapp_id.to_s].join("/")
if options['vcpus']
vcpu_item = <<-DATA
<Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"> <InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">#{options['vcpus']}</VirtualQuantity></Item>
DATA
items << vcpu_item
end
if options['memory']
memory_item = <<-DATA
<Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">2</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">4</ResourceType>38<VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">#{options['memory']}</VirtualQuantity></Item>
DATA
items << memory_item
end
#Default root disk
virtual_disk_item = <<-DATA
<Item>
<AddressOnParent xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">0</AddressOnParent> <HostResource xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1048576</HostResource><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">9</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">17</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1048576</VirtualQuantity></Item>
DATA
items << virtual_disk_item
#Additional disks
if options['virtual_disks']
for disk in options['virtual_disks']
actual_size = disk.to_i * 1024 * 1024
virtual_disk_item = <<-DATA
<Item>
<AddressOnParent xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">-1</AddressOnParent><HostResource xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">#{actual_size}</HostResource><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">9</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">17</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">#{actual_size}</VirtualQuantity></Item>
DATA
items << virtual_disk_item
end
end
data = <<-DATA
<VApp href="#{vapp_uri}" type="application/vnd.vmware.vcloud.vApp+xml" name="#{vapp_name}" status="2" size="10485760" xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<VirtualHardwareSection xmlns="http://schemas.dmtf.org/ovf/envelope/1"><Info>Virtual Hardware</Info>#{items}
</VirtualHardwareSection>
</VApp>
DATA
request(
:body => data,
:expects => 202,
:headers => { 'Content-Type' => 'application/vnd.vmware.vCloud.vApp+xml' },
:method => 'PUT',
:path => "vapp/#{vapp_id}"
)
end
end
end
end
end

View File

@ -2,6 +2,7 @@ module Fog
module Terremark
module Shared
module Real
include Common
# Reserve requested resources and deploy vApp
#
@ -30,23 +31,27 @@ module Fog
unless options.has_key?('Enabled')
options['Enabled'] = true
end
#Sample: "https://services.vcloudexpress.terremark.com/api/extensions/v1.6/vdc/3142/internetServices"
path = vdcs.get(vdc_id).links.find { |item| item['name'] == 'Internet Services'}['href'].split(@host)[1]
data = <<-DATA
<InternetService xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:tmrk:vCloudExpress-1.0:request:createInternetService">
<Name>#{name}</Name>
<Protocol>#{protocol.upcase}</Protocol>
<Port>#{port}</Port>
<Enabled>#{options['Enabled']}</Enabled>
<Description>#{options['Description']}</Description>
</InternetService>
DATA
request(
<CreateInternetServiceRequest xml:lang="en" xmlns="urn:tmrk:vCloudExpressExtensions-1.6" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>#{name}</Name>
<Protocol>#{protocol.upcase}</Protocol>
<Port>#{port}</Port>
<Enabled>#{options['Enabled']}</Enabled>
<Description>#{options['Description']}</Description>
</CreateInternetServiceRequest>
DATA
response = request(
:body => data,
:expects => 200,
:headers => {'Content-Type' => 'application/xml'},
:headers => {'Content-Type' => 'application/vnd.tmrk.vCloud.internetService+xml'},
:method => 'POST',
:parser => Fog::Parsers::Terremark::Shared::InternetService.new,
:path => "vdc/#{vdc_id}/internetServices"
:path => path,
:override_path => true
)
response
end
end

View File

@ -12,7 +12,8 @@ module Fog
request(
:expects => 200,
:method => 'DELETE',
:path => "InternetServices/#{internet_service_id}"
:path => "api/extensions/v1.6/internetService/#{internet_service_id}",
:override_path => true
)
end

View File

@ -12,7 +12,8 @@ module Fog
request(
:expects => 200,
:method => 'DELETE',
:path => "nodeServices/#{node_service_id}"
:path => "api/extensions/v1.6/nodeService/#{node_service_id}",
:override_path => true
)
end

View File

@ -12,7 +12,8 @@ module Fog
request(
:expects => 200,
:method => 'DELETE',
:path => "publicIps/#{public_ip_id}"
:path => "api/extensions/v1.6/publicIp/#{public_ip_id}",
:override_path => true
)
end

View File

@ -25,7 +25,8 @@ module Fog
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Terremark::Shared::GetInternetServices.new,
:path => "vdc/#{vdc_id}/internetServices"
:path => "api/extensions/v1.6/vdc/#{vdc_id}/internetServices",
:override_path => true
)
end

View File

@ -0,0 +1,36 @@
module Fog
module Terremark
module Shared
module Real
include Common
# Get list of SSH keys for an organization
#
# ==== Parameters
# * organization_id<~Integer> - Id of organization to lookup
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'description'<~String> - Description of organization
# * 'links'<~Array> - An array of links to entities in the organization
# * 'href'<~String> - location of link
# * 'name'<~String> - name of link
# * 'rel'<~String> - action to perform
# * 'type'<~String> - type of link
def get_keys_list(organization_id)
response = request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Terremark::Shared::GetKeysList.new,
:path => "api/extensions/v1.6/org/#{organization_id}/keys",
:override_path => true
)
response
end
end
end
end
end

View File

@ -20,7 +20,8 @@ module Fog
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Terremark::Shared::GetNodeServices.new,
:path => "InternetServices/#{service_id}/nodes"
:path => "api/extensions/v1.6/internetService/#{service_id}/nodeServices",
:override_path => true
)
end

View File

@ -23,17 +23,27 @@ module Fog
unless name.length < 15
raise ArgumentError.new('Name must be fewer than 15 characters')
end
unless vapp_template
raise ArgumentError.new("vApp Image Template is a compulsary parameter")
end
options['ssh_key_fingerprint'] ||= default_ssh_key["FingerPrint"]
options['cpus'] ||= 1
options['memory'] ||= 512
options['network_id'] ||= default_network_id
options['vdc_id'] ||= default_vdc_id
options['primary_dns'] ||= '208.67.222.222'
options['secondary_dns'] ||= '208.67.220.220'
data = <<-DATA
<?xml version="1.0" encoding="UTF-8"?>
<InstantiateVAppTemplateParams name="#{name}" xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 http://services.vcloudexpress.terremark.com/api/v0.8/ns/vcloud.xsd">
<VAppTemplate href="#{@scheme}://#{@host}/#{@path}/vAppTemplate/#{vapp_template}" />
<InstantiationParams xmlns:vmw="http://www.vmware.com/schema/ovf">
<ProductSection xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:q1="http://www.vmware.com/vcloud/v0.8"/>
<ProductSection xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:q1="http://www.vmware.com/vcloud/v0.8">
<Property xmlns="http://schemas.dmtf.org/ovf/envelope/1" ovf:key="primaryDNS" ovf:value="#{options['primary_dns']}" />
<Property xmlns="http://schemas.dmtf.org/ovf/envelope/1" ovf:key="secondaryDNS" ovf:value="#{options['secondary_dns']}" />
<Property xmlns="http://schemas.dmtf.org/ovf/envelope/1" ovf:key="sshKeyFingerprint" ovf:value="#{options['ssh_key_fingerprint']}" />
</ProductSection>
<VirtualHardwareSection xmlns:q1="http://www.vmware.com/vcloud/v0.8">
<Item xmlns="http://schemas.dmtf.org/ovf/envelope/1">
<InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</InstanceID>

View File

@ -72,6 +72,15 @@ module Fog
if @cookie
headers.merge!('Cookie' => @cookie)
end
if params[:path]
if params[:override_path] == true
path = params[:path]
else
path = "#{@path}/#{params[:path]}"
end
else
path = "#{@path}"
end
@connection.request({
:body => params[:body],
:expects => params[:expects],
@ -79,7 +88,7 @@ module Fog
:host => @host,
:method => params[:method],
:parser => params[:parser],
:path => "#{@path}/#{params[:path]}"
:path => path
})
end
@ -236,10 +245,16 @@ module Fog
require 'fog/terremark/models/shared/networks'
require 'fog/terremark/models/shared/server'
require 'fog/terremark/models/shared/servers'
require 'fog/terremark/models/shared/image'
require 'fog/terremark/models/shared/images'
require 'fog/terremark/models/shared/task'
require 'fog/terremark/models/shared/tasks'
require 'fog/terremark/models/shared/vdc'
require 'fog/terremark/models/shared/vdcs'
require 'fog/terremark/models/shared/internetservice'
require 'fog/terremark/models/shared/internetservices'
require 'fog/terremark/models/shared/nodeservice'
require 'fog/terremark/models/shared/nodeservices'
require 'fog/terremark/parsers/shared/get_catalog'
require 'fog/terremark/parsers/shared/get_catalog_item'
require 'fog/terremark/parsers/shared/get_internet_services'
@ -249,6 +264,7 @@ module Fog
require 'fog/terremark/parsers/shared/get_organizations'
require 'fog/terremark/parsers/shared/get_public_ips'
require 'fog/terremark/parsers/shared/get_tasks_list'
require 'fog/terremark/parsers/shared/get_keys_list'
require 'fog/terremark/parsers/shared/get_vapp_template'
require 'fog/terremark/parsers/shared/get_vdc'
require 'fog/terremark/parsers/shared/instantiate_vapp_template'
@ -278,10 +294,12 @@ module Fog
require 'fog/terremark/requests/shared/get_public_ips'
require 'fog/terremark/requests/shared/get_task'
require 'fog/terremark/requests/shared/get_tasks_list'
require 'fog/terremark/requests/shared/get_keys_list'
require 'fog/terremark/requests/shared/get_vapp'
require 'fog/terremark/requests/shared/get_vapp_template'
require 'fog/terremark/requests/shared/get_vdc'
require 'fog/terremark/requests/shared/instantiate_vapp_template'
require 'fog/terremark/requests/shared/configure_vapp'
require 'fog/terremark/requests/shared/power_off'
require 'fog/terremark/requests/shared/power_on'
require 'fog/terremark/requests/shared/power_reset'

View File

@ -7,7 +7,8 @@ module Fog
module Defaults
HOST = 'services.vcloudexpress.terremark.com'
PATH = '/api/v0.8'
PATH = '/api/v0.8a-ext1.6'
#PATH = '/api/'
PORT = 443
SCHEME = 'https'
end
@ -96,6 +97,14 @@ module Fog
end
end
def default_ssh_key
if default_ssh_key
@default_ssh_key ||= begin
keys = get_keys_list(default_organization_id).body["Keys"]
keys.find { |item| item["IsDefault"] == "true" }
end
end
end
class Mock
include Fog::Terremark::Shared::Mock
include Fog::Terremark::Shared::Parser