Close ONOS cli log handles on cli disconnect.
And truncate the onoscli.session file instead of appending to cli session log file on every connect.

Change-Id: I3bdacb5aabd2e708cc8a86d8076a17e2f1bb9077
diff --git a/src/test/cli/component.py b/src/test/cli/component.py
index 12defa8..b56b899 100644
--- a/src/test/cli/component.py
+++ b/src/test/cli/component.py
@@ -1,12 +1,12 @@
-# 
+#
 # Copyright 2016-present Ciena 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.
@@ -96,7 +96,7 @@
         # Adding header for the component log
         vars( main )[ self.name + 'log' ].info( main.logHeader )
         # Opening the session log to append command's execution output
-        self.logfile_handler = open( session_file, "a" )
+        self.logfile_handler = open( session_file, "w" )
 
         return "Dummy"
 
@@ -139,4 +139,3 @@
 if __name__ != "__main__":
     import sys
     sys.modules[ __name__ ] = Component()
-