Added lxc_conf param to Client.start

This commit is contained in:
shin- 2013-09-12 00:28:11 +02:00
parent e2e5b9e0fd
commit e07e0599e8
2 changed files with 12 additions and 10 deletions

View File

@ -89,13 +89,14 @@ Restart a container. Similar to the `docker restart` command.
* `c.search(term)`
Identical to the `docker search` command.
* `c.start(container, binds=None)`
Identical to the `docker start` command, but doesn't support attach options.
Use `docker logs` to recover `stdout`/`stderr`
* `c.start(container, binds=None, lxc_conf=None)`
Similar to the `docker start` command, but doesn't support attach options.
Use `docker logs` to recover `stdout`/`stderr`
`binds` Allows to bind a directory in the host to the container.
Similar to the `docker run` command with option `-b="/host:/mnt"`.
Similar to the `docker run` command with option `-b="/host:/mnt"`.
Requires the container to be created with the volumes argument:
`c.create_container(..., volumes={'/mnt': {}})`
`c.create_container(..., volumes={'/mnt': {}})`
`lxc_conf` allows to pass LXC configuration options in dict form.
* `c.stop(containers, timeout=10)`
Stops a container. Similar to the `docker stop` command.

View File

@ -413,15 +413,16 @@ class Client(requests.Session):
return self._result(self.get(self._url("/images/search"),
params={'term': term}), True)
def start(self, container, binds=None):
def start(self, container, binds=None, lxc_conf=None):
if isinstance(container, dict):
container = container.get('Id')
start_config = {}
start_config = {
'LxcConf': lxc_conf
}
if binds:
bind_pairs = ['{0}:{1}'.format(host, dest) for host, dest in binds.items()]
start_config = {
'Binds': bind_pairs,
}
start_config['Binds'] = bind_pairs
url = self._url("/containers/{0}/start".format(container))
res = self._post_json(url, start_config)
self._raise_for_status(res)