本文整理汇总了Python中com.m1.ems.mgmt.ManagementContainer.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python ManagementContainer.getInstance方法的具体用法?Python ManagementContainer.getInstance怎么用?Python ManagementContainer.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.m1.ems.mgmt.ManagementContainer
的用法示例。
在下文中一共展示了ManagementContainer.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addToCustomer
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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
示例2: activate
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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
示例3: test
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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)
示例4: enableIslandEDiscovery
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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
示例5: addDomains
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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
示例6: retrieve_an_archive
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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)
示例7: setup
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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)
示例8: enableIslandEDiscovery
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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
示例9: testRemote
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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:
示例10: setup
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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)
示例11: changeState
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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
示例12: setupCustomer
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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]
示例13: getSearchParams
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
def getSearchParams():
result = ''
mc = ManagementContainer.getInstance()
island = mc.getIslandManager().getIsland(101)
if island is not None:
result = island.getSearchParms()
return result
示例14: setUserPurgeDate
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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)
示例15: setColumnState
# 需要导入模块: from com.m1.ems.mgmt import ManagementContainer [as 别名]
# 或者: from com.m1.ems.mgmt.ManagementContainer import getInstance [as 别名]
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)