[ecloud] improvements and some mocking
This commit is contained in:
parent
4e047e9d30
commit
853755d32f
|
@ -103,10 +103,10 @@ module Fog
|
||||||
raise(ArgumentError.new("Initialization parameters must be an attributes hash, got #{attributes.class} #{attributes.inspect}"))
|
raise(ArgumentError.new("Initialization parameters must be an attributes hash, got #{attributes.class} #{attributes.inspect}"))
|
||||||
end
|
end
|
||||||
model.new(
|
model.new(
|
||||||
attributes.merge(
|
{
|
||||||
:collection => self,
|
:collection => self,
|
||||||
:connection => connection
|
:connection => connection
|
||||||
)
|
}.merge(attributes)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,30 @@ require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
|
||||||
|
|
||||||
module Fog
|
module Fog
|
||||||
module Ecloud
|
module Ecloud
|
||||||
|
ECLOUD_OPTIONS = [:ecloud_authentication_method]
|
||||||
|
|
||||||
extend Fog::Provider
|
extend Fog::Provider
|
||||||
|
|
||||||
service(:compute, 'ecloud/compute', 'Compute')
|
service(:compute, 'ecloud/compute', 'Compute')
|
||||||
|
|
||||||
end
|
def self.keep(hash, *keys)
|
||||||
end
|
{}.tap do |kept|
|
||||||
|
keys.each{|k| kept[k]= hash[k] if hash.key?(k)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module Fog
|
def self.slice(hash, *keys)
|
||||||
module Ecloud
|
hash.dup.tap do |sliced|
|
||||||
ECLOUD_OPTIONS = [:ecloud_authentication_method]
|
keys.each{|k| sliced.delete(k)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.ip_address
|
||||||
|
4.times.map{ Fog::Mock.random_numbers(3) }.join(".")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.mac_address
|
||||||
|
6.times.map{ Fog::Mock.random_numbers(2) }.join(":")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,34 +4,38 @@ module Fog
|
||||||
class AdminOrganization < Fog::Ecloud::Model
|
class AdminOrganization < Fog::Ecloud::Model
|
||||||
identity :href
|
identity :href
|
||||||
|
|
||||||
attribute :name, :aliases => :Name
|
attribute :name, :aliases => :Name
|
||||||
attribute :type, :aliases => :Type
|
attribute :type, :aliases => :Type
|
||||||
attribute :other_links, :aliases => :Links
|
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||||
attribute :multifactor_summary, :aliases => :MultifactorSummary
|
attribute :multifactor_summary, :aliases => :MultifactorSummary
|
||||||
attribute :support_access, :aliases => :SupportAccess
|
attribute :support_access, :aliases => :SupportAccess
|
||||||
|
|
||||||
def ssh_keys
|
def ssh_keys
|
||||||
@ssh_keys = Fog::Compute::Ecloud::SshKeys.new(:connection => connection, :href => "/cloudapi/ecloud/admin/sshKeys/organizations/#{org_id}")
|
@ssh_keys = Fog::Compute::Ecloud::SshKeys.new(:connection => connection, :href => "/cloudapi/ecloud/admin/sshKeys/organizations/#{organization.id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def password_complexity_rules
|
def password_complexity_rules
|
||||||
@password_complexity_rules = Fog::Compute::Ecloud::PasswordComplexityRules.new(:connection => connection, :href => "/cloudapi/ecloud/admin/organizations/#{org_id}/passwordComplexityRules")
|
@password_complexity_rules = Fog::Compute::Ecloud::PasswordComplexityRules.new(:connection => connection, :href => "/cloudapi/ecloud/admin/organizations/#{organization.id}/passwordComplexityRules")
|
||||||
end
|
end
|
||||||
|
|
||||||
def login_banner
|
def login_banner
|
||||||
@login_banner = Fog::Compute::Ecloud::LoginBanner.new(:connection => connection, :href => "/cloudapi/ecloud/admin/organizations/#{org_id}/loginBanner")
|
@login_banner = Fog::Compute::Ecloud::LoginBanner.new(:connection => connection, :href => "/cloudapi/ecloud/admin/organizations/#{organization.id}/loginBanner")
|
||||||
end
|
end
|
||||||
|
|
||||||
def authentication_levels
|
def authentication_levels
|
||||||
@authentication_levels = Fog::Compute::Ecloud::AuthenticationLevels.new(:connection => connection, :href => "/cloudapi/ecloud/admin/organizations/#{org_id}/authenticationLevels")
|
@authentication_levels = Fog::Compute::Ecloud::AuthenticationLevels.new(:connection => connection, :href => "/cloudapi/ecloud/admin/organizations/#{organization.id}/authenticationLevels")
|
||||||
end
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
href.scan(/\d+/)[0]
|
href.scan(/\d+/)[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
def org_id
|
def organization
|
||||||
other_links[:Link].detect { |l| l[:type] == "application/vnd.tmrk.cloud.organization" }[:href].scan(/\d+/)[0]
|
@organization ||= begin
|
||||||
|
reload unless other_links
|
||||||
|
organization_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.organization"}
|
||||||
|
self.connection.organizations.new(organization_link)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,11 +9,6 @@ module Fog
|
||||||
|
|
||||||
model Fog::Compute::Ecloud::AdminOrganization
|
model Fog::Compute::Ecloud::AdminOrganization
|
||||||
|
|
||||||
def all
|
|
||||||
data = connection.get_admin_organizations(href).body
|
|
||||||
load(data)
|
|
||||||
end
|
|
||||||
|
|
||||||
def get(uri)
|
def get(uri)
|
||||||
if data = connection.get_admin_organization(uri)
|
if data = connection.get_admin_organization(uri)
|
||||||
new(data.body)
|
new(data.body)
|
||||||
|
|
|
@ -5,13 +5,13 @@ module Fog
|
||||||
|
|
||||||
identity :href
|
identity :href
|
||||||
|
|
||||||
attribute :href, :aliases => :Href
|
attribute :href, :aliases => :Href
|
||||||
attribute :name, :aliases => :Name
|
attribute :name, :aliases => :Name
|
||||||
attribute :type, :aliases => :Type
|
attribute :type, :aliases => :Type
|
||||||
attribute :other_links, :aliases => :Links
|
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||||
attribute :all_servers, :aliases => :VirtualMachines
|
attribute :all_servers, :aliases => :VirtualMachines
|
||||||
attribute :purchased, :aliases => :Purchased
|
attribute :purchased, :aliases => :Purchased
|
||||||
attribute :cpu_burst, :aliases => :CpuBurst
|
attribute :cpu_burst, :aliases => :CpuBurst
|
||||||
attribute :memory_burst, :aliases => :MemoryBurst
|
attribute :memory_burst, :aliases => :MemoryBurst
|
||||||
|
|
||||||
def servers
|
def servers
|
||||||
|
@ -41,7 +41,19 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def templates
|
def templates
|
||||||
@templates ||= Fog::Compute::Ecloud::Templates.new(:connection => connection, :href => "/cloudapi/ecloud/templates/computePools/#{id}")
|
@templates ||= self.connection.templates(:href => "/cloudapi/ecloud/templates/computePools/#{id}")
|
||||||
|
end
|
||||||
|
|
||||||
|
def detached_disks
|
||||||
|
@detached_disks ||= self.connection.detached_disks(:href => "/cloudapi/ecloud/detacheddisks/computepools/#{id}")
|
||||||
|
end
|
||||||
|
|
||||||
|
def environment
|
||||||
|
@environment ||= begin
|
||||||
|
reload unless other_links
|
||||||
|
environment_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.environment"}
|
||||||
|
self.connection.environments.get(environment_link[:href])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit(options)
|
def edit(options)
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ecloud
|
||||||
|
class DetachedDisk < Fog::Ecloud::Model
|
||||||
|
identity :href
|
||||||
|
|
||||||
|
attribute :name, :aliases => :Name
|
||||||
|
attribute :type, :aliases => :Type
|
||||||
|
attribute :other_links, :aliases => :Links
|
||||||
|
attribute :status, :aliases => :Status
|
||||||
|
attribute :size, :aliases => :Size
|
||||||
|
|
||||||
|
def ready?
|
||||||
|
unless status =~ /AttachInProgress|DetachInProgress/
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def id
|
||||||
|
href.scan(/\d+/)[0]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,31 @@
|
||||||
|
require 'fog/ecloud/models/compute/detached_disk'
|
||||||
|
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ecloud
|
||||||
|
class DetachedDisks < Fog::Ecloud::Collection
|
||||||
|
|
||||||
|
identity :href
|
||||||
|
|
||||||
|
model Fog::Compute::Ecloud::DetachedDisk
|
||||||
|
|
||||||
|
def all
|
||||||
|
data = connection.get_detached_disks(href).body[:DetachedDisk]
|
||||||
|
data = [] if data.nil?
|
||||||
|
load(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get(uri)
|
||||||
|
data = connection.get_detached_disk(uri).body
|
||||||
|
if data == ""
|
||||||
|
new({})
|
||||||
|
else
|
||||||
|
new(data)
|
||||||
|
end
|
||||||
|
rescue Fog::Errors::NotFound
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -9,7 +9,7 @@ module Fog
|
||||||
|
|
||||||
attribute :name
|
attribute :name
|
||||||
attribute :type
|
attribute :type
|
||||||
attribute :other_links, :aliases => :Links
|
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||||
|
|
||||||
def public_ips
|
def public_ips
|
||||||
@public_ips ||= Fog::Compute::Ecloud::PublicIps.new(:connection => connection, :href => "/cloudapi/ecloud/publicIps/environments/#{id}")
|
@public_ips ||= Fog::Compute::Ecloud::PublicIps.new(:connection => connection, :href => "/cloudapi/ecloud/publicIps/environments/#{id}")
|
||||||
|
@ -28,7 +28,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def networks
|
def networks
|
||||||
@networks ||= Fog::Compute::Ecloud::Networks.new(:connection => connection, :href => "/cloudapi/ecloud/networks/environments/#{id}")
|
@networks ||= self.connection.networks(:href => "/cloudapi/ecloud/networks/environments/#{id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def servers
|
def servers
|
||||||
|
@ -45,11 +45,11 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def layout
|
def layout
|
||||||
@layout ||= Fog::Compute::Ecloud::Layouts.new(:connection => connection, :href => "/cloudapi/ecloud/layout/environments/#{id}").first
|
@layout ||= self.connection.layouts(:href => "/cloudapi/ecloud/layout/environments/#{id}").first
|
||||||
end
|
end
|
||||||
|
|
||||||
def rows
|
def rows
|
||||||
layout.rows
|
@rows ||= layout.rows
|
||||||
end
|
end
|
||||||
|
|
||||||
def tasks
|
def tasks
|
||||||
|
@ -73,8 +73,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def catalog
|
def catalog
|
||||||
org_href = other_links[:Link].detect { |l| l[:type] == "application/vnd.tmrk.cloud.organization" }[:href]
|
@catalog = connection.catalog(:href => "/cloudapi/ecloud/admin/catalog/organizations/#{organization.id}")
|
||||||
@catalog ||= Fog::Compute::Ecloud::Catalog.new(:connection => connection, :href => "/cloudapi/ecloud/admin/catalog/organizations/#{org_href.scan(/\d+/)[0]}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def rnats
|
def rnats
|
||||||
|
@ -98,6 +97,14 @@ module Fog
|
||||||
def id
|
def id
|
||||||
href.scan(/\d+/)[0]
|
href.scan(/\d+/)[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def organization
|
||||||
|
@organization ||= begin
|
||||||
|
reload unless other_links
|
||||||
|
organization_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.organization"}
|
||||||
|
self.connection.organizations.new(organization_link)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Vdc = Environment
|
Vdc = Environment
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Fog
|
||||||
|
|
||||||
def all
|
def all
|
||||||
data = []
|
data = []
|
||||||
connection.get_organization(href).body[:Locations][:Location].each do |d|
|
connection.get_organization(href).body[:Locations][:Location].each do |d|
|
||||||
if d[:Environments][:Environment].is_a?(Array)
|
if d[:Environments][:Environment].is_a?(Array)
|
||||||
d[:Environments][:Environment].each { |e| data << e }
|
d[:Environments][:Environment].each { |e| data << e }
|
||||||
else
|
else
|
||||||
|
|
|
@ -33,6 +33,8 @@ module Fog
|
||||||
def id
|
def id
|
||||||
href.scan(/\d+/)[0]
|
href.scan(/\d+/)[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias destroy delete
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,15 +11,26 @@ module Fog
|
||||||
|
|
||||||
def all
|
def all
|
||||||
data = connection.get_groups(href).body
|
data = connection.get_groups(href).body
|
||||||
data = data[:Groups] ? data[:Groups][:Group] : data
|
data = if data == ""
|
||||||
load(data)
|
""
|
||||||
|
else
|
||||||
|
data[:Groups] ? data[:Groups][:Group] : data
|
||||||
|
end
|
||||||
|
if data == "" || !data.is_a?(Array) && data[:type] == "application/vnd.tmrk.cloud.layoutRow"
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
load(data)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(uri)
|
def get(uri)
|
||||||
if data = connection.get_group(uri)
|
data = connection.get_group(uri).body
|
||||||
new(data.body)
|
if data == ""
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
new(data)
|
||||||
end
|
end
|
||||||
rescue Fog::Errors::NotFound
|
rescue Excon::Errors::NotFound
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,10 +4,10 @@ module Fog
|
||||||
class HardwareConfiguration < Fog::Ecloud::Model
|
class HardwareConfiguration < Fog::Ecloud::Model
|
||||||
identity :href
|
identity :href
|
||||||
|
|
||||||
attribute :processor_count, :aliases => :ProcessorCount, :type => :integer
|
attribute :processor_count, :aliases => :ProcessorCount, :type => :integer
|
||||||
attribute :mem, :aliases => :Memory
|
attribute :memory, :aliases => :Memory, :squash => :Value # {:Memory => {:Value => 15}}
|
||||||
attribute :storage, :aliases => :Disks
|
attribute :storage, :aliases => :Disks, :squash => :Disk
|
||||||
attribute :network_cards, :aliases => :Nics
|
attribute :network_cards, :aliases => :Nics, :squash => :Nic
|
||||||
|
|
||||||
def id
|
def id
|
||||||
href.scan(/\d+/)[0]
|
href.scan(/\d+/)[0]
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
||||||
model Fog::Compute::Ecloud::HardwareConfiguration
|
model Fog::Compute::Ecloud::HardwareConfiguration
|
||||||
|
|
||||||
def all
|
def all
|
||||||
data = connection.get_hardware_configurations(href).body
|
data = connection.get_server(href).body
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,20 +4,24 @@ module Fog
|
||||||
class InternetService < Fog::Ecloud::Model
|
class InternetService < Fog::Ecloud::Model
|
||||||
identity :href
|
identity :href
|
||||||
|
|
||||||
attribute :name, :aliases => :Name
|
attribute :name, :aliases => :Name
|
||||||
attribute :type, :aliases => :Type
|
attribute :type, :aliases => :Type
|
||||||
attribute :other_links, :aliases => :Links
|
attribute :other_links, :aliases => :Links
|
||||||
attribute :actions, :aliases => :Actions
|
attribute :actions, :aliases => :Actions
|
||||||
attribute :protocol, :aliases => :Protocol
|
attribute :protocol, :aliases => :Protocol
|
||||||
attribute :port, :aliases => :Port, :type => :integer
|
attribute :port, :aliases => :Port, :type => :integer
|
||||||
attribute :enabled, :aliases => :Enabled, :type => :boolean
|
attribute :enabled, :aliases => :Enabled, :type => :boolean
|
||||||
attribute :description, :aliases => :Description
|
attribute :description, :aliases => :Description
|
||||||
attribute :public_ip, :aliases => :PublicIp
|
attribute :public_ip, :aliases => :PublicIp
|
||||||
attribute :persistence, :aliases => :Persistence
|
attribute :persistence, :aliases => :Persistence
|
||||||
attribute :redirect_url, :aliases => :RedirectUrl
|
attribute :redirect_url, :aliases => :RedirectUrl
|
||||||
attribute :trusted_network_group, :aliases => :TrustedNetworkGroup
|
attribute :trusted_network_group, :aliases => :TrustedNetworkGroup
|
||||||
attribute :backup_internet_service, :aliases => :BackupInternetService
|
attribute :backup_internet_service, :aliases => :BackupInternetService
|
||||||
|
|
||||||
|
def ready?
|
||||||
|
!self.port.nil?
|
||||||
|
end
|
||||||
|
|
||||||
def nodes
|
def nodes
|
||||||
@nodes ||= Fog::Compute::Ecloud::Nodes.new(:connection => connection, :href => href)
|
@nodes ||= Fog::Compute::Ecloud::Nodes.new(:connection => connection, :href => href)
|
||||||
end
|
end
|
||||||
|
@ -43,7 +47,7 @@ module Fog
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
data = connection.internet_service_delete(href).body
|
data = connection.internet_service_delete(href).body
|
||||||
task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0]
|
self.connection.tasks.new(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_monitor(options = {})
|
def create_monitor(options = {})
|
||||||
|
@ -85,6 +89,8 @@ module Fog
|
||||||
service_data.reject! {|k, v| v.nil? }
|
service_data.reject! {|k, v| v.nil? }
|
||||||
service_data
|
service_data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias destroy delete
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,8 +19,11 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(uri)
|
def get(uri)
|
||||||
if data = connection.get_internet_service(uri)
|
data = connection.get_internet_service(uri).body
|
||||||
new(data.body)
|
if data == ""
|
||||||
|
new({})
|
||||||
|
else
|
||||||
|
new(data)
|
||||||
end
|
end
|
||||||
rescue Fog::Errors::NotFound
|
rescue Fog::Errors::NotFound
|
||||||
nil
|
nil
|
||||||
|
@ -28,10 +31,10 @@ module Fog
|
||||||
|
|
||||||
def create(options)
|
def create(options)
|
||||||
options[:uri] = "/cloudapi/ecloud/internetServices/publicIps/#{public_ip_id}/action/createInternetService"
|
options[:uri] = "/cloudapi/ecloud/internetServices/publicIps/#{public_ip_id}/action/createInternetService"
|
||||||
options[:protocol] ||= "TCP"
|
options[:protocol] ||= "TCP"
|
||||||
options[:enabled] ||= true
|
options[:enabled] ||= true
|
||||||
options[:description] ||= ""
|
options[:description] ||= ""
|
||||||
options[:persistence] ||= {}
|
options[:persistence] ||= {}
|
||||||
options[:persistence][:type] ||= "None"
|
options[:persistence][:type] ||= "None"
|
||||||
data = connection.internet_service_create(options).body
|
data = connection.internet_service_create(options).body
|
||||||
object = new(data)
|
object = new(data)
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Fog
|
||||||
|
|
||||||
attribute :name, :aliases => :Name
|
attribute :name, :aliases => :Name
|
||||||
attribute :type, :aliases => :Type
|
attribute :type, :aliases => :Type
|
||||||
attribute :other_links, :aliases => :Links
|
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||||
attribute :host, :aliases => :Host
|
attribute :host, :aliases => :Host
|
||||||
attribute :detected_on, :aliases => :DetectedOn
|
attribute :detected_on, :aliases => :DetectedOn
|
||||||
attribute :rnat, :aliases => :RnatAddress
|
attribute :rnat, :aliases => :RnatAddress
|
||||||
|
@ -15,9 +15,23 @@ module Fog
|
||||||
def status
|
def status
|
||||||
(detected_on || host) ? "Assigned" : "Available"
|
(detected_on || host) ? "Assigned" : "Available"
|
||||||
end
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
href.scan(/\d+/)[0]
|
href.match(/((\d+{1,3}\.){3}(\d+{1,3}))$/)[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
def server
|
||||||
|
@server ||= begin
|
||||||
|
reload unless other_links
|
||||||
|
server_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.virtualMachine"}
|
||||||
|
self.connection.servers.get(server_link[:href])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def network
|
||||||
|
reload if other_links.nil?
|
||||||
|
network_href = other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.network" }[:href]
|
||||||
|
network = self.connection.networks.get(network_href)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,12 @@ module Fog
|
||||||
model Fog::Compute::Ecloud::IpAddress
|
model Fog::Compute::Ecloud::IpAddress
|
||||||
|
|
||||||
def all
|
def all
|
||||||
data = connection.get_ip_addresses(href).body[:IpAddresses][:IpAddress]
|
data = connection.get_network(href).body
|
||||||
|
data = if data[:IpAddresses]
|
||||||
|
data[:IpAddresses][:IpAddress]
|
||||||
|
else
|
||||||
|
data
|
||||||
|
end
|
||||||
data = data.nil? ? [] : data
|
data = data.nil? ? [] : data
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Fog
|
||||||
attribute :other_links, :aliases => :Links
|
attribute :other_links, :aliases => :Links
|
||||||
|
|
||||||
def rows
|
def rows
|
||||||
@rows = Fog::Compute::Ecloud::Rows.new(:connection => connection, :href => href)
|
@rows ||= self.connection.rows(:href => href)
|
||||||
end
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
|
|
|
@ -4,14 +4,14 @@ module Fog
|
||||||
class Network < Fog::Ecloud::Model
|
class Network < Fog::Ecloud::Model
|
||||||
identity :href
|
identity :href
|
||||||
|
|
||||||
attribute :name, :aliases => :Name
|
attribute :name, :aliases => :Name
|
||||||
attribute :type, :aliases => :Type
|
attribute :type, :aliases => :Type
|
||||||
attribute :other_links, :aliases => :Links
|
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||||
attribute :address, :aliases => :Address
|
attribute :address, :aliases => :Address
|
||||||
attribute :network_type, :aliases => :NetworkType
|
attribute :network_type, :aliases => :NetworkType
|
||||||
attribute :broadcast_address, :aliases => :BroadcastAddress
|
attribute :broadcast_address, :aliases => :BroadcastAddress
|
||||||
attribute :gateway_address, :aliases => :GatewayAddress
|
attribute :gateway_address, :aliases => :GatewayAddress
|
||||||
attribute :rnat_address, :aliases => :RnatAddress
|
attribute :rnat_address, :aliases => :RnatAddress
|
||||||
|
|
||||||
def rnats
|
def rnats
|
||||||
@rnats ||= Fog::Compute::Ecloud::Rnats.new(:connection => connection, :href => "cloudapi/ecloud/rnats/networks/#{id}")
|
@rnats ||= Fog::Compute::Ecloud::Rnats.new(:connection => connection, :href => "cloudapi/ecloud/rnats/networks/#{id}")
|
||||||
|
@ -26,10 +26,20 @@ module Fog
|
||||||
data = connection.rnat_associations_edit_network(options).body
|
data = connection.rnat_associations_edit_network(options).body
|
||||||
task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0]
|
task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
href.scan(/\d+/)[0]
|
href.scan(/\d+/)[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def environment
|
||||||
|
reload if other_links.nil?
|
||||||
|
environment_href = other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href]
|
||||||
|
self.connection.environments.get(environment_href)
|
||||||
|
end
|
||||||
|
|
||||||
|
def location
|
||||||
|
environment.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,14 +5,18 @@ module Fog
|
||||||
class Ecloud
|
class Ecloud
|
||||||
class Networks < Fog::Ecloud::Collection
|
class Networks < Fog::Ecloud::Collection
|
||||||
|
|
||||||
identity :href
|
attribute :href, :aliases => :Href
|
||||||
|
|
||||||
model Fog::Compute::Ecloud::Network
|
model Fog::Compute::Ecloud::Network
|
||||||
|
|
||||||
def all
|
def all
|
||||||
data = connection.get_networks(href).body
|
body = connection.get_networks(self.href).body
|
||||||
data = data[:Networks] ? data[:Networks][:Network] : data[:Network]
|
body = body[:Networks] ? body[:Networks][:Network] : body[:Network]
|
||||||
data = data.nil? ? [] : data
|
data = case body
|
||||||
|
when NilClass then []
|
||||||
|
when Array then body
|
||||||
|
when Hash then [body]
|
||||||
|
end
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,17 @@ module Fog
|
||||||
attribute :enabled, :aliases => :Enabled, :type => :boolean
|
attribute :enabled, :aliases => :Enabled, :type => :boolean
|
||||||
attribute :description, :aliases => :Description
|
attribute :description, :aliases => :Description
|
||||||
|
|
||||||
|
def ready?
|
||||||
|
!self.name.nil?
|
||||||
|
end
|
||||||
|
|
||||||
def tasks
|
def tasks
|
||||||
@tasks ||= Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => "/cloudapi/ecloud/tasks/virtualMachines/#{id}")
|
@tasks ||= Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => "/cloudapi/ecloud/tasks/virtualMachines/#{id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
data = connection.node_service_delete(href).body
|
data = connection.node_service_delete(href).body
|
||||||
task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0]
|
self.connection.tasks.new(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit(options)
|
def edit(options)
|
||||||
|
@ -29,10 +33,12 @@ module Fog
|
||||||
data = connection.node_service_edit(options).body
|
data = connection.node_service_edit(options).body
|
||||||
task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0]
|
task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
href.scan(/\d+/)[0]
|
href.scan(/\d+/)[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias destroy delete
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,8 +19,11 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(uri)
|
def get(uri)
|
||||||
if data = connection.get_node(uri)
|
data = connection.get_node(uri).body
|
||||||
new(data.body)
|
if data == ""
|
||||||
|
new({})
|
||||||
|
else
|
||||||
|
new(data)
|
||||||
end
|
end
|
||||||
rescue Fog::Errors::NotFound
|
rescue Fog::Errors::NotFound
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
||||||
attribute :operating_system_family, :aliases => :OperatingSystems
|
attribute :operating_system_family, :aliases => :OperatingSystems
|
||||||
|
|
||||||
def operating_systems
|
def operating_systems
|
||||||
@operating_systems ||= Fog::Compute::Ecloud::OperatingSystems.new(:connection => connection, :data => operating_system_family[:OperatingSystem])
|
@operating_systems ||= self.connection.operating_systems(:data => operating_system_family[:OperatingSystem])
|
||||||
end
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
|
|
|
@ -9,26 +9,26 @@ module Fog
|
||||||
|
|
||||||
attribute :name, :aliases => :Name
|
attribute :name, :aliases => :Name
|
||||||
attribute :type, :aliases => :Type
|
attribute :type, :aliases => :Type
|
||||||
attribute :other_links, :aliases => :Links
|
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||||
|
|
||||||
def locations
|
def locations
|
||||||
@locations ||= Fog::Compute::Ecloud::Locations.new( :connection => connection, :href => href )
|
@locations ||= Fog::Compute::Ecloud::Locations.new( :connection => connection, :href => href )
|
||||||
end
|
end
|
||||||
|
|
||||||
def environments
|
def environments
|
||||||
@environments ||= Fog::Compute::Ecloud::Environments.new(:connection => connection, :href => href)
|
@environments ||= self.connection.environments(:href => href)
|
||||||
end
|
end
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
@tags ||= Fog::Compute::Ecloud::Tags.new(:connection => connection, :href => "/cloudapi/ecloud/deviceTags/organizations/#{id}")
|
@tags ||= self.connection.tags(:href => "/cloudapi/ecloud/deviceTags/organizations/#{id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def admin
|
def admin
|
||||||
@admin ||= Fog::Compute::Ecloud::AdminOrganizations.new(:connection => connection, :href => "/cloudapi/ecloud/admin/organizations/#{id}").first
|
@admin ||= self.connection.admin_organizations.new(:href => "/cloudapi/ecloud/admin/organizations/#{id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def users
|
def users
|
||||||
@users ||= Fog::Compute::Ecloud::Users.new(:connection => connection, :href => "/cloudapi/ecloud/admin/users/organizations/#{id}")
|
@users ||= self.connection.users(:href => "/cloudapi/ecloud/admin/users/organizations/#{id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def support_tickets(type = :open)
|
def support_tickets(type = :open)
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Fog
|
||||||
def internet_services
|
def internet_services
|
||||||
@internet_services = Fog::Compute::Ecloud::InternetServices.new(:connection => connection, :href => href)
|
@internet_services = Fog::Compute::Ecloud::InternetServices.new(:connection => connection, :href => href)
|
||||||
end
|
end
|
||||||
|
|
||||||
def environment_id
|
def environment_id
|
||||||
other_links[:Link].detect { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0]
|
other_links[:Link].detect { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0]
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,8 +16,11 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(uri)
|
def get(uri)
|
||||||
if data = connection.get_public_ip(uri)
|
data = connection.get_public_ip(uri).body
|
||||||
new(data.body)
|
if data == ""
|
||||||
|
new({})
|
||||||
|
else
|
||||||
|
new(data)
|
||||||
end
|
end
|
||||||
rescue Fog::Errors::NotFound
|
rescue Fog::Errors::NotFound
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
||||||
attribute :index, :aliases => :Index
|
attribute :index, :aliases => :Index
|
||||||
|
|
||||||
def groups
|
def groups
|
||||||
@groups = Fog::Compute::Ecloud::Groups.new(:connection => connection, :href => href)
|
@groups = self.connection.groups(:href => href)
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit(options)
|
def edit(options)
|
||||||
|
@ -37,16 +37,19 @@ module Fog
|
||||||
options[:row_name] = name
|
options[:row_name] = name
|
||||||
options[:href] = href
|
options[:href] = href
|
||||||
data = connection.groups_create(options).body
|
data = connection.groups_create(options).body
|
||||||
group = Fog::Compute::Ecloud::Groups.new(:connection => connection, :href => data[:href])[0]
|
group = self.connection.groups.new(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def environment_id
|
def environment_id
|
||||||
|
reload if other_links.nil?
|
||||||
other_links[:Link][:href].scan(/\d+/)[0]
|
other_links[:Link][:href].scan(/\d+/)[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
href.scan(/\d+/)[0]
|
href.scan(/\d+/)[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias destroy delete
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,10 +15,13 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(uri)
|
def get(uri)
|
||||||
if data = connection.get_row(uri)
|
data = connection.get_row(uri).body
|
||||||
new(data.body)
|
if data == ""
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
new(data)
|
||||||
end
|
end
|
||||||
rescue Fog::Errors::NotFound
|
rescue Excon::Errors::NotFound
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,80 +2,69 @@ module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
class Server < Fog::Ecloud::Model
|
class Server < Fog::Ecloud::Model
|
||||||
|
extend Forwardable
|
||||||
|
|
||||||
identity :href
|
identity :href
|
||||||
|
|
||||||
attribute :name, :aliases => :Name
|
attribute :description, :aliases => :Description
|
||||||
attribute :type , :aliases => :Type
|
attribute :hardware_configuration, :aliases => :HardwareConfiguration
|
||||||
attribute :other_links, :aliases => :Link
|
attribute :ip_addresses, :aliases => :IpAddresses, :squash => :AssignedIpAddresses
|
||||||
attribute :status, :aliases => :Status
|
attribute :layout, :aliases => :Layout
|
||||||
attribute :storage, :aliases => :Storage
|
attribute :name, :aliases => :Name
|
||||||
attribute :ip_addresses, :aliases => :IpAddresses
|
attribute :operating_system, :aliases => :OperatingSystem
|
||||||
attribute :operating_system, :aliases => :OperatingSystem
|
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||||
attribute :powered_on, :aliases => :PoweredOn, :type => :boolean
|
attribute :powered_on, :aliases => :PoweredOn, :type => :boolean
|
||||||
attribute :tools_status, :aliases => :ToolsStatus
|
attribute :status, :aliases => :Status
|
||||||
attribute :cpus, :aliases => :ProcessorCount, :type => :integer
|
attribute :tags, :aliases => :Tags
|
||||||
attribute :memory, :aliases => :Memory
|
attribute :tools_status, :aliases => :ToolsStatus
|
||||||
attribute :description, :aliases => :Description
|
attribute :type, :aliases => :Type
|
||||||
attribute :tags, :aliases => :Tags
|
|
||||||
attribute :layout, :aliases => :Layout
|
def cpus
|
||||||
|
hardware_configuration.processor_count
|
||||||
|
end
|
||||||
|
|
||||||
|
def memory # always in MB
|
||||||
|
hardware_configuration.memory.to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
def location
|
||||||
|
end
|
||||||
|
|
||||||
|
def flavor_id
|
||||||
|
{:ram => hardware_configuration.memory.to_i, :cpus => hardware_configuration.processor_count}
|
||||||
|
end
|
||||||
|
|
||||||
|
def storage
|
||||||
|
hardware_configuration.storage[:Disk]
|
||||||
|
end
|
||||||
|
|
||||||
def tasks
|
def tasks
|
||||||
@tasks ||= Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => "/cloudapi/ecloud/tasks/virtualMachines/#{id}")
|
@tasks ||= self.connection.tasks(:href => "/cloudapi/ecloud/tasks/virtualMachines/#{id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def processes
|
def processes
|
||||||
@processes ||= Fog::Compute::Ecloud::GuestProcesses.new(:connection, connection, :href => "/cloudapi/ecloud/virtualMachines/#{id}/guest/processes")
|
@processes ||= Fog::Compute::Ecloud::GuestProcesses.new(:connection, connection, :href => "/cloudapi/ecloud/virtualMachines/#{id}/guest/processes")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hardware_configuration=(hardware_configuration)
|
||||||
|
@hardware_configuration = self.connection.hardware_configurations.new(hardware_configuration)
|
||||||
|
end
|
||||||
|
|
||||||
def hardware_configuration
|
def hardware_configuration
|
||||||
@hardware_configuration ||= Fog::Compute::Ecloud::HardwareConfigurations.new(:connection => connection, :href => "/cloudapi/ecloud/virtualMachines/#{id}/hardwareConfiguration")[0]
|
@hardware_configuration ||= self.connection.hardware_configurations.new(:href => "/cloudapi/ecloud/virtualMachines/#{id}/hardwareConfiguration")
|
||||||
|
@hardware_configuration.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
def configuration
|
def configuration
|
||||||
@configuration ||= Fog::Compute::Ecloud::ServerConfigurationOptions.new(:connection => connection, :href => "/cloudapi/ecloud/virtualMachines/#{id}/configurationOptions")[0]
|
@configuration ||= Fog::Compute::Ecloud::ServerConfigurationOptions.new(:connection => connection, :href => "/cloudapi/ecloud/virtualMachines/#{id}/configurationOptions")[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def ips
|
def ips
|
||||||
network_hash = ip_addresses[:AssignedIpAddresses][:Networks] || []
|
@ips = self.connection.virtual_machine_assigned_ips(:virtual_machine_id => self.id)
|
||||||
network_hash[:Network] = network_hash[:Network].is_a?(Hash) ? [network_hash[:Network]] : network_hash[:Network]
|
|
||||||
network_hash[:Network].each do |network|
|
|
||||||
network[:IpAddresses][:IpAddress] = network[:IpAddresses][:IpAddress].is_a?(String) ? [network[:IpAddresses][:IpAddress]] : network[:IpAddresses][:IpAddress]
|
|
||||||
end
|
|
||||||
@ips = nil
|
|
||||||
networks = Fog::Compute::Ecloud::Networks.new(:connection => connection, :href => "/cloudapi/ecloud/virtualMachines/#{id}/assignedIps")
|
|
||||||
networks.each do |network|
|
|
||||||
if networks.index(network) == 0
|
|
||||||
if @ips.nil?
|
|
||||||
@ips = network.ips.select do |ip|
|
|
||||||
network_hash[:Network].any? do |network|
|
|
||||||
network[:IpAddresses][:IpAddress].include?(ip.name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
network.ips.each do |ip|
|
|
||||||
network_hash[:Network].any? do |network|
|
|
||||||
network[:IpAddresses][:IpAddress].each do |i|
|
|
||||||
@ips << ip if i == ip.name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
network.ips.each do |ip|
|
|
||||||
network_hash[:Network].each do |network|
|
|
||||||
network[:IpAddresses][:IpAddress].each do |i|
|
|
||||||
@ips << ip if i == ip.name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ips
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def networks
|
def networks
|
||||||
@networks ||= Fog::Compute::Ecloud::Networks.new(:connection => connection, :href => "/cloudapi/ecloud/virtualMachines/#{id}/assignedIps")
|
@networks ||= self.connection.networks(:href => "/cloudapi/ecloud/virtualMachines/#{id}/assignedIps")
|
||||||
end
|
end
|
||||||
|
|
||||||
def power_on
|
def power_on
|
||||||
|
@ -96,7 +85,7 @@ module Fog
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
data = connection.virtual_machine_delete(href).body
|
data = connection.virtual_machine_delete(href).body
|
||||||
task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0]
|
self.connection.tasks.new(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy(options = {})
|
def copy(options = {})
|
||||||
|
@ -165,20 +154,43 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def disks
|
def disks
|
||||||
c = hardware_configuration.reload.storage[:Disk]
|
c = hardware_configuration.reload.storage
|
||||||
c = c.is_a?(Hash) ? [c] : c
|
c = c.is_a?(Hash) ? [c] : c
|
||||||
@disks = c
|
@disks = c
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_disk(size)
|
def add_disk(size)
|
||||||
index = disks.map { |d| d[:Index].to_i }.sort[-1] + 1
|
index = disks.map { |d| d[:Index].to_i }.sort[-1] + 1
|
||||||
vm_disks = disks << {:Index => index, :Size=>{:Unit => "GB", :Value => size}}
|
vm_disks = disks << {:Index => index.to_s, :Size=>{:Unit => "GB", :Value => size.to_s}, :Name => "Hard Disk #{index + 1}"}
|
||||||
data = connection.virtual_machine_edit_hardware_configuration(href + "/hardwareConfiguration", _configuration_data(:disks => vm_disks)).body
|
data = connection.virtual_machine_edit_hardware_configuration(href + "/hardwareConfiguration", _configuration_data(:disks => vm_disks)).body
|
||||||
task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0]
|
task = self.connection.tasks.new(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
def detach_disk(index)
|
||||||
|
options = {}
|
||||||
|
options[:disk] = disks.detect { |disk_hash| disk_hash[:Index] == index.to_s }
|
||||||
|
options[:name] = self.name
|
||||||
|
options[:description] = self.description
|
||||||
|
data = connection.virtual_machine_detach_disk(href + "/hardwareconfiguration/disks/actions/detach", options).body
|
||||||
|
detached_disk = self.connection.detached_disks.new(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
def attach_disk(detached_disk)
|
||||||
|
options = {}
|
||||||
|
options[:name] = detached_disk.name
|
||||||
|
options[:href] = detached_disk.href
|
||||||
|
data = connection.virtual_machine_attach_disk(href + "/hardwareconfiguration/disks/actions/attach", options).body
|
||||||
|
task = self.connection.tasks.new(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete_disk(index)
|
||||||
|
vm_disks = disks.delete_if { |h| h[:Index] == index.to_s }
|
||||||
|
data = connection.virtual_machine_edit_hardware_configuration(href + "/hardwareconfiguration", _configuration_data(:disks => vm_disks)).body
|
||||||
|
task = self.connection.tasks.new(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def nics
|
def nics
|
||||||
c = hardware_configuration.network_cards[:Nic]
|
c = hardware_configuration.network_cards
|
||||||
c = c.is_a?(Hash) ? [c] : c
|
c = c.is_a?(Hash) ? [c] : c
|
||||||
@nics = c
|
@nics = c
|
||||||
end
|
end
|
||||||
|
@ -187,22 +199,21 @@ module Fog
|
||||||
unit_number = nics.map { |n| n[:UnitNumber].to_i }.sort[-1] + 1
|
unit_number = nics.map { |n| n[:UnitNumber].to_i }.sort[-1] + 1
|
||||||
vm_nics = nics << {:UnitNumber => unit_number, :Network => {:href => network.href, :name => network.name, :type => "application/vnd.tmrk.cloud.network"}}
|
vm_nics = nics << {:UnitNumber => unit_number, :Network => {:href => network.href, :name => network.name, :type => "application/vnd.tmrk.cloud.network"}}
|
||||||
data = connection.virtual_machine_edit_hardware_configuration(href + "/hardwareConfiguration", _configuration_data(:nics => vm_nics)).body
|
data = connection.virtual_machine_edit_hardware_configuration(href + "/hardwareConfiguration", _configuration_data(:nics => vm_nics)).body
|
||||||
task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0]
|
task = self.connection.tasks.new(:href => data[:href])[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_ip(options)
|
def add_ip(options)
|
||||||
begin
|
slice_ips = begin
|
||||||
slice_ips = ips
|
ips
|
||||||
rescue
|
rescue
|
||||||
slice_ips = []
|
[]
|
||||||
end
|
end
|
||||||
begin
|
slice_networks = if slice_ips.empty?
|
||||||
slice_networks = networks
|
[]
|
||||||
rescue
|
else
|
||||||
slice_networks = []
|
ips.map { |ip| {:href => ip.network.href, :name => ip.network.name.split(' ')[0], :type => ip.network.type} }.push({:href => options[:href], :name => options[:network_name], :type => "application/vnd.tmrk.cloud.network"}).uniq
|
||||||
end
|
end
|
||||||
slice_networks = slice_networks.map { |n| {:href => n.href, :name => n.name.split(' ')[0], :type => 'application/vnd.tmrk.cloud.network'} }.push({:href => options[:href], :name => options[:network_name], :type => 'application/vnd.tmrk.cloud.network'}).uniq
|
slice_ips = slice_ips.map { |i| {:name => i.address.name, :network_name => i.network.name} }.push({:name => options[:ip], :network_name => options[:network_name]}).uniq
|
||||||
slice_ips = slice_ips.map { |i| {:name => i.name, :network_name => i.other_links[:Link][:name]} }.push({:name => options[:ip], :network_name => options[:network_name]})
|
|
||||||
slice_ips.each do |ip|
|
slice_ips.each do |ip|
|
||||||
slice_networks.each do |network|
|
slice_networks.each do |network|
|
||||||
if network[:name] == ip[:network_name]
|
if network[:name] == ip[:network_name]
|
||||||
|
@ -211,8 +222,37 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
data = connection.virtual_machine_add_ip(href + "/assignedIps", slice_networks).body
|
data = connection.virtual_machine_edit_assigned_ips(href + "/assignedIps", slice_networks).body
|
||||||
task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0]
|
task = self.connection.tasks.new(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete_ip(options)
|
||||||
|
slice_ips = begin
|
||||||
|
ips
|
||||||
|
rescue
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
slice_networks = if slice_ips.empty?
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
ips.map do |ip|
|
||||||
|
{
|
||||||
|
:href => ip.network.href,
|
||||||
|
:name => ip.network.name.split(' ')[0],
|
||||||
|
:type => ip.network.type,
|
||||||
|
}
|
||||||
|
end#.delete_if { |ip| ip[:href] == options[:href] && ip[:name] == options[:network_name] }
|
||||||
|
end
|
||||||
|
slice_ips.map! { |i| {:name => i.address.name, :network_name => i.network.name, :network_name => i.network.name } }.delete_if { |ip| ip[:name] == options[:ip] }
|
||||||
|
slice_ips.each do |ip|
|
||||||
|
slice_networks.each do |network|
|
||||||
|
if network[:name] == ip[:network_name]
|
||||||
|
network[:ips].delete(ip[:name])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
data = connection.virtual_machine_edit_assigned_ips(href + "/assignedips", slice_networks).body
|
||||||
|
task = self.connection.tasks.new(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def upload_file(options)
|
def upload_file(options)
|
||||||
|
@ -222,7 +262,7 @@ module Fog
|
||||||
|
|
||||||
def storage_size
|
def storage_size
|
||||||
vm_disks = disks
|
vm_disks = disks
|
||||||
disks.map! { |d| d[:Size][:Value].to_i }.inject(0){|sum,item| sum + item} * 1024 * 1024
|
disks.map! { |d| d[:Size][:Value].to_i }.inject(0){|sum,item| sum + item} * 1024 * 1024
|
||||||
end
|
end
|
||||||
|
|
||||||
def ready?
|
def ready?
|
||||||
|
@ -243,11 +283,16 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def compute_pool_id
|
def compute_pool_id
|
||||||
other_links[:Link].detect { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href].scan(/\d+/)[0]
|
other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href].scan(/\d+/)[0]
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_pool
|
||||||
|
reload if other_links.nil?
|
||||||
|
@compute_pool = self.connection.compute_pools.new(:href => other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href])
|
||||||
end
|
end
|
||||||
|
|
||||||
def environment_id
|
def environment_id
|
||||||
other_links[:Link].detect { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0]
|
other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
|
@ -257,7 +302,7 @@ module Fog
|
||||||
private
|
private
|
||||||
|
|
||||||
def _configuration_data(options = {})
|
def _configuration_data(options = {})
|
||||||
{:cpus => (options[:cpus] || hardware_configuration.processor_count), :memory => (options[:memory] || hardware_configuration.mem), :disks => (options[:disks] || disks), :nics => (options[:nics] || nics)}
|
{:cpus => (options[:cpus] || hardware_configuration.processor_count), :memory => (options[:memory] || hardware_configuration.memory), :disks => (options[:disks] || disks), :nics => (options[:nics] || nics)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def power_operation(op)
|
def power_operation(op)
|
||||||
|
@ -271,6 +316,7 @@ module Fog
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias destroy delete
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
class Servers < Fog::Ecloud::Collection
|
class Servers < Fog::Ecloud::Collection
|
||||||
|
|
||||||
model Fog::Compute::Ecloud::Server
|
model Fog::Compute::Ecloud::Server
|
||||||
|
|
||||||
identity :href
|
identity :href
|
||||||
|
@ -22,10 +22,13 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(uri)
|
def get(uri)
|
||||||
if data = connection.get_server(uri)
|
data = connection.get_server(uri).body
|
||||||
new(data.body)
|
if data == ""
|
||||||
|
new({})
|
||||||
|
else
|
||||||
|
new(data)
|
||||||
end
|
end
|
||||||
rescue Fog::Errors::NotFound
|
rescue Excon::Errors::NotFound
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,21 +37,21 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def create( template_uri, options )
|
def create( template_uri, options )
|
||||||
options[:cpus] ||= 1
|
options[:cpus] ||= 1
|
||||||
options[:memory] ||= 512
|
options[:memory] ||= 512
|
||||||
options[:description] ||= ""
|
options[:description] ||= ""
|
||||||
options[:tags] ||= []
|
options[:tags] ||= []
|
||||||
|
|
||||||
if template_uri =~ /\/templates\/\d+/
|
if template_uri =~ /\/templates\/\d+/
|
||||||
options[:uri] = href + "/action/createVirtualMachine"
|
options[:uri] = href + "/action/createVirtualMachine"
|
||||||
options[:customization] ||= :linux
|
options[:customization] ||= :linux
|
||||||
options[:powered_on] ||= false
|
options[:powered_on] ||= false
|
||||||
if options[:ips]
|
if options[:ips]
|
||||||
options[:ips] = options[:ips].is_a?(String) ? [options[:ips]] : options[:ips]
|
options[:ips] = [*options[:ips]]
|
||||||
else
|
else
|
||||||
options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
|
[*options[:network_uri]].each do |uri|
|
||||||
options[:network_uri].each do |uri|
|
|
||||||
index = options[:network_uri].index(uri)
|
index = options[:network_uri].index(uri)
|
||||||
ip = Fog::Compute::Ecloud::IpAddresses.new(:connection => connection, :href => uri).detect { |i| i.host == nil }.name
|
ip = self.connection.ip_addresses(:href => uri).detect { |i| i.host == nil && i.detected_on.nil? }.name
|
||||||
options[:ips] ||= []
|
options[:ips] ||= []
|
||||||
options[:ips][index] = ip
|
options[:ips][index] = ip
|
||||||
end
|
end
|
||||||
|
@ -58,7 +61,7 @@ module Fog
|
||||||
options[:uri] = href + "/action/importVirtualMachine"
|
options[:uri] = href + "/action/importVirtualMachine"
|
||||||
data = connection.virtual_machine_import( template_uri, options ).body
|
data = connection.virtual_machine_import( template_uri, options ).body
|
||||||
end
|
end
|
||||||
object = new(data)
|
object = self.connection.servers.new(data)
|
||||||
object
|
object
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
||||||
attribute :default, :aliases => :Default, :type => :boolean
|
attribute :default, :aliases => :Default, :type => :boolean
|
||||||
attribute :finger_print, :aliases => :FingerPrint
|
attribute :finger_print, :aliases => :FingerPrint
|
||||||
|
|
||||||
|
|
||||||
def id
|
def id
|
||||||
href.scan(/\d+/)[0]
|
href.scan(/\d+/)[0]
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,6 +14,9 @@ module Fog
|
||||||
attribute :error_message, :aliases => :ErrorMessage
|
attribute :error_message, :aliases => :ErrorMessage
|
||||||
attribute :initiated_by, :aliases => :InitiatedBy
|
attribute :initiated_by, :aliases => :InitiatedBy
|
||||||
|
|
||||||
|
def ready?
|
||||||
|
!self.completed_time.nil?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,17 +4,16 @@ module Fog
|
||||||
class Template < Fog::Ecloud::Model
|
class Template < Fog::Ecloud::Model
|
||||||
identity :href
|
identity :href
|
||||||
|
|
||||||
attribute :name, :aliases => :Name
|
attribute :name, :aliases => :Name
|
||||||
attribute :type, :aliases => :Type
|
attribute :type, :aliases => :Type
|
||||||
attribute :other_links, :aliases => :Links
|
attribute :other_links, :aliases => :Links
|
||||||
attribute :operating_system, :aliases => :OperatingSystem
|
attribute :operating_system, :aliases => :OperatingSystem
|
||||||
attribute :description, :aliases => :Description
|
attribute :description, :aliases => :Description
|
||||||
attribute :storage, :aliases => :Storage
|
attribute :storage, :aliases => :Storage
|
||||||
attribute :network_adapters, :aliases => :NetworkAdapters
|
attribute :network_adapters, :aliases => :NetworkAdapters
|
||||||
attribute :customization, :aliases => :Customization
|
attribute :customization, :aliases => :Customization
|
||||||
attribute :licensed_software, :aliases => :LicensedSoftware
|
attribute :licensed_software, :aliases => :LicensedSoftware
|
||||||
|
|
||||||
|
|
||||||
def id
|
def id
|
||||||
href.scan(/\d+/)[0]
|
href.scan(/\d+/)[0]
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ecloud
|
||||||
|
class VirtualMachineAssignedIp < Fog::Ecloud::Model
|
||||||
|
identity :href
|
||||||
|
|
||||||
|
attribute :network, :aliases => :Networks
|
||||||
|
attribute :address
|
||||||
|
|
||||||
|
def id
|
||||||
|
href.scan(/\d+/)[0]
|
||||||
|
end
|
||||||
|
|
||||||
|
def network=(network)
|
||||||
|
network = network.dup
|
||||||
|
network_address = network[:Network]
|
||||||
|
@network = self.connection.networks.new(network_address)
|
||||||
|
network_id = @network.href.match(/(\d+)$/)[1]
|
||||||
|
address_ip = network_address[:IpAddresses][:IpAddress]
|
||||||
|
@address = self.connection.ip_addresses.new(
|
||||||
|
:href => "/cloudapi/ecloud/ipaddresses/networks/#{network_id}/#{address_ip}",
|
||||||
|
:name => address_ip
|
||||||
|
)
|
||||||
|
end
|
||||||
|
attr_reader :network
|
||||||
|
|
||||||
|
def address=(address); end
|
||||||
|
attr_reader :address
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,27 @@
|
||||||
|
require 'fog/ecloud/models/compute/virtual_machine_assigned_ip'
|
||||||
|
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ecloud
|
||||||
|
class VirtualMachineAssignedIps < Fog::Ecloud::Collection
|
||||||
|
|
||||||
|
identity :virtual_machine_id
|
||||||
|
|
||||||
|
model Fog::Compute::Ecloud::VirtualMachineAssignedIp
|
||||||
|
|
||||||
|
def all
|
||||||
|
data = connection.get_virtual_machine_assigned_ips(self.identity).body
|
||||||
|
load(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get(uri)
|
||||||
|
if data = connection.get_virtual_machine_assigned_ip(self.identity)
|
||||||
|
new(data.body)
|
||||||
|
end
|
||||||
|
rescue Fog::Errors::NotFound
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -18,7 +18,6 @@ module Fog
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
||||||
def build_authentication_levels_edit(data)
|
def build_authentication_levels_edit(data)
|
||||||
xml = Builder::XmlMarkup.new
|
xml = Builder::XmlMarkup.new
|
||||||
xml.AuthenticationLevels do
|
xml.AuthenticationLevels do
|
||||||
|
@ -26,7 +25,7 @@ module Fog
|
||||||
xml.SHA1Enabled data[:sha1]
|
xml.SHA1Enabled data[:sha1]
|
||||||
xml.SHA256Enabled data[:sha256]
|
xml.SHA256Enabled data[:sha256]
|
||||||
xml.SHA512Enabled data[:sha512]
|
xml.SHA512Enabled data[:sha512]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,20 @@ module Fog
|
||||||
basic_request :get_admin_organization
|
basic_request :get_admin_organization
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_admin_organization(uri)
|
||||||
|
|
||||||
|
organization_id = id_from_uri(uri)
|
||||||
|
admin_organization = self.data[:admin_organizations][organization_id]
|
||||||
|
|
||||||
|
if admin_organization
|
||||||
|
body = Fog::Ecloud.slice(admin_organization, :id, :organization_id)
|
||||||
|
|
||||||
|
response(:body => body)
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
module Fog
|
|
||||||
module Compute
|
|
||||||
class Ecloud
|
|
||||||
|
|
||||||
class Real
|
|
||||||
basic_request :get_admin_organizations
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -6,6 +6,17 @@ module Fog
|
||||||
basic_request :get_compute_pool
|
basic_request :get_compute_pool
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_compute_pool(uri)
|
||||||
|
compute_pool_id = id_from_uri(uri)
|
||||||
|
compute_pool = self.data[:compute_pools][compute_pool_id]
|
||||||
|
|
||||||
|
if compute_pool
|
||||||
|
response(:body => Fog::Ecloud.slice(compute_pool, :id, :environment))
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,27 @@ module Fog
|
||||||
basic_request :get_compute_pools
|
basic_request :get_compute_pools
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_compute_pools(uri) # /cloudapi/ecloud/computepools/environments/534
|
||||||
|
environment_id = id_from_uri(uri)
|
||||||
|
environment = self.data[:environments][environment_id]
|
||||||
|
|
||||||
|
compute_pools = self.data[:compute_pools].values.select{|cp| cp[:environment_id] == environment_id}
|
||||||
|
|
||||||
|
compute_pools = compute_pools.map{|cp| Fog::Ecloud.slice(cp, :id, :environment_id)}
|
||||||
|
|
||||||
|
compute_pool_response = {:ComputePool => (compute_pools.size > 1 ? compute_pools : compute_pools.first)} # GAH
|
||||||
|
body = {
|
||||||
|
:href => uri,
|
||||||
|
:type => "application/vnd.tmrk.cloud.computePool; type=collection",
|
||||||
|
:Links => {
|
||||||
|
:Link => environment,
|
||||||
|
}
|
||||||
|
}.merge(compute_pool_response)
|
||||||
|
|
||||||
|
response(:body => body)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ecloud
|
||||||
|
class Real
|
||||||
|
basic_request :get_detached_disk
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_detached_disk(uri)
|
||||||
|
detached_disk_id = id_from_uri(uri)
|
||||||
|
detached_disk = self.data[:detached_disks][detached_disk_id]
|
||||||
|
|
||||||
|
if detached_disk
|
||||||
|
response(:body => Fog::Ecloud.slice(detached_disk, :id, :compute_pool_id))
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,33 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ecloud
|
||||||
|
|
||||||
|
class Real
|
||||||
|
basic_request :get_detached_disks
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_detached_disks(uri)
|
||||||
|
|
||||||
|
compute_pool_id = id_from_uri(uri)
|
||||||
|
compute_pool = self.data[:compute_pools][compute_pool_id]
|
||||||
|
|
||||||
|
detached_disks = self.data[:detached_disks].values.select{|cp| cp[:compute_pool_id] == compute_pool_id}
|
||||||
|
|
||||||
|
detached_disks = detached_disks.map{|dd| Fog::Ecloud.slice(dd, :id, :compute_pool_id)}
|
||||||
|
|
||||||
|
detached_disk_response = {:DetachedDisk => (detached_disks.size > 1 ? detached_disks : detached_disks.first)} # GAH
|
||||||
|
body = {
|
||||||
|
:href => uri,
|
||||||
|
:type => "application/vnd.tmrk.cloud.detachedDisk; type=collection",
|
||||||
|
:Links => {
|
||||||
|
:Link => Fog::Ecloud.keep(compute_pool, :name, :href, :type),
|
||||||
|
}
|
||||||
|
}.merge(detached_disk_response)
|
||||||
|
|
||||||
|
response(:body => body)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -6,6 +6,27 @@ module Fog
|
||||||
basic_request :get_environment
|
basic_request :get_environment
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_environment(uri)
|
||||||
|
environment_id = id_from_uri(uri)
|
||||||
|
organizations = self.data[:organizations].values
|
||||||
|
environment = nil
|
||||||
|
catch(:found) do
|
||||||
|
organizations.each do |organization|
|
||||||
|
organization[:Locations][:Location].each do |location|
|
||||||
|
environment = location[:Environments][:Environment].find{|e| e[:id] == environment_id}
|
||||||
|
throw :found if environment
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if environment
|
||||||
|
body = environment.dup
|
||||||
|
body.delete(:id)
|
||||||
|
response(:body => body)
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :get_group
|
basic_request :get_group
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_group(uri)
|
||||||
|
group_id = id_from_uri(uri)
|
||||||
|
group = self.data[:groups][group_id]
|
||||||
|
|
||||||
|
response(:body => group)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :get_groups
|
basic_request :get_groups
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_groups(uri)
|
||||||
|
row_id = id_from_uri(uri)
|
||||||
|
row = self.data[:rows][row_id]
|
||||||
|
|
||||||
|
response(:body => row)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,25 @@ module Fog
|
||||||
basic_request :get_hardware_configuration
|
basic_request :get_hardware_configuration
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_hardware_configuration(uri)
|
||||||
|
server_id = uri.match(/(\d+)/)[1]
|
||||||
|
|
||||||
|
server = self.data[:servers][server_id.to_i]
|
||||||
|
server_hardware_configuration = server[:HardwareConfiguration]
|
||||||
|
|
||||||
|
new_hardware_configuration = {
|
||||||
|
:href => server_hardware_configuration[:href],
|
||||||
|
:type => server_hardware_configuration[:type],
|
||||||
|
:ProcessorCount => server_hardware_configuration[:ProcessorCount],
|
||||||
|
:Memory => server_hardware_configuration[:Memory],
|
||||||
|
:Disks => server_hardware_configuration[:Disks],
|
||||||
|
:Nics => server_hardware_configuration[:Nics],
|
||||||
|
}
|
||||||
|
|
||||||
|
response(:body => {:HardwareConfiguration => new_hardware_configuration})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,10 @@ module Fog
|
||||||
basic_request :get_hardware_configurations
|
basic_request :get_hardware_configurations
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_hardware_configurations(uri)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,18 @@ module Fog
|
||||||
basic_request :get_internet_service
|
basic_request :get_internet_service
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_internet_service(uri)
|
||||||
|
|
||||||
|
internet_service_id = id_from_uri(uri)
|
||||||
|
internet_service = self.data[:internet_services][internet_service_id.to_i]
|
||||||
|
|
||||||
|
if internet_service
|
||||||
|
response(:body => Fog::Ecloud.slice(internet_service, :id, :public_ip))
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,14 @@ module Fog
|
||||||
basic_request :get_internet_services
|
basic_request :get_internet_services
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_internet_services(uri)
|
||||||
|
public_ip_id = id_from_uri(uri)
|
||||||
|
public_ip = self.data[:public_ips][public_ip_id]
|
||||||
|
|
||||||
|
response(:body => Fog::Ecloud.slice(public_ip, :environment_id))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,17 @@ module Fog
|
||||||
basic_request :get_ip_address
|
basic_request :get_ip_address
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_ip_address(uri)
|
||||||
|
|
||||||
|
network_id, ip_address_id = uri.match(/\/networks\/(\d+)\/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/).captures
|
||||||
|
ip_address = self.data[:networks][network_id.to_i][:IpAddresses][:IpAddress].detect{|ip| ip[:name] == ip_address_id }.dup
|
||||||
|
if ip_address
|
||||||
|
response(:body => ip_address)
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
module Fog
|
|
||||||
module Compute
|
|
||||||
class Ecloud
|
|
||||||
|
|
||||||
class Real
|
|
||||||
basic_request :get_ip_addresses
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,11 +1,18 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :get_layout
|
basic_request :get_layout
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_layout(uri)
|
||||||
|
environment_id = id_from_uri(uri)
|
||||||
|
layout = self.data[:layouts][environment_id]
|
||||||
|
|
||||||
|
response(:body => layout)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :get_layouts
|
basic_request :get_layouts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_layouts(uri)
|
||||||
|
environment_id = id_from_uri(uri)
|
||||||
|
layout = self.data[:layouts][environment_id]
|
||||||
|
|
||||||
|
response(:body => layout)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,17 @@ module Fog
|
||||||
basic_request :get_network
|
basic_request :get_network
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_network(uri)
|
||||||
|
network_id = id_from_uri(uri)
|
||||||
|
network = self.data[:networks][network_id].dup
|
||||||
|
|
||||||
|
if network
|
||||||
|
response(:body => Fog::Ecloud.slice(network, :id, :environment_id))
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,26 @@ module Fog
|
||||||
basic_request :get_networks
|
basic_request :get_networks
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_networks(uri)
|
||||||
|
environment_id = id_from_uri(uri)
|
||||||
|
environment = self.data[:environments][environment_id]
|
||||||
|
|
||||||
|
networks = self.data[:networks].values.select{|n| n[:environment_id] == environment_id}.dup
|
||||||
|
networks = networks.map{|n| Fog::Ecloud.slice(n, :environment, :id)}
|
||||||
|
|
||||||
|
body = {
|
||||||
|
:href => uri,
|
||||||
|
:type => "application/vnd.tmrk.cloud.network; type=collection",
|
||||||
|
:Links => {
|
||||||
|
:Link => Fog::Ecloud.keep(environment, :name, :href, :type)
|
||||||
|
},
|
||||||
|
:Network => (networks.size > 1 ? networks : networks.first),
|
||||||
|
}
|
||||||
|
|
||||||
|
response(:body => body)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,17 @@ module Fog
|
||||||
basic_request :get_node
|
basic_request :get_node
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_node(uri)
|
||||||
|
node_service_id = id_from_uri(uri)
|
||||||
|
node_service = self.data[:node_services][node_service_id.to_i]
|
||||||
|
|
||||||
|
if node_service
|
||||||
|
response(:body => Fog::Ecloud.slice(node_service, :id, :internet_service_id))
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,15 @@ module Fog
|
||||||
basic_request :get_nodes
|
basic_request :get_nodes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_nodes(uri)
|
||||||
|
|
||||||
|
internet_service_id = id_from_uri(uri)
|
||||||
|
internet_service = self.data[:internet_services][internet_service_id]
|
||||||
|
|
||||||
|
response(:body => internet_service)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,20 @@ module Fog
|
||||||
basic_request :get_operating_system
|
basic_request :get_operating_system
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_operating_system(uri)
|
||||||
|
os_name, compute_pool_id = uri.match(/operatingsystems\/(.*)\/computepools\/(\d+)$/).captures
|
||||||
|
compute_pool_id = compute_pool_id.to_i
|
||||||
|
|
||||||
|
operating_systems = self.data[:operating_systems].values.select{|os| os[:compute_pool_id] == compute_pool_id}
|
||||||
|
operating_system = operating_systems.find{|os| os[:short_name] == os_name}
|
||||||
|
|
||||||
|
if operating_system
|
||||||
|
response(:body => Fog::Ecloud.slice(operating_system, :id, :compute_pool_id, :short_name))
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,26 @@ module Fog
|
||||||
basic_request :get_operating_system_families
|
basic_request :get_operating_system_families
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_operating_system_families(uri)
|
||||||
|
compute_pool_id = id_from_uri(uri)
|
||||||
|
compute_pool = self.data[:compute_pools][compute_pool_id]
|
||||||
|
|
||||||
|
operating_system_families = self.data[:operating_system_families].values.select{|osf| osf[:compute_pool_id] == compute_pool_id}
|
||||||
|
operating_system_families = operating_system_families.map{|osf| Fog::Ecloud.slice(osf, :id, :compute_pool_id)}.map{|osf| osf[:OperatingSystemFamily]}
|
||||||
|
|
||||||
|
operating_system_family_response = {:OperatingSystemFamily => (operating_system_families.size > 1 ? operating_system_families : operating_system_families.first)} # GAH
|
||||||
|
body = {
|
||||||
|
:href => uri,
|
||||||
|
:type => "application/vnd.tmrk.cloud.operatingSystemFamily; type=collection",
|
||||||
|
:Links => {
|
||||||
|
:Link => compute_pool,
|
||||||
|
}
|
||||||
|
}.merge(operating_system_family_response)
|
||||||
|
|
||||||
|
response(:body => body)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
module Fog
|
|
||||||
module Compute
|
|
||||||
class Ecloud
|
|
||||||
|
|
||||||
class Real
|
|
||||||
basic_request :get_operating_system
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -6,6 +6,20 @@ module Fog
|
||||||
basic_request :get_organization
|
basic_request :get_organization
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_organization(uri)
|
||||||
|
organization_id = id_from_uri(uri)
|
||||||
|
organization = self.data[:organizations][organization_id]
|
||||||
|
|
||||||
|
body = {
|
||||||
|
:xmlns_i => "http://www.w3.org/2001/XMLSchema-instance",
|
||||||
|
:href => "/cloudapi/ecloud/organizations/",
|
||||||
|
:type => "application/vnd.tmrk.cloud.organization; type=collection"
|
||||||
|
}.merge(organization)
|
||||||
|
|
||||||
|
response(:body => body)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,23 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :get_organizations
|
basic_request :get_organizations
|
||||||
end
|
end # Real
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_organizations(uri)
|
||||||
|
organizations = self.data[:organizations].values.dup
|
||||||
|
organizations.each{|org| org.delete(:id)}
|
||||||
|
body = {
|
||||||
|
:xmlns_i => "http://www.w3.org/2001/XMLSchema-instance",
|
||||||
|
:href => "/cloudapi/ecloud/organizations/",
|
||||||
|
:type => "application/vnd.tmrk.cloud.organization; type=collection"
|
||||||
|
}.merge(:Organization => (organizations.size > 1 ? organizations : organizations.first))
|
||||||
|
|
||||||
|
response(:body => body)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :get_public_ip
|
basic_request :get_public_ip
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_public_ip(uri)
|
||||||
|
public_ip_id = id_from_uri(uri)
|
||||||
|
public_ip = self.data[:public_ips][public_ip_id]
|
||||||
|
|
||||||
|
if public_ip
|
||||||
|
response(:body => Fog::Ecloud.slice(public_ip, :id, :environment_id))
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,28 @@ module Fog
|
||||||
basic_request :get_public_ips
|
basic_request :get_public_ips
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_public_ips(uri)
|
||||||
|
|
||||||
|
environment_id = id_from_uri(uri)
|
||||||
|
environment = self.data[:environments][environment_id]
|
||||||
|
|
||||||
|
public_ips = self.data[:public_ips].values.select{|cp| cp[:environment_id] == environment_id}
|
||||||
|
|
||||||
|
public_ips = public_ips.map{|pi| Fog::Ecloud.slice(pi, :id, :environment_id)}
|
||||||
|
|
||||||
|
public_ip_response = {:PublicIp => (public_ips.size > 1 ? public_ips : public_ips.first)} # GAH
|
||||||
|
body = {
|
||||||
|
:href => uri,
|
||||||
|
:type => "application/vnd.tmrk.cloud.publicIp; type=collection",
|
||||||
|
:Links => {
|
||||||
|
:Link => environment,
|
||||||
|
}
|
||||||
|
}.merge(public_ip_response)
|
||||||
|
|
||||||
|
response(:body => body)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :get_row
|
basic_request :get_row
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_row(uri)
|
||||||
|
row_id = id_from_uri(uri)
|
||||||
|
row = self.data[:rows][row_id]
|
||||||
|
|
||||||
|
response(:body => row)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :get_rows
|
basic_request :get_rows
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,17 @@ module Fog
|
||||||
basic_request :get_server
|
basic_request :get_server
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_server(uri)
|
||||||
|
server_id = uri.match(/(\d+)/)
|
||||||
|
server_id = server_id.nil? ? nil : server_id[1].to_i
|
||||||
|
server = self.data[:servers][server_id]
|
||||||
|
if server
|
||||||
|
response(:body => Fog::Ecloud.slice(server, :id, :compute_pool_id))
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,42 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :get_servers
|
basic_request :get_servers
|
||||||
end
|
end
|
||||||
|
class Mock
|
||||||
|
def get_servers(uri)
|
||||||
|
if uri =~ /layoutgroups/i
|
||||||
|
group_id = id_from_uri(uri)
|
||||||
|
group = self.data[:groups][group_id]
|
||||||
|
servers = group[:VirtualMachines][:VirtualMachine]
|
||||||
|
compute_pool_id = servers.first[:compute_pool_id] unless servers.empty?
|
||||||
|
compute_pool = self.data[:compute_pools][compute_pool_id] unless compute_pool_id.nil?
|
||||||
|
elsif uri =~ /computepool/i
|
||||||
|
compute_pool_id = id_from_uri(uri)
|
||||||
|
compute_pool = self.data[:compute_pools][compute_pool_id]
|
||||||
|
servers = self.data[:servers].values.select{|cp| cp[:compute_pool_id] == compute_pool_id}
|
||||||
|
servers = servers.map{|server| Fog::Ecloud.slice(server, :id, :compute_pool_id)}
|
||||||
|
end
|
||||||
|
|
||||||
|
links = if compute_pool.nil?
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
[Fog::Ecloud.keep(compute_pool, :name, :href, :type),]
|
||||||
|
end
|
||||||
|
|
||||||
|
server_response = {:VirtualMachine => (servers.size > 1 ? servers : servers.first)} # GAH
|
||||||
|
body = {
|
||||||
|
:href => uri,
|
||||||
|
:type => "application/vnd.tmrk.cloud.virtualMachine; type=collection",
|
||||||
|
:Links => {
|
||||||
|
:Link => links
|
||||||
|
}
|
||||||
|
}.merge(server_response)
|
||||||
|
|
||||||
|
response(:body => body)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,17 @@ module Fog
|
||||||
basic_request :get_ssh_key
|
basic_request :get_ssh_key
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_ssh_key(uri)
|
||||||
|
ssh_key_id = id_from_uri(uri).to_i
|
||||||
|
ssh_key = self.data[:ssh_keys][ssh_key_id.to_i]
|
||||||
|
|
||||||
|
if ssh_key
|
||||||
|
response(:body => Fog::Ecloud.slice(ssh_key, :id, :admin_organization))
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,26 @@ module Fog
|
||||||
basic_request :get_ssh_keys
|
basic_request :get_ssh_keys
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_ssh_keys(uri)
|
||||||
|
organization_id = id_from_uri(uri)
|
||||||
|
organization = self.data[:organizations][organization_id]
|
||||||
|
|
||||||
|
ssh_keys = self.data[:ssh_keys].values.select{|key| key[:admin_organization_id] == organization_id}
|
||||||
|
ssh_keys = ssh_keys.map{|key| Fog::Ecloud.slice(key, :id, :admin_organization)}
|
||||||
|
|
||||||
|
ssh_key_response = {:SshKey => (ssh_keys.size > 1 ? ssh_keys : ssh_keys.first)} # GAH
|
||||||
|
body = {
|
||||||
|
:href => "/cloudapi/ecloud/admin/organizations/#{organization_id}/sshKeys",
|
||||||
|
:type => "application/vnd.tmrk.cloud.sshKey; type=collection",
|
||||||
|
:Links => {
|
||||||
|
:Link => organization,
|
||||||
|
},
|
||||||
|
}.merge(ssh_key_response)
|
||||||
|
|
||||||
|
response(:body => body)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :get_task
|
basic_request :get_task
|
||||||
end
|
end
|
||||||
|
class Mock
|
||||||
|
def get_task(uri)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,17 @@ module Fog
|
||||||
basic_request :get_template
|
basic_request :get_template
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_template(uri)
|
||||||
|
template_id, compute_pool_id = uri.match(/(\d+).*\/(\d+)$/).captures
|
||||||
|
template = self.data[:templates][template_id.to_i]
|
||||||
|
|
||||||
|
if template
|
||||||
|
response(:body => Fog::Ecloud.slice(template, :id, :environment))
|
||||||
|
else response(:status => 404) # ?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,44 @@ module Fog
|
||||||
basic_request :get_templates
|
basic_request :get_templates
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_templates(uri) # /cloudapi/ecloud/computepools/compute_pools/534
|
||||||
|
compute_pool_id = id_from_uri(uri)
|
||||||
|
compute_pool = self.data[:compute_pools][compute_pool_id]
|
||||||
|
|
||||||
|
templates = self.data[:templates].values.select{|template| template[:compute_pool_id] == compute_pool_id}
|
||||||
|
templates = templates.map{|template| Fog::Ecloud.slice(template, :id, :compute_pool)}
|
||||||
|
|
||||||
|
template_response = {:Template => (templates.size > 1 ? templates : templates.first)} # GAH
|
||||||
|
body = {
|
||||||
|
:href => uri,
|
||||||
|
:type => "application/vnd.tmrk.cloud.template; type=collection",
|
||||||
|
:Links => {
|
||||||
|
:Link => compute_pool,
|
||||||
|
},
|
||||||
|
:Families => {
|
||||||
|
:Family => {
|
||||||
|
:Name => "Standard Templates",
|
||||||
|
:Categories => {
|
||||||
|
:Category => [
|
||||||
|
{
|
||||||
|
:Name => "OS Only",
|
||||||
|
:OperatingSystems => {
|
||||||
|
:OperatingSystem => {
|
||||||
|
:Name => "Linux",
|
||||||
|
:Templates => template_response,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response(:body => body)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ecloud
|
||||||
|
|
||||||
|
class Real
|
||||||
|
def get_virtual_machine_assigned_ips(virtual_machine_id)
|
||||||
|
request(
|
||||||
|
:uri => "/cloudapi/ecloud/virtualmachines/#{virtual_machine_id}/assignedips",
|
||||||
|
:parse => true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def get_virtual_machine_assigned_ips(virtual_machine_id)
|
||||||
|
server = self.data[:servers][virtual_machine_id.to_i]
|
||||||
|
compute_pool = self.data[:compute_pools][server[:compute_pool_id]]
|
||||||
|
environment_id = compute_pool[:environment_id]
|
||||||
|
environment = self.data[:environments][environment_id]
|
||||||
|
|
||||||
|
networks = self.data[:networks].values.select{|n| n[:environment_id] == environment_id}
|
||||||
|
networks = networks.map{|n| deep_copy(Fog::Ecloud.slice(n, :environment, :id))}
|
||||||
|
|
||||||
|
|
||||||
|
networks.each do |network|
|
||||||
|
address = network[:IpAddresses][:IpAddress].map{|ia| ia[:name]}
|
||||||
|
network[:IpAddresses][:IpAddress] = address.first
|
||||||
|
end
|
||||||
|
|
||||||
|
body = {
|
||||||
|
:href => "/cloudapi/ecloud/virtualMachines/#{virtual_machine_id}/assignedIps",
|
||||||
|
:type => "application/vnd.tmrk.cloud.network",
|
||||||
|
:Links => {
|
||||||
|
:Link => Fog::Ecloud.keep(environment, :name, :href, :type)
|
||||||
|
},
|
||||||
|
:Networks => {:Network => (networks.size > 1 ? networks : networks.first)},
|
||||||
|
}
|
||||||
|
|
||||||
|
response(:body => body)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,11 +1,26 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :groups_delete, 204, 'DELETE'
|
basic_request :groups_delete, 204, 'DELETE'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def groups_delete(uri)
|
||||||
|
group_id = id_from_uri(uri)
|
||||||
|
self.data[:groups].delete(group_id)
|
||||||
|
self.data[:rows].values.each do |row|
|
||||||
|
row[:Groups][:Group].delete_if { |g| g[:id] == group_id }
|
||||||
|
end
|
||||||
|
self.data[:layouts].values.each do |layout|
|
||||||
|
layout[:Rows][:Row].each do |row|
|
||||||
|
row[:Groups][:Group].delete_if { |g| g[:id] == group_id }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
response(:body => nil, :status => 204)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -62,6 +62,41 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def internet_service_create(service_data)
|
||||||
|
validate_internet_service_data(service_data)
|
||||||
|
public_ip_id = service_data[:uri].match(/(\d+)/)[1]
|
||||||
|
public_ip = self.data[:public_ips][public_ip_id.to_i].dup
|
||||||
|
service_id = Fog::Mock.random_numbers(6).to_i
|
||||||
|
service = {
|
||||||
|
:href => "/cloudapi/ecloud/internetServices/#{service_id}",
|
||||||
|
:name => service_data[:name],
|
||||||
|
:type => "application/vnd.tmrk.cloud.internetService",
|
||||||
|
:Links => {
|
||||||
|
:Link => [
|
||||||
|
Fog::Ecloud.keep(public_ip, :href, :name, :type),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:Protocol => service_data[:protocol],
|
||||||
|
:Port => service_data[:port],
|
||||||
|
:Enabled => service_data[:enabled],
|
||||||
|
:Description => service_data[:description],
|
||||||
|
:PublicIp => Fog::Ecloud.keep(public_ip, :href, :name, :type),
|
||||||
|
:Persistence => {
|
||||||
|
:Type => service_data[:persistence][:type],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
internet_service_response = response(:body => service)
|
||||||
|
|
||||||
|
service.merge!(:public_ip => public_ip)
|
||||||
|
|
||||||
|
self.data[:internet_services][service_id] = service
|
||||||
|
|
||||||
|
internet_service_response
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,29 @@ module Fog
|
||||||
basic_request :internet_service_delete, 202, 'DELETE'
|
basic_request :internet_service_delete, 202, 'DELETE'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def internet_service_delete(uri)
|
||||||
|
service_id = id_from_uri(uri)
|
||||||
|
|
||||||
|
service = self.data[:internet_services][service_id].dup
|
||||||
|
self.data[:internet_services].delete(service_id)
|
||||||
|
|
||||||
|
task_id = Fog::Mock.random_numbers(10).to_i
|
||||||
|
task = {
|
||||||
|
:id => task_id,
|
||||||
|
:href => "/cloudapi/ecloud/tasks/#{task_id}",
|
||||||
|
:type => "application/vnd.tmrk.cloud.task",
|
||||||
|
:Operation => "Delete Service",
|
||||||
|
:Status => "Complete",
|
||||||
|
:ImpactedItem => Fog::Ecloud.keep(service, :name, :href, :type),
|
||||||
|
:StartTime => Time.now.iso8601,
|
||||||
|
:CompletedTime => Time.now.iso8601,
|
||||||
|
:InitiatedBy => {},
|
||||||
|
}
|
||||||
|
self.data[:tasks][task_id] = task
|
||||||
|
response(:body => task)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,6 +40,54 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def node_service_create(service_data)
|
||||||
|
validate_node_service_data(service_data)
|
||||||
|
|
||||||
|
internet_service_id = service_data[:uri].match(/(\d+)/)[1]
|
||||||
|
internet_service = self.data[:internet_services][internet_service_id.to_i].dup
|
||||||
|
network_id, ip_address_name = service_data[:ip_address].match(/\/(\d+)\/(.*)$/).captures
|
||||||
|
network = self.data[:networks][network_id.to_i]
|
||||||
|
ip_addresses = network[:IpAddresses][:IpAddress]
|
||||||
|
ip_addresses = ip_addresses.is_a?(Array) ? ip_addresses : [ip_addresses]
|
||||||
|
ip_address = ip_addresses.detect { |ip| ip[:name] == ip_address_name }
|
||||||
|
|
||||||
|
service_id = Fog::Mock.random_numbers(6).to_i
|
||||||
|
service = {
|
||||||
|
:href => "/cloudapi/ecloud/nodeservices/#{service_id}",
|
||||||
|
:name => service_data[:name],
|
||||||
|
:type => "application/vnd.tmrk.cloud.nodeService",
|
||||||
|
:Links => {
|
||||||
|
:Link => [
|
||||||
|
Fog::Ecloud.keep(internet_service, :href, :name, :type),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:Protocol => service_data[:protocol],
|
||||||
|
:Port => service_data[:port],
|
||||||
|
:Enabled => service_data[:enabled],
|
||||||
|
:Description => service_data[:description],
|
||||||
|
:IpAddress => {
|
||||||
|
:href => ip_address[:href],
|
||||||
|
:name => ip_address[:name],
|
||||||
|
:type => ip_address[:type],
|
||||||
|
:Network => {
|
||||||
|
:href => network[:href],
|
||||||
|
:name => network[:name],
|
||||||
|
:type => network[:type],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
node_service_response = response(:body => service)
|
||||||
|
|
||||||
|
service.merge!(:internet_service => internet_service)
|
||||||
|
|
||||||
|
self.data[:node_services][service_id] = service
|
||||||
|
|
||||||
|
node_service_response
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,30 @@ module Fog
|
||||||
basic_request :node_service_delete, 202, 'DELETE'
|
basic_request :node_service_delete, 202, 'DELETE'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def node_service_delete(uri)
|
||||||
|
|
||||||
|
service_id = id_from_uri(uri)
|
||||||
|
|
||||||
|
service = self.data[:node_services][service_id].dup
|
||||||
|
self.data[:node_services].delete(service_id)
|
||||||
|
|
||||||
|
task_id = Fog::Mock.random_numbers(10).to_i
|
||||||
|
task = {
|
||||||
|
:id => task_id,
|
||||||
|
:href => "/cloudapi/ecloud/tasks/#{task_id}",
|
||||||
|
:type => "application/vnd.tmrk.cloud.task",
|
||||||
|
:Operation => "Delete Node Service",
|
||||||
|
:Status => "Complete",
|
||||||
|
:ImpactedItem => Fog::Ecloud.keep(service, :name, :href, :type),
|
||||||
|
:StartTime => Time.now.iso8601,
|
||||||
|
:CompletedTime => Time.now.iso8601,
|
||||||
|
:InitiatedBy => {},
|
||||||
|
}
|
||||||
|
self.data[:tasks][task_id] = task
|
||||||
|
response(:body => task)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :rows_delete, 204, 'DELETE'
|
basic_request :rows_delete, 204, 'DELETE'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def rows_delete(uri)
|
||||||
|
row_id = id_from_uri(uri)
|
||||||
|
self.data[:rows].delete(row_id)
|
||||||
|
self.data[:layouts].values.each do |layout|
|
||||||
|
layout[:Rows][:Row].delete_if { |r| r[:id] == row_id }
|
||||||
|
end
|
||||||
|
|
||||||
|
response(:body => nil, :status => 204)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
module Fog
|
|
||||||
module Compute
|
|
||||||
class Ecloud
|
|
||||||
module Shared
|
|
||||||
|
|
||||||
def build_request_body_add_ip(networks)
|
|
||||||
xml = Builder::XmlMarkup.new
|
|
||||||
xml.AssignedIpAddresses do
|
|
||||||
xml.Networks do
|
|
||||||
networks.each do |network|
|
|
||||||
xml.Network(:href => network[:href], :type => network[:type]) do
|
|
||||||
xml.IpAddresses do
|
|
||||||
network[:ips].each do |ip|
|
|
||||||
xml.IpAddress ip
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Real
|
|
||||||
|
|
||||||
def virtual_machine_add_ip(href, options)
|
|
||||||
body = build_request_body_add_ip(options)
|
|
||||||
request(
|
|
||||||
:expects => 202,
|
|
||||||
:method => 'PUT',
|
|
||||||
:headers => {},
|
|
||||||
:body => body,
|
|
||||||
:uri => href,
|
|
||||||
:parse => true
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ecloud
|
||||||
|
module Shared
|
||||||
|
|
||||||
|
def build_request_body_attach_disk(options)
|
||||||
|
xml = Builder::XmlMarkup.new
|
||||||
|
xml.AttachDisks(:name => options[:name]) do
|
||||||
|
xml.DetachedDisks do
|
||||||
|
xml.DetachedDisk(:href => options[:href], :name => options[:name], :type => "application/vnd.tmrk.cloud.detachedDisk")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Real
|
||||||
|
def virtual_machine_attach_disk(href, options)
|
||||||
|
body = build_request_body_attach_disk(options)
|
||||||
|
request(
|
||||||
|
:expects => 202,
|
||||||
|
:method => 'POST',
|
||||||
|
:headers => {},
|
||||||
|
:body => body,
|
||||||
|
:uri => href,
|
||||||
|
:parse => true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def virtual_machine_attach_disk(href, options)
|
||||||
|
server_id = href.match(/(\d+)/)[1].to_i
|
||||||
|
server = self.data[:servers][server_id]
|
||||||
|
compute_pool_id = server[:compute_pool_id]
|
||||||
|
compute_pool = self.data[:compute_pools][compute_pool_id]
|
||||||
|
detached_disk_id = options[:href].match(/(\d+)/)[1].to_i
|
||||||
|
detached_disk = self.data[:detached_disks][detached_disk_id]
|
||||||
|
new_index = (server[:HardwareConfiguration][:Disks][:Disk].map { |h| h[:Index].to_i }.sort.last + 1).to_s
|
||||||
|
detached_disk[:Index] = new_index
|
||||||
|
server[:HardwareConfiguration][:Disks][:Disk] << Fog::Ecloud.keep(detached_disk, :Index, :Size, :Name)
|
||||||
|
|
||||||
|
self.data[:detached_disks].delete(detached_disk_id)
|
||||||
|
|
||||||
|
task_id = Fog::Mock.random_numbers(10).to_i
|
||||||
|
task = {
|
||||||
|
:id => task_id,
|
||||||
|
:href => "/cloudapi/ecloud/tasks/#{task_id}",
|
||||||
|
:type => "application/vnd.tmrk.cloud.task",
|
||||||
|
:Operation => "Attach Disk",
|
||||||
|
:Status => "Complete",
|
||||||
|
:ImpactedItem => Fog::Ecloud.keep(server, :href, :type),
|
||||||
|
:StartTime => Time.now.iso8601,
|
||||||
|
:CompletedTime => Time.now.iso8601,
|
||||||
|
:InitiatedBy => {},
|
||||||
|
}
|
||||||
|
self.data[:tasks][task_id] = task
|
||||||
|
response(:body => task)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -14,12 +14,6 @@ module Fog
|
||||||
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
|
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
|
||||||
end
|
end
|
||||||
|
|
||||||
if template_uri.scan(/\/catalog\/\d+/)[0]
|
|
||||||
options[:template_type] = get_catalog_item(template_uri).body[:type]
|
|
||||||
elsif template_uri.scan(/\/templates\/\d+/)[0]
|
|
||||||
options[:template_type] = get_template(template_uri).body[:type]
|
|
||||||
end
|
|
||||||
|
|
||||||
options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
|
options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
|
||||||
options[:network_uri].map! do |uri|
|
options[:network_uri].map! do |uri|
|
||||||
network = get_network(uri).body
|
network = get_network(uri).body
|
||||||
|
@ -27,7 +21,7 @@ module Fog
|
||||||
ip = options[:ips][options[:network_uri].index(uri)]
|
ip = options[:ips][options[:network_uri].index(uri)]
|
||||||
end
|
end
|
||||||
{:href => uri, :name => network[:name], :ip => ip}
|
{:href => uri, :name => network[:name], :ip => ip}
|
||||||
end
|
end
|
||||||
options[:template_uri] = template_uri
|
options[:template_uri] = template_uri
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
@ -82,7 +76,7 @@ module Fog
|
||||||
options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
|
options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
|
||||||
options[:network_uri].each do |uri|
|
options[:network_uri].each do |uri|
|
||||||
xml.NetworkAdapter do
|
xml.NetworkAdapter do
|
||||||
xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network")
|
xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network")
|
||||||
xml.IpAddress uri[:ip]
|
xml.IpAddress uri[:ip]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -95,31 +89,157 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
xml.SshKey(:href => options[:ssh_key_uri])
|
xml.SshKey(:href => options[:ssh_key_uri])
|
||||||
end
|
end
|
||||||
xml.PoweredOn options[:powered_on]
|
xml.PoweredOn options[:powered_on]
|
||||||
xml.Template(:href => options[:template_uri], :type => options[:template_type])
|
xml.Template(:href => options[:template_uri], :type => options[:template_type])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def virtual_machine_create_from_template(template_uri, options)
|
def virtual_machine_create_from_template(template_uri, options)
|
||||||
options = validate_create_server_options(template_uri, options)
|
options = validate_create_server_options(template_uri, options)
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:expects => 201,
|
:expects => 201,
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:headers => {},
|
:body => build_request_body(options),
|
||||||
:body => build_request_body(options),
|
:uri => options[:uri],
|
||||||
:uri => options[:uri],
|
:parse => true
|
||||||
:parse => true
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def virtual_machine_create_from_template(template_uri, options)
|
||||||
|
options = validate_create_server_options(template_uri, options)
|
||||||
|
server_id = Fog::Mock.random_numbers(7).to_i
|
||||||
|
row_id = Fog::Mock.random_numbers(6).to_i
|
||||||
|
group_id = Fog::Mock.random_numbers(6).to_i
|
||||||
|
template_id, compute_pool_id = template_uri.match(/\/templates\/(\d+)\/computepools\/(\d+)$/).captures
|
||||||
|
compute_pool = self.data[:compute_pools][compute_pool_id.to_i].dup
|
||||||
|
environment = self.data[:environments][compute_pool[:environment_id]]
|
||||||
|
layout = self.data[:layouts][environment[:id]]
|
||||||
|
networks = options[:network_uri]
|
||||||
|
nics = networks.each_with_index.map do |network, i|
|
||||||
|
{
|
||||||
|
:UnitNumber => i.to_s,
|
||||||
|
:Name => "Network adapter #{i}",
|
||||||
|
:MacAddress => Fog::Ecloud.mac_address,
|
||||||
|
:Network => Fog::Ecloud.keep(network, :name, :href, :type),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
links = [Fog::Ecloud.keep(compute_pool, :name, :href, :type), Fog::Ecloud.keep(environment, :name, :href, :type)]
|
||||||
|
networks.each do |network|
|
||||||
|
links << Fog::Ecloud.keep(network, :name, :href, :type)
|
||||||
|
network_id = id_from_uri(network[:href])
|
||||||
|
ip = self.data[:networks][network_id][:IpAddresses][:IpAddress].detect { |ip| ip[:id] = network[:ip] }
|
||||||
|
ip[:DetectedOn] = {:href => "/cloudapi/ecloud/networkhosts/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.networkHost"}
|
||||||
|
ip[:Host] = {:href => "/cloudapi/ecloud/networkhosts/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.networkHost"}
|
||||||
|
end
|
||||||
|
|
||||||
|
server = {
|
||||||
|
:href => "/cloudapi/ecloud/virtualmachines/#{server_id}",
|
||||||
|
:name => options[:name],
|
||||||
|
:type => "application/vnd.tmrk.cloud.virtualMachine",
|
||||||
|
:Description => options[:description],
|
||||||
|
:Status => "Deployed",
|
||||||
|
:HardwareConfiguration => {
|
||||||
|
:href => "/cloudapi/ecloud/virtualmachines/#{server_id}/hardwareconfiguration",
|
||||||
|
:type => "application/vnd.tmrk.cloud.virtualMachineHardware",
|
||||||
|
:Links => {
|
||||||
|
:Link => {
|
||||||
|
:href => "/cloudapi/ecloud/virtualmachines/#{server_id}",
|
||||||
|
:name => options[:name],
|
||||||
|
:type => "application/vnd.tmrk.cloud.virtualMachine",
|
||||||
|
:rel => "up",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:ProcessorCount => options[:cpus],
|
||||||
|
:Memory => {
|
||||||
|
:Unit => "MB",
|
||||||
|
:Value => options[:memory],
|
||||||
|
},
|
||||||
|
:Disks => {
|
||||||
|
:Disk => [{
|
||||||
|
:Index => "0",
|
||||||
|
:Name => "Hard Disk 1",
|
||||||
|
:Size => {
|
||||||
|
:Unit => "GB",
|
||||||
|
:Value => "25",
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
:Nics => {
|
||||||
|
:Nic => nics,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
:IpAddresses => {
|
||||||
|
:AssignedIpAddresses => {
|
||||||
|
:Networks => {
|
||||||
|
:Network => self.data[:networks].dup.values,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:Links => { :Link => links },
|
||||||
|
}
|
||||||
|
|
||||||
|
row = {
|
||||||
|
:id => row_id,
|
||||||
|
:name => options[:row],
|
||||||
|
:href => "/cloudapi/ecloud/layoutrows/#{row_id}",
|
||||||
|
:type => "application/vnd.tmrk.cloud.layoutRow",
|
||||||
|
:Links => {
|
||||||
|
:Link => [
|
||||||
|
Fog::Ecloud.keep(environment, :name, :href, :type)
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:Index => 0,
|
||||||
|
:Groups => {
|
||||||
|
:Group => [
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:environment_id => environment[:id],
|
||||||
|
}
|
||||||
|
|
||||||
|
group = {
|
||||||
|
:id => group_id,
|
||||||
|
:name => options[:group],
|
||||||
|
:href => "/cloudapi/ecloud/layoutgroups/#{group_id}",
|
||||||
|
:type => "application/vnd.tmrk.cloud.layoutGroup",
|
||||||
|
:Links => {
|
||||||
|
:Link => [
|
||||||
|
Fog::Ecloud.keep(row, :name, :href, :type),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:Index => 0,
|
||||||
|
:VirtualMachines => {
|
||||||
|
:VirtualMachine => [
|
||||||
|
server,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:row_id => row_id,
|
||||||
|
}
|
||||||
|
row[:Groups][:Group].push(group)
|
||||||
|
layout[:Rows][:Row].push(row)
|
||||||
|
|
||||||
|
server.merge!(:OperatingSystem => options[:operating_system].merge(:type => "application/vnd.tmrk.cloud.operatingSystem")) if options[:operating_system]
|
||||||
|
|
||||||
|
server_response = response(:body => server)
|
||||||
|
|
||||||
|
server.merge!(:compute_pool_id => compute_pool[:id])
|
||||||
|
|
||||||
|
self.data[:servers][server_id] = server
|
||||||
|
self.data[:rows][row_id] = row
|
||||||
|
self.data[:groups][group_id] = group
|
||||||
|
|
||||||
|
server_response
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,46 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class Ecloud
|
class Ecloud
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
basic_request :virtual_machine_delete, 202, 'DELETE'
|
basic_request :virtual_machine_delete, 202, 'DELETE'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def virtual_machine_delete(uri)
|
||||||
|
server_id = id_from_uri(uri)
|
||||||
|
|
||||||
|
server = self.data[:servers][server_id]
|
||||||
|
self.data[:servers].delete(server_id)
|
||||||
|
self.data[:groups].values.each do |group|
|
||||||
|
group[:VirtualMachines][:VirtualMachine].delete_if { |s| s[:name] == server[:name] }
|
||||||
|
end
|
||||||
|
self.data[:networks].values.each do |network|
|
||||||
|
network[:IpAddresses][:IpAddress].each do |ip|
|
||||||
|
unless ip[:Host].nil?
|
||||||
|
ip[:Host] = nil if ip[:Host][:name] == server[:name]
|
||||||
|
end
|
||||||
|
unless ip[:DetectedOn].nil?
|
||||||
|
ip[:DetectedOn] = nil if ip[:DetectedOn][:name] == server[:name]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
task_id = Fog::Mock.random_numbers(10)
|
||||||
|
task = {
|
||||||
|
:id => task_id,
|
||||||
|
:href => "/cloudapi/ecloud/tasks/#{task_id}",
|
||||||
|
:type => "application/vnd.tmrk.cloud.task",
|
||||||
|
:Operation => "Delete Server",
|
||||||
|
:Status => "Complete",
|
||||||
|
:ImpactedItem => Fog::Ecloud.keep(server, :name, :href, :type),
|
||||||
|
:StartTime => Time.now.iso8601,
|
||||||
|
:CompletedTime => Time.now.iso8601,
|
||||||
|
:InitiatedBy => {},
|
||||||
|
}
|
||||||
|
self.data[:tasks][task_id] = task
|
||||||
|
|
||||||
|
response(:body => task)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ecloud
|
||||||
|
module Shared
|
||||||
|
|
||||||
|
def build_request_body_detach_disk(options)
|
||||||
|
xml = Builder::XmlMarkup.new
|
||||||
|
xml.DetachDisk(:name => options[:name]) do
|
||||||
|
xml.Description options[:description]
|
||||||
|
xml.Disk do
|
||||||
|
xml.Index options[:disk][:Index]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Real
|
||||||
|
def virtual_machine_detach_disk(href, options)
|
||||||
|
body = build_request_body_detach_disk(options)
|
||||||
|
request(
|
||||||
|
:expects => 201,
|
||||||
|
:method => 'POST',
|
||||||
|
:headers => {},
|
||||||
|
:body => body,
|
||||||
|
:uri => href,
|
||||||
|
:parse => true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def virtual_machine_detach_disk(href, options)
|
||||||
|
server_id = href.match(/(\d+)/)[1].to_i
|
||||||
|
server = self.data[:servers][server_id]
|
||||||
|
compute_pool_id = server[:compute_pool_id]
|
||||||
|
compute_pool = self.data[:compute_pools][compute_pool_id]
|
||||||
|
detached_disk_id = Fog::Mock.random_numbers(6).to_i
|
||||||
|
detached_disk = {
|
||||||
|
:id => detached_disk_id,
|
||||||
|
:href => "/cloudapi/ecloud/detacheddisks/#{detached_disk_id}",
|
||||||
|
:name => options[:name],
|
||||||
|
:type => "application/vnd.tmrk.cloud.detachedDisk",
|
||||||
|
:Links => {
|
||||||
|
:Link => [
|
||||||
|
Fog::Ecloud.keep(compute_pool, :href, :name, :type),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:Description => options[:description],
|
||||||
|
:LastKnownVirtualMachineConfiguration => Fog::Ecloud.keep(server, :name, :ProcessorCount, :Memory, :OperatingSystem),
|
||||||
|
:Type => "Data",
|
||||||
|
:Size => {
|
||||||
|
:Unit => "GB",
|
||||||
|
:Value => options[:disk][:Size][:Value],
|
||||||
|
},
|
||||||
|
:Status => "Available",
|
||||||
|
}
|
||||||
|
|
||||||
|
server[:HardwareConfiguration][:Disks][:Disk].delete_if { |disk| disk[:Index] == options[:disk][:Index] }
|
||||||
|
|
||||||
|
detached_disk_response = response(:body => detached_disk)
|
||||||
|
|
||||||
|
detached_disk.merge!(:compute_pool_id => compute_pool_id)
|
||||||
|
|
||||||
|
self.data[:detached_disks][detached_disk_id] = detached_disk
|
||||||
|
|
||||||
|
detached_disk_response
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,82 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Ecloud
|
||||||
|
module Shared
|
||||||
|
|
||||||
|
def build_request_body_edit_assigned_ips(networks)
|
||||||
|
xml = Builder::XmlMarkup.new
|
||||||
|
xml.AssignedIpAddresses do
|
||||||
|
xml.Networks do
|
||||||
|
networks.each do |network|
|
||||||
|
xml.Network(:href => network[:href], :type => network[:type]) do
|
||||||
|
xml.IpAddresses do
|
||||||
|
network[:ips].each do |ip|
|
||||||
|
xml.IpAddress ip
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Real
|
||||||
|
|
||||||
|
def virtual_machine_edit_assigned_ips(href, options)
|
||||||
|
body = build_request_body_edit_assigned_ips(options)
|
||||||
|
request(
|
||||||
|
:expects => 202,
|
||||||
|
:method => 'PUT',
|
||||||
|
:headers => {},
|
||||||
|
:body => body,
|
||||||
|
:uri => href,
|
||||||
|
:parse => true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def virtual_machine_edit_assigned_ips(href, options)
|
||||||
|
server_id = href.match(/(\d+)/)[1].to_i
|
||||||
|
server = self.data[:servers][server_id]
|
||||||
|
options.each do |network|
|
||||||
|
network_id = id_from_uri(network[:href])
|
||||||
|
network = self.data[:networks][network_id]
|
||||||
|
options.each.each do |net|
|
||||||
|
net[:ips].each do |ip|
|
||||||
|
ip = network[:IpAddresses][:IpAddress].detect { |iph| iph[:name] == ip }
|
||||||
|
ip[:Host] = {
|
||||||
|
:href => "/clouapi/ecloud/networkhosts/#{server_id}",
|
||||||
|
:name => server[:name],
|
||||||
|
:type => "application/vnd.tmrk.cloud.networkHost"
|
||||||
|
}
|
||||||
|
ip[:DetectedOn] = {
|
||||||
|
:href => "/clouapi/ecloud/networkhosts/#{server_id}",
|
||||||
|
:name => server[:name],
|
||||||
|
:type => "application/vnd.tmrk.cloud.networkHost"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
task_id = Fog::Mock.random_numbers(10)
|
||||||
|
task = {
|
||||||
|
:id => task_id,
|
||||||
|
:href => "/cloudapi/ecloud/tasks/#{task_id}",
|
||||||
|
:type => "application/vnd.tmrk.cloud.task",
|
||||||
|
:Operation => "Delete Server",
|
||||||
|
:Status => "Complete",
|
||||||
|
:ImpactedItem => Fog::Ecloud.keep(server, :name, :href, :type),
|
||||||
|
:StartTime => Time.now.iso8601,
|
||||||
|
:CompletedTime => Time.now.iso8601,
|
||||||
|
:InitiatedBy => {},
|
||||||
|
}
|
||||||
|
self.data[:tasks][task_id] = task
|
||||||
|
|
||||||
|
response(:body => task)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -21,8 +21,8 @@ module Fog
|
||||||
xml.HardwareConfiguration do
|
xml.HardwareConfiguration do
|
||||||
xml.ProcessorCount data[:cpus]
|
xml.ProcessorCount data[:cpus]
|
||||||
xml.Memory do
|
xml.Memory do
|
||||||
xml.Unit data[:memory][:Unit]
|
xml.Unit "MB"
|
||||||
xml.Value data[:memory][:Value]
|
xml.Value data[:memory]
|
||||||
end
|
end
|
||||||
xml.Disks do
|
xml.Disks do
|
||||||
data[:disks].each do |disk|
|
data[:disks].each do |disk|
|
||||||
|
@ -45,7 +45,31 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def virtual_machine_edit_hardware_configuration(vm_uri, data)
|
||||||
|
|
||||||
|
server_id = vm_uri.match(/(\d+)/)[1]
|
||||||
|
|
||||||
|
server = self.data[:servers][server_id.to_i]
|
||||||
|
task_id = Fog::Mock.random_numbers(10)
|
||||||
|
task = {
|
||||||
|
:id => task_id,
|
||||||
|
:href => "/cloudapi/ecloud/tasks/#{task_id}",
|
||||||
|
:type => "application/vnd.tmrk.cloud.task",
|
||||||
|
:Operation => "Configure Server",
|
||||||
|
:Status => "Complete",
|
||||||
|
:ImpactedItem => Fog::Ecloud.keep(server, :name, :href, :type),
|
||||||
|
:StartTime => Time.now.iso8601,
|
||||||
|
:CompletedTime => Time.now.iso8601,
|
||||||
|
:InitiatedBy => {},
|
||||||
|
}
|
||||||
|
self.data[:tasks][task_id] = task
|
||||||
|
|
||||||
|
response(:body => task)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
||||||
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
|
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
|
||||||
end
|
end
|
||||||
|
|
||||||
options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
|
options[:network_uri] = [*options[:network_uri]]
|
||||||
options[:template_uri] = template_uri
|
options[:template_uri] = template_uri
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
@ -54,14 +54,128 @@ module Fog
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:expects => 201,
|
:expects => 201,
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:headers => {},
|
:body => build_request_body_import(options),
|
||||||
:body => build_request_body_import(options),
|
:uri => options[:uri],
|
||||||
:uri => options[:uri],
|
:parse => true
|
||||||
:parse => true
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def virtual_machine_import(template_uri, options)
|
||||||
|
options = validate_import_server_options(template_uri, options)
|
||||||
|
|
||||||
|
compute_pool_id = options[:uri].match(/computePools\/(\d+)/)[1].to_i
|
||||||
|
compute_pool = self.data[:compute_pools][compute_pool_id].dup
|
||||||
|
environment = self.data[:environments][compute_pool[:environment_id]]
|
||||||
|
networks = options[:network_uri].map{|nuri| self.data[:networks][id_from_uri(nuri)].dup}
|
||||||
|
server_id = Fog::Mock.random_numbers(6).to_i
|
||||||
|
row_id = Fog::Mock.random_numbers(6).to_i
|
||||||
|
group_id = Fog::Mock.random_numbers(6).to_i
|
||||||
|
nics = networks.each_with_index.map do |network, i|
|
||||||
|
{
|
||||||
|
:UnitNumber => i.to_s,
|
||||||
|
:Name => "Network adapter #{i}",
|
||||||
|
:MacAddress => Fog::Ecloud.mac_address,
|
||||||
|
:Network => Fog::Ecloud.keep(network, :name, :href, :type)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
links = [Fog::Ecloud.keep(compute_pool, :name, :href, :type), Fog::Ecloud.keep(environment, :name, :href, :type)]
|
||||||
|
networks.each{|network| links << Fog::Ecloud.keep(network, :name, :href, :type)}
|
||||||
|
server = {
|
||||||
|
:href => "/cloudapi/ecloud/virtualmachines/#{server_id}",
|
||||||
|
:name => options[:name],
|
||||||
|
:type => "application/vnd.tmrk.cloud.virtualMachine",
|
||||||
|
:Description => options[:description],
|
||||||
|
:Status => "Deployed",
|
||||||
|
:PoweredOn => "false",
|
||||||
|
:HardwareConfiguration => {
|
||||||
|
:href => "/cloudapi/ecloud/virtualmachines/#{server_id}/hardwareconfiguration",
|
||||||
|
:type => "application/vnd.tmrk.cloud.virtualMachineHardware",
|
||||||
|
:Links => {
|
||||||
|
:Link => {
|
||||||
|
:href => "/cloudapi/ecloud/virtualmachines/#{server_id}",
|
||||||
|
:name => options[:name],
|
||||||
|
:type => "application/vnd.tmrk.cloud.virtualMachine",
|
||||||
|
:rel => "up"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:ProcessorCount => options[:cpus],
|
||||||
|
:Memory => {
|
||||||
|
:Unit => "MB",
|
||||||
|
:Value => options[:memory],
|
||||||
|
},
|
||||||
|
:Disks => { # Default drive
|
||||||
|
:Disk => [{
|
||||||
|
:Index => "0",
|
||||||
|
:Name => "Hard Disk 1",
|
||||||
|
:Size => {
|
||||||
|
:Unit => "GB",
|
||||||
|
:Value => "25"
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
:Nics => {
|
||||||
|
:Nic => nics,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
:Links => { :Link => links },
|
||||||
|
}
|
||||||
|
|
||||||
|
row = {
|
||||||
|
:id => row_id,
|
||||||
|
:name => options[:row],
|
||||||
|
:href => "/cloudapi/ecloud/layoutrows/#{row_id}",
|
||||||
|
:type => "application/vnd.tmrk.cloud.layoutRow",
|
||||||
|
:Links => {
|
||||||
|
:Link => [
|
||||||
|
Fog::Ecloud.keep(environment, :name, :href, :type)
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:Index => 0,
|
||||||
|
:Groups => {
|
||||||
|
:Group => [
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:environment_id => environment[:id],
|
||||||
|
}
|
||||||
|
|
||||||
|
group = {
|
||||||
|
:id => group_id,
|
||||||
|
:name => options[:group],
|
||||||
|
:href => "/cloudapi/ecloud/layoutgroups/#{group_id}",
|
||||||
|
:type => "application/vnd.tmrk.cloud.layoutGroup",
|
||||||
|
:Links => {
|
||||||
|
:Link => [
|
||||||
|
Fog::Ecloud.keep(row, :name, :href, :type),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:Index => 0,
|
||||||
|
:VirtualMachines => {
|
||||||
|
:VirtualMachine => [
|
||||||
|
server,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:row_id => row_id,
|
||||||
|
}
|
||||||
|
row[:Groups][:Group].push(group)
|
||||||
|
layout[:Rows][:Row].push(row)
|
||||||
|
|
||||||
|
server.merge!(:OperatingSystem => options[:operating_system].merge(:type => "application/vnd.tmrk.cloud.operatingSystem")) if options[:operating_system]
|
||||||
|
|
||||||
|
server_response = response(:body => server)
|
||||||
|
|
||||||
|
server.merge!(:compute_pool_id => compute_pool_id)
|
||||||
|
|
||||||
|
self.data[:servers][server_id] = server
|
||||||
|
self.data[:rows][row_id] = row
|
||||||
|
self.data[:groups][group_id] = group
|
||||||
|
|
||||||
|
server_response
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,13 +19,26 @@ def compute_providers
|
||||||
},
|
},
|
||||||
:mocked => false
|
:mocked => false
|
||||||
},
|
},
|
||||||
:openstack => {
|
:ecloud => {
|
||||||
:mocked => true,
|
|
||||||
:server_attributes => {
|
:server_attributes => {
|
||||||
:flavor_ref => 2,
|
:name => "eugene",
|
||||||
:image_ref => "0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
|
:row => "eugene1",
|
||||||
:name => "fog_#{Time.now.to_i}"
|
:group => "eugene-104",
|
||||||
}
|
:catalog_network_name => "bridged",
|
||||||
|
:description => "blarg",
|
||||||
|
:operating_system => {
|
||||||
|
:name => "Red Hat Enterprise Linux 5 (64-bit)",
|
||||||
|
:href => "/cloudapi/ecloud/operatingsystems/rhel5_64guest/computepools/963",
|
||||||
|
},
|
||||||
|
}.tap do |hash|
|
||||||
|
[:template_href, :network_uri, :environment_name].each do |k|
|
||||||
|
key = "ecloud_#{k}".to_sym
|
||||||
|
if Fog.credentials[key]
|
||||||
|
hash[k]= Fog.credentials[key]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
:mocked => true,
|
||||||
},
|
},
|
||||||
:cloudstack => {
|
:cloudstack => {
|
||||||
:provider_attributes => {
|
:provider_attributes => {
|
||||||
|
@ -81,6 +94,14 @@ def compute_providers
|
||||||
:ninefold => {
|
:ninefold => {
|
||||||
:mocked => false
|
:mocked => false
|
||||||
},
|
},
|
||||||
|
:openstack => {
|
||||||
|
:mocked => true,
|
||||||
|
:server_attributes => {
|
||||||
|
:flavor_ref => 2,
|
||||||
|
:image_ref => "0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
|
||||||
|
:name => "fog_#{Time.now.to_i}"
|
||||||
|
}
|
||||||
|
},
|
||||||
:rackspace => {
|
:rackspace => {
|
||||||
:provider_attributes => { :version => :v1 },
|
:provider_attributes => { :version => :v1 },
|
||||||
:server_attributes => {
|
:server_attributes => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
for provider, config in compute_providers
|
for provider, config in compute_providers
|
||||||
|
|
||||||
next if [:glesys, :voxel, :ibm].include?(provider)
|
next if [:glesys, :voxel, :ibm, :ecloud].include?(provider)
|
||||||
|
|
||||||
Shindo.tests("Fog::Compute[:#{provider}] | flavors", [provider.to_s]) do
|
Shindo.tests("Fog::Compute[:#{provider}] | flavors", [provider.to_s]) do
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
for provider, config in compute_providers
|
for provider, config in compute_providers
|
||||||
|
|
||||||
|
next if [:ecloud].include?(provider)
|
||||||
|
|
||||||
Shindo.tests("Fog::Compute[:#{provider}] | server", [provider.to_s]) do
|
Shindo.tests("Fog::Compute[:#{provider}] | server", [provider.to_s]) do
|
||||||
|
|
||||||
provider_attributes = config[:provider_attributes] || {}
|
provider_attributes = config[:provider_attributes] || {}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
for provider, config in compute_providers
|
for provider, config in compute_providers
|
||||||
|
|
||||||
|
next if [:ecloud].include?(provider)
|
||||||
|
|
||||||
Shindo.tests("Fog::Compute[:#{provider}] | servers", [provider.to_s]) do
|
Shindo.tests("Fog::Compute[:#{provider}] | servers", [provider.to_s]) do
|
||||||
|
|
||||||
provider_attributes = config[:provider_attributes] || {}
|
provider_attributes = config[:provider_attributes] || {}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
provider, config = :ecloud, compute_providers[:ecloud]
|
||||||
|
|
||||||
|
Shindo.tests("Fog::Compute[:#{provider}] | admin_organizations", [provider.to_s]) do
|
||||||
|
connection = Fog::Compute[provider]
|
||||||
|
@organization = connection.organizations.first
|
||||||
|
@admin_organization = @organization.admin
|
||||||
|
|
||||||
|
tests('#get').succeeds do
|
||||||
|
fetched_admin_organization = connection.get_admin_organization(@admin_organization.href)
|
||||||
|
returns(true) { !fetched_admin_organization.nil? }
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#ssh_keys').succeeds do
|
||||||
|
returns(true, "a list of SshKeys") { @admin_organization.ssh_keys.is_a?(Fog::Compute::Ecloud::SshKeys) }
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,17 @@
|
||||||
|
provider, config = :ecloud, compute_providers[:ecloud]
|
||||||
|
|
||||||
|
Shindo.tests("Fog::Compute[:#{provider}] | compute_pools", [provider.to_s]) do
|
||||||
|
connection = Fog::Compute[provider]
|
||||||
|
@organization = connection.organizations.first
|
||||||
|
@environment = @organization.environments.first
|
||||||
|
|
||||||
|
tests('#all').succeeds do
|
||||||
|
returns(false) { @environment.compute_pools.all.empty? }
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#get').succeeds do
|
||||||
|
compute_pool = @environment.compute_pools.all.first
|
||||||
|
fetched_compute_pool = connection.compute_pools.get(compute_pool.href)
|
||||||
|
returns(true) { !fetched_compute_pool.nil? }
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,26 @@
|
||||||
|
provider, config = :ecloud, compute_providers[:ecloud]
|
||||||
|
|
||||||
|
Shindo.tests("Fog::Compute[:#{provider}] | detached_disks", [provider.to_s]) do
|
||||||
|
connection = Fog::Compute[provider]
|
||||||
|
@organization = connection.organizations.first
|
||||||
|
@environment = @organization.environments.first
|
||||||
|
@compute_pool = @environment.compute_pools.first
|
||||||
|
@detached_disks = @compute_pool.detached_disks
|
||||||
|
|
||||||
|
tests('#all').succeeds do
|
||||||
|
if @detached_disks.is_a?(Fog::Compute::Ecloud::DetachedDisks) && @detached_disks.reload.empty?
|
||||||
|
returns(true, "compute pool has no detached disks") { @detached_disks.all.empty? }
|
||||||
|
else
|
||||||
|
returns(false, "has detached disks") { @detached_disks.all.empty? }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
unless @detached_disks.empty?
|
||||||
|
tests('#get') do
|
||||||
|
disk = @detached_disks.first
|
||||||
|
fetched_disk = connection.detached_disks.get(disk.href)
|
||||||
|
returns(false, "disk is not nil") { fetched_disk.nil? }
|
||||||
|
returns(true, "is a DetachedDisk") { fetched_disk.is_a?(Fog::Compute::Ecloud::DetachedDisk) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,23 @@
|
||||||
|
provider, config = :ecloud, compute_providers[:ecloud]
|
||||||
|
|
||||||
|
Shindo.tests("Fog::Compute[:#{provider}] | environments", [provider.to_s]) do
|
||||||
|
connection = Fog::Compute[provider]
|
||||||
|
@organization = connection.organizations.first
|
||||||
|
|
||||||
|
tests('#all').succeeds do
|
||||||
|
returns(false) { @organization.environments.all.empty? }
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#get').succeeds do
|
||||||
|
environment = @organization.environments.all.first
|
||||||
|
fetched_environment = connection.environments.get(environment.href)
|
||||||
|
|
||||||
|
returns(true) { !fetched_environment.nil? }
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#organization").succeeds do
|
||||||
|
environment = @organization.environments.all.first
|
||||||
|
returns(false, "returns an organization") { environment.organization.nil? }
|
||||||
|
returns(true, "returns correct organization") { environment.organization.href == @organization.href }
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,28 @@
|
||||||
|
provider, config = :ecloud, compute_providers[:ecloud]
|
||||||
|
connection = Fog::Compute[provider]
|
||||||
|
organization = connection.organizations.first
|
||||||
|
environment = organization.environments.detect { |e| e.name == config[:ecloud_environment_name] } || organization.environments.first
|
||||||
|
public_ips = environment.public_ips
|
||||||
|
public_ip = public_ips.detect { |i| i.name == config[:ecloud_public_ip_name] } || public_ips.first
|
||||||
|
|
||||||
|
Shindo.tests("Fog::Compute[:#{provider}] | internet_services", "queries") do
|
||||||
|
@internet_services = public_ip.internet_services
|
||||||
|
|
||||||
|
tests('#all').succeeds do
|
||||||
|
returns(true, "is a collection") { @internet_services.is_a?(Fog::Compute::Ecloud::InternetServices) }
|
||||||
|
if Fog.mocking?
|
||||||
|
returns(false, "has services") { @internet_services.empty? }
|
||||||
|
else
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
unless @internet_services.empty?
|
||||||
|
tests('#get').succeeds do
|
||||||
|
service = @internet_services.first
|
||||||
|
fetched_service = connection.internet_services.get(service.href)
|
||||||
|
returns(false, "service is not nil") { fetched_service.nil? }
|
||||||
|
returns(true, "is an InternetService") { fetched_service.is_a?(Fog::Compute::Ecloud::InternetService) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,19 @@
|
||||||
|
provider, config = :ecloud, compute_providers[:ecloud]
|
||||||
|
|
||||||
|
Shindo.tests("Fog::Compute[:#{provider}] | ip_addresses", [provider.to_s]) do
|
||||||
|
connection = Fog::Compute[provider]
|
||||||
|
@organization = connection.organizations.first
|
||||||
|
@environment = @organization.environments.first
|
||||||
|
@network = @environment.networks.first
|
||||||
|
@ip_addresses = @network.ips
|
||||||
|
|
||||||
|
tests('#all').succeeds do
|
||||||
|
returns(false) { @ip_addresses.all.empty? }
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#get').succeeds do
|
||||||
|
address = @ip_addresses.first
|
||||||
|
fetched_network = connection.ip_addresses.get(address.href)
|
||||||
|
returns(false) { fetched_network.nil? }
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,17 @@
|
||||||
|
provider, config = :ecloud, compute_providers[:ecloud]
|
||||||
|
|
||||||
|
Shindo.tests("Fog::Compute[:#{provider}] | networks", [provider.to_s]) do
|
||||||
|
connection = Fog::Compute[provider]
|
||||||
|
@organization = connection.organizations.first
|
||||||
|
@environment = @organization.environments.first
|
||||||
|
|
||||||
|
tests('#all').succeeds do
|
||||||
|
returns(false) { @environment.networks.all.empty? }
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#get').succeeds do
|
||||||
|
network = @environment.networks.all.first
|
||||||
|
fetched_network = connection.networks.get(network.href)
|
||||||
|
returns(true) { !fetched_network.nil? }
|
||||||
|
end
|
||||||
|
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue