1# 2# Migration test migration operation progress 3# 4# Copyright (c) 2016 Red Hat, Inc. 5# 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.1 of the License, or (at your option) any later version. 10# 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. 15# 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/>. 18# 19 20 21class ProgressStats(object): 22 23 def __init__(self, 24 transferred_bytes, 25 remaining_bytes, 26 total_bytes, 27 duplicate_pages, 28 skipped_pages, 29 normal_pages, 30 normal_bytes, 31 dirty_rate_pps, 32 transfer_rate_mbs, 33 iterations): 34 self._transferred_bytes = transferred_bytes 35 self._remaining_bytes = remaining_bytes 36 self._total_bytes = total_bytes 37 self._duplicate_pages = duplicate_pages 38 self._skipped_pages = skipped_pages 39 self._normal_pages = normal_pages 40 self._normal_bytes = normal_bytes 41 self._dirty_rate_pps = dirty_rate_pps 42 self._transfer_rate_mbs = transfer_rate_mbs 43 self._iterations = iterations 44 45 def serialize(self): 46 return { 47 "transferred_bytes": self._transferred_bytes, 48 "remaining_bytes": self._remaining_bytes, 49 "total_bytes": self._total_bytes, 50 "duplicate_pages": self._duplicate_pages, 51 "skipped_pages": self._skipped_pages, 52 "normal_pages": self._normal_pages, 53 "normal_bytes": self._normal_bytes, 54 "dirty_rate_pps": self._dirty_rate_pps, 55 "transfer_rate_mbs": self._transfer_rate_mbs, 56 "iterations": self._iterations, 57 } 58 59 @classmethod 60 def deserialize(cls, data): 61 return cls( 62 data["transferred_bytes"], 63 data["remaining_bytes"], 64 data["total_bytes"], 65 data["duplicate_pages"], 66 data["skipped_pages"], 67 data["normal_pages"], 68 data["normal_bytes"], 69 data["dirty_rate_pps"], 70 data["transfer_rate_mbs"], 71 data["iterations"]) 72 73 74class Progress(object): 75 76 def __init__(self, 77 status, 78 ram, 79 now, 80 duration, 81 downtime, 82 downtime_expected, 83 setup_time, 84 throttle_pcent, 85 dirty_limit_throttle_time_per_round, 86 dirty_limit_ring_full_time): 87 88 self._status = status 89 self._ram = ram 90 self._now = now 91 self._duration = duration 92 self._downtime = downtime 93 self._downtime_expected = downtime_expected 94 self._setup_time = setup_time 95 self._throttle_pcent = throttle_pcent 96 self._dirty_limit_throttle_time_per_round = \ 97 dirty_limit_throttle_time_per_round 98 self._dirty_limit_ring_full_time = \ 99 dirty_limit_ring_full_time 100 101 def serialize(self): 102 return { 103 "status": self._status, 104 "ram": self._ram.serialize(), 105 "now": self._now, 106 "duration": self._duration, 107 "downtime": self._downtime, 108 "downtime_expected": self._downtime_expected, 109 "setup_time": self._setup_time, 110 "throttle_pcent": self._throttle_pcent, 111 "dirty_limit_throttle_time_per_round": 112 self._dirty_limit_throttle_time_per_round, 113 "dirty_limit_ring_full_time": 114 self._dirty_limit_ring_full_time, 115 } 116 117 @classmethod 118 def deserialize(cls, data): 119 return cls( 120 data["status"], 121 ProgressStats.deserialize(data["ram"]), 122 data["now"], 123 data["duration"], 124 data["downtime"], 125 data["downtime_expected"], 126 data["setup_time"], 127 data["throttle_pcent"], 128 data["dirty_limit_throttle_time_per_round"], 129 data["dirty_limit_ring_full_time"]) 130