Added copyMininetFile function in onosdriver

Change-Id: I7097f6c201fd32a86b0687d57b43af284c44fe42

Fixed typo and renamed some variable

Change-Id: I7e3e8cdbed136ad8f86dd998269ccedbd0ddf4ed

Remove print statement in copyMininetFile function

Change-Id: I3ebd206d0d84167441224faefa1464d4cf968d72
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index c4e9149..cfceaf9 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -2301,3 +2301,59 @@
             main.log.exception( self.name + ": Uncaught exception!" )
             main.cleanup()
             main.exit()
+
+    def copyMininetFile( self, fileName, localPath, userName, ip,
+                         mnPath='~/mininet/custom/', timeout = 60 ):
+        """
+        Description:
+            Copy mininet topology file from dependency folder in the test folder
+            and paste it to the mininet machine's mininet/custom folder
+        Required:
+            fileName - Name of the topology file to copy
+            localPath - File path of the mininet topology file
+            userName - User name of the mininet machine to send the file to
+            ip - Ip address of the mininet machine
+        Optional:
+            mnPath - of the mininet directory to send the file to
+        Return:
+            Return main.TRUE if successfully copied the file otherwise
+            return main.FALSE
+        """
+
+        try:
+            cmd = "scp " + localPath + fileName + " " + userName + "@" + \
+                  str( ip ) + ":" + mnPath + fileName
+
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+
+            main.log.info( self.name + ": Execute: " + cmd )
+
+            self.handle.sendline( cmd )
+
+            i = self.handle.expect( [ 'No such file',
+                                      "100%",
+                                      pexpect.TIMEOUT ] )
+
+            if i == 0:
+                main.log.error( self.name + ": File " + fileName +
+                                " does not exist!" )
+                return main.FALSE
+
+            if i == 1:
+                main.log.info( self.name + ": File " + fileName +
+                                " has been copied!" )
+                self.handle.sendline( "" )
+                self.handle.expect( "\$" )
+                return main.TRUE
+
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except pexpect.TIMEOUT:
+            main.log.error( self.name + ": TIMEOUT exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
+            main.cleanup()
+            main.exit()