2012-04-02 07:25:03 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
|
|
|
module XenServer
|
|
|
|
class Base
|
|
|
|
|
|
|
|
attr_reader :response
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
reset
|
|
|
|
end
|
|
|
|
|
|
|
|
def reset
|
|
|
|
@response = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
def parse( data )
|
2012-04-04 13:48:21 -04:00
|
|
|
if data.kind_of? Hash
|
2012-04-02 07:25:03 -04:00
|
|
|
@response = data.symbolize_keys!
|
2012-04-04 03:01:55 -04:00
|
|
|
@response.each do |k,v|
|
|
|
|
if @response[k] == "OpaqueRef:NULL"
|
|
|
|
@response[k] = nil
|
|
|
|
end
|
|
|
|
end
|
2012-04-04 13:48:21 -04:00
|
|
|
elsif data.kind_of? Array
|
2012-04-02 07:25:03 -04:00
|
|
|
@response = data.first
|
2012-04-04 13:48:21 -04:00
|
|
|
elsif data.kind_of?(String) and data =~ /OpaqueRef:/
|
|
|
|
@response = data
|
2012-04-02 07:25:03 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
@response
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-04-04 03:01:55 -04:00
|
|
|
end
|