def post(self, src_dc, src_stack, src_vnf, src_intfs, dst_dc, dst_stack, dst_vnf, dst_intfs):
"""
A post request to "/v1/chain/<src_dc>/<src_stack>/<src_vnf>/<src_intfs>/<dst_dc>/<dst_stack>/<dst_vnf>/<dst_intfs>"
will create a chain between two interfaces at the specified vnfs.
The POST data contains the path like this.
{ "path": ["dc1.s1", "s1", "dc4.s1"]}
path specifies the destination vnf and interface and contains a list of switches
that the path traverses. The path may not contain single hop loops like:
[s1, s2, s1].
This is a limitation of Ryu, as Ryu does not allow the `INPUT_PORT` action!
:param src_vnf: Name of the source VNF
:type src_vnf: ``str``
:param src_intfs: Name of the source VNF interface to chain on
:type src_intfs: ``str``
:param dst_vnf: Name of the destination VNF
:type dst_vnf: ``str``
:param dst_intfs: Name of the destination VNF interface to chain on
:type dst_intfs: ``str``
:return: flask.Response 200 if set up correctly else 500 also returns the cookie as dict {'cookie': value}
501 if vnf / intfs do not exist
:rtype: :class:`flask.Response`
"""
if request.is_json:
path = request.json.get('path')
layer2 = request.json.get('layer2', True)
else:
path = None
layer2 = True
# search for real names
real_names = self._findNames(src_dc, src_stack, src_vnf, src_intfs, dst_dc, dst_stack, dst_vnf, dst_intfs)
if type(real_names) is not tuple:
# something went wrong
return real_names
container_src, container_dst, interface_src, interface_dst = real_names
try:
cookie = self.api.manage.network_action_start(container_src, container_dst, vnf_src_interface=interface_src,
vnf_dst_interface=interface_dst, bidirectional=True,
path=path, layer2=layer2)
resp = {'cookie': cookie}
return Response(json.dumps(resp), status=200, mimetype="application/json")
except Exception as e:
logging.exception(u"%s: Error setting up the chain.\n %s" % (__name__, e))
return Response(u"Error setting up the chain", status=500, mimetype="application/json")
评论列表
文章目录