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