Exemplo n.º 1
0
    def get(self, zapp_id):
        """Home page with authentication."""
        uid, role = get_auth(self)
        if uid is None:
            return self.redirect(self.get_argument('next', u'/login'))

        manifest_index = int(zapp_id.split('-')[-1])
        zapp_id = "-".join(zapp_id.split('-')[:-1])
        zapps = zapp_shop.zshop_read_manifest(zapp_id)
        zapp = zapps[manifest_index]

        template_vars = {
            "uid":
            uid,
            "role":
            role,
            'zapp':
            zapp,
            'max_core_limit':
            get_conf().max_core_limit,
            'max_memory_limit':
            get_conf().max_memory_limit,
            'resources_are_customizable':
            role == "admin"
            or (role != "guest" and
                (role == "user" and not get_conf().no_user_edit_limits_web)),
            'additional_volumes':
            get_conf().additional_volumes
        }
        self.render('zapp_start.html', **template_vars)
Exemplo n.º 2
0
    def post(self, zapp_id):
        """Write the parameters in the description and start the ZApp."""
        uid, role = get_auth(self)
        if uid is None:
            return self.redirect(self.get_argument('next', u'/login'))

        manifest_index = int(zapp_id.split('-')[-1])
        zapp_id = "-".join(zapp_id.split('-')[:-1])
        zapps = zapp_shop.zshop_read_manifest(zapp_id)
        zapp = zapps[manifest_index]

        exec_name = self.get_argument('exec_name')

        app_descr = self._set_parameters(zapp.zoe_description, zapp.parameters,
                                         role)

        try:
            self.get_argument('download_json')
            self.set_header('Content-Type', 'application/json')
            self.set_header('Content-Disposition',
                            'attachment; filename={}.json'.format(zapp_id))
            self.write(app_descr)
            self.finish()
            return
        except MissingArgumentError:
            new_id = self.api_endpoint.execution_start(uid, role, exec_name,
                                                       app_descr)

        self.redirect(self.reverse_url('execution_inspect', new_id))
Exemplo n.º 3
0
    def get(self, zapp_id):
        """Home page with authentication."""
        if self.current_user is None:
            return

        self.set_header("Content-type", "image/png")
        self.set_header("Cache-Control", "public,max-age=1209600")

        manifest_index = int(zapp_id.split('-')[-1])
        zapp_id = "-".join(zapp_id.split('-')[:-1])
        zapps = zapp_shop.zshop_read_manifest(zapp_id)
        zapp = zapps[manifest_index]
        self.write(zapp_shop.get_logo(zapp))
Exemplo n.º 4
0
    def get(self, zapp_id):
        """Home page with authentication."""
        uid, role_ = get_auth(self)
        if uid is None:
            return self.redirect(self.get_argument('next', u'/login'))

        self.set_header("Content-type", "image/png")

        manifest_index = int(zapp_id.split('-')[-1])
        zapp_id = "-".join(zapp_id.split('-')[:-1])
        zapps = zapp_shop.zshop_read_manifest(zapp_id)
        zapp = zapps[manifest_index]
        self.write(zapp_shop.get_logo(zapp))
Exemplo n.º 5
0
    def get(self, zapp_id):
        """Home page with authentication."""
        if self.current_user is None:
            return

        manifest_index = int(zapp_id.split('-')[-1])
        zapp_id = "-".join(zapp_id.split('-')[:-1])
        zapps = zapp_shop.zshop_read_manifest(zapp_id)
        zapp = zapps[manifest_index]

        template_vars = {
            'zapp': zapp,
            'max_core_limit': get_conf().max_core_limit,
            'max_memory_limit': get_conf().max_memory_limit,
            'resources_are_customizable': self.current_user.role.can_customize_resources,
            'additional_volumes': get_conf().additional_volumes
        }
        self.render('zapp_start.jinja2', **template_vars)
Exemplo n.º 6
0
    def post(self, zapp_id):
        """Write the parameters in the description and start the ZApp."""
        if self.current_user is None:
            return

        manifest_index = int(zapp_id.split('-')[-1])
        zapp_id = "-".join(zapp_id.split('-')[:-1])
        zapps = zapp_shop.zshop_read_manifest(zapp_id)
        zapp = zapps[manifest_index]

        exec_name = self.get_argument('exec_name')

        if self.current_user.role.can_customize_resources:
            app_descr = self._set_parameters(zapp.zoe_description,
                                             zapp.parameters)
        else:
            app_descr = zapp.zoe_description

        if len(zapp.labels) > 0:
            for service in app_descr['services']:
                if 'labels' in service:
                    service['labels'].append(zapp.labels)
                else:
                    service['labels'] = zapp.labels

        try:
            self.get_argument('download_json')
            self.set_header('Content-Type', 'application/json')
            self.set_header('Content-Disposition',
                            'attachment; filename={}.json'.format(zapp_id))
            self.write(app_descr)
            self.finish()
            return
        except MissingArgumentError:
            try:
                new_id = self.api_endpoint.execution_start(
                    self.current_user, exec_name, app_descr)
            except ZoeException as e:
                self.error_page(e.message, 500)
                return

        self.redirect(self.reverse_url('execution_inspect', new_id))