Пример #1
0
def RESTGetInfrastructureInfo(id=None):
    try:
        auth = get_auth_header()
    except:
        return return_error(401, "No authentication data provided")

    try:
        vm_ids = InfrastructureManager.GetInfrastructureInfo(id, auth)
        res = []

        protocol = "http://"
        if Config.REST_SSL:
            protocol = "https://"
        for vm_id in vm_ids:
            res.append(protocol + bottle.request.environ[
                       'HTTP_HOST'] + '/infrastructures/' + str(id) + '/vms/' + str(vm_id))

        return format_output(res, "text/uri-list", "uri-list", "uri")
    except DeletedInfrastructureException as ex:
        return return_error(404, "Error Getting Inf. info: " + str(ex))
    except IncorrectInfrastructureException as ex:
        return return_error(404, "Error Getting Inf. info: " + str(ex))
    except UnauthorizedUserException as ex:
        return return_error(403, "Error Getting Inf. info: " + str(ex))
    except Exception as ex:
        logger.exception("Error Getting Inf. info")
        return return_error(400, "Error Getting Inf. info: " + str(ex))
Пример #2
0
def RESTGetInfrastructureInfo(infid=None):
    try:
        auth = get_auth_header()
    except:
        return return_error(401, "No authentication data provided")

    try:
        vm_ids = InfrastructureManager.GetInfrastructureInfo(infid, auth)
        res = []

        for vm_id in vm_ids:
            res.append(
                get_full_url('/infrastructures/' + str(infid) + '/vms/' +
                             str(vm_id)))

        return format_output(res, "text/uri-list", "uri-list", "uri")
    except DeletedInfrastructureException as ex:
        return return_error(404, "Error Getting Inf. info: %s" % ex.args[0])
    except IncorrectInfrastructureException as ex:
        return return_error(404, "Error Getting Inf. info: %s" % ex.args[0])
    except UnauthorizedUserException as ex:
        return return_error(403, "Error Getting Inf. info: %s" % ex.args[0])
    except Exception as ex:
        logger.exception("Error Getting Inf. info")
        return return_error(400, "Error Getting Inf. info: %s" % ex.args[0])
Пример #3
0
    def test_inf_removeresources(self):
        """Deploy 4 VMs and remove 2"""
        radl = RADL()
        radl.add(
            system("s0", [
                Feature("disk.0.image.url", "=", "mock0://linux.for.ev.er"),
                Feature("disk.0.os.credentials.username", "=", "user"),
                Feature("disk.0.os.credentials.password", "=", "pass")
            ]))
        radl.add(deploy("s0", 4))

        auth0 = self.getAuth([0], [], [("Dummy", 0)])
        infId = IM.CreateInfrastructure(str(radl), auth0)
        cont = IM.RemoveResource(infId, ['0', '1'], auth0)
        self.assertEqual(cont, 2)
        vms = IM.GetInfrastructureInfo(infId, auth0)
        self.assertEqual(sorted(vms), ['2', '3'])

        IM.DestroyInfrastructure(infId, auth0)