Scalability tests and log improvement
Change-Id: I510002ea48ecc17e86d771e85c79b85cadf08f32
diff --git a/Fabric/Utilities/accton/accton_util.py b/Fabric/Utilities/accton/accton_util.py
index b0752e6..592265e 100755
--- a/Fabric/Utilities/accton/accton_util.py
+++ b/Fabric/Utilities/accton/accton_util.py
@@ -1880,40 +1880,32 @@
def ofagent_restart(self):
- log_path = (config["log_dir"])
- log_file = "OF_agent_service_restart.log"
regexp = 'Setting up OFDPA running environment'
- output = open(log_path + '/' + log_file, 'w')
cmd = "service ofagentd restart"
+ logging.info(cmd)
child = pexpect.spawn('ssh -p 22 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ' + self.switch_user +'@%s' % self.switch_ip)
child.expect('[pP]assword:')
child.sendline(self.switch_passwd)
- child.logfile = output
child.expect('root@localhost:~#')
child.sendline(cmd)
if regexp:
child.expect(regexp)
- output.close()
child.close()
def switch_restart(self):
- log_path = (config["log_dir"])
- log_file = "Switch_restart.log"
regexp = 'The system is going down for reboot NOW!'
- output = open(log_path + '/' + log_file, 'w')
cmd = "reboot"
+ logging.info(cmd)
child = pexpect.spawn('ssh -p 22 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ' + self.switch_user +'@%s' % self.switch_ip)
child.expect('[pP]assword:')
child.sendline(self.switch_passwd)
- child.logfile = output
child.expect('root@localhost:~#')
child.sendline(cmd)
if regexp:
child.expect(regexp)
- output.close()
child.close()
@@ -1921,10 +1913,7 @@
# @parameters:
# port - port number on the switch to admin state Enable or Disable
# state - admin state "False" - Down or "True" - Up for switch's port
- log_path = (config["log_dir"])
- log_file = "Switch_port_" + str(state) + ".log"
regexp = 'Returned from ofdpaBcmCommand rpc with rc = 0.'
- output = open(log_path + '/' + log_file, 'w')
if state == False:
cmd = "client_drivshell port xe{} enable=false".format(port - 1)
elif state == True:
@@ -1932,16 +1921,15 @@
else:
assert False, "Incorrect port state parameter is given!"
+ logging.info(cmd)
child = pexpect.spawn('ssh -p 22 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ' + self.switch_user +'@%s' % self.switch_ip)
child.expect('[pP]assword:')
child.sendline(self.switch_passwd)
- child.logfile = output
child.expect('root@localhost:~#')
child.sendline(cmd)
if regexp:
child.expect(regexp)
- output.close()
child.close()
@@ -1949,27 +1937,24 @@
# @parameters:
# port - port number on the switch to admin state Enable or Disable
# mtu - size of MTU for switch's port in bytes
- log_path = (config["log_dir"])
- log_file = "Switch_port_set_mtu_" + str(mtu) + ".log"
regexp = 'Returned from ofdpaBcmCommand rpc with rc = 0.'
- output = open(log_path + '/' + log_file, 'w')
cmd = ("client_drivshell port xe{} FrameMax=" + str(mtu)).format(port - 1)
+ logging.info(cmd)
child = pexpect.spawn('ssh -p 22 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ' + self.switch_user +'@%s' % self.switch_ip)
child.expect('[pP]assword:')
child.sendline(self.switch_passwd)
- child.logfile = output
child.expect('root@localhost:~#')
child.sendline(cmd)
if regexp:
child.expect(regexp)
- output.close()
child.close()
def send_command_to_switch_cli(log_file, cmd, switch_ip, switch_user, switch_passwd, regexp=None):
log_path = (config["log_dir"])
- output = open(log_path + '/' + log_file, 'w')
+ output = open(log_path + '/' + log_file, 'a+')
+ logging.info(cmd)
child = pexpect.spawn('ssh -p 22 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ' + switch_user +'@%s' % switch_ip)
child.expect('[pP]assword:')
child.sendline(switch_passwd)
@@ -1985,7 +1970,8 @@
def send_command_to_onos_cli(log_file, cmd, onos_server, onos_user, onos_passwd, regexp=None):
log_path = (config["log_dir"])
- output = open(log_path + '/' + log_file, 'w')
+ output = open(log_path + '/' + log_file, 'a+')
+ logging.info(cmd)
child = pexpect.spawn('ssh -p 30115 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ' + onos_user + '@%s' % onos_server)
child.expect('[pP]assword:')
child.sendline(onos_passwd)
@@ -1999,47 +1985,40 @@
child.close()
-def add_onos_xconnect(self,datapathid, vid, port1, port2):
- log_path = (config["log_dir"])
+def add_onos_xconnect(self, datapathid, vid, port1, port2):
cmd = "sr-xconnect-add of:" + datapathid + " " + str(vid) + " " + str(port1) + " " + str(port2)
regexp = 'onos>'
- output = open(log_path + '/' + "add_xconnection" + str(vid) + "_" + str(port1) + "_" + str(port2), 'w')
+ logging.info(cmd)
child = pexpect.spawn(
'ssh -p 30115 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ' + self.onos_user + '@%s' % self.onos_server_ip)
child.expect('[pP]assword:')
child.sendline(self.onos_passwd)
- child.logfile = output
child.expect('onos>')
child.sendline(cmd)
if regexp:
child.expect(regexp)
- output.close()
child.close()
def remove_onos_xconnect(self,datapathid, vid):
- log_path = (config["log_dir"])
cmd = "sr-xconnect-remove of:" + datapathid + " " + str(vid)
regexp = 'onos>'
- output = open(log_path + '/' + "remove_xconnection" + str(vid), 'w')
+ logging.info(cmd)
child = pexpect.spawn(
'ssh -p 30115 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ' + self.onos_user + '@%s' % self.onos_server_ip)
child.expect('[pP]assword:')
child.sendline(self.onos_passwd)
- child.logfile = output
child.expect('onos>')
child.sendline(cmd)
if regexp:
child.expect(regexp)
- output.close()
child.close()
def ofagent_reconfig(self, arg):
# @parameters:
# arg - configure switch with both OFTest and ONOS (arg = yes) or only OFTest is required (arg = no)
- log_path = (config["log_dir"])
if arg == "yes":
logging.info("Reconfigure OFAGENT to use both ONOS and OFTEST")
comd = "sed -i '/^OPT_ARGS=/c\OPT_ARGS=\"-d 2 -c 2 -c 4 -t " + self.controller_ip + ":" + self.controller_port + " -t " + self.onos_server_ip + ":" + self.onos_port + " -i $DPID\"' /etc/ofagent/ofagent.conf"