예제 #1
0
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())
예제 #2
0
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())
예제 #3
0
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())
예제 #4
0
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())
예제 #5
0
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())
예제 #6
0
 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))
예제 #7
0
 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))