Changeset 338 for trunk


Ignore:
Timestamp:
Mar 30, 2008, 4:02:48 AM (17 years ago)
Author:
price
Message:

some cleanups in copying autoinstaller

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-guest-installer/files/usr/sbin/sipb-xen-lvcopy

    r336 r338  
    7979
    8080def frob_copy(target, *args):
     81  '''UNUSED: maybe we'll use this someday; it does isolate the frobber.'''
    8182  # 1. prepare arguments volume
    8283  args_volume = prefix+target+'_args'
     
    9596  # XXX should check_call(['/sbin/lvremove', '-f', 'xenvg/'+args_volume])
    9697
    97 def frob_copy_simple(target, hostname, rootpw, *args):
     98def frob_copy_simple(target, hostname, rootpw):
    9899  """target should be an LV device filename
    99100
     
    128129  os.chdir('/')
    129130  call(['umount', mntdir])
     131  os.rmdir(mntdir)
    130132  call(['losetup', '-d', fs])
    131133
    132 def duplicate_by_vm(source, target, *args):
     134def duplicate_by_vm(source, target, rootpw, nodd=False):
    133135  # source, target should be machine names
    134136  prefix = 'd_'
     
    136138  source_device = '/dev/xenvg/' + prefix + source + '_hda'
    137139  target_device = '/dev/xenvg/' + prefix + target + '_hda'
    138   check_call(['/bin/dd', 'bs=1M', 'conv=nocreat',
    139               'if='+source_device, 'of='+target_device])
     140  if not nodd:
     141    check_call(['/bin/dd', 'bs=1M', 'conv=nocreat',
     142                'if='+source_device, 'of='+target_device])
    140143  # 2. frob target
    141   frob_copy_simple(target_device, *args)
     144  frob_copy_simple(target_device, target, rootpw)
     145
     146def main(*argv):
     147  subcommand = argv[1]
     148  args = argv[2:]
     149  os.environ['PATH'] = '/usr/sbin:/usr/bin:/sbin:/bin'
     150  if subcommand == 'lvcopy':
     151    kwargs = {}
     152    if args[0] == '--nodd':
     153      args = args[1:]
     154      kwargs['nodd'] = True
     155    duplicate_by_vm(*args, **kwargs)
     156  else:
     157    print >>sys.stderr, argv[0]+": unknown subcommand: "+subcommand
     158    return 2
     159  return 0
    142160
    143161if __name__ == '__main__':
    144   duplicate_by_vm(*sys.argv[1:])
     162  sys.exit(main(*sys.argv))
Note: See TracChangeset for help on using the changeset viewer.