summaryrefslogtreecommitdiffstats
path: root/src/tools/rbd/Schedule.h
blob: bf0964bb1e51b6fd948cf4c730b769cabc176fe1 (plain)
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
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#ifndef CEPH_RBD_SCHEDULE_H
#define CEPH_RBD_SCHEDULE_H

#include "json_spirit/json_spirit.h"

#include <iostream>
#include <list>
#include <map>
#include <string>
#include <boost/program_options.hpp>

namespace ceph { class Formatter; }

namespace rbd {

void add_level_spec_options(
  boost::program_options::options_description *options, bool allow_image=true);
int get_level_spec_args(const boost::program_options::variables_map &vm,
                        std::map<std::string, std::string> *args);
void normalize_level_spec_args(std::map<std::string, std::string> *args);

void add_schedule_options(
  boost::program_options::options_description *positional, bool mandatory);
int get_schedule_args(const boost::program_options::variables_map &vm,
                      bool mandatory, std::map<std::string, std::string> *args);

class Schedule {
public:
  Schedule() {
  }
  
  int parse(json_spirit::mValue &schedule_val);
  void dump(ceph::Formatter *f);

  friend std::ostream& operator<<(std::ostream& os, Schedule &s);

private:
  std::string name;
  std::list<std::pair<std::string, std::string>> items;
};

std::ostream& operator<<(std::ostream& os, Schedule &s);

class ScheduleList {
public:
  ScheduleList(bool allow_images=true) : allow_images(allow_images) {
  }

  int parse(const std::string &list);
  Schedule *find(const std::string &name);
  void dump(ceph::Formatter *f);

  friend std::ostream& operator<<(std::ostream& os, ScheduleList &l);

private:
  bool allow_images;
  std::map<std::string, Schedule> schedules;
};

std::ostream& operator<<(std::ostream& os, ScheduleList &l);

} // namespace rbd

#endif // CEPH_RBD_SCHEDULE_H