Esempio n. 1
0
def index():
    if auth.is_logged_in():
        if get_constant('baadal_status') != BAADAL_STATUS_UP:
            if not is_moderator():
                redirect(URL(r=request,c='default', f='user/logout'))
            session.flash='Baadal is in Maintenance Mode'
    return dict(request=request)
Esempio n. 2
0
def index():
    if auth.is_logged_in():
        if get_constant('baadal_status') != BAADAL_STATUS_UP:
            if not is_moderator():
                redirect(URL(r=request, c='default', f='user/logout'))
            session.flash = 'Baadal is in Maintenance Mode'
    return dict(request=request)
Esempio n. 3
0
def respawn_dangling_vms(host_id):
    
    vms = current.db(current.db.vm_data.host_id == host_id).select(current.db.vm_data.ALL)
    vm_image_location = get_constant('vmfiles_path') + get_constant('vms') + '/%s/%s.qcow2'
    for vm_data in vms:
        
        logger.debug('Re-spawning VM ' + vm_data.vm_identity)
        #Create a copy of existing image and rename it with '_old' suffix
        storage_type = config.get("GENERAL_CONF","storage_type")
        copy_command = 'ndmpcopy ' if storage_type == current.STORAGE_NETAPP_NFS else 'cp '
            
        ds_image_location = vm_data.datastore_id.path + get_constant('vms') + '/%s/%s.qcow2'
        command_to_execute = copy_command + ds_image_location%(vm_data.vm_identity, vm_data.vm_identity) + \
                                ' ' + ds_image_location%(vm_data.vm_identity, vm_data.vm_identity+'_old')

        execute_remote_cmd(vm_data.datastore_id.ds_ip, 
                           vm_data.datastore_id.username, 
                           command_to_execute, 
                           vm_data.datastore_id.password)
        logger.debug('Backup copy of the VM image cretaed successfully.')
        
        vm_properties = {}
        vm_properties['host'] = find_new_host(vm_data.RAM, vm_data.vCPU)
        vm_properties['ram'] = vm_data.RAM
        vm_properties['vcpus'] = vm_data.vCPU
        vm_properties['mac_addr'] = vm_data.private_ip.mac_addr
        vm_properties['vnc_port'] = vm_data.vnc_port
        vm_properties['template'] = current.db.template[vm_data.template_id]
        vm_properties['vlan_name'] = current.db(current.db.private_ip_pool.private_ip == vm_data.private_ip).select()[0].vlan.name

        # Re-spawn the VM on new host
        launch_vm_on_host(vm_data, vm_image_location%(vm_data.vm_identity, vm_data.vm_identity), vm_properties)
        vm_data.update_record(host_id = vm_properties['host'])
        
        #Find the most recent snapshot of the given VM; revert to the snapshot
        recent_snapshot = current.db(current.db.snapshot.vm_id == vm_data.id).select(orderby = ~current.db.snapshot.timestamp)[0]
        logger.debug('Reverting VM %s to snapshot %s' %(vm_data.vm_identity, recent_snapshot.snapshot_name))
        revert(dict(vm_id = vm_data.id, snapshot_id = recent_snapshot.id))
Esempio n. 4
0
def baadal_status():
    vm_list = get_baadal_status_info()
    baadal_status = get_constant('baadal_status')
    return dict(vm_list=vm_list, baadal_status=baadal_status)
Esempio n. 5
0
                response.admin_menu.extend([(T('Approve Users'), False, URL('admin','approve_users')),
                                            (T('Modify User Role'), False, URL('admin','modify_user_role'))])

        response.admin_menu.extend([(T('Configure System'), False,dict(_href='#', _id='configure'),[
                (T('Configure Host'), False, URL('admin','host_details')),
                (T('Configure Template'), False, URL('admin','manage_template')),
                (T('Configure Datastore'), False, URL('admin','manage_datastore')),
		(T('Controller Performance'), False, URL('admin','show_cont_performance')),
		(T('NAT Performance'), False, URL('admin','show_nat_performance')),
                (T('Host Throughput Graph'), False, URL('admin','network_graph')),
		(T('Host Latency Graph'), False, URL('admin','host_network_graph')),
                (T('Utilization'), False, URL('admin','zoom_tree')),
                (T('Configure Security Domain'), False, URL('admin','manage_security_domain')),
                (T('Configure Private IP Pool'), False, URL('admin','manage_private_ip_pool')),
                (T('Configure Public IP Pool'), False, URL('admin','manage_public_ip_pool')),
                (T('Launch VM Image'), False, URL('admin','launch_vm_image'))
                ])])

        baadal_status = get_constant('baadal_status')
        status_txt = None
        if baadal_status == BAADAL_STATUS_DOWN:
            status_txt = 'Bootup Baadal'
        elif baadal_status == BAADAL_STATUS_DOWN_IN_PROGRESS:
            status_txt = 'Check Baadal Shutdown Status'
        elif baadal_status == BAADAL_STATUS_UP:
            status_txt = 'Shutdown Baadal'
        elif baadal_status == BAADAL_STATUS_UP_IN_PROGRESS:
            status_txt = 'Check Baadal Bootup Status'
        if status_txt:
            response.admin_menu.extend([((T(status_txt), False, URL('admin','baadal_status')))])
Esempio n. 6
0
def baadal_status():
    vm_list = get_baadal_status_info()
    baadal_status = get_constant('baadal_status')
    return dict(vm_list=vm_list, baadal_status=baadal_status)
Esempio n. 7
0
                  (T('Host Throughput Graph'), False,
                   URL('admin', 'network_graph')),
                  (T('Host Latency Graph'), False,
                   URL('admin', 'host_network_graph')),
                  (T('Utilization'), False, URL('admin', 'zoom_tree')),
                  (T('Configure Security Domain'), False,
                   URL('admin', 'manage_security_domain')),
                  (T('Configure Private IP Pool'), False,
                   URL('admin', 'manage_private_ip_pool')),
                  (T('Configure Public IP Pool'), False,
                   URL('admin', 'manage_public_ip_pool')),
                  (T('Launch VM Image'), False, URL('admin',
                                                    'launch_vm_image'))])
            ])

        baadal_status = get_constant('baadal_status')
        status_txt = None
        if baadal_status == BAADAL_STATUS_DOWN:
            status_txt = 'Bootup Baadal'
        elif baadal_status == BAADAL_STATUS_DOWN_IN_PROGRESS:
            status_txt = 'Check Baadal Shutdown Status'
        elif baadal_status == BAADAL_STATUS_UP:
            status_txt = 'Shutdown Baadal'
        elif baadal_status == BAADAL_STATUS_UP_IN_PROGRESS:
            status_txt = 'Check Baadal Bootup Status'
        if status_txt:
            response.admin_menu.extend([((T(status_txt), False,
                                          URL('admin', 'baadal_status')))])

else:
    response.user_menu = [
Esempio n. 8
0
def get_rrd_file(identity):

    rrd_file = get_constant("vmfiles_path") + os.sep + get_constant("vm_rrds_dir") + os.sep + identity + ".rrd"
    return rrd_file
Esempio n. 9
0
def get_rrd_file(identity):

    rrd_file = get_constant("vmfiles_path") + os.sep + get_constant("vm_rrds_dir") + os.sep + identity + ".rrd"
    return rrd_file
Esempio n. 10
0
def create_graph(rrd_file_name, graph_type, rrd_file_path, graph_period):

    rrd_logger.debug(rrd_file_name+" : "+graph_type+" : "+rrd_file_path+" : "+graph_period)
    #rrd_file = rrd_file_name + '.rrd'       

    #shutil.copyfile(rrd_file_path, rrd_file)
    graph_file = rrd_file_name + "_" + graph_type + ".png"
    graph_file_dir = os.path.join(get_context_path(), 'static' + get_constant('graph_file_dir'))
    graph_file_path = graph_file_dir + os.sep + graph_file

    start_time = None
    consolidation = 'MIN'
    ds = ds1 = ds2 = None
    line = line1 = line2 = None

    
    if graph_period == 'hour':
        start_time = 'now - ' + str(24*60*60)
    elif graph_period == 'day':
        start_time = '-1w'
    elif graph_period == 'month':
        start_time = '-1y'
    elif graph_period == 'week':
        start_time = '-1m'
    elif graph_period == 'year':
        start_time = '-5y'
  
    if ((graph_type == 'ram') or (graph_type == 'cpu')):

        if graph_type == 'ram':
            ds = 'DEF:ram=' + rrd_file_path + ':ram:' + consolidation
            line = 'LINE1:ram#0000FF:Memory'
            graph_type += " (Bytes/Sec)"
            upper_limit = ""
        elif graph_type == 'cpu':
            ds = 'DEF:cpu=' + rrd_file_path + ':cpu:' + consolidation
            line = 'LINE1:cpu#0000FF:CPU'
            graph_type += " (%)"
            upper_limit = "-u 100"
                
        rrdtool.graph(graph_file_path, '--start', start_time, '--end', 'now', '--vertical-label', graph_type, '--watermark', time.asctime(), '-t', ' ' + rrd_file_name, ds, line, "-l 0 --alt-y-grid -L 6" + upper_limit )

    else:

        if graph_type == 'nw':
            ds1 = 'DEF:nwr=' + rrd_file_path + ':tx:' + consolidation
            ds2 = 'DEF:nww=' + rrd_file_path + ':rx:' + consolidation
            line1 = 'LINE1:nwr#0000FF:Transmit'
            line2 = 'LINE1:nww#FF7410:Receive'

        elif graph_type == 'disk':
            ds1 = 'DEF:diskr=' + rrd_file_path + ':dr:' + consolidation
            ds2 = 'DEF:diskw=' + rrd_file_path + ':dw:' + consolidation
            line1 = 'LINE1:diskr#0000FF:DiskRead'
            line2 = 'LINE1:diskw#FF7410:DiskWrite'

        graph_type += " (Bytes/Sec)"

        rrdtool.graph(graph_file_path, '--start', start_time, '--end', 'now', '--vertical-label', graph_type, '--watermark', time.asctime(), '-t', ' ' + rrd_file_name, ds1, ds2, line1, line2, "-l 0 --alt-y-grid -L 6" )

    rrd_logger.debug(graph_file_path)

    if os.path.exists(graph_file_path):
        return True
    else:
        return False