1 # Copyright 2017 Red Hat Inc & Xena Networks.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 # Dan Amzulescu, Xena Networks
17 # Christian Trautman, Red Hat Inc.
19 # Usage can be seen below in unit test. This implementation is designed for one
20 # module two port Xena chassis runs only.
23 Xena JSON module for pairs topology
26 from tools.pkt_gen.xena.json.xena_json import XenaJSON
29 class XenaJSONPairs(XenaJSON):
31 Class to modify and read Xena JSON configuration files. Topology will be set
35 super(XenaJSONPairs, self).__init__()
36 self.set_topology_pairs()
38 def set_topology_pairs(self):
40 Set the test topology to loopback pairs for packets that need to return
41 to the same port they are sent from
44 self.json_data['TestOptions']['TopologyConfig']['Topology'] = 'PAIRS'
45 self.json_data['TestOptions']['TopologyConfig'][
46 'Direction'] = 'WEST_EAST'
47 self.json_data['PortHandler']['EntityList'][0][
49 self.json_data['PortHandler']['EntityList'][1][
52 def remove_port(self, port_number):
54 Remove a port from the config.
55 :param port_number: port to remove from json config as int
58 del self.json_data['PortHandler']['EntityList'][port_number]
59 del self.json_data['StreamHandler']['StreamConnectionList'][0][
60 'Port{}Id'.format(port_number + 1)]