Ejemplo n.º 1
0
def addToCustomer(mc,island,custId,corpus='/tmp/corpus'):
    print 'addToCustomer()'
    amptool = ActiveMailboxPartitionTool()
    emscmdtool = EmsCommandLineTool()

    print 'executing amp cluster-location'
    amptool.runCommand('cluster-location',array(['-r'],String))


    args = []
    args.append("-f" )
    args.append( str(island))
    args.append("-s" )
    args.append( str(island))

    args.append( "-i" )
    args.append( corpus)
    args.append( "-o" )
    args.append( "/tmp")
    args.append( "-r" )
    args.append( "equal-to-sent")
    args.append( "-c")
    args.append(str(custId))
    args.append( "-q")
    argsArr = array(args,String)

    print 'executing make-test-customer'
    result = emscmdtool.runCommand('make-test-customer',argsArr)

    if result is False:
        raise Exception('make-test-customer failed, customer already exists?')
    ManagementContainer.getInstance().getMailRoutingConfigGenerator().waitForRegenComplete()

    # ensure policy_exploded_users updates with user account info
    rpm = mc.getRetentionPolicyManager()
    rpm.notifyOfExternalPolicyChanges(int(custId))

    # move the contents of staging to sftp.drop
    src = os.path.join('/tmp',str(custId))
    dst = os.path.join('/ems/bigdisk/sftp.drop',str(custId))
    if not os.path.exists(dst):
        os.mkdir(dst)
    for f in os.listdir(src):
        if f.endswith('.gzip.enc.done.ftp'):
            shutil.copy(os.path.join(src,f),dst)
            os.remove(os.path.join(src,f))

            idxF = f.replace('.gzip.enc.done.ftp','.index.done.ftp')
            shutil.copy(os.path.join(src,idxF),dst)
            os.remove(os.path.join(src,idxF))

    shutil.rmtree(src)

    return
Ejemplo n.º 2
0
def enableIslandEDiscovery( islandId, enabled ):

    file = File('/tmp/cluster_tmp.out')
    ampout = PrintStream(FileOutputStream(file))
    amptool = ActiveMailboxPartitionTool()
    amptool.setOutputStream(ampout)

    mc = ManagementContainer.getInstance()
    island = mc.getIslandManager().getIsland( islandId )
    edMode = island.isEdiscoveryEnabled()
    if edMode != enabled:
        island.setEdiscoveryEnabled( enabled )
        mc.getIslandManager().updateIsland(island)

    result = amptool.runCommand('cluster',array(['-l'],String))
    cmdline = 'cat /tmp/cluster_tmp.out | grep -v FeedOn | grep -E \" .*' + str( islandId ) + ' .*\" > /tmp/cluster.out'
    os.system(cmdline)
    if result is False:
        return ERROR_CLUSTER_FAILED
    linedata = open( '/tmp/cluster.out', 'r' ).read()
    items = linedata.split()
    enderServiceName = items[5]

    if island.getPlatformVersion().endswith( '-solr' ):
        enderServiceName = 'solrproxy-' + enderServiceName
    else:
        enderServiceName = 'fastproxy-' + enderServiceName
    proxyHost = items[10]
    print 'restarting proxy \"' + enderServiceName + '\" on \"' + proxyHost + '\" to ensure that island capability cache is in synch'

    proxy = Service( enderServiceName )
    proxy.invoke( 'restart', proxyHost )
    print 'proxy restarted'

    return edMode
Ejemplo n.º 3
0
def setupCustomer(mc,island,domain,isCloud,isOnPremises,userAccounts,loadCorpus=False):
    deleteCustomer(mc)
    amptool = ActiveMailboxPartitionTool()
    emscmdtool = EmsCommandLineTool()
    print 'creating customer...'
    cm = mc.getCustomerManager()
    print 'executing amp cluster-location'
    amptool.runCommand('cluster-location',array(['-r'],String))



    args = []
    args.append("-f" )
    args.append( str(island))
    args.append("-s" )
    args.append( str(island))
    args.append("-d" )
    args.append( domain)
    args.append( "-n" )
    args.append("systest_journaling_customer" )
    args.append("-e" )
    args.append( "nobody@" + domain)
    args.append("-q")
    if loadCorpus:
        args.append( "-i" )
        args.append( "/tmp/corpus")
        args.append( "-o" )
        args.append( "/ems/bigdisk/sftp.drop")

    if isCloud:
        args.append("--guid")
    if isOnPremises:
        args.append( "--bcc" )

    if userAccounts is not None:
        for address in userAccounts:
            args.append("--user-account" )
            args.append( address + "@" + domain )
    print "creating journal-enabled customer "
    Logger.getLogger( "cloud.py" ).info( "Creating systest_journaling_customer..." )
    result = emscmdtool.runCommand('make-test-customer',args)

    if result is False:
        raise Exception('make-test-customer failed, customer already exists?')
    ManagementContainer.getInstance().getMailRoutingConfigGenerator().waitForRegenComplete()
    cust = cm.findCustomers([SearchConstraint(ICustomerManager.PROP_NAME, SearchConstraintOperator.CONSTRAINT_EQUALS, 'systest_journaling_customer')])
    return cust[0]
Ejemplo n.º 4
0
def setupCustomer(mc,island,corpus='/tmp/corpus',domain='enron.com',cleanupFirst=True,name='systest_customer',recvDate='equal-to-sent',enableFolderSync=False,runAsync=False,isCloud=False,isOnPremises=False,userAccounts=[],folderid=None, corpusFolders=False,
                  sourceDomain='enron.com',copyMail = False):

    print 'setupCustomer()'
    amptool = ActiveMailboxPartitionTool()
    file = File('/tmp/%s.log')
    emscmdout = PrintStream(FileOutputStream(file))
    emscmdtool = EmsCommandLineTool()
    emscmdtool.setOutputStream(emscmdout)


    if cleanupFirst:
        customerList=[name]
        domainList=[domain]
        deleteCustomers( customerList, domainList )

    if (sourceDomain is not None)  and (domain != sourceDomain):
        print 'renaming domain in corpus', corpus, 'from', sourceDomain, 'to', domain
        os.system("find " + corpus +" -type f -print | xargs -n 25 sed -i 's/"+sourceDomain+"/"+domain+"/g'")


    cm = mc.getCustomerManager()
    amptool.runCommand('cluster-location',array(['-r'],String))

    if runAsync is False:

        args = []
        args.append("-f" )
        args.append( str(island))
        args.append("-s" )
        args.append( str(island))

        args.append( "-i" )
        args.append( corpus)
        args.append( "-o" )
        args.append( "/ems/bigdisk/sftp.drop")
        args.append( "-r" )
        args.append( recvDate)
        args.append("-d" )
        args.append( domain)
        args.append( "-n" )
        args.append( name)
        args.append("-e" )
        args.append( "nobody@" + domain)
        args.append("-q")
        #args.append("-t")
        #args.append("10")
        if copyMail:
            arg.append(" -y")

        if enableFolderSync:
            args.append( "-x" )

        if isCloud:
            args.append("--guid")

        if folderid is not None:
            args.append("-j")

            args.append(folderid)
        elif corpusFolders is True:
            args.append( "-k" )

        if isOnPremises:
            args.append( "--bcc" )

        if userAccounts is not None:
            for address in userAccounts:
                args.append("--user-account" )
                args.append( address + "@" + domain )



        argsArr = array(args,String)
        print 'executing make-test-customer command'
        result = emscmdtool.runCommand('make-test-customer',argsArr)
        if result is False:
            raise Exception('make-test-customer failed, customer already exists?')
        ManagementContainer.getInstance().getMailRoutingConfigGenerator().waitForRegenComplete()
        custIds = cm.findCustomers([SearchConstraint(ICustomerManager.PROP_NAME, SearchConstraintOperator.CONSTRAINT_EQUALS, name)])
        custid = custIds[0].getCustID()
    if runAsync:

        cmdline = 'ulimit -n 4096 ; /opt/ems/bin/emscmd ' + ' make-test-customer ' + ' -f ' + str(island) + ' -s ' + str(island)
        cmdline = cmdline + ' -d ' + domain + ' -n ' + ' ' + name + ' '
        cmdline = cmdline + ' -e ' + ' nobody@' + domain
        cmdline = cmdline + " -q"
        if copyMail:
            cmdline = cmdline + " -y"

        if enableFolderSync:
            cmdline = cmdline + " -x"

        if isCloud:
            cmdline = cmdline + ' --guid'

        if folderid is not None:
            cmdline = cmdline + " -j '"+folderid+"'"
        elif corpusFolders is True:
            cmdline = cmdline + " -k"

        if isOnPremises:
            cmdline = cmdline + ' --bcc'

        if userAccounts is not None:
            for address in userAccounts:
                cmdline = cmdline + ' --user-account "' + address + '@' + domain  + '"'

        print 'executing',cmdline

        rc = os.system('/bin/bash -c ' + cmdline)
        if rc != 0:
            raise Exception('make-test-customer failed, customer already exists?')
        custIds = cm.findCustomers([SearchConstraint(ICustomerManager.PROP_NAME, SearchConstraintOperator.CONSTRAINT_EQUALS, name)])
        custid = custIds[0].getCustID()

        cmdline = 'ulimit -n 4096 ; /opt/ems/bin/emscmd ' + ' make-test-customer ' + ' -f ' + str(island) + ' -s ' + str(island)
        cmdline = cmdline + ' -i ' + corpus
        cmdline = cmdline + ' -o ' + ' /ems/bigdisk/sftp.drop '
        cmdline = cmdline + ' -c ' + str(custid)
        cmdline = cmdline + ' -r ' + ' ' + recvDate + ' '
        cmdline = cmdline + " -q"
        if copyMail:
            cmdline = cmdline + " -y"

        if enableFolderSync:
            cmdline = cmdline + " -x"

        cmdline = cmdline + ' >/tmp/%s.log 2>&1' % name
        print 'executing',cmdline
        os.popen(cmdline,'r')


    return custid