/silverlining/commands/disable.py

https://bitbucket.org/ianb/silverlining/ · Python · 25 lines · 23 code · 2 blank · 0 comment · 9 complexity · 80518072fcdac39078df0a2433461252 MD5 · raw file

  1. from cmdutils import CommandError
  2. from silversupport.appdata import normalize_location
  3. from silversupport.shell import ssh
  4. def command_disable(config, enable=False):
  5. node, location, appname = None, None, None
  6. if config.args.by_name is not None:
  7. appname = config.args.by_name
  8. if config.args.by_location is not None:
  9. location = config.args.by_location
  10. node, _path = normalize_location(location)
  11. if config.args.node is not None:
  12. node = config.node_hostname
  13. if location and not appname:
  14. stdout, _stderr, _returncode = ssh(
  15. 'www-mgr', node,
  16. '/usr/local/share/silverlining/mgr-scripts/get-application.py',
  17. fail_on_error=True)
  18. appname = stdout.strip()
  19. if node is None or appname is None:
  20. raise CommandError("Unable to determine target node or appname.")
  21. ssh('www-mgr', node,
  22. '/usr/local/share/silverlining/mgr-scripts/disable.py %s %s'
  23. % ('--enable' if enable else '', appname))