PageRenderTime 23ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/fog/rackspace/requests/compute_v2/get_server.rb

https://gitlab.com/debian-ruby/ruby-fog-rackspace
Ruby | 63 lines | 27 code | 1 blank | 35 comment | 1 complexity | dffe45a4ca7a54bb91014c5035ec99df MD5 | raw file
  1. module Fog
  2. module Compute
  3. class RackspaceV2
  4. class Real
  5. # Retrieves server detail
  6. # @param [String] server_id
  7. # @return [Excon::Response] response:
  8. # * body [Hash]:
  9. # * server [Hash]:
  10. # * OS-DCF:diskConfig [String] - The disk configuration value.
  11. # * OS-EXT-STS:power_state [Fixnum] - The power state.
  12. # * OS-EXT-STS:task_state [String] - The task state.
  13. # * OS-EXT-STS:vm_state [String] - The VM state.
  14. # * accessIPv4 [String] - The public IP version 4 access address.
  15. # * accessIPv6 [String] - The public IP version 6 access address.
  16. # * addresses [Hash] - Public and private IP addresses, The version field indicates whether the IP address is version 4 or 6.
  17. # * created [String] - created timestamp
  18. # * hostId [String] - The host id.
  19. # * id [String] - id of image
  20. # * image [Hash]:
  21. # * id [String] - id of the image
  22. # * links [Hash] - links to image
  23. # * flavor [Hash]:
  24. # * id [String] - id of the flavor
  25. # * links [Hash] - links to flavor
  26. # * links [Hash] - links to server
  27. # * metadata [Hash] - server metadata
  28. # * name [String] - name of server
  29. # * progress [Fixnum] - progress complete. Value is from 0 to 100.
  30. # * rax-bandwidth:bandwidth [Array] - The amount of bandwidth used for the specified audit period.
  31. # * status [String] - The server status.
  32. # * tenant_id [String] - The tenant ID.
  33. # * updated [String] - updated timestamp
  34. # * user_id [Array] - The user ID.
  35. # @raise [Fog::Compute::RackspaceV2::NotFound] - HTTP 404
  36. # @raise [Fog::Compute::RackspaceV2::BadRequest] - HTTP 400
  37. # @raise [Fog::Compute::RackspaceV2::InternalServerError] - HTTP 500
  38. # @raise [Fog::Compute::RackspaceV2::ServiceError]
  39. # @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/Get_Server_Details-d1e2623.html
  40. def get_server(server_id)
  41. request(
  42. :expects => [200, 203, 300],
  43. :method => 'GET',
  44. :path => "servers/#{server_id}"
  45. )
  46. end
  47. end
  48. class Mock
  49. def get_server(server_id)
  50. server = self.data[:servers][server_id]
  51. if server.nil?
  52. raise Fog::Compute::RackspaceV2::NotFound
  53. else
  54. server_response = Fog::Rackspace::MockData.keep(server, 'id', 'name', 'hostId', 'created', 'updated', 'status', 'progress', 'user_id', 'tenant_id', 'links', 'metadata', 'accessIPv4', 'accessIPv6', 'OS-DCF:diskConfig', 'rax-bandwidth:bandwidth', 'addresses', 'flavor', 'image')
  55. server_response['image']['links'].map! { |l| l.delete("type"); l }
  56. response(:body => {"server" => server_response})
  57. end
  58. end
  59. end
  60. end
  61. end
  62. end