class Fog::Compute::Ecloud::Mock
Public Class Methods
data()
click to toggle source
# File lib/fog/compute/ecloud.rb, line 443 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
new(options = {})
click to toggle source
# File lib/fog/compute/ecloud.rb, line 822 def initialize(options = {}) @base_path = "/cloudapi/ecloud" @ecloud_api_key = options[:ecloud] end
reset()
click to toggle source
# File lib/fog/compute/ecloud.rb, line 818 def self.reset @data = nil end
Public Instance Methods
data()
click to toggle source
# File lib/fog/compute/ecloud.rb, line 827 def data self.class.data[@ecloud_api_key] end
deep_copy(o)
click to toggle source
# File lib/fog/compute/ecloud.rb, line 851 def deep_copy(o) Marshal.load(Marshal.dump(o)) end
get_admin_organization(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_admin_organization.rb, line 9 def get_admin_organization(uri) organization_id = id_from_uri(uri) admin_organization = data[:admin_organizations][organization_id] if admin_organization body = Fog::Ecloud.slice(admin_organization, :id, :organization_id) response(:body => body) else body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />" response(:body => body, :expects => 200, :status => 404) end end
get_compute_pool(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_compute_pool.rb, line 9 def get_compute_pool(uri) compute_pool_id = id_from_uri(uri) compute_pool = data[:compute_pools][compute_pool_id] if compute_pool response(:body => Fog::Ecloud.slice(compute_pool, :id, :environment)) else body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />" response(:body => body, :expects => 200, :status => 404) end end
get_compute_pools(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_compute_pools.rb, line 9 def get_compute_pools(uri) # /cloudapi/ecloud/computepools/environments/534 environment_id = id_from_uri(uri) environment = self.data[:environments][environment_id] compute_pools = self.data[:compute_pools].values.select{|cp| cp[:environment_id] == environment_id} compute_pools = compute_pools.map{|cp| Fog::Ecloud.slice(cp, :id, :environment_id)} compute_pool_response = {:ComputePool => (compute_pools.size > 1 ? compute_pools : compute_pools.first)} # GAH body = { :href => uri, :type => "application/vnd.tmrk.cloud.computePool; type=collection", :Links => { :Link => environment, } }.merge(compute_pool_response) response(:body => body) end
get_detached_disk(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_detached_disk.rb, line 9 def get_detached_disk(uri) detached_disk_id = id_from_uri(uri) detached_disk = self.data[:detached_disks][detached_disk_id] if detached_disk response(:body => Fog::Ecloud.slice(detached_disk, :id, :compute_pool_id)) else raise Fog::Errors::NotFound end end
get_detached_disks(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_detached_disks.rb, line 9 def get_detached_disks(uri) compute_pool_id = id_from_uri(uri) compute_pool = self.data[:compute_pools][compute_pool_id] detached_disks = self.data[:detached_disks].values.select{|cp| cp[:compute_pool_id] == compute_pool_id} detached_disks = detached_disks.map{|dd| Fog::Ecloud.slice(dd, :id, :compute_pool_id)} detached_disk_response = {:DetachedDisk => (detached_disks.size > 1 ? detached_disks : detached_disks.first)} # GAH body = { :href => uri, :type => "application/vnd.tmrk.cloud.detachedDisk; type=collection", :Links => { :Link => Fog::Ecloud.keep(compute_pool, :name, :href, :type), } }.merge(detached_disk_response) response(:body => body) end
get_environment(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_environment.rb, line 9 def get_environment(uri) environment_id = id_from_uri(uri) organizations = data[:organizations].values environment = nil catch(:found) do organizations.each do |organization| organization[:Locations][:Location].each do |location| environment = location[:Environments][:Environment].detect { |e| e[:id] == environment_id } throw :found if environment end end end if environment body = environment.dup body.delete(:id) response(:body => body) else body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />" response(:body => body, :expects => 200, :status => 404) end end
get_group(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_group.rb, line 9 def get_group(uri) group_id = id_from_uri(uri) group = self.data[:groups][group_id] response(:body => group) end
get_groups(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_groups.rb, line 9 def get_groups(uri) row_id = id_from_uri(uri) row = self.data[:rows][row_id] response(:body => row) end
get_hardware_configuration(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_hardware_configuration.rb, line 9 def get_hardware_configuration(uri) server_id = uri.match(/(\d+)/)[1] server = self.data[:servers][server_id.to_i] server_hardware_configuration = server[:HardwareConfiguration] new_hardware_configuration = { :href => server_hardware_configuration[:href], :type => server_hardware_configuration[:type], :ProcessorCount => server_hardware_configuration[:ProcessorCount], :Memory => server_hardware_configuration[:Memory], :Disks => server_hardware_configuration[:Disks], :Nics => server_hardware_configuration[:Nics], } response(:body => {:HardwareConfiguration => new_hardware_configuration}) end
get_hardware_configurations(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_hardware_configurations.rb, line 9 def get_hardware_configurations(uri) end
get_internet_service(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_internet_service.rb, line 9 def get_internet_service(uri) internet_service_id = id_from_uri(uri) internet_service = self.data[:internet_services][internet_service_id.to_i] if internet_service response(:body => Fog::Ecloud.slice(internet_service, :id, :public_ip)) else raise Fog::Errors::NotFound end end
get_internet_services(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_internet_services.rb, line 9 def get_internet_services(uri) public_ip_id = id_from_uri(uri) public_ip = self.data[:public_ips][public_ip_id] response(:body => Fog::Ecloud.slice(public_ip, :environment_id)) end
get_ip_address(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_ip_address.rb, line 9 def get_ip_address(uri) network_id, ip_address_id = uri.match(/\/networks\/(\d+)\/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/).captures ip_address = data[:networks][network_id.to_i][:IpAddresses][:IpAddress].detect { |ip| ip[:name] == ip_address_id }.dup if ip_address response(:body => ip_address) else body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />" response(:body => body, :expects => 200, :status => 404) end end
get_layout(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_layout.rb, line 9 def get_layout(uri) environment_id = id_from_uri(uri) layout = self.data[:layouts][environment_id] response(:body => layout) end
get_layouts(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_layouts.rb, line 9 def get_layouts(uri) environment_id = id_from_uri(uri) layout = self.data[:layouts][environment_id] response(:body => layout) end
get_network(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_network.rb, line 9 def get_network(uri) network_id = id_from_uri(uri) network = data[:networks][network_id].dup if network response(:body => Fog::Ecloud.slice(network, :id, :environment_id)) else body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />" response(:body => body, :expects => 200, :status => 404) end end
get_networks(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_networks.rb, line 9 def get_networks(uri) environment_id = id_from_uri(uri) environment = self.data[:environments][environment_id] networks = self.data[:networks].values.select{|n| n[:environment_id] == environment_id}.dup networks = networks.map{|n| Fog::Ecloud.slice(n, :environment, :id)} body = { :href => uri, :type => "application/vnd.tmrk.cloud.network; type=collection", :Links => { :Link => Fog::Ecloud.keep(environment, :name, :href, :type) }, :Network => (networks.size > 1 ? networks : networks.first), } response(:body => body) end
get_node(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_node.rb, line 9 def get_node(uri) node_service_id = id_from_uri(uri) node_service = self.data[:node_services][node_service_id.to_i] if node_service response(:body => Fog::Ecloud.slice(node_service, :id, :internet_service_id)) else raise Fog::Errors::NotFound end end
get_nodes(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_nodes.rb, line 9 def get_nodes(uri) internet_service_id = id_from_uri(uri) internet_service = self.data[:internet_services][internet_service_id] response(:body => internet_service) end
get_operating_system(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_operating_system.rb, line 9 def get_operating_system(uri) os_name, compute_pool_id = uri.match(/operatingsystems\/(.*)\/computepools\/(\d+)$/).captures compute_pool_id = compute_pool_id.to_i operating_systems = data[:operating_systems].values.select { |os| os[:compute_pool_id] == compute_pool_id } operating_system = operating_systems.detect { |os| os[:short_name] == os_name } if operating_system response(:body => Fog::Ecloud.slice(operating_system, :id, :compute_pool_id, :short_name)) else body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />" response(:body => body, :expects => 200, :status => 404) end end
get_operating_system_families(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_operating_system_families.rb, line 9 def get_operating_system_families(uri) compute_pool_id = id_from_uri(uri) compute_pool = self.data[:compute_pools][compute_pool_id] operating_system_families = self.data[:operating_system_families].values.select{|osf| osf[:compute_pool_id] == compute_pool_id} operating_system_families = operating_system_families.map{|osf| Fog::Ecloud.slice(osf, :id, :compute_pool_id)}.map{|osf| osf[:OperatingSystemFamily]} operating_system_family_response = {:OperatingSystemFamily => (operating_system_families.size > 1 ? operating_system_families : operating_system_families.first)} # GAH body = { :href => uri, :type => "application/vnd.tmrk.cloud.operatingSystemFamily; type=collection", :Links => { :Link => compute_pool, } }.merge(operating_system_family_response) response(:body => body) end
get_organization(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_organization.rb, line 9 def get_organization(uri) organization_id = id_from_uri(uri) organization = self.data[:organizations][organization_id] body = { :xmlns_i => "http://www.w3.org/2001/XMLSchema-instance", :href => "/cloudapi/ecloud/organizations/", :type => "application/vnd.tmrk.cloud.organization; type=collection" }.merge(organization) response(:body => body) end
get_organizations(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_organizations.rb, line 9 def get_organizations(uri) organizations = self.data[:organizations].values.dup organizations.each{|org| org.delete(:id)} body = { :xmlns_i => "http://www.w3.org/2001/XMLSchema-instance", :href => "/cloudapi/ecloud/organizations/", :type => "application/vnd.tmrk.cloud.organization; type=collection" }.merge(:Organization => (organizations.size > 1 ? organizations : organizations.first)) response(:body => body) end
get_public_ip(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_public_ip.rb, line 9 def get_public_ip(uri) public_ip_id = id_from_uri(uri) public_ip = self.data[:public_ips][public_ip_id] if public_ip response(:body => Fog::Ecloud.slice(public_ip, :id, :environment_id)) else raise Fog::Errors::NotFound end end
get_public_ips(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_public_ips.rb, line 9 def get_public_ips(uri) environment_id = id_from_uri(uri) environment = self.data[:environments][environment_id] public_ips = self.data[:public_ips].values.select{|cp| cp[:environment_id] == environment_id} public_ips = public_ips.map{|pi| Fog::Ecloud.slice(pi, :id, :environment_id)} public_ip_response = {:PublicIp => (public_ips.size > 1 ? public_ips : public_ips.first)} # GAH body = { :href => uri, :type => "application/vnd.tmrk.cloud.publicIp; type=collection", :Links => { :Link => environment, } }.merge(public_ip_response) response(:body => body) end
get_row(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_row.rb, line 9 def get_row(uri) row_id = id_from_uri(uri) row = self.data[:rows][row_id] response(:body => row) end
get_server(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_server.rb, line 9 def get_server(uri) server_id = uri.match(/(\d+)/) server_id = server_id.nil? ? nil : server_id[1].to_i server = self.data[:servers][server_id] if server response(:body => Fog::Ecloud.slice(server, :id, :compute_pool_id)) else raise Fog::Errors::NotFound end end
get_servers(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_servers.rb, line 8 def get_servers(uri) if uri =~ /layoutgroups/i group_id = id_from_uri(uri) group = self.data[:groups][group_id] servers = group[:VirtualMachines][:VirtualMachine] compute_pool_id = servers.first[:compute_pool_id] unless servers.empty? compute_pool = self.data[:compute_pools][compute_pool_id] unless compute_pool_id.nil? elsif uri =~ /computepool/i compute_pool_id = id_from_uri(uri) compute_pool = self.data[:compute_pools][compute_pool_id] servers = self.data[:servers].values.select{|cp| cp[:compute_pool_id] == compute_pool_id} servers = servers.map{|server| Fog::Ecloud.slice(server, :id, :compute_pool_id)} end links = if compute_pool.nil? [] else [Fog::Ecloud.keep(compute_pool, :name, :href, :type),] end server_response = {:VirtualMachine => (servers.size > 1 ? servers : servers.first)} # GAH body = { :href => uri, :type => "application/vnd.tmrk.cloud.virtualMachine; type=collection", :Links => { :Link => links } }.merge(server_response) response(:body => body) end
get_ssh_key(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_ssh_key.rb, line 9 def get_ssh_key(uri) ssh_key_id = id_from_uri(uri).to_i ssh_key = self.data[:ssh_keys][ssh_key_id.to_i] if ssh_key response(:body => Fog::Ecloud.slice(ssh_key, :id, :admin_organization)) else body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />" response(:body => body, :expects => 200, :status => 404) end end
get_ssh_keys(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_ssh_keys.rb, line 9 def get_ssh_keys(uri) organization_id = id_from_uri(uri) organization = self.data[:organizations][organization_id] ssh_keys = self.data[:ssh_keys].values.select{|key| key[:admin_organization_id] == organization_id} ssh_keys = ssh_keys.map{|key| Fog::Ecloud.slice(key, :id, :admin_organization)} ssh_key_response = {:SshKey => (ssh_keys.size > 1 ? ssh_keys : ssh_keys.first)} # GAH body = { :href => "/cloudapi/ecloud/admin/organizations/#{organization_id}/sshKeys", :type => "application/vnd.tmrk.cloud.sshKey; type=collection", :Links => { :Link => organization, }, }.merge(ssh_key_response) response(:body => body) end
get_task(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_task.rb, line 8 def get_task(uri) end
get_template(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_template.rb, line 9 def get_template(uri) template_id, _compute_pool_id = uri.match(/(\d+).*\/(\d+)$/).captures template = data[:templates][template_id.to_i] if template response(:body => Fog::Ecloud.slice(template, :id, :environment)) else body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />" response(:body => body, :expects => 200, :status => 404) end end
get_templates(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_templates.rb, line 9 def get_templates(uri) # /cloudapi/ecloud/computepools/compute_pools/534 compute_pool_id = id_from_uri(uri) compute_pool = self.data[:compute_pools][compute_pool_id] templates = self.data[:templates].values.select{|template| template[:compute_pool_id] == compute_pool_id} templates = templates.map{|template| Fog::Ecloud.slice(template, :id, :compute_pool)} template_response = {:Template => (templates.size > 1 ? templates : templates.first)} # GAH body = { :href => uri, :type => "application/vnd.tmrk.cloud.template; type=collection", :Links => { :Link => compute_pool, }, :Families => { :Family => { :Name => "Standard Templates", :Categories => { :Category => [ { :Name => "OS Only", :OperatingSystems => { :OperatingSystem => { :Name => "Linux", :Templates => template_response, } } } ] } } } } response(:body => body) end
get_virtual_machine_assigned_ips(virtual_machine_id)
click to toggle source
# File lib/fog/compute/ecloud/requests/get_virtual_machine_assigned_ips.rb, line 14 def get_virtual_machine_assigned_ips(virtual_machine_id) server = self.data[:servers][virtual_machine_id.to_i] compute_pool = self.data[:compute_pools][server[:compute_pool_id]] environment_id = compute_pool[:environment_id] environment = self.data[:environments][environment_id] networks = self.data[:networks].values.select{|n| n[:environment_id] == environment_id} networks = networks.map{|n| deep_copy(Fog::Ecloud.slice(n, :environment, :id))} networks.each do |network| address = network[:IpAddresses][:IpAddress].map{|ia| ia[:name]} network[:IpAddresses][:IpAddress] = address.first end body = { :href => "/cloudapi/ecloud/virtualMachines/#{virtual_machine_id}/assignedIps", :type => "application/vnd.tmrk.cloud.network", :Links => { :Link => Fog::Ecloud.keep(environment, :name, :href, :type) }, :Networks => {:Network => (networks.size > 1 ? networks : networks.first)}, } response(:body => body) end
groups_delete(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/groups_delete.rb, line 9 def groups_delete(uri) group_id = id_from_uri(uri) self.data[:groups].delete(group_id) self.data[:rows].values.each do |row| row[:Groups][:Group].delete_if { |g| g[:id] == group_id } end self.data[:layouts].values.each do |layout| layout[:Rows][:Row].each do |row| row[:Groups][:Group].delete_if { |g| g[:id] == group_id } end end response(:body => nil, :status => 204) end
internet_service_create(service_data)
click to toggle source
# File lib/fog/compute/ecloud/requests/internet_service_create.rb, line 67 def internet_service_create(service_data) validate_internet_service_data(service_data) public_ip_id = service_data[:uri].match(/(\d+)/)[1] public_ip = self.data[:public_ips][public_ip_id.to_i].dup service_id = Fog::Mock.random_numbers(6).to_i service = { :href => "/cloudapi/ecloud/internetServices/#{service_id}", :name => service_data[:name], :type => "application/vnd.tmrk.cloud.internetService", :Links => { :Link => [ Fog::Ecloud.keep(public_ip, :href, :name, :type), ], }, :Protocol => service_data[:protocol], :Port => service_data[:port], :Enabled => service_data[:enabled], :Description => service_data[:description], :PublicIp => Fog::Ecloud.keep(public_ip, :href, :name, :type), :Persistence => { :Type => service_data[:persistence][:type], }, } internet_service_response = response(:body => service) service.merge!(:public_ip => public_ip) self.data[:internet_services][service_id] = service internet_service_response end
internet_service_delete(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/internet_service_delete.rb, line 9 def internet_service_delete(uri) service_id = id_from_uri(uri) service = self.data[:internet_services][service_id].dup self.data[:internet_services].delete(service_id) task_id = Fog::Mock.random_numbers(10).to_i task = { :id => task_id, :href => "/cloudapi/ecloud/tasks/#{task_id}", :type => "application/vnd.tmrk.cloud.task", :Operation => "Delete Service", :Status => "Complete", :ImpactedItem => Fog::Ecloud.keep(service, :name, :href, :type), :StartTime => Time.now.iso8601, :CompletedTime => Time.now.iso8601, :InitiatedBy => {}, } self.data[:tasks][task_id] = task response(:body => task) end
node_service_create(service_data)
click to toggle source
# File lib/fog/compute/ecloud/requests/node_service_create.rb, line 45 def node_service_create(service_data) validate_node_service_data(service_data) internet_service_id = service_data[:uri].match(/(\d+)/)[1] internet_service = self.data[:internet_services][internet_service_id.to_i].dup network_id, ip_address_name = service_data[:ip_address].match(/\/(\d+)\/(.*)$/).captures network = self.data[:networks][network_id.to_i] ip_addresses = network[:IpAddresses][:IpAddress] ip_addresses = ip_addresses.is_a?(Array) ? ip_addresses : [ip_addresses] ip_address = ip_addresses.find { |ip| ip[:name] == ip_address_name } service_id = Fog::Mock.random_numbers(6).to_i service = { :href => "/cloudapi/ecloud/nodeservices/#{service_id}", :name => service_data[:name], :type => "application/vnd.tmrk.cloud.nodeService", :Links => { :Link => [ Fog::Ecloud.keep(internet_service, :href, :name, :type), ], }, :Protocol => service_data[:protocol], :Port => service_data[:port], :Enabled => service_data[:enabled], :Description => service_data[:description], :IpAddress => { :href => ip_address[:href], :name => ip_address[:name], :type => ip_address[:type], :Network => { :href => network[:href], :name => network[:name], :type => network[:type], }, }, } node_service_response = response(:body => service) service.merge!(:internet_service => internet_service) self.data[:node_services][service_id] = service node_service_response end
node_service_delete(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/node_service_delete.rb, line 9 def node_service_delete(uri) service_id = id_from_uri(uri) service = self.data[:node_services][service_id].dup self.data[:node_services].delete(service_id) task_id = Fog::Mock.random_numbers(10).to_i task = { :id => task_id, :href => "/cloudapi/ecloud/tasks/#{task_id}", :type => "application/vnd.tmrk.cloud.task", :Operation => "Delete Node Service", :Status => "Complete", :ImpactedItem => Fog::Ecloud.keep(service, :name, :href, :type), :StartTime => Time.now.iso8601, :CompletedTime => Time.now.iso8601, :InitiatedBy => {}, } self.data[:tasks][task_id] = task response(:body => task) end
reset_data()
click to toggle source
# File lib/fog/compute/ecloud.rb, line 831 def reset_data self.class.data.delete(@ecloud_api_key) end
response(params = {})
click to toggle source
# File lib/fog/compute/ecloud.rb, line 835 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) e = Excon::Errors::NotFound.new("Expected([200]) <=> Actual(404 Not Found)", "404", response) raise ServiceError.slurp(e) else response end end
rows_delete(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/rows_delete.rb, line 9 def rows_delete(uri) row_id = id_from_uri(uri) self.data[:rows].delete(row_id) self.data[:layouts].values.each do |layout| layout[:Rows][:Row].delete_if { |r| r[:id] == row_id } end response(:body => nil, :status => 204) end
ssh_key_create(data)
click to toggle source
# File lib/fog/compute/ecloud/requests/ssh_key_create.rb, line 33 def ssh_key_create(data) validate_data([:Name], data) ssh_key_id = Fog::Mock.random_numbers(7).to_i ssh_key_fingerprint = "" (1..15).each do ssh_key_fingerprint = ssh_key_fingerprint + Fog::Mock.random_hex(2) + ":" end ssh_key_fingerprint = ssh_key_fingerprint + Fog::Mock.random_hex(2) ssh_private_key = Fog::Mock.random_base64(512) org_id = self.data[:organization_id] org_name = self.data[:organization_name] ssh_key = { :href => "/cloudapi/ecloud/admin/sshKeys/#{ssh_key_id}", :Name => data[:Name], :type => "application/vnd.tmrk.cloud.admin.sshKey", :Links => { :Link => { :href => "/cloudapi/ecloud/admin/organizations/#{org_id}", :name => org_name, :type => "application/vnd.tmrk.cloud.admin.organization", :rel => "up", }, :Link => { :href => "/cloudapi/ecloud/organizations/#{org_id}", :name => org_name, :type => "application/vnd.tmrk.cloud.organization", :rel => "up", }, }, :Default => data[:Default] || false, :FingerPrint => ssh_key_fingerprint, :PrivateKey => ssh_private_key, } ssh_key_response = response(:body => ssh_key) self.data[:ssh_keys][ssh_key_id] = ssh_key ssh_key_response.body end
ssh_key_delete(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/ssh_key_delete.rb, line 9 def ssh_key_delete(uri) ssh_key_id = id_from_uri(uri) data[:ssh_keys].delete(ssh_key_id) response(:body => nil, :status => 204) end
ssh_key_edit(options)
click to toggle source
# File lib/fog/compute/ecloud/requests/ssh_key_edit.rb, line 29 def ssh_key_edit(options) ssh_key_id = id_from_uri(options[:uri]).to_i if data[:ssh_keys][ssh_key_id] data[:ssh_keys][ssh_key_id][:Name] = options[:Name] data[:ssh_keys][ssh_key_id][:Default] = options[:Default] ssh_key = data[:ssh_keys][ssh_key_id] response(:body => Fog::Ecloud.slice(ssh_key, :id, :admin_organization)).body else body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />" response(:body => body, :expects => 200, :status => 404) end end
virtual_machine_attach_disk(href, options)
click to toggle source
# File lib/fog/compute/ecloud/requests/virtual_machine_attach_disk.rb, line 30 def virtual_machine_attach_disk(href, options) server_id = href.match(/(\d+)/)[1].to_i server = self.data[:servers][server_id] compute_pool_id = server[:compute_pool_id] compute_pool = self.data[:compute_pools][compute_pool_id] detached_disk_id = options[:href].match(/(\d+)/)[1].to_i detached_disk = self.data[:detached_disks][detached_disk_id] new_index = (server[:HardwareConfiguration][:Disks][:Disk].map { |h| h[:Index].to_i }.sort.last + 1).to_s detached_disk[:Index] = new_index server[:HardwareConfiguration][:Disks][:Disk] << Fog::Ecloud.keep(detached_disk, :Index, :Size, :Name) self.data[:detached_disks].delete(detached_disk_id) task_id = Fog::Mock.random_numbers(10).to_i task = { :id => task_id, :href => "/cloudapi/ecloud/tasks/#{task_id}", :type => "application/vnd.tmrk.cloud.task", :Operation => "Attach Disk", :Status => "Complete", :ImpactedItem => Fog::Ecloud.keep(server, :href, :type), :StartTime => Time.now.iso8601, :CompletedTime => Time.now.iso8601, :InitiatedBy => {}, } self.data[:tasks][task_id] = task response(:body => task) end
virtual_machine_create_from_template(template_uri, options)
click to toggle source
# File lib/fog/compute/ecloud/requests/virtual_machine_create_from_template.rb, line 116 def virtual_machine_create_from_template(template_uri, options) options = validate_create_server_options(template_uri, options) server_id = Fog::Mock.random_numbers(7).to_i row_id = Fog::Mock.random_numbers(6).to_i group_id = Fog::Mock.random_numbers(6).to_i template_id, compute_pool_id = template_uri.match(/\/templates\/(\d+)\/computepools\/(\d+)$/).captures compute_pool = self.data[:compute_pools][compute_pool_id.to_i].dup environment = self.data[:environments][compute_pool[:environment_id]] layout = self.data[:layouts][environment[:id]] networks = options[:network_uri] nics = networks.each_with_index.map do |network, i| { :UnitNumber => i.to_s, :Name => "Network adapter #{i}", :MacAddress => Fog::Ecloud.mac_address, :Network => Fog::Ecloud.keep(network, :name, :href, :type), } end links = [Fog::Ecloud.keep(compute_pool, :name, :href, :type), Fog::Ecloud.keep(environment, :name, :href, :type)] networks.each do |network| links << Fog::Ecloud.keep(network, :name, :href, :type) network_id = id_from_uri(network[:href]) ip = self.data[:networks][network_id][:IpAddresses][:IpAddress].find { |ip| ip[:id] = network[:ip] } ip[:DetectedOn] = {:href => "/cloudapi/ecloud/networkhosts/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.networkHost"} ip[:Host] = {:href => "/cloudapi/ecloud/networkhosts/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.networkHost"} end server = { :href => "/cloudapi/ecloud/virtualmachines/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.virtualMachine", :Description => options[:description], :Status => "Deployed", :HardwareConfiguration => { :href => "/cloudapi/ecloud/virtualmachines/#{server_id}/hardwareconfiguration", :type => "application/vnd.tmrk.cloud.virtualMachineHardware", :Links => { :Link => { :href => "/cloudapi/ecloud/virtualmachines/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.virtualMachine", :rel => "up", } }, :ProcessorCount => options[:cpus], :Memory => { :Unit => "MB", :Value => options[:memory], }, :Disks => { :Disk => [{ :Index => "0", :Name => "Hard Disk 1", :Size => { :Unit => "GB", :Value => "25", }, }], }, :Nics => { :Nic => nics, }, }, :IpAddresses => { :AssignedIpAddresses => { :Networks => { :Network => self.data[:networks].dup.values, } } }, :Links => { :Link => links }, } row = { :id => row_id, :name => options[:row], :href => "/cloudapi/ecloud/layoutrows/#{row_id}", :type => "application/vnd.tmrk.cloud.layoutRow", :Links => { :Link => [ Fog::Ecloud.keep(environment, :name, :href, :type) ], }, :Index => 0, :Groups => { :Group => [ ], }, :environment_id => environment[:id], } group = { :id => group_id, :name => options[:group], :href => "/cloudapi/ecloud/layoutgroups/#{group_id}", :type => "application/vnd.tmrk.cloud.layoutGroup", :Links => { :Link => [ Fog::Ecloud.keep(row, :name, :href, :type), ], }, :Index => 0, :VirtualMachines => { :VirtualMachine => [ server, ], }, :row_id => row_id, } row[:Groups][:Group].push(group) layout[:Rows][:Row].push(row) server.merge!(:OperatingSystem => options[:operating_system].merge(:type => "application/vnd.tmrk.cloud.operatingSystem")) if options[:operating_system] server_response = response(:body => server) server.merge!(:compute_pool_id => compute_pool[:id]) self.data[:servers][server_id] = server self.data[:rows][row_id] = row self.data[:groups][group_id] = group server_response end
virtual_machine_delete(uri)
click to toggle source
# File lib/fog/compute/ecloud/requests/virtual_machine_delete.rb, line 9 def virtual_machine_delete(uri) server_id = id_from_uri(uri) server = self.data[:servers][server_id] self.data[:servers].delete(server_id) self.data[:groups].values.each do |group| group[:VirtualMachines][:VirtualMachine].delete_if { |s| s[:name] == server[:name] } end self.data[:networks].values.each do |network| network[:IpAddresses][:IpAddress].each do |ip| unless ip[:Host].nil? ip[:Host] = nil if ip[:Host][:name] == server[:name] end unless ip[:DetectedOn].nil? ip[:DetectedOn] = nil if ip[:DetectedOn][:name] == server[:name] end end end task_id = Fog::Mock.random_numbers(10) task = { :id => task_id, :href => "/cloudapi/ecloud/tasks/#{task_id}", :type => "application/vnd.tmrk.cloud.task", :Operation => "Delete Server", :Status => "Complete", :ImpactedItem => Fog::Ecloud.keep(server, :name, :href, :type), :StartTime => Time.now.iso8601, :CompletedTime => Time.now.iso8601, :InitiatedBy => {}, } self.data[:tasks][task_id] = task response(:body => task) end
virtual_machine_detach_disk(href, options)
click to toggle source
# File lib/fog/compute/ecloud/requests/virtual_machine_detach_disk.rb, line 31 def virtual_machine_detach_disk(href, options) server_id = href.match(/(\d+)/)[1].to_i server = self.data[:servers][server_id] compute_pool_id = server[:compute_pool_id] compute_pool = self.data[:compute_pools][compute_pool_id] detached_disk_id = Fog::Mock.random_numbers(6).to_i detached_disk = { :id => detached_disk_id, :href => "/cloudapi/ecloud/detacheddisks/#{detached_disk_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.detachedDisk", :Links => { :Link => [ Fog::Ecloud.keep(compute_pool, :href, :name, :type), ], }, :Description => options[:description], :LastKnownVirtualMachineConfiguration => Fog::Ecloud.keep(server, :name, :ProcessorCount, :Memory, :OperatingSystem), :Type => "Data", :Size => { :Unit => "GB", :Value => options[:disk][:Size][:Value], }, :Status => "Available", } server[:HardwareConfiguration][:Disks][:Disk].delete_if { |disk| disk[:Index] == options[:disk][:Index] } detached_disk_response = response(:body => detached_disk) detached_disk.merge!(:compute_pool_id => compute_pool_id) self.data[:detached_disks][detached_disk_id] = detached_disk detached_disk_response end
virtual_machine_edit_assigned_ips(href, options)
click to toggle source
# File lib/fog/compute/ecloud/requests/virtual_machine_edit_assigned_ips.rb, line 38 def virtual_machine_edit_assigned_ips(href, options) server_id = href.match(/(\d+)/)[1].to_i server = self.data[:servers][server_id] options.each do |network| network_id = id_from_uri(network[:href]) network = self.data[:networks][network_id] options.each.each do |net| net[:ips].each do |ip| ip = network[:IpAddresses][:IpAddress].find { |iph| iph[:name] == ip } ip[:Host] = { :href => "/clouapi/ecloud/networkhosts/#{server_id}", :name => server[:name], :type => "application/vnd.tmrk.cloud.networkHost" } ip[:DetectedOn] = { :href => "/clouapi/ecloud/networkhosts/#{server_id}", :name => server[:name], :type => "application/vnd.tmrk.cloud.networkHost" } end end end task_id = Fog::Mock.random_numbers(10) task = { :id => task_id, :href => "/cloudapi/ecloud/tasks/#{task_id}", :type => "application/vnd.tmrk.cloud.task", :Operation => "Delete Server", :Status => "Complete", :ImpactedItem => Fog::Ecloud.keep(server, :name, :href, :type), :StartTime => Time.now.iso8601, :CompletedTime => Time.now.iso8601, :InitiatedBy => {}, } self.data[:tasks][task_id] = task response(:body => task) end
virtual_machine_edit_hardware_configuration(vm_uri, data)
click to toggle source
# File lib/fog/compute/ecloud/requests/virtual_machine_edit_hardware_configuration.rb, line 52 def virtual_machine_edit_hardware_configuration(vm_uri, data) server_id = vm_uri.match(/(\d+)/)[1] server = self.data[:servers][server_id.to_i] task_id = Fog::Mock.random_numbers(10) task = { :id => task_id, :href => "/cloudapi/ecloud/tasks/#{task_id}", :type => "application/vnd.tmrk.cloud.task", :Operation => "Configure Server", :Status => "Complete", :ImpactedItem => Fog::Ecloud.keep(server, :name, :href, :type), :StartTime => Time.now.iso8601, :CompletedTime => Time.now.iso8601, :InitiatedBy => {}, } self.data[:tasks][task_id] = task response(:body => task) end
virtual_machine_import(template_uri, options)
click to toggle source
# File lib/fog/compute/ecloud/requests/virtual_machine_import.rb, line 64 def virtual_machine_import(template_uri, options) options = validate_import_server_options(template_uri, options) compute_pool_id = options[:uri].match(/computePools\/(\d+)/)[1].to_i compute_pool = self.data[:compute_pools][compute_pool_id].dup environment = self.data[:environments][compute_pool[:environment_id]] networks = options[:network_uri].map{|nuri| self.data[:networks][id_from_uri(nuri)].dup} server_id = Fog::Mock.random_numbers(6).to_i row_id = Fog::Mock.random_numbers(6).to_i group_id = Fog::Mock.random_numbers(6).to_i nics = networks.each_with_index.map do |network, i| { :UnitNumber => i.to_s, :Name => "Network adapter #{i}", :MacAddress => Fog::Ecloud.mac_address, :Network => Fog::Ecloud.keep(network, :name, :href, :type) } end links = [Fog::Ecloud.keep(compute_pool, :name, :href, :type), Fog::Ecloud.keep(environment, :name, :href, :type)] networks.each{|network| links << Fog::Ecloud.keep(network, :name, :href, :type)} server = { :href => "/cloudapi/ecloud/virtualmachines/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.virtualMachine", :Description => options[:description], :Status => "Deployed", :PoweredOn => "false", :HardwareConfiguration => { :href => "/cloudapi/ecloud/virtualmachines/#{server_id}/hardwareconfiguration", :type => "application/vnd.tmrk.cloud.virtualMachineHardware", :Links => { :Link => { :href => "/cloudapi/ecloud/virtualmachines/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.virtualMachine", :rel => "up" } }, :ProcessorCount => options[:cpus], :Memory => { :Unit => "MB", :Value => options[:memory], }, :Disks => { # Default drive :Disk => [{ :Index => "0", :Name => "Hard Disk 1", :Size => { :Unit => "GB", :Value => "25" }, }], }, :Nics => { :Nic => nics, }, }, :Links => { :Link => links }, } row = { :id => row_id, :name => options[:row], :href => "/cloudapi/ecloud/layoutrows/#{row_id}", :type => "application/vnd.tmrk.cloud.layoutRow", :Links => { :Link => [ Fog::Ecloud.keep(environment, :name, :href, :type) ], }, :Index => 0, :Groups => { :Group => [ ], }, :environment_id => environment[:id], } group = { :id => group_id, :name => options[:group], :href => "/cloudapi/ecloud/layoutgroups/#{group_id}", :type => "application/vnd.tmrk.cloud.layoutGroup", :Links => { :Link => [ Fog::Ecloud.keep(row, :name, :href, :type), ], }, :Index => 0, :VirtualMachines => { :VirtualMachine => [ server, ], }, :row_id => row_id, } row[:Groups][:Group].push(group) layout[:Rows][:Row].push(row) server.merge!(:OperatingSystem => options[:operating_system].merge(:type => "application/vnd.tmrk.cloud.operatingSystem")) if options[:operating_system] server_response = response(:body => server) server.merge!(:compute_pool_id => compute_pool_id) self.data[:servers][server_id] = server self.data[:rows][row_id] = row self.data[:groups][group_id] = group server_response end