forked from yandex/porto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibporto.hpp
107 lines (84 loc) · 3.35 KB
/
libporto.hpp
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#pragma once
#include <map>
#include <vector>
#include <string>
#include <memory>
namespace Porto {
struct Property {
std::string Name;
std::string Description;
};
struct Volume {
std::string Path;
std::map<std::string, std::string> Properties;
std::vector<std::string> Containers;
};
struct GetResponse {
std::string Value;
int Error;
std::string ErrorMsg;
};
class Connection {
class ConnectionImpl;
std::unique_ptr<ConnectionImpl> Impl;
Connection(const Connection&) = delete;
void operator=(const Connection&) = delete;
public:
Connection();
~Connection();
/* each rpc call does auto-connect/reconnect */
int Connect();
void Close();
/* request timeout in seconds */
int SetTimeout(int timeout);
int Create(const std::string &name);
int CreateWeakContainer(const std::string &name);
int Destroy(const std::string &name);
int Start(const std::string &name);
int Stop(const std::string &name);
int Kill(const std::string &name, int sig);
int Pause(const std::string &name);
int Resume(const std::string &name);
int WaitContainers(const std::vector<std::string> &containers,
std::string &name, int timeout);
int List(std::vector<std::string> &clist);
int Plist(std::vector<Property> &list);
int Dlist(std::vector<Property> &list);
int Get(const std::vector<std::string> &name,
const std::vector<std::string> &variable,
std::map<std::string, std::map<std::string, GetResponse>> &result);
int GetProperty(const std::string &name,
const std::string &property, std::string &value);
int SetProperty(const std::string &name,
const std::string &property, std::string value);
int GetData(const std::string &name,
const std::string &data, std::string &value);
int GetVersion(std::string &tag, std::string &revision);
int Raw(const std::string &message, std::string &response);
void GetLastError(int &error, std::string &msg) const;
int ListVolumeProperties(std::vector<Property> &list);
int CreateVolume(const std::string &path,
const std::map<std::string, std::string> &config,
Volume &result);
int CreateVolume(std::string &path,
const std::map<std::string, std::string> &config);
int LinkVolume(const std::string &path,
const std::string &container = std::string());
int UnlinkVolume(const std::string &path,
const std::string &container = std::string());
int ListVolumes(const std::string &path, const std::string &container,
std::vector<Volume> &volumes);
int ListVolumes(std::vector<Volume> &volumes) {
return ListVolumes(std::string(), std::string(), volumes);
}
int TuneVolume(const std::string &path,
const std::map<std::string, std::string> &config);
int ImportLayer(const std::string &layer, const std::string &tarball,
bool merge = false);
int ExportLayer(const std::string &volume, const std::string &tarball);
int RemoveLayer(const std::string &layer);
int ListLayers(std::vector<std::string> &layers);
int ConvertPath(const std::string &path, const std::string &src,
const std::string &dest, std::string &res);
};
} /* namespace Porto */