예제 #1
0
def main():
    (options, host, port, auid_files) = _process_args()
    fix_auth_failure.fix_auth_failure()
    client = lockss_daemon.Client(host, port, options.user, options.password)
    aus = _aus(auid_files)
    has = list()
    missing = list()
    initial_auIds = client.getListOfAuids()
    for au in aus:
        if au.auId in initial_auIds:
            has.append(au)
        else:
            missing.append(au)

    if options.verbose:
        print "Daemon %s" % client
        if missing:
            print "does not have"
            for au in missing:
                print au.auId
        if has:
            print "to be deleted"
            for au in has:
                print au.auId

    for au in has:
        if not options.verify or \
                options.verify and \
                raw_input('delete %s [n]? ' % au.title).startswith('y'):
            client.deleteAu(au)
            if options.verbose:
                print 'Deleted: %s' % (au.auId, )
예제 #2
0
def main():
    sys.stderr.write('This tool is deprecated.\nUse scripts/ws/contentconfigurationservice --delete-aus instead.\n')

    (options, host, port, auid_files) = _process_args()
    fix_auth_failure.fix_auth_failure()
    client = lockss_daemon.Client(host, port,
                                  options.username, options.password)
    aus = _aus(auid_files)
    has = list()
    missing = list()
    initial_auIds = client.getListOfAuids()
    for au in aus:
        if au.auId in initial_auIds:
            has.append(au)
        else:
            missing.append(au)
    
    if options.verbose:
        print "Daemon %s" % client
        if missing:
            print "does not have"
            for au in missing:
                print au.auId
        if has:
            print "to be deleted"
            for au in has:
                print au.auId

    for au in has:
        if not options.verify or \
                options.verify and \
                raw_input('delete %s [n]? ' % au.title).startswith('y'):
            client.deleteAu(au)
            if options.verbose:
                print 'Deleted: %s' % (au.auId,)
예제 #3
0
 def __make_ui_connection(self):
     opt = self.__options
     daemon_ui_host, daemon_ui_port_str = self.__daemon_ui_host_port.split(':')
     self.__ui = lockss_daemon.Client(daemon_ui_host,
                                      int(daemon_ui_port_str),
                                      opt.daemon_ui_user,
                                      opt.daemon_ui_pass)
     if not self.__ui.waitForDaemonReady(self.__options.daemon_ui_timeout):
         raise RuntimeError, '%s is not ready after %d seconds' % (self.__daemon_ui_host_port,
                                                                   self.__options.daemon_ui_timeout)
예제 #4
0
def main():
    sys.stderr.write(
        'This tool is deprecated.\nUse scripts/ws/contentconfigurationservice --add-aus instead.\n'
    )

    (options, host, port, auid_files) = _process_args()
    fix_auth_failure.fix_auth_failure()
    client = lockss_daemon.Client(host, port, options.username,
                                  options.password)
    aus = _aus(auid_files)
    has = list()
    missing = list()
    initial_auIds = client.getListOfAuids()
    for au in aus:
        if au.auId in initial_auIds:
            has.append(au)
        else:
            missing.append(au)

    if options.verbose:
        print "Daemon %s" % client
        if missing:
            print "to be created"
            for au in missing:
                print au.auId
        if has:
            print "already has"
            for au in has:
                print au.auId

    for au in missing:
        try:
            if not options.verify or \
                    options.verify and \
                    raw_input('create %s [n]? ' % au.title).startswith('y'):
                if options.tdb:
                    client.addByAuid(au)
                else:
                    client.createAu(au)
        except lockss_util.LockssError:
            # Failed to create. Print the errors after all creation attempts.
            pass

    # Note: also prints out auids which were n'ed in verbose mode.
    final_auIds = client.getListOfAuids()
    failed = list()
    for au in missing:
        if au.auId not in final_auIds:
            failed.append(au)

    if failed:
        print >> sys.stderr, "failed to add"
        for au in failed:
            print >> sys.stderr, au.auId
        exit(1)
예제 #5
0
try:

    if configuration.getboolean(PROGRAM, 'test'):
        content_list, local_clients, remote_clients = self_test_startup()
    else:

        local_clients = dict(
            zip(Content.Action.values,
                ([] for value in Content.Action.values)))
        for server in configuration.get(PROGRAM, 'local_servers'):
            url_components = urlparse.urlparse(server)
            assert url_components.scheme in Content.Action.values, 'Unknown local server scheme: "%s"' % url_components.scheme
            local_clients[url_components.scheme].append(
                lockss_daemon.Client(
                    url_components.hostname, url_components.port
                    if url_components.port else DEFAULT_UI_PORT,
                    configuration.get(PROGRAM, 'username'),
                    configuration.get(PROGRAM, 'password')))

        remote_clients = dict(
            zip(Content.Action.values,
                ([] for value in Content.Action.values)))
        for server in configuration.get(PROGRAM, 'remote_servers'):
            url_components = urlparse.urlparse(server)
            assert url_components.scheme in Content.Action.values, 'Unknown remote server scheme: "%s"' % url_components.scheme
            remote_clients[url_components.scheme].append(
                lockss_daemon.Client(
                    url_components.hostname, url_components.port
                    if url_components.port else DEFAULT_UI_PORT,
                    configuration.get(PROGRAM, 'username'),
                    configuration.get(PROGRAM, 'password')))
예제 #6
0
def main():
    options = _process_args()
    src = options.directory
    local_txt = os.path.join(src, 'local.txt')
    if not os.path.isdir(os.path.join(src, 'cache')):
        raise Exception('%s doesn\'t look like a daemon directory. '
                        'Try --directory.' % src)

    if 'LOCKSS_IPADDR' in os.environ: ipAddr = os.environ['LOCKSS_IPADDR']
    else: ipAddr = '127.0.0.1'

    if 'LOCKSS_UI_PORT' in os.environ:
        port = os.environ['LOCKSS_UI_PORT']
    else:
        if not os.path.isfile(local_txt):
            raise Exception('LOCKSS_UI_PORT is not set but there is no'
                            '%s' % (local_txt, ))
        config = ConfigParser.ConfigParser()
        local_config = open(local_txt)
        try:
            config.readfp(_SectionAdder('foo', local_config))
            port = config.get('foo', 'org.lockss.ui.port')
        finally:
            local_config.close()

    fix_auth_failure.fix_auth_failure()
    client = lockss_daemon.Client(ipAddr, port, options.user, options.password)
    repos = client._getStatusTable('RepositoryTable')[1]

    no_auid = [r for r in repos if r['status'] == 'No AUID']
    if no_auid:
        print 'Warning: These cache directories have no AUID:'
        for r in no_auid:
            print r['dir']
        print

    deleted = [r for r in repos if r['status'] == 'Deleted']
    for r in deleted:
        r['auid'] = _auid(os.path.join(src, r['dir']))
    deleted.sort(key=lambda r: r['auid'])

    move_all = False
    if options.verbose:
        if deleted:
            print 'These AUs have been deleted on the daemon:'
            for r in deleted:
                print r['auid']
            if options.verify:
                move_all = raw_input('move all [y]? ').startswith('y')
        else:
            print 'No deleted AUs.'

    verify_each = options.verify and not move_all
    dst = os.path.join(options.directory, options.dest)
    for r in deleted:
        dir = r['dir']
        if not verify_each or \
                verify_each and \
                raw_input('move %s [n]? ' % r['auid']).startswith('y'):
            src_r = os.path.join(src, dir)
            if os.path.isabs(dir):
                if not dir.startswith(options.directory):
                    print 'Absolute/relative path mismatch: %s' % (dir, )
                dst_r = os.path.join(dst, dir[len(options.directory) + 1:])
            else:
                dst_r = os.path.join(dst, dir)
            if options.commands:
                print "mv %s %s # %s" % (src_r, dst_r, r['auid'])
            else:
                os.renames(src_r, dst_r)