~tyler-baker/lava-lab/latest-minion

« back to all changes in this revision

Viewing changes to scripts/lava-upgrade

  • Committer: Andy Doan
  • Date: 2013-02-08 04:41:31 UTC
  • mto: This revision was merged to the branch mainline in revision 68.
  • Revision ID: andy.doan@linaro.org-20130208044131-92ukqd5s542qqbrp
add some lava scripts to help manage lab

lava-status - shows the nodes contributing to a lava deployment, if
they are running, and which is the master instance

lava-{start/stop} - start/stop each lava-instance contributing to a lava deployment

lava-upgrade - performs an upgrade for a lava-deployment

lava-addworker - add support for installing a remote worker instance

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import argparse
 
4
 
 
5
import lava_salt
 
6
 
 
7
 
 
8
def _indented(buff, indent_char):
 
9
    indent_char = '\n' + indent_char
 
10
    return '   ' + indent_char.join(buff.split('\n'))
 
11
 
 
12
 
 
13
if __name__ == '__main__':
 
14
    parser = argparse.ArgumentParser(description=lava_salt.upgrade.__doc__)
 
15
    parser.add_argument('instance', metavar='<instance>',
 
16
                        help='The instance name to upgrade')
 
17
    parser.add_argument('--dry-run', dest='dryrun', action='store_true',
 
18
                        help='Just display what would be changed')
 
19
    args = parser.parse_args()
 
20
 
 
21
    client = lava_salt.salt_client()
 
22
    m_ret, w_ret = lava_salt.upgrade(client, args.instance, args.dryrun)
 
23
 
 
24
    print 'Master:'
 
25
    for host, msg in m_ret.iteritems():
 
26
        print ' {0}:'.format(host)
 
27
        print '  upgrade:\n{0}'.format(_indented(msg, '   |'))
 
28
 
 
29
    print '\nWorkers:'
 
30
    for host, rets in w_ret.iteritems():
 
31
        print ' {0}:'.format(host)
 
32
        print '  stop:\n{0}'.format(_indented(rets['stop'], '   |'))
 
33
        print '  upgrade:\n{0}'.format(_indented(rets['upgrade'], '   |'))
 
34
        print '  start:\n{0}'.format(_indented(rets['start'], '   |'))