140253a3843853ef305f9733cbc27cf0a8e2a66b
[csit.git] / GPL / tools / trex / trex_astf_assert.py
1 #!/usr/bin/python3
2
3 # Copyright (c) 2020 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 Apache 2.
18 #
19 # Unless required by applicable law or agreed to in writing, software
20 # distributed under the License is distributed on an "AS IS" BASIS,
21 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 # See the License for the specific language governing permissions and
23 # limitations under the License.
24
25 """This script uses T-Rex advanced stateful (astf) API to drive T-Rex instance.
26
27 Requirements:
28 - T-Rex: https://github.com/cisco-system-traffic-generator/trex-core
29  - compiled and running T-Rex process (eg. ./t-rex-64 -i)
30  - trex.astf.api library
31 - Script must be executed on a node with T-Rex instance.
32
33 Functionality:
34 1. Verify the API functionality and get server information.
35 """
36
37 import sys
38
39 sys.path.insert(
40     0, u"/opt/trex-core-2.86/scripts/automation/trex_control_plane/interactive/"
41 )
42 from trex.astf.api import *
43
44
45 def main():
46     """Check server info and quit."""
47     client = ASTFClient()
48     try:
49         # connect to server
50         client.connect()
51
52         # get server info
53         print(client.get_server_system_info())
54     except TRexError as ex_error:
55         print(ex_error, file=sys.stderr)
56         sys.exit(1)
57     finally:
58         client.disconnect()
59
60
61 if __name__ == u"__main__":
62     main()