示例#1
0
def setupExportCustomer(numMessages, islandId, cloudDomain, stage1Mta):

    print time.asctime(), 'Start setting '
    userMsgs = [0] * len(users)
    mc = ManagementContainer.getInstance()
    custId = setupCustomer(mc, str(islandId),domain=domainName, name=custname, isCloud=True,userAccounts=users, recvDate="now")

    print time.asctime(), 'customerID', custId

    propagateMtaConfig()

    custList = mc.getCustomerManager().findCustomers([SearchConstraint(ICustomerManager.PROP_NAME, SearchConstraintOperator.CONSTRAINT_EQUALS, custname)])

    cust = custList[0]

    office365Guid = cust.getGuids(CloudService.OFFICE365)[0].getGuid()

    # stage cloud messages
    for i in range(numMessages):
        if (i % 5) == 0:
            sendJournalMessage(office365Guid, users[0], ["invaliduser"], None, None, domainName, cloudDomain, stage1Mta)
            userMsgs[0] += 1
        elif (i % 4) == 0:
            sendJournalMessage(office365Guid, "invaliduser", [users[1]], None, None, domainName, cloudDomain, stage1Mta)
            userMsgs[1] += 1
        elif (i % 3) == 0:
            sendJournalMessage(office365Guid, "invaliduser", None, [users[2]], None, domainName, cloudDomain, stage1Mta)
            userMsgs[2] += 1
        elif (i % 2) == 0:
            sendJournalMessage(office365Guid, "invaliduser", None, None, [users[3]], domainName, cloudDomain, stage1Mta)
            userMsgs[3] += 1
        else :
            sendJournalMessage(office365Guid, users[0], [users[1]], [users[2]], [users[3]], domainName, cloudDomain, stage1Mta)
            for j in range(len(users)):
                userMsgs[j] += 1

        sleep(1)

    # create reviewer group
    print time.asctime(), 'creating reviewer group...'
    allUsers = InternalUserSets.getAllUsersSet(cust.getCustID())
    mc.getUserManager().saveUserSet(allUsers)

    reviewer = mc.getUserManager().findUserForEmail(users[0] + '@' + domainName)
    reviewerSet = SavedUserSet(cust.getCustID())
    reviewerSet.addUsers(Collections.singletonList(SearchConstraint(IUserManager.PROP_USERID, SearchConstraintOperator.CONSTRAINT_EQUALS, reviewer.getUserID())))
    mc.getUserManager().saveUserSet(reviewerSet)
    mc.getReviewerGroupManager().createReviewerGroup(cust.getCustID(), REVIEWER_GROUP_NAME, reviewerSet, allUsers, None)

    sys.exit(0)
def migrateDListToSavedUserSet():
    mc = ManagementContainer.getInstance()
    userManager = mc.getUserManager()
    dlistManager = mc.getDistributionListManager()
    customerManager = mc.getCustomerManager()

    numWithDListAndWithSUS = 0
    numWithoutDList = 0
    numWithDListAndWithoutSUS = 0

    capMap = customerManager.getCapabilityForAllCustomers(Capabilities.CAP_MOBILE_APP_SUPPORT)
    for custId in capMap.keySet():
        # next, see if they have the DList
        dlist = dlistManager.getDListByDisplayName(custId, "Mobile Enabled Users FABEF3")
        if None is not dlist:
            # finally, check to see if a SUS already exists. if not, create it
            verifiedSUS = userManager.getMobileEnabledSavedUserSet(custId)
            if None is verifiedSUS:
                logMsg("customer ID " + str(custId) + " is mobile enabled, with a dlist, AND no pre-existing SUS. creating one... ")
                # set up SUS
                newSUS = SavedUserSet(custId)
                newSUS.setInternal(True)
                name = UserManagerConstants.MOBILE_SAVED_USER_SET_NAME_PREFIX
                name += str(custId)
                newSUS.setName(name)
                # add DList and save SUS
                sc = SearchConstraint(UserManagerConstants.PROP_IN_DLIST, SearchConstraintOperator.CONSTRAINT_EQUALS, dlist.getDlistId())
                listOfLists = [sc]
                listOfConstraints = [listOfLists]
                newSUS.addConstraintSets(listOfConstraints)
                userManager.saveUserSet(newSUS)
                # double check that new SUS exists
                verifiedSUS = userManager.getMobileEnabledSavedUserSet(custId)
                logMsg("creation succeeded= " + str(None is not verifiedSUS))
                numWithDListAndWithoutSUS += 1
            else:
                logMsg("customer ID " + str(custId) + " is mobile enabled, with a dlist, AND a pre-existing SUS. nothing done.")
                numWithDListAndWithSUS += 1
        else:
            logMsg("customer ID " + str(custId) + " is mobile enabled but doesn't have a dlist. nothing done.")
            numWithoutDList += 1
    # end for loop

    # print summary
    logMsg("---------SUMMARY---------", True)
    logMsg("Number of customers that didn't have the DList present (Mobile enablement never happened for customer, no migration to perform): " + str(numWithoutDList), True)
    logMsg("Number of customers that had DList present AND were just migrated by this script: " + str(numWithDListAndWithoutSUS), True)
    logMsg("Number of customers that had DList present and appeared to have already been migrated (should be 0 for the first run): " + str(numWithDListAndWithSUS), True)