Fix flake8 09/8309/1
authorquilesj <e.nvi001.tid@telefonica.com>
Fri, 29 Nov 2019 11:19:14 +0000 (11:19 +0000)
committerquilesj <e.nvi001.tid@telefonica.com>
Wed, 4 Dec 2019 07:53:49 +0000 (07:53 +0000)
Change-Id: Ia81b37958ab03630cf9f3c65ab1ec59a95f82d68
Signed-off-by: quilesj <e.nvi001.tid@telefonica.com>
n2vc/juju_observer.py
n2vc/n2vc_conn.py
n2vc/n2vc_juju_conn.py

index f4102a4..25c1c1f 100644 (file)
@@ -54,7 +54,7 @@ class JujuModelObserver(ModelObserver):
     def register_machine(self, machine: Machine, db_dict: dict):
         try:
             entity_id = machine.entity_id
-        except:
+        except Exception as e:
             # no entity_id aatribute, try machine attribute
             entity_id = machine.machine
         self.n2vc.debug(msg='Registering machine for changes notifications: {}'.format(entity_id))
index d3aaf35..8f6c3ef 100644 (file)
@@ -64,7 +64,7 @@ class N2VCConnector(abc.ABC, Loggable):
             url: str,
             username: str,
             vca_config: dict,
-            on_update_db = None
+            on_update_db=None
     ):
         """Initialize N2VC abstract connector. It defines de API for VCA connectors
 
@@ -440,6 +440,8 @@ def juju_status_2_osm_status(type: str, status: str) -> N2VCDeploymentStatus:
     if type == 'application' or type == 'unit':
         if status in ['waiting', 'maintenance']:
             return N2VCDeploymentStatus.RUNNING
+        if status in ['error']:
+                return N2VCDeploymentStatus.FAILED
         elif status in ['active']:
             return N2VCDeploymentStatus.COMPLETED
         elif status in ['blocked']:
index a9f9b76..6ada220 100644 (file)
@@ -1021,9 +1021,6 @@ class N2VCJujuConnector(N2VCConnector):
             total_timeout: float = None
     ):
 
-        # get juju model
-        model = await self._juju_get_model(model_name=model_name)
-
         # get the application
         application = await self._juju_get_application(model_name=model_name, application_name=application_name)
 
@@ -1042,10 +1039,11 @@ class N2VCJujuConnector(N2VCConnector):
                 )
 
         # check if 'verify-ssh-credentials' action exists
-        unit = application.units[0]
+        unit = application.units[0]
         actions = await application.get_actions()
         if 'verify-ssh-credentials' not in actions:
             msg = 'Action verify-ssh-credentials does not exist in application {}'.format(application_name)
+            self.debug(msg=msg)
             return False
 
         # execute verify-credentials