Пример #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)
Пример #2
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 = 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)
Пример #3
0
    def __init__(self, current_manifest=None, username=None, password=None,
                 http_proxy=None, http_proxy_username=None, http_proxy_password=None):
        self.base_url = current_manifest.get_api_url()
        if CFG.CANDLEPIN_SERVER_API:
            log(0, "Overriding Candlepin server to: '%s'" % CFG.CANDLEPIN_SERVER_API)
            self.base_url = CFG.CANDLEPIN_SERVER_API

        if self.base_url.startswith('https'):
            self.protocol = 'https'
        elif self.base_url.startswith('http'):
            self.protocol = 'http'
        else:
            raise ValueError("Invalid protocol in URL: '%s'" % self.base_url)

        if not self.base_url.endswith('/'):
            self.base_url += '/'

        self.current_manifest = current_manifest

        # Authentication with upstream consumer certificate or with username and password
        if self.current_manifest and self.protocol == 'https' and not username:
            self.username = self.password = None
        else:
            log(0, "Candlepin login:")
            self.username, self.password = getUsernamePassword(username, password)

        self.http_proxy = http_proxy
        self.http_proxy_username = http_proxy_username
        self.http_proxy_password = http_proxy_password
Пример #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)
Пример #5
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)
Пример #6
0
    def __init__(self,
                 current_manifest=None,
                 username=None,
                 password=None,
                 http_proxy=None,
                 http_proxy_username=None,
                 http_proxy_password=None):
        self.base_url = current_manifest.get_api_url()
        if CFG.CANDLEPIN_SERVER_API:
            log(
                0, "Overriding Candlepin server to: '%s'" %
                CFG.CANDLEPIN_SERVER_API)
            self.base_url = CFG.CANDLEPIN_SERVER_API

        if self.base_url.startswith('https'):
            self.protocol = 'https'
        elif self.base_url.startswith('http'):
            self.protocol = 'http'
        else:
            raise ValueError("Invalid protocol in URL: '%s'" % self.base_url)

        if not self.base_url.endswith('/'):
            self.base_url += '/'

        self.current_manifest = current_manifest

        # Authentication with upstream consumer certificate or with username and password
        if self.current_manifest and self.protocol == 'https' and not username:
            self.username = self.password = None
        else:
            log(0, "Candlepin login:")
            self.username, self.password = getUsernamePassword(
                username, password)

        self.http_proxy = http_proxy
        self.http_proxy_username = http_proxy_username
        self.http_proxy_password = http_proxy_password