Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / os / kstore / kstore_types.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2014 Red Hat
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software
11  * Foundation.  See file COPYING.
12  *
13  */
14
15 #include "kstore_types.h"
16 #include "common/Formatter.h"
17 #include "include/stringify.h"
18
19 // cnode_t
20
21 void kstore_cnode_t::encode(bufferlist& bl) const
22 {
23   ENCODE_START(1, 1, bl);
24   ::encode(bits, bl);
25   ENCODE_FINISH(bl);
26 }
27
28 void kstore_cnode_t::decode(bufferlist::iterator& p)
29 {
30   DECODE_START(1, p);
31   ::decode(bits, p);
32   DECODE_FINISH(p);
33 }
34
35 void kstore_cnode_t::dump(Formatter *f) const
36 {
37   f->dump_unsigned("bits", bits);
38 }
39
40 void kstore_cnode_t::generate_test_instances(list<kstore_cnode_t*>& o)
41 {
42   o.push_back(new kstore_cnode_t());
43   o.push_back(new kstore_cnode_t(0));
44   o.push_back(new kstore_cnode_t(123));
45 }
46
47
48 // kstore_onode_t
49
50 void kstore_onode_t::encode(bufferlist& bl) const
51 {
52   ENCODE_START(1, 1, bl);
53   ::encode(nid, bl);
54   ::encode(size, bl);
55   ::encode(attrs, bl);
56   ::encode(omap_head, bl);
57   ::encode(stripe_size, bl);
58   ::encode(expected_object_size, bl);
59   ::encode(expected_write_size, bl);
60   ::encode(alloc_hint_flags, bl);
61   ENCODE_FINISH(bl);
62 }
63
64 void kstore_onode_t::decode(bufferlist::iterator& p)
65 {
66   DECODE_START(1, p);
67   ::decode(nid, p);
68   ::decode(size, p);
69   ::decode(attrs, p);
70   ::decode(omap_head, p);
71   ::decode(stripe_size, p);
72   ::decode(expected_object_size, p);
73   ::decode(expected_write_size, p);
74   ::decode(alloc_hint_flags, p);
75   DECODE_FINISH(p);
76 }
77
78 void kstore_onode_t::dump(Formatter *f) const
79 {
80   f->dump_unsigned("nid", nid);
81   f->dump_unsigned("size", size);
82   f->open_object_section("attrs");
83   for (map<string,bufferptr>::const_iterator p = attrs.begin();
84        p != attrs.end(); ++p) {
85     f->open_object_section("attr");
86     f->dump_string("name", p->first);
87     f->dump_unsigned("len", p->second.length());
88     f->close_section();
89   }
90   f->close_section();
91   f->dump_unsigned("omap_head", omap_head);
92   f->dump_unsigned("stripe_size", stripe_size);
93   f->dump_unsigned("expected_object_size", expected_object_size);
94   f->dump_unsigned("expected_write_size", expected_write_size);
95   f->dump_unsigned("alloc_hint_flags", alloc_hint_flags);
96 }
97
98 void kstore_onode_t::generate_test_instances(list<kstore_onode_t*>& o)
99 {
100   o.push_back(new kstore_onode_t());
101   // FIXME
102 }