PageRenderTime 81ms CodeModel.GetById 40ms app.highlight 3ms RepoModel.GetById 37ms app.codeStats 0ms

/silverlining/commands/disable.py

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