diff options
| author | Hans Lindgren <hanlind@kth.se> | 2013-03-12 14:42:36 +0100 |
|---|---|---|
| committer | Hans Lindgren <hanlind@kth.se> | 2013-03-12 15:06:07 +0100 |
| commit | 071a41f1d052bd01b181e4ae5d6e9aa5f0b39b8b (patch) | |
| tree | 12bc962dcc1316ac6721c6d50477276f79855f76 /bin | |
| parent | 562b0787421b145c4a91ccbbcacfc74c340cead8 (diff) | |
Fix: nova-manage throws uncaught exception on invalid host/service
Add a test case for this too.
Fix bug 1154089.
Change-Id: I3a60e581a9fac945fddf72c4f037ca5cae0005fc
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/nova-manage | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/bin/nova-manage b/bin/nova-manage index 274ae4640..96e4a4012 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -675,11 +675,13 @@ class ServiceCommands(object): def enable(self, host, service): """Enable scheduling for a service.""" ctxt = context.get_admin_context() - svc = db.service_get_by_args(ctxt, host, service) - if not svc: - print _("Unable to find service") - return - db.service_update(ctxt, svc['id'], {'disabled': False}) + try: + svc = db.service_get_by_args(ctxt, host, service) + db.service_update(ctxt, svc['id'], {'disabled': False}) + except exception.NotFound as ex: + print _("error: %s") % ex + sys.exit(2) + print _("Service %(service)s on host %(host)s enabled.") % locals() @args('--host', dest='host', metavar='<host>', help='Host') @args('--service', dest='service', metavar='<service>', @@ -687,11 +689,13 @@ class ServiceCommands(object): def disable(self, host, service): """Disable scheduling for a service.""" ctxt = context.get_admin_context() - svc = db.service_get_by_args(ctxt, host, service) - if not svc: - print _("Unable to find service") - return - db.service_update(ctxt, svc['id'], {'disabled': True}) + try: + svc = db.service_get_by_args(ctxt, host, service) + db.service_update(ctxt, svc['id'], {'disabled': True}) + except exception.NotFound as ex: + print _("error: %s") % ex + sys.exit(2) + print _("Service %(service)s on host %(host)s disabled.") % locals() @args('--host', dest='host', metavar='<host>', help='Host') def describe_resource(self, host): |
