lib/fog/xenserver/compute.rb in fog-1.14.0 vs lib/fog/xenserver/compute.rb in fog-1.15.0
- old
+ new
@@ -1,20 +1,20 @@
require 'fog/xenserver'
require 'fog/compute'
module Fog
- module Compute
+ module Compute
class XenServer < Fog::Service
require 'fog/xenserver/utilities'
require 'fog/xenserver/parser'
-
+
requires :xenserver_username
requires :xenserver_password
requires :xenserver_url
recognizes :xenserver_defaults
-
+
model_path 'fog/xenserver/models/compute'
model :server
collection :servers
model :host
collection :hosts
@@ -38,10 +38,12 @@
model :vbd_metrics
model :host_metrics
model :host_cpu
model :vlan
collection :vlans
+ model :console
+ collection :consoles
request_path 'fog/xenserver/requests/compute'
request :create_server
request :create_vif
request :create_vdi
@@ -74,13 +76,13 @@
request :destroy_network
request :create_vlan
request :destroy_vlan
request :snapshot_server
request :snapshot_revert
-
+
class Real
-
+
def initialize(options={})
@host = options[:xenserver_url]
@username = options[:xenserver_username]
@password = options[:xenserver_password]
@defaults = options[:xenserver_defaults] || {}
@@ -89,49 +91,49 @@
end
def reload
@connection.authenticate(@username, @password)
end
-
+
def default_template=(name)
@defaults[:template] = name
end
def default_template
return nil if @defaults[:template].nil?
(servers.custom_templates + servers.builtin_templates).find do |s|
(s.name == @defaults[:template]) or (s.uuid == @defaults[:template])
end
end
-
+
def default_network
networks.find { |n| n.name == (@defaults[:network] || "Pool-wide network associated with eth0") }
end
-
+
end
-
+
class Mock
def self.data
@data ||= Hash.new do |hash, key|
hash[key] = {}
end
end
-
+
def self.reset_data(keys=data.keys)
for key in [*keys]
data.delete(key)
end
end
-
+
def initialize(options={})
@host = options[:xenserver_pool_master]
@username = options[:xenserver_username]
@password = options[:xenserver_password]
@connection = Fog::Connection.new(@host)
@connection.authenticate(@username, @password)
end
-
+
end
end
end
end