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))
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))
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))