eef06be49f582c3f60caff15ec87308142969b89
[csit.git] / GPL / tools / trex / trex_stl_assert.py
1 #!/usr/bin/python3
2
3 # Copyright (c) 2021 Cisco and/or its affiliates.
4 #
5 # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
6 #
7 # Licensed under the Apache License 2.0 or
8 # GNU General Public License v2.0 or later;  you may not use this file
9 # except in compliance with one of these Licenses. You
10 # may obtain a copy of the Licenses at:
11 #
12 #     http://www.apache.org/licenses/LICENSE-2.0
13 #     https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
14 #
15 # Note: If this file is linked with Scapy, which is GPLv2+, your use of it
16 # must be under GPLv2+.  If at any point in the future it is no longer linked
17 # with Scapy (or other GPLv2+ licensed software), you are free to choose
18 # Apache 2.
19 #
20 # Unless required by applicable law or agreed to in writing, software
21 # distributed under the License is distributed on an "AS IS" BASIS,
22 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 # See the License for the specific language governing permissions and
24 # limitations under the License.
25
26 """This script uses T-Rex stateless API to drive T-Rex instance.
27
28 Requirements:
29 - T-REX: https://github.com/cisco-system-traffic-generator/trex-core
30  - compiled and running T-Rex process (eg. ./t-rex-64 -i)
31  - trex.stl.api library
32 - Script must be executed on a node with T-Rex instance.
33
34 Functionality:
35 1. Verify the API functionality and get server information.
36 """
37
38 import sys
39
40 sys.path.insert(
41     0, u"/opt/trex-core-2.88/scripts/automation/trex_control_plane/interactive/"
42 )
43 from trex.stl.api import *
44
45
46 def main():
47     """Check server info and quit."""
48     client = STLClient()
49     try:
50         # connect to server
51         client.connect()
52
53         # get server info
54         print(client.get_server_system_info())
55     except STLError as ex_error:
56         print(ex_error, file=sys.stderr)
57         sys.exit(1)
58     finally:
59         client.disconnect()
60
61
62 if __name__ == u"__main__":
63     main()