Пример #1
0
        # NOTE(apugachev) for big this will fail to load and BrokenPipe
        # will be raised inside Flask
        return flask.jsonify({})

    @bp.route('progress/<uploaded_filename>/')
    def progress(uploaded_filename):
        r = flask.current_app.cache.get(uploaded_filename)
        return flask.jsonify(r or {})

    @bp.route('<image_id>/delete/', methods=['POST'])
    def delete(image_id):
        image = clients.admin_clients().glance.images.get(image_id)
        owner = getattr(image, 'owner')
        if owner == clients.get_systenant_id():
            principal.Permission(('role', 'admin')).test()
        else:
            principal.Permission(('role', 'member', owner)).test()
        form = forms.DeleteForm()
        if form.validate_on_submit():
            image.delete()
            flask.flash('Image successfully deleted', 'success')
        else:
            flask.flash('Invalid form', 'error')
        return flask.redirect(flask.url_for('.index'))

    return bp


ABP = environments.admin(get_bp('global_images'))
PBP = environments.project(get_bp('project_images'))
Пример #2
0
                group_id = None
                cidr = form.cidr.data
            try:
                (clients.user_clients(flask.g.tenant_id).
                 compute.security_group_rules.create(
                        security_group_id,
                        form.ip_protocol.data,
                        form.from_port.data,
                        form.to_port.data,
                        cidr,
                        group_id))
            except exceptions.HttpException as ex:
                flask.flash(ex.message, 'error')
            else:
                flask.flash('Security group rule successfully added',
                            'success')
                return flask.redirect(flask.url_for(
                        '.show', security_group_id=security_group_id))

        return {
            'form': form,
            'security_group_id': security_group_id,
            'title': bp.name.replace('global_', '').replace('_', ' ').capitalize(),
            'subtitle': 'Add new rule'
        }

    return bp


PBP = environments.project(get_bp('project_security_groups'))
Пример #3
0
            except ValueError:
                group_id = None
                cidr = form.cidr.data
            try:
                (clients.user_clients(
                    flask.g.tenant_id).compute.security_group_rules.create(
                        security_group_id, form.ip_protocol.data,
                        form.from_port.data, form.to_port.data, cidr,
                        group_id))
            except exceptions.HttpException as ex:
                flask.flash(ex.message, 'error')
            else:
                flask.flash('Security group rule successfully added',
                            'success')
                return flask.redirect(
                    flask.url_for('.show',
                                  security_group_id=security_group_id))

        return {
            'form': form,
            'security_group_id': security_group_id,
            'title': bp.name.replace('global_', '').replace('_',
                                                            ' ').capitalize(),
            'subtitle': 'Add new rule'
        }

    return bp


PBP = environments.project(get_bp('project_security_groups'))
Пример #4
0
import re

import flask
from flask import blueprints

from focus import clients
from focus.views import forms
from focus.views import generic_billing
from focus.views import pagination
from focus.views import utils as views_utils
from focus.views import environments
from focus.views.blueprints import images

from openstackclient_base.exceptions import NotFound

bp = environments.project(blueprints.Blueprint('project_views', __name__))


@bp.route('')
def show_tenant():
    """
    List VMs for the project
    """
    c = clients.user_clients(flask.g.tenant_id)
    servers = c.compute.servers.list(detailed=True)
    vms_data = [s._info for s in servers]
    vms_data = sorted(vms_data, key=lambda x: x['name'])
    p = pagination.Pagination(vms_data)
    data = p.slice(vms_data)
    user_id2name = {}
    uuid_regex = re.compile(
Пример #5
0
# <http://www.gnu.org/licenses/>.


import re
import flask
from flask import blueprints
from flask import Response

from focus import clients
from focus.views import forms
from focus.views import environments

from openstackclient_base.exceptions import HttpException


bp = environments.project(blueprints.Blueprint('ssh_keys', __name__))


@bp.route('')
def index():
    c = clients.user_clients(flask.g.tenant_id)
    context = {
        'keys': c.nova.keypairs.list(),
        'delete_form': forms.DeleteForm(),
        'title': bp.name.replace('_', ' '),
        'subtitle': 'List of SSH keys'
    }
    return context


@bp.route('create/', methods=['GET', 'POST'])
Пример #6
0
import re

import flask
from flask import blueprints

from focus import clients
from focus.views import forms
from focus.views import generic_billing
from focus.views import pagination
from focus.views import utils as views_utils
from focus.views import environments
from focus.views.blueprints import images

from openstackclient_base.exceptions import NotFound

bp = environments.project(blueprints.Blueprint('project_views', __name__))


@bp.route('')
def show_tenant():
    """
    List VMs for the project
    """
    c = clients.user_clients(flask.g.tenant_id)
    servers = c.compute.servers.list(detailed=True)
    vms_data = [s._info for s in servers]
    vms_data = sorted(vms_data, key=lambda x: x['name'])
    p = pagination.Pagination(vms_data)
    data = p.slice(vms_data)
    user_id2name = {}
    uuid_regex = re.compile(
Пример #7
0
# You should have received a copy of the GNU Lesser General Public
# License along with this program. If not, see
# <http://www.gnu.org/licenses/>.

import re
import flask
from flask import blueprints
from flask import Response

from focus import clients
from focus.views import forms
from focus.views import environments

from openstackclient_base.exceptions import HttpException

bp = environments.project(blueprints.Blueprint('ssh_keys', __name__))


@bp.route('')
def index():
    c = clients.user_clients(flask.g.tenant_id)
    context = {
        'keys': c.nova.keypairs.list(),
        'delete_form': forms.DeleteForm(),
        'title': bp.name.replace('_', ' '),
        'subtitle': 'List of SSH keys'
    }
    return context


@bp.route('create/', methods=['GET', 'POST'])
Пример #8
0
        # NOTE(apugachev) for big this will fail to load and BrokenPipe
        # will be raised inside Flask
        return flask.jsonify({})

    @bp.route('progress/<uploaded_filename>/')
    def progress(uploaded_filename):
        r = flask.current_app.cache.get(uploaded_filename)
        return flask.jsonify(r or {})

    @bp.route('<image_id>/delete/', methods=['POST'])
    def delete(image_id):
        image = clients.admin_clients().glance.images.get(image_id)
        owner = getattr(image, 'owner')
        if owner == clients.get_systenant_id():
            principal.Permission(('role', 'admin')).test()
        else:
            principal.Permission(('role', 'member', owner)).test()
        form = forms.DeleteForm()
        if form.validate_on_submit():
            image.delete()
            flask.flash('Image successfully deleted', 'success')
        else:
            flask.flash('Invalid form', 'error')
        return flask.redirect(flask.url_for('.index'))

    return bp


ABP = environments.admin(get_bp('global_images'))
PBP = environments.project(get_bp('project_images'))