Update status messages to fix bug 49
authorAdam Israel <adam.israel@canonical.com>
Tue, 27 Sep 2016 12:48:37 +0000 (08:48 -0400)
committerAdam Israel <adam.israel@canonical.com>
Tue, 27 Sep 2016 12:48:37 +0000 (08:48 -0400)
Change-Id: Ia577db687cf2aa659d22afd18e316a73a85aae05
Signed-off-by: Adam Israel <adam.israel@canonical.com>
vpe-router/reactive/vpe_router.py

index c62983d..e2be327 100644 (file)
@@ -39,6 +39,8 @@ def validate_config():
                 out, err = router.ssh(['whoami'], routerip,
                                       user, passwd)
                 if out.strip() != user:
+                    remove_state('vpe.configured')
+                    status_set('blocked', 'vpe is not configured')
                     raise Exception('invalid credentials')
 
                 # Set the router's hostname
@@ -56,15 +58,18 @@ def validate_config():
                                                ],
                                               routerip,
                                               user, passwd)
-
+                        set_state('vpe.configured')
+                        status_set('active', 'ready!')
+                    else:
+                        remove_state('vpe.configured')
+                        status_set('blocked', 'vpe is not configured')
                 except subprocess.CalledProcessError as e:
+                    remove_state('vpe.configured')
+                    status_set('blocked', 'validation failed: %s' % e)
                     log('Command failed: %s (%s)' %
                         (' '.join(e.cmd), str(e.output)))
                     raise
 
-        set_state('vpe.configured')
-        status_set('active', 'ready!')
-
     except Exception as e:
         log(repr(e))
         remove_state('vpe.configured')