Matteo Scandolo | 48d3d2d | 2017-08-08 13:05:27 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 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 | |
| 16 | |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 17 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 18 | # Copyright 2016-present Ciena Corporation |
| 19 | # |
| 20 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 21 | # you may not use this file except in compliance with the License. |
| 22 | # You may obtain a copy of the License at |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 23 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 24 | # http://www.apache.org/licenses/LICENSE-2.0 |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 25 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 26 | # Unless required by applicable law or agreed to in writing, software |
| 27 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 28 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 29 | # See the License for the specific language governing permissions and |
| 30 | # limitations under the License. |
| 31 | # |
Chetan Gaonker | b8619e5 | 2016-04-12 18:03:05 -0700 | [diff] [blame] | 32 | import unittest |
| 33 | import time |
| 34 | import os |
| 35 | import json |
| 36 | from nose.tools import * |
| 37 | from onosclidriver import OnosCliDriver |
| 38 | from OnosCtrl import OnosCtrl |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 39 | from CordTestUtils import log_test as log |
Chetan Gaonker | b8619e5 | 2016-04-12 18:03:05 -0700 | [diff] [blame] | 40 | |
| 41 | log.setLevel('INFO') |
| 42 | |
| 43 | class routes_exchange(unittest.TestCase): |
| 44 | |
| 45 | @classmethod |
| 46 | def setUpClass(cls): |
| 47 | cls.cli = OnosCliDriver(connect = True) |
| 48 | |
| 49 | @classmethod |
| 50 | def tearDownClass(cls): |
| 51 | cls.cli.disconnect() |
| 52 | |
| 53 | def test_route_cli(self): |
| 54 | routes = json.loads(self.cli.routes(jsonFormat = True)) |
| 55 | log.info('Routes: %s' %routes) |
| 56 | |
| 57 | def test_devices_cli(self): |
| 58 | devices = json.loads(self.cli.devices(jsonFormat = True)) |
| 59 | available_devices = filter(lambda d: d['available'], devices) |
| 60 | device_ids = [ d['id'] for d in devices ] |
| 61 | log.info('Available Devices: %s' %devices) |
| 62 | log.info('Device IDS: %s' %device_ids) |
| 63 | |
| 64 | def test_flows_cli(self): |
| 65 | flows = json.loads(self.cli.flows(jsonFormat = True)) |
| 66 | flows = filter(lambda f: f['flows'], flows) |
| 67 | log.info('Flows: %s' %flows) |