Exemplo n.º 1
0
def launch():
    profile = UserProfile.get_or_create()
    reqs = get_requirements()
    obj = LaunchFormData(reqs, **request.args)
    form = LaunchForm(obj=obj, user_profile=profile)
    form.fill_fields_choices(reqs)

    if form.validate_on_submit():
        client = infra.get_client(profile.user_proxy)
        image = reqs['images'][form.image.data]['image-id']
        flavor = reqs['flavors'][form.flavor.data]['flavor-id']
        app_env = reqs['app_envs'][form.app_env.data]['app-id']
        current_app.logger.debug("%s %s %s", image, flavor, app_env)
        try:
            infra.launch_vm(client,
                            name=form.name.data,
                            image=image,
                            flavor=flavor,
                            app_env=app_env,
                            recid=form.recid.data,
                            ssh_key=profile.ssh_public_key)
            return redirect(url_for('.index'))
        except infra.InfraException as e:
            flash(e.message, 'error')

    ctx = dict(
        form=form,
        flavors=reqs['flavors'],
    )
    return render_template('analyze/launch.html', **ctx)
Exemplo n.º 2
0
def launch():
    profile = UserProfile.get_or_create()
    reqs = get_requirements()
    obj = LaunchFormData(reqs, **request.args)
    form = LaunchForm(obj=obj, user_profile=profile)
    form.fill_fields_choices(reqs)

    if form.validate_on_submit():
        client = infra.get_client(profile.user_proxy)
        image = reqs['images'][form.image.data]['image-id']
        flavor = reqs['flavors'][form.flavor.data]['flavor-id']
        app_env = reqs['app_envs'][form.app_env.data]['app-id']
        current_app.logger.debug("%s %s %s", image, flavor, app_env)
        try:
            infra.launch_vm(client,
                            name=form.name.data,
                            image=image,
                            flavor=flavor,
                            app_env=app_env,
                            recid=form.recid.data,
                            ssh_key=profile.ssh_public_key)
            return redirect(url_for('.index'))
        except infra.InfraException as e:
            flash(e.message, 'error')

    ctx = dict(
        form=form,
        flavors=reqs['flavors'],
    )
    return render_template('analyze/launch.html', **ctx)
Exemplo n.º 3
0
def index():
    profile = UserProfile.get_or_create()
    ctx = {}
    try:
        client = infra.get_client(profile.user_proxy)
        ctx['vms'] = infra.list_vms(client)
    except infra.InfraException as e:
        flash(e.message, 'error')
    return render_template('analyze/index.html', **ctx)
Exemplo n.º 4
0
def index():
    profile = UserProfile.get_or_create()
    ctx = {}
    try:
        client = infra.get_client(profile.user_proxy)
        ctx['vms'] = infra.list_vms(client)
    except infra.InfraException as e:
        flash(e.message, 'error')
    return render_template('analyze/index.html', **ctx)
Exemplo n.º 5
0
def connect(vm_id):
    profile = UserProfile.get_or_create()
    client = infra.get_client(profile.user_proxy)
    return jsonify(infra.get_vm_connection(client, vm_id))
Exemplo n.º 6
0
def terminate(vm_id):
    profile = UserProfile.get_or_create()
    client = infra.get_client(profile.user_proxy)
    infra.terminate_vm(client, vm_id)
    return redirect(url_for('.index'))
Exemplo n.º 7
0
def connect(vm_id):
    profile = UserProfile.get_or_create()
    client = infra.get_client(profile.user_proxy)
    return jsonify(infra.get_vm_connection(client, vm_id))
Exemplo n.º 8
0
def terminate(vm_id):
    profile = UserProfile.get_or_create()
    client = infra.get_client(profile.user_proxy)
    infra.terminate_vm(client, vm_id)
    return redirect(url_for('.index'))