Beispiel #1
0
def main():
    global client, DEBUG
    parser = OptionParser(option_list=options_table)

    (options, _args) = parser.parse_args()

    if options.satellite:
        satellite_host = options.satellite
    else:
        satellite_host = os.uname()[1]

    if options.verbose:
        DEBUG = 1

    satellite_url = "http://%s/rpc/api" % satellite_host
    if DEBUG:
        print("Connecting to %s" % satellite_url)

    client = xmlrpclib.Server(satellite_url, verbose=0)

    if options.csv:
        migrate_data = read_csv_file(options.csv)
    else:
        migrate_data = []

    if not options.csv:
        if not options.systemId:
            print("Missing --systemId")
            return 1

        if not options.to_org_id:
            print("Missing Destination org id")
            return
        else:
            to_org_id = options.to_org_id or None

        migrate_data = [[options.systemId, to_org_id]]

    username, password = getUsernamePassword(options.username,
                                             options.password)

    sessionKey = xmlrpc_login(client, username, password)

    if not migrate_data:
        sys.stderr.write("Nothing to migrate. Exiting.. \n")
        sys.exit(1)

    for server_id, to_org_id in migrate_data:
        if isinstance(server_id, type([])):
            server_id = list(map(int, server_id))
        else:
            server_id = [int(server_id)]
        try:
            migrate_system(sessionKey, int(to_org_id), server_id)
        except Exception:
            raise

    if DEBUG:
        print("Migration Completed successfully")
    xmlrpc_logout(client, sessionKey)
def main():
    global client, DEBUG
    parser = OptionParser(option_list=options_table)

    (options, _args) = parser.parse_args()

    if options.satellite:
        satellite_host = options.satellite
    else:
        satellite_host = os.uname()[1]

    if options.verbose:
        DEBUG = 1

    satellite_url = "http://%s/rpc/api" % satellite_host
    if DEBUG:
        print "Connecting to %s" % satellite_url

    client = xmlrpclib.Server(satellite_url, verbose=0)

    if options.csv:
        migrate_data = read_csv_file(options.csv)
    else:
        migrate_data = []

    if not options.csv:
        if not options.systemId:
            print "Missing --systemId"
            return 1

        if not options.to_org_id:
            print "Missing Destination org id"
            return
        else:
            to_org_id = options.to_org_id or None

        migrate_data = [[options.systemId, to_org_id]]

    username, password = getUsernamePassword(options.username,
                                             options.password)

    sessionKey = xmlrpc_login(client, username, password)

    if not migrate_data:
        sys.stderr.write("Nothing to migrate. Exiting.. \n")
        sys.exit(1)

    for server_id, to_org_id in migrate_data:
        if isinstance(server_id, type([])):
            server_id = map(int, server_id)
        else:
            server_id = [int(server_id)]
        try:
            migrate_system(sessionKey, int(to_org_id), server_id)
        except Exception:
            raise

    if DEBUG:
        print "Migration Completed successfully"
    xmlrpc_logout(client, sessionKey)
Beispiel #3
0
def main():

    global client, options

    parser = OptionParser(option_list=options_table)
    (options, _args) = parser.parse_args()
    processCommandLine()

    satellite_url = "http://%s/rpc/api" % options.satellite

    if options.verbose:
        print "start date=", options.start_date
        print "end date=", options.end_date
        print "connecting to %s" % satellite_url

    client = xmlrpclib.Server(satellite_url, verbose=0)

    username, password = getUsernamePassword(options.username,
                                             options.password)

    sessionKey = xmlrpc_login(client, username, password, options.verbose)

    if options.all:

        if options.start_date and options.end_date:
            deleteAllBetweenDates(sessionKey, options.start_date,
                                  options.end_date)

        elif options.start_date:
            deleteAllAfterDate(sessionKey, options.start_date)

        else:
            deleteAll(sessionKey)

    elif options.system_id:

        if options.start_date and options.end_date:
            deleteBySystemBetweenDates(sessionKey, options.system_id,
                                       options.start_date, options.end_date)

        elif options.start_date:
            deleteBySystemAfterDate(sessionKey, options.system_id,
                                    options.start_date)

        else:
            deleteBySystem(sessionKey, options.system_id)

    elif options.snapshot_id:

        deleteBySnapshotId(sessionKey, options.snapshot_id)

    if options.verbose:
        print "Delete Snapshots Completed successfully"

    xmlrpc_logout(client, sessionKey, options.verbose)
Beispiel #4
0
def main():

    global client, options

    parser = OptionParser(option_list=options_table)
    (options, _args) = parser.parse_args()
    processCommandLine()

    satellite_url = "http://%s/rpc/api" % options.satellite

    if options.verbose:
        print "start date=", options.start_date
        print "end date=", options.end_date
        print "connecting to %s" % satellite_url

    client = xmlrpclib.Server(satellite_url, verbose=0)

    username, password = getUsernamePassword(options.username, \
                            options.password)

    sessionKey = xmlrpc_login(client, username, password, options.verbose)

    if options.all:

        if options.start_date and options.end_date:
            deleteAllBetweenDates(sessionKey, options.start_date, \
                options.end_date)

        elif options.start_date:
            deleteAllAfterDate(sessionKey, options.start_date)

        else:
            deleteAll(sessionKey)

    elif options.system_id:

        if options.start_date and options.end_date:
            deleteBySystemBetweenDates(sessionKey, options.system_id, \
                options.start_date, options.end_date)

        elif options.start_date:
            deleteBySystemAfterDate(sessionKey, options.system_id, \
                options.start_date)

        else:
            deleteBySystem(sessionKey, options.system_id)

    elif options.snapshot_id:

        deleteBySnapshotId(sessionKey, options.snapshot_id)

    if options.verbose:
        print "Delete Snapshots Completed successfully"

    xmlrpc_logout(client, sessionKey, options.verbose)