blob: 0a116c3fcfffa81de3c47013b31ab8f655597104 [file] [log] [blame]
Zsolt Harasztia8789e02016-12-14 01:55:43 -08001#!/usr/bin/env python
Zack Williams41513bf2018-07-07 20:08:35 -07002# 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 Harasztia8789e02016-12-14 01:55:43 -080015import os
16import sys
17
18from scripts.scriptbase import ScriptBase
19
20
21class _(ScriptBase):
22
23 usage = """
24Usage: {} <device-id>
25
26Make sure you have VOLTHA_BASE_URL environment variable
27defined, examples:
28
ubuntuc5c83d72017-07-01 17:57:19 -070029export VOLTHA_BASE_URL=https://localhost:8881/api/v1
Zsolt Harasztia8789e02016-12-14 01:55:43 -080030
31or
32
ubuntuc5c83d72017-07-01 17:57:19 -070033export VOLTHA_BASE_URL=https://10.100.192.220:8881/api/v1
Zsolt Harasztia8789e02016-12-14 01:55:43 -080034""".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
53if __name__ == '__main__':
54 _().main()
55