コード例 #1
0
ファイル: views.py プロジェクト: JaySpell/isilontools
def cost():
    tool = Isilon_Tools()
    name = session['selected']
    myform = MyForm()
    myform.name = name[1]

    if myform.validate_on_submit():
        '''Set variables from form data for the database'''
        cust_fname = myform.cust_fname.data
        cust_lname = myform.cust_lname.data
        cost_cent = myform.cost_center.data
        work_order = myform.work_order.data
        sc_account = current_user

        try:
            '''Get quota info'''
            quota_info = tool.get_quota_info(name)

            '''Set current quota == current_quota + 100GB'''
            current_thresh = int(quota_info['threshold'])
            tool.update_quota(name, current_thresh)
            new_thresh = tool.get_quota_size(name)
            new_thresh_GB = pro_utils.convert_to_GB(new_thresh)
        except:
            return render_template('404.html', error="Could not add space to quota....")

        '''Add data to database'''
        quota_add = Quota_Update.create(
                cust_fname=cust_fname,
                cust_lname=cust_lname,
                sc_account=sc_account,
                cost_cent=cost_cent,
                work_order=work_order,
                quota_path=quota_info['path'],
                quota_id=name,
                quota_before=current_thresh,
                quota_after=new_thresh
            )

        '''Send email'''
        cost_dict = {
                'cust_fname': cust_fname,
                'cust_lname': cust_lname,
                'cost_cent': cost_cent,
                'quota_id': name,
                'work_order': work_order,
                'sc_account': sc_account,
                'quota_before': current_thresh,
                'quota_after': new_thresh,
                'quota_path': quota_info['path']
            }

        email_status = pro_utils.send_email(cost_dict)

        return render_template('finish.html', name=name,
            new_limit=new_thresh_GB, email_status=email_status)

    print myform.errors
    return render_template('cost.html', form=myform,
        btn_txt="Add Space", title="Enter Customer Name & Cost Center")
コード例 #2
0
ファイル: views.py プロジェクト: JaySpell/isilontools
def quotas():
    '''
    This gets returned after a query is entered - it should do the following...
    - set the search_string from the session data
    - use the isilon_find_quotas to return a list of dictionaries with all quotas
    - IF there are quotas it should create a new form using the quotas_radio_return function
        -- new form will have a list of radio buttons (create
    :return:
    '''
    tool = Isilon_Tools()
    search_string = session['search']

    all_quotas = tool.isilon_find_quotas(search_string)
    if all_quotas == "NA":
        return render_template('quota_not_found.html')
    else:
        myform = quotas_radio_return(all_quotas)
        itemid = myform.itemid.data

    if myform.is_submitted():
        session['selected'] = myform.itemid.data
        return redirect(url_for('cost'))
    else:
        return render_template('quotas.html',form=myform, itemid=itemid)
コード例 #3
0
ファイル: dump_quotas.py プロジェクト: JaySpell/isilontools
#!/usr/bin/env python

from isilon_tools import Isilon_Tools

if __name__ == "__main__":
    tool = Isilon_Tools()
    tool.isilon_Query_Quota()