def change_ctid(conn, uuid, new_ctid): if conn.getType() == "OpenVZ": ctid = openvz.get_ctid_by_uuid(conn, uuid) get_logger().info("Change ctid from %s to %s", ctid, new_ctid) openvz.change_ctid(ctid, new_ctid) else: raise NotImplementedError("VM type '%s' is not (yet) supported" % conn.getType())
def clone_vm(conn, uuid, *args, **kwargs): settings = kwargs settings.update(args[0] if ( len(args) == 1 and type(args[0]) is dict) else {}) if conn.getType() == 'OpenVZ': # XXX: Perform vzmlocal -C ctid:new_ctid - this changes uuid of new VM. openvz.clone_vm(openvz.get_ctid_by_uuid(conn, uuid), settings['ctid']) # XXX: If user changed target ctid in edit form then openvz.update_vm() # would perform another vzmlocal move. settings['ctid_old'] = settings['ctid'] param_name_map = { 'cpu_limit': 'vcpulimit', 'swap_size': 'swap', 'num_cores': 'vcpu' } openvz_settings = {} openvz_settings.update( dict((param_name_map.get(key, key), value) for key, value in settings.iteritems())) # XXX: uuid must be re-read from disk. openvz_settings['uuid'] = openvz.get_uuid_by_ctid(settings['ctid']) # XXX: connection to libvirt must be re-opened as old connection does # not know about newly created VM. conn = _connection(openvz_settings['vm_uri']) openvz.update_vm(conn, openvz_settings) return else: raise NotImplementedError("VM type '%s' is not (yet) supported" % conn.getType())
def clone_vm(conn, uuid, *args, **kwargs): settings = kwargs settings.update(args[0] if (len(args) == 1 and type(args[0]) is dict) else {}) if conn.getType() == 'OpenVZ': # XXX: Perform vzmlocal -C ctid:new_ctid - this changes uuid of new VM. openvz.clone_vm(openvz.get_ctid_by_uuid(conn, uuid), settings['ctid']) # XXX: If user changed target ctid in edit form then openvz.update_vm() # would perform another vzmlocal move. settings['ctid_old'] = settings['ctid'] param_name_map = {'cpu_limit': 'vcpulimit', 'swap_size': 'swap', 'num_cores': 'vcpu'} openvz_settings = {} openvz_settings.update(dict((param_name_map.get(key, key), value) for key, value in settings.iteritems())) # XXX: uuid must be re-read from disk. openvz_settings['uuid'] = openvz.get_uuid_by_ctid(settings['ctid']) openvz.update_vm(conn, openvz_settings) return else: raise NotImplementedError("VM type '%s' is not (yet) supported" % conn.getType())
def change_ctid(conn, uuid, new_ctid): if conn.getType() == 'OpenVZ': ctid = openvz.get_ctid_by_uuid(conn, uuid) get_logger().info('Change ctid from %s to %s', ctid, new_ctid) openvz.change_ctid(ctid, new_ctid) else: raise NotImplementedError("VM type '%s' is not (yet) supported" % conn.getType())
def clone_vm(conn, uuid, *args, **kwargs): settings = kwargs settings.update(args[0] if (len(args) == 1 and type(args[0]) is dict) else {}) if conn.getType() == "OpenVZ": # XXX: Perform vzmlocal -C ctid:new_ctid - this changes uuid of new VM. openvz.clone_vm(openvz.get_ctid_by_uuid(conn, uuid), settings["ctid"]) # XXX: If user changed target ctid in edit form then openvz.update_vm() # would perform another vzmlocal move. settings["ctid_old"] = settings["ctid"] param_name_map = {"cpu_limit": "vcpulimit", "swap_size": "swap", "num_cores": "vcpu"} openvz_settings = {} openvz_settings.update(dict((param_name_map.get(key, key), value) for key, value in settings.iteritems())) # XXX: uuid must be re-read from disk. openvz_settings["uuid"] = openvz.get_uuid_by_ctid(settings["ctid"]) # XXX: connection to libvirt must be re-opened as old connection does # not know about newly created VM. conn = _connection(openvz_settings["vm_uri"]) openvz.update_vm(conn, openvz_settings) return else: raise NotImplementedError("VM type '%s' is not (yet) supported" % conn.getType())
def vm_ctid(vm): if conn.getType() == 'OpenVZ': return openvz.get_ctid_by_uuid(conn, get_uuid(vm)) else: return kvm.get_id_by_uuid(conn, get_uuid(vm))
def vm_ctid(vm): if conn.getType() == "OpenVZ": return openvz.get_ctid_by_uuid(conn, get_uuid(vm)) else: return kvm.get_id_by_uuid(conn, get_uuid(vm))