Fix the Greeting message - package is an attribute of version, not QMP.
At this stage, we can connect to a QEMU server and issue commands and queries.
This commit is contained in:
@@ -3,40 +3,34 @@ require 'qmp_client/messages/message'
|
||||
module QMPClient
|
||||
module Messages
|
||||
class Greeting < Message
|
||||
attr_reader :qmp_version
|
||||
attr_reader :qmp_package
|
||||
attr_reader :version
|
||||
attr_reader :capabilities
|
||||
|
||||
def self.represents?(hsh)
|
||||
|
||||
super(hsh) && hsh['QMP'].is_a?(Hash) &&
|
||||
hsh['QMP']['version'].is_a?(Hash) &&
|
||||
hsh['QMP']['package'].is_a?(String) &&
|
||||
hsh['capabilities'].is_a?(Array)
|
||||
hsh['QMP']['capabilities'].is_a?(Array)
|
||||
end
|
||||
|
||||
# build an event from a Hash
|
||||
def self.build(hsh)
|
||||
new(hsh['QMP']['version'], hsh['QMP']['package'], hsh['capabilities'])
|
||||
new(hsh['QMP']['version'], hsh['QMP']['package'], hsh['QMP']['capabilities'])
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
other.is_a?(Greeting) && other.qmp_version == self.qmp_version &&
|
||||
other.qmp_package == self.qmp_package &&
|
||||
other.is_a?(Greeting) && other.version == self.version &&
|
||||
other.capabilities == self.capabilities
|
||||
end
|
||||
|
||||
def initialize(qmp_version, qmp_package, capabilities)
|
||||
@qmp_version = qmp_version
|
||||
@qmp_package = qmp_package
|
||||
def initialize(version, package, capabilities)
|
||||
@version = version
|
||||
@package = package
|
||||
@capabilities = capabilities
|
||||
end
|
||||
|
||||
def to_hash
|
||||
{
|
||||
'QMP' => {'version' => qmp_version, 'package' => qmp_package},
|
||||
'capabilities' => capabilities
|
||||
}
|
||||
{ 'QMP' => { 'version' => version, 'capabilities' => capabilities } }
|
||||
end
|
||||
|
||||
protected
|
||||
|
@@ -12,16 +12,16 @@ module TestQMPClient
|
||||
COMMAND_TXT = COMMAND_HSH.to_json
|
||||
|
||||
GREETING_MSG = Messages::Greeting.new(
|
||||
{'qemu' => {'micro' => 50, 'minor' => 13, 'major' => 0}},
|
||||
{'qemu' => {'micro' => 50, 'minor' => 13, 'major' => 0}, 'package' => ''},
|
||||
"", []
|
||||
)
|
||||
GREETING_HSH = {
|
||||
'QMP' => {
|
||||
'version' => {'qemu' => {'micro' => 50, 'minor' => 13, 'major' => 0}},
|
||||
'package' => "",
|
||||
GREETING_HSH = { 'QMP' => {
|
||||
'version' => {
|
||||
'qemu' => {'micro' => 50, 'minor' => 13, 'major' => 0},
|
||||
'package' => ''
|
||||
},
|
||||
'capabilities' => []
|
||||
}
|
||||
}}
|
||||
GREETING_TXT = GREETING_HSH.to_json
|
||||
|
||||
ETIME = Time.now
|
||||
|
Reference in New Issue
Block a user