コード例 #1
0
ファイル: container.py プロジェクト: alexk307/pylxd
    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(name=config['name'])
コード例 #2
0
 def rename(self, new_name, wait=False):
     """Rename a snapshot."""
     response = self.api.post(json={'name': new_name})
     if wait:
         Operation.wait_for_operation(self.client,
                                      response.json()['operation'])
     self.name = new_name
コード例 #3
0
ファイル: container.py プロジェクト: fabfurnari/pylxd
    def delete(self, wait=False):
        """Delete the container."""
        response = self._client.api.containers[self.name].delete()

        if wait:
            Operation.wait_for_operation(
                self._client, response.json()['operation'])
コード例 #4
0
ファイル: container.py プロジェクト: stgraber/pylxd
    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(name=config["name"])
コード例 #5
0
ファイル: container.py プロジェクト: moreati/pylxd
    def delete(self, wait=False):
        """Delete the container."""
        response = self._client.api.containers[self.name].delete()

        if wait:
            Operation.wait_for_operation(self._client,
                                         response.json()['operation'])
コード例 #6
0
ファイル: image.py プロジェクト: fabfurnari/pylxd
    def delete(self, wait=False):
        """Delete the image."""
        response = self._client.api.images[self.fingerprint].delete()

        if wait:
            Operation.wait_for_operation(
                self._client, response.json()['operation'])
コード例 #7
0
ファイル: container.py プロジェクト: ahmadfaizalbh/pylxd
 def rename(self, new_name, wait=False):
     """Rename a snapshot."""
     response = self.api.post(json={'name': new_name})
     if wait:
         Operation.wait_for_operation(
             self.client, response.json()['operation'])
     self.name = new_name
コード例 #8
0
    def delete(self, wait=False):
        """Delete the image."""
        response = self._client.api.images[self.fingerprint].delete()

        if wait:
            Operation.wait_for_operation(self._client,
                                         response.json()['operation'])
コード例 #9
0
    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
コード例 #10
0
ファイル: container.py プロジェクト: ahmadfaizalbh/pylxd
    def create(cls, client, container, name, stateful=False, wait=False):
        response = client.api.containers[container.name].snapshots.post(json={
            'name': name, 'stateful': stateful})

        snapshot = cls(client, container=container, name=name)
        if wait:
            Operation.wait_for_operation(client, response.json()['operation'])
        return snapshot
コード例 #11
0
ファイル: container.py プロジェクト: ahmadfaizalbh/pylxd
    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
コード例 #12
0
ファイル: model.py プロジェクト: ahmadfaizalbh/pylxd
    def delete(self, wait=False):
        """Delete an object from the server."""
        response = self.api.delete()

        if response.json()['type'] == 'async' and wait:
            Operation.wait_for_operation(
                self.client, response.json()['operation'])
        self.client = None
コード例 #13
0
ファイル: model.py プロジェクト: codersquid/pylxd
    def delete(self, wait=False):
        """Delete an object from the server."""
        response = self.api.delete()

        if response.json()['type'] == 'async' and wait:
            Operation.wait_for_operation(self.client,
                                         response.json()['operation'])
        self.client = None
コード例 #14
0
ファイル: container.py プロジェクト: bbrcan/pylxd
    def create(cls, client, config, wait=False):
        """Create a new container config."""
        response = client.api.containers.post(json=config)

        if response.status_code != 202:
            raise exceptions.CreateFailed(response.json())
        if wait:
            Operation.wait_for_operation(client, response.json()['operation'])
        return cls(name=config['name'], _client=client)
コード例 #15
0
ファイル: container.py プロジェクト: ahmadfaizalbh/pylxd
 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()
コード例 #16
0
    def create(cls, client, config, wait=False):
        """Create a new container config."""
        try:
            response = client.api.containers.post(json=config)
        except exceptions.LXDAPIException as e:
            raise exceptions.CreateFailed(e.response)

        if wait:
            Operation.wait_for_operation(client, response.json()['operation'])
        return cls(client, name=config['name'])
コード例 #17
0
ファイル: container.py プロジェクト: fabfurnari/pylxd
    def create(cls, client, config, wait=False):
        """Create a new container config."""
        try:
            response = client.api.containers.post(json=config)
        except exceptions.LXDAPIException as e:
            raise exceptions.CreateFailed(e.response)

        if wait:
            Operation.wait_for_operation(client, response.json()['operation'])
        return cls(name=config['name'], _client=client)
コード例 #18
0
 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()
コード例 #19
0
ファイル: container.py プロジェクト: fabfurnari/pylxd
 def _set_state(self, state, timeout=30, force=True, wait=False):
     response = self._client.api.containers[self.name].state.put(json={
         'action': state,
         'timeout': timeout,
         'force': force
     })
     if wait:
         Operation.wait_for_operation(
             self._client, response.json()['operation'])
         self.fetch()
コード例 #20
0
    def create(cls, client, container, name, stateful=False, wait=False):
        response = client.api.containers[container.name].snapshots.post(
            json={
                'name': name,
                'stateful': stateful
            })

        snapshot = cls(client, container=container, name=name)
        if wait:
            Operation.wait_for_operation(client, response.json()['operation'])
        return snapshot
コード例 #21
0
ファイル: container.py プロジェクト: moreati/pylxd
 def _set_state(self, state, timeout=30, force=True, wait=False):
     response = self._client.api.containers[self.name].state.put(
         json={
             'action': state,
             'timeout': timeout,
             'force': force
         })
     if wait:
         Operation.wait_for_operation(self._client,
                                      response.json()['operation'])
         self.fetch()
コード例 #22
0
    def create(cls, client, image_data, public=False, wait=False):
        """Create an image."""
        fingerprint = hashlib.sha256(image_data).hexdigest()

        headers = {}
        if public:
            headers['X-LXD-Public'] = '1'
        response = client.api.images.post(data=image_data, headers=headers)

        if wait:
            Operation.wait_for_operation(client, response.json()['operation'])
        return cls.get(client, fingerprint)
コード例 #23
0
ファイル: image.py プロジェクト: Cubx/pylxd
    def create(cls, client, image_data, public=False, wait=False):
        """Create an image."""
        fingerprint = hashlib.sha256(image_data).hexdigest()

        headers = {}
        if public:
            headers['X-LXD-Public'] = '1'
        response = client.api.images.post(
            data=image_data, headers=headers)

        if wait:
            Operation.wait_for_operation(client, response.json()['operation'])
        return cls.get(client, fingerprint)
コード例 #24
0
ファイル: model.py プロジェクト: ahmadfaizalbh/pylxd
    def save(self, wait=False):
        """Save data to the server.

        This method should write the new data to the server via marshalling.
        It should be a no-op when the object is not dirty, to prevent needless
        I/O.
        """
        marshalled = self.marshall()
        response = self.api.put(json=marshalled)

        if response.json()['type'] == 'async' and wait:
            Operation.wait_for_operation(
                self.client, response.json()['operation'])
        del self.__dirty__[:]
コード例 #25
0
ファイル: model.py プロジェクト: codersquid/pylxd
    def save(self, wait=False):
        """Save data to the server.

        This method should write the new data to the server via marshalling.
        It should be a no-op when the object is not dirty, to prevent needless
        I/O.
        """
        marshalled = self.marshall()
        response = self.api.put(json=marshalled)

        if response.json()['type'] == 'async' and wait:
            Operation.wait_for_operation(self.client,
                                         response.json()['operation'])
        del self.__dirty__[:]
コード例 #26
0
ファイル: container.py プロジェクト: moreati/pylxd
    def update(self, wait=False):
        """Update the container in lxd from local changes."""
        try:
            marshalled = self.marshall()
        except AttributeError:
            raise exceptions.ObjectIncomplete()
        # These two properties are explicitly not allowed.
        del marshalled['name']
        del marshalled['status']

        response = self._client.api.containers[self.name].put(json=marshalled)

        if wait:
            Operation.wait_for_operation(self._client,
                                         response.json()['operation'])
コード例 #27
0
    def create(cls, client, image_data, public=False, wait=False):
        """Create an image."""
        fingerprint = hashlib.sha256(image_data).hexdigest()

        headers = {}
        if public:
            headers['X-LXD-Public'] = '1'
        try:
            response = client.api.images.post(data=image_data, headers=headers)
        except exceptions.LXDAPIException as e:
            raise exceptions.CreateFailed(e.response.json())

        if wait:
            Operation.wait_for_operation(client, response.json()['operation'])
        return cls(_client=client, fingerprint=fingerprint)
コード例 #28
0
ファイル: image.py プロジェクト: fabfurnari/pylxd
    def create(cls, client, image_data, public=False, wait=False):
        """Create an image."""
        fingerprint = hashlib.sha256(image_data).hexdigest()

        headers = {}
        if public:
            headers['X-LXD-Public'] = '1'
        try:
            response = client.api.images.post(
                data=image_data, headers=headers)
        except exceptions.LXDAPIException as e:
            raise exceptions.CreateFailed(e.response.json())

        if wait:
            Operation.wait_for_operation(client, response.json()['operation'])
        return cls(_client=client, fingerprint=fingerprint)
コード例 #29
0
ファイル: container.py プロジェクト: fabfurnari/pylxd
    def update(self, wait=False):
        """Update the container in lxd from local changes."""
        try:
            marshalled = self.marshall()
        except AttributeError:
            raise exceptions.ObjectIncomplete()
        # These two properties are explicitly not allowed.
        del marshalled['name']
        del marshalled['status']

        response = self._client.api.containers[self.name].put(
            json=marshalled)

        if wait:
            Operation.wait_for_operation(
                self._client, response.json()['operation'])