Пример #1
0
def saveOrphans(orphan_names, orphan_ids):
    qString = ''
    qData = []
    for name, uid in zip(orphan_names, orphan_ids):
        qString += "insert into orphan_accounts (account_name, account_id) VALUES (%s, %s);"
        qData.append(str(name))
        qData.append(str(uid))
        sendMail(
            '*****@*****.**', [name] + WATCHERS,
            'SDSC Cloud User Account Inactivity',
            'Dear SDSC Cloud User,\n\nYour user account, {0}, does not belong to any active projects.  The user account will automatically be deleted if it is not associated with an active project within 14 days.\n\nPlease contact us by replying to this email if you need your user account to remain active.\n\nRegards,\nSDSC Cloud Support Team'
            .format(name))
    query(qString, tuple(qData), False)
Пример #2
0
def main(project_name, shouldPrint=True):
    ticketNumber = createTicket(project_name=project_name,
                                billing_index='CACNULL',
                                first_name='Andrew',
                                last_name='Ferbert',
                                email='*****@*****.**',
                                title='Commvault Invoice - {0}',
                                t_assignees=['dferbert'])
    query(
        "insert into commvault_tickets (name, ticket_number) VALUES (%s, %s);",
        [project_name, ticketNumber], False)
    if shouldPrint:
        print ticketNumber
    return ticketNumber
def main():
    argCount = len(sys.argv)
    if argCount != 2:
        return
    #return
    data = json.loads(sys.argv[1])

    project_name = data[0]
    project_index = data[1].upper()

    if not validateProjectIndex(project_index):
        raise InvalidCharacters()

    project_o = pBuilder.getProject(project_name)
    if project_o == None:
        return

    contact_name = project_o.contact_name
    if ' ' in contact_name:
        indexOfSpace = contact_name.index(' ')
        first_name = contact_name[:indexOfSpace]
        last_name = contact_name[indexOfSpace + 1:]
    else:
        first_name = contact_name
        last_name = contact_name
    title = None  #auto set in create ticket
    assignees = None  #auto set in create ticket

    ticketNumber = tEditor.createTicket(project_name, project_index,
                                        first_name, last_name,
                                        project_o.contact_email, title,
                                        assignees)
    pBuilder.setBillingInfo(project_name, str(ticketNumber))

    query('delete from trial_projects where name = %s;', tuple([project_name]),
          False)

    subj = "Cloud Project Upgraded [{0}]".format(project_name)
    msg = "The Cloud Project " + project_name + " has been upgraded to a paid project \n\n\n Cloud-Web-Util"
    sendMail("*****@*****.**",
             ["*****@*****.**", "*****@*****.**"], subj, msg)
    print ticketNumber
def getTicketNumber(name):
    res = db_communicator.query(
        'select ticket_number from commvault_tickets where name = %s', [name],
        True)

    try:
        return res[0][0]
    except:
        printTicketNumber = False
        print 'created ticekt for ' + name
        return createCommvaultTicket.main(name, printTicketNumber)
Пример #5
0
def notifyOrphans():
    orphan_names, orphan_ids = collectOrphans()

    previous_orphans = query(
        'select account_name, account_id from orphan_accounts', (), True)

    still_orphan = []
    for prev_orphan in previous_orphans:
        name = prev_orphan[0]
        if name in orphan_names:
            still_orphan.append(prev_orphan)

    for name, uid in still_orphan:
        keyStone.users.delete(user=uid)
        sendMail(
            '*****@*****.**', [name] + WATCHERS,
            'SDSC Cloud User Account Deleted',
            'Dear SDSC Cloud User,\n\nYour user account, {0}, has been deleted because it does not belong to any active projects.\n\nPlease contact us by replying to this email if you need your account re-created.\n\nRegards,\nSDSC Cloud Support Team'
            .format(name))

    query('delete from orphan_accounts;', (), False)
Пример #6
0
def runTests():
	r = requests.post("https://cloud-web-util.ucsd.edu/new-commvault-ticket", data='c1mckaytest', verify=False, headers={'Authorization': getCredentials()})
	print 'delete ticket ' + r.text + ' on footprints'
	query("delete from commvault_tickets where ticket_number = %s;", [ticketNumber], False)
Пример #7
0
from db_communicator import query

from openstack_utility import keyStoneUtility
import json, credentials, datetime

pBuilder = keyStoneUtility.KeyStoneUtility(
    username=credentials.open_stack_username,
    password=credentials.open_stack_pw,
    auth_url=credentials.open_stack_url,
    auth_url_dep=credentials.open_stack_url_dep,
    tenant_name=credentials.open_stack_username)

results = query(
    'select project_id, name, created, notified, warning_length, delete_length from trial_projects',
    (), True)

trialData = []

for r in results:
    proj_o = pBuilder.getProject(r[1])
    if proj_o == None:
        continue
    dataPacket = {}
    dataPacket['projectName'] = r[1]
    dataPacket['projCreated'] = (r[2] -
                                 datetime.date(1970, 1, 1)).total_seconds()
    dataPacket['trialLength'] = (r[5])

    dataPacket['contactEmail'] = proj_o.contact_email
    dataPacket['contactName'] = proj_o.contact_name
Пример #8
0
def deleteTrialDbEntry(uid):
    query('delete from trial_projects where project_id = %s;',
          tuple([int(uid)]), False)
Пример #9
0
def markNotified(uid):
    db_communicator.query(
        'update trial_projects set notified = true where project_id = %s',
        tuple([int(uid)]), False)
Пример #10
0
def saveTrialProject(project_name, warning, expiration):
    query(
        'insert into trial_projects (name, created, notified, warning_length, delete_length) values (%s, CURRENT_TIMESTAMP, %s, %s, %s);',
        [project_name, False, warning, expiration], False)
Пример #11
0
def getDatesSent(project_name):
	results = db_communicator.query('select date_sent from email_records where project_name = %s', [project_name.lower()], True)
	return [r[0] for r in results]
Пример #12
0
def saveEmailTimeToDb(project_name):
	db_communicator.query('insert into email_records (project_name, date_sent) values (%s, CURRENT_TIMESTAMP);', [project_name], False)