fhq-server  v0.2.33
Documentation for fhq-server. FreeHackQuest is an open source platform for competitions of computer security.
employ_orchestra.h
Go to the documentation of this file.
1 #ifndef EMPLOY_ORCHESTRA
2 #define EMPLOY_ORCHESTRA
3 
4 #include <employees.h>
5 #include <model_lxd_orchestra.h>
6 
7 #include <list>
8 #include <string>
9 #include <map>
10 #include <curl/curl.h>
11 #include <future>
12 
13 
15 public:
17 
18  static std::string name() { return "EmployOrchestra"; }
19 
20  virtual bool init() override;
21  virtual bool deinit() override;
22 
23  bool initConnection();
24  bool create_container(const std::string &sName, std::string &sError);
25  bool create_service(const ServiceConfig &serviceReq, std::string &sError);
26  bool create_service(const nlohmann::json &jsonConfig, std::string &sError);
27  bool check_response(const nlohmann::json &jsonResponse, std::string &sError);
28  bool find_container(const std::string &sName, LXDContainer *&pContainer);
29  bool find_service(const std::string &sName, ServiceLXD *&pService);
30  bool remove_container(const std::string &sName, std::string &sError);
31  bool get_all_profiles(std::vector<std::string> &vecProfiles, std::string &sError);
32  bool find_profile(const std::string &sName, std::string &sError);
33  bool send_post_request_file(const std::string &sUrl, const std::string &sFile, std::string &sResponse,
34  std::string &sError);
35  bool send_post_request(const std::string &sUrl, const nlohmann::json &jsonData, nlohmann::json &jsonResponse,
36  std::string &sError);
37  bool send_patch_request(const std::string &sUrl, const nlohmann::json &jsonData, nlohmann::json &jsonResponse,
38  std::string &sError);
39  bool send_put_request(const std::string &sUrl, const nlohmann::json &jsonData, nlohmann::json &jsonResponse,
40  std::string &sError);
41  bool send_get_request(const std::string &sUrl, nlohmann::json &jsonResponse, std::string &sError);
42  bool send_get_request(const std::string &sUrl, std::string &sResponse, std::string &sError);
43  bool send_get_request_raw(const std::string &sUrl, std::string &sResponse, std::string &sError);
44  bool send_delete_request(const std::string &sUrl, nlohmann::json &jsonResponse, std::string &sError);
45 
46  std::list<std::string> registry_names();
47  std::string lastError();
48 
49 private:
50  std::map<std::string, LXDContainer *> m_mapContainers;
51  std::map<std::string, ServiceLXD *> m_mapServices;
52  std::string m_sPathDirLxcSSL;
53  std::string m_sLxdAddress;
54  std::string m_sLastError;
55  std::string TAG;
56 
57  bool m_bTrusted;
58 
59  bool pull_container_names();
60 };
61 
62 #endif // EMPLOY_ORCHESTRA
63 
bool remove_container(const std::string &sName, std::string &sError)
Definition: employ_orchestra.cpp:549
bool send_put_request(const std::string &sUrl, const nlohmann::json &jsonData, nlohmann::json &jsonResponse, std::string &sError)
Definition: employ_orchestra.cpp:325
bool create_service(const ServiceConfig &serviceReq, std::string &sError)
Definition: employ_orchestra.cpp:104
bool send_get_request_raw(const std::string &sUrl, std::string &sResponse, std::string &sError)
Definition: employ_orchestra.cpp:375
bool send_get_request(const std::string &sUrl, nlohmann::json &jsonResponse, std::string &sError)
Definition: employ_orchestra.cpp:412
static std::string name()
Definition: employ_orchestra.h:18
bool send_delete_request(const std::string &sUrl, nlohmann::json &jsonResponse, std::string &sError)
Definition: employ_orchestra.cpp:435
std::map< std::string, ServiceLXD * > m_mapServices
Definition: employ_orchestra.h:51
std::string m_sLastError
Definition: employ_orchestra.h:54
Definition: model_lxd_orchestra.h:10
std::string lastError()
Definition: employ_orchestra.cpp:79
bool send_patch_request(const std::string &sUrl, const nlohmann::json &jsonData, nlohmann::json &jsonResponse, std::string &sError)
Definition: employ_orchestra.cpp:275
bool initConnection()
Definition: employ_orchestra.cpp:69
std::list< std::string > registry_names()
Definition: employ_orchestra.cpp:573
virtual bool init() override
Definition: employ_orchestra.cpp:36
virtual bool deinit() override
Definition: employ_orchestra.cpp:62
std::string TAG
Definition: employ_orchestra.h:55
bool find_service(const std::string &sName, ServiceLXD *&pService)
Definition: employ_orchestra.cpp:135
Definition: wsjcpp_employees.h:13
std::string m_sLxdAddress
Definition: employ_orchestra.h:53
Definition: model_lxd_orchestra.h:26
EmployOrchestra()
Definition: employ_orchestra.cpp:20
bool pull_container_names()
Definition: employ_orchestra.cpp:481
Definition: employ_orchestra.h:14
std::string m_sPathDirLxcSSL
Definition: employ_orchestra.h:52
std::map< std::string, LXDContainer * > m_mapContainers
Definition: employ_orchestra.h:50
bool send_post_request(const std::string &sUrl, const nlohmann::json &jsonData, nlohmann::json &jsonResponse, std::string &sError)
Definition: employ_orchestra.cpp:227
bool find_container(const std::string &sName, LXDContainer *&pContainer)
Definition: employ_orchestra.cpp:126
bool m_bTrusted
Definition: employ_orchestra.h:57
bool get_all_profiles(std::vector< std::string > &vecProfiles, std::string &sError)
Definition: employ_orchestra.cpp:144
Definition: model_lxd_orchestra.h:66
bool create_container(const std::string &sName, std::string &sError)
Definition: employ_orchestra.cpp:85
bool send_post_request_file(const std::string &sUrl, const std::string &sFile, std::string &sResponse, std::string &sError)
Definition: employ_orchestra.cpp:182
bool find_profile(const std::string &sName, std::string &sError)
Definition: employ_orchestra.cpp:161
bool check_response(const nlohmann::json &jsonResponse, std::string &sError)
Definition: employ_orchestra.cpp:522