Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add igmp and mroute Services #762

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ markers =
find
help
interface
igmp
lpm
mac
namespace
route
mroute
show
sqcmds
summarize
Expand Down Expand Up @@ -133,6 +135,7 @@ markers =
nxos
panos
vmx
multicast

# misc
recursive
Expand All @@ -149,11 +152,13 @@ markers =
evpnVni
fs
ifCounters
igmp
interfaces
inventory
lldp
macs
mlag
mroute
network
ospf
ospfIf
Expand Down
43 changes: 43 additions & 0 deletions suzieq/cli/sqcmds/IgmpCmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from nubia import command
from suzieq.cli.nubia_patch import argument

from suzieq.cli.sqcmds.command import SqTableCommand
from suzieq.sqobjects.igmp import IgmpObj


@command("igmp", help="Act on Igmp")
@argument("vrf", description="VRF(s), space separated")
@argument("group", description="Group(s), in quotes, space separated")
class IgmpCmd(SqTableCommand):
"""IGMP table information"""

def __init__(
self,
engine: str = "",
hostname: str = "",
start_time: str = "",
end_time: str = "",
view: str = "",
namespace: str = "",
format: str = "", # pylint: disable=redefined-builtin
query_str: str = ' ',
columns: str = "default",
vrf: str = "",
group: str = "",
) -> None:
super().__init__(
engine=engine,
hostname=hostname,
start_time=start_time,
end_time=end_time,
view=view,
namespace=namespace,
columns=columns,
format=format,
query_str=query_str,
sqobj=IgmpObj,
)
self.lvars = {
'vrf': vrf.split(),
'group': group.split()
}
68 changes: 68 additions & 0 deletions suzieq/cli/sqcmds/MrouteCmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import ipaddress

from nubia import command
from suzieq.cli.nubia_patch import argument

from suzieq.cli.sqcmds.command import SqTableCommand
from suzieq.sqobjects.mroutes import MroutesObj


@command("mroute", help="Act on Mroutes")
@argument("vrf", description="VRF(s), space separated")
@argument("source", description="Source(s), in quotes, space separated")
@argument("group", description="Group(s), in quotes, space separated")
class MrouteCmd(SqTableCommand):
"""Multicast Routing table information"""

def __init__(
self,
engine: str = "",
hostname: str = "",
start_time: str = "",
end_time: str = "",
view: str = "",
namespace: str = "",
format: str = "", # pylint: disable=redefined-builtin
query_str: str = ' ',
columns: str = "default",
vrf: str = "",
source: str = '',
group: str = '',
) -> None:
super().__init__(
engine=engine,
hostname=hostname,
start_time=start_time,
end_time=end_time,
view=view,
namespace=namespace,
columns=columns,
format=format,
query_str=query_str,
sqobj=MroutesObj,
)
self.lvars = {
'vrf': vrf.split(),
'source': source.split(),
'group': group.split()
}

def _json_print_handler(self, in_data): # pylint: disable=method-hidden
"""This handler calls the code to print the IPNetwork as a string"""
if isinstance(in_data, ipaddress.IPv4Network):
return ipaddress.IPv4Network.__str__(in_data)
elif isinstance(in_data, ipaddress.IPv6Network):
return ipaddress.IPv6Network.__str__(in_data)
return in_data

def _get_ipvers(self, value: str) -> int:
"""Return the IP version in use"""

if ':' in value:
ipvers = 6
elif '.' in value:
ipvers = 4
else:
ipvers = ''

return ipvers
37 changes: 37 additions & 0 deletions suzieq/config/igmp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
service: igmp
keys:
- group
- vrf
- interface
ignore-fields:
- lastUpTime
show-fields:
- interface
- flag
- vrf

apply:
eos:
version: all
command:
- command: show ip igmp groups
normalize: 'groupList/*/[
"groupAddress: group",
"interfaceName: interface",
"uptime: lastUpTime",
"lastReporter: querier",
"flag: flag?|dynamic",
"vrf: vrf?|default"
]'
- command: show ip igmp static-groups
normalize: 'intfAddrs/*:interface/[
"groupAddrsList: group",
"flag: flag?|static",
"vrf: vrf?|default"
]'
nxos:
version: all
command: show ip igmp groups vrf all
textfsm: textfsm_templates/nxos_show_ip_igmp_groups_vrf_all.tfsm
merge: False

35 changes: 35 additions & 0 deletions suzieq/config/mroutes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
service: mroutes
keys:
- source
- group
- vrf
ignore-fields:
- statusChangeTimestamp
show-fields:
- source
- group
- rpfInterface
- oifList
- vrf
- ipvers
- rpfNeighbor
- lastUpTime


apply:
eos:
version: all
command: show ip mroute
normalize: '*:protocol/groups/*:group/groupSources/*:source/[
"creationTime: lastUpTime",
"rpfInterface: rpfInterface",
"rpf/rpfNeighbor: rpfNeighbor",
"oifList: oifList",
"vrf: vrf?|default"
]'

nxos:
version: all
command: show ip mroute vrf all
textfsm: textfsm_templates/nxos_show_ip_mroute_vrf_all.tfsm
merge: False
63 changes: 63 additions & 0 deletions suzieq/config/schema/igmp.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"namespace": "suzieq",
"name": "igmp",
"type": "record",
"fields": [
{
"name": "sqvers",
"type": "string",
"partition": 0,
"default": "2.0",
"suppress": true,
"description": "Schema version, not selectable"
},
{
"name": "group",
"type": "string",
"key": 3,
"display": 3,
"description": "The multicast group being subscribed to"
},
{
"name": "interface",
"type": "string",
"display": 4,
"description": "The interface with a subscribed to the group"
},
{
"name": "flag",
"type": "string",
"display": 5,
"description": "Whether the igmp group is dynamic or statically configured"
},
{
"name": "hostname",
"type": "string",
"key": 1,
"display": 1,
"description": "Hostname of the device that returned the data"
},
{
"name": "vrf",
"type": "string",
"key": 4,
"display": 6,
"description": "VRF that the group has joined"
},
{
"name": "namespace",
"type": "string",
"key": 0,
"display": 0,
"description": "namespace to which the data belongs"
},
{
"name": "timestamp",
"type": "timestamp"
},
{
"name": "active",
"type": "boolean"
}
]
}
87 changes: 87 additions & 0 deletions suzieq/config/schema/mroutes.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"namespace": "suzieq",
"name": "mroutes",
"type": "record",
"fields": [
{
"name": "sqvers",
"type": "string",
"partition": 0,
"default": "2.0",
"suppress": true,
"description": "Schema version, not selectable"
},
{
"name": "source",
"type": "string",
"key": 2,
"display": 2,
"description": "Source advertising a given multicast group/route"
},
{
"name": "group",
"type": "string",
"key": 3,
"display": 3,
"description": "multicast group"
},
{
"name": "hostname",
"type": "string",
"key": 1,
"display": 1,
"description": "Device the data was gathered from"
},
{
"name": "rpfInterface",
"type": "string",
"display": 4,
"description": "Reverse path forwarding interface. The interface toward the originator of the multicast traffic"
},
{
"name": "oifList",
"type": {
"type": "array",
"items": {
"name": "oif",
"type": "string"
}
},
"display": 5,
"description": "Outgoing interface list. The list of interfaces toward the multicast receivers"
},
{
"name": "vrf",
"type": "string",
"key": 3,
"display": 6,
"description": "VRF the data is from on the specific device"
},
{
"name": "ipvers",
"type": "long",
"display": 7
},
{
"name": "rpNeighbor",
"type": "string",
"display": 9,
"description": "IP of the RPF neighbor. Should be reachable via the rpfInterface"
},
{
"name": "namespace",
"type": "string",
"key": 0,
"display": 0
},
{
"name": "timestamp",
"type": "timestamp",
"display": 10
},
{
"name": "active",
"type": "boolean"
}
]
}
Loading
Loading