2012-04-02 07:25:03 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
|
|
|
module XenServer
|
|
|
|
class Base
|
|
|
|
attr_reader :response
|
2014-02-19 07:30:59 -05:00
|
|
|
|
2012-04-02 07:25:03 -04:00
|
|
|
def initialize
|
|
|
|
reset
|
|
|
|
end
|
2014-02-19 07:30:59 -05:00
|
|
|
|
2012-04-02 07:25:03 -04:00
|
|
|
def reset
|
|
|
|
@response = {}
|
|
|
|
end
|
2014-02-19 07:30:59 -05:00
|
|
|
|
2012-04-02 07:25:03 -04:00
|
|
|
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
|
2014-02-19 07:30:59 -05:00
|
|
|
|
2012-04-02 07:25:03 -04:00
|
|
|
@response
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-04-04 03:01:55 -04:00
|
|
|
end
|