2 # Migration test output result reporting
4 # Copyright (c) 2016 Red Hat, Inc.
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2 of the License, or (at your option) any later version.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, see <http://www.gnu.org/licenses/>.
22 from guestperf
.hardware
import Hardware
23 from guestperf
.scenario
import Scenario
24 from guestperf
.progress
import Progress
25 from guestperf
.timings
import Timings
43 self
._hardware
= hardware
44 self
._scenario
= scenario
45 self
._progress
_history
= progress_history
46 self
._guest
_timings
= guest_timings
47 self
._qemu
_timings
= qemu_timings
48 self
._vcpu
_timings
= vcpu_timings
50 self
._dst
_host
= dst_host
53 self
._transport
= transport
58 "hardware": self
._hardware
.serialize(),
59 "scenario": self
._scenario
.serialize(),
60 "progress_history": [progress
.serialize() for progress
in self
._progress
_history
],
61 "guest_timings": self
._guest
_timings
.serialize(),
62 "qemu_timings": self
._qemu
_timings
.serialize(),
63 "vcpu_timings": self
._vcpu
_timings
.serialize(),
64 "binary": self
._binary
,
65 "dst_host": self
._dst
_host
,
66 "kernel": self
._kernel
,
67 "initrd": self
._initrd
,
68 "transport": self
._transport
,
73 def deserialize(cls
, data
):
75 Hardware
.deserialize(data
["hardware"]),
76 Scenario
.deserialize(data
["scenario"]),
77 [Progress
.deserialize(record
) for record
in data
["progress_history"]],
78 Timings
.deserialize(data
["guest_timings"]),
79 Timings
.deserialize(data
["qemu_timings"]),
80 Timings
.deserialize(data
["vcpu_timings"]),
89 return json
.dumps(self
.serialize(), indent
=4)
92 def from_json(cls
, data
):
93 return cls
.deserialize(json
.loads(data
))
96 def from_json_file(cls
, filename
):
97 with
open(filename
, "r") as fh
:
98 return cls
.deserialize(json
.load(fh
))