mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Moved Ecloud to a modular gem
This commit is contained in:
parent
319fed9589
commit
7d047e769c
262 changed files with 2 additions and 9091 deletions
|
|
@ -62,6 +62,7 @@ Gem::Specification.new do |s|
|
|||
s.add_dependency("fog-voxel")
|
||||
s.add_dependency("fog-vmfusion")
|
||||
s.add_dependency("fog-terremark")
|
||||
s.add_dependency("fog-ecloud")
|
||||
|
||||
# Extra Dependencies
|
||||
s.add_dependency("opennebula")
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
class Ecloud < Fog::Bin
|
||||
class << self
|
||||
def available?
|
||||
Fog::Ecloud::ECLOUD_OPTIONS.all? {|requirement| Fog.credentials.include?(requirement)}
|
||||
end
|
||||
|
||||
def class_for(key)
|
||||
case key
|
||||
when :compute
|
||||
Fog::Compute::Ecloud
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{key}"
|
||||
end
|
||||
end
|
||||
|
||||
def [](service)
|
||||
@@connections ||= Hash.new do |hash, key|
|
||||
hash[key] = case key
|
||||
when :compute
|
||||
Fog::Logger.warning("Ecloud[:compute] is not recommended, use Compute[:ecloud] for portability")
|
||||
Fog::Compute.new(:provider => 'Ecloud')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
Fog::Ecloud.services
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1 +0,0 @@
|
|||
require 'fog/ecloud/compute'
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
module Fog
|
||||
module Ecloud
|
||||
class Collection < Fog::Collection
|
||||
def load(objects)
|
||||
objects = [ objects ] if objects.is_a?(Hash)
|
||||
super
|
||||
end
|
||||
|
||||
def check_href!(opts = {})
|
||||
unless href
|
||||
opts = { :parent => opts } if opts.is_a?(String)
|
||||
msg = ":href missing, call with a :href pointing to #{if opts[:message]
|
||||
opts[:message]
|
||||
elsif opts[:parent]
|
||||
"the #{opts[:parent]} whos #{self.class.to_s.split('::').last.downcase} you want to enumerate"
|
||||
else
|
||||
"the resource"
|
||||
end}"
|
||||
raise Fog::Errors::Error.new(msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,824 +0,0 @@
|
|||
require 'fog/ecloud/core'
|
||||
require 'fog/ecloud/collection'
|
||||
require 'fog/ecloud/model'
|
||||
require 'builder'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud < Fog::Service
|
||||
API_URL = "https://services.enterprisecloud.terremark.com"
|
||||
|
||||
attr_reader :authentication_method, :version
|
||||
|
||||
#### Credentials
|
||||
#requires
|
||||
recognizes :ecloud_username, :ecloud_password, :ecloud_version,
|
||||
:ecloud_access_key, :ecloud_private_key,
|
||||
:ecloud_authentication_method, :base_path
|
||||
|
||||
#### Models
|
||||
model_path 'fog/ecloud/models/compute'
|
||||
model :organization
|
||||
collection :organizations
|
||||
model :location
|
||||
collection :locations
|
||||
model :catalog_item
|
||||
collection :catalog
|
||||
model :catalog_configuration
|
||||
collection :catalog_configurations
|
||||
model :environment
|
||||
collection :environments
|
||||
model :task
|
||||
collection :tasks
|
||||
model :compute_pool
|
||||
collection :compute_pools
|
||||
model :server
|
||||
collection :servers
|
||||
model :virtual_machine_assigned_ip
|
||||
collection :virtual_machine_assigned_ips
|
||||
model :hardware_configuration
|
||||
collection :hardware_configurations
|
||||
model :server_configuration_option
|
||||
collection :server_configuration_options
|
||||
model :guest_process
|
||||
collection :guest_processes
|
||||
model :layout
|
||||
collection :layouts
|
||||
model :row
|
||||
collection :rows
|
||||
model :group
|
||||
collection :groups
|
||||
model :internet_service
|
||||
collection :internet_services
|
||||
model :node
|
||||
collection :nodes
|
||||
model :monitor
|
||||
collection :monitors
|
||||
model :cpu_usage_detail
|
||||
collection :cpu_usage_detail_summary
|
||||
model :memory_usage_detail
|
||||
collection :memory_usage_detail_summary
|
||||
model :storage_usage_detail
|
||||
collection :storage_usage_detail_summary
|
||||
model :operating_system_family
|
||||
collection :operating_system_families
|
||||
model :operating_system
|
||||
collection :operating_systems
|
||||
model :template
|
||||
collection :templates
|
||||
model :firewall_acl
|
||||
collection :firewall_acls
|
||||
model :network
|
||||
collection :networks
|
||||
model :ip_address
|
||||
collection :ip_addresses
|
||||
model :physical_device
|
||||
collection :physical_devices
|
||||
model :public_ip
|
||||
collection :public_ips
|
||||
model :trusted_network_group
|
||||
collection :trusted_network_groups
|
||||
model :backup_internet_service
|
||||
collection :backup_internet_services
|
||||
model :rnat
|
||||
collection :rnats
|
||||
model :association
|
||||
collection :associations
|
||||
model :tag
|
||||
collection :tags
|
||||
model :admin_organization
|
||||
collection :admin_organizations
|
||||
model :ssh_key
|
||||
collection :ssh_keys
|
||||
model :password_complexity_rule
|
||||
collection :password_complexity_rules
|
||||
model :authentication_level
|
||||
collection :authentication_levels
|
||||
model :login_banner
|
||||
collection :login_banners
|
||||
model :user
|
||||
collection :users
|
||||
model :role
|
||||
collection :roles
|
||||
model :ssh_key
|
||||
collection :ssh_keys
|
||||
model :support_ticket
|
||||
collection :support_tickets
|
||||
model :detached_disk
|
||||
collection :detached_disks
|
||||
|
||||
#### Requests
|
||||
request_path 'fog/ecloud/requests/compute'
|
||||
request :backup_internet_service_create
|
||||
request :backup_internet_service_delete
|
||||
request :backup_internet_service_edit
|
||||
request :compute_pool_edit
|
||||
request :firewall_acls_create
|
||||
request :firewall_acls_delete
|
||||
request :get_admin_organization
|
||||
request :get_api_key
|
||||
request :get_api_keys
|
||||
request :get_association
|
||||
request :get_associations
|
||||
request :get_authentication_level
|
||||
request :get_authentication_levels
|
||||
request :get_backup_internet_service
|
||||
request :get_backup_internet_services
|
||||
request :get_catalog
|
||||
request :get_catalog_configuration
|
||||
request :get_catalog_configurations
|
||||
request :get_catalog_item
|
||||
request :get_compute_pool
|
||||
request :get_compute_pools
|
||||
request :get_cpu_usage_detail
|
||||
request :get_cpu_usage_detail_summary
|
||||
request :get_environment
|
||||
request :get_firewall_acl
|
||||
request :get_firewall_acls
|
||||
request :get_group
|
||||
request :get_groups
|
||||
request :get_guest_process
|
||||
request :get_guest_processes
|
||||
request :get_hardware_configuration
|
||||
request :get_internet_service
|
||||
request :get_internet_services
|
||||
request :get_ip_address
|
||||
request :get_layout
|
||||
request :get_layouts
|
||||
request :get_location
|
||||
request :get_locations
|
||||
request :get_login_banner
|
||||
request :get_login_banners
|
||||
request :get_memory_usage_detail
|
||||
request :get_memory_usage_detail_summary
|
||||
request :get_monitor
|
||||
request :get_monitors
|
||||
request :get_network
|
||||
request :get_network_summary
|
||||
request :get_networks
|
||||
request :get_node
|
||||
request :get_nodes
|
||||
request :get_operating_system
|
||||
request :get_operating_system_families
|
||||
request :get_organization
|
||||
request :get_organizations
|
||||
request :get_password_complexity_rule
|
||||
request :get_password_complexity_rules
|
||||
request :get_physical_device
|
||||
request :get_physical_devices
|
||||
request :get_public_ip
|
||||
request :get_public_ips
|
||||
request :get_rnat
|
||||
request :get_rnats
|
||||
request :get_role
|
||||
request :get_roles
|
||||
request :get_row
|
||||
request :get_rows
|
||||
request :get_server
|
||||
request :get_server_configuration_option
|
||||
request :get_server_configuration_options
|
||||
request :get_servers
|
||||
request :get_ssh_key
|
||||
request :get_ssh_keys
|
||||
request :get_storage_usage_detail
|
||||
request :get_storage_usage_detail_summary
|
||||
request :get_support_ticket
|
||||
request :get_support_tickets
|
||||
request :get_tag
|
||||
request :get_tags
|
||||
request :get_task
|
||||
request :get_tasks
|
||||
request :get_template
|
||||
request :get_templates
|
||||
request :get_trusted_network_group
|
||||
request :get_trusted_network_groups
|
||||
request :get_user
|
||||
request :get_users
|
||||
request :get_virtual_machine_assigned_ips
|
||||
request :get_detached_disks
|
||||
request :get_detached_disk
|
||||
request :groups_create
|
||||
request :groups_delete
|
||||
request :groups_edit
|
||||
request :groups_movedown
|
||||
request :groups_moveup
|
||||
request :internet_service_create
|
||||
request :internet_service_delete
|
||||
request :internet_service_edit
|
||||
request :monitors_create_default
|
||||
request :monitors_create_ecv
|
||||
request :monitors_create_http
|
||||
request :monitors_create_loopback
|
||||
request :monitors_create_ping
|
||||
request :monitors_disable
|
||||
request :monitors_edit_ecv
|
||||
request :monitors_edit_http
|
||||
request :monitors_edit_ping
|
||||
request :monitors_enable
|
||||
request :node_service_create
|
||||
request :node_service_delete
|
||||
request :node_service_edit
|
||||
request :power_off
|
||||
request :power_on
|
||||
request :power_reset
|
||||
request :power_shutdown
|
||||
request :public_ip_activate
|
||||
request :rnat_associations_create_device
|
||||
request :rnat_associations_delete
|
||||
request :rnat_associations_edit_network
|
||||
request :rows_create
|
||||
request :rows_delete
|
||||
request :rows_edit
|
||||
request :rows_movedown
|
||||
request :rows_moveup
|
||||
request :trusted_network_groups_create
|
||||
request :trusted_network_groups_delete
|
||||
request :trusted_network_groups_edit
|
||||
request :virtual_machine_edit_assigned_ips
|
||||
request :virtual_machine_copy
|
||||
request :virtual_machine_copy_identical
|
||||
request :virtual_machine_create_from_template
|
||||
request :virtual_machine_delete
|
||||
request :virtual_machine_edit
|
||||
request :virtual_machine_edit_hardware_configuration
|
||||
request :virtual_machine_import
|
||||
request :virtual_machine_upload_file
|
||||
request :virtual_machine_detach_disk
|
||||
request :virtual_machine_attach_disk
|
||||
|
||||
module Shared
|
||||
attr_accessor :base_path
|
||||
attr_reader :versions_uri
|
||||
|
||||
def validate_data(required_opts = [], options = {})
|
||||
unless required_opts.all? { |opt| options.key?(opt) }
|
||||
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
|
||||
end
|
||||
end
|
||||
|
||||
def id_from_uri(uri)
|
||||
uri.match(/(\d+)$/)[1].to_i
|
||||
end
|
||||
|
||||
def default_organization_uri
|
||||
"#{@base_path}/organizations"
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
include Shared
|
||||
|
||||
class << self
|
||||
def basic_request(name, expects=[200], method=:get, headers={}, body='')
|
||||
define_method(name) do |uri|
|
||||
request({
|
||||
:expects => expects,
|
||||
:method => method,
|
||||
:headers => headers,
|
||||
:body => body,
|
||||
:parse => true,
|
||||
:uri => uri
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(options = {})
|
||||
@base_path = options[:base_path] || '/cloudapi/ecloud'
|
||||
@connections = {}
|
||||
@connection_options = options[:connection_options] || {}
|
||||
@host = options[:ecloud_host] || API_URL
|
||||
@persistent = options[:persistent] || false
|
||||
@version = options[:ecloud_version] || "2013-06-01"
|
||||
@authentication_method = options[:ecloud_authentication_method] || :cloud_api_auth
|
||||
@access_key = options[:ecloud_access_key]
|
||||
@private_key = options[:ecloud_private_key]
|
||||
if @private_key.nil? || @authentication_method == :basic_auth
|
||||
@authentication_method = :basic_auth
|
||||
@username = options[:ecloud_username]
|
||||
@password = options[:ecloud_password]
|
||||
if @username.nil? || @password.nil?
|
||||
raise ArgumentError, "No credentials (cloud auth, or basic auth) passed!"
|
||||
end
|
||||
else
|
||||
@hmac = Fog::HMAC.new("sha256", @private_key)
|
||||
end
|
||||
end
|
||||
|
||||
def request(params)
|
||||
# Convert the uri to a URI if it's a string.
|
||||
if params[:uri].is_a?(String)
|
||||
params[:uri] = URI.parse(@host + params[:uri])
|
||||
end
|
||||
host_url = "#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? ":#{params[:uri].port}" : ''}"
|
||||
|
||||
# Hash connections on the host_url ... There's nothing to say we won't get URI's that go to
|
||||
# different hosts.
|
||||
@connections[host_url] ||= Fog::XML::Connection.new(host_url, @persistent, @connection_options)
|
||||
|
||||
# Set headers to an empty hash if none are set.
|
||||
headers = set_extra_headers_for(params) || set_extra_headers_for({})
|
||||
|
||||
# Make the request
|
||||
options = {
|
||||
:expects => (params[:expects] || 200),
|
||||
:method => params[:method] || 'GET',
|
||||
:path => params[:uri].path + "#{"?#{params[:uri].query}" if params[:uri].query}",
|
||||
:headers => headers
|
||||
}
|
||||
unless params[:body].nil? || params[:body].empty?
|
||||
options.merge!({:body => params[:body]})
|
||||
end
|
||||
response = @connections[host_url].request(options)
|
||||
# Parse the response body into a hash
|
||||
unless response.body.empty?
|
||||
if params[:parse]
|
||||
document = Fog::ToHashDocument.new
|
||||
parser = Nokogiri::XML::SAX::PushParser.new(document)
|
||||
parser << response.body
|
||||
parser.finish
|
||||
|
||||
response.body = document.body
|
||||
end
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# if Authorization and x-tmrk-authorization are used, the x-tmrk-authorization takes precendence.
|
||||
def set_extra_headers_for(params)
|
||||
params[:headers] = {
|
||||
'x-tmrk-version' => @version,
|
||||
'Date' => Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S GMT"),
|
||||
}.merge(params[:headers] || {})
|
||||
if params[:method]=="POST" || params[:method]=="PUT"
|
||||
params[:headers].merge!({"Content-Type" => 'application/xml'}) unless params[:headers]['Content-Type']
|
||||
params[:headers].merge!({"Accept" => 'application/xml'})
|
||||
end
|
||||
unless params[:body].nil? || params[:body].empty?
|
||||
params[:headers].merge!({"x-tmrk-contenthash" => "Sha256 #{Base64.encode64(Digest::SHA2.digest(params[:body].to_s)).chomp}"})
|
||||
end
|
||||
if @authentication_method == :basic_auth
|
||||
params[:headers].merge!({'Authorization' => "Basic #{Base64.encode64(@username+":"+@password).delete("\r\n")}"})
|
||||
elsif @authentication_method == :cloud_api_auth
|
||||
signature = cloud_api_signature(params)
|
||||
params[:headers].merge!({
|
||||
"x-tmrk-authorization" => %{CloudApi AccessKey="#{@access_key}" SignatureType="HmacSha256" Signature="#{signature}"},
|
||||
"Authorization" => %{CloudApi AccessKey="#{@access_key}" SignatureType="HmacSha256" Signature="#{signature}"}
|
||||
})
|
||||
end
|
||||
params[:headers]
|
||||
end
|
||||
|
||||
def cloud_api_signature(params)
|
||||
verb = params[:method].upcase
|
||||
headers = params[:headers]
|
||||
path = params[:uri].path
|
||||
canonicalized_headers = canonicalize_headers(headers)
|
||||
canonicalized_resource = canonicalize_resource(path)
|
||||
string = [
|
||||
verb,
|
||||
headers['Content-Length'].to_s,
|
||||
headers['Content-Type'].to_s,
|
||||
headers['Date'].to_s,
|
||||
canonicalized_headers,
|
||||
canonicalized_resource + "\n"
|
||||
].join("\n")
|
||||
Base64.encode64(@hmac.sign(string)).chomp
|
||||
end
|
||||
|
||||
# section 5.6.3.2 in the ~1000 page pdf spec
|
||||
def canonicalize_headers(headers)
|
||||
tmp = headers.reduce({}) {|ret, h| ret[h.first.downcase] = h.last if h.first.match(/^x-tmrk/i) ; ret }
|
||||
tmp.reject! {|k,v| k == "x-tmrk-authorization" }
|
||||
tmp = tmp.sort.map{|e| "#{e.first}:#{e.last}" }.join("\n")
|
||||
tmp
|
||||
end
|
||||
|
||||
# section 5.6.3.3 in the ~1000 page pdf spec
|
||||
def canonicalize_resource(path)
|
||||
uri, query_string = path.split("?")
|
||||
return uri if query_string.nil?
|
||||
query_string_pairs = query_string.split("&").sort.map{|e| e.split("=") }
|
||||
tm_query_string = query_string_pairs.map{|x| "#{x.first.downcase}:#{x.last}" }.join("\n")
|
||||
"#{uri.downcase}\n#{tm_query_string}\n"
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
include Shared
|
||||
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, key|
|
||||
hash[key] = begin
|
||||
compute_pool_id = Fog.credentials[:ecloud_compute_pool_id] || Fog::Mock.random_numbers(3).to_i
|
||||
environment_id = Fog.credentials[:ecloud_environment_id] || Fog::Mock.random_numbers(3).to_i
|
||||
public_ip_id = Fog.credentials[:ecloud_public_ip_id] || Fog::Mock.random_numbers(6).to_i
|
||||
internet_service_id = Fog::Mock.random_numbers(6).to_i
|
||||
node_service_id = Fog::Mock.random_numbers(6).to_i
|
||||
environment_name = Fog.credentials[:ecloud_environment_name] || Fog::Mock.random_letters(12)
|
||||
location_id = Fog::Mock.random_numbers(4).to_i
|
||||
network_id = Fog.credentials[:ecloud_network_id] || Fog::Mock.random_numbers(6).to_i
|
||||
network_ip = Fog::Ecloud.ip_address
|
||||
public_ip = Fog.credentials[:ecloud_public_ip_name] || Fog::Ecloud.ip_address
|
||||
ip_address_id = Fog::Ecloud.ip_address
|
||||
ip_address2_id = Fog::Ecloud.ip_address
|
||||
operating_system_id = Fog::Mock.random_numbers(7).to_i
|
||||
operating_system_family_id = Fog::Mock.random_numbers(7).to_i
|
||||
organization_id = Fog::Mock.random_numbers(7).to_i
|
||||
organization_name = Fog::Mock.random_letters(7)
|
||||
template_id = Fog.credentials[:ecloud_template_id] || Fog::Mock.random_numbers(7).to_i
|
||||
ssh_key_id = Fog.credentials[:ecloud_ssh_key_id] || Fog::Mock.random_numbers(4).to_i
|
||||
ssh_key_name = Fog.credentials[:ecloud_ssh_key_name] || "root"
|
||||
|
||||
environment = {
|
||||
:id => environment_id,
|
||||
:href => "/cloudapi/ecloud/environments/#{environment_id}",
|
||||
:name => environment_name,
|
||||
:type => "application/vnd.tmrk.cloud.environment"
|
||||
}
|
||||
|
||||
organization = {
|
||||
:href => "/cloudapi/ecloud/organizations/#{organization_id}",
|
||||
:type => "application/vnd.tmrk.cloud.organization",
|
||||
:name => organization_name,
|
||||
:Links => {
|
||||
:Link => [
|
||||
Fog::Ecloud.keep(environment, :href, :name, :type),
|
||||
{
|
||||
:href => "/cloudapi/ecloud/admin/organizations/#{organization_id}",
|
||||
:name => organization_name,
|
||||
:type => "application/vnd.tmrk.cloud.admin.organization",
|
||||
:rel => "alternate",
|
||||
},
|
||||
{
|
||||
:href => "/cloudapi/ecloud/devicetags/organizations/#{organization_id}",
|
||||
:type => "application/vnd.tmrk.cloud.deviceTag; type=collection",
|
||||
:rel => "down",
|
||||
},
|
||||
{
|
||||
:href => "/cloudapi/ecloud/alerts/organizations/#{organization_id}",
|
||||
:type => "application/vnd.tmrk.cloud.alertLog",
|
||||
:rel => "down",
|
||||
},
|
||||
],
|
||||
},
|
||||
:Locations => {
|
||||
:Location => [
|
||||
{
|
||||
:href => "/cloudapi/ecloud/locations/#{location_id}",
|
||||
:name => organization_name,
|
||||
:Catalog => {
|
||||
:href => "/cloudapi/ecloud/admin/catalog/organizations/#{organization_id}/locations/#{location_id}",
|
||||
:type => "application/vnd.tmrk.cloud.admin.catalogEntry; type=collection"
|
||||
},
|
||||
:Environments => { :Environment => [environment] }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
environment.merge!(
|
||||
:Links => {
|
||||
:Link => [ Fog::Ecloud.keep(organization, :href, :name, :type), ]
|
||||
}
|
||||
)
|
||||
|
||||
admin_organization = {
|
||||
:id => organization_id,
|
||||
:href => "/cloudapi/ecloud/admin/organizations/#{organization_id}",
|
||||
:type => "application/vnd.tmrk.cloud.admin.organization",
|
||||
:name => organization_name,
|
||||
:Links => {
|
||||
:Link => [
|
||||
Fog::Ecloud.keep(organization, :href, :type, :name)
|
||||
],
|
||||
},
|
||||
:organization_id => organization_id,
|
||||
}
|
||||
|
||||
compute_pool = {
|
||||
:id => compute_pool_id,
|
||||
:href => "/cloudapi/ecloud/computepools/#{compute_pool_id}",
|
||||
:name => Fog::Mock.random_letters(12),
|
||||
:type => "application/vnd.tmrk.cloud.computePool",
|
||||
:environment_id => environment_id,
|
||||
:Links => {
|
||||
:Link => [
|
||||
Fog::Ecloud.keep(organization, :href, :name, :type),
|
||||
Fog::Ecloud.keep(environment, :href, :name, :type),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
public_ip = {
|
||||
:id => public_ip_id,
|
||||
:href => "/cloudapi/ecloud/publicips/#{public_ip_id}",
|
||||
:name => public_ip,
|
||||
:type => "application/vnd.tmrk.cloud.publicIp",
|
||||
:IpType => "none",
|
||||
:environment_id => environment_id,
|
||||
:Links => {
|
||||
:Link => [
|
||||
Fog::Ecloud.keep(environment, :href, :name, :type),
|
||||
],
|
||||
},
|
||||
:InternetServices => {
|
||||
:InternetService => [
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
internet_service = {
|
||||
:id => internet_service_id,
|
||||
:href => "/cloudapi/ecloud/internetservices/#{internet_service_id}",
|
||||
:name => Fog::Mock.random_letters(6),
|
||||
:type => "application/vnd.tmrk.cloud.internetService",
|
||||
:public_ip_id => public_ip_id,
|
||||
:Links => {
|
||||
:Link => [
|
||||
Fog::Ecloud.keep(public_ip, :href, :name, :type),
|
||||
],
|
||||
},
|
||||
:NodeServices => {
|
||||
:NodeService => [
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
node_service = {
|
||||
:id => node_service_id,
|
||||
:href => "/cloudapi/ecloud/nodeservices/#{node_service_id}",
|
||||
:name => Fog::Mock.random_letters(6),
|
||||
:type => "application/vnd.tmrk.cloud.nodeService",
|
||||
:internet_service_id => internet_service_id,
|
||||
:Links => {
|
||||
:Link => [
|
||||
Fog::Ecloud.keep(internet_service, :href, :name, :type)
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
internet_service[:NodeServices][:NodeService].push(node_service)
|
||||
public_ip[:InternetServices][:InternetService].push(internet_service)
|
||||
|
||||
network = {
|
||||
:id => network_id,
|
||||
:href => "/cloudapi/ecloud/networks/#{network_id}",
|
||||
:name => "#{network_ip}/#{Fog::Mock.random_numbers(2)}",
|
||||
:type => "application/vnd.tmrk.cloud.network",
|
||||
:Address => network_ip,
|
||||
:NetworkType => "Dmz",
|
||||
:BroadcastAddress => network_ip,
|
||||
:GatewayAddress => network_ip,
|
||||
:environment_id => environment_id,
|
||||
:Links => {
|
||||
:Link => [
|
||||
Fog::Ecloud.keep(environment, :href, :name, :type),
|
||||
]
|
||||
},
|
||||
:IpAddresses => {
|
||||
:IpAddress => [],
|
||||
},
|
||||
}
|
||||
|
||||
ip_address = {
|
||||
:id => ip_address_id,
|
||||
:href => "/cloudapi/ecloud/ipaddresses/networks/#{network_id}/#{ip_address_id}",
|
||||
:name => ip_address_id,
|
||||
:type => "application/vnd.tmrk.cloud.ipAddress",
|
||||
:network_id => network_id,
|
||||
:Links => {
|
||||
:Link => [ Fog::Ecloud.keep(network, :href, :name, :type), ],
|
||||
},
|
||||
:Reserved => "false",
|
||||
:Host => nil,
|
||||
:DetectedOn => nil,
|
||||
}
|
||||
|
||||
ip_address2 = ip_address.dup.merge(:id => ip_address2_id, :href => "/cloudapi/ecloud/ipaddresses/networks/#{network_id}/#{ip_address2_id}", :name => ip_address2_id)
|
||||
|
||||
network[:IpAddresses][:IpAddress].push(ip_address).push(ip_address2)
|
||||
|
||||
short_name = "solaris10_64guest"
|
||||
operating_system = {
|
||||
:short_name => short_name,
|
||||
:compute_pool_id => compute_pool_id,
|
||||
:href => "/cloudapi/ecloud/operatingsystems/#{short_name}/computepools/#{compute_pool_id}",
|
||||
:name => "Sun Solaris 10 (64-bit)",
|
||||
:type => "application/vnd.tmrk.cloud.operatingSystem",
|
||||
:FamilyName => "Solaris",
|
||||
:Links => {
|
||||
:Link => Fog::Ecloud.keep(compute_pool, :href, :name, :type),
|
||||
},
|
||||
:ConfigurationOptions => {
|
||||
:Processor => {
|
||||
:Minimum => "1",
|
||||
:Maximum => "8",
|
||||
:StepFactor => "1"
|
||||
},
|
||||
:Memory => {
|
||||
:MinimumSize => {
|
||||
:Unit => "MB",
|
||||
:Value => "800"
|
||||
},
|
||||
:MaximumSize => {
|
||||
:Unit => "MB",
|
||||
:Value => "16384"
|
||||
},
|
||||
:StepFactor => {
|
||||
:Unit => "MB",
|
||||
:Value => "4"
|
||||
}
|
||||
},
|
||||
:Disk => {
|
||||
:Minimum => "1",
|
||||
:Maximum => "15",
|
||||
:SystemDisk => {
|
||||
:ResourceCapacityRange => {
|
||||
:MinimumSize => {
|
||||
:Unit => "GB",
|
||||
:Value => "1"
|
||||
},
|
||||
:MaximumSize => {
|
||||
:Unit => "GB",
|
||||
:Value => "512"
|
||||
},
|
||||
:StepFactor => {
|
||||
:Unit => "GB",
|
||||
:Value => "1"}
|
||||
},
|
||||
:MonthlyCost => "0"
|
||||
},
|
||||
:DataDisk => {
|
||||
:ResourceCapacityRange => {
|
||||
:MinimumSize => {
|
||||
:Unit => "GB",
|
||||
:Value => "1"
|
||||
},
|
||||
:MaximumSize => {
|
||||
:Unit => "GB",
|
||||
:Value => "512"
|
||||
},
|
||||
:StepFactor => {
|
||||
:Unit => "GB",
|
||||
:Value => "1"
|
||||
}
|
||||
},
|
||||
:MonthlyCost => "0"
|
||||
}
|
||||
},
|
||||
:NetworkAdapter=> {
|
||||
:Minimum => "1",
|
||||
:Maximum => "4",
|
||||
:StepFactor => "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template = {
|
||||
:id => template_id,
|
||||
:href => "/cloudapi/ecloud/templates/#{template_id}/computepools/#{compute_pool_id}",
|
||||
:type => "application/vnd.tmrk.cloud.template",
|
||||
:name => "Sun Solaris 10 (x64)",
|
||||
:compute_pool_id => compute_pool_id,
|
||||
:OperatingSystem => Fog::Ecloud.keep(operating_system, :href, :name, :type),
|
||||
:Memory => {
|
||||
:MinimumSize => {
|
||||
:Unit => "MB",
|
||||
:Value => "800"
|
||||
},
|
||||
:MaximumSize => {
|
||||
:Unit => "MB",
|
||||
:Value => "16384"
|
||||
},
|
||||
:StepFactor => {
|
||||
:Unit => "MB",
|
||||
:Value => "4"
|
||||
}
|
||||
},
|
||||
:Storage => {
|
||||
:Size => {
|
||||
:Unit => "GB",
|
||||
:Value => "7"
|
||||
}
|
||||
},
|
||||
:NetworkAdapters => "1",
|
||||
:Links => {
|
||||
:Link => [
|
||||
Fog::Ecloud.keep(compute_pool, :href, :name, :type),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
operating_system_family = {
|
||||
:id => operating_system_family_id,
|
||||
:compute_pool_id => compute_pool_id,
|
||||
:OperatingSystemFamily => {
|
||||
:Name => "Linux",
|
||||
:OperatingSystems => {
|
||||
:OperatingSystem => [Fog::Ecloud.keep(operating_system, :href, :name, :type)],
|
||||
}
|
||||
},
|
||||
:Links => {
|
||||
:Link => [
|
||||
Fog::Ecloud.keep(compute_pool, :href, :name, :type),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
ssh_key = {
|
||||
:id => ssh_key_id,
|
||||
:href => "/cloudapi/ecloud/admin/sshKeys/#{ssh_key_id}",
|
||||
:name => ssh_key_name,
|
||||
:admin_organization_id => organization_id,
|
||||
:Links => {
|
||||
:Link => [
|
||||
Fog::Ecloud.keep(admin_organization, :href, :name, :type),
|
||||
Fog::Ecloud.keep(organization, :href, :name, :type),
|
||||
]
|
||||
},
|
||||
:Default => "true",
|
||||
:FingerPrint => Fog::Ecloud.mac_address
|
||||
}
|
||||
|
||||
layout = {
|
||||
:id => environment_id,
|
||||
:href => "/cloudapi/ecloud/layout/environments/#{environment_id}",
|
||||
:type => "application/vnd.tmrk.cloud.deviceLayout",
|
||||
:Links => {
|
||||
:Link => [
|
||||
Fog::Ecloud.keep(environment, :name, :href, :type),
|
||||
],
|
||||
},
|
||||
:Rows => {
|
||||
:Row => [
|
||||
],
|
||||
},
|
||||
:environment_id => environment_id
|
||||
}
|
||||
|
||||
{
|
||||
:compute_pools => {compute_pool_id => compute_pool},
|
||||
:environments => {environment_id => environment},
|
||||
:public_ips => {public_ip_id => public_ip},
|
||||
:internet_services => {internet_service_id => internet_service},
|
||||
:node_services => {node_service_id => node_service},
|
||||
:networks => {network_id => network},
|
||||
:organizations => {organization_id => organization},
|
||||
:admin_organizations => {organization_id => admin_organization},
|
||||
:operating_systems => {operating_system_id => operating_system},
|
||||
:operating_system_families => {operating_system_family_id => operating_system_family},
|
||||
:servers => {},
|
||||
:tasks => {},
|
||||
:templates => {template_id => template},
|
||||
:ssh_keys => {ssh_key_id => ssh_key},
|
||||
:detached_disks => {},
|
||||
:template_href => (Fog.credentials[:ecloud_template_href] || "/cloudapi/ecloud/templates/#{template_id}/computepools/#{compute_pool_id}"),
|
||||
:rows => {},
|
||||
:groups => {},
|
||||
:layouts => {environment_id => layout},
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.reset
|
||||
@data = nil
|
||||
end
|
||||
|
||||
def initialize(options={})
|
||||
@base_path = '/cloudapi/ecloud'
|
||||
@ecloud_api_key = options[:ecloud]
|
||||
end
|
||||
|
||||
def data
|
||||
self.class.data[@ecloud_api_key]
|
||||
end
|
||||
|
||||
def reset_data
|
||||
self.class.data.delete(@ecloud_api_key)
|
||||
end
|
||||
|
||||
def response(params={})
|
||||
body = params[:body]
|
||||
headers = {
|
||||
"Content-Type" => "application/xml"
|
||||
}.merge(params[:headers] || {})
|
||||
status = params[:status] || 200
|
||||
|
||||
response = Excon::Response.new(:body => body, :headers => headers, :status => status)
|
||||
if params.key?(:expects) && ![*params[:expects]].include?(response.status)
|
||||
raise(Excon::Errors.status_error(params, response))
|
||||
else response
|
||||
end
|
||||
end
|
||||
|
||||
def deep_copy(o)
|
||||
Marshal.load(Marshal.dump(o))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
require 'fog/core'
|
||||
require 'fog/xml'
|
||||
module Fog
|
||||
module Ecloud
|
||||
ECLOUD_OPTIONS = [:ecloud_authentication_method]
|
||||
|
||||
extend Fog::Provider
|
||||
|
||||
service(:compute, 'Compute')
|
||||
|
||||
def self.keep(hash, *keys)
|
||||
{}.tap do |kept|
|
||||
keys.each{|k| kept[k]= hash[k] if hash.key?(k)}
|
||||
end
|
||||
end
|
||||
|
||||
def self.slice(hash, *keys)
|
||||
hash.dup.tap do |sliced|
|
||||
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
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
require 'optparse'
|
||||
|
||||
class String
|
||||
def camelize
|
||||
self.split('_').map {|w| w.capitalize}.join
|
||||
end
|
||||
end
|
||||
|
||||
options = {}
|
||||
OptionParser.new do |opts|
|
||||
opts.banner = "Usage: #{__FILE__} [options]"
|
||||
opts.on("-m", "--model-name NAME", "Model Name") { |v| options[:model] = v }
|
||||
opts.on("-c", "--collection-name NAME", "Collection Name") { |v| options[:collection] = v }
|
||||
opts.on("-M", "--methods a:href,b:href,c:href", Array, "List of methods to be defined and href to the method") { |v| options[:methods] = v.map { |a| a.split(':') } }
|
||||
opts.on("-a", "--attributes name:alias,other_name:other_alias", Array, "List of attributes to be defined") { |v| options[:attributes] = v.map { |a| a.split(':') } }
|
||||
end.parse!
|
||||
|
||||
if options[:methods]
|
||||
methods = options[:methods].map do |m|
|
||||
m = <<METHOD
|
||||
def #{m[0]}
|
||||
@#{m[0]} = Fog::Compute::Ecloud::#{m[0].camelize}.new(:service => service, :href => "#{m[1]}")
|
||||
end
|
||||
METHOD
|
||||
end.join("\n ")
|
||||
end
|
||||
|
||||
if options[:attributes]
|
||||
attributes = options[:attributes].map do |a|
|
||||
a = "attribute :#{a[0]}, :aliases => :#{a[1] || a[0].camelize}"
|
||||
end.join("\n ")
|
||||
end
|
||||
|
||||
collection_file = "#{File.expand_path(File.dirname(__FILE__))}/models/compute/#{options[:collection]}.rb"
|
||||
model_file = "#{File.expand_path(File.dirname(__FILE__))}/models/compute/#{options[:model]}.rb"
|
||||
collection_request_file = "#{File.expand_path(File.dirname(__FILE__))}/requests/compute/get_#{options[:collection]}.rb"
|
||||
model_request_file = "#{File.expand_path(File.dirname(__FILE__))}/requests/compute/get_#{options[:model]}.rb"
|
||||
|
||||
collection = <<COLLECTION
|
||||
require 'fog/ecloud/models/compute/#{options[:model]}'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class #{options[:collection].camelize} < Fog::Ecloud::Collection
|
||||
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::#{options[:model].camelize}
|
||||
|
||||
def all
|
||||
data = service.get_#{options[:collection]}(href).body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_#{options[:model]}(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
COLLECTION
|
||||
|
||||
model = <<MODEL
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class #{options[:model].camelize} < Fog::Model
|
||||
identity :href
|
||||
|
||||
#{attributes}
|
||||
|
||||
#{methods}
|
||||
def id
|
||||
href.scan(/\\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
MODEL
|
||||
|
||||
collection_request = <<COLLECTION
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
|
||||
class Real
|
||||
basic_request :get_#{options[:collection]}
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_#{options[:collection]}(uri)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
COLLECTION
|
||||
|
||||
model_request = <<MODEL
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
|
||||
class Real
|
||||
basic_request :get_#{options[:model]}
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_#{options[:model]}(uri)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
MODEL
|
||||
|
||||
File.open(collection_file, 'w') { |f| f.write(collection) }
|
||||
File.open(model_file, 'w') { |f| f.write(model) }
|
||||
File.open(collection_request_file, 'w') { |f| f.write(collection_request) }
|
||||
File.open(model_request_file, 'w') { |f| f.write(model_request) }
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
class IPAddr
|
||||
def mask
|
||||
_to_string(@mask_addr)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,766 +0,0 @@
|
|||
module Fog
|
||||
module Ecloud
|
||||
module MockDataClasses
|
||||
class Base < Hash
|
||||
def self.base_url=(url)
|
||||
@base_url = url
|
||||
end
|
||||
|
||||
self.base_url = "http://vcloud.example.com"
|
||||
|
||||
def self.base_url
|
||||
@base_url
|
||||
end
|
||||
|
||||
def first
|
||||
raise "Don't do this"
|
||||
end
|
||||
|
||||
def last
|
||||
raise "Don't do this"
|
||||
end
|
||||
|
||||
def initialize(data = {}, parent = nil)
|
||||
@parent = parent
|
||||
|
||||
replace(data)
|
||||
end
|
||||
|
||||
def _parent
|
||||
@parent
|
||||
end
|
||||
|
||||
def base_url
|
||||
Base.base_url
|
||||
end
|
||||
|
||||
def href
|
||||
[base_url, self.class.name.split("::").last, object_id].join("/")
|
||||
end
|
||||
|
||||
def inspect
|
||||
"<#{self.class.name} #{object_id} data=#{super}>"
|
||||
end
|
||||
end
|
||||
|
||||
class MockData < Base
|
||||
def versions
|
||||
@versions ||= []
|
||||
end
|
||||
|
||||
def organizations
|
||||
@organizations ||= []
|
||||
end
|
||||
|
||||
def organization_collection_from_href(href)
|
||||
find_href_in(href, all_organizations)
|
||||
end
|
||||
|
||||
def all_organizations
|
||||
organizations.map(&:environments).flatten
|
||||
end
|
||||
|
||||
def organization_from_href(href)
|
||||
find_href_in(href, all_organizations)
|
||||
end
|
||||
|
||||
def all_vdcs
|
||||
organizations.map(&:environments).flatten
|
||||
end
|
||||
|
||||
def vdc_from_href(href)
|
||||
find_href_in(href, all_vdcs)
|
||||
end
|
||||
|
||||
def all_catalogs
|
||||
all_vdcs.map(&:catalog).flatten
|
||||
end
|
||||
|
||||
def catalog_from_href(href)
|
||||
find_href_in(href, all_catalogs)
|
||||
end
|
||||
|
||||
def all_catalog_items
|
||||
all_catalogs.map(&:items).flatten
|
||||
end
|
||||
|
||||
def catalog_item_from_href(href)
|
||||
find_href_in(href, all_catalog_items)
|
||||
end
|
||||
|
||||
def all_virtual_machines
|
||||
all_vdcs.map(&:virtual_machines).flatten
|
||||
end
|
||||
|
||||
def virtual_machine_from_href(href)
|
||||
find_href_prefixed_in(href, all_virtual_machines)
|
||||
end
|
||||
|
||||
def all_networks
|
||||
all_vdcs.map(&:networks).flatten
|
||||
end
|
||||
|
||||
def network_from_href(href)
|
||||
find_href_in(href, all_networks)
|
||||
end
|
||||
|
||||
def all_network_extensions
|
||||
all_networks.map(&:extensions).flatten
|
||||
end
|
||||
|
||||
def network_extension_from_href(href)
|
||||
find_href_in(href, all_network_extensions)
|
||||
end
|
||||
|
||||
def all_vdc_internet_service_collections
|
||||
all_vdcs.map(&:internet_service_collection).flatten
|
||||
end
|
||||
|
||||
def vdc_internet_service_collection_from_href(href)
|
||||
find_href_in(href, all_vdc_internet_service_collections)
|
||||
end
|
||||
|
||||
def all_backup_internet_services
|
||||
all_vdc_internet_service_collections.map(&:backup_internet_services).flatten
|
||||
end
|
||||
|
||||
def backup_internet_service_from_href(href)
|
||||
find_href_in(href, all_backup_internet_services)
|
||||
end
|
||||
|
||||
def all_public_ip_collections
|
||||
all_vdcs.map {|v| v.public_ip_collection }.flatten
|
||||
end
|
||||
|
||||
def public_ip_collection_from_href(href)
|
||||
find_href_in(href, all_public_ip_collections)
|
||||
end
|
||||
|
||||
def all_public_ips
|
||||
all_public_ip_collections.map(&:items).flatten
|
||||
end
|
||||
|
||||
def public_ip_from_href(href)
|
||||
find_href_in(href, all_public_ips)
|
||||
end
|
||||
|
||||
def all_public_ip_internet_service_collections
|
||||
all_public_ips.map(&:internet_service_collection).flatten
|
||||
end
|
||||
|
||||
def public_ip_internet_service_collection_from_href(href)
|
||||
find_href_in(href, all_public_ip_internet_service_collections)
|
||||
end
|
||||
|
||||
def all_public_ip_internet_services
|
||||
all_public_ip_internet_service_collections.map(&:items).flatten
|
||||
end
|
||||
|
||||
def public_ip_internet_service_from_href(href)
|
||||
find_href_in(href, all_public_ip_internet_services)
|
||||
end
|
||||
|
||||
def all_public_ip_internet_service_node_collections
|
||||
all_public_ip_internet_services.map(&:node_collection).flatten
|
||||
end
|
||||
|
||||
def public_ip_internet_service_node_collection_from_href(href)
|
||||
find_href_in(href, all_public_ip_internet_service_node_collections)
|
||||
end
|
||||
|
||||
def all_public_ip_internet_service_nodes
|
||||
all_public_ip_internet_service_node_collections.map(&:items).flatten
|
||||
end
|
||||
|
||||
def public_ip_internet_service_node_from_href(href)
|
||||
find_href_in(href, all_public_ip_internet_service_nodes)
|
||||
end
|
||||
|
||||
def all_network_ip_collections
|
||||
all_networks.map(&:ip_collection)
|
||||
end
|
||||
|
||||
def network_ip_collection_from_href(href)
|
||||
find_href_in(href, all_network_ip_collections)
|
||||
end
|
||||
|
||||
def all_network_ips
|
||||
all_network_ip_collections.map {|c| c.items.values }.flatten
|
||||
end
|
||||
|
||||
def network_ip_from_href(href)
|
||||
find_href_in(href, all_network_ips)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_href_in(href, objects)
|
||||
objects.find {|o| o.href == href }
|
||||
end
|
||||
|
||||
def find_href_prefixed_in(href, objects)
|
||||
objects.find {|o| href =~ %r{^#{o.href}($|/)} }
|
||||
end
|
||||
end
|
||||
|
||||
class MockVersion < Base
|
||||
def version
|
||||
self[:version]
|
||||
end
|
||||
|
||||
def supported
|
||||
!!self[:supported]
|
||||
end
|
||||
|
||||
def login_url
|
||||
href
|
||||
end
|
||||
end
|
||||
|
||||
class MockOrganization < Base
|
||||
def name
|
||||
self[:name]
|
||||
end
|
||||
|
||||
def environments
|
||||
@vdcs ||= []
|
||||
end
|
||||
end
|
||||
|
||||
class MockVdc < Base
|
||||
def name
|
||||
self[:name]
|
||||
end
|
||||
|
||||
def storage_allocated
|
||||
self[:storage_allocated] || 200
|
||||
end
|
||||
|
||||
def storage_used
|
||||
self[:storage_used] || 105
|
||||
end
|
||||
|
||||
def cpu_allocated
|
||||
self[:cpu_allocated] || 10000
|
||||
end
|
||||
|
||||
def memory_allocated
|
||||
self[:memory_allocated] || 20480
|
||||
end
|
||||
|
||||
def catalog
|
||||
@catalog ||= MockCatalog.new({}, self)
|
||||
end
|
||||
|
||||
def networks
|
||||
@networks ||= []
|
||||
end
|
||||
|
||||
def virtual_machines
|
||||
@virtual_machines ||= []
|
||||
end
|
||||
|
||||
def task_list
|
||||
@task_list ||= MockTaskList.new({}, self)
|
||||
end
|
||||
|
||||
# for TM eCloud, should probably be subclassed
|
||||
def public_ip_collection
|
||||
@public_ip_collection ||= MockPublicIps.new({}, self)
|
||||
end
|
||||
|
||||
def internet_service_collection
|
||||
@internet_service_collection ||= MockVdcInternetServices.new({}, self)
|
||||
end
|
||||
|
||||
def firewall_acls
|
||||
@firewall_acls ||= MockFirewallAcls.new({}, self)
|
||||
end
|
||||
end
|
||||
|
||||
class MockTaskList < Base
|
||||
def name
|
||||
self[:name] || "Tasks List"
|
||||
end
|
||||
end
|
||||
|
||||
class MockCatalog < Base
|
||||
def name
|
||||
self[:name] || "Catalog"
|
||||
end
|
||||
|
||||
def items
|
||||
@items ||= []
|
||||
end
|
||||
end
|
||||
|
||||
class MockCatalogItem < Base
|
||||
def name
|
||||
self[:name]
|
||||
end
|
||||
|
||||
def disks
|
||||
@disks ||= MockVirtualMachineDisks.new(self)
|
||||
end
|
||||
|
||||
def customization
|
||||
@customization ||= MockCatalogItemCustomization.new({}, self)
|
||||
end
|
||||
|
||||
def vapp_template
|
||||
@vapp_template ||= MockCatalogItemVappTemplate.new({ :name => name }, self)
|
||||
end
|
||||
end
|
||||
|
||||
class MockCatalogItemCustomization < Base
|
||||
def name
|
||||
self[:name] || "Customization Options"
|
||||
end
|
||||
end
|
||||
|
||||
class MockCatalogItemVappTemplate < Base
|
||||
def name
|
||||
self[:name]
|
||||
end
|
||||
end
|
||||
|
||||
class MockNetwork < Base
|
||||
def name
|
||||
self[:name] || subnet
|
||||
end
|
||||
|
||||
def subnet
|
||||
self[:subnet]
|
||||
end
|
||||
|
||||
def gateway
|
||||
self[:gateway] || subnet_ips[1]
|
||||
end
|
||||
|
||||
def netmask
|
||||
self[:netmask] || subnet_ipaddr.mask
|
||||
end
|
||||
|
||||
def dns
|
||||
"8.8.8.8"
|
||||
end
|
||||
|
||||
def features
|
||||
[
|
||||
{ :type => :FenceMode, :value => "isolated" }
|
||||
]
|
||||
end
|
||||
|
||||
def ip_collection
|
||||
@ip_collection ||= MockNetworkIps.new({}, self)
|
||||
end
|
||||
|
||||
def extensions
|
||||
@extensions ||= MockNetworkExtensions.new({}, self)
|
||||
end
|
||||
|
||||
def random_ip
|
||||
usable_subnet_ips[rand(usable_subnet_ips.length)]
|
||||
end
|
||||
|
||||
# for TM eCloud. should probably be a subclass
|
||||
def rnat
|
||||
self[:rnat]
|
||||
end
|
||||
|
||||
def usable_subnet_ips
|
||||
subnet_ips[3..-2]
|
||||
end
|
||||
|
||||
def address
|
||||
subnet_ips.first
|
||||
end
|
||||
|
||||
def broadcast
|
||||
subnet_ips.last
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def subnet_ipaddr
|
||||
@ipaddr ||= IPAddr.new(subnet)
|
||||
end
|
||||
|
||||
def subnet_ips
|
||||
subnet_ipaddr.to_range.to_a.map(&:to_s)
|
||||
end
|
||||
end
|
||||
|
||||
class MockNetworkIps < Base
|
||||
def items
|
||||
@items ||= _parent.usable_subnet_ips.reduce({}) do |out, subnet_ip|
|
||||
out.update(subnet_ip => MockNetworkIp.new({ :ip => subnet_ip }, self))
|
||||
end
|
||||
end
|
||||
|
||||
def ordered_ips
|
||||
items.values.sort_by {|i| i.ip.split(".").map(&:to_i) }
|
||||
end
|
||||
|
||||
def name
|
||||
"IP Addresses"
|
||||
end
|
||||
end
|
||||
|
||||
class MockNetworkIp < Base
|
||||
def name
|
||||
self[:name] || ip
|
||||
end
|
||||
|
||||
def ip
|
||||
self[:ip]
|
||||
end
|
||||
|
||||
def used_by
|
||||
self[:used_by] || _parent._parent._parent.virtual_machines.find {|v| v.ip == ip }
|
||||
end
|
||||
|
||||
def status
|
||||
if used_by
|
||||
"Assigned"
|
||||
else
|
||||
"Available"
|
||||
end
|
||||
end
|
||||
|
||||
def rnat
|
||||
self[:rnat] || _parent._parent.rnat
|
||||
end
|
||||
|
||||
def rnat_set?
|
||||
!!self[:rnat]
|
||||
end
|
||||
end
|
||||
|
||||
class MockNetworkExtensions < Base
|
||||
def name
|
||||
_parent.name
|
||||
end
|
||||
|
||||
def gateway
|
||||
_parent.gateway
|
||||
end
|
||||
|
||||
def broadcast
|
||||
_parent.broadcast
|
||||
end
|
||||
|
||||
def address
|
||||
_parent.address
|
||||
end
|
||||
|
||||
def rnat
|
||||
_parent.rnat
|
||||
end
|
||||
|
||||
def type
|
||||
self[:type] || "DMZ"
|
||||
end
|
||||
|
||||
def vlan
|
||||
object_id.to_s
|
||||
end
|
||||
|
||||
def friendly_name
|
||||
"#{name} (#{type}_#{object_id})"
|
||||
end
|
||||
end
|
||||
|
||||
class MockVirtualMachine < Base
|
||||
def name
|
||||
self[:name]
|
||||
end
|
||||
|
||||
def ip
|
||||
self[:ip]
|
||||
end
|
||||
|
||||
def cpus
|
||||
self[:cpus] || 1
|
||||
end
|
||||
|
||||
def memory
|
||||
self[:memory] || 1024
|
||||
end
|
||||
|
||||
def disks
|
||||
@disks ||= MockVirtualMachineDisks.new(self)
|
||||
end
|
||||
|
||||
def status
|
||||
self[:status] || 2
|
||||
end
|
||||
|
||||
def power_off!
|
||||
self[:status] = 2
|
||||
end
|
||||
|
||||
def power_on!
|
||||
self[:status] = 4
|
||||
end
|
||||
|
||||
def size
|
||||
disks.reduce(0) {|s, d| s + d.vcloud_size }
|
||||
end
|
||||
|
||||
def network_ip
|
||||
if network = _parent.networks.find {|n| n.ip_collection.items[ip] }
|
||||
network.ip_collection.items[ip]
|
||||
end
|
||||
end
|
||||
|
||||
# from fog ecloud server's _compose_vapp_data
|
||||
def to_configure_vapp_hash
|
||||
{
|
||||
:name => name,
|
||||
:cpus => cpus,
|
||||
:memory => memory,
|
||||
:disks => disks.map {|d| { :number => d.address.to_s, :size => d.vcloud_size, :resource => d.vcloud_size.to_s } }
|
||||
}
|
||||
end
|
||||
|
||||
def href(purpose = :base)
|
||||
case purpose
|
||||
when :base
|
||||
super()
|
||||
when :power_on
|
||||
super() + "/power/action/powerOn"
|
||||
when :power_off
|
||||
super() + "/power/action/powerOff"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class MockVirtualMachineDisks < Array
|
||||
def initialize(parent = nil)
|
||||
@parent = parent
|
||||
end
|
||||
|
||||
def _parent
|
||||
@parent
|
||||
end
|
||||
|
||||
def <<(disk)
|
||||
next_address = 0
|
||||
disk_with_max_address = max {|a, b| a[:address] <=> b[:address] }
|
||||
disk_with_max_address && next_address = disk_with_max_address.address + 1
|
||||
disk[:address] ||= next_address
|
||||
|
||||
super(disk)
|
||||
|
||||
if (addresses = map {|d| d.address }).uniq.size != size
|
||||
raise "Duplicate disk address in: #{addresses.inspect} (#{size})"
|
||||
end
|
||||
|
||||
sort! {|a, b| a.address <=> b.address }
|
||||
self
|
||||
end
|
||||
|
||||
def at_address(address)
|
||||
find {|d| d.address == address }
|
||||
end
|
||||
end
|
||||
|
||||
class MockVirtualMachineDisk < Base
|
||||
def size
|
||||
self[:size].to_i
|
||||
end
|
||||
|
||||
def vcloud_size
|
||||
# kilobytes
|
||||
size * 1024
|
||||
end
|
||||
|
||||
def address
|
||||
self[:address].to_i
|
||||
end
|
||||
end
|
||||
|
||||
# for Terremark eCloud
|
||||
|
||||
class MockVdcInternetServices < Base
|
||||
def href
|
||||
_parent.href + "/internetServices"
|
||||
end
|
||||
|
||||
def name
|
||||
"Internet Services"
|
||||
end
|
||||
|
||||
def items
|
||||
public_ip_internet_services + backup_internet_services
|
||||
end
|
||||
|
||||
def public_ip_internet_services
|
||||
_parent.public_ip_collection.items.reduce([]) do |services, public_ip|
|
||||
services + public_ip.internet_service_collection.items
|
||||
end
|
||||
end
|
||||
|
||||
def backup_internet_services
|
||||
@backup_internet_services ||= []
|
||||
end
|
||||
end
|
||||
|
||||
class MockBackupInternetService < Base
|
||||
def name
|
||||
self[:name] || "Backup Internet Service #{object_id}"
|
||||
end
|
||||
|
||||
def protocol
|
||||
self[:protocol]
|
||||
end
|
||||
|
||||
def port
|
||||
0
|
||||
end
|
||||
|
||||
def enabled
|
||||
self[:enabled].to_s.downcase != "false"
|
||||
end
|
||||
|
||||
def timeout
|
||||
self[:timeout] || 2
|
||||
end
|
||||
|
||||
def description
|
||||
self[:description] || "Description for Backup Service #{name}"
|
||||
end
|
||||
|
||||
def redirect_url
|
||||
nil
|
||||
end
|
||||
|
||||
def node_collection
|
||||
@node_collection ||= MockPublicIpInternetServiceNodes.new({}, self)
|
||||
end
|
||||
end
|
||||
|
||||
class MockFirewallAcls < Base
|
||||
def name
|
||||
"Firewall Access List"
|
||||
end
|
||||
end
|
||||
|
||||
class MockPublicIps < Base
|
||||
def name
|
||||
self[:name] || "Public IPs"
|
||||
end
|
||||
|
||||
def items
|
||||
@items ||= []
|
||||
end
|
||||
end
|
||||
|
||||
class MockPublicIp < Base
|
||||
def name
|
||||
self[:name]
|
||||
end
|
||||
|
||||
def internet_service_collection
|
||||
@internet_service_collection ||= MockPublicIpInternetServices.new({}, self)
|
||||
end
|
||||
end
|
||||
|
||||
class MockPublicIpInternetServices < Base
|
||||
def href
|
||||
_parent.href + "/internetServices"
|
||||
end
|
||||
|
||||
def items
|
||||
@items ||= []
|
||||
end
|
||||
end
|
||||
|
||||
class MockPublicIpInternetService < Base
|
||||
def name
|
||||
self[:name] || "Public IP Service #{object_id}"
|
||||
end
|
||||
|
||||
def description
|
||||
self[:description] || "Description for Public IP Service #{name}"
|
||||
end
|
||||
|
||||
def protocol
|
||||
self[:protocol]
|
||||
end
|
||||
|
||||
def port
|
||||
self[:port]
|
||||
end
|
||||
|
||||
def enabled
|
||||
!!self[:enabled]
|
||||
end
|
||||
|
||||
def redirect_url
|
||||
self[:redirect_url]
|
||||
end
|
||||
|
||||
def timeout
|
||||
self[:timeout] || 2
|
||||
end
|
||||
|
||||
def node_collection
|
||||
@node_collection ||= MockPublicIpInternetServiceNodes.new({}, self)
|
||||
end
|
||||
|
||||
def monitor
|
||||
nil
|
||||
end
|
||||
|
||||
def backup_service
|
||||
self[:backup_service]
|
||||
end
|
||||
end
|
||||
|
||||
class MockPublicIpInternetServiceNodes < Base
|
||||
def href
|
||||
_parent.href + "/nodeServices"
|
||||
end
|
||||
|
||||
def items
|
||||
@items ||= [].tap do |node_array|
|
||||
node_array.instance_variable_set("@default_port", _parent.port)
|
||||
|
||||
def node_array.<<(node)
|
||||
node[:port] ||= @default_port
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class MockPublicIpInternetServiceNode < Base
|
||||
def ip_address
|
||||
self[:ip_address]
|
||||
end
|
||||
|
||||
def name
|
||||
self[:name] || "Public IP Service Node #{object_id}"
|
||||
end
|
||||
|
||||
def description
|
||||
self[:description] || "Description for Public IP Service Node #{name}"
|
||||
end
|
||||
|
||||
def port
|
||||
self[:port]
|
||||
end
|
||||
|
||||
def enabled
|
||||
self[:enabled].to_s.downcase != "false"
|
||||
end
|
||||
|
||||
def enabled=(new_value)
|
||||
self[:enabled] = new_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Ecloud
|
||||
class Model < Fog::Model
|
||||
attr_accessor :loaded
|
||||
alias_method :loaded?, :loaded
|
||||
|
||||
def reload
|
||||
instance = super
|
||||
@loaded = true
|
||||
instance
|
||||
end
|
||||
|
||||
def load_unless_loaded!
|
||||
unless @loaded
|
||||
reload
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class AdminOrganization < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||
attribute :multifactor_summary, :aliases => :MultifactorSummary
|
||||
attribute :support_access, :aliases => :SupportAccess
|
||||
|
||||
def ssh_keys
|
||||
@ssh_keys = Fog::Compute::Ecloud::SshKeys.new(:service => service, :href => "#{service.base_path}/admin/sshKeys/organizations/#{organization.id}")
|
||||
end
|
||||
|
||||
def password_complexity_rules
|
||||
@password_complexity_rules = Fog::Compute::Ecloud::PasswordComplexityRules.new(:service => service, :href => "#{service.base_path}/admin/organizations/#{organization.id}/passwordComplexityRules")
|
||||
end
|
||||
|
||||
def login_banner
|
||||
@login_banner = Fog::Compute::Ecloud::LoginBanner.new(:service => service, :href => "#{service.base_path}/admin/organizations/#{organization.id}/loginBanner")
|
||||
end
|
||||
|
||||
def authentication_levels
|
||||
@authentication_levels = Fog::Compute::Ecloud::AuthenticationLevels.new(:service => service, :href => "#{service.base_path}/admin/organizations/#{organization.id}/authenticationLevels")
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
def organization
|
||||
@organization ||= begin
|
||||
reload unless other_links
|
||||
organization_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.organization"}
|
||||
self.service.organizations.new(organization_link)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/admin_organization'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class AdminOrganizations < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::AdminOrganization
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_admin_organization(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class ApiKey < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :access_key, :aliases => :AccessKey
|
||||
attribute :status, :aliases => :Status
|
||||
attribute :private_key, :aliases => :PrivateKey
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/api_key'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class ApiKeys < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::ApiKey
|
||||
|
||||
def all
|
||||
data = service.get_api_keys(href).body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_api_key(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Association < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :ip_address, :aliases => :IpAddress
|
||||
|
||||
def delete
|
||||
data = service.rnat_associations_delete(href).body
|
||||
task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => href)[0]
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/association'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Associations < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::Association
|
||||
|
||||
def all
|
||||
data = service.get_associations(href).body
|
||||
if data[:Associations]
|
||||
data = data[:Associations]
|
||||
if data.is_a?(String) && data.empty?
|
||||
data = []
|
||||
elsif data.is_a?(Hash)
|
||||
data = data[:Association]
|
||||
end
|
||||
end
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_association(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class AuthenticationLevel < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :basic_enabled, :aliases => :BasicEnabled, :type => :boolean
|
||||
attribute :sha1_enabled, :aliases => :SHA1Enabled, :type => :boolean
|
||||
attribute :Sha256_enabled, :aliases => :SHA256Enabled, :type => :boolean
|
||||
attribute :Sha512_enabled, :aliases => :SHA512Enabled, :type => :boolean
|
||||
attribute :hmacsha1_enabled, :aliases => :HMACSHA1Enabled, :type => :boolean
|
||||
attribute :hmacsha256_enabled, :aliases => :HMACSHA256Enabled, :type => :boolean
|
||||
attribute :hmacsha512_enabled, :aliases => :HMACSHA512Enabled, :type => :boolean
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/authentication_level'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class AuthenticationLevels < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::AuthenticationLevel
|
||||
|
||||
def all
|
||||
data = service.get_authentication_levels(href).body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_authentication_level(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class BackupInternetService < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :protocol, :aliases => :Protocol
|
||||
attribute :enabled, :aliases => :Enabled, :type => :boolean
|
||||
attribute :description, :aliases => :Description
|
||||
attribute :persistence, :aliases => :Persistence
|
||||
attribute :redirect_url, :aliases => :RedirectUrl
|
||||
|
||||
def tasks
|
||||
@tasks = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => href)
|
||||
end
|
||||
|
||||
def internet_services
|
||||
@internet_services = Fog::Compute::Ecloud::InternetServices.new(:service => service, :href => href)
|
||||
end
|
||||
|
||||
def node_services
|
||||
@node_services = Fog::Compute::Ecloud::NodeServices.new(:service => service, :href => href)
|
||||
end
|
||||
|
||||
def edit(options)
|
||||
options[:uri] = href
|
||||
data = service.backup_internet_service_edit(options).body
|
||||
object = collection.from_data(data)
|
||||
end
|
||||
|
||||
def delete
|
||||
data = service.backup_internet_service_delete(href).body
|
||||
task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/backup_internet_service'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class BackupInternetServices < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::BackupInternetService
|
||||
|
||||
def all
|
||||
data = service.get_backup_internet_services(href).body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_backup_internet_service(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
def from_data(data)
|
||||
new(data)
|
||||
end
|
||||
|
||||
def create(options)
|
||||
options[:uri] = href + "/action/createBackupInternetService"
|
||||
options[:enabled] ||= true
|
||||
data = service.backup_internet_service_create(options)
|
||||
new(data)
|
||||
end
|
||||
|
||||
def internet_service_id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/catalog_item'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Catalog < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::CatalogItem
|
||||
|
||||
def all
|
||||
data = service.get_catalog(href).body#[:Locations][:Location][:Catalog][:CatalogEntry]
|
||||
if data[:Locations][:Location].is_a?(Hash)
|
||||
data = [] if data[:Locations][:Location][:Catalog].is_a?(String) && data[:Locations][:Location][:Catalog].empty?
|
||||
load(data)
|
||||
elsif data[:Locations][:Location].is_a?(Array)
|
||||
r_data = []
|
||||
data[:Locations][:Location].each do |d|
|
||||
unless d[:Catalog].is_a?(String) && d[:Catalog].empty?
|
||||
d[:Catalog][:CatalogEntry].each do |c|
|
||||
r_data << c
|
||||
end
|
||||
end
|
||||
end
|
||||
load(r_data)
|
||||
end
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_catalog_item(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class CatalogConfiguration < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :processor_count, :aliases => :ProcessorCount, :type => :integer
|
||||
attribute :memory, :aliases => :Memory
|
||||
attribute :operating_system, :aliases => :OperatingSystem
|
||||
attribute :disks, :aliases => :Disks
|
||||
attribute :network_adapters, :aliases => :NetworkAdapters, :type => :integer
|
||||
attribute :network_mappings, :aliases => :NetworkMappings
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/catalog_configuration'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class CatalogConfigurations < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::CatalogConfiguration
|
||||
|
||||
def all
|
||||
data = service.get_catalog_configurations(href).body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_catalog_configuration(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class CatalogItem < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :status, :aliases => :Status
|
||||
attribute :alerts, :aliases => :Alerts
|
||||
attribute :files, :aliases => :Files
|
||||
|
||||
def configuration
|
||||
@configuration = Fog::Compute::Ecloud::CatalogConfigurations.new(:service => service, :href => "#{service.base_path}/admin/catalog/#{id}/configuration")
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class ComputePool < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :href, :aliases => :Href
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||
attribute :all_servers, :aliases => :VirtualMachines
|
||||
attribute :purchased, :aliases => :Purchased
|
||||
attribute :cpu_burst, :aliases => :CpuBurst
|
||||
attribute :memory_burst, :aliases => :MemoryBurst
|
||||
|
||||
def servers
|
||||
@servers ||= Fog::Compute::Ecloud::Servers.new( :service => service, :href => "#{service.base_path}/virtualMachines/computePools/#{id}" )
|
||||
end
|
||||
|
||||
def layout
|
||||
@layout ||= Fog::Compute::Ecloud::Layouts.new(:service => service, :href => "#{service.base_path}/layout/computePools/#{id}").first
|
||||
end
|
||||
|
||||
def cpu_usage
|
||||
# time ? query = "/details?time=#{Time.parse(time).utc.strftime('%Y-%m-%dT%H:%M:%SZ')}" : query = ""
|
||||
@cpu_usage ||= Fog::Compute::Ecloud::CpuUsageDetailSummary.new(:service => service, :href => "#{service.base_path}/computePools/#{id}/usage/cpu")
|
||||
end
|
||||
|
||||
def memory_usage
|
||||
# time ? query = "/details?time=#{Time.parse(time).utc.strftime('%Y-%m-%dT%H:%M:%SZ')}" : query = ""
|
||||
@memory_usage ||= Fog::Compute::Ecloud::MemoryUsageDetailSummary.new(:service => service, :href => "#{service.base_path}/computePools/#{id}/usage/memory")
|
||||
end
|
||||
|
||||
def storage_usage
|
||||
@storage_usage ||= Fog::Compute::Ecloud::StorageUsageDetailSummary.new(:service => service, :href => "#{service.base_path}/computePools/#{id}/usage/storage")
|
||||
end
|
||||
|
||||
def operating_system_families
|
||||
@operating_system_families ||= Fog::Compute::Ecloud::OperatingSystemFamilies.new(:service => service, :href => "#{service.base_path}/operatingSystemFamilies/computePools/#{id}")
|
||||
end
|
||||
|
||||
def templates
|
||||
@templates ||= self.service.templates(:href => "#{service.base_path}/templates/computePools/#{id}")
|
||||
end
|
||||
|
||||
def detached_disks
|
||||
@detached_disks ||= self.service.detached_disks(:href => "#{service.base_path}/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.service.environments.get(environment_link[:href])
|
||||
end
|
||||
end
|
||||
|
||||
def edit(options)
|
||||
options[:uri] = href
|
||||
data = service.compute_pool_edit(options).body
|
||||
pool = collection.from_data(data)
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/compute_pool'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class ComputePools < Fog::Ecloud::Collection
|
||||
undef_method :create
|
||||
|
||||
attribute :href, :aliases => :Href
|
||||
|
||||
model Fog::Compute::Ecloud::ComputePool
|
||||
|
||||
def all
|
||||
check_href!(:message => "the Compute Pool href of the Environment you want to enumerate")
|
||||
data = service.get_compute_pools(href).body[:ComputePool]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_compute_pool(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
def from_data(data)
|
||||
new(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class CpuUsageDetail < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :time, :aliases => :Time
|
||||
attribute :value, :aliases => :Value
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/cpu_usage_detail'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class CpuUsageDetailSummary < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::CpuUsageDetail
|
||||
|
||||
def all
|
||||
data = service.get_cpu_usage_detail_summary(href).body[:CpuUsageDetailSummary][:CpuUsageDetail]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_cpu_usage_detail(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
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
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
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 = service.get_detached_disks(href).body[:DetachedDisk]
|
||||
data = [] if data.nil?
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
data = service.get_detached_disk(uri).body
|
||||
new(data)
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Environment < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd
|
||||
|
||||
attribute :name
|
||||
attribute :type
|
||||
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||
|
||||
def public_ips
|
||||
@public_ips ||= Fog::Compute::Ecloud::PublicIps.new(:service => service, :href => "#{service.base_path}/publicIps/environments/#{id}")
|
||||
end
|
||||
|
||||
def internet_services
|
||||
@internet_services ||= Fog::Compute::Ecloud::InternetServices.new(:service => service, :href => "#{service.base_path}/networkSummary/environments/#{id}")
|
||||
end
|
||||
|
||||
def node_services
|
||||
@node_services ||= Fog::Compute::Ecloud::Nodes.new(:service => service, :href => "#{service.base_path}/networkSummary/environments/#{id}")
|
||||
end
|
||||
|
||||
def backup_internet_services
|
||||
@backup_internet_services ||= Fog::Compute::Ecloud::BackupInternetServices.new(:service => service, :href => "#{service.base_path}/backupInternetServices/environments/#{id}")
|
||||
end
|
||||
|
||||
def networks
|
||||
@networks ||= self.service.networks(:href => "#{service.base_path}/networks/environments/#{id}")
|
||||
end
|
||||
|
||||
def servers
|
||||
@servers = nil
|
||||
pools = compute_pools
|
||||
pools.each do |c|
|
||||
if pools.index(c) == 0
|
||||
@servers = c.servers
|
||||
else
|
||||
c.servers.each { |s| @servers << s }
|
||||
end
|
||||
end
|
||||
@servers
|
||||
end
|
||||
|
||||
def layout
|
||||
@layout ||= self.service.layouts(:href => "#{service.base_path}/layout/environments/#{id}").first
|
||||
end
|
||||
|
||||
def rows
|
||||
@rows ||= layout.rows
|
||||
end
|
||||
|
||||
def tasks
|
||||
@tasks ||= Fog::Compute::Ecloud::Tasks.new(:service => service, :href => "#{service.base_path}/tasks/environments/#{id}")
|
||||
end
|
||||
|
||||
def firewall_acls
|
||||
@firewall_acls ||= Fog::Compute::Ecloud::FirewallAcls.new(:service => service, :href => "#{service.base_path}/firewallAcls/environments/#{id}")
|
||||
end
|
||||
|
||||
def compute_pools
|
||||
@compute_pools ||= Fog::Compute::Ecloud::ComputePools.new(:service => service, :href => "#{service.base_path}/computePools/environments/#{id}")
|
||||
end
|
||||
|
||||
def physical_devices
|
||||
@physical_devices ||= Fog::Compute::Ecloud::PhysicalDevices.new(:service => service, :href => "#{service.base_path}/physicalDevices/environments/#{id}")
|
||||
end
|
||||
|
||||
def trusted_network_groups
|
||||
@trusted_network_groups ||= Fog::Compute::Ecloud::TrustedNetworkGroups.new(:service => service, :href => "#{service.base_path}/trustedNetworkGroups/environments/#{id}")
|
||||
end
|
||||
|
||||
def catalog
|
||||
@catalog = service.catalog(:href => "#{service.base_path}/admin/catalog/organizations/#{organization.id}")
|
||||
end
|
||||
|
||||
def rnats
|
||||
@rnats ||= Fog::Compute::Ecloud::Rnats.new(:service => service, :href => "#{service.base_path}/rnats/environments/#{id}")
|
||||
end
|
||||
|
||||
def create_trusted_network_group(options = {})
|
||||
options[:uri] = "#{service.base_path}/trustedNetworkGroups/environments/#{id}/action/createTrustedNetworkGroup"
|
||||
data = service.trusted_network_groups_create(options).body
|
||||
tng = Fog::Compute::Ecloud::TrustedNetworkGroups.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
|
||||
def create_firewall_acl(options = {})
|
||||
options[:uri] = "#{service.base_path}/firewallAcls/environments/#{id}/action/createFirewallAcl"
|
||||
options[:permission] ||= "deny"
|
||||
options[:protocol] ||= "any"
|
||||
data = service.firewall_acls_create(options).body
|
||||
acl = Fog::Compute::Ecloud::FirewallAcls.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
def organization
|
||||
@organization ||= begin
|
||||
reload unless other_links
|
||||
organization_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.organization"}
|
||||
self.service.organizations.new(organization_link)
|
||||
end
|
||||
end
|
||||
end
|
||||
Vdc = Environment
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/environment'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Environments < Fog::Ecloud::Collection
|
||||
model Fog::Compute::Ecloud::Environment
|
||||
|
||||
undef_method :create
|
||||
|
||||
identity :href
|
||||
|
||||
def all
|
||||
data = []
|
||||
service.get_organization(href).body[:Locations][:Location].each do |d|
|
||||
environments = d[:Environments]
|
||||
next unless environments
|
||||
if environments[:Environment].is_a?(Array)
|
||||
environments[:Environment].each { |e| data << e }
|
||||
else
|
||||
data << environments[:Environment]
|
||||
end
|
||||
end
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_environment(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
Vdcs = Environments
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class FirewallAcl < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :links, :aliases => :Links
|
||||
attribute :permission, :aliases => :Permission
|
||||
attribute :acl_type, :aliases => :AclType
|
||||
attribute :port_type, :aliases => :PortType
|
||||
attribute :protocol, :aliases => :Protocol
|
||||
attribute :source, :aliases => :Source
|
||||
attribute :destination, :aliases => :Destination
|
||||
attribute :port_range, :aliases => :PortRange
|
||||
|
||||
def tasks
|
||||
@tasks = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => "#{service.base_path}/tasks/virtualMachines/#{id}")
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/firewall_acl'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class FirewallAcls < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::FirewallAcl
|
||||
|
||||
def all
|
||||
data = service.get_firewall_acls(href).body
|
||||
data = data[:FirewallAcl] ? data[:FirewallAcl] : data
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_firewall_acl(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Group < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :index, :aliases => :Index
|
||||
|
||||
def servers
|
||||
@servers = Fog::Compute::Ecloud::Servers.new(:service => service, :href => href)
|
||||
end
|
||||
|
||||
def edit(options = {})
|
||||
options[:uri] = href
|
||||
data = service.groups_edit(options).body
|
||||
end
|
||||
|
||||
def move_up
|
||||
service.groups_moveup(href).body
|
||||
end
|
||||
|
||||
def move_down
|
||||
service.groups_movedown(href).body
|
||||
end
|
||||
|
||||
def delete
|
||||
service.groups_delete(href).body
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
alias_method :destroy, :delete
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/group'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Groups < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::Group
|
||||
|
||||
def all
|
||||
data = service.get_groups(href).body
|
||||
data = if 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
|
||||
|
||||
def get(uri)
|
||||
data = service.get_group(uri).body
|
||||
if data == ""
|
||||
nil
|
||||
else
|
||||
new(data)
|
||||
end
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class GuestProcess < Fog::Ecloud::Model
|
||||
identity :name
|
||||
|
||||
attribute :process_id, :aliases => :ProcessId
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/guest_process'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class GuestProcesses < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::GuestProcess
|
||||
|
||||
def all
|
||||
data = service.get_guest_processes(href).body[:GuestProcess]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_guest_process(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class HardwareConfiguration < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :processor_count, :aliases => :ProcessorCount, :type => :integer
|
||||
attribute :memory, :aliases => :Memory, :squash => :Value # {:Memory => {:Value => 15}}
|
||||
attribute :storage, :aliases => :Disks, :squash => :Disk
|
||||
attribute :network_cards, :aliases => :Nics, :squash => :Nic
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/hardware_configuration'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class HardwareConfigurations < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::HardwareConfiguration
|
||||
|
||||
def all
|
||||
data = service.get_server(href).body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_hardware_configuration(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class InternetService < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :actions, :aliases => :Actions
|
||||
attribute :protocol, :aliases => :Protocol
|
||||
attribute :port, :aliases => :Port, :type => :integer
|
||||
attribute :enabled, :aliases => :Enabled, :type => :boolean
|
||||
attribute :description, :aliases => :Description
|
||||
attribute :public_ip, :aliases => :PublicIp
|
||||
attribute :persistence, :aliases => :Persistence
|
||||
attribute :redirect_url, :aliases => :RedirectUrl
|
||||
attribute :trusted_network_group, :aliases => :TrustedNetworkGroup
|
||||
attribute :backup_internet_service, :aliases => :BackupInternetService
|
||||
|
||||
def ready?
|
||||
!self.port.nil?
|
||||
end
|
||||
|
||||
def nodes
|
||||
@nodes ||= Fog::Compute::Ecloud::Nodes.new(:service => service, :href => href)
|
||||
end
|
||||
|
||||
def monitors
|
||||
@monitors ||= Fog::Compute::Ecloud::Monitors.new(:service => service, :href => "#{service.base_path}/internetServices/#{id}/monitor")
|
||||
end
|
||||
|
||||
def save
|
||||
unless persisted?
|
||||
result = service.internet_service_create( collection.href, _compose_service_data )
|
||||
merge_attributes(result.body)
|
||||
else
|
||||
service.configure_internet_service( href, _compose_service_data, _compose_ip_data )
|
||||
end
|
||||
end
|
||||
|
||||
def edit(options)
|
||||
options[:uri] = href
|
||||
data = service.internet_service_edit(options).body
|
||||
task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
|
||||
def delete
|
||||
data = service.internet_service_delete(href).body
|
||||
self.service.tasks.new(data)
|
||||
end
|
||||
|
||||
def create_monitor(options = {})
|
||||
options = {:type => :default}.merge(options)
|
||||
case options[:type]
|
||||
when :default
|
||||
data = service.monitors_create_default(href + "/action/createDefaultMonitor").body
|
||||
when :ping
|
||||
options[:enabled] ||= true
|
||||
options[:uri] = href + "/action/createPingMonitor"
|
||||
data = service.monitors_create_ping(options).body
|
||||
when :http
|
||||
options[:uri] = href + "/action/createHttpMonitor"
|
||||
data = service.monitors_create_http(options).body
|
||||
when :ecv
|
||||
options[:uri] = href + "/action/createEcvMonitor"
|
||||
data = service.monitors_create_ecv(options).body
|
||||
when :loopback
|
||||
data = service.monitors_create_loopback(href).body
|
||||
end
|
||||
monitor = Fog::Compute::Ecloud::Monitors.new(:service => service, :href => data[:href])
|
||||
end
|
||||
|
||||
def disable_monitor
|
||||
data = service.monitors_disable(href + "/action/disableMonitor").body
|
||||
task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def _compose_service_data
|
||||
#For some reason inject didn't work
|
||||
service_data = {}
|
||||
self.class.attributes.select{ |attribute| attribute != :backup_service_data }.each { |attribute| service_data[attribute] = send(attribute) }
|
||||
service_data.reject! {|k, v| v.nil? }
|
||||
service_data
|
||||
end
|
||||
|
||||
alias_method :destroy, :delete
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/internet_service'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class InternetServices < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::InternetService
|
||||
|
||||
def all
|
||||
data = service.get_internet_services(href).body[:InternetServices]
|
||||
if data.is_a?(Hash)
|
||||
load(data[:InternetService])
|
||||
elsif data.is_a?(String) && data.empty?
|
||||
load([])
|
||||
end
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
data = service.get_internet_service(uri).body
|
||||
new(data)
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
def create(options)
|
||||
options[:uri] = "#{service.base_path}/internetServices/publicIps/#{public_ip_id}/action/createInternetService"
|
||||
options[:protocol] ||= "TCP"
|
||||
options[:enabled] ||= true
|
||||
options[:description] ||= ""
|
||||
options[:persistence] ||= {}
|
||||
options[:persistence][:type] ||= "None"
|
||||
data = service.internet_service_create(options).body
|
||||
object = new(data)
|
||||
end
|
||||
|
||||
def public_ip_id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class IpAddress < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||
attribute :host, :aliases => :Host
|
||||
attribute :detected_on, :aliases => :DetectedOn
|
||||
attribute :rnat, :aliases => :RnatAddress
|
||||
attribute :reserved, :aliases => :Reserved, :type => :boolean
|
||||
|
||||
def status
|
||||
(detected_on || host) ? "Assigned" : "Available"
|
||||
end
|
||||
|
||||
def id
|
||||
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.service.servers.get(server_link[:href])
|
||||
end
|
||||
end
|
||||
|
||||
def network
|
||||
reload if other_links.nil?
|
||||
network_href = other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.network" }[:href]
|
||||
network = self.service.networks.get(network_href)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/ip_address'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class IpAddresses < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::IpAddress
|
||||
|
||||
def all
|
||||
data = service.get_network(href).body
|
||||
data = if data[:IpAddresses]
|
||||
data[:IpAddresses][:IpAddress]
|
||||
else
|
||||
data
|
||||
end
|
||||
data = data.nil? ? [] : data
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_ip_address(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Layout < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
|
||||
def rows
|
||||
@rows ||= self.service.rows(:href => href)
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/layout'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Layouts < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::Layout
|
||||
|
||||
def all
|
||||
data = service.get_layouts(href).body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_layout(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Location < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
|
||||
def catalog(org_href)
|
||||
@catalog ||= Fog::Compute::Ecloud::Catalog.new(:service => service, :href => "#{service.base_path}/admin/catalog/organizations/#{org_href.scan(/\d+/)[0]}/locations/#{id}")
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/location'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Locations < Fog::Ecloud::Collection
|
||||
model Fog::Compute::Ecloud::Location
|
||||
|
||||
undef_method :create
|
||||
|
||||
identity :href
|
||||
|
||||
def all
|
||||
data = service.get_organization(href).body[:Locations][:Location]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_location(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class LoginBanner < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :display, :aliases => :Display, :type => :boolean
|
||||
attribute :text, :aliases => :Text
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/login_banner'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class LoginBanners < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::LoginBanner
|
||||
|
||||
def all
|
||||
data = service.get_login_banners(href).body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_login_banner(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class MemoryUsageDetail < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :time, :aliases => :Time
|
||||
attribute :value, :aliases => :Value
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/memory_usage_detail'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class MemoryUsageDetailSummary < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::MemoryUsageDetail
|
||||
|
||||
def all
|
||||
data = service.get_memory_usage_detail_summary(href).body[:MemoryUsageDetailSummary][:MemoryUsageDetail]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_memory_usage_detail(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Monitor < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :interval, :aliases => :Interval, :type => :integer
|
||||
attribute :response_timeout, :aliases => :ResponseTimeout, :type => :integer
|
||||
attribute :retries, :aliases => :Retries, :type => :integer
|
||||
attribute :downtime, :aliases => :Downtime, :type => :integer
|
||||
attribute :enabled, :aliases => :Enabled, :type => :boolean
|
||||
attribute :request_uri, :aliases => :RequestUri
|
||||
attribute :http_headers, :aliases => :HttpHeaders
|
||||
attribute :response_codes, :aliases => :ResponseCodes
|
||||
attribute :send_string, :aliases => :SendString
|
||||
attribute :receive_string, :aliases => :ReceiveString
|
||||
|
||||
def edit(options = {})
|
||||
href = "#{service.base_path}/internetServices/#{internet_service_id}/monitor?type="
|
||||
case type
|
||||
when "application/vnd.tmrk.cloud.pingMonitor"
|
||||
options[:uri] = href + "ping"
|
||||
data = service.monitors_edit_ping(options).body
|
||||
when "application/vnd.tmrk.cloud.httpMonitor"
|
||||
options[:uri] = href + "http"
|
||||
data = service.monitors_edit_http(options).body
|
||||
when "application/vnd.tmrk.cloud.ecvMonitor"
|
||||
options[:uri] = href + "ecv"
|
||||
data = service.monitors_edit_ecv(options).body
|
||||
end
|
||||
object = collection.from_data(data)
|
||||
end
|
||||
|
||||
def internet_service_id
|
||||
other_links[:Link][:href].scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/monitor'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Monitors < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::Monitor
|
||||
|
||||
def all
|
||||
data = service.get_monitors(href).body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_monitor(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
def from_data(data)
|
||||
new(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Network < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||
attribute :address, :aliases => :Address
|
||||
attribute :network_type, :aliases => :NetworkType
|
||||
attribute :broadcast_address, :aliases => :BroadcastAddress
|
||||
attribute :gateway_address, :aliases => :GatewayAddress
|
||||
attribute :rnat_address, :aliases => :RnatAddress
|
||||
|
||||
def rnats
|
||||
@rnats ||= Fog::Compute::Ecloud::Rnats.new(:service => service, :href => "#{service.base_path}/rnats/networks/#{id}")
|
||||
end
|
||||
|
||||
def ips
|
||||
@ips ||= Fog::Compute::Ecloud::IpAddresses.new(:service => service, :href => href)
|
||||
end
|
||||
|
||||
def edit_rnat_association(options)
|
||||
options[:uri] = href
|
||||
data = service.rnat_associations_edit_network(options).body
|
||||
task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
def environment
|
||||
reload if other_links.nil?
|
||||
environment_href = other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href]
|
||||
self.service.environments.get(environment_href)
|
||||
end
|
||||
|
||||
def location
|
||||
environment.id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/network'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Networks < Fog::Ecloud::Collection
|
||||
attribute :href, :aliases => :Href
|
||||
|
||||
model Fog::Compute::Ecloud::Network
|
||||
|
||||
def all
|
||||
body = service.get_networks(self.href).body
|
||||
body = body[:Networks] ? body[:Networks][:Network] : body[:Network]
|
||||
data = case body
|
||||
when NilClass then []
|
||||
when Array then body
|
||||
when Hash then [body]
|
||||
end
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_network(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Node < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :ip_address, :aliases => :IpAddress
|
||||
attribute :protocol, :aliases => :Protocol
|
||||
attribute :port, :aliases => :Port, :type => :integer
|
||||
attribute :enabled, :aliases => :Enabled, :type => :boolean
|
||||
attribute :description, :aliases => :Description
|
||||
|
||||
def ready?
|
||||
!self.name.nil?
|
||||
end
|
||||
|
||||
def tasks
|
||||
@tasks ||= Fog::Compute::Ecloud::Tasks.new(:service => service, :href => "#{service.base_path}/tasks/virtualMachines/#{id}")
|
||||
end
|
||||
|
||||
def delete
|
||||
data = service.node_service_delete(href).body
|
||||
self.service.tasks.new(data)
|
||||
end
|
||||
|
||||
def edit(options)
|
||||
options[:uri] = href
|
||||
options[:description] ||= ""
|
||||
options = {:name => name}.merge(options)
|
||||
data = service.node_service_edit(options).body
|
||||
task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
alias_method :destroy, :delete
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/node'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Nodes < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::Node
|
||||
|
||||
def all
|
||||
data = service.get_nodes(href).body
|
||||
if data[:NodeServices]
|
||||
load(data[:NodeServices][:NodeService])
|
||||
else
|
||||
load([])
|
||||
end
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
data = service.get_node(uri).body
|
||||
new(data)
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
def create(options)
|
||||
options[:uri] = "#{service.base_path}/nodeServices/internetServices/#{internet_service_id}/action/createNodeService"
|
||||
options[:protocol] ||= "TCP"
|
||||
options[:enabled] ||= true
|
||||
options[:description] ||= ""
|
||||
data = service.node_service_create(options).body
|
||||
object = new(data)
|
||||
end
|
||||
|
||||
def internet_service_id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class OperatingSystem < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/operating_system_family'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class OperatingSystemFamilies < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::OperatingSystemFamily
|
||||
|
||||
def all
|
||||
data = service.get_operating_system_families(href).body[:OperatingSystemFamily]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_operating_system(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class OperatingSystemFamily < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :operating_system_family, :aliases => :OperatingSystems
|
||||
|
||||
def operating_systems
|
||||
@operating_systems ||= self.service.operating_systems(:data => operating_system_family[:OperatingSystem])
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/operating_system'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class OperatingSystems < Fog::Ecloud::Collection
|
||||
model Fog::Compute::Ecloud::OperatingSystem
|
||||
|
||||
identity :data
|
||||
|
||||
def all
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_operating_system(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Organization < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||
|
||||
def locations
|
||||
@locations ||= Fog::Compute::Ecloud::Locations.new( :service => service, :href => href )
|
||||
end
|
||||
|
||||
def environments
|
||||
@environments ||= self.service.environments(:href => href)
|
||||
end
|
||||
|
||||
def tags
|
||||
@tags ||= self.service.tags(:href => "#{service.base_path}/deviceTags/organizations/#{id}")
|
||||
end
|
||||
|
||||
def admin
|
||||
@admin ||= self.service.admin_organizations.new(:href => "#{service.base_path}/admin/organizations/#{id}")
|
||||
end
|
||||
|
||||
def users
|
||||
@users ||= self.service.users(:href => "#{service.base_path}/admin/users/organizations/#{id}")
|
||||
end
|
||||
|
||||
def support_tickets(type = :open)
|
||||
case type
|
||||
when :open
|
||||
@support_tickets ||= Fog::Compute::Ecloud::SupportTickets.new(:service => service, :href => "#{service.base_path}/admin/tickets/organizations/#{id}/active")
|
||||
when :closed
|
||||
@support_tickets ||= Fog::Compute::Ecloud::SupportTickets.new(:service => service, :href => "#{service.base_path}/admin/tickets/organizations/#{id}/closed")
|
||||
end
|
||||
end
|
||||
|
||||
def edit_authentication_levels(options = {})
|
||||
options[:uri] = "#{service.base_path}/admin/organizations/#{id}/authenticationLevels"
|
||||
data = service.admin_edit_authentication_levels(options).body
|
||||
level = Fog::Compute::Ecloud::AdminOrganizations.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
|
||||
def edit_password_complexity_rules(options = {})
|
||||
options[:uri] = "#{service.base_path}/admin/organizations/#{id}/passwordComplexityRules"
|
||||
data = service.admin_edit_password_complexity_rules(options).body
|
||||
level = Fog::Compute::Ecloud::PasswordComplexityRules.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
|
||||
def edit_login_banner(options = {})
|
||||
options[:uri] = "#{service.base_path}/admin/organizations/#{id}/loginBanner"
|
||||
data = service.admin_edit_login_banner(options).body
|
||||
banner = Fog::Compute::Ecloud::LoginBanners.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
|
||||
def enable_support_access(options = {})
|
||||
options[:uri] = "#{service.base_path}/admin/organizations/#{id}/action/enableSupportAccess"
|
||||
service.admin_enable_support_access(options[:uri])
|
||||
end
|
||||
|
||||
def disable_support_access(options = {})
|
||||
options[:uri] = "#{service.base_path}/admin/organizations/#{id}/action/disableSupportAccess"
|
||||
service.admin_disable_support_access(options[:uri])
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
alias_method :vdcs, :environments
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/organization'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Organizations < Fog::Ecloud::Collection
|
||||
model Fog::Compute::Ecloud::Organization
|
||||
|
||||
undef_method :create
|
||||
|
||||
identity :href
|
||||
|
||||
def all
|
||||
data = service.get_organizations(organization_uri).body
|
||||
load(data[:Organization])
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_organization(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
def organization_uri
|
||||
@organization_uri ||= service.default_organization_uri
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def organization_uri=(new_organization_uri)
|
||||
@organization_uri = new_organization_uri
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class PasswordComplexityRule < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :rule_type, :aliases => :RuleType
|
||||
attribute :custom_rules, :aliases => :CustomRules
|
||||
attribute :description, :aliases => :Description
|
||||
|
||||
def minimum_characters
|
||||
custom_rules[:MinimumCharacters]
|
||||
end
|
||||
|
||||
def minimum_upper_case_characters
|
||||
custom_rules[:MinimumUpperCaseCharacters]
|
||||
end
|
||||
|
||||
def minimum_lower_case_characters
|
||||
custom_rules[:MinimumLowerCaseCharacters]
|
||||
end
|
||||
|
||||
def minimum_numeric_characters
|
||||
custom_rules[:MinimumNumericCharacters]
|
||||
end
|
||||
|
||||
def minimum_special_characters
|
||||
custom_rules[:MinimumSpecialCharacters]
|
||||
end
|
||||
|
||||
def maximum_consecutive_characters_from_prior_password
|
||||
custom_rules[:MaximumConsecutiveCharactersFromPriorPassword]
|
||||
end
|
||||
|
||||
def minimum_lifetime_restriction
|
||||
custom_rules[:MinimumLifetimeRestriction]
|
||||
end
|
||||
|
||||
def minimum_generations_before_reuse
|
||||
custom_rules[:MinimumGenerationsBeforeReuse]
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/password_complexity_rule'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class PasswordComplexityRules < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::PasswordComplexityRule
|
||||
|
||||
def all
|
||||
data = service.get_password_complexity_rules(href).body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_password_complexity_rule(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class PhysicalDevice < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :tags, :aliases => :Tags
|
||||
attribute :layout, :aliases => :Layout
|
||||
attribute :network_host, :aliases => :NetworkHost
|
||||
attribute :classification, :aliases => :Classification
|
||||
attribute :model, :aliases => :Model
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/physical_device'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class PhysicalDevices < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::PhysicalDevice
|
||||
|
||||
def all
|
||||
data = service.get_physical_devices(href).body[:PhysicalDevice] || []
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_physical_device(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class PublicIp < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :ip_type, :aliases => :IpType
|
||||
|
||||
def internet_services
|
||||
@internet_services = Fog::Compute::Ecloud::InternetServices.new(:service => service, :href => href)
|
||||
end
|
||||
|
||||
def environment_id
|
||||
other_links[:Link].find { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/public_ip'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class PublicIps < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::PublicIp
|
||||
|
||||
def all
|
||||
data = service.get_public_ips(href).body
|
||||
data = data[:PublicIp] ? data[:PublicIp] : data
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
data = service.get_public_ip(uri).body
|
||||
new(data)
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
def activate
|
||||
data = service.public_ip_activate(href + "/action/activatePublicIp").body
|
||||
ip = Fog::Compute::Ecloud::PublicIps.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Rnat < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :default, :aliases => :Default, :type => :boolean
|
||||
attribute :public_ip, :aliases => :PublicIp
|
||||
|
||||
def networks
|
||||
@networks = Fog::Compute::Ecloud::Networks.new(:service => service, :href => href)
|
||||
end
|
||||
|
||||
def associations
|
||||
@associations = Fog::Compute::Ecloud::Associations.new(:service => service, :href => href)
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/rnat'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Rnats < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::Rnat
|
||||
|
||||
def all
|
||||
data = service.get_rnats(href).body[:Rnats][:Rnat]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_rnat(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Role < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :environment_name, :aliases => :EnvironmentName
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :role_type, :aliases => :RoleType
|
||||
attribute :active, :aliases => :Active, :type => :boolean
|
||||
attribute :category, :aliases => :Category
|
||||
attribute :is_admin, :aliases => :IsAdmin, :type => :boolean
|
||||
attribute :business_operations, :aliases => :BusinessOperations
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/role'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Roles < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::Role
|
||||
|
||||
def all
|
||||
data = service.get_roles(href).body
|
||||
if data[:OrganizationRole]
|
||||
load(data[:OrganizationRole])
|
||||
else
|
||||
r_data = []
|
||||
data[:EnvironmentRoles][:EnvironmentRole].each do |d|
|
||||
d[:Environment][:EnvironmentName] = d[:Environment][:name]
|
||||
d[:Environment] = d[:Environment].merge(d[:Role]) if d[:Role]
|
||||
r_data << d[:Environment]
|
||||
end
|
||||
load(r_data)
|
||||
end
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_role(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Row < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :index, :aliases => :Index
|
||||
|
||||
def groups
|
||||
@groups = self.service.groups(:href => href)
|
||||
end
|
||||
|
||||
def edit(options)
|
||||
options[:uri] = href
|
||||
service.rows_edit(options).body
|
||||
end
|
||||
|
||||
def move_up(options)
|
||||
options[:uri] = href + "/action/moveup"
|
||||
service.rows_moveup(options).body
|
||||
end
|
||||
|
||||
def move_down(options)
|
||||
options[:uri] = href + "/action/movedown"
|
||||
service.rows_movedown(options).body
|
||||
end
|
||||
|
||||
def delete
|
||||
service.rows_delete(href).body
|
||||
end
|
||||
|
||||
def create_group(options = {})
|
||||
options[:uri] = "#{service.base_path}/layoutGroups/environments/#{environment_id}/action/createLayoutGroup"
|
||||
options[:row_name] = name
|
||||
options[:href] = href
|
||||
data = service.groups_create(options).body
|
||||
group = self.service.groups.new(data)
|
||||
end
|
||||
|
||||
def environment_id
|
||||
reload if other_links.nil?
|
||||
other_links[:Link][:href].scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
alias_method :destroy, :delete
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/row'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Rows < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::Row
|
||||
|
||||
def all
|
||||
data = service.get_layout(href).body[:Rows][:Row]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
data = service.get_row(uri).body
|
||||
if data == ""
|
||||
nil
|
||||
else
|
||||
new(data)
|
||||
end
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
def create(options = {})
|
||||
options[:uri] = "#{service.base_path}/layoutRows/environments/#{environment_id}/action/createLayoutRow"
|
||||
data = service.rows_create(options).body
|
||||
new(data)
|
||||
end
|
||||
|
||||
def environment_id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,323 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Server < Fog::Ecloud::Model
|
||||
extend Forwardable
|
||||
|
||||
identity :href
|
||||
|
||||
attribute :description, :aliases => :Description
|
||||
attribute :hardware_configuration, :aliases => :HardwareConfiguration
|
||||
attribute :ip_addresses, :aliases => :IpAddresses, :squash => :AssignedIpAddresses
|
||||
attribute :layout, :aliases => :Layout
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :operating_system, :aliases => :OperatingSystem
|
||||
attribute :other_links, :aliases => :Links, :squash => :Link
|
||||
attribute :powered_on, :aliases => :PoweredOn, :type => :boolean
|
||||
attribute :status, :aliases => :Status
|
||||
attribute :tags, :aliases => :Tags
|
||||
attribute :tools_status, :aliases => :ToolsStatus
|
||||
attribute :type, :aliases => :Type
|
||||
|
||||
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
|
||||
@tasks ||= self.service.tasks(:href => "#{service.base_path}/tasks/virtualMachines/#{id}")
|
||||
end
|
||||
|
||||
def processes
|
||||
@processes ||= Fog::Compute::Ecloud::GuestProcesses.new(:service, service, :href => "#{service.base_path}/virtualMachines/#{id}/guest/processes")
|
||||
end
|
||||
|
||||
def hardware_configuration=(hardware_configuration)
|
||||
@hardware_configuration = self.service.hardware_configurations.new(hardware_configuration)
|
||||
end
|
||||
|
||||
def hardware_configuration
|
||||
@hardware_configuration ||= self.service.hardware_configurations.new(:href => "#{service.base_path}/virtualMachines/#{id}/hardwareConfiguration")
|
||||
@hardware_configuration.reload
|
||||
end
|
||||
|
||||
def configuration
|
||||
@configuration ||= Fog::Compute::Ecloud::ServerConfigurationOptions.new(:service => service, :href => "#{service.base_path}/virtualMachines/#{id}/configurationOptions")[0]
|
||||
end
|
||||
|
||||
def ips
|
||||
@ips = self.service.virtual_machine_assigned_ips(:virtual_machine_id => self.id)
|
||||
end
|
||||
|
||||
def networks
|
||||
@networks ||= self.service.networks(:href => "#{service.base_path}/virtualMachines/#{id}/assignedIps")
|
||||
end
|
||||
|
||||
def power_on
|
||||
power_operation( :power_on => :powerOn )
|
||||
end
|
||||
|
||||
def power_off
|
||||
power_operation( :power_off => :powerOff )
|
||||
end
|
||||
|
||||
def shutdown
|
||||
power_operation( :power_shutdown => :shutdown )
|
||||
end
|
||||
|
||||
def power_reset
|
||||
power_operation( :power_reset => :reboot )
|
||||
end
|
||||
|
||||
def delete
|
||||
data = service.virtual_machine_delete(href).body
|
||||
self.service.tasks.new(data)
|
||||
end
|
||||
|
||||
def copy(options = {})
|
||||
options = {:type => :copy}.merge(options)
|
||||
options[:source] ||= href
|
||||
if options[:type] == :copy
|
||||
options[:cpus] ||= 1
|
||||
options[:memory] ||= 512
|
||||
options[:customization] ||= :linux
|
||||
options[:tags] ||= []
|
||||
options[:powered_on] ||= false
|
||||
if options[:ips]
|
||||
options[:ips] = options[:ips].is_a?(String) ? [options[:ips]] : options[:ips]
|
||||
else
|
||||
options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
|
||||
options[:network_uri].each do |uri|
|
||||
index = options[:network_uri].index(uri)
|
||||
ip = Fog::Compute::Ecloud::IpAddresses.new(:service => service, :href => uri).find { |i| i.host == nil }.name
|
||||
options[:ips] ||= []
|
||||
options[:ips][index] = ip
|
||||
end
|
||||
end
|
||||
data = service.virtual_machine_copy("#{service.base_path}/virtualMachines/computePools/#{compute_pool_id}/action/copyVirtualMachine", options).body
|
||||
elsif options[:type] == :identical
|
||||
data = service.virtual_machine_copy_identical("#{service.base_path}/virtualMachines/computePools/#{compute_pool_id}/action/copyIdenticalVirtualMachine", options).body
|
||||
end
|
||||
vm = collection.from_data(data)
|
||||
vm
|
||||
end
|
||||
|
||||
def rnats
|
||||
rnats = Fog::Compute::Ecloud::Rnats.new(:service => service, :href => "#{service.base_path}/rnats/environments/#{environment_id}")
|
||||
associations = nil
|
||||
rnats.each do |rnat|
|
||||
if rnats.index(rnat) == 0
|
||||
associations = rnat.associations.select do |association|
|
||||
ips.any? do |ip|
|
||||
association.name == ip.name
|
||||
end
|
||||
end
|
||||
else
|
||||
rnat.associations.select do |association|
|
||||
ips.each do |ip|
|
||||
if ip.name == association.name
|
||||
associations << association
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
associations
|
||||
end
|
||||
|
||||
def edit(options = {})
|
||||
data = service.virtual_machine_edit(href, options).body
|
||||
if data[:type] == "application/vnd.tmrk.cloud.task"
|
||||
task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
end
|
||||
|
||||
def create_rnat(options)
|
||||
options[:host_ip_href] ||= ips.first.href
|
||||
options[:uri] = "#{service.base_path}/rnats/environments/#{environment_id}/action/createAssociation"
|
||||
data = service.rnat_associations_create_device(options).body
|
||||
rnat = Fog::Compute::Ecloud::Associations.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
|
||||
def disks
|
||||
c = hardware_configuration.reload.storage
|
||||
c = c.is_a?(Hash) ? [c] : c
|
||||
@disks = c
|
||||
end
|
||||
|
||||
def add_disk(size)
|
||||
index = disks.map { |d| d[:Index].to_i }.sort[-1] + 1
|
||||
vm_disks = disks << {:Index => index.to_s, :Size=>{:Unit => "GB", :Value => size.to_s}, :Name => "Hard Disk #{index + 1}"}
|
||||
data = service.virtual_machine_edit_hardware_configuration(href + "/hardwareConfiguration", _configuration_data(:disks => vm_disks)).body
|
||||
task = self.service.tasks.new(data)
|
||||
end
|
||||
|
||||
def detach_disk(index)
|
||||
options = {}
|
||||
options[:disk] = disks.find { |disk_hash| disk_hash[:Index] == index.to_s }
|
||||
options[:name] = self.name
|
||||
options[:description] = self.description
|
||||
data = service.virtual_machine_detach_disk(href + "/hardwareconfiguration/disks/actions/detach", options).body
|
||||
detached_disk = self.service.detached_disks.new(data)
|
||||
end
|
||||
|
||||
def attach_disk(detached_disk)
|
||||
options = {}
|
||||
options[:name] = detached_disk.name
|
||||
options[:href] = detached_disk.href
|
||||
data = service.virtual_machine_attach_disk(href + "/hardwareconfiguration/disks/actions/attach", options).body
|
||||
task = self.service.tasks.new(data)
|
||||
end
|
||||
|
||||
def delete_disk(index)
|
||||
vm_disks = disks.delete_if { |h| h[:Index] == index.to_s }
|
||||
data = service.virtual_machine_edit_hardware_configuration(href + "/hardwareconfiguration", _configuration_data(:disks => vm_disks)).body
|
||||
task = self.service.tasks.new(data)
|
||||
end
|
||||
|
||||
def nics
|
||||
c = hardware_configuration.network_cards
|
||||
c = c.is_a?(Hash) ? [c] : c
|
||||
@nics = c
|
||||
end
|
||||
|
||||
def add_nic(network)
|
||||
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"}}
|
||||
data = service.virtual_machine_edit_hardware_configuration(href + "/hardwareConfiguration", _configuration_data(:nics => vm_nics)).body
|
||||
task = self.service.tasks.new(:href => data[:href])[0]
|
||||
end
|
||||
|
||||
def add_ip(options)
|
||||
slice_ips = begin
|
||||
ips
|
||||
rescue
|
||||
[]
|
||||
end
|
||||
slice_networks = if slice_ips.empty?
|
||||
[]
|
||||
else
|
||||
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
|
||||
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.each do |ip|
|
||||
slice_networks.each do |network|
|
||||
if network[:name] == ip[:network_name]
|
||||
network[:ips] ||= []
|
||||
network[:ips].push(ip[:name])
|
||||
end
|
||||
end
|
||||
end
|
||||
data = service.virtual_machine_edit_assigned_ips(href + "/assignedIps", slice_networks).body
|
||||
task = self.service.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 = service.virtual_machine_edit_assigned_ips(href + "/assignedips", slice_networks).body
|
||||
task = self.service.tasks.new(data)
|
||||
end
|
||||
|
||||
def upload_file(options)
|
||||
service.virtual_machine_upload_file(href + "/guest/action/files", options)
|
||||
true
|
||||
end
|
||||
|
||||
def storage_size
|
||||
vm_disks = disks
|
||||
disks.map! { |d| d[:Size][:Value].to_i }.reduce(0){|sum,item| sum + item} * 1024 * 1024
|
||||
end
|
||||
|
||||
def ready?
|
||||
load_unless_loaded!
|
||||
unless status =~ /NotDeployed|Orphaned|TaskInProgress|CopyInProgress/
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def on?
|
||||
powered_on == true
|
||||
end
|
||||
|
||||
def off?
|
||||
powered_on == false
|
||||
end
|
||||
|
||||
def compute_pool_id
|
||||
other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href].scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
def compute_pool
|
||||
reload if other_links.nil?
|
||||
@compute_pool = self.service.compute_pools.new(:href => other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href])
|
||||
end
|
||||
|
||||
def environment_id
|
||||
other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def _configuration_data(options = {})
|
||||
{:cpus => (options[:cpus] || hardware_configuration.processor_count), :memory => (options[:memory] || hardware_configuration.memory), :disks => (options[:disks] || disks), :nics => (options[:nics] || nics)}
|
||||
end
|
||||
|
||||
def power_operation(op)
|
||||
requires :href
|
||||
begin
|
||||
service.send(op.keys.first, href + "/action/#{op.values.first}" )
|
||||
rescue Excon::Errors::Conflict => e
|
||||
#Frankly we shouldn't get here ...
|
||||
raise e unless e.to_s =~ /because it is already powered o(n|ff)/
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
alias_method :destroy, :delete
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class ServerConfigurationOption < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :disk, :aliases => :Disk
|
||||
attribute :customization, :aliases => :Customization
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/server_configuration_option'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class ServerConfigurationOptions < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::ServerConfigurationOption
|
||||
|
||||
def all
|
||||
data = service.get_server_configuration_options(href).body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_server_configuration_option(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/server'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Servers < Fog::Ecloud::Collection
|
||||
model Fog::Compute::Ecloud::Server
|
||||
|
||||
identity :href
|
||||
|
||||
def all
|
||||
data = service.get_servers(href).body
|
||||
if data.keys.include?(:VirtualMachines)
|
||||
data = data[:VirtualMachines][:VirtualMachine]
|
||||
elsif data[:VirtualMachine]
|
||||
data = data[:VirtualMachine]
|
||||
else
|
||||
data = []
|
||||
end
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
data = service.get_server(uri).body
|
||||
new(data)
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
def from_data(data)
|
||||
new(data)
|
||||
end
|
||||
|
||||
def create( template_uri, options )
|
||||
options[:cpus] ||= 1
|
||||
options[:memory] ||= 512
|
||||
options[:description] ||= ""
|
||||
options[:tags] ||= []
|
||||
|
||||
if template_uri =~ /\/templates\/\d+/
|
||||
options[:uri] = href + "/action/createVirtualMachine"
|
||||
options[:customization] ||= :linux
|
||||
options[:powered_on] ||= false
|
||||
if options[:ips]
|
||||
options[:ips] = [*options[:ips]]
|
||||
else
|
||||
[*options[:network_uri]].each do |uri|
|
||||
index = options[:network_uri].index(uri)
|
||||
ip = self.service.ip_addresses(:href => uri).find { |i| i.host == nil && i.detected_on.nil? }.name
|
||||
options[:ips] ||= []
|
||||
options[:ips][index] = ip
|
||||
end
|
||||
end
|
||||
data = service.virtual_machine_create_from_template( template_uri, options ).body
|
||||
else
|
||||
options[:uri] = href + "/action/importVirtualMachine"
|
||||
data = service.virtual_machine_import( template_uri, options ).body
|
||||
end
|
||||
object = self.service.servers.new(data)
|
||||
object
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class SshKey < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :default, :aliases => :Default, :type => :boolean
|
||||
attribute :finger_print, :aliases => :FingerPrint
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/ssh_key'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class SshKeys < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::SshKey
|
||||
|
||||
def all
|
||||
data = service.get_ssh_keys(href).body[:SshKey]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_ssh_key(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class StorageUsageDetail < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :disk_count, :aliases => :DiskCount
|
||||
attribute :allocated, :aliases => :Allocated
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/storage_usage_detail'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class StorageUsageDetailSummary < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::StorageUsageDetail
|
||||
|
||||
def all
|
||||
data = service.get_storage_usage_detail_summary(href).body[:VirtualMachines][:VirtualMachine]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_storage_usage_detail(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class SupportTicket < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :date, :aliases => :Date
|
||||
attribute :status, :aliases => :Status
|
||||
attribute :category, :aliases => :Category
|
||||
attribute :detected_by, :aliases => :DetectedBy
|
||||
attribute :severity, :aliases => :Severity
|
||||
attribute :device, :aliases => :Device
|
||||
attribute :classification, :aliases => :Classification
|
||||
attribute :owner, :aliases => :Owner
|
||||
attribute :description, :aliases => :Description
|
||||
attribute :information, :aliases => :Information
|
||||
attribute :solution, :aliases => :Solution
|
||||
attribute :history, :aliases => :History
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/support_ticket'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class SupportTickets < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::SupportTicket
|
||||
|
||||
def all
|
||||
data = service.get_support_tickets(href).body[:TicketReference]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_support_ticket(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Tag < Fog::Ecloud::Model
|
||||
identity :name
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/tag'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Tags < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::Tag
|
||||
|
||||
def all
|
||||
data = service.get_tags(href).body[:DeviceTag]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_tag(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Task < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :type , :aliases => :Type
|
||||
attribute :operation, :aliases => :Operation
|
||||
attribute :status, :aliases => :Status
|
||||
attribute :impacted_item, :aliases => :ImpactedItem
|
||||
attribute :start_time, :aliases => :StartTime
|
||||
attribute :completed_time, :aliases => :CompletedTime
|
||||
attribute :notes, :aliases => :Notes
|
||||
attribute :error_message, :aliases => :ErrorMessage
|
||||
attribute :initiated_by, :aliases => :InitiatedBy
|
||||
|
||||
def ready?
|
||||
!self.completed_time.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/task'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Tasks < Fog::Ecloud::Collection
|
||||
model Fog::Compute::Ecloud::Task
|
||||
|
||||
identity :href
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :total_count, :aliases => :TotalCount
|
||||
|
||||
def all
|
||||
data = service.get_tasks(href).body
|
||||
data = data[:Task] ? data[:Task] : data
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_task(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Template < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :operating_system, :aliases => :OperatingSystem
|
||||
attribute :description, :aliases => :Description
|
||||
attribute :storage, :aliases => :Storage
|
||||
attribute :network_adapters, :aliases => :NetworkAdapters
|
||||
attribute :customization, :aliases => :Customization
|
||||
attribute :licensed_software, :aliases => :LicensedSoftware
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/template'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Templates < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::Template
|
||||
|
||||
def all
|
||||
r_data = []
|
||||
data = service.get_templates(href).body[:Families]
|
||||
data[:Family].is_a?(Hash) ? data = [data[:Family]] : data = data[:Family]
|
||||
data.each do |d|
|
||||
cats = d[:Categories][:Category]
|
||||
cats = [cats] if cats.is_a?(Hash)
|
||||
cats.each do |cat|
|
||||
cat[:OperatingSystems][:OperatingSystem].is_a?(Hash) ? cat = [cat[:OperatingSystems][:OperatingSystem]] : cat = cat[:OperatingSystems][:OperatingSystem]
|
||||
cat.each do |os|
|
||||
os[:Templates][:Template].is_a?(Hash) ? os = [os[:Templates][:Template]] : os = os[:Templates][:Template]
|
||||
os.each do |template|
|
||||
r_data << template
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
load(r_data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_template(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class TrustedNetworkGroup < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :hosts, :aliases => :Hosts
|
||||
|
||||
def internet_services
|
||||
@internet_services ||= Fog::Compute::Ecloud::InternetServices.new(:service => service, :href => href)
|
||||
end
|
||||
|
||||
def edit(options)
|
||||
options[:uri] = href
|
||||
data = service.trusted_network_groups_edit(options).body
|
||||
task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
|
||||
def delete
|
||||
data = service.trusted_network_groups_delete(href).body
|
||||
task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0]
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/trusted_network_group'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class TrustedNetworkGroups < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::TrustedNetworkGroup
|
||||
|
||||
def all
|
||||
data = service.get_trusted_network_groups(href).body
|
||||
data = data[:TrustedNetworkGroup] ? data[:TrustedNetworkGroup] : data
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_trusted_network_group(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class User < Fog::Ecloud::Model
|
||||
identity :href
|
||||
|
||||
attribute :name, :aliases => :Name
|
||||
attribute :type, :aliases => :Type
|
||||
attribute :other_links, :aliases => :Links
|
||||
attribute :first_name, :aliases => :FirstName
|
||||
attribute :last_name, :aliases => :LastName
|
||||
attribute :email, :aliases => :Email
|
||||
attribute :status, :aliases => :Status
|
||||
attribute :last_login, :aliases => :LastLogin
|
||||
attribute :multifactor_authentication, :aliases => :MultifactorAuthentication
|
||||
attribute :is_administrator, :aliases => :IsAdministrator, :type => :boolean
|
||||
attribute :is_api_user, :aliases => :IsApiUser, :type => :boolean
|
||||
attribute :is_alert_notification_enabled, :aliases => :IsAlertNotificationEnabled, :type => :boolean
|
||||
attribute :is_multifactor_authentication_enabled, :aliases => :IsMultifactorAuthenticationEnabled, :type => :boolean
|
||||
|
||||
def roles
|
||||
@roles = Fog::Compute::Ecloud::Roles.new(:service => service, :href => "#{service.base_path}/admin/roles/users/#{id}")
|
||||
end
|
||||
|
||||
def api_keys
|
||||
@api_keys = Fog::Compute::Ecloud::ApiKeys.new(:service => service, :href => "#{service.base_path}/admin/apiKeys/users/#{id}")
|
||||
end
|
||||
|
||||
def id
|
||||
href.scan(/\d+/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/ecloud/models/compute/user'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Users < Fog::Ecloud::Collection
|
||||
identity :href
|
||||
|
||||
model Fog::Compute::Ecloud::User
|
||||
|
||||
def all
|
||||
data = service.get_users(href).body[:User]
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_user(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
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.service.networks.new(network_address)
|
||||
network_id = @network.href.match(/(\d+)$/)[1]
|
||||
address_ip = network_address[:IpAddresses][:IpAddress]
|
||||
@address = self.service.ip_addresses.new(
|
||||
:href => "#{service.base_path}/ipaddresses/networks/#{network_id}/#{address_ip}",
|
||||
:name => address_ip
|
||||
)
|
||||
end
|
||||
attr_reader :network
|
||||
|
||||
def address=(address); end
|
||||
attr_reader :address
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
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 = service.get_virtual_machine_assigned_ips(self.identity).body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = service.get_virtual_machine_assigned_ip(self.identity)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Real
|
||||
basic_request :admin_disable_support_access, 204, 'POST'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Ecloud
|
||||
class Real
|
||||
def authentication_levels_edit(data)
|
||||
validate_data([:basic, :sha1, :sha256, :sha512], data)
|
||||
body = build_authentication_levels_edit(data)
|
||||
request(
|
||||
:expects => 202,
|
||||
:method => 'PUT',
|
||||
:headers => {},
|
||||
:body => body,
|
||||
:uri => data[:uri],
|
||||
:parse => true
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_authentication_levels_edit(data)
|
||||
xml = Builder::XmlMarkup.new
|
||||
xml.AuthenticationLevels do
|
||||
xml.BasicEnabled data[:basic]
|
||||
xml.SHA1Enabled data[:sha1]
|
||||
xml.SHA256Enabled data[:sha256]
|
||||
xml.SHA512Enabled data[:sha512]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue