How to use the pylxd.deprecated.exceptions.PyLXDException 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 / deprecated / connection.py View on Github external
def get_raw(self, *args, **kwargs):
        response = self._request(*args, **kwargs)

        if not response.body:
            raise exceptions.PyLXDException('Null Body')
        elif response.status == 200:
            return response.body
        else:
            raise exceptions.PyLXDException('Failed to get raw response')
github lxc / pylxd / pylxd / deprecated / connection.py View on Github external
def get_raw(self, *args, **kwargs):
        response = self._request(*args, **kwargs)

        if not response.body:
            raise exceptions.PyLXDException('Null Body')
        elif response.status == 200:
            return response.body
        else:
            raise exceptions.PyLXDException('Failed to get raw response')
github lxc / pylxd / pylxd / deprecated / connection.py View on Github external
def get_object(self, *args, **kwargs):
        response = self._request(*args, **kwargs)

        if not response.json:
            raise exceptions.PyLXDException('Null Data')
        elif response.status == 200 or (
                response.status == 202 and
                response.json.get('status_code') == 100):
            return response.status, response.json
        else:
            utils.get_lxd_error(response.status, response.json)
github lxc / pylxd / pylxd / deprecated / hosts.py View on Github external
def host_ping(self):
        try:
            return self.connection.get_status('GET', '/1.0')
        except Exception as e:
            msg = 'LXD service is unavailable. %s' % e
            raise exceptions.PyLXDException(msg)
github lxc / pylxd / pylxd / deprecated / container.py View on Github external
def container_defined(self, container):
        _, data = self.connection.get_object('GET', '/1.0/containers')
        try:
            containers = data["metadata"]
        except KeyError:
            raise exceptions.PyLXDException("no metadata in GET containers?")

        container_url = "/1.0/containers/%s" % container
        for ct in containers:
            if ct == container_url:
                return True
        return False
github lxc / pylxd / pylxd / deprecated / hosts.py View on Github external
def get_certificate(self):
        try:
            (state, data) = self.connection.get_object('GET', '/1.0')
            data = data.get('metadata')
            return data['environment']['certificate']
        except exceptions.PyLXDException as e:
            print('Handling run-time error: {}'.format(e))
github lxc / pylxd / pylxd / deprecated / connection.py View on Github external
def get_status(self, *args, **kwargs):
        response = self._request(*args, **kwargs)

        if not response.json:
            raise exceptions.PyLXDException('Null Data')
        elif response.json.get('error'):
            utils.get_lxd_error(response.status, response.json)
        elif response.status == 200 or (
                response.status == 202 and
                response.json.get('status_code') == 100):
            return True
        return False