Ejemplo n.º 1
0
def import_app(request, app_id):
    app_data = get_apps_data(request).setdefault(app_id, {})

    ui_desc = pkg_api.get_app_ui(request, app_id)
    fqn = pkg_api.get_app_fqn(request, app_id)
    LOG.debug('Using data {0} for app {1}'.format(app_data, fqn))
    version.check_version(ui_desc.pop('Version', 1))
    service = dict(
        (helpers.decamelize(k), v) for (k, v) in ui_desc.iteritems())

    global _apps  # In-memory caching of dynamic UI forms
    if app_id in _apps:
        LOG.debug('Using in-memory forms for app {0}'.format(fqn))
        app = _apps[app_id]
        app.set_data(app_data)
    else:
        LOG.debug('Creating new forms for app {0}'.format(fqn))
        app = _apps[app_id] = Service(app_data, **service)
    return app
def import_app(request, app_id):
    app_data = get_apps_data(request).setdefault(app_id, {})

    ui_desc = pkg_api.get_app_ui(request, app_id)
    fqn = pkg_api.get_app_fqn(request, app_id)
    LOG.debug('Using data {0} for app {1}'.format(app_data, fqn))
    app_version = ui_desc.pop('Version', version.LATEST_FORMAT_VERSION)
    version.check_version(app_version)
    service = dict(
        (helpers.decamelize(k), v) for (k, v) in six.iteritems(ui_desc))
    parameters = service.pop('parameters', {})
    parameters_source = service.pop('parameters_source', None)
    if parameters_source is not None:
        parts = parameters_source.rsplit('.', 1)
        if 2 >= len(parts) > 0:
            if len(parts) == 2:
                class_name, method_name = parts
            else:
                method_name = parts[0]
                class_name = service.get('application',
                                         {}).get('?', {}).get('type', fqn)

            details = pkg_api.get_package_details(request, app_id)
            pkg_version = getattr(details, 'version', '*')
            request_body = {
                'className': class_name,
                'methodName': method_name,
                'packageName': fqn,
                'classVersion': pkg_version,
                'parameters': {}
            }

            result = api.muranoclient(request).static_actions.call(
                request_body).get_result()
            if result and isinstance(result, dict):
                parameters.update(result)

    return Service(app_data,
                   app_version,
                   fqn,
                   parameters=parameters,
                   **service)
Ejemplo n.º 3
0
def import_app(request, app_id):
    app_data = get_apps_data(request).setdefault(app_id, {})

    ui_desc = pkg_api.get_app_ui(request, app_id)
    fqn = pkg_api.get_app_fqn(request, app_id)
    LOG.debug('Using data {0} for app {1}'.format(app_data, fqn))
    app_version = ui_desc.pop('Version', version.LATEST_FORMAT_VERSION)
    version.check_version(app_version)
    service = dict(
        (helpers.decamelize(k), v) for (k, v) in ui_desc.iteritems())

    global _apps  # In-memory caching of dynamic UI forms
    if app_id in _apps:
        LOG.debug('Using in-memory forms for app {0}'.format(fqn))
        app = _apps[app_id]
        app.set_data(app_data)
    else:
        LOG.debug('Creating new forms for app {0}'.format(fqn))
        app = _apps[app_id] = Service(app_data, app_version, **service)
    return app
Ejemplo n.º 4
0
def import_app(request, app_id):
    from muranodashboard.environments import api

    if not request.session.get('apps'):
        request.session['apps'] = {}
    services = request.session['apps']

    app = services.get(app_id)
    if not app:

        @cache.with_cache('ui', 'ui.yaml')
        def _get(_request, _app_id):
            return api.muranoclient(_request).packages.get_ui(
                _app_id, make_loader_cls())

        ui_desc = _get(request, app_id)
        version.check_version(ui_desc.pop('Version', 1))
        service = dict((decamelize(k), v) for (k, v) in ui_desc.iteritems())
        services[app_id] = Service(**service)
        app = services[app_id]

    return app
Ejemplo n.º 5
0
def import_app(request, app_id):
    app_data = get_apps_data(request).setdefault(app_id, {})

    ui_desc = pkg_api.get_app_ui(request, app_id)
    fqn = pkg_api.get_app_fqn(request, app_id)
    LOG.debug('Using data {0} for app {1}'.format(app_data, fqn))
    app_version = ui_desc.pop('Version', version.LATEST_FORMAT_VERSION)
    version.check_version(app_version)
    service = dict(
        (helpers.decamelize(k), v) for (k, v) in six.iteritems(ui_desc))
    parameters = service.pop('parameters', {})
    parameters_source = service.pop('parameters_source', None)
    if parameters_source is not None:
        parts = parameters_source.rsplit('.', 1)
        if 2 >= len(parts) > 0:
            if len(parts) == 2:
                class_name, method_name = parts
            else:
                method_name = parts[0]
                class_name = service.get('application', {}).get('?', {}).get(
                    'type', fqn)

            details = pkg_api.get_package_details(request, app_id)
            pkg_version = getattr(details, 'version', '*')
            request_body = {
                'className': class_name,
                'methodName': method_name,
                'packageName': fqn,
                'classVersion': pkg_version,
                'parameters': {}
            }

            result = api.muranoclient(request).static_actions.call(
                request_body).get_result()
            if result and isinstance(result, dict):
                parameters.update(result)

    return Service(app_data, app_version, fqn, parameters=parameters,
                   **service)
Ejemplo n.º 6
0
 def test_oldest_in_family(self):
     version.check_version(2)
Ejemplo n.º 7
0
 def test_string_match(self):
     version.check_version('2.4')
Ejemplo n.º 8
0
 def test_exact_match(self):
     version.check_version(2.4)
Ejemplo n.º 9
0
 def test_older_in_family(self):
     version.check_version('2.1')
Ejemplo n.º 10
0
 def test_oldest_in_family(self):
     version.check_version('2')
Ejemplo n.º 11
0
 def test_exact_match(self):
     version.check_version('2.4')