Skip to content

Commit

Permalink
T6335: Add/Update EVPN op commands
Browse files Browse the repository at this point in the history
Converted completion helpers from python to bash for performance

Previous commit:
Added the following commands:
show evpn
show evpn es
show evpn es <es-id>
show evpn es detail
show evpn es-evi
show evpn es-evi detail
show evpn es-evi vni <num>
show evpn vni
show evpn vni detail
show evpn vni <num>

Updated the following commands:
show evpn access-vlan
show evpn arp-cache
show evpn mac
show evpn next-hops
show evpn rmac
  • Loading branch information
l0crian1 committed May 16, 2024
1 parent c6be441 commit 3917e3e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 32 deletions.
2 changes: 1 addition & 1 deletion op-mode-definitions/include/vni-tagnode-all.xml.i
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<help>VXLAN network identifier (VNI) number</help>
<completionHelp>
<list>&lt;1-16777215&gt; all</list>
<script>${vyos_completion_dir}/list_vni.py</script>
<script>${vyos_completion_dir}/list_vni.sh</script>
</completionHelp>
</properties>
<command>${vyos_op_scripts_dir}/evpn.py show_evpn --command "$*"</command>
Expand Down
2 changes: 1 addition & 1 deletion op-mode-definitions/include/vni-tagnode.xml.i
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<help>VXLAN network identifier (VNI) number</help>
<completionHelp>
<list>&lt;1-16777215&gt;</list>
<script>${vyos_completion_dir}/list_vni.py</script>
<script>${vyos_completion_dir}/list_vni.sh</script>
</completionHelp>
</properties>
<command>${vyos_op_scripts_dir}/evpn.py show_evpn --command "$*"</command>
Expand Down
2 changes: 1 addition & 1 deletion op-mode-definitions/show-evpn.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<help>Show ESI information for specified ESI</help>
<completionHelp>
<list>&lt;esi&gt;</list>
<script>${vyos_completion_dir}/list_esi.py</script>
<script>${vyos_completion_dir}/list_esi.sh</script>
</completionHelp>
</properties>
<command>${vyos_op_scripts_dir}/evpn.py show_evpn --command "$*"</command>
Expand Down
23 changes: 6 additions & 17 deletions src/completion/list_esi.py → src/completion/list_esi.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
#!/usr/bin/env python3
#!/bin/bash
#
# Copyright (C) 2016-2024 VyOS maintainers and contributors
# Copyright (C) 2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This script is completion helper to list all configured VNIs that are visible to FRR
# This script is completion helper to list all valid ESEs that are visible to FRR

import json
from vyos.utils.process import cmd

def get_esi():
esiDict = json.loads(cmd(f"vtysh -c 'show evpn es json'"))
esiList = []
for i in esiDict:
esiList.append(i['esi'])

print(' '.join(esiList))

if __name__ == '__main__':
get_esi()
esiJson=$(vtysh -c 'show evpn es json')
echo "$(echo "$esiJson" | jq -r '.[] | .esi')"
17 changes: 5 additions & 12 deletions src/completion/list_vni.py → src/completion/list_vni.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
#!/usr/bin/env python3
#!/bin/bash
#
# Copyright (C) 2016-2024 VyOS maintainers and contributors
# Copyright (C) 2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This script is completion helper to list all configured VNIs that are visible to FRR

import json
from vyos.utils.process import cmd

def get_vni():
vniDict = json.loads(cmd(f"vtysh -c 'show evpn vni json'"))
print(' '.join(vniDict.keys()))

if __name__ == '__main__':
get_vni()
vniJson=$(vtysh -c 'show evpn vni json')
echo "$(echo "$vniJson" | jq -r 'keys | .[]')"

0 comments on commit 3917e3e

Please sign in to comment.