1 """Variables file for basicpcep suite.
3 Expected JSON templates are fairly long,
4 therefore there are moved out of testcase file.
5 Also, it is needed to generate base64 encoded tunnel name
6 from Mininet IP (which is not known beforehand),
7 so it is easier to employ Python here,
8 than do manipulation in Robot file."""
9 # Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
11 # This program and the accompanying materials are made available under the
12 # terms of the Eclipse Public License v1.0 which accompanies this distribution,
13 # and is available at http://www.eclipse.org/legal/epl-v10.html
15 __author__ = "Vratko Polak"
16 __copyright__ = "Copyright(c) 2015, Cisco Systems, Inc."
17 __license__ = "Eclipse Public License v1.0"
18 __email__ = "vrpolak@cisco.com"
21 from string import Template
24 def get_variables(mininet_ip):
25 """Return dict of variables for the given IP addtess of Mininet VM."""
26 tunnelname = 'pcc_' + mininet_ip + '_tunnel_1'
27 pathcode = binascii.b2a_base64(tunnelname)[:-1] # remove endline
31 "topology-id": "pcep-topology",
33 "network-topology-pcep:topology-pcep": {}
38 onjsontempl = Template('''{
43 "network-topology-pcep:path-computation-client": {
52 "processing-rule": false,
56 "ip-prefix": "1.1.1.1/32"
63 "odl-pcep-ietf-stateful07:lsp": {
64 "administrative": true,
67 "odl-pcep-ietf-initiated00:create": false,
70 "processing-rule": false,
76 "ipv4-extended-tunnel-id": "$IP",
77 "ipv4-tunnel-endpoint-address": "1.1.1.1",
78 "ipv4-tunnel-sender-address": "$IP"
83 "symbolic-path-name": {
92 "state-sync": "synchronized",
94 "odl-pcep-ietf-stateful07:stateful": {
95 "lsp-update-capability": true,
96 "odl-pcep-ietf-initiated00:initiation": true
100 "node-id": "pcc://$IP"
103 "topology-id": "pcep-topology",
105 "network-topology-pcep:topology-pcep": {}
110 repl_dict = {'IP': mininet_ip, 'NAME': tunnelname, 'CODE': pathcode}
111 onjson = onjsontempl.substitute(repl_dict)
112 variables = {'offjson': offjson, 'onjson': onjson}