def custcopy(name, srcpath): print "Probing VPS version at %s..." % srcpath src = distro_util.probe_vps(srcpath) if not src: print "ERROR: VPS version at %s is unknown to us" % srcpath print "Exiting." return print "Detected %s" % src.get_desc() if src.cancopy() != []: print "ERROR: the source VPS does not have: %s" % ` src.cancopy() ` return vpsroot = os.path.join(cfg.VSERVERS_ROOT, name) print "Probing VPS version at %s..." % vpsroot vps = distro_util.probe_vps(vpsroot) if not vps: print "ERROR: VPS version at %s is unknown to us" % vpsroot print "Exiting." return print "Detected %s" % vps.get_desc() xid = vps.custcopy(src, name, name) vps.fixxids(xid)
def custcopy(name, srcpath): print "Probing VPS version at %s..." % srcpath src = distro_util.probe_vps(srcpath) if not src: print "ERROR: VPS version at %s is unknown to us" % srcpath print "Exiting." return print "Detected %s" % src.get_desc() if src.cancopy() != []: print "ERROR: the source VPS does not have: %s" % `src.cancopy()` return vpsroot = os.path.join(cfg.VSERVERS_ROOT, name) print "Probing VPS version at %s..." % vpsroot vps = distro_util.probe_vps(vpsroot) if not vps: print "ERROR: VPS version at %s is unknown to us" % vpsroot print "Exiting." return print "Detected %s" % vps.get_desc() xid = vps.custcopy(src, name, name) vps.fixxids(xid)
def customize(name, xid, ip, userid, passwd, disklim, dns=cfg.PRIMARY_IP, vpn_ip=None, vpn_mask='255.255.255.0'): vpsroot = os.path.join(cfg.VSERVERS_ROOT, name) print "Probing VPS version at %s..." % vpsroot vps = distro_util.probe_vps(vpsroot) if not vps: print "ERROR: VPS version at %s is unknown to us" % vpsroot print "Exiting." return print "Detected %s" % vps.get_desc() vps.customize(name, xid, ip, userid, passwd, disklim, dns, vpn_ip, vpn_mask) vps.fixxids(xid) vserver_vroot_perms()
def fixxids(vpsroot, xid, pace=cfg.PACE[0]): print "Probing VPS version at %s..." % vpsroot vps = distro_util.probe_vps(vpsroot) if not vps: print "ERROR: VPS version at %s is unknown to us" % vpsroot print "Exiting." return print "Detected %s" % vps.get_desc() vps.fixxids(xid)
def fixflags(refroot): print "Probing VPS version at %s..." % refroot vps = distro_util.probe_vps(refroot) if not vps: print "ERROR: VPS version at %s is unknown to us" % refroot print "Exiting." return print "Detected %s" % vps.get_desc() vps.fixflags()
def clone(source, dest, pace=cfg.PACE[0]): print "Probing VPS version at %s..." % source vps = distro_util.probe_vps(source) if not vps: print "ERROR: VPS version at %s is unknown to us" % source print "Exiting." return print "Detected %s" % vps.get_desc() vps.clone(dest, pace)
def rebuild(refroot, name): # make sure it is stopped if vsutil.is_running(name): print "ERROR: %s is running, you must first stop it" % name return vpspath = os.path.join(cfg.VSERVERS_ROOT, name) # create a rebuild lock lock = os.path.join(cfg.ETC_VSERVERS, name, '.rebuild') if os.path.exists(lock): print "ERROR: %s exists - is it being rebuilt?" % lock print "Cannot rebuild, aborting..." return # create the lock open(lock, 'w') try: print "Probing VPS version at %s..." % vpspath vps = distro_util.probe_vps(vpspath) if not vps: print "ERROR: VPS version at %s is unknown to us" % vpspath print "Exiting." return print "Detected %s" % vps.get_desc() if vps.cancopy() != []: print "ERROR: the source VPS does not have: %s" % ` vps.cancopy() ` print "Cannot rebuild, aborting..." return # need to make sure reference server is good too print "Probing VPS version at %s..." % refroot ref = distro_util.probe_vps(refroot) if not ref: print "ERROR: VPS version at %s is unknown to us" % refroot print "Exiting." return print "Detected %s" % vps.get_desc() # rename it to something temporary. there is a bit of a race # condition here. d = tempfile.mkdtemp(prefix='.rebuild', dir=cfg.VSERVERS_ROOT) os.rmdir(d) temppath = d print 'Renaming %s -> %s...' % (vpspath, temppath) os.rename(vpspath, temppath) # touch it, so that it does not get wiped by the # ovcleanrebuilds cron script os.utime(temppath, None) # clone it clone(refroot, vpspath) #custcopy it custcopy(name, temppath) print 'remember to delete %s' % temppath finally: os.remove(lock)
def rebuild(refroot, name): # make sure it is stopped if vsutil.is_running(name): print "ERROR: %s is running, you must first stop it" % name return vpspath = os.path.join(cfg.VSERVERS_ROOT, name) # create a rebuild lock lock = os.path.join(cfg.ETC_VSERVERS, name, '.rebuild') if os.path.exists(lock): print "ERROR: %s exists - is it being rebuilt?" % lock print "Cannot rebuild, aborting..." return # create the lock open(lock, 'w') try: print "Probing VPS version at %s..." % vpspath vps = distro_util.probe_vps(vpspath) if not vps: print "ERROR: VPS version at %s is unknown to us" % vpspath print "Exiting." return print "Detected %s" % vps.get_desc() if vps.cancopy() != []: print "ERROR: the source VPS does not have: %s" % `vps.cancopy()` print "Cannot rebuild, aborting..." return # need to make sure reference server is good too print "Probing VPS version at %s..." % refroot ref = distro_util.probe_vps(refroot) if not ref: print "ERROR: VPS version at %s is unknown to us" % refroot print "Exiting." return print "Detected %s" % vps.get_desc() # rename it to something temporary. there is a bit of a race # condition here. d = tempfile.mkdtemp(prefix='.rebuild', dir=cfg.VSERVERS_ROOT) os.rmdir(d) temppath = d print 'Renaming %s -> %s...' % (vpspath, temppath) os.rename(vpspath, temppath) # touch it, so that it does not get wiped by the # ovcleanrebuilds cron script os.utime(temppath, None) # clone it clone(refroot, vpspath) #custcopy it custcopy(name, temppath) print 'remember to delete %s' % temppath finally: os.remove(lock)