def vps_open (self, vps, vps_image=None, is_new=True): self.logger.info ("to open vps %s" % (vps.id)) if vps.host_id != self.host_id: msg = "vpsopen : vps %s host_id=%s != current host %s , abort" % (vps.id, vps.host_id, self.host_id) self.logger.error (msg) self.done_task (Cmd.OPEN, vps.id, False, msg) return if not vps.ipv4 or not vps.ipv4_gateway or vps.cpu <= 0 or vps.ram <= 0 or vps.hd <= 0 or not vps.password: self.logger.error ("vps open: invalid vps data received: %s" % (self.dump_vps_info (vps))) self.done_task (Cmd.OPEN, vps.id, False, "invalid vps data") return xv = XenVPS (vps.id) vpsops = VPSOps (self.logger) try: self.setup_vps (xv, vps) if xv.is_running (): msg = "vps %s is running" % (vps.id) self.logger_err.error (msg) self.done_task (Cmd.OPEN, vps.id, False, msg) return if vps.state in [vps_const.VPS_STATE_PAY, vps_const.VPS_STATE_RUN]: vpsops.create_vps (xv, vps_image, is_new) elif vps.state == vps_const.VPS_STATE_CLOSE: vpsops.reopen_vps (vps.id, xv) else: msg = "vps%s state is %s(%s)" % (str(vps.id), vps.state, vps_const.VPS_STATE2CN[vps.state]) self.logger_err.error (msg) self.done_task (Cmd.OPEN, vps.id, False, msg) return except Exception, e: self.logger_err.exception ("for %s: %s" % (str(vps.id), str(e))) self.done_task (Cmd.OPEN, vps.id, False, "error, " + str(e)) return
def test_create_vps0 (self): print "create vps00" logger = Log ("test", config=conf) vpsops = VPSOps (logger) vps = XenVPS (0) try: vps.setup (os_id=20001, vcpu=1, mem_m=512, disk_g=7, ip="113.11.199.3", netmask="255.255.255.0", gateway="113.11.199.1", root_pw="fdfdfd") #vps.add_extra_storage (disk_id=1, size_g=1, fs_type='ext3') #vps.add_extra_storage (disk_id=2, size_g=0.5, fs_type='ext4') #vps.setup (os_id=10001, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") #vps.setup (os_id=10002, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") #vps.setup (os_id=30001, vcpu=1, mem_m=512, disk_g=7, ip="10.10.2.2", netmask="255.255.255.0", gateway="10.10.2.1", root_pw="root") #vps.setup (os_id=1, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") #vps.setup (os_id=10000, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") #vps.setup (os_id=20001, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") #vps.setup (os_id=10003, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") #vps.setup (os_id=20001, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") print vps.gen_xenpv_config () #vpsops.create_vps (vps, vps_image='/data/vps/images/arch-2011.08.19-i386-fs-ext3.tar.gz') vpsops.create_vps (vps) except Exception, e: print str(e) logger.exception (e) raise e
def gen_meta(vps_mgr, domain_dict, vps_id): xv = XenVPS(vps_id) vps = vps_mgr.query_vps(vps_id) if not vps_mgr.vps_is_valid(vps): print "no backend data for %s " % vps_id return domain_id = domain_dict[xv.name] vif_datas = XenStore.get_vif_by_domain_id(domain_id) vps_mgr.setup_vps(xv, vps) #xv.add_extra_storage (1, 964) #TEST vpsops = VPSOps(vps_mgr.logger) if len(vif_datas.values()) == 1: vif_data = vif_datas.values()[0] if vif_data['online'] == '1': if vif_data.has_key('vifname'): xv.vifs[vif_data['vifname']].mac = vif_data['mac'] else: vif_id = vif_datas.items()[0][0] vif_name = 'vif%s.%s' % (domain_id, vif_id) del xv.vifs[xv.name] xv.add_netinf_ext(ip=xv.ip, netmask=xv.netmask, mac=vif_data['mac']) #vpsops.create_xen_config (xv) vpsops.save_vps_meta(xv, override=True)
def save_closed_vps(self, meta, origin_host_id): try: xv = XenVPS.from_meta(meta) self.logger.info("closed vps %s immigrate from host=%s" % (xv.vps_id, origin_host_id)) vpsops = VPSOps(self.logger) vpsops.save_vps_meta(xv, is_trash=True) except Exception, e: self.logger.exception(e) raise
def vps_close(self, vps): try: assert vps.state == vps_const.VPS_STATE_CLOSE vpsops = VPSOps(self.logger) xv = XenVPS(vps.id) self.setup_vps(xv, vps) vpsops.close_vps(vps.id, xv) except Exception, e: self.logger_err.exception(e) self.done_task(Cmd.CLOSE, vps.id, False, "exception %s" % (str(e))) return
def _vps_delete(self, vps_id, vps=None): try: vpsops = VPSOps(self.logger) xv = None if vps: xv = XenVPS(vps_id) self.setup_vps(xv, vps) vpsops.delete_vps(vps_id, xv) except Exception, e: self.logger_err.exception(e) raise e
def create_vps(self, meta, origin_host_id): try: xv = XenVPS.from_meta(meta) self.logger.info("vps %s immigrate from host=%s" % (xv.vps_id, origin_host_id)) vpsops = VPSOps(self.logger) # some setting various between different hosts vpsops.create_from_migrate(xv.clone()) except Exception, e: self.logger.exception(e) raise
def vps_close (self, vps): try: assert vps.state == vps_const.VPS_STATE_CLOSE vpsops = VPSOps (self.logger) xv = XenVPS (vps.id) self.setup_vps (xv, vps) vpsops.close_vps (vps.id, xv) except Exception, e: self.logger_err.exception (e) self.done_task (Cmd.CLOSE, vps.id, False, "exception %s" % (str(e))) return
def modify_vif_rate (self, vps): xv = XenVPS (vps.id) vpsops = VPSOps (self.logger) self.logger.info ("to modify vif rate for vps %s" % (vps.id)) try: self.setup_vps (xv, vps) vpsops.create_xen_config (vps) except Exception, e: self.logger_err.exception (e) self.done_task (Cmd.BANDWIDTH, vps.id, False, "exception %s" % (str(e))) return
def _vps_delete (self, vps_id, vps=None): try: vpsops = VPSOps (self.logger) xv = None if vps: xv = XenVPS (vps_id) self.setup_vps (xv, vps) vpsops.delete_vps (vps_id, xv) except Exception, e: self.logger_err.exception (e) raise e
def vps_reboot (self, vps): xv = XenVPS (vps.id) self.logger.info ("to reboot vps %s" % (vps.id)) vpsops = VPSOps (self.logger) try: self.setup_vps (xv, vps) vpsops.reboot_vps (xv) except Exception, e: self.logger_err.exception (e) self.done_task (Cmd.REBOOT, vps.id, False, "exception %s" % (str(e))) return
def modify_vif_rate(self, vps): xv = XenVPS(vps.id) vpsops = VPSOps(self.logger) self.logger.info("to modify vif rate for vps %s" % (vps.id)) try: self.setup_vps(xv, vps) vpsops.create_xen_config(vps) except Exception, e: self.logger_err.exception(e) self.done_task(Cmd.BANDWIDTH, vps.id, False, "exception %s" % (str(e))) return
def vps_reboot(self, vps): xv = XenVPS(vps.id) self.logger.info("to reboot vps %s" % (vps.id)) vpsops = VPSOps(self.logger) try: self.setup_vps(xv, vps) vpsops.reboot_vps(xv) except Exception, e: self.logger_err.exception(e) self.done_task(Cmd.REBOOT, vps.id, False, "exception %s" % (str(e))) return
def test_vps0 (self): print "create vps00" logger = Log ("test", config=conf) vpsops = VPSOps (logger) xv = XenVPS (0) try: xv.setup (os_id=10001, vcpu=1, mem_m=512, disk_g=7, ip="10.10.2.2", netmask="255.255.255.0", gateway="10.10.2.1", root_pw="fdfdfd") xv.add_extra_storage (disk_id=1, size_g=1, fs_type='ext3') print xv.gen_xenpv_config () vpsops.create_vps (xv) except Exception, e: logger.exception (e) raise e
def _reinstall_os(self, vps_id, _vps=None, os_id=None, vps_image=None): try: vpsops = VPSOps(self.logger) xv = None if _vps: xv = XenVPS(_vps.id) self.setup_vps(xv, _vps) vpsops.reinstall_os(vps_id, xv, os_id, vps_image) if _vps: self.done_task(Cmd.OS, vps_id, True) return True except Exception, e: self.logger_err.exception("for %s: %s" % (str(vps_id), str(e))) if _vps: self.done_task(Cmd.OS, vps_id, False, "error," + str(e)) return False
def _reinstall_os (self, vps_id, _vps=None, os_id=None, vps_image=None): try: vpsops = VPSOps (self.logger) xv = None if _vps: xv = XenVPS (_vps.id) self.setup_vps (xv, _vps) vpsops.reinstall_os (vps_id, xv, os_id, vps_image) if _vps: self.done_task (Cmd.OS, vps_id, True) return True except Exception, e: self.logger_err.exception ("for %s: %s" % (str(vps_id), str(e))) if _vps: self.done_task (Cmd.OS, vps_id, False, "error," +str(e)) return False
def __init__(self): self.logger = Log("vps_mgr", config=conf) self.logger_net = Log("vps_mgr_net", config=conf) self.logger_misc = Log("misc", config=conf) self.logger_debug = Log("debug", config=conf) self.host_id = conf.HOST_ID self.vpsops = VPSOps(self.logger) self.handlers = { CMD.OPEN: self.__class__.vps_open, CMD.REBOOT: self.__class__.vps_reboot, CMD.CLOSE: self.__class__.vps_close, CMD.OS: self.__class__.vps_reinstall_os, CMD.UPGRADE: self.__class__.vps_upgrade, CMD.BANDWIDTH: self.__class__.vps_set_bandwidth, CMD.RM: self.__class__.vps_delete, CMD.PRE_SYNC: self.__class__.vps_hot_sync, CMD.MIGRATE: self.__class__.vps_migrate, CMD.RESET_PW: self.__class__.vps_reset_pw, } self._locker = threading.Lock() self._vps_locker = dict() self.xenstat = XenStat() self.timer = TimerEvents(time.time, self.logger_misc) assert conf.MONITOR_COLLECT_INV > 0 self.last_netflow = None self.last_diskstat = None self.monitor_inv = conf.MONITOR_COLLECT_INV self.last_monitor_ts = None self.timer.add_timer(conf.MONITOR_COLLECT_INV, self.monitor_vps) self.timer.add_timer(12 * 3600, self.refresh_host_space) self.workers = [] self.running = False
def test_meta(self): print "test vps meta" logger = Log("test", config=conf) vpsops = VPSOps(logger) vps = XenVPS(0) vps.setup(os_id=50001, vcpu=1, mem_m=500000, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") vps.add_extra_storage(disk_id=1, size_g=1, fs_type='ext3') vps.add_netinf('vps0_inter', "10.10.3.2", '255.255.255.0', 'xenbr0', None) vps.data_disks['xvdc1']._set_expire_days(1) print "trash_date", vps.data_disks['xvdc1'].trash_date print "expire_date", vps.data_disks['xvdc1'].expire_date vpsops.save_vps_meta(vps) _vps = vpsops.load_vps_meta(0) self.assertEqual(_vps.vps_id, vps.vps_id) self.assertEqual(_vps.os_id, vps.os_id) self.assertEqual(_vps.vcpu, vps.vcpu) self.assertEqual(_vps.mem_m, vps.mem_m) self.assertEqual(_vps.ip, vps.ip) self.assertEqual(_vps.netmask, vps.netmask) self.assertEqual(_vps.gateway, vps.gateway) self.assertEqual(_vps.root_store.size_g, vps.root_store.size_g) self.assertEqual(_vps.swap_store.size_g, vps.swap_store.size_g) self.assertEqual(_vps.data_disks['xvdc1'].size_g, 1) self.assertEqual(_vps.data_disks['xvdc1'].fs_type, 'ext3') self.assertEqual(_vps.data_disks['xvdc1'].mount_point, '/mnt/data1') self.assertEqual(_vps.data_disks['xvdc1'].xen_dev, 'xvdc1') self.assertEqual(_vps.data_disks['xvdc1'].trash_date, vps.data_disks['xvdc1'].trash_date) self.assertEqual(_vps.data_disks['xvdc1'].expire_date, vps.data_disks['xvdc1'].expire_date) print _vps.data_disks['xvdc1'].__class__.__name__ self.assertEqual(len(_vps.vifs.values()), 2) self.assertEqual(_vps.vifs['vps0_inter'].ip, '10.10.3.2') self.assertEqual(_vps.vifs['vps0_inter'].netmask, '255.255.255.0') self.assertEqual(_vps.vifs['vps0_inter'].bridge, 'xenbr0') self.assertEqual(_vps.vifs['vps0_inter'].mac, vps.vifs['vps0_inter'].mac) print "test trash expire date None" vps.data_disks['xvdc1']._set_expire_days(None) self.assertEqual(vps.data_disks['xvdc1'].trash_date, None) self.assertEqual(vps.data_disks['xvdc1'].expire_date, None) vpsops.save_vps_meta(vps) _vps = vpsops.load_vps_meta(0) self.assertEqual(_vps.data_disks['xvdc1'].trash_date, None) self.assertEqual(_vps.data_disks['xvdc1'].expire_date, None)
def test_vps0(self): print "create vps00" logger = Log("test", config=conf) vpsops = VPSOps(logger) xv = XenVPS(0) try: xv.setup(os_id=10001, vcpu=1, mem_m=512, disk_g=7, ip="10.10.2.2", netmask="255.255.255.0", gateway="10.10.2.1", root_pw="fdfdfd") xv.add_extra_storage(disk_id=1, size_g=1, fs_type='ext3') print xv.gen_xenpv_config() vpsops.create_vps(xv) except Exception, e: logger.exception(e) raise e
def main(): bridge = args[0] vif_name = args[1] logger = Log("vps_mgr", config=conf) vpsops = VPSOps(logger) logger.debug("set %s" % vif_name) try: ovsops = OVSOps() om = re.match(r'^\w+?(\d+)\w*?$', vif_name) if not om: print >> sys.stderr, "wrong vif format %s" % (vif_name) return 1 vps_id = int(om.group(1)) xv = vpsops.load_vps_meta(vps_id) vif = xv.vifs.get(vif_name) if not vif: logger.error("no vif %s in metadata of %s" % (vif_name, vps_id)) return 1 ofport = ovsops.find_ofport_by_name(vif_name) if ofport < 0: logger.error( "vif %s ofport=%s, fix it by delete the port from bridge " % (vif_name, ofport)) ovsops.del_port_from_bridge(bridge, vif_name) ovsops.add_port_to_bridge(bridge, vif_name) ofport = ovsops.find_ofport_by_name(vif_name) if ofport < 0: logger.error("vif %s ofport=%s, impossible " % (vif_name, ofport)) if ofport >= 0: ovsops.set_mac_filter(bridge, ofport, vif.ip_dict.keys()) ovsops.unset_traffic_limit(vif_name) bandwidth = float(vif.bandwidth or 0) ovsops.set_traffic_limit(vif_name, int(bandwidth * 1000)) print "set vif %s bandwidth %sm/s" % (vif_name, vif.bandwidth) return 0 except Exception, e: logger.exception(e) print >> sys.stderr, str(e) return 1
def main(): bridge = args[0] vif_name = args[1] logger = Log("vps_mgr", config=conf) vpsops = VPSOps(logger) logger.debug("set %s" % vif_name) try: ovsops = OVSOps() om = re.match(r"^\w+?(\d+)\w*?$", vif_name) if not om: print >> sys.stderr, "wrong vif format %s" % (vif_name) return 1 vps_id = int(om.group(1)) xv = vpsops.load_vps_meta(vps_id) vif = xv.vifs.get(vif_name) if not vif: logger.error("no vif %s in metadata of %s" % (vif_name, vps_id)) return 1 ofport = ovsops.find_ofport_by_name(vif_name) if ofport < 0: logger.error("vif %s ofport=%s, fix it by delete the port from bridge " % (vif_name, ofport)) ovsops.del_port_from_bridge(bridge, vif_name) ovsops.add_port_to_bridge(bridge, vif_name) ofport = ovsops.find_ofport_by_name(vif_name) if ofport < 0: logger.error("vif %s ofport=%s, impossible " % (vif_name, ofport)) if ofport >= 0: ovsops.set_mac_filter(bridge, ofport, vif.ip_dict.keys()) ovsops.unset_traffic_limit(vif_name) bandwidth = float(vif.bandwidth or 0) ovsops.set_traffic_limit(vif_name, int(bandwidth * 1000)) print "set vif %s bandwidth %sm/s" % (vif_name, vif.bandwidth) return 0 except Exception, e: logger.exception(e) print >> sys.stderr, str(e) return 1
def gen_meta (vps_mgr, domain_dict, vps_id): xv = XenVPS (vps_id) vps = vps_mgr.query_vps (vps_id) if not vps_mgr.vps_is_valid (vps): print "no backend data for %s " % vps_id return domain_id = domain_dict[xv.name] vif_datas = XenStore.get_vif_by_domain_id (domain_id) vps_mgr.setup_vps (xv, vps) #xv.add_extra_storage (1, 964) #TEST vpsops = VPSOps (vps_mgr.logger) if len (vif_datas.values ()) == 1: vif_data = vif_datas.values()[0] if vif_data['online'] == '1': if vif_data.has_key ('vifname'): xv.vifs[vif_data['vifname']].mac = vif_data['mac'] else: vif_id = vif_datas.items ()[0][0] vif_name = 'vif%s.%s' % (domain_id, vif_id) del xv.vifs[xv.name] xv.add_netinf (name=vif_name, ip=xv.ip, netmask=xv.netmask,bridge=vif_data['bridge'], mac=vif_data['mac']) #vpsops.create_xen_config (xv) vpsops.save_vps_meta (xv, override=False)
def test_meta (self): print "test vps meta" logger = Log ("test", config=conf) vpsops = VPSOps (logger) vps = XenVPS (0) vps.setup (os_id=50001, vcpu=1, mem_m=500000, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") vps.add_extra_storage (disk_id=1, size_g=1, fs_type='ext3') vps.add_netinf ('vps0_inter', "10.10.3.2", '255.255.255.0', 'xenbr0', None) vps.data_disks['xvdc1']._set_expire_days (1) print "trash_date", vps.data_disks['xvdc1'].trash_date print "expire_date", vps.data_disks['xvdc1'].expire_date vpsops.save_vps_meta (vps) _vps = vpsops.load_vps_meta (0) self.assertEqual (_vps.vps_id, vps.vps_id) self.assertEqual (_vps.os_id, vps.os_id) self.assertEqual (_vps.vcpu, vps.vcpu) self.assertEqual (_vps.mem_m, vps.mem_m) self.assertEqual (_vps.ip, vps.ip) self.assertEqual (_vps.netmask, vps.netmask) self.assertEqual (_vps.gateway, vps.gateway) self.assertEqual (_vps.root_store.size_g, vps.root_store.size_g) self.assertEqual (_vps.swap_store.size_g, vps.swap_store.size_g) self.assertEqual (_vps.data_disks['xvdc1'].size_g, 1) self.assertEqual (_vps.data_disks['xvdc1'].fs_type, 'ext3') self.assertEqual (_vps.data_disks['xvdc1'].mount_point, '/mnt/data1') self.assertEqual (_vps.data_disks['xvdc1'].xen_dev, 'xvdc1') self.assertEqual (_vps.data_disks['xvdc1'].trash_date, vps.data_disks['xvdc1'].trash_date) self.assertEqual (_vps.data_disks['xvdc1'].expire_date, vps.data_disks['xvdc1'].expire_date) print _vps.data_disks['xvdc1'].__class__.__name__ self.assertEqual (len (_vps.vifs.values ()), 2) self.assertEqual (_vps.vifs['vps0_inter'].ip, '10.10.3.2') self.assertEqual (_vps.vifs['vps0_inter'].netmask, '255.255.255.0') self.assertEqual (_vps.vifs['vps0_inter'].bridge, 'xenbr0') self.assertEqual (_vps.vifs['vps0_inter'].mac, vps.vifs['vps0_inter'].mac) print "test trash expire date None" vps.data_disks['xvdc1']._set_expire_days (None) self.assertEqual (vps.data_disks['xvdc1'].trash_date, None) self.assertEqual (vps.data_disks['xvdc1'].expire_date, None) vpsops.save_vps_meta (vps) _vps = vpsops.load_vps_meta (0) self.assertEqual (_vps.data_disks['xvdc1'].trash_date, None) self.assertEqual (_vps.data_disks['xvdc1'].expire_date, None)
def vps_open(self, vps, vps_image=None, is_new=True): self.logger.info("to open vps %s" % (vps.id)) if vps.host_id != self.host_id: msg = "vpsopen : vps %s host_id=%s != current host %s , abort" % ( vps.id, vps.host_id, self.host_id) self.logger.error(msg) self.done_task(Cmd.OPEN, vps.id, False, msg) return if not vps.ipv4 or not vps.ipv4_gateway or vps.cpu <= 0 or vps.ram <= 0 or vps.hd <= 0 or not vps.password: self.logger.error("vps open: invalid vps data received: %s" % (self.dump_vps_info(vps))) self.done_task(Cmd.OPEN, vps.id, False, "invalid vps data") return xv = XenVPS(vps.id) vpsops = VPSOps(self.logger) try: self.setup_vps(xv, vps) if xv.is_running(): msg = "vps %s is running" % (vps.id) self.logger_err.error(msg) self.done_task(Cmd.OPEN, vps.id, False, msg) return if vps.state in [vps_const.VPS_STATE_PAY, vps_const.VPS_STATE_RUN]: vpsops.create_vps(xv, vps_image, is_new) elif vps.state == vps_const.VPS_STATE_CLOSE: vpsops.reopen_vps(vps.id, xv) else: msg = "vps%s state is %s(%s)" % (str( vps.id), vps.state, vps_const.VPS_STATE2CN[vps.state]) self.logger_err.error(msg) self.done_task(Cmd.OPEN, vps.id, False, msg) return except Exception, e: self.logger_err.exception("for %s: %s" % (str(vps.id), str(e))) self.done_task(Cmd.OPEN, vps.id, False, "error, " + str(e)) return
from ops.vps import XenVPS from ops.vps_ops import VPSOps def move_closed_vps(vps_id, dest_ip, speed=None, force=False): logger = Log("vps_mgr", config=conf) client = VPSMgr() vps_info = None try: vps_info = client.query_vps(vps_id) except Exception, e: print "failed to query vps state: [%s] %s" % (type(e), str(e)) if not force: os._exit(1) try: vpsops = VPSOps(logger) xv = None if vps_info: xv = XenVPS(vps_info.id) client.setup_vps(xv, vps_info) migclient = MigrateClient(logger, dest_ip) vpsops.migrate_closed_vps(migclient, vps_id, dest_ip, speed=speed, _xv=xv) print "ok" except Exception, e: logger.exception(e) raise e def usage(): print "usage: %s [ --speed MBbit/s] vps_id [vps_id2 ...] dest_ip" % (sys.argv[0])
from ops.vps import XenVPS from ops.vps_ops import VPSOps def move_closed_vps(vps_id, dest_ip, speed=None, force=False): logger = Log("vps_mgr", config=conf) client = VPSMgr() vps_info = None try: vps_info = client.query_vps(vps_id) except Exception, e: print "failed to query vps state: [%s] %s" % (type(e), str(e)) if not force: os._exit(1) try: vpsops = VPSOps(logger) xv = None if vps_info: xv = XenVPS(vps_info.id) client.setup_vps(xv, vps_info) migclient = MigrateClient(logger, dest_ip) vpsops.migrate_closed_vps( migclient, vps_id, dest_ip, speed=speed, _xv=xv) print "ok" except Exception, e: logger.exception(e) raise e def usage(): print "usage: %s [ --speed MBbit/s] vps_id [vps_id2 ...] dest_ip" % (sys.argv[0])