- Timestamp:
- Mar 30, 2008, 4:02:48 AM (17 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-guest-installer/files/usr/sbin/sipb-xen-lvcopy
r336 r338 79 79 80 80 def frob_copy(target, *args): 81 '''UNUSED: maybe we'll use this someday; it does isolate the frobber.''' 81 82 # 1. prepare arguments volume 82 83 args_volume = prefix+target+'_args' … … 95 96 # XXX should check_call(['/sbin/lvremove', '-f', 'xenvg/'+args_volume]) 96 97 97 def frob_copy_simple(target, hostname, rootpw , *args):98 def frob_copy_simple(target, hostname, rootpw): 98 99 """target should be an LV device filename 99 100 … … 128 129 os.chdir('/') 129 130 call(['umount', mntdir]) 131 os.rmdir(mntdir) 130 132 call(['losetup', '-d', fs]) 131 133 132 def duplicate_by_vm(source, target, *args):134 def duplicate_by_vm(source, target, rootpw, nodd=False): 133 135 # source, target should be machine names 134 136 prefix = 'd_' … … 136 138 source_device = '/dev/xenvg/' + prefix + source + '_hda' 137 139 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]) 140 143 # 2. frob target 141 frob_copy_simple(target_device, *args) 144 frob_copy_simple(target_device, target, rootpw) 145 146 def 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 142 160 143 161 if __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.