1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
#
# Migration test migration operation progress
#
# Copyright (c) 2016 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, see <http://www.gnu.org/licenses/>.
#
class ProgressStats(object):
def __init__(self,
transferred_bytes,
remaining_bytes,
total_bytes,
duplicate_pages,
skipped_pages,
normal_pages,
normal_bytes,
dirty_rate_pps,
transfer_rate_mbs,
iterations):
self._transferred_bytes = transferred_bytes
self._remaining_bytes = remaining_bytes
self._total_bytes = total_bytes
self._duplicate_pages = duplicate_pages
self._skipped_pages = skipped_pages
self._normal_pages = normal_pages
self._normal_bytes = normal_bytes
self._dirty_rate_pps = dirty_rate_pps
self._transfer_rate_mbs = transfer_rate_mbs
self._iterations = iterations
def serialize(self):
return {
"transferred_bytes": self._transferred_bytes,
"remaining_bytes": self._remaining_bytes,
"total_bytes": self._total_bytes,
"duplicate_pages": self._duplicate_pages,
"skipped_pages": self._skipped_pages,
"normal_pages": self._normal_pages,
"normal_bytes": self._normal_bytes,
"dirty_rate_pps": self._dirty_rate_pps,
"transfer_rate_mbs": self._transfer_rate_mbs,
"iterations": self._iterations,
}
@classmethod
def deserialize(cls, data):
return cls(
data["transferred_bytes"],
data["remaining_bytes"],
data["total_bytes"],
data["duplicate_pages"],
data["skipped_pages"],
data["normal_pages"],
data["normal_bytes"],
data["dirty_rate_pps"],
data["transfer_rate_mbs"],
data["iterations"])
class Progress(object):
def __init__(self,
status,
ram,
now,
duration,
downtime,
downtime_expected,
setup_time,
throttle_pcent):
self._status = status
self._ram = ram
self._now = now
self._duration = duration
self._downtime = downtime
self._downtime_expected = downtime_expected
self._setup_time = setup_time
self._throttle_pcent = throttle_pcent
def serialize(self):
return {
"status": self._status,
"ram": self._ram.serialize(),
"now": self._now,
"duration": self._duration,
"downtime": self._downtime,
"downtime_expected": self._downtime_expected,
"setup_time": self._setup_time,
"throttle_pcent": self._throttle_pcent,
}
@classmethod
def deserialize(cls, data):
return cls(
data["status"],
ProgressStats.deserialize(data["ram"]),
data["now"],
data["duration"],
data["downtime"],
data["downtime_expected"],
data["setup_time"],
data["throttle_pcent"])
|