softwarecontainer  0.18.0-739e8d7 2017-05-04
containerabstractinterface.h
1 /*
2  * Copyright (C) 2016-2017 Pelagicore AB
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
9  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
10  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
11  * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
12  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
13  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
14  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
15  * SOFTWARE.
16  *
17  * For further information see LICENSE
18  */
19 
20 
21 #pragma once
22 
23 #include "softwarecontainer-common.h"
24 #include "executable.h"
25 
26 namespace softwarecontainer {
27 
29 {
30 
31 public:
32 
33  virtual ~ContainerAbstractInterface() {};
34  virtual const char *id() const = 0;
35 
36  virtual bool initialize() = 0;
37  virtual bool create() = 0;
38  virtual bool start(pid_t *pid) = 0;
39  virtual bool stop() = 0;
40 
41  virtual bool shutdown() = 0;
42  virtual bool shutdown(unsigned int timeout) = 0;
43 
44  virtual bool suspend() = 0;
45  virtual bool resume() = 0;
46 
47  virtual bool destroy() = 0;
48  virtual bool destroy(unsigned int timeout) = 0;
49 
50  virtual bool mountDevice(const std::string &pathInHost) = 0;
51 
63  virtual bool bindMountInContainer(const std::string &pathInHost,
64  const std::string &pathInContainer,
65  bool readOnly = true) = 0;
66 
67  virtual bool setEnvironmentVariable(const std::string &variable, const std::string &value) = 0;
68  virtual bool setCgroupItem(std::string subsys, std::string value) = 0;
69 };
70 
71 } // namespace softwarecontainer
virtual bool bindMountInContainer(const std::string &pathInHost, const std::string &pathInContainer, bool readOnly=true)=0
Tries to bind mount a path from host to container.
Developers guide to adding a config item: