summaryrefslogtreecommitdiffstats
path: root/src/scripts/vppctl
blob: 0136918950378e5785bf123536b03b4d1d18acb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#! /usr/bin/python
'''
Copyright 2016 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'''

from cmd import Cmd
import os
import subprocess
import re
import sys
from optparse import OptionParser

try:
        import readline
except ImportError:
        readline = None

persishist = os.path.expanduser('~/.vpphistory')
persishist_size = 1000
if not persishist:
        os.mknod(persishist, stat.S_IFREG)

class Vppctl(Cmd):

        def __init__(self,api_prefix=None):
                Cmd.__init__(self)
                self.api_prefix = api_prefix

        def historyWrite(self):
                if readline:
                        readline.set_history_length(persishist_size)
                        readline.write_history_file(persishist)

        def runVat(self, line):
                input_prefix = "exec "
                input_command = input_prefix + line
                line_remove = '^load_one_plugin:'
                s = '\n'
                if ( self.api_prefix is None):
                        command = ['vpp_api_test']
                else:
                        command = ['vpp_api_test',"chroot prefix %s " % self.api_prefix]

                if os.geteuid() != 0:
                    command = ['sudo'] + command

                vpp_process = subprocess.Popen(command,
                        stderr=subprocess.PIPE,
                        stdin=subprocess.PIPE,
                        stdout=subprocess.PIPE)
                stdout_value = vpp_process.communicate(input_command)[0]

                buffer_stdout = stdout_value.splitlines()

                buffer_stdout[:]  = [b for b in buffer_stdout
                        if line_remove not in b]

                for i, num in enumerate(buffer_stdout):
                        buffer_stdout[i] = num.replace('vat# ','')

                stdout_value = s.join(buffer_stdout)
                print stdout_value

        def do_help(self, line):
                self.runVat("help")

        def default(self, line):
                self.runVat(line)

        def do_exit(self, line):
                self.historyWrite()
                raise SystemExit

        def emptyline(self):
                pass

        def do_EOF(self,line):
                self.historyWrite()
                sys.stdout.write('\n')
                raise SystemExit

        def preloop(self):
                if readline and os.path.exists(persishist):
                        readline.read_history_file(persishist)

        def postcmd(self, stop, line):
                self.historyWrite()

if __name__ == '__main__':
        parser = OptionParser()
        parser.add_option("-p","--prefix",action="store",type="string",dest="prefix")
        (options,command_args) = parser.parse_args(sys.argv)

        if not len(command_args) > 1:
                prompt = Vppctl(options.prefix)
                red_set = '\033[31m'
                norm_set = '\033[0m'
                if sys.stdout.isatty():
                        if(options.prefix is None):
                                prompt.prompt = 'vpp# '
                        else:
                                prompt.prompt = '%s# ' % options.prefix
                        try:
                                prompt.cmdloop(red_set + "    _______    _       " + norm_set + " _   _____  ___ \n" +
                                        red_set + " __/ __/ _ \  (_)__   " + norm_set + " | | / / _ \/ _ \\\n" +
                                        red_set + " _/ _// // / / / _ \\" + norm_set + "   | |/ / ___/ ___/\n" +
                                        red_set + " /_/ /____(_)_/\___/   " + norm_set + "|___/_/  /_/   \n")
                        except KeyboardInterrupt:
                                sys.stdout.write('\n')
                else:
                        try:
                                prompt.cmdloop()
                        except KeyboardInterrupt:
                                sys.stdout.write('\n')
        else:
                del command_args[0]
                stdout_value = " ".join(command_args)
                VatAddress = Vppctl(options.prefix)
                VatAddress.runVat(stdout_value)
ass="s">- frame_size - Framesize in Bytes in integer or string (IMIX_v4_1). | | ... | Type: integer, string | | ... | - phy_cores - Number of physical cores. Type: integer | | ... | - rxq - Number of RX queues, default value: ${None}. Type: integer | | | | [Arguments] | ${frame_size} | ${phy_cores} | ${rxq}=${None} | | | | Set Test Variable | \${frame_size} | | | | # These are enums (not strings) so they cannot be in Variables table. | | ${encr_alg}= | Crypto Alg AES CBC 128 | | ${auth_alg}= | Integ Alg SHA 512 256 | | | | Given Set Max Rate And Jumbo | | And Add worker threads to all DUTs | ${phy_cores} | ${rxq} | | And Pre-initialize layer driver | ${nic_driver} | | And Apply startup configuration on all VPP DUTs | | When Initialize layer driver | ${nic_driver} | | And Initialize layer interface | | And Initialize IPSec in 3-node circular topology | | And VPP IPsec Create Tunnel Interfaces | | ... | ${nodes} | ${dut1_if2_ip4} | ${dut2_if1_ip4} | ${DUT1_${int}2}[0] | | ... | ${DUT2_${int}1}[0] | ${n_tunnels} | ${encr_alg} | ${auth_alg} | | ... | ${laddr_ip4} | ${raddr_ip4} | ${addr_range} | | Then Find NDR and PDR intervals using optimized search *** Test Cases *** | 64B-1c-ethip4ipsec4tnlsw-ip4base-int-aes128cbc-hmac512sha-ndrpdr | | [Tags] | 64B | 1C | | frame_size=${64} | phy_cores=${1} | 64B-2c-ethip4ipsec4tnlsw-ip4base-int-aes128cbc-hmac512sha-ndrpdr | | [Tags] | 64B | 2C | | frame_size=${64} | phy_cores=${2} | 64B-4c-ethip4ipsec4tnlsw-ip4base-int-aes128cbc-hmac512sha-ndrpdr | | [Tags] | 64B | 4C | | frame_size=${64} | phy_cores=${4} | 1518B-1c-ethip4ipsec4tnlsw-ip4base-int-aes128cbc-hmac512sha-ndrpdr | | [Tags] | 1518B | 1C | | frame_size=${1518} | phy_cores=${1} | 1518B-2c-ethip4ipsec4tnlsw-ip4base-int-aes128cbc-hmac512sha-ndrpdr | | [Tags] | 1518B | 2C | | frame_size=${1518} | phy_cores=${2} | 1518B-4c-ethip4ipsec4tnlsw-ip4base-int-aes128cbc-hmac512sha-ndrpdr | | [Tags] | 1518B | 4C | | frame_size=${1518} | phy_cores=${4} | IMIX-1c-ethip4ipsec4tnlsw-ip4base-int-aes128cbc-hmac512sha-ndrpdr | | [Tags] | IMIX | 1C | | frame_size=IMIX_v4_1 | phy_cores=${1} | IMIX-2c-ethip4ipsec4tnlsw-ip4base-int-aes128cbc-hmac512sha-ndrpdr | | [Tags] | IMIX | 2C | | frame_size=IMIX_v4_1 | phy_cores=${2} | IMIX-4c-ethip4ipsec4tnlsw-ip4base-int-aes128cbc-hmac512sha-ndrpdr | | [Tags] | IMIX | 4C | | frame_size=IMIX_v4_1 | phy_cores=${4}