def print_ipv6_route_nhlist_func(dict): print 'base-route/obj/entry/nh-list/nh-addr = ', for k in dict: inner_dict = dict[k] ip_str = inner_dict['base-route/obj/entry/nh-list/nh-addr'] print ba_utils.ba_to_ipv6str('', str(ip_str)), print ''
def _parse_snoop_routes(vlan_id, vlan_info, op, igmp_events, group_info, pub_data): for key, val in group_info.items(): if 'group' not in val: mcast_utils.log_err( "Route Event: VLAN %d Group not present, skip processing" % (vlan_id)) continue if 'interface' not in val: mcast_utils.log_err( "Route Event: VLAN %d interface not present, skip processing" % (vlan_id)) continue interface = val['interface'] #Validate given interface is VLAN member if mcast_utils.is_intf_vlan_member(vlan_info, interface, vlan_id) is False: mcast_utils.log_err( "Route Event: interface %s is not VLAN %d member, skip processing" % (str(interface), vlan_id)) if (op != "delete"): return False continue if mcast_utils._is_ip_addr(igmp_events, val['group']): group = val['group'] elif igmp_events is True: group = ba.ba_to_ipv4str('ipv4', val['group']) else: group = ba.ba_to_ipv6str('ipv6', val['group']) pub_data.update({ 'vlan-id': vlan_id, ('group', key, 'interface'): interface, ('group', key, 'address'): group }) if 'source-addr' in val: if mcast_utils._is_ip_addr(igmp_events, val['source-addr']): source = val['source-addr'] elif igmp_events is True: source = ba.ba_to_ipv4str('ipv4', val['source-addr']) else: source = ba.ba_to_ipv6str('ipv6', val['source-addr']) pub_data.update({('group', key, 'source', '0', 'address'): source}) mcast_utils.log_info( "Route event:VLAN %d Interface: %s Group %s Source %s" % (vlan_id, str(interface), group, source)) else: mcast_utils.log_info( "Route Event: VLAN %d Interface %s Source not present, (*, %s) route " % (vlan_id, str(interface), group)) return True
def _handle_static_groups(op, data, vlan_info, ipv4_flag, static_l2_mcast_grp_key, vlan_id_key): try: res = [] _cps_to_bridge_op = {'create': 'add', 'delete': 'del'} _static_grp = data[static_l2_mcast_grp_key] ret = True for k in _static_grp: # Check if the group address is a valid ipv4 or ipv6 address string if _is_ip_addr(ipv4_flag, _static_grp[k]['group']): grp = _static_grp[k]['group'] else: # Convert the bytearray to ipv4 or ipv6 address string representation if ipv4_flag: grp = ba.ba_to_ipv4str('ipv4', _static_grp[k]['group']) else: grp = ba.ba_to_ipv6str('ipv6', _static_grp[k]['group']) if_name = _get_if_name(vlan_info, _static_grp[k]['interface'], data[vlan_id_key]) if not if_name: return False vlan_name = vlan_info['cps/key_data'][ 'if/interfaces/interface/name'] cmd = [ bridge_cmd, 'mdb', _cps_to_bridge_op[op], 'dev', vlan_name, 'port', if_name, 'grp', grp, 'permanent' ] res = [] if (run_command(cmd, res) != 0): ret = ret and False return ret except Exception as e: log_err(str(e)) return False
def get_remote_endpoint_list(cps_obj): """Method to retrive a list of remote endpoints from the CPS object""" rlist = {} remote_endpoints = __read_attr(cps_obj, REMOTE_ENDPOINT_LIST) if remote_endpoints is not None: for name in remote_endpoints: ip = None addr_family = None flooding_enabled = 1 try: endpoint = remote_endpoints[name] nas_if.log_info(" remote endpoint %s" % (str(remote_endpoints))) addr_family = endpoint[REMOTE_ENDPOINT_ADDR_FAMILY] if addr_family is None: return False, rlist ip = None if addr_family is socket.AF_INET: ip_ba = ba.hex_to_ba('ipv4', endpoint[REMOTE_ENDPOINT_IP_ADDR]) ip = ba.ba_to_ipv4str('ipv4', ip_ba) else: ip_ba = ba.hex_to_ba('ipv6', endpoint[REMOTE_ENDPOINT_IP_ADDR]) ip = ba.ba_to_ipv6str('ipv6', ip_ba) if REMOTE_ENDPOINT_FLOODING_ENABLED in endpoint: flooding_enabled = endpoint[REMOTE_ENDPOINT_FLOODING_ENABLED] except ValueError: logging.exception('error:') nas_if.log_err("Failed to read attr of remote endpoint") pass if ip is None or addr_family is None or flooding_enabled is None: return False, rlist rlist[ip] = RemoteEndpoint(ip, addr_family, flooding_enabled) return True, rlist
def print_ipv6_route_prefix_func(data): print 'base-route/obj/entry/route-prefix = ', ba_utils.ba_to_ipv6str('', str(data))