neutron_dummy_api.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:son-emu 作者: sonata-nfv 项目源码 文件源码
def post(self):
        """
        Creates a network with the name, specified within the request under ['network']['name'].

        :return: * 400, if the network already exists.
            * 500, if any exception occurred while creation.
            * 201, if everything worked out.
        :rtype: :class:`flask.response`
        """
        LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
        try:
            network_dict = json.loads(request.data)
            name = network_dict['network']['name']
            net = self.api.compute.find_network_by_name_or_id(name)
            if net is not None:
                return Response('Network already exists.\n', status=400, mimetype='application/json')

            net = self.api.compute.create_network(name)
            return Response(json.dumps({"network": net.create_network_dict()}), status=201, mimetype='application/json')
        except Exception as ex:
            LOG.exception("Neutron: Create network excepiton.")
            return Response(ex.message, status=500, mimetype='application/json')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号