summaryrefslogtreecommitdiff
path: root/src/lbdecision.hh
blob: e4b53789b27b7cd86874f2df881377a704173f95 (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
/*
 * Module: lbdecision.hh
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation.
 */
#ifndef __LBDECISION_HH__
#define __LBDECISION_HH__

#include <map>
#include <string>
#include "lbdata.hh"

using namespace std;

class LBDecision
{
public:
  LBDecision(bool debug);
  ~LBDecision();

  void
  init(LBData &lbdata);

  void
  update_paths(LBData &lbdata);

  void
  run(LBData &lbdata);

  void
  shutdown(LBData &lbdata);

private:
  int
  execute(string cmd, string &stdout, bool read = false);

  void
  insert_default(LBHealth &h, string &nexthop);

  map<string,float> 
  get_new_weights(LBData &data, LBRule &rule);

  string
  get_application_cmd(LBRule &rule, bool local = false, bool exclude = false);

  string
  fetch_iface_addr(const string &iface);

  string
  fetch_iface_nexthop(const string &iface);

  string
  get_limit_cmd(LBRule &rule);

private:
  bool _debug;
};

#endif //__LBDECISION_HH__