libcls_rbd_client_la_SOURCES = cls/rbd/cls_rbd_client.cc
noinst_LTLIBRARIES += libcls_rbd_client.la
-libcls_user_client_a_SOURCES = cls/user/cls_user_client.cc cls/user/cls_user_types.cc
+libcls_user_client_a_SOURCES = cls/user/cls_user_client.cc \
+ cls/user/cls_user_types.cc \
+ cls/user/cls_user_ops.cc
+DENCODER_DEPS += libcls_user_client.a
+
noinst_LIBRARIES += libcls_user_client.a
noinst_HEADERS += \
--- /dev/null
+// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "cls/user/cls_user_types.h"
+#include "cls/user/cls_user_ops.h"
+#include "common/Formatter.h"
+#include "common/ceph_json.h"
+
+void cls_user_set_buckets_op::dump(Formatter *f) const
+{
+ encode_json("entries", entries, f);
+ encode_json("add", add, f);
+ encode_json("time", time, f);
+}
+
+void cls_user_set_buckets_op::generate_test_instances(list<cls_user_set_buckets_op*>& ls)
+{
+ ls.push_back(new cls_user_set_buckets_op);
+ cls_user_set_buckets_op *op = new cls_user_set_buckets_op;
+ for (int i = 0; i < 3; i++) {
+ cls_user_bucket_entry e;
+ cls_user_gen_test_bucket_entry(&e, i);
+ op->entries.push_back(e);
+ }
+ op->add = true;
+ op->time = utime_t(1, 0);
+ ls.push_back(op);
+}
+
+void cls_user_remove_bucket_op::dump(Formatter *f) const
+{
+ encode_json("bucket", bucket, f);
+}
+
+void cls_user_remove_bucket_op::generate_test_instances(list<cls_user_remove_bucket_op*>& ls)
+{
+ ls.push_back(new cls_user_remove_bucket_op);
+ cls_user_remove_bucket_op *op = new cls_user_remove_bucket_op;
+ cls_user_gen_test_bucket(&op->bucket, 0);
+ ls.push_back(op);
+}
+
+void cls_user_list_buckets_op::dump(Formatter *f) const
+{
+ encode_json("marker", marker, f);
+ encode_json("max_entries", max_entries, f);
+}
+
+void cls_user_list_buckets_op::generate_test_instances(list<cls_user_list_buckets_op*>& ls)
+{
+ ls.push_back(new cls_user_list_buckets_op);
+ cls_user_list_buckets_op *op = new cls_user_list_buckets_op;
+ op->marker = "marker";
+ op->max_entries = 1000;
+ ls.push_back(op);
+}
+
+void cls_user_list_buckets_ret::dump(Formatter *f) const
+{
+ encode_json("entries", entries, f);
+ encode_json("marker", marker, f);
+ encode_json("truncated", truncated, f);
+}
+
+void cls_user_list_buckets_ret::generate_test_instances(list<cls_user_list_buckets_ret*>& ls)
+{
+ ls.push_back(new cls_user_list_buckets_ret);
+ cls_user_list_buckets_ret *ret = new cls_user_list_buckets_ret;
+ for (int i = 0; i < 3; i++) {
+ cls_user_bucket_entry e;
+ cls_user_gen_test_bucket_entry(&e, i);
+ ret->entries.push_back(e);
+ }
+ ret->marker = "123";
+ ret->truncated = true;
+ ls.push_back(ret);
+}
+
+void cls_user_get_header_op::dump(Formatter *f) const
+{
+ // empty!
+}
+
+void cls_user_get_header_op::generate_test_instances(list<cls_user_get_header_op*>& ls)
+{
+ ls.push_back(new cls_user_get_header_op);
+}
+
+void cls_user_get_header_ret::dump(Formatter *f) const
+{
+ encode_json("header", header, f);
+}
+
+void cls_user_get_header_ret::generate_test_instances(list<cls_user_get_header_ret*>& ls)
+{
+ ls.push_back(new cls_user_get_header_ret);
+ cls_user_get_header_ret *ret = new cls_user_get_header_ret;
+ cls_user_gen_test_header(&ret->header);
+ ls.push_back(ret);
+}
+
+void cls_user_complete_stats_sync_op::dump(Formatter *f) const
+{
+ encode_json("time", time, f);
+}
+
+void cls_user_complete_stats_sync_op::generate_test_instances(list<cls_user_complete_stats_sync_op*>& ls)
+{
+ ls.push_back(new cls_user_complete_stats_sync_op);
+ cls_user_complete_stats_sync_op *op = new cls_user_complete_stats_sync_op;
+ op->time = utime_t(12345, 0);
+ ls.push_back(op);
+}
+
+
::decode(time, bl);
DECODE_FINISH(bl);
}
+
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_user_set_buckets_op*>& ls);
};
WRITE_CLASS_ENCODER(cls_user_set_buckets_op)
::decode(bucket, bl);
DECODE_FINISH(bl);
}
+
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_user_remove_bucket_op*>& ls);
};
WRITE_CLASS_ENCODER(cls_user_remove_bucket_op)
::decode(max_entries, bl);
DECODE_FINISH(bl);
}
+
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_user_list_buckets_op*>& ls);
};
WRITE_CLASS_ENCODER(cls_user_list_buckets_op)
::decode(truncated, bl);
DECODE_FINISH(bl);
}
+
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_user_list_buckets_ret*>& ls);
};
WRITE_CLASS_ENCODER(cls_user_list_buckets_ret)
DECODE_START(1, bl);
DECODE_FINISH(bl);
}
+
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_user_get_header_op*>& ls);
};
WRITE_CLASS_ENCODER(cls_user_get_header_op)
::decode(header, bl);
DECODE_FINISH(bl);
}
+
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_user_get_header_ret*>& ls);
};
WRITE_CLASS_ENCODER(cls_user_get_header_ret)
::decode(time, bl);
DECODE_FINISH(bl);
}
+
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_user_complete_stats_sync_op*>& ls);
};
WRITE_CLASS_ENCODER(cls_user_complete_stats_sync_op)
#include "common/Formatter.h"
#include "common/ceph_json.h"
+void cls_user_gen_test_bucket(cls_user_bucket *bucket, int i)
+{
+ char buf[16];
+ snprintf(buf, sizeof(buf), ".%d", i);
+
+ bucket->name = string("buck") + buf;
+ bucket->data_pool = string(".data.pool") + buf;
+ bucket->index_pool = string(".index.pool") + buf;
+ bucket->marker = string("mark") + buf;
+ bucket->bucket_id = string("bucket.id") + buf;
+}
+
+void cls_user_bucket::dump(Formatter *f) const
+{
+ encode_json("name", name, f);
+ encode_json("data_pool", data_pool,f);
+ encode_json("index_pool", index_pool,f);
+ encode_json("marker", marker,f);
+ encode_json("bucket_id", bucket_id,f);
+}
+
+void cls_user_bucket::generate_test_instances(list<cls_user_bucket*>& ls)
+{
+ ls.push_back(new cls_user_bucket);
+ cls_user_bucket *b = new cls_user_bucket;
+ cls_user_gen_test_bucket(b, 0);
+ ls.push_back(b);
+}
+
+void cls_user_bucket_entry::dump(Formatter *f) const
+{
+ encode_json("bucket", bucket, f);
+ encode_json("size", size, f);
+ encode_json("size_rounded", size_rounded, f);
+ encode_json("creation_time", creation_time, f);
+ encode_json("count", count, f);
+ encode_json("user_stats_sync", user_stats_sync, f);
+}
+
+void cls_user_gen_test_bucket_entry(cls_user_bucket_entry *entry, int i)
+{
+ cls_user_gen_test_bucket(&entry->bucket, i);
+ entry->size = i + 1;
+ entry->size_rounded = i + 2;
+ entry->creation_time = i + 3;
+ entry->count = i + 4;
+ entry->user_stats_sync = true;
+}
+
+void cls_user_bucket_entry::generate_test_instances(list<cls_user_bucket_entry*>& ls)
+{
+ ls.push_back(new cls_user_bucket_entry);
+ cls_user_bucket_entry *entry = new cls_user_bucket_entry;
+ cls_user_gen_test_bucket_entry(entry, 0);
+ ls.push_back(entry);
+}
+
+void cls_user_gen_test_stats(cls_user_stats *s)
+{
+ s->total_entries = 1;
+ s->total_bytes = 2;
+ s->total_bytes_rounded = 3;
+}
void cls_user_stats::dump(Formatter *f) const
{
f->dump_int("total_bytes_rounded", total_bytes_rounded);
}
+void cls_user_stats::generate_test_instances(list<cls_user_stats*>& ls)
+{
+ ls.push_back(new cls_user_stats);
+ cls_user_stats *s = new cls_user_stats;
+ cls_user_gen_test_stats(s);
+ ls.push_back(s);
+}
+
+void cls_user_gen_test_header(cls_user_header *h)
+{
+ cls_user_gen_test_stats(&h->stats);
+ h->last_stats_sync = utime_t(1, 0);
+ h->last_stats_update = utime_t(2, 0);
+}
+
void cls_user_header::dump(Formatter *f) const
{
encode_json("stats", stats, f);
encode_json("last_stats_sync", last_stats_sync, f);
encode_json("last_stats_update", last_stats_update, f);
}
+
+void cls_user_header::generate_test_instances(list<cls_user_header*>& ls)
+{
+ ls.push_back(new cls_user_header);
+ cls_user_header *h = new cls_user_header;
+ cls_user_gen_test_header(h);
+ ls.push_back(h);
+}
bool operator<(const cls_user_bucket& b) const {
return name.compare(b.name) < 0;
}
+
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_user_bucket*>& ls);
};
WRITE_CLASS_ENCODER(cls_user_bucket)
::decode(user_stats_sync, bl);
DECODE_FINISH(bl);
}
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_user_bucket_entry*>& ls);
};
WRITE_CLASS_ENCODER(cls_user_bucket_entry)
}
void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_user_stats*>& ls);
};
WRITE_CLASS_ENCODER(cls_user_stats)
}
void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_user_header*>& ls);
};
WRITE_CLASS_ENCODER(cls_user_header)
+void cls_user_gen_test_bucket(cls_user_bucket *bucket, int i);
+void cls_user_gen_test_bucket_entry(cls_user_bucket_entry *entry, int i);
+void cls_user_gen_test_stats(cls_user_stats *stats);
+void cls_user_gen_test_header(cls_user_header *h);
+
#endif
#include "cls/rgw/cls_rgw_client.h"
TYPE(rgw_bi_log_entry)
+#include "cls/user/cls_user_types.h"
+TYPE(cls_user_bucket)
+TYPE(cls_user_bucket_entry)
+TYPE(cls_user_stats)
+TYPE(cls_user_header)
+
+#include "cls/user/cls_user_ops.h"
+TYPE(cls_user_set_buckets_op)
+TYPE(cls_user_remove_bucket_op)
+TYPE(cls_user_list_buckets_op)
+TYPE(cls_user_list_buckets_ret)
+TYPE(cls_user_get_header_op)
+TYPE(cls_user_get_header_ret)
+TYPE(cls_user_complete_stats_sync_op)
+
#include "rgw/rgw_common.h"
TYPE(RGWAccessKey);
TYPE(RGWSubUser);