0e148f0435c6a967cd56ef0283c7c5e6d65bc912
[csit.git] / GPL / tools / trex / trex_astf_assert.py
1 #!/usr/bin/python3
2
3 # Copyright (c) 2020 Cisco and/or its affiliates.
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 """This script uses T-Rex advanced stateful (astf) API to drive T-Rex instance.
17
18 Requirements:
19 - T-Rex: https://github.com/cisco-system-traffic-generator/trex-core
20  - compiled and running T-Rex process (eg. ./t-rex-64 -i)
21  - trex.astf.api library
22 - Script must be executed on a node with T-Rex instance.
23
24 Functionality:
25 1. Verify the API functionality and get server information.
26 """
27
28 import sys
29
30 sys.path.insert(
31     0, u"/opt/trex-core-2.73/scripts/automation/trex_control_plane/interactive/"
32 )
33 from trex.astf.api import *
34
35
36 def main():
37     """Check server info and quit."""
38     client = ASTFClient()
39     try:
40         # connect to server
41         client.connect()
42
43         # get server info
44         print(client.get_server_system_info())
45     except TRexError as ex_error:
46         print(ex_error, file=sys.stderr)
47         sys.exit(1)
48     finally:
49         client.disconnect()
50
51
52 if __name__ == u"__main__":
53     main()