예제 #1
0
파일: rest.py 프로젝트: novakadam94/api
def submit_infrastructure():
    """Create a new infrastructure and returns the identifier of the
    infrastructure. The returned identifier can be used as ``infraid`` parameter
    in the infrastructure-related commands.

    Requires an :ref:`infrastructure description <infradescription>` as POST data.

    :return type:
        .. code::

            {
                "infraid": "<infraid_in_uuid_format>"
            }

    Example::
    
        curl -X POST http://127.0.0.1:5000/infrastructures/ --data-binary @my_infrastructure_description.yaml
    """
    log.debug('Serving request %s infrastructures',
                request.method)
    infra_desc = request.stream.read()
    log.info('Submitting infrastructure:\n%s', util.yamldump(infra_desc))
    if not infra_desc:
        raise RequestException(400, 'Empty POST data')
    try:
        infraid = manager.add(infra_desc)
    except Exception as ex:
        log.exception('manager.add:')
        raise RequestException(400, str(ex))
    else:
        return jsonify(dict(infraid=infraid))
예제 #2
0
파일: rest.py 프로젝트: occopus/api
def submit_infrastructure():
    """Create a new infrastructure and returns the identifier of the
    infrastructure. The returned identifier can be used as ``infraid`` parameter
    in the infrastructure-related commands.

    Requires an :ref:`infrastructure description <infradescription>` as POST data.

    :return type:
        .. code::

            {
                "infraid": "<infraid_in_uuid_format>"
            }

    Example::

        curl -X POST http://127.0.0.1:5000/infrastructures/ --data-binary @my_infrastructure_description.yaml
    """
    log.debug('Serving request %s infrastructures',
                request.method)
    infra_desc = request.stream.read()
    log.info('Submitting infrastructure:\n%s', util.yamldump(infra_desc))
    if not infra_desc:
        raise RequestException(400, 'Empty POST data')
    try:
        infraid = manager.add(infra_desc)
        util.Infralist().add(infraid)
    except Exception as ex:
        log.exception('manager.add:')
        raise RequestException(400, str(ex))
    else:
        return jsonify(dict(infraid=infraid))
예제 #3
0
 def test_yaml_dump(self):
     # Only a wrapper for yaml.dump, so the test is only for coverage
     util.yamldump(dict(a=1, b=2))
예제 #4
0
 def test_yaml_dump(self):
     # Only a wrapper for yaml.dump, so the test is only for coverage
     util.yamldump(dict(a=1, b=2))