コード例 #1
0
ファイル: apiserver.py プロジェクト: ArcCha/hera
def create_sandbox():
    return get_session().create_sandbox(
        owner=request.forms['owner'],
        memory=int(request.forms['memory']),
        timeout=float(request.forms['timeout']),
        disk=request.forms['disk'],
        whole_node=util.is_true(request.forms.get('whole_node')),
        async=util.is_true(request.forms.get('async')),
        webhook_url=request.forms.get('webhook_url'),
        webhook_secret=request.forms.get('webhook_secret'),
        priority=float(request.forms.get('priority', 0)),
        priority_growth=float(request.forms.get('priority_growth', 0))
    )
コード例 #2
0
ファイル: dispatcher.py プロジェクト: ArcCha/hera
def createvm():
    logger.info('Received createvm request')
    owner = request.form['owner']
    stats = json.loads(request.form['stats'])
    async = util.is_true(request.form['async'])
    async_params = json.loads(request.form['async_params']) if async else None
    try:
        vm_id = create_vm(owner, stats, async=async, async_params=async_params)
    except errors.ResourceNotAvailableError:
        return jsonify({"status": "ResourceNotAvailable"})
    except errors.QueueFull:
        return jsonify({"status": "QueueFull"})
    else:
        return jsonify({"status": "ok", "id": vm_id})