Skip to content

Commit

Permalink
Dev: ui_corosync: add subcommand 'crm corosync link add' (jsc#PED-8083)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasyang2022 committed Jun 26, 2024
1 parent 5170931 commit 3906984
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions crmsh/ui_corosync.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,30 @@ def do_update(self, context, *argv):
logger.info("Use \"crm corosync diff\" to show the difference")
logger.info("Use \"crm corosync push\" to sync")

def do_add(self, context, *argv):
lm = corosync.LinkManager.load_config_file()
if lm.totem_transport() != 'knet':
logger.error('Corosync is not using knet transport')
return False
try:
args = LinkArgumentParser().parse(argv)
except LinkArgumentParser.SyntaxException as e:
logger.error('%s', str(e))
print('Usage: link add <linknumber> <node>=<addr> ... [options <option>=<value> ...] ', file=sys.stderr)
return False
nodes = lm.links()[args.linknumber].nodes
node_addresses: dict[int, str] = dict()
for name, addr in args.nodes:
nodeid = next((x.nodeid for x in nodes if x.name == name), -1)
if nodeid == -1:
logger.error(f'Unknown node {name}.')
node_addresses[nodeid] = addr
lm.write_config_file(
lm.add_link(node_addresses, args.options)
)
logger.info("Use \"crm corosync diff\" to show the difference")
logger.info("Use \"crm corosync push\" to sync")

def do_remove(self, context, linknumber: str):
if not linknumber.isdecimal():
raise ValueError(f'Invalid linknumber: {linknumber}')
Expand Down

0 comments on commit 3906984

Please sign in to comment.