Guest User

install update script for citrix xen 6.2

a guest
Oct 21st, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import sys
  3. print sys.argv
  4. if len(sys.argv)==1:
  5.     sys.exit(0)
  6.    
  7. import commands
  8. for item in sys.argv[1:]:
  9.     print 'item',item
  10.     #unpack
  11.     print commands.getoutput('unzip -o %s'%item)
  12.     #install
  13.     patch_name=item.split('.')[0]
  14.     print 'INSTALL %s' % patch_name
  15.     uuid_update=commands.getoutput('xe patch-upload file-name=%s.xsupdate'%patch_name)
  16.     print 'result'
  17.     print uuid_update
  18.     #apply to hosts
  19.     '''
  20.    uuid ( RO)                : 7f36dd15-3fdb-4daf-a259-971df8276ae1
  21.    name-label ( RW): xen
  22.    name-description ( RW): Default install of XenServer
  23.    '''
  24.     hosts=commands.getoutput('xe host-list')
  25.     import re
  26.     #found_result=re.findall('uuid\.*:\s([0-9a-z\-]',hosts)
  27.     for uuid_host in re.findall('uuid \( RO\)\s+:\s([0-9a-z-]+)',hosts):
  28.         print 'APPLY TO HOST',uuid_host
  29.         commands.getoutput('xe patch-apply host-uuid=%s uuid=%s'%(uuid_host,uuid_update))
  30.     commands.getoutput('xe-toolstack-restart')
  31. print 'SUCCSESFUL'
Advertisement
Add Comment
Please, Sign In to add comment