Zsolt Haraszti | a8789e0 | 2016-12-14 01:55:43 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | import os |
| 3 | import sys |
| 4 | |
| 5 | from scripts.scriptbase import ScriptBase |
| 6 | |
| 7 | |
| 8 | class _(ScriptBase): |
| 9 | |
| 10 | usage = """ |
| 11 | Usage: {} <device-id> |
| 12 | |
| 13 | Make sure you have VOLTHA_BASE_URL environment variable |
| 14 | defined, examples: |
| 15 | |
| 16 | export VOLTHA_BASE_URL=http://localhost:8881/api/v1 |
| 17 | |
| 18 | or |
| 19 | |
| 20 | export VOLTHA_BASE_URL=http://10.100.192.220:8881/api/v1 |
| 21 | """.format(sys.argv[0]) |
| 22 | |
| 23 | def main(self): |
| 24 | |
| 25 | if len(sys.argv) != 2: |
| 26 | self.err(1) |
| 27 | |
| 28 | device_id = sys.argv[1] |
| 29 | |
| 30 | device = self.fetch_device_info(self.voltha_base_url, device_id) |
| 31 | self.print_flows( |
| 32 | 'Device', |
| 33 | device_id, |
| 34 | type=device['type'], |
| 35 | flows=device['flows']['items'], |
| 36 | groups=device['flow_groups']['items'] |
| 37 | ) |
| 38 | |
| 39 | |
| 40 | if __name__ == '__main__': |
| 41 | _().main() |
| 42 | |