void MirrorPeer::encode(bufferlist &bl) const {
ENCODE_START(1, 1, bl);
- ::encode(uuid, bl);
- ::encode(cluster_name, bl);
- ::encode(client_name, bl);
- ::encode(pool_id, bl);
+ encode(uuid, bl);
+ encode(cluster_name, bl);
+ encode(client_name, bl);
+ encode(pool_id, bl);
ENCODE_FINISH(bl);
}
-void MirrorPeer::decode(bufferlist::iterator &it) {
+void MirrorPeer::decode(bufferlist::const_iterator &it) {
DECODE_START(1, it);
- ::decode(uuid, it);
- ::decode(cluster_name, it);
- ::decode(client_name, it);
- ::decode(pool_id, it);
+ decode(uuid, it);
+ decode(cluster_name, it);
+ decode(client_name, it);
+ decode(pool_id, it);
DECODE_FINISH(it);
}
void MirrorImage::encode(bufferlist &bl) const {
ENCODE_START(1, 1, bl);
- ::encode(global_image_id, bl);
- ::encode(static_cast<uint8_t>(state), bl);
+ encode(global_image_id, bl);
+ encode(static_cast<uint8_t>(state), bl);
ENCODE_FINISH(bl);
}
-void MirrorImage::decode(bufferlist::iterator &it) {
+void MirrorImage::decode(bufferlist::const_iterator &it) {
uint8_t int_state;
DECODE_START(1, it);
- ::decode(global_image_id, it);
- ::decode(int_state, it);
+ decode(global_image_id, it);
+ decode(int_state, it);
state = static_cast<MirrorImageState>(int_state);
DECODE_FINISH(it);
}
void MirrorImageStatus::encode(bufferlist &bl) const {
ENCODE_START(1, 1, bl);
- ::encode(state, bl);
- ::encode(description, bl);
- ::encode(last_update, bl);
- ::encode(up, bl);
+ encode(state, bl);
+ encode(description, bl);
+ encode(last_update, bl);
+ encode(up, bl);
ENCODE_FINISH(bl);
}
-void MirrorImageStatus::decode(bufferlist::iterator &it) {
+void MirrorImageStatus::decode(bufferlist::const_iterator &it) {
DECODE_START(1, it);
- ::decode(state, it);
- ::decode(description, it);
- ::decode(last_update, it);
- ::decode(up, it);
+ decode(state, it);
+ decode(description, it);
+ decode(last_update, it);
+ decode(up, it);
DECODE_FINISH(it);
}
return os;
}
+void ParentImageSpec::encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ encode(pool_id, bl);
+ encode(pool_namespace, bl);
+ encode(image_id, bl);
+ encode(snap_id, bl);
+ ENCODE_FINISH(bl);
+}
+
+void ParentImageSpec::decode(bufferlist::const_iterator& bl) {
+ DECODE_START(1, bl);
+ decode(pool_id, bl);
+ decode(pool_namespace, bl);
+ decode(image_id, bl);
+ decode(snap_id, bl);
+ DECODE_FINISH(bl);
+}
+
+void ParentImageSpec::dump(Formatter *f) const {
+ f->dump_int("pool_id", pool_id);
+ f->dump_string("pool_namespace", pool_namespace);
+ f->dump_string("image_id", image_id);
+ f->dump_unsigned("snap_id", snap_id);
+}
+
+void ParentImageSpec::generate_test_instances(std::list<ParentImageSpec*>& o) {
+ o.push_back(new ParentImageSpec{});
+ o.push_back(new ParentImageSpec{1, "", "foo", 3});
+ o.push_back(new ParentImageSpec{1, "ns", "foo", 3});
+}
+
+void ChildImageSpec::encode(bufferlist &bl) const {
+ ENCODE_START(2, 1, bl);
+ encode(pool_id, bl);
+ encode(image_id, bl);
+ encode(pool_namespace, bl);
+ ENCODE_FINISH(bl);
+}
+
+void ChildImageSpec::decode(bufferlist::const_iterator &it) {
+ DECODE_START(2, it);
+ decode(pool_id, it);
+ decode(image_id, it);
+ if (struct_v >= 2) {
+ decode(pool_namespace, it);
+ }
+ DECODE_FINISH(it);
+}
+
+void ChildImageSpec::dump(Formatter *f) const {
+ f->dump_int("pool_id", pool_id);
+ f->dump_string("pool_namespace", pool_namespace);
+ f->dump_string("image_id", image_id);
+}
+
+void ChildImageSpec::generate_test_instances(std::list<ChildImageSpec*> &o) {
+ o.push_back(new ChildImageSpec());
+ o.push_back(new ChildImageSpec(123, "", "abc"));
+ o.push_back(new ChildImageSpec(123, "ns", "abc"));
+}
+
void GroupImageSpec::encode(bufferlist &bl) const {
ENCODE_START(1, 1, bl);
- ::encode(image_id, bl);
- ::encode(pool_id, bl);
+ encode(image_id, bl);
+ encode(pool_id, bl);
ENCODE_FINISH(bl);
}
-void GroupImageSpec::decode(bufferlist::iterator &it) {
+void GroupImageSpec::decode(bufferlist::const_iterator &it) {
DECODE_START(1, it);
- ::decode(image_id, it);
- ::decode(pool_id, it);
+ decode(image_id, it);
+ decode(pool_id, it);
DECODE_FINISH(it);
}
}
}
+void GroupImageSpec::generate_test_instances(std::list<GroupImageSpec*> &o) {
+ o.push_back(new GroupImageSpec("10152ae8944a", 0));
+ o.push_back(new GroupImageSpec("1018643c9869", 3));
+}
+
void GroupImageStatus::encode(bufferlist &bl) const {
ENCODE_START(1, 1, bl);
- ::encode(spec, bl);
- ::encode(state, bl);
+ encode(spec, bl);
+ encode(state, bl);
ENCODE_FINISH(bl);
}
-void GroupImageStatus::decode(bufferlist::iterator &it) {
+void GroupImageStatus::decode(bufferlist::const_iterator &it) {
DECODE_START(1, it);
- ::decode(spec, it);
- ::decode(state, it);
+ decode(spec, it);
+ decode(state, it);
DECODE_FINISH(it);
}
f->dump_string("state", state_to_string());
}
+void GroupImageStatus::generate_test_instances(std::list<GroupImageStatus*> &o) {
+ o.push_back(new GroupImageStatus(GroupImageSpec("10152ae8944a", 0), GROUP_IMAGE_LINK_STATE_ATTACHED));
+ o.push_back(new GroupImageStatus(GroupImageSpec("1018643c9869", 3), GROUP_IMAGE_LINK_STATE_ATTACHED));
+ o.push_back(new GroupImageStatus(GroupImageSpec("10152ae8944a", 0), GROUP_IMAGE_LINK_STATE_INCOMPLETE));
+ o.push_back(new GroupImageStatus(GroupImageSpec("1018643c9869", 3), GROUP_IMAGE_LINK_STATE_INCOMPLETE));
+}
+
+
void GroupSpec::encode(bufferlist &bl) const {
ENCODE_START(1, 1, bl);
- ::encode(pool_id, bl);
- ::encode(group_id, bl);
+ encode(pool_id, bl);
+ encode(group_id, bl);
ENCODE_FINISH(bl);
}
-void GroupSpec::decode(bufferlist::iterator &it) {
+void GroupSpec::decode(bufferlist::const_iterator &it) {
DECODE_START(1, it);
- ::decode(pool_id, it);
- ::decode(group_id, it);
+ decode(pool_id, it);
+ decode(group_id, it);
DECODE_FINISH(it);
}
return (!group_id.empty()) && (pool_id != -1);
}
+void GroupSpec::generate_test_instances(std::list<GroupSpec *> &o) {
+ o.push_back(new GroupSpec("10152ae8944a", 0));
+ o.push_back(new GroupSpec("1018643c9869", 3));
+}
+
+void GroupSnapshotNamespace::encode(bufferlist& bl) const {
+ using ceph::encode;
+ encode(group_pool, bl);
+ encode(group_id, bl);
+ encode(group_snapshot_id, bl);
+}
+
+void GroupSnapshotNamespace::decode(bufferlist::const_iterator& it) {
+ using ceph::decode;
+ decode(group_pool, it);
+ decode(group_id, it);
+ decode(group_snapshot_id, it);
+}
+
+void GroupSnapshotNamespace::dump(Formatter *f) const {
+ f->dump_int("group_pool", group_pool);
+ f->dump_string("group_id", group_id);
+ f->dump_string("group_snapshot_id", group_snapshot_id);
+}
+
+void TrashSnapshotNamespace::encode(bufferlist& bl) const {
+ using ceph::encode;
+ encode(original_name, bl);
+ encode(static_cast<uint32_t>(original_snapshot_namespace_type), bl);
+}
+
+void TrashSnapshotNamespace::decode(bufferlist::const_iterator& it) {
+ using ceph::decode;
+ decode(original_name, it);
+ uint32_t snap_type;
+ decode(snap_type, it);
+ original_snapshot_namespace_type = static_cast<SnapshotNamespaceType>(
+ snap_type);
+}
+
+void TrashSnapshotNamespace::dump(Formatter *f) const {
+ f->dump_string("original_name", original_name);
+ f->dump_stream("original_snapshot_namespace")
+ << original_snapshot_namespace_type;
+}
+
class EncodeSnapshotNamespaceVisitor : public boost::static_visitor<void> {
public:
explicit EncodeSnapshotNamespaceVisitor(bufferlist &bl) : m_bl(bl) {
template <typename T>
inline void operator()(const T& t) const {
- ::encode(static_cast<uint32_t>(T::SNAPSHOT_NAMESPACE_TYPE), m_bl);
+ using ceph::encode;
+ encode(static_cast<uint32_t>(T::SNAPSHOT_NAMESPACE_TYPE), m_bl);
t.encode(m_bl);
}
class DecodeSnapshotNamespaceVisitor : public boost::static_visitor<void> {
public:
- DecodeSnapshotNamespaceVisitor(bufferlist::iterator &iter)
+ DecodeSnapshotNamespaceVisitor(bufferlist::const_iterator &iter)
: m_iter(iter) {
}
t.decode(m_iter);
}
private:
- bufferlist::iterator &m_iter;
+ bufferlist::const_iterator &m_iter;
};
class DumpSnapshotNamespaceVisitor : public boost::static_visitor<void> {
}
};
+SnapshotNamespaceType get_snap_namespace_type(
+ const SnapshotNamespace& snapshot_namespace) {
+ return static_cast<SnapshotNamespaceType>(boost::apply_visitor(
+ GetTypeVisitor(), snapshot_namespace));
+}
+
+void SnapshotInfo::encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ encode(id, bl);
+ encode(snapshot_namespace, bl);
+ encode(name, bl);
+ encode(image_size, bl);
+ encode(timestamp, bl);
+ encode(child_count, bl);
+ ENCODE_FINISH(bl);
+}
+
+void SnapshotInfo::decode(bufferlist::const_iterator& it) {
+ DECODE_START(1, it);
+ decode(id, it);
+ decode(snapshot_namespace, it);
+ decode(name, it);
+ decode(image_size, it);
+ decode(timestamp, it);
+ decode(child_count, it);
+ DECODE_FINISH(it);
+}
+
+void SnapshotInfo::dump(Formatter *f) const {
+ f->dump_unsigned("id", id);
+ f->open_object_section("namespace");
+ boost::apply_visitor(DumpSnapshotNamespaceVisitor(f, "type"),
+ snapshot_namespace);
+ f->close_section();
+ f->dump_string("name", name);
+ f->dump_unsigned("image_size", image_size);
+ f->dump_stream("timestamp") << timestamp;
+}
-SnapshotNamespaceType SnapshotNamespaceOnDisk::get_namespace_type() const {
- return static_cast<SnapshotNamespaceType>(boost::apply_visitor(GetTypeVisitor(),
- snapshot_namespace));
+void SnapshotInfo::generate_test_instances(std::list<SnapshotInfo*> &o) {
+ o.push_back(new SnapshotInfo(1ULL, UserSnapshotNamespace{}, "snap1", 123,
+ {123456, 0}, 12));
+ o.push_back(new SnapshotInfo(2ULL,
+ GroupSnapshotNamespace{567, "group1", "snap1"},
+ "snap1", 123, {123456, 0}, 987));
+ o.push_back(new SnapshotInfo(3ULL,
+ TrashSnapshotNamespace{
+ SNAPSHOT_NAMESPACE_TYPE_USER, "snap1"},
+ "12345", 123, {123456, 0}, 429));
}
-void SnapshotNamespaceOnDisk::encode(bufferlist& bl) const {
+void SnapshotNamespace::encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
- boost::apply_visitor(EncodeSnapshotNamespaceVisitor(bl), snapshot_namespace);
+ boost::apply_visitor(EncodeSnapshotNamespaceVisitor(bl), *this);
ENCODE_FINISH(bl);
}
-void SnapshotNamespaceOnDisk::decode(bufferlist::iterator &p)
+void SnapshotNamespace::decode(bufferlist::const_iterator &p)
{
DECODE_START(1, p);
uint32_t snap_type;
- ::decode(snap_type, p);
+ decode(snap_type, p);
switch (snap_type) {
case cls::rbd::SNAPSHOT_NAMESPACE_TYPE_USER:
- snapshot_namespace = UserSnapshotNamespace();
+ *this = UserSnapshotNamespace();
+ break;
+ case cls::rbd::SNAPSHOT_NAMESPACE_TYPE_GROUP:
+ *this = GroupSnapshotNamespace();
+ break;
+ case cls::rbd::SNAPSHOT_NAMESPACE_TYPE_TRASH:
+ *this = TrashSnapshotNamespace();
break;
default:
- snapshot_namespace = UnknownSnapshotNamespace();
+ *this = UnknownSnapshotNamespace();
break;
}
- boost::apply_visitor(DecodeSnapshotNamespaceVisitor(p), snapshot_namespace);
+ boost::apply_visitor(DecodeSnapshotNamespaceVisitor(p), *this);
DECODE_FINISH(p);
}
-void SnapshotNamespaceOnDisk::dump(Formatter *f) const {
- boost::apply_visitor(DumpSnapshotNamespaceVisitor(f, "snapshot_namespace_type"), snapshot_namespace);
+void SnapshotNamespace::dump(Formatter *f) const {
+ boost::apply_visitor(
+ DumpSnapshotNamespaceVisitor(f, "snapshot_namespace_type"), *this);
}
-void SnapshotNamespaceOnDisk::generate_test_instances(std::list<SnapshotNamespaceOnDisk *> &o) {
- o.push_back(new SnapshotNamespaceOnDisk(UserSnapshotNamespace()));
+void SnapshotNamespace::generate_test_instances(std::list<SnapshotNamespace*> &o) {
+ o.push_back(new SnapshotNamespace(UserSnapshotNamespace()));
+ o.push_back(new SnapshotNamespace(GroupSnapshotNamespace(0, "10152ae8944a",
+ "2118643c9732")));
+ o.push_back(new SnapshotNamespace(GroupSnapshotNamespace(5, "1018643c9869",
+ "33352be8933c")));
+ o.push_back(new SnapshotNamespace(TrashSnapshotNamespace()));
+}
+
+std::ostream& operator<<(std::ostream& os, const SnapshotNamespaceType& type) {
+ switch (type) {
+ case SNAPSHOT_NAMESPACE_TYPE_USER:
+ os << "user";
+ break;
+ case SNAPSHOT_NAMESPACE_TYPE_GROUP:
+ os << "group";
+ break;
+ case SNAPSHOT_NAMESPACE_TYPE_TRASH:
+ os << "trash";
+ break;
+ default:
+ os << "unknown";
+ break;
+ }
+ return os;
}
std::ostream& operator<<(std::ostream& os, const UserSnapshotNamespace& ns) {
- os << "[user]";
+ os << "[" << SNAPSHOT_NAMESPACE_TYPE_USER << "]";
+ return os;
+}
+
+std::ostream& operator<<(std::ostream& os, const GroupSnapshotNamespace& ns) {
+ os << "[" << SNAPSHOT_NAMESPACE_TYPE_GROUP << " "
+ << "group_pool=" << ns.group_pool << ", "
+ << "group_id=" << ns.group_id << ", "
+ << "group_snapshot_id=" << ns.group_snapshot_id << "]";
+ return os;
+}
+
+std::ostream& operator<<(std::ostream& os, const TrashSnapshotNamespace& ns) {
+ os << "[" << SNAPSHOT_NAMESPACE_TYPE_TRASH << " "
+ << "original_name=" << ns.original_name << ", "
+ << "original_snapshot_namespace=" << ns.original_snapshot_namespace_type
+ << "]";
return os;
}
return os;
}
-void TrashImageSpec::encode(bufferlist& bl) const {
+void ImageSnapshotSpec::encode(bufferlist& bl) const {
+ using ceph::encode;
ENCODE_START(1, 1, bl);
- ::encode(source, bl);
- ::encode(name, bl);
- ::encode(deletion_time, bl);
- ::encode(deferment_end_time, bl);
+ encode(pool, bl);
+ encode(image_id, bl);
+ encode(snap_id, bl);
ENCODE_FINISH(bl);
}
-void TrashImageSpec::decode(bufferlist::iterator &it) {
+void ImageSnapshotSpec::decode(bufferlist::const_iterator& it) {
+ using ceph::decode;
DECODE_START(1, it);
- ::decode(source, it);
- ::decode(name, it);
- ::decode(deletion_time, it);
- ::decode(deferment_end_time, it);
+ decode(pool, it);
+ decode(image_id, it);
+ decode(snap_id, it);
DECODE_FINISH(it);
}
-void TrashImageSpec::dump(Formatter *f) const {
- switch(source) {
- case TRASH_IMAGE_SOURCE_USER:
- f->dump_string("source", "user");
- break;
- case TRASH_IMAGE_SOURCE_MIRRORING:
- f->dump_string("source", "rbd_mirror");
+void ImageSnapshotSpec::dump(Formatter *f) const {
+ f->dump_int("pool", pool);
+ f->dump_string("image_id", image_id);
+ f->dump_int("snap_id", snap_id);
+}
+
+void ImageSnapshotSpec::generate_test_instances(std::list<ImageSnapshotSpec *> &o) {
+ o.push_back(new ImageSnapshotSpec(0, "myimage", 2));
+ o.push_back(new ImageSnapshotSpec(1, "testimage", 7));
+}
+
+void GroupSnapshot::encode(bufferlist& bl) const {
+ using ceph::encode;
+ ENCODE_START(1, 1, bl);
+ encode(id, bl);
+ encode(name, bl);
+ encode(state, bl);
+ encode(snaps, bl);
+ ENCODE_FINISH(bl);
+}
+
+void GroupSnapshot::decode(bufferlist::const_iterator& it) {
+ using ceph::decode;
+ DECODE_START(1, it);
+ decode(id, it);
+ decode(name, it);
+ decode(state, it);
+ decode(snaps, it);
+ DECODE_FINISH(it);
+}
+
+void GroupSnapshot::dump(Formatter *f) const {
+ f->dump_string("id", id);
+ f->dump_string("name", name);
+ f->dump_int("state", state);
+}
+
+void GroupSnapshot::generate_test_instances(std::list<GroupSnapshot *> &o) {
+ o.push_back(new GroupSnapshot("10152ae8944a", "groupsnapshot1", GROUP_SNAPSHOT_STATE_INCOMPLETE));
+ o.push_back(new GroupSnapshot("1018643c9869", "groupsnapshot2", GROUP_SNAPSHOT_STATE_COMPLETE));
+}
+void TrashImageSpec::encode(bufferlist& bl) const {
+ ENCODE_START(2, 1, bl);
+ encode(source, bl);
+ encode(name, bl);
+ encode(deletion_time, bl);
+ encode(deferment_end_time, bl);
+ encode(state, bl);
+ ENCODE_FINISH(bl);
+}
+
+void TrashImageSpec::decode(bufferlist::const_iterator &it) {
+ DECODE_START(2, it);
+ decode(source, it);
+ decode(name, it);
+ decode(deletion_time, it);
+ decode(deferment_end_time, it);
+ if (struct_v >= 2) {
+ decode(state, it);
}
+ DECODE_FINISH(it);
+}
+
+void TrashImageSpec::dump(Formatter *f) const {
+ f->dump_stream("source") << source;
f->dump_string("name", name);
f->dump_unsigned("deletion_time", deletion_time);
f->dump_unsigned("deferment_end_time", deferment_end_time);
}
+void MirrorImageMap::encode(bufferlist &bl) const {
+ ENCODE_START(1, 1, bl);
+ encode(instance_id, bl);
+ encode(mapped_time, bl);
+ encode(data, bl);
+ ENCODE_FINISH(bl);
+}
+
+void MirrorImageMap::decode(bufferlist::const_iterator &it) {
+ DECODE_START(1, it);
+ decode(instance_id, it);
+ decode(mapped_time, it);
+ decode(data, it);
+ DECODE_FINISH(it);
+}
+
+void MirrorImageMap::dump(Formatter *f) const {
+ f->dump_string("instance_id", instance_id);
+ f->dump_stream("mapped_time") << mapped_time;
+
+ std::stringstream data_ss;
+ data.hexdump(data_ss);
+ f->dump_string("data", data_ss.str());
+}
+
+void MirrorImageMap::generate_test_instances(
+ std::list<MirrorImageMap*> &o) {
+ bufferlist data;
+ data.append(std::string(128, '1'));
+
+ o.push_back(new MirrorImageMap("uuid-123", utime_t(), data));
+ o.push_back(new MirrorImageMap("uuid-abc", utime_t(), data));
+}
+
+bool MirrorImageMap::operator==(const MirrorImageMap &rhs) const {
+ return instance_id == rhs.instance_id && mapped_time == rhs.mapped_time &&
+ data.contents_equal(rhs.data);
+}
+
+bool MirrorImageMap::operator<(const MirrorImageMap &rhs) const {
+ return instance_id < rhs.instance_id ||
+ (instance_id == rhs.instance_id && mapped_time < rhs.mapped_time);
+}
+
+std::ostream& operator<<(std::ostream& os,
+ const MirrorImageMap &image_map) {
+ return os << "[" << "instance_id=" << image_map.instance_id << ", mapped_time="
+ << image_map.mapped_time << "]";
+}
+
+std::ostream& operator<<(std::ostream& os,
+ const MigrationHeaderType& type) {
+ switch (type) {
+ case MIGRATION_HEADER_TYPE_SRC:
+ os << "source";
+ break;
+ case MIGRATION_HEADER_TYPE_DST:
+ os << "destination";
+ break;
+ default:
+ os << "unknown (" << static_cast<uint32_t>(type) << ")";
+ break;
+ }
+ return os;
+}
+
+std::ostream& operator<<(std::ostream& os,
+ const MigrationState& migration_state) {
+ switch (migration_state) {
+ case MIGRATION_STATE_ERROR:
+ os << "error";
+ break;
+ case MIGRATION_STATE_PREPARING:
+ os << "preparing";
+ break;
+ case MIGRATION_STATE_PREPARED:
+ os << "prepared";
+ break;
+ case MIGRATION_STATE_EXECUTING:
+ os << "executing";
+ break;
+ case MIGRATION_STATE_EXECUTED:
+ os << "executed";
+ break;
+ default:
+ os << "unknown (" << static_cast<uint32_t>(migration_state) << ")";
+ break;
+ }
+ return os;
+}
+
+void MigrationSpec::encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ encode(header_type, bl);
+ encode(pool_id, bl);
+ encode(pool_namespace, bl);
+ encode(image_name, bl);
+ encode(image_id, bl);
+ encode(snap_seqs, bl);
+ encode(overlap, bl);
+ encode(flatten, bl);
+ encode(mirroring, bl);
+ encode(state, bl);
+ encode(state_description, bl);
+ ENCODE_FINISH(bl);
+}
+
+void MigrationSpec::decode(bufferlist::const_iterator& bl) {
+ DECODE_START(1, bl);
+ decode(header_type, bl);
+ decode(pool_id, bl);
+ decode(pool_namespace, bl);
+ decode(image_name, bl);
+ decode(image_id, bl);
+ decode(snap_seqs, bl);
+ decode(overlap, bl);
+ decode(flatten, bl);
+ decode(mirroring, bl);
+ decode(state, bl);
+ decode(state_description, bl);
+ DECODE_FINISH(bl);
+}
+
+std::ostream& operator<<(std::ostream& os,
+ const std::map<uint64_t, uint64_t>& snap_seqs) {
+ os << "{";
+ size_t count = 0;
+ for (auto &it : snap_seqs) {
+ os << (count++ > 0 ? ", " : "") << "(" << it.first << ", " << it.second
+ << ")";
+ }
+ os << "}";
+ return os;
+}
+
+void MigrationSpec::dump(Formatter *f) const {
+ f->dump_stream("header_type") << header_type;
+ f->dump_int("pool_id", pool_id);
+ f->dump_string("pool_namespace", pool_namespace);
+ f->dump_string("image_name", image_name);
+ f->dump_string("image_id", image_id);
+ f->dump_stream("snap_seqs") << snap_seqs;
+ f->dump_unsigned("overlap", overlap);
+ f->dump_bool("mirroring", mirroring);
+}
+
+void MigrationSpec::generate_test_instances(std::list<MigrationSpec*> &o) {
+ o.push_back(new MigrationSpec());
+ o.push_back(new MigrationSpec(MIGRATION_HEADER_TYPE_SRC, 1, "ns",
+ "image_name", "image_id", {{1, 2}}, 123, true,
+ true, MIGRATION_STATE_PREPARED, "description"));
+}
+
+std::ostream& operator<<(std::ostream& os,
+ const MigrationSpec& migration_spec) {
+ os << "["
+ << "header_type=" << migration_spec.header_type << ", "
+ << "pool_id=" << migration_spec.pool_id << ", "
+ << "pool_namespace=" << migration_spec.pool_namespace << ", "
+ << "image_name=" << migration_spec.image_name << ", "
+ << "image_id=" << migration_spec.image_id << ", "
+ << "snap_seqs=" << migration_spec.snap_seqs << ", "
+ << "overlap=" << migration_spec.overlap << ", "
+ << "flatten=" << migration_spec.flatten << ", "
+ << "mirroring=" << migration_spec.mirroring << ", "
+ << "state=" << migration_spec.state << ", "
+ << "state_description=" << migration_spec.state_description << "]";
+ return os;
+}
+
+std::ostream& operator<<(std::ostream& os, const AssertSnapcSeqState& state) {
+ switch (state) {
+ case ASSERT_SNAPC_SEQ_GT_SNAPSET_SEQ:
+ os << "gt";
+ break;
+ case ASSERT_SNAPC_SEQ_LE_SNAPSET_SEQ:
+ os << "le";
+ break;
+ default:
+ os << "unknown (" << static_cast<uint32_t>(state) << ")";
+ break;
+ }
+ return os;
+}
+
} // namespace rbd
} // namespace cls