X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=RO-plugin%2Fosm_ro_plugin%2Fvimconn.py;h=20ab3a3b02370e220e3146701b292c887f8de74c;hb=refs%2Fchanges%2F05%2F12005%2F13;hp=b4e936c1408137d92f36a1e9e78aeaa4359d2f40;hpb=049cbb1b256805f589c24776dcf092c77fefec6a;p=osm%2FRO.git diff --git a/RO-plugin/osm_ro_plugin/vimconn.py b/RO-plugin/osm_ro_plugin/vimconn.py index b4e936c1..20ab3a3b 100644 --- a/RO-plugin/osm_ro_plugin/vimconn.py +++ b/RO-plugin/osm_ro_plugin/vimconn.py @@ -33,6 +33,7 @@ from io import StringIO import logging import socket import sys +import traceback import warnings import paramiko @@ -528,6 +529,29 @@ class VimConnector: """ raise VimConnNotImplemented("Should have implemented this") + def get_affinity_group(self, affinity_group_id): + """Obtain affinity or anti affinity group details from the VIM + Returns the flavor dict details {'id':<>, 'name':<>, other vim specific } + Raises an exception upon error or if not found + """ + raise VimConnNotImplemented("Should have implemented this") + + def new_affinity_group(self, affinity_group_data): + """Adds an affinity or anti affinity group to VIM + affinity_group_data contains a dictionary with information, keys: + name: name in VIM for the affinity or anti-affinity group + type: affinity or anti-affinity + scope: Only nfvi-node allowed + Returns the affinity or anti affinity group identifier + """ + raise VimConnNotImplemented("Should have implemented this") + + def delete_affinity_group(self, affinity_group_id): + """Deletes an affinity or anti affinity group from the VIM identified by its id + Returns the used id or raise an exception + """ + raise VimConnNotImplemented("Should have implemented this") + def new_image(self, image_dict): """Adds a tenant image to VIM Returns the image id or raises an exception if failed @@ -566,6 +590,7 @@ class VimConnector: start, image_id, flavor_id, + affinity_group_list, net_list, cloud_config=None, disk_list=None, @@ -576,6 +601,8 @@ class VimConnector: Params: 'start': (boolean) indicates if VM must start or created in pause mode. 'image_id','flavor_id': image and flavor VIM id to use for the VM + affinity_group_list: list of affinity groups, each one is a dictionary. + Ignore if empty. 'net_list': list of interfaces, each one is a dictionary with: 'name': (optional) name for the interface. 'net_id': VIM network id where this interface must be connect to. Mandatory for type==virtual @@ -730,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: @@ -739,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 @@ -1051,6 +1089,24 @@ 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") + + def resize_instance(self, vm_id, flavor_id=None): + """ + resize a vdu + param: + vm_id: ID of an instance + flavor_id: flavor_id to resize the vdu to + """ + raise VimConnNotImplemented("Should have implemented this") + # NOT USED METHODS in current version. Deprecated @deprecated def host_vim2gui(self, host, server_dict):