1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

fixes for vcloud to match up with new stuff

This commit is contained in:
geemus 2010-09-14 10:40:02 -07:00
parent 2c349c1adb
commit 4076bbaec5
69 changed files with 303 additions and 277 deletions

View file

@ -17,6 +17,7 @@ module Fog
def modules
[
::AWS,
::Bluebox,
::GoGrid,
::Linode,
::Local,
@ -24,10 +25,8 @@ module Fog
::Rackspace,
::Slicehost,
::Terremark,
::Vcloud,
::Bluebox
::Vcloud
].select {|_module_| _module_.initialized?}
end
end

View file

@ -52,12 +52,28 @@ module Fog
end
end
setup_requirements
if Fog.mocking?
service::Mock.send(:include, service::Collections)
service::Mock.new(options)
else
service::Real.send(:include, service::Collections)
service::Real.new(options)
end
end
def setup_requirements
if superclass.respond_to?(:setup_requirements)
superclass.setup_requirements
end
unless @required
for collection in collections
require [@model_path, collection].join('/')
constant = collection.to_s.split('_').map {|characters| characters[0...1].upcase << characters[1..-1]}.join('')
service::Collections.module_eval <<-EOS, __FILE__, __LINE__
def #{collection}(attributes={})
def #{collection}(attributes = {})
#{service}::#{constant}.new({:connection => self}.merge(attributes))
end
EOS
@ -70,12 +86,6 @@ module Fog
end
@required = true
end
if Fog.mocking?
service::Mock.new(options)
else
service::Real.new(options)
end
end
def model_path(new_path)

View file

@ -1,10 +1,8 @@
require 'fog/vcloud/service'
require 'builder'
require 'fog/vcloud/model'
require 'fog/vcloud/collection'
require 'fog/vcloud/generators'
require 'fog/vcloud/terremark/ecloud'
require 'fog/vcloud/terremark/vcloud'
# ecloud/vcloud requires at the bottom so that the following will be defined
module URI
class Generic
@ -21,7 +19,7 @@ module Fog
model_path 'fog/vcloud/models'
model :vdc
model :vdcs
collection :vdcs
request_path 'fog/vcloud/requests'
request :login
@ -32,7 +30,55 @@ module Fog
class UnsupportedVersion < Exception ; end
module Shared
def default_organization_uri
@default_organization_uri ||= begin
unless @login_results
do_login
end
case @login_results.body[:Org]
when Array
@login_results.body[:Org].first[:href]
when Hash
@login_results.body[:Org][:href]
else
nil
end
end
end
# login handles the auth, but we just need the Set-Cookie
# header from that call.
def do_login
@login_results = login
@cookie = @login_results.headers['Set-Cookie']
end
def supported_versions
@supported_versions ||= get_versions(@versions_uri).body[:VersionInfo]
end
def xmlns
{ "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" }
end
# private
def ensure_unparsed(uri)
if uri.is_a?(String)
uri
else
uri.to_s
end
end
end
class Real
include Shared
extend Fog::Vcloud::Generators
attr_accessor :login_uri
@ -68,12 +114,6 @@ module Fog
end
end
def xmlns
{ "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" }
end
def reload
@connections.each_value { |k,v| v.reset if v }
end
@ -93,10 +133,6 @@ module Fog
end
end
def supported_versions
@supported_versions ||= get_versions(@versions_uri).body[:VersionInfo]
end
private
def ensure_parsed(uri)
@ -107,14 +143,6 @@ module Fog
end
end
def ensure_unparsed(uri)
if uri.is_a?(String)
uri
else
uri.to_s
end
end
def supported_version_numbers
case supported_versions
when Array
@ -218,7 +246,9 @@ module Fog
end
end
class Mock < Real
class Mock
include Shared
def self.base_url
"https://fakey.com/api/v0.8"
end
@ -349,7 +379,7 @@ module Fog
end
end
def initialize(credentials = {})
def initialize(options = {})
@versions_uri = URI.parse('https://vcloud.fakey.com/api/versions')
end
@ -383,3 +413,6 @@ module Fog
end
end
end
require 'fog/vcloud/terremark/ecloud'
require 'fog/vcloud/terremark/vcloud'

View file

@ -1,5 +1,5 @@
module Fog
class Vcloud
class Vcloud < Fog::Service
class Collection < Fog::Collection
def load(objects)

View file

@ -1,5 +1,5 @@
module Fog
class Vcloud
class Vcloud < Fog::Service
module Generators
def unauthenticated_basic_request(*args)

View file

@ -1,5 +1,5 @@
module Fog
class Vcloud
class Vcloud < Fog::Service
class Model < Fog::Model
attr_accessor :loaded

View file

@ -1,12 +1,7 @@
require 'fog/vcloud/models/vdc'
module Fog
class Vcloud
class Real
def vdcs(options = {})
@vdcs ||= Fog::Vcloud::Vdcs.new(options.merge(:connection => self))
end
end
class Vdcs < Fog::Vcloud::Collection
model Fog::Vcloud::Vdc
@ -36,6 +31,5 @@ module Fog
end
end
end
end

View file

@ -1,28 +0,0 @@
module Fog
class Vcloud < Fog::Service
class Service < Fog::Service
class << self
@versions = []
def inherited(child)
super
child.class_eval <<-EOS, __FILE__, __LINE__
module #{child}::Real
extend Fog::Vcloud::Generators
end
module #{child}::Mock
end
EOS
child.extend(child::Real)
if Fog.mocking?
child.extend(child::Mock)
end
end
end
end
end
end

View file

@ -1,29 +1,29 @@
module Fog
class Vcloud
module Terremark
class Ecloud < Fog::Vcloud::Service
class Ecloud < Fog::Vcloud
model_path 'fog/vcloud/terremark/ecloud/models'
model :catalog_item
model :catalog
model :firewall_acl
model :firewall_acls
collection :firewall_acls
model :internet_service
model :internet_services
collection :internet_services
model :ip
model :ips
collection :ips
model :network
model :networks
collection :networks
model :node
model :nodes
collection :nodes
model :public_ip
model :public_ips
collection :public_ips
model :server
model :servers
collection :servers
model :task
model :tasks
collection :tasks
model :vdc
model :vdcs
collection :vdcs
request_path 'fog/vcloud/terremark/ecloud/requests'
request :add_internet_service
@ -62,7 +62,12 @@ module Fog
request :power_reset
request :power_shutdown
module Mock
class Mock < Fog::Vcloud::Mock
include Collections
def initialize(options={})
end
def self.base_url
"https://fakey.com/api/v0.8b-ext2.3"
end
@ -186,10 +191,13 @@ module Fog
end
end
module Real
class Real < Fog::Vcloud::Real
include Collections
def supporting_versions
["v0.8b-ext2.3", "0.8b-ext2.3"]
end
end
end

View file

@ -1,7 +1,7 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class Catalog < Fog::Vcloud::Collection

View file

@ -1,10 +1,10 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class CatalogItem < Fog::Vcloud::Model
identity :href, :Href
identity :href, :aliases => :Href
ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd

View file

@ -1,10 +1,10 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class FirewallAcl < Fog::Vcloud::Model
identity :href, :Href
identity :href, :aliases => :Href
ignore_attributes :xmlns, :xmlns_i

View file

@ -1,7 +1,9 @@
require 'lib/fog/vcloud/terremark/ecloud/models/firewall_acl'
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class FirewallAcls < Fog::Vcloud::Collection

View file

@ -1,10 +1,10 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class InternetService < Fog::Vcloud::Model
identity :href, :Href
identity :href, :aliases => :Href
ignore_attributes :xmlns, :xmlns_i
@ -35,7 +35,7 @@ module Fog
end
def monitor=(new_monitor = {})
if new_monitor.nil?
if new_monitor.nil? || new_monitor.empty?
@monitor = nil
elsif new_monitor.is_a?(Hash)
@monitor = {}

View file

@ -1,13 +1,9 @@
require 'lib/fog/vcloud/terremark/ecloud/models/internet_service'
module Fog
class Vcloud
module Terremark
module Ecloud
module Real
def internet_services(options = {})
@internet_services ||= Fog::Vcloud::Terremark::Ecloud::InternetServices.new(options.merge(:connection => self))
end
end
class Ecloud
class InternetServices < Fog::Vcloud::Collection

View file

@ -1,14 +1,14 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class Ip < Fog::Vcloud::Model
ignore_attributes :xmlns_i, :xmlns
identity :href, :Href
identity :href, :aliases => :Href
attribute :name, :Name
attribute :name, :aliases => :Name
attribute :status, :aliases => :Status
attribute :server, :aliases => :Server
attribute :rnat, :aliases => :RnatAddress

View file

@ -1,7 +1,9 @@
require 'lib/fog/vcloud/terremark/ecloud/models/ip'
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class Ips < Fog::Vcloud::Collection

View file

@ -1,7 +1,7 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class Network < Fog::Vcloud::Model
identity :href

View file

@ -1,13 +1,9 @@
require 'lib/fog/vcloud/terremark/ecloud/models/network'
module Fog
class Vcloud
module Terremark
module Ecloud
module Real
def networks(options = {})
@networks ||= Fog::Vcloud::Terremark::Ecloud::Networks.new(options.merge(:connection => self))
end
end
class Ecloud
class Networks < Fog::Vcloud::Collection

View file

@ -1,10 +1,10 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class Node < Fog::Vcloud::Model
identity :href, :Href
identity :href, :aliases => :Href
ignore_attributes :xmlns, :xmlns_i

View file

@ -1,7 +1,9 @@
require 'lib/fog/vcloud/terremark/ecloud/models/node'
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class Nodes < Fog::Vcloud::Collection

View file

@ -1,10 +1,10 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class PublicIp < Fog::Vcloud::Model
identity :href, :Href
identity :href, :aliases => :Href
ignore_attributes :xmlns, :xmlns_i

View file

@ -1,19 +1,9 @@
require 'lib/fog/vcloud/terremark/ecloud/models/public_ip'
module Fog
class Vcloud
module Terremark
module Ecloud
module Mock
def public_ips(options = {})
@public_ips ||= Fog::Vcloud::Terremark::Ecloud::PublicIps.new(options.merge(:connection => self))
end
end
module Real
def public_ips(options = {})
@public_ips ||= Fog::Vcloud::Terremark::Ecloud::PublicIps.new(options.merge(:connection => self))
end
end
class Ecloud
class PublicIps < Fog::Vcloud::Collection

View file

@ -1,10 +1,10 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class Server < Fog::Vcloud::Model
identity :href, :Href
identity :href, :aliases => :Href
ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd
@ -14,7 +14,7 @@ module Fog
attribute :network_connections, :aliases => :NetworkConnectionSection, :squash => :NetworkConnection
attribute :os, :aliases => :OperatingSystemSection
attribute :virtual_hardware, :aliases => :VirtualHardwareSection
attribute :storage_size, :size
attribute :storage_size, :aliases => :size
attribute :links, :aliases => :Link, :type => :array
def friendly_status

View file

@ -1,7 +1,9 @@
require 'lib/fog/vcloud/terremark/ecloud/models/server'
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class Servers < Fog::Vcloud::Collection

View file

@ -1,10 +1,10 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class Task < Fog::Vcloud::Model
identity :href, :Href
identity :href, :aliases => :Href
ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd

View file

@ -1,7 +1,9 @@
require 'lib/fog/vcloud/terremark/ecloud/models/task'
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class Tasks < Fog::Vcloud::Collection

View file

@ -1,7 +1,7 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
class Vdc < Fog::Vcloud::Model
identity :href

View file

@ -1,28 +1,38 @@
require 'lib/fog/vcloud/terremark/ecloud/models/vdc'
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
def vdcs(options = {})
@vdcs ||= Fog::Vcloud::Terremark::Ecloud::Vdcs.new(options.merge(:connection => self))
end
end
#FIXME: Should be no need to do this ... duplicte code ... find a better way
module Mock
def vdcs(options = {})
@vdcs ||= Fog::Vcloud::Terremark::Ecloud::Vdcs.new(options.merge(:connection => self))
end
end
#/FIXME
class Vdcs < Fog::Vcloud::Vdcs
undef_method :create
class Vdcs < Collection
model Fog::Vcloud::Terremark::Ecloud::Vdc
def all
data = connection.get_organization(organization_uri).body[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.vdc+xml" }
data.each { |link| link.delete_if { |key, value| [:rel].include?(key) } }
load(data)
end
def get(uri)
if data = connection.get_vdc(uri)
new(data.body)
end
rescue Fog::Errors::NotFound
nil
end
def organization_uri
@organizatio_uri ||= connection.default_organization_uri
end
private
def organization_uri=(new_organization_uri)
@organization_uri = new_organization_uri
end
end
end
end

View file

@ -1,8 +1,8 @@
module Fog
class Vcloud
module Terremark
module Ecloud
module Real
class Ecloud
class Real
def generate_internet_service_request(service_data)
builder = Builder::XmlMarkup.new
@ -107,7 +107,7 @@ module Fog
end
module Mock
class Mock
#
# Based on
# http://support.theenterprisecloud.com/kb/default.asp?id=561&Lang=1&SID=

View file

@ -1,8 +1,8 @@
module Fog
class Vcloud
module Terremark
module Ecloud
module Real
class Ecloud
class Real
def add_node(nodes_uri, node_data)
validate_node_data(node_data)
@ -43,7 +43,7 @@ module Fog
end
end
module Mock
class Mock
def add_node(nodes_uri, node_data)
validate_node_data(node_data)

View file

@ -1,9 +1,9 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
def validate_clone_vapp_options(options)
valid_opts = [:name, :poweron]
@ -38,7 +38,7 @@ module Fog
end
end
module Mock
class Mock
def clone_vapp(vdc_uri, vapp_uri, customization_data)
validate_customization_data(customization_data)
Fog::Mock.not_implemented

View file

@ -1,8 +1,8 @@
module Fog
class Vcloud
module Terremark
module Ecloud
module Real
class Ecloud
class Real
def generate_internet_service_response(service_data,ip_address_data)
builder = Builder::XmlMarkup.new
@ -57,7 +57,7 @@ module Fog
end
module Mock
class Mock
#
# Based on
# http://support.theenterprisecloud.com/kb/default.asp?id=583&Lang=1&SID=

View file

@ -1,8 +1,8 @@
module Fog
class Vcloud
module Terremark
module Ecloud
module Real
class Ecloud
class Real
def validate_network_data(network_data, configure=false)
valid_opts = [:id, :href, :name, :rnat, :address, :broadcast, :gateway]
@ -42,7 +42,7 @@ module Fog
end
module Mock
class Mock
def configure_network(network_uri, network_data)
Fog::Mock.not_implemented

View file

@ -1,8 +1,8 @@
module Fog
class Vcloud
module Terremark
module Ecloud
module Real
class Ecloud
class Real
def validate_network_ip_data(network_ip_data, configure=false)
valid_opts = [:id, :href, :name, :status, :server, :rnat]
@ -41,7 +41,7 @@ module Fog
end
module Mock
class Mock
def configure_network_ip(network_ip_uri, network_ip_data)
Fog::Mock.not_implemented

View file

@ -1,8 +1,8 @@
module Fog
class Vcloud
module Terremark
module Ecloud
module Real
class Ecloud
class Real
def configure_node(node_uri, node_data)
validate_node_data(node_data, true)
@ -31,7 +31,7 @@ module Fog
end
module Mock
class Mock
def configure_node(node_uri, node_data)
node_uri = ensure_unparsed(node_uri)

View file

@ -1,8 +1,8 @@
module Fog
class Vcloud
module Terremark
module Ecloud
module Real
class Ecloud
class Real
def generate_configure_vapp_request(vapp_uri, vapp_data)
rasd_xmlns = { "xmlns" => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" }
@ -104,7 +104,7 @@ module Fog
end
module Mock
class Mock
def configure_vapp(vapp_uri, vapp_data)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :delete_internet_service, 200, 'DELETE', {}, ""
end
module Mock
class Mock
def delete_internet_service(service_uri)

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :delete_node, 200, 'DELETE', {}, ""
end
module Mock
class Mock
def delete_node(node_uri)
node_uri = ensure_unparsed(node_uri)

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :delete_vapp, 202, "DELETE"
end
module Mock
class Mock
def delete_vapp(vapp_uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_catalog
end
module Mock
class Mock
def get_catalog(catalog_uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_catalog_item
end
module Mock
class Mock
def get_catalog(catalog_uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_customization_options
end
module Mock
class Mock
def get_customization_options( options_uri )
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_firewall_acl
end
module Mock
class Mock
def get_firewall_acl(firewall_acl_uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_firewall_acls
end
module Mock
class Mock
def get_firewall_acls(firewall_acls_uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_internet_services
end
module Mock
class Mock
#
#Based off of:

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
# Handled by the main Vcloud get_network
end
module Mock
class Mock
def get_network(network_uri)
#

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_network_extensions
end
module Mock
class Mock
def get_network_extensions(network_uri)
network_uri = ensure_unparsed(network_uri)

View file

@ -5,13 +5,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_network_ip
end
module Mock
class Mock
def get_network_ip(ip_uri)
response = Excon::Response.new

View file

@ -5,13 +5,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_network_ips
end
module Mock
class Mock
require 'ipaddr'
def get_network_ips(network_ips_uri)

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_node
end
module Mock
class Mock
#
# Based on http://support.theenterprisecloud.com/kb/default.asp?id=641&Lang=1&SID=

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_nodes
end
module Mock
class Mock
#
# Based off of:

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_public_ip
end
module Mock
class Mock
#
#Based off of:
#http://support.theenterprisecloud.com/kb/default.asp?id=567&Lang=1&SID=

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_public_ips
end
module Mock
class Mock
#
#Based off of:

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_task
end
module Mock
class Mock
def get_task(task__uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_task_list
end
module Mock
class Mock
def get_task_list(task_list_uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_vapp
end
module Mock
class Mock
def get_vapp(vapp_uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :get_vapp_template
end
module Mock
class Mock
def get_vapp_template(templace_uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
# Handled by the main Vcloud get_vdc
end
module Mock
class Mock
#
#Based off of:
#http://support.theenterprisecloud.com/kb/default.asp?id=545&Lang=1&SID=

View file

@ -1,9 +1,9 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
def validate_instantiate_vapp_template_options(catalog_item_uri, options)
valid_opts = [:name, :vdc_uri, :network_uri, :cpus, :memory, :row, :group]
@ -89,7 +89,7 @@ module Fog
end
end
module Mock
class Mock
def instantiate_vapp_template(vdc_uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :power_off, 202, 'POST'
end
module Mock
class Mock
def power_off(off_uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :power_on, 202, 'POST'
end
module Mock
class Mock
def power_on(on_uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :power_reset, 202, 'POST'
end
module Mock
class Mock
def power_reset(reset_uri)
Fog::Mock.not_implemented
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Ecloud
class Ecloud
module Real
class Real
basic_request :power_shutdown, 204, 'POST'
end
module Mock
class Mock
def power_shutdown(shutdown_uri)
Fog::Mock.not_implemented
end

View file

@ -1,16 +1,24 @@
module Fog
class Vcloud
module Terremark
class Vcloud < Fog::Vcloud::Service
class Vcloud < Fog::Vcloud
request_path 'fog/vcloud/terremark/vcloud/requests'
request :get_vdc
module Real
class Real < Fog::Vcloud::Real
include Collections
def supporting_versions
["0.8", "0.8a-ext1.6"]
end
end
class Mock < Fog::Vcloud::Mock
include Collections
end
end
end
end

View file

@ -1,13 +1,13 @@
module Fog
class Vcloud
module Terremark
module Vcloud
class Vcloud
module Real
class Real
# Handled by the main Vcloud get_vdc
end
module Mock
class Mock
#
#Based off of:
#https://community.vcloudexpress.terremark.com/en-us/product_docs/w/wiki/09-get-vdc.aspx

View file

@ -21,7 +21,7 @@ if Fog.mocking?
end
context "as a collection member" do
subject { @vcloud.vdcs[0].reload; @vcloud.vdcs[0] }
subject { p @vcloud.vdcs[0]; @vcloud.vdcs[0].reload; @vcloud.vdcs[0] }
it { should be_an_instance_of Fog::Vcloud::Vdc }

View file

@ -234,12 +234,9 @@ Spec::Runner.configure do |config|
end
config.before(:each, :type => :vcloud_request) do
@vcloud = Fog.services.detect { |service| service == Vcloud }[:vcloud]
@vcloud = Fog::Vcloud::Terremark::Ecloud.new(Fog.credentials[:vcloud][:ecloud])
end
config.before(:all, :type => :mock_vcloud_model) do
@vcloud = Fog::Vcloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions")
end
config.before(:all, :type => :mock_vcloud_model) do
@base_url = Fog::Vcloud::Mock.base_url
@mock_data = Fog::Vcloud::Mock.data
@ -256,20 +253,23 @@ Spec::Runner.configure do |config|
@mock_vdc = @mock_organization[:vdcs][0]
@mock_network = @mock_vdc[:networks][0]
end
config.before(:all, :type => :mock_vcloud_model) do
@vcloud = Fog::Vcloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions")
end
config.before(:each, :type => :mock_vcloud_request) do
@vcloud = Fog::Vcloud.new(:username => "", :password => "bar", :versions_uri => "http://fakey.com/api/versions")
@vcloud = Fog::Vcloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions")
end
config.before(:each, :type => :mock_tmrk_ecloud_request) do
Fog::Vcloud::Mock.data_reset
Fog::Vcloud::Terremark::Ecloud::Mock.data_reset
setup_ecloud_mock_data
@vcloud = Fog::Vcloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions", :module => "Fog::Vcloud::Terremark::Ecloud")
@vcloud = Fog::Vcloud::Terremark::Ecloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions", :module => "Fog::Vcloud::Terremark::Ecloud")
end
config.before(:each, :type => :mock_tmrk_ecloud_model) do
Fog::Vcloud::Mock.data_reset
Fog::Vcloud::Terremark::Ecloud::Mock.data_reset
setup_ecloud_mock_data
@vcloud = Fog::Vcloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions", :module => "Fog::Vcloud::Terremark::Ecloud")
@vcloud = Fog::Vcloud::Terremark::Ecloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions", :module => "Fog::Vcloud::Terremark::Ecloud")
end
end

View file

@ -46,7 +46,7 @@ if Fog.mocking?
its(:public_ip) { should == public_ip }
its(:timeout) { should == @mock_service[:timeout] }
its(:redirect_url) { should == @mock_service[:redirect_url] }
its(:monitor) { should == "" }
its(:monitor) { should == nil }
specify { composed_public_ip_data[:href].should == public_ip[:Href].to_s }
specify { composed_public_ip_data[:name].should == public_ip[:Name] }