def scheduler_profile_create_example( algo, weight, min_rate, min_burst, max_rate, max_burst): attr_list = { 'algorithm': algo, 'weight': weight, 'meter-type': 'PACKET', 'min-rate': min_rate, 'min-burst': min_burst, 'max-rate': min_rate, 'max-burst': max_burst, 'npu-id-list': [0], } sched_obj = nas_qos.SchedulerCPSObj(map_of_attr=attr_list) upd = ('create', sched_obj.data()) ret_cps_data = cps_utils.CPSTransaction([upd]).commit() if ret_cps_data == False: print 'Scheduler profile creation failed' return None print 'Return = ', ret_cps_data sched_obj = nas_qos.SchedulerCPSObj(cps_data=ret_cps_data[0]) sched_id = sched_obj.extract_id() print 'Successfully installed Scheduler profile id = ', sched_id return sched_id
def scheduler_profile_get_example(sched_id): return_data_list = [] sched_obj = nas_qos.SchedulerCPSObj(sched_id=sched_id) ret = cps.get([sched_obj.data()], return_data_list) if ret: print '#### Scheduler Profile Show ####' for cps_ret_data in return_data_list: m = nas_qos.SchedulerCPSObj(cps_data=cps_ret_data) m.print_obj() else: print 'Error in get'
def read_current_sched_prof(lookup_sched_prof): sched_prof_obj = nas_qos.SchedulerCPSObj(sched_id=0) ret_list = [] ret = cps.get([sched_prof_obj.data()], ret_list) if ret: for cps_ret_data in ret_list: m = nas_qos.SchedulerCPSObj(cps_data=cps_ret_data) if (dbg_on): m.print_obj() sp_name = m.extract_attr('name') sp_id = m.extract_attr('id') if (sp_name): lookup_sched_prof[sp_name] = sp_id; else: syslog.syslog('Error in get scheduler profiles')
def create_scheduler_profile(xnode_profile): attrs = copy.deepcopy(xnode_profile.attrib) sched_obj = nas_qos.SchedulerCPSObj(map_of_attr=attrs) upd = ('create', sched_obj.data()) ret_cps_data = cps_utils.CPSTransaction([upd]).commit() if ret_cps_data == False: raise RuntimeError( 'Scheduler profile {0} creation failed'.format(xnode_profile.attrib['name'])) sched_obj = nas_qos.SchedulerCPSObj(cps_data=ret_cps_data[0]) sched_id = sched_obj.extract_id() dbg_print(' Scheduler profile {0} = {1}'.format( xnode_profile.attrib['name'], sched_id)) return sched_id
def scheduler_profile_modify_attrs(sched_id, mod_attr_list): sched_obj = nas_qos.SchedulerCPSObj(sched_id=sched_id) for attr in mod_attr_list: sched_obj.set_attr(attr[0], attr[1]) upd = ('set', sched_obj.data()) ret_cps_data = cps_utils.CPSTransaction([upd]).commit() if ret_cps_data == False: print 'Scheduler profile modification failed' return None print 'Return = ', ret_cps_data sched_obj = nas_qos.SchedulerCPSObj(cps_data=ret_cps_data[0]) sched_id = sched_obj.extract_id() print 'Successfully modified Scheduler id = ', sched_id return sched_id
def scheduler_profile_delete_example(sched_id): sched_obj = nas_qos.SchedulerCPSObj(sched_id=sched_id) upd = ('delete', sched_obj.data()) ret_cps_data = cps_utils.CPSTransaction([upd]).commit() if ret_cps_data == False: print 'Scheduler profile delete failed' return None print 'Return = ', ret_cps_data print 'Successfully delted Scheduler id = ', sched_id