当前位置: 首页>>代码示例>>Python>>正文


Python mgmt.ManagementContainer类代码示例

本文整理汇总了Python中com.m1.ems.mgmt.ManagementContainer的典型用法代码示例。如果您正苦于以下问题:Python ManagementContainer类的具体用法?Python ManagementContainer怎么用?Python ManagementContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ManagementContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addToCustomer

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
开发者ID:piyush76,项目名称:EMS,代码行数:54,代码来源:testUtils.py

示例2: activate

def activate( customerId, domain, makingActive=True ):
    print 'Looking up customer...'
    customer = getCustomer( customerId )
    print '  Customer State: ',customer.getState()
    if (customer.getState() == CustomerState.ACTIVE and makingActive is True) or (customer.getState() == CustomerState.READY and makingActive is False):
        print 'Customer is already '+ customer.getState().toString() +', returning OK'
        return OK

    print 'getting user'
    user = "[email protected]" + domain;
    actualUser = ManagementContainer.getInstance().getUserManager().getUser( user )
    if actualUser is None:
        return ERROR_ACTUAL_USER
    print 'User: ', actualUser

    stateMgr = ManagementContainer.getInstance().getStateManager()
    print 'state mgr: ', stateMgr

    transitionMessage = None
    notificationMessage = None
    passPhrase = None

    print 'Changing state...'
    LOGGER.info( 'Changing state...' )
    if makingActive:
        res = stateMgr.changeCustomerState( customer, actualUser, CustomerState.ACTIVE, transitionMessage, notificationMessage, passPhrase, 'activating from activate.py', True )
        if not res is True:
            print 'Activation failed'
            LOGGER.error( 'Activation failed.' )
            return ERROR_STATE_CHANGE_FAILED
    else:
        res = stateMgr.changeCustomerState( customer, actualUser, CustomerState.RECOVERY, transitionMessage, notificationMessage, passPhrase, 'recovering from activate.py', True )
        if not res is True:
            print 'Shift to RECOVERY failed'
            LOGGER.error( 'Shift to RECOVERY failed.' )
            return ERROR_STATE_CHANGE_FAILED
        res = stateMgr.changeCustomerState( customer, actualUser, CustomerState.READY, transitionMessage, notificationMessage, passPhrase, 'making ready from activate.py', True )
        if not res is True:
            print 'Shift to READY failed'
            LOGGER.error( 'Shift to READY failed.' )
            return ERROR_STATE_CHANGE_FAILED
        # java's "boolean ? x : y" is written as "x if boolean else y" in python!
    state='ACTIVE'
    if not makingActive:
        state='READY'
    print 'State change to ' + state + ' succeeded.'
    LOGGER.info( 'State change to ' + state + ' succeeded.' )
    return OK
开发者ID:piyush76,项目名称:EMS,代码行数:48,代码来源:activate.py

示例3: test

def test(islandId,numMessages):
    mc = ManagementContainer.getInstance()
    cm = mc.getCustomerManager()
    amsm = mc.getActiveMailboxStoreManager()
    custid = 0
    
    try:
        if not os.path.exists('/tmp/replay-custid.txt'):
            print '/tmp/replay-custid.txt does not exist'
            return(1)

        f = open('/tmp/replay-custid.txt','r')
        for line in f:
            custid = int(line.strip())
            break
        f.close()
        os.remove('/tmp/replay-custid.txt')
        print 'using customer id',custid

        msgs = findMessages(mc,custid,numMessages)

        print 'search for',msgs

        if not checkSearchStatus2(mc,msgs,custid,True):
            print 'Did not find messages'
            return(1)
        else:
            print 'Found messages'
    finally:
        if custid > 0:
            cm.deleteCustomers([custid])
    
    return(0)
开发者ID:piyush76,项目名称:EMS,代码行数:33,代码来源:testReplay2.py

示例4: enableIslandEDiscovery

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
开发者ID:piyush76,项目名称:EMS,代码行数:35,代码来源:testUtils.py

示例5: addDomains

def addDomains( customerId, domains ):
    print 'Clearing any .lock files...'
    os.system('find /ems/sysconf/postfix -type f -name ".lock" -exec rm -f {} \;')

    print 'Looking up customer...'
    customer = getCustomer( customerId )

    customerDomains = customer.getDomains()
    updatedDomains = list()
    for d in customerDomains:
        updatedDomains.append( d )

    count = 0
    for d in domains:
        if not d in updatedDomains:
            updatedDomains.append( d )
            count += 1

    if count == 0:
        print 'No new domains to add to customer.'
        return OK

    print 'Updating customer to have domains ', updatedDomains
    customer.setDomains( updatedDomains )
    customerList = list()
    customerList.append( customer )
    res = ManagementContainer.getInstance().getCustomerManager().updateCustomers( customerList )
    if res != 1:
        return ERROR_CUSTOMER_NOT_UPDATED
    return OK
开发者ID:piyush76,项目名称:EMS,代码行数:30,代码来源:addCustomerDomains.py

示例6: retrieve_an_archive

def retrieve_an_archive(cust_id, archive_name, user_id, chunk_hint, file_name, output_ids):
    print "\nretrieve_a_chunk routine:: output file_name is :", file_name

    try:
        outfile_stream = FileOutputStream(file_name)
    except:
        print "retrieve_a_chunk routine:: Failed to open output stream on file : ", file_name, "..returning"
        return None

    # retrieve data
    mc = ManagementContainer.getInstance()
    rm = mc.getRecoveryManager()

    l_cust_id = Integer.parseInt(cust_id);
    l_user_id = Integer.parseInt(user_id);
    sosw = IRecoveryManager.SimpleOutputStreamWrapper(outfile_stream)

    try:
        rm.createPerUserActiveRecoveryArchiveFile(l_cust_id, archive_name, l_user_id, sosw, chunk_hint)
    except:
        print "retrieve_a_chunk routine:: `Exception while creating active recovery archive..returning"
        sys.exc_info()[1].printStackTrace()

        print("*** print_exc:")
        traceback.print_exc(file=sys.stdout)
        outfile_stream.close()
        raise

    outfile_stream.close()
    return get_chunk_hint(file_name, output_ids)
开发者ID:piyush76,项目名称:MyPythonModule,代码行数:30,代码来源:verify_archive_download.py

示例7: setup

def setup(islandId):
    sor = SOR()
    hosts = sor.getHosts("purge-dispatcherV2")
    if hosts is None or len(hosts) != 1:
        print "Did not find expected host for purge-dispatcherV2", hosts
        return 1
    purgeHost = hosts.pop()

    mc = ManagementContainer.getInstance()
    purgeDispatcher = Service("purge-dispatcherV2")
    preCalcSvc = Service("purge-precalc-service")

    try:
        purgeDispatcher.invoke("stop", purgeHost)
        preCalcSvc.invoke("stop", purgeHost)

        os.system(
            "cd /tmp; /bin/rm -rf /tmp/corpus /tmp/purge-1; tar -xf endtoend-test-corpus.tar; mv /tmp/corpus /tmp/purge-1"
        )
        os.system("sed -i 's/@enron.com/@purge1.com/g' /tmp/purge-1/*")

        setupCustomer(mc, islandId, corpus="/tmp/purge-1", name="purge1", domain="purge1.com", recvDate="now")

        return 0
    finally:
        purgeDispatcher.invoke("start", purgeHost)
        preCalcSvc.invoke("start", purgeHost)
开发者ID:piyush76,项目名称:EMS,代码行数:27,代码来源:testPurge.py

示例8: enableIslandEDiscovery

def enableIslandEDiscovery( islandId, enabled ):

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

    res = os.system( '/opt/ems/bin/amp cluster -l | grep -v FeedOn | grep -E \" .*' + str( islandId ) + ' .*\" > /tmp/cluster.out')
    if res != 0:
        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
开发者ID:piyush76,项目名称:EMS,代码行数:28,代码来源:testUtils.py

示例9: testRemote

def testRemote(islandId,numMessages):
    mc = ManagementContainer.getInstance()
    pm = mc.getPartitionManager()
    custId = None

    custId = findCustomer("rgm-remote")
    print 'Found customer id',custId
    
    if custId < 0:
        print 'Unable to locate test customer named rgm1'
        return 1
        
    msgs = findMessages(mc,custId,numMessages)
    for msg in msgs:
        pp = pm.getContentProxy(msg.getPartitionId())
        print 'Get message',msg.getMessageId(),"from partition",msg.getPartitionId()
        inputStream = pp.getRawMessage(custId,-1,msg.getMessageId())
        if inputStream is None:
            print >>sys.stderr,"Got null stream for message",msg.getMessageId(),"from partition",msg.getPartitionId()
            return 1
        createPurgeOrphan(mc,msg)
        print 'Get message',msg.getMessageId(),"from partition",msg.getPartitionId()
        try:
            inputStream = pp.getRawMessage(custId,-1,msg.getMessageId())
            print >>sys.stderr,"Got unexpected stream for message",msg.getMessageId(),"from partition",msg.getPartitionId()
            return 1
        except MessageNotFoundIOException, e:
            print >>sys.stderr,"Got expected MessageNotFoundIOException"
        except:
开发者ID:piyush76,项目名称:EMS,代码行数:29,代码来源:testRawGetMessage.py

示例10: setup

def setup(islandId):
    sor = SOR()
    hosts = sor.getHosts('purge-dispatcherV2')
    if hosts is None or len(hosts) != 1:
        print 'Did not find expected host for purge-dispatcherV2',hosts
        return 1
    purgeHost = hosts.pop()

    mc = ManagementContainer.getInstance()
    purgeDispatcher = Service('purge-dispatcherV2')
    preCalcSvc = Service('purge-precalc-service')
    
    try:
        purgeDispatcher.invoke('stop',purgeHost)
        preCalcSvc.invoke('stop',purgeHost)

        os.system("cd /tmp; /bin/rm -rf /tmp/corpus /tmp/policystats-1; tar -xf endtoend-test-corpus.tar; mv /tmp/corpus /tmp/policystats-1");
        os.system("sed -i 's/@enron.com/@policystats.com/g' /tmp/policystats-1/*");
        
        setupCustomer(mc,islandId,corpus='/tmp/policystats-1',name='PolicyStatsTest',domain='policystats.com',recvDate='now')
        
        return 0
    finally:
        purgeDispatcher.invoke('start',purgeHost)
        preCalcSvc.invoke('start',purgeHost)
开发者ID:piyush76,项目名称:EMS,代码行数:25,代码来源:testPolicyStats.py

示例11: changeState

    def changeState(self,locName,feed,update,purge,threshMsg):
        cm = ManagementContainer.getInstance().getClusterManager()
        cl = cm.findFirstMatchingClusterLocation(locName)
        changeState = False

        if feed is not None and feed == cl.isFeedEnabled():
            log('changeState: feed is already in expected state (' + str(feed) + ') for ' + cl.toString())
        elif feed is not None:
            cl.setFeedEnabled(feed)
            changeState = True

        if purge is not None and purge == cl.isPurgeEnabled():
            log('changeState: purge is already in expected state (' + str(purge) + ') for ' + cl.toString())
        elif purge is not None:
            cl.setPurgeEnabled(purge)
            changeState = True

        if update is not None and update == cl.isUpdateEnabled():
            log('changeState: update is already is expected state (' + str(update) + ') for ' + cl.toString())
        elif update is not None:
            cl.setUpdateEnabled(update)
            changeState = True

        if changeState:
            self.sendMail('cluster location policy changed for ' + cl.toString(), threshMsg + ' feed ' + str(cl.isFeedEnabled()) + ',update ' + str(cl.isUpdateEnabled()) + ',purge ' + str(cl.isPurgeEnabled()) + ' for ' + cl.toString())
            log('changeState: feed ' + str(cl.isFeedEnabled()) + ',update ' + str(cl.isUpdateEnabled()) + ',purge ' + str(cl.isPurgeEnabled()) + ' for ' + cl.toString())
            cm.updateClusterLocation(cl)
        else:
            log('changeState: feed no changes for ' + cl.toString())

        return changeState
开发者ID:piyush76,项目名称:EMS,代码行数:31,代码来源:ApiQController.py

示例12: setupCustomer

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( "[email protected]" + 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]
开发者ID:piyush76,项目名称:EMS,代码行数:47,代码来源:cloud.py

示例13: getSearchParams

def getSearchParams():
    result = ''
    mc = ManagementContainer.getInstance()
    island = mc.getIslandManager().getIsland(101)
    if island is not None:
      result = island.getSearchParms()

    return result
开发者ID:piyush76,项目名称:EMS,代码行数:8,代码来源:testShardObserver.py

示例14: setUserPurgeDate

def setUserPurgeDate(usersToPurge, markPurgeDaysBeforeCurrent):
    mc = ManagementContainer.getInstance()
    connection = mc.getDBConnection(ManagementContainer.POOL_NAME)
    s = connection.createStatement()
    s.executeUpdate("update dat_user_account set purge_date = current_timestamp - '"+str(markPurgeDaysBeforeCurrent)+" days'::interval where object_id in "+QueryUtils.literal(usersToPurge))
    s.close()
    connection.commit()
    mc.safeReturnDBConnection(connection, ManagementContainer.POOL_NAME)
    DbUtils.safeClose(s)
开发者ID:piyush76,项目名称:EMS,代码行数:9,代码来源:testUtils.py

示例15: setColumnState

 def setColumnState(self, feed, update, purge):
     if self.config.allowColumnStateChange > 0:
         log('set state for ' + self.clusterLocationName + ' feed: ' + str(feed) + ' update: ' + str(update) + ' purge: ' + str(purge))
         mc = ManagementContainer.getInstance()
         cm = mc.getClusterManager()
         self.clusterLocation.setFeedEnabled(feed)
         self.clusterLocation.setUpdateEnabled(update)
         self.clusterLocation.setPurgeEnabled(purge)
         cm.updateClusterLocation(self.clusterLocation)
开发者ID:piyush76,项目名称:EMS,代码行数:9,代码来源:isctrl.py


注:本文中的com.m1.ems.mgmt.ManagementContainer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。