Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _set_state(self, state, timeout=30, force=True, wait=False):
response = self.api.state.put(json={
'action': state,
'timeout': timeout,
'force': force
})
if wait:
Operation.wait_for_operation(
self.client, response.json()['operation'])
self.sync()
def create(cls, client, config, wait=False):
"""Create a new container config."""
response = client.api.containers.post(json=config)
if wait:
Operation.wait_for_operation(client, response.json()['operation'])
return cls(client, name=config['name'])
method does not enforce that constraint, so a LXDAPIException may be
raised if this method is called on a running container.
If wait=True, an Image is returned.
"""
data = {
'public': public,
'source': {
'type': 'container',
'name': self.name,
}
}
response = self.client.api.images.post(json=data)
if wait:
operation = Operation.wait_for_operation(
self.client, response.json()['operation'])
return self.client.images.get(operation.metadata['fingerprint'])
def rename(self, name, wait=False):
"""Rename a container."""
response = self.api.post(json={'name': name})
if wait:
Operation.wait_for_operation(
self.client, response.json()['operation'])
self.name = name