Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2016-present Ciena Corporation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
Chetan Gaonker | b8619e5 | 2016-04-12 18:03:05 -0700 | [diff] [blame] | 16 | import unittest |
| 17 | import time |
| 18 | import os |
| 19 | import json |
| 20 | from nose.tools import * |
| 21 | from onosclidriver import OnosCliDriver |
| 22 | from OnosCtrl import OnosCtrl |
| 23 | from scapy.all import * |
| 24 | |
| 25 | log.setLevel('INFO') |
| 26 | |
| 27 | class routes_exchange(unittest.TestCase): |
| 28 | |
| 29 | @classmethod |
| 30 | def setUpClass(cls): |
| 31 | cls.cli = OnosCliDriver(connect = True) |
| 32 | |
| 33 | @classmethod |
| 34 | def tearDownClass(cls): |
| 35 | cls.cli.disconnect() |
| 36 | |
| 37 | def test_route_cli(self): |
| 38 | routes = json.loads(self.cli.routes(jsonFormat = True)) |
| 39 | log.info('Routes: %s' %routes) |
| 40 | |
| 41 | def test_devices_cli(self): |
| 42 | devices = json.loads(self.cli.devices(jsonFormat = True)) |
| 43 | available_devices = filter(lambda d: d['available'], devices) |
| 44 | device_ids = [ d['id'] for d in devices ] |
| 45 | log.info('Available Devices: %s' %devices) |
| 46 | log.info('Device IDS: %s' %device_ids) |
| 47 | |
| 48 | def test_flows_cli(self): |
| 49 | flows = json.loads(self.cli.flows(jsonFormat = True)) |
| 50 | flows = filter(lambda f: f['flows'], flows) |
| 51 | log.info('Flows: %s' %flows) |