Ejemplo n.º 1
0
def request_vm_validation(form):
    set_configuration_elem(form)
    if not(is_moderator() | is_faculty()):
        validate_approver(form)
    else:
        form.vars.owner_id = auth.user.id
        form.vars.status = VM_STATUS_VERIFIED
    
    form.vars.requester_id = auth.user.id
Ejemplo n.º 2
0
def get_request_vm_form():
    
    form_fields = ['vm_name','template_id','extra_HDD','purpose']
    form_labels = {'vm_name':'Name of VM','extra_HDD':'Optional Additional Harddisk(GB)','template_id':'Template Image','purpose':'Purpose of this VM'}

    form =SQLFORM(db.vm_data, fields = form_fields, labels = form_labels, hidden=dict(user_name=''))
    get_configuration_elem(form) # Create dropdowns for configuration

    if not(is_moderator() | is_faculty()):
        add_faculty_approver(form)
    
    return form
Ejemplo n.º 3
0
def settings():

    vm_id=request.args[0]
    vm_users = None
    vm_info = get_vm_config(vm_id)
    
    if is_moderator() | is_faculty() | is_orgadmin():
        vm_users = get_vm_user_list(vm_id)
    
    vm_operations = get_vm_operations(vm_id)

    vm_snapshots = get_vm_snapshots(vm_id)
    
    return dict(vminfo = vm_info , vmoperations = vm_operations, vmsnapshots = vm_snapshots, vmusers = vm_users)     
Ejemplo n.º 4
0
def settings():

    vm_id = request.args[0]
    vm_users = None
    vm_info = get_vm_config(vm_id)

    if is_moderator() | is_faculty() | is_orgadmin():
        vm_users = get_vm_user_list(vm_id)

    vm_operations = get_vm_operations(vm_id)

    vm_snapshots = get_vm_snapshots(vm_id)

    return dict(vminfo=vm_info,
                vmoperations=vm_operations,
                vmsnapshots=vm_snapshots,
                vmusers=vm_users)
Ejemplo n.º 5
0
    (T('Photos'), False, URL('default', 'page_under_construction')),
    (T('Team Baadal'), False, URL('default', 'page_under_construction')),
    (T('Contact'), False, URL('default', 'page_under_construction'))
]
if auth.is_logged_in():
    response.user_menu = [
        (H2('USER MENU'), False, dict(_href='#', _id='menu_user')),
        (T('Home'), False, URL('default', 'index')),
        (T('Request VM'), False, URL('user', 'request_vm')),
        (T('My VMs'), False, URL('user', 'list_my_vm')),
        (T('My Tasks'), False, URL('user', 'list_my_task')),
        (T('Mail Admin'), False, URL('default', 'page_under_construction')),
        (T('Report Bug'), False, URL('default', 'page_under_construction'))
    ]

    if (is_moderator() | is_faculty()):
        response.faculty_menu = [
            (H2('FACULTY MENU'), False, dict(_href='#', _id='menu_faculty')),
            (T('Pending Requests {' + str(len(get_pending_requests())) + '} '),
             False, URL('faculty', 'pending_requests'))
        ]

        if (is_moderator() | is_orgadmin()):
            response.orgadmin_menu = [
                (H2('ORG-ADMIN MENU'), False,
                 dict(_href='#', _id='menu_orgadmin')),
                (T('List All Org-Level VMs'), False,
                 URL('orgadmin', 'list_all_orglevel_vm')),
                (T('Pending Org-Level VM Approvals {' +
                   str(get_pending_approval_count()) + '}'), False,
                 URL('orgadmin', 'pending_approvals'))
Ejemplo n.º 6
0
def get_vm_operations(vm_id):

    valid_operations_list = []
    vmstatus = int(db(db.vm_data.id == vm_id).select(db.vm_data.status).first()['status'])
   
    if (vmstatus == VM_STATUS_RUNNING) or (vmstatus == VM_STATUS_SUSPENDED) or (vmstatus == VM_STATUS_SHUTDOWN):

        valid_operations_list.append(A(IMG(_src=URL('static','images/snapshot.png'), _height=20, _width=20),
                    _href=URL(r=request, c='user' ,f='snapshot', args=[vm_id]), 
                    _title="Take VM snapshot", _alt="Take VM snapshot"))

        valid_operations_list.append(A(IMG(_src=URL('static','images/performance.jpg'), _height=20, _width=20),
                    _href=URL(r=request, c='default' ,f='page_under_construction', args=[vm_id]), 
                    _title="Check VM performance", _alt="Check VM Performance"))

        if is_moderator():

            if (db(db.host.id > 0).count() >= 2):

                valid_operations_list.append(A(IMG(_src=URL('static','images/migrate.png'), _height=20, _width=20),
               	     _href=URL(r=request, c = 'admin' , f='migrate_vm', args=[vm_id]), 
                     _title="Migrate this virtual machine", _alt="Migrate this virtual machine"))

        if is_moderator() or is_orgadmin() or is_faculty():
            valid_operations_list.append(A(IMG(_src=URL('static','images/delete.png'), _height=20, _width=20),
               	 	_onclick="confirm_vm_deletion()",	_title="Delete this virtual machine",	_alt="Delete this virtual machine"))
  
        if vmstatus == VM_STATUS_SUSPENDED:
            
            valid_operations_list.append(A(IMG(_src=URL('static','images/play2.png'), _height=20, _width=20),
                _href=URL(r=request, f='resume_machine', args=[vm_id]), 
                _title="Unpause this virtual machine", _alt="Unpause on this virtual machine"))
                
            valid_operations_list.append(A(IMG(_src=URL('static','images/cpu.png'), _height=20, _width=20),
                _href=URL(r=request, f='adjrunlevel', args = vm_id),
                _title="Adjust your machines resource utilization", _alt="Adjust your machines resource utilization"))
            
        if vmstatus == VM_STATUS_SHUTDOWN:
            
            valid_operations_list.append(A(IMG(_src=URL('static','images/on-off.png'), _height=20, _width=20),
               	 	_href=URL(r=request, f='start_machine', args=[vm_id]), 
                	_title="Turn on this virtual machine", _alt="Turn on this virtual machine"))

            valid_operations_list.append(A(IMG(_src=URL('static','images/clonevm.png'), _height=20, _width=20),
                _href=URL(r=request,c='default', f='request_clonevm', args=vm_id), _title="Request Clone vm", _alt="Request Clone vm"))
                               
            valid_operations_list.append(A(IMG(_src=URL('static','images/disk.jpg'), _height=20, _width=20),
                    _href=URL(r=request, c='default' ,f='page_under_construction', args=[vm_id]), 
                    _title="Attach Extra Disk", _alt="Attach Extra Disk"))
                    
            if is_moderator():
            
                valid_operations_list.append(A(IMG(_src=URL('static','images/vnc.jpg'), _height=20, _width=20),
                    _href=URL(r=request, c='default' ,f='page_under_construction', args=[vm_id]), 
                    _title="Assign VNC", _alt="Assign VNC"))
                    
                valid_operations_list.append(A(IMG(_src=URL('static','images/editme.png'), _height=20, _width=20),
                    _href=URL(r = request, c = 'admin', f = 'edit_vmconfig', args = vm_id), _title="Edit VM Config", 
                    _alt="Edit VM Config"))
                
        if vmstatus == VM_STATUS_RUNNING:
            
            valid_operations_list.append(A(IMG(_src=URL('static','images/pause2.png'), _height=20, _width=20),
                    _href=URL(r=request, f='pause_machine', args=[vm_id]), 
                    _title="Pause this virtual machine", _alt="Pause this virtual machine"))

            valid_operations_list.append(A(IMG(_src=URL('static','images/shutdown2.png'), _height=20, _width=20),
                    _href=URL(r=request, f='shutdown_machine', args=[vm_id]), _title="Gracefully shut down this virtual machine",
                    _alt="Gracefully shut down this virtual machine"))
                    
                    
        if (vmstatus == VM_STATUS_RUNNING) or (vmstatus == VM_STATUS_SUSPENDED):
            
            valid_operations_list.append(A(IMG(_src=URL('static','images/on-off.png'), _height=20, _width=20),
                    _href=URL(r=request, f='destroy_machine', args= [vm_id]), 
                    _title="Forcefully power off this virtual machine",
                    _alt="Forcefully power off this virtual machine"))

    if is_moderator():
   
        valid_operations_list.append(A(IMG(_src=URL('static','images/user_add.png'), _height=20, _width=20),
                    _href=URL(r = request, c = 'admin', f = 'user_details', args = vm_id), _title="Add User to VM", 
                    _alt="Add User to VM"))
   
   
    else:
        logger.error("INVALID VM STATUS!!!")
        raise
    return valid_operations_list  
Ejemplo n.º 7
0
 def decorator(*args, **kwargs):
     if (auth.is_logged_in()) & (is_faculty() | is_orgadmin() | is_moderator()):
         return fn(*args, **kwargs)
     else:
         session.flash = "You don't have faculty privileges"
         redirect(URL(c='default', f='index'))
Ejemplo n.º 8
0
    (T('Photos'), False, URL('default','page_under_construction')),
    (T('Team Baadal'), False, URL('default','page_under_construction')),
    (T('Contact'), False, URL('default','page_under_construction'))
    ]
if auth.is_logged_in():
    response.user_menu = [
        (H2('USER MENU'),False, dict(_href='#', _id='menu_user')),
        (T('Home'), False, URL('default','index')),
        (T('Request VM'), False, URL('user','request_vm')),
        (T('My VMs'), False, URL('user','list_my_vm')),
        (T('My Tasks'), False, URL('user','list_my_task')),
        (T('Mail Admin'), False, URL('default','page_under_construction')),
        (T('Report Bug'), False, URL('default','page_under_construction'))
        ]
    
    if (is_moderator() | is_faculty()):
        response.faculty_menu = [
            (H2('FACULTY MENU'),False, dict(_href='#', _id='menu_faculty')),
            (T('Pending Requests {'+str(len(get_pending_requests()))+'} '), False, URL('faculty','pending_requests'))
            ]
            
        if (is_moderator() | is_orgadmin()):
            response.orgadmin_menu = [
                (H2('ORG-ADMIN MENU'),False, dict(_href='#', _id='menu_orgadmin')),
                (T('List All Org-Level VMs'), False, URL('orgadmin','list_all_orglevel_vm')),
                (T('Pending Org-Level VM Approvals {'+str(get_pending_approval_count())+'}'), False, URL('orgadmin','pending_approvals'))
                ]
        
            if is_moderator():
                response.admin_menu = [
                    (H2('ADMIN MENU'),False, dict(_href='#', _id='menu_admin')),