Skip to content

Commit

Permalink
Dev: ui_corosync: add subcommand 'crm corosync link show' (jsc#PED-8083)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasyang2022 committed Jun 21, 2024
1 parent 5d00733 commit c605aa1
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion crmsh/ui_corosync.py
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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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

0 comments on commit c605aa1

Please sign in to comment.