Increase the default number of rx and tx descriptors to 2K
[samplevnf.git] / VNFs / DPPD-PROX / helper-scripts / testvRouter / remote_system.py
1 #!/bin/env python
2
3 ##
4 ## Copyright (c) 2010-2017 Intel Corporation
5 ##
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
9 ##
10 ##     http://www.apache.org/licenses/LICENSE-2.0
11 ##
12 ## Unless required by applicable law or agreed to in writing, software
13 ## distributed under the License is distributed on an "AS IS" BASIS,
14 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ## See the License for the specific language governing permissions and
16 ## limitations under the License.
17 ##
18
19 import os
20 import thread
21 import time
22 import socket
23
24 def ssh(user, ip, cmd):
25     # print cmd;
26     ssh_options = ""
27     ssh_options += "-o StrictHostKeyChecking=no "
28     ssh_options += "-o UserKnownHostsFile=/dev/null "
29     ssh_options += "-o LogLevel=quiet "
30     running = os.popen("ssh " + ssh_options + " " + user + "@" + ip + " \"" + cmd + "\"");
31     ret = {};
32     ret['out'] = running.read().strip();
33     ret['ret'] = running.close();
34     if (ret['ret'] == None):
35         ret['ret'] = 0;
36
37     return ret;
38
39 def ssh_check_quit(obj, user, ip, cmd):
40     ret = ssh(user, ip, cmd);
41     if (ret['ret'] != 0):
42         obj._err = True;
43         obj._err_str = ret['out'];
44         exit(-1);
45
46 class remote_system:
47     def __init__(self, user, ip):
48         self._ip          = ip;
49         self._user        = user;
50     def run(self, cmd):
51         return ssh(self._user, self._ip, cmd);
52     def run_forked(self, cmd):
53         thread.start_new_thread(ssh, (self._user, self._ip, cmd));
54         return 0;
55     def scp(self, src, dst):
56         running = os.popen("scp " + self._user + "@" + self._ip + ":" + src + " " + dst);
57         return running.close();