Skip to content

Commit

Permalink
T4583: Rewrite VRRP op-mode to vyos.opmode format
Browse files Browse the repository at this point in the history
  • Loading branch information
HollyGurza committed Oct 17, 2024
1 parent e5d2ac5 commit 893a0eb
Show file tree
Hide file tree
Showing 3 changed files with 330 additions and 46 deletions.
25 changes: 22 additions & 3 deletions op-mode-definitions/vrrp.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,42 @@
<interfaceDefinition>
<node name="show">
<children>
<tagNode name="vrrp">
<properties>
<help>Show specified VRRP (Virtual Router Redundancy Protocol) group information</help>
</properties>
<children>
<node name="statistics">
<properties>
<help>Show VRRP statistics</help>
</properties>
<command>sudo ${vyos_op_scripts_dir}/vrrp.py show_statistics --group-name="$3"</command>
</node>
<node name="detail">
<properties>
<help>Show detailed VRRP state information</help>
</properties>
<command>sudo ${vyos_op_scripts_dir}/vrrp.py show_detail --group-name="$3"</command>
</node>
</children>
</tagNode>
<node name="vrrp">
<properties>
<help>Show VRRP (Virtual Router Redundancy Protocol) information</help>
</properties>
<command>sudo ${vyos_op_scripts_dir}/vrrp.py --summary</command>
<command>sudo ${vyos_op_scripts_dir}/vrrp.py show_summary</command>
<children>
<node name="statistics">
<properties>
<help>Show VRRP statistics</help>
</properties>
<command>sudo ${vyos_op_scripts_dir}/vrrp.py --statistics</command>
<command>sudo ${vyos_op_scripts_dir}/vrrp.py show_statistics</command>
</node>
<node name="detail">
<properties>
<help>Show detailed VRRP state information</help>
</properties>
<command>sudo ${vyos_op_scripts_dir}/vrrp.py --data</command>
<command>sudo ${vyos_op_scripts_dir}/vrrp.py show_detail</command>
</node>
</children>
</node>
Expand Down
8 changes: 4 additions & 4 deletions python/vyos/ifconfig/vrrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ def collect(cls, what):
timeout=30)

return read_file(fname)
except OSError:
# raised by vyos.utils.file.read_file
raise VRRPNoData("VRRP data is not available (wait time exceeded)")
except FileNotFoundError:
raise VRRPNoData("VRRP data is not available (process not running or no active groups)")
except OSError:
# raised by vyos.utils.file.read_file
raise VRRPNoData(f"VRRP data is not available (wait time exceeded)")
except Exception:
name = cls._name[what]
raise VRRPError(f'VRRP {name} is not available')
Expand Down Expand Up @@ -136,7 +136,7 @@ def format(cls, data):
headers = ["Name", "Interface", "VRID", "State", "Priority", "Last Transition"]
groups = []

data = json.loads(data)
data = json.loads(data) if isinstance(data, str) else data
for group in data:
data = group['data']

Expand Down
Loading

0 comments on commit 893a0eb

Please sign in to comment.