示例#1
0
def get_counters_in_cac():
    """    
    This keyword is used to shows counters in CAC part.
    #COMMAND: fsclish -c "show troubleshooting cac leg"
    | Parameters          | Man. | Description                                 |
    | NA                  |      |                                             |

    | Return value | an Instance of list with legs number and capacity         |

    Example
    | result | get_couters_in_cac  |  |
    """
    command = """fsclish -c "show troubleshooting cac leg" """
    print "Command: " + command
    output = connections.execute_mml_without_check(command)
    pattern = re.compile(
        '''^.*
UDP\sleg\s:\s+(?P<udp_num>\d+)\s+
RTP\sleg\s:\s+(?P<rtp_num>\d+)\s+
GTP\sleg\s:\s+(?P<gtp_num>\d+)\s+
Capacities:\s+
UDP\sand\s+RTP\s+leg\s+:\s+(?P<udp_rtp_leg_capacity>\d+)\s+
GTP\sleg\s+:\s+(?P<gtp_leg_capacity>\d+)\s+
''', re.VERBOSE | re.DOTALL)
    item = pattern.match(output)
    leg_info = CommonItem()
    if item:
        leg_list = item.groupdict()
        leg_info.udp_num = leg_list['udp_num']
        leg_info.rtp_num = leg_list['rtp_num']
        leg_info.gtp_num = leg_list['gtp_num']
        leg_info.udp_rtp_leg_capacity = leg_list['udp_rtp_leg_capacity']
        leg_info.gtp_leg_capacity = leg_list['gtp_leg_capacity']

    return leg_info
示例#2
0
def get_specific_ipbr_info_in_cac(ipbr_id):
    """    
    This keyword is used to get ipbr resource information from CAC PRB
    
    #COMMAND: fsclish -c "show troubleshooting cac ipbr ipbr-id  <IPBR ID>"
    
    | Parameters         | Man. | Description                                 |
    | ipbr_id            | Yes  | IPBR ID                                     |

    | Return value | an Instance of commonitem with specific IPBR all information in CAC |

    Example
    | result | get_specific_ipbr_info_in_cac | 12 |
    """
    command = """fsclish -c "show troubleshooting cac ipbr ipbr-id %s" """ % (
        ipbr_id)
    print "Command: " + command
    output = connections.execute_mml_without_check(command)
    if output.find('does not exist') != -1:
        output = 'IPBR with ipbr-id (%s) does not exist in connection admission control part.' % (
            ipbr_id)
        return output
    if output.find('NO WORKING') != -1:
        return output
    else:
        pattern = re.compile(
            '''^.*
IPBR\sID\s+:\s+(?P<ipbr_id>\d+)\s+
IPBR\sname\s+:\s+(?P<ipbr_name>\S+)\s+
Route\sbandwidth\s+:\s(?P<route_bw>\d+)\s+kbps\s+
Committed\sbandwidth\s+:\s(?P<cmmt_bw>\d+)\s+kbps\s+
Committed\sDCN\sbandwidth\s+:\s(?P<cmmt_dcn_bw>\d+)\s+kbps\s+
Committed\ssignaling\sbandwidth\s+:\s(?P<cmmt_sig_bw>\d+)\s+kbps\s+
Committed\suser\splane\sbandwidth\s+:\s(?P<up_bw>\d+)\s+kbps\s+
Reserved\sbandwidth\s+:\s(?P<res_bw>\S+)\s+kbps\s+
IFC\sNRTDCH\s+:\s+(?P<ifc_nrtdch>\S+)\s+
IFC\sNRTHSDPA\s+:\s+(?P<ifc_nrthsdpa>\S+)\s+
Scheduler\stype\s+:\s+(?P<scheduler_type>\S+)\s+ 
PHB\sprofile\sID\s+:\s+(?P<phb_profile>\d+)\s+
DSPM\sprofile\sID\s+:\s+(?P<dspm_profile>\d+)\s+
MUX\senable\s+:\s+(?P<mux_enable>\S+)\s+
Max\sMUX\spackets\snumber\s+:\s+(?P<max_mux_packet>\d+)\s+
Local\sMUX\sUDP\sport\s+:\s+(?P<local_mux_port>\d+)\s+
Remote\sMUX\sUDP\sport\s+:\s+(?P<remote_mux_port>\d+)\s+
MUX\sUDP\sDSCP\svalue\s+:\s+(?P<mux_udp_value>\d+)\s+ 
GTP\sleg\snumber\s+:\s+(?P<gtp_num>\d+)\s+
RTP\sleg\snumber\s+:\s+(?P<rtp_num>\d+)\s+
UDP\sleg\snumber\s+:\s+(?P<udp_num>\d+)\s+
IPBR\sstatus\s+:\s((?P<ipbr_status>\S+)\s+)
''', re.VERBOSE | re.DOTALL)
        item = pattern.match(output)
        ipbr_info = CommonItem()
        if item:
            ipbr_attr = item.groupdict()
            ipbr_info.ipbr_id = ipbr_attr['ipbr_id']
            ipbr_info.ipbr_name = ipbr_attr['ipbr_name']
            ipbr_info.route_bw = ipbr_attr['route_bw']
            ipbr_info.cmmt_bw = ipbr_attr['cmmt_bw']
            ipbr_info.cmmt_dcn_bw = ipbr_attr['cmmt_dcn_bw']
            ipbr_info.cmmt_sig_bw = ipbr_attr['cmmt_sig_bw']
            ipbr_info.ifc_nrtdch = ipbr_attr['ifc_nrtdch']
            ipbr_info.ifc_nrthsdpa = ipbr_attr['ifc_nrthsdpa']
            ipbr_info.scheduler_type = ipbr_attr['scheduler_type']
            ipbr_info.phb_profile = ipbr_attr['phb_profile']
            ipbr_info.dspm_profile = ipbr_attr['dspm_profile']
            ipbr_info.mux_enable = ipbr_attr['mux_enable']
            ipbr_info.max_mux_packet = ipbr_attr['max_mux_packet']
            ipbr_info.local_mux_port = ipbr_attr['local_mux_port']
            ipbr_info.mux_udp_value = ipbr_attr['mux_udp_value']
            ipbr_info.up_bw = ipbr_attr['up_bw']
            ipbr_info.res_bw = "%d" % (atof(ipbr_attr['res_bw']) * 1000)
            ipbr_info.free_bw = "%d" % (atof(ipbr_info.up_bw) -
                                        atof(ipbr_info.res_bw))
            ipbr_info.gtp_num = ipbr_attr['gtp_num']
            ipbr_info.rtp_num = ipbr_attr['rtp_num']
            ipbr_info.udp_num = ipbr_attr['udp_num']
            ipbr_info.ipbr_status = ipbr_attr['ipbr_status']
            ipbr_info.ip_list = []
        else:
            return ipbr_info

    if output.find('No IP address bound with the IPBR.') != -1:
        ipbr_info.ip_list = 'No IP address bound with the IPBR.'
    else:
        ip_pattern = re.compile('(\d+\.\d+\.\d+\.\d+)\s+(\d+)\s+(\S+)\s+(\S+)')
        items = ip_pattern.findall(output)
        for item in items:
            ip_info = CommonItem()
            ip_info.ip_addr = item[0]
            ip_info.vrf_id = item[1]
            ip_info.monitor = item[2]
            ip_info.status = item[3]
            ipbr_info.ip_list.append(ip_info)
    return ipbr_info