How to use the pylxd.operation.Operation.wait_for_operation function in pylxd

To help you get started, we’ve selected a few pylxd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lxc / pylxd / pylxd / container.py View on Github external
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()
github lxc / pylxd / pylxd / container.py View on Github external
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'])
github lxc / pylxd / pylxd / container.py View on Github external
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'])
github lxc / pylxd / pylxd / container.py View on Github external
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