Update paramiko version to 2.11.0
[osm/RO.git] / RO-plugin / osm_ro_plugin / vimconn.py
index 50e14fa..2baa202 100644 (file)
@@ -33,6 +33,7 @@ from io import StringIO
 import logging
 import socket
 import sys
+import traceback
 import warnings
 
 import paramiko
@@ -756,6 +757,11 @@ class VimConnector:
                 "chmod 644 ~/.ssh/authorized_keys",
                 "chmod 700 ~/.ssh/",
             }
+
+            logging.basicConfig(
+                format="%(asctime)s %(levelname)s %(name)s %(filename)s:%(lineno)s %(message)s"
+            )
+            logging.getLogger("paramiko").setLevel(logging.DEBUG)
             client = paramiko.SSHClient()
 
             try:
@@ -765,33 +771,39 @@ class VimConnector:
                     pkey = None
 
                 client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+
                 client.connect(
-                    ip_addr, username=user, password=password, pkey=pkey, timeout=10
+                    ip_addr,
+                    username=user,
+                    password=password,
+                    pkey=pkey,
+                    timeout=30,
+                    auth_timeout=60,
                 )
 
                 for command in commands:
-                    (i, o, e) = client.exec_command(command, timeout=10)
+                    (i, o, e) = client.exec_command(command, timeout=30)
                     returncode = o.channel.recv_exit_status()
                     outerror = e.read()
 
                     if returncode != 0:
                         text = "run_command='{}' Error='{}'".format(command, outerror)
+                        self.logger.debug(traceback.format_tb(e.__traceback__))
                         raise VimConnUnexpectedResponse(
                             "Cannot inject ssh key in VM: '{}'".format(text)
                         )
-
                         return
             except (
                 socket.error,
                 paramiko.AuthenticationException,
                 paramiko.SSHException,
             ) as message:
+                self.logger.debug(traceback.format_exc())
                 raise VimConnUnexpectedResponse(
                     "Cannot inject ssh key in VM: '{}' - {}".format(
                         ip_addr, str(message)
                     )
                 )
-
                 return
 
     # Optional methods
@@ -1077,6 +1089,15 @@ class VimConnector:
         """
         raise VimConnNotImplemented("SFC support not implemented")
 
+    def migrate_instance(self, vm_id, compute_host=None):
+        """Migrate a vdu
+        Params:
+            vm_id: ID of an instance
+            compute_host: Host to migrate the vdu to
+        Returns the vm state or raises an exception upon error
+        """
+        raise VimConnNotImplemented("Should have implemented this")
+
     # NOT USED METHODS in current version. Deprecated
     @deprecated
     def host_vim2gui(self, host, server_dict):