How to use the proxmoxer.core.ResourceException function in proxmoxer

To help you get started, we’ve selected a few proxmoxer 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 swayf / proxmoxer / tests / base / base_ssh_suite.py View on Github external
    @raises(ResourceException)
    def test_error_with_extra_output(self):
        self._set_stderr("Extra output\n500 whoops")
        self.proxmox.nodes('proxmox').get()
github swayf / proxmoxer / tests / base / base_ssh_suite.py View on Github external
    @raises(ResourceException)
    def test_error(self):
        self._set_stderr("500 whoops")
        self.proxmox.nodes('proxmox').get()
github swayf / proxmoxer / proxmoxer / core.py View on Github external
def _request(self, method, data=None, params=None):
        url = self._store["base_url"]
        if data:
            logger.info('%s %s %r', method, url, data)
        else:
            logger.info('%s %s', method, url)
        resp = self._store["session"].request(method, url, data=data or None, params=params)
        logger.debug('Status code: %s, output: %s', resp.status_code, resp.content)

        if resp.status_code >= 400:
            raise ResourceException("{0} {1}: {2}".format(resp.status_code, httplib.responses[resp.status_code],
                                                          resp.content))
        elif 200 <= resp.status_code <= 299:
            return self._store["serializer"].loads(resp)
github ComputerScienceHouse / proxstar / proxstar / user.py View on Github external
def vms(self):
        proxmox = connect_proxmox()
        try:
            # try to get the users vms from their pool
            vms = proxmox.pools(self.name).get()['members']
        except ResourceException:
            # they likely don't have a pool yet, try to create it
            if is_user(self.name):
                proxmox.pools.post(
                    poolid=self.name, comment='Managed by Proxstar')
                # if created, their pool is empty so return empty array
                return []
            else:
                return []
        for vm in vms:
            if 'name' not in vm:
                vms.remove(vm)
        vms = sorted(vms, key=lambda k: k['name'])
        return vms