forked from ClusterLabs/crmsh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev: ui_corosync: add subcommand 'crm corosync link show' (jsc#PED-8083)
- Loading branch information
1 parent
5d00733
commit c605aa1
Showing
1 changed file
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Copyright (C) 2013 Kristoffer Gronlund <[email protected]> | ||
# See COPYING for license information. | ||
|
||
import dataclasses | ||
import os | ||
from . import command, sh | ||
from . import completers | ||
|
@@ -47,6 +47,34 @@ def _diff_nodes(args): | |
return [] | ||
|
||
|
||
class Link(command.UI): | ||
"""This level provides subcommands for managing knet links.""" | ||
|
||
name = 'link' | ||
|
||
def do_show(self, context): | ||
""" | ||
Show link configurations. | ||
""" | ||
lm = corosync.LinkManager.load_config_file() | ||
if lm.totem_transport() != 'knet': | ||
logger.error('Corosync is not using knet transport') | ||
return False | ||
for link in lm.links(): | ||
print(f'Link {link.linknumber}:\n Options:') | ||
for name, value in dataclasses.asdict(link).items(): | ||
if name == 'linknumber' or name == 'nodes': | ||
continue | ||
if value is None: | ||
continue | ||
print(f' {name}:\t{value}') | ||
print('\n Node addresses:') | ||
for node in link.nodes: | ||
print(f' Node {node.nodeid}: {node.name}\t{node.addr}') | ||
print('') | ||
# TODO: show link status | ||
|
||
|
||
class Corosync(command.UI): | ||
''' | ||
Corosync is the underlying messaging layer for most HA clusters. | ||
|
@@ -158,3 +186,10 @@ def do_get(self, context, path): | |
def do_set(self, context, path, value, index: int = 0): | ||
"""Set a corosync configuration value""" | ||
corosync.set_value(path, value, index) | ||
|
||
@command.level(Link) | ||
@command.help('''Knet link management | ||
Knet is a multi-link and multi-protocol transport used by corosync. | ||
This level provides subcommands for managing these links.''') | ||
def do_link(self): | ||
pass |