Zsolt Haraszti | a8789e0 | 2016-12-14 01:55:43 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
Zack Williams | 41513bf | 2018-07-07 20:08:35 -0700 | [diff] [blame] | 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. |
Zsolt Haraszti | a8789e0 | 2016-12-14 01:55:43 -0800 | [diff] [blame] | 15 | import os |
| 16 | import sys |
| 17 | |
| 18 | from scripts.scriptbase import ScriptBase |
| 19 | |
| 20 | |
| 21 | class _(ScriptBase): |
| 22 | |
| 23 | usage = """ |
| 24 | Usage: {} <device-id> |
| 25 | |
| 26 | Make sure you have VOLTHA_BASE_URL environment variable |
| 27 | defined, examples: |
| 28 | |
ubuntu | c5c83d7 | 2017-07-01 17:57:19 -0700 | [diff] [blame] | 29 | export VOLTHA_BASE_URL=https://localhost:8881/api/v1 |
Zsolt Haraszti | a8789e0 | 2016-12-14 01:55:43 -0800 | [diff] [blame] | 30 | |
| 31 | or |
| 32 | |
ubuntu | c5c83d7 | 2017-07-01 17:57:19 -0700 | [diff] [blame] | 33 | export VOLTHA_BASE_URL=https://10.100.192.220:8881/api/v1 |
Zsolt Haraszti | a8789e0 | 2016-12-14 01:55:43 -0800 | [diff] [blame] | 34 | """.format(sys.argv[0]) |
| 35 | |
| 36 | def main(self): |
| 37 | |
| 38 | if len(sys.argv) != 2: |
| 39 | self.err(1) |
| 40 | |
| 41 | device_id = sys.argv[1] |
| 42 | |
| 43 | device = self.fetch_device_info(self.voltha_base_url, device_id) |
| 44 | self.print_flows( |
| 45 | 'Device', |
| 46 | device_id, |
| 47 | type=device['type'], |
| 48 | flows=device['flows']['items'], |
| 49 | groups=device['flow_groups']['items'] |
| 50 | ) |
| 51 | |
| 52 | |
| 53 | if __name__ == '__main__': |
| 54 | _().main() |
| 55 | |