Beispiel #1
0
def migrate(conn, uid, target_host, live=False, print_=True):
    """Migrate given container to a target_host"""
    if not test_passwordless_ssh(target_host):
        raise CommandException(
            "Public key ssh connection with the target host could not be established"
        )
    log = get_logger()
    # a workaround for the megadynamic nature of python variable type when called via an agent
    live = live == 'True' if type(live) is str else live
    # is ctid present on the target host?
    ctid = get_ctid_by_uuid(conn, uid)
    try:
        execute("ssh %s vzlist %s" % (target_host, ctid))
        raise CommandException(
            "Target host '%s' has an already defined CTID '%s'" %
            (target_host, ctid))
    except CommandException as ce:
        if ce.code != 256:
            raise
    msg = "Initiating migration to %s..." % target_host
    log.info(msg)
    live_trigger = '--online' if live else ''
    for line in execute2("vzmigrate -v %s %s %s" %
                         (live_trigger, target_host, ctid)):
        log.info(line)
Beispiel #2
0
def migrate(uid, target_host, live=False):
    """Migrate given container to a target_host"""
    if not test_passwordless_ssh(target_host):
        raise CommandException("Public key ssh connection with the target host could not be established")
    # is ctid present on the target host?
    ctid = get_ctid_by_uuid(uid)
    try:
        execute("ssh %s vzlist %s" % (target_host, ctid))
        raise CommandException("Target host '%s' already has a defined CTID '%s'" % (target_host, ctid))
    except CommandException as ce:
        if ce.code == 256:
            pass
        else:
            raise ce
    print "Initiating migration to %s..." % target_host
    live_trigger = '--online' if live else ''
    for line in execute2("vzmigrate -v %s %s %s" % (live_trigger, target_host, ctid)):
        print line
Beispiel #3
0
def migrate(conn, uid, target_host, live=False, print_=True):
    """Migrate given container to a target_host"""
    if not test_passwordless_ssh(target_host):
        raise CommandException("Public key ssh connection with the target host could not be established")
    log = get_logger()
    # a workaround for the megadynamic nature of python variable type when called via an agent
    live = live == 'True' if type(live) is str else live
    # is ctid present on the target host?
    ctid = get_ctid_by_uuid(conn, uid)
    try:
        execute("ssh %s vzlist %s" % (target_host, ctid))
        raise CommandException("Target host '%s' has an already defined CTID '%s'" % (target_host, ctid))
    except CommandException as ce:
        if ce.code != 256:
            raise
    msg = "Initiating migration to %s..." % target_host
    log.info(msg)
    live_trigger = '--online' if live else ''
    for line in execute2("vzmigrate -v %s %s %s" % (live_trigger, target_host, ctid)):
        log.info(line)