Example #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, )
Example #2
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()
    for au in aus:
        if client.hasAu(au):
            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)
Example #3
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,)
Example #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)
Example #5
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 "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)
Example #6
0
import optparse
import os
import random
import sys
import tempfile
import threading
import time
import urllib2
import urlparse

sys.path.append( os.path.realpath( os.path.join( os.path.dirname( sys.argv[ 0 ] ), '../lib' ) ) )
import lockss_daemon
import fix_auth_failure


fix_auth_failure.fix_auth_failure()

# Constants
PROGRAM = os.path.splitext( os.path.basename( sys.argv[ 0 ] ) )[ 0 ].title()
REVISION = '$Revision: 2.17 $'.split()[ 1 ]
MAGIC_NUMBER = 'PLRS' + ''.join( number.rjust( 2, '0' ) for number in REVISION.split( '.' ) )
DEFAULT_UI_PORT = 8081
SERVER_READY_TIMEOUT = 60
MINIMUM_SLEEP_DURATION = 15
MAXIMUM_SLEEP_DURATION = 120
REMOTE_CRAWL_RETRY_TOTAL = 3
POLL_FAILURE_RETRY_TOTAL = 3
POLL_MISMATCH_RETRY_TOTAL = 3
MAXIMUM_URLError = 3
CONFIGURATION_DEFAULTS = { 
    'configuration':    '',
Example #7
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'))
        or not os.path.isfile(local_txt)):
        raise Exception('%s doesn\'t look like a daemon directory. '
                        'Try --directory.' % src)

    if 'LOCKSS_UI_PORT' in os.environ:
        port = os.environ['LOCKSS_UI_PORT']
    else:
        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('127.0.0.1', 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)
            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)
Example #8
0
import optparse
import os
import random
import sys
import tempfile
import threading
import time
import urllib2
import urlparse

sys.path.append(
    os.path.realpath(os.path.join(os.path.dirname(sys.argv[0]), '../lib')))
import lockss_daemon
import fix_auth_failure

fix_auth_failure.fix_auth_failure()

# Constants
PROGRAM = os.path.splitext(os.path.basename(sys.argv[0]))[0].title()
REVISION = '$Revision: 2.27 $'.split()[1]
MAGIC_NUMBER = 'PLRS' + ''.join(
    number.rjust(2, '0') for number in REVISION.split('.'))
DEFAULT_UI_PORT = 8081
SERVER_READY_TIMEOUT = 600
MINIMUM_SLEEP_DURATION = 60
MAXIMUM_SLEEP_DURATION = 300
REMOTE_CRAWL_RETRY_TOTAL = 3
POLL_FAILURE_RETRY_TOTAL = 6
POLL_MISMATCH_RETRY_TOTAL = 6
MAXIMUM_URLError = SERVER_READY_TIMEOUT / MINIMUM_SLEEP_DURATION
CONFIGURATION_DEFAULTS = {
Example #9
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)