Skip to content

Commit

Permalink
Merge pull request #57 from lukemartinlogan/master
Browse files Browse the repository at this point in the history
Updates to chi-net-ping
  • Loading branch information
lukemartinlogan authored Feb 12, 2025
2 parents ba771cd + 0d692e4 commit ae799eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 10 additions & 8 deletions jarvis_util/introspect/system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,16 @@ class ChiNetPing(Exec):
"""
Determine whether a network functions across a set of hosts
"""
def __init__(self, provider, domain, port, mode, exec_info):
def __init__(self, provider, domain, port, mode, local_only, exec_info):
hostfile = exec_info.hostfile.path if exec_info.hostfile.path else '\"\"'
self.cmd = [
'chi_net_ping',
exec_info.hostfile.path if exec_info.hostfile.path else '\"\"',
hostfile,
provider,
domain,
str(port),
mode
mode,
local_only
]
self.cmd = ' '.join(self.cmd)
if mode == 'server':
Expand All @@ -381,10 +383,10 @@ class ChiNetPingTest:
"""
Determine whether a network functions across a set of hosts
"""
def __init__(self, provider, domain, port, exec_info, net_sleep=10):
self.server = ChiNetPing(provider, domain, port, "server", exec_info.mod(exec_async=True))
def __init__(self, provider, domain, port, local_only, exec_info, net_sleep=10):
self.server = ChiNetPing(provider, domain, port, "server", local_only, exec_info.mod(exec_async=True))
time.sleep(net_sleep)
self.client = ChiNetPing(provider, domain, port, "client", exec_info)
self.client = ChiNetPing(provider, domain, port, "client", local_only, exec_info)
self.exit_code = self.client.exit_code
# Kill('chi_net_ping', exec_info)

Expand Down Expand Up @@ -427,14 +429,14 @@ def _async_test(self, idx, net, port, exec_info, net_sleep):
domain = net['domain']
fabric = net['fabric']
# Test if the network works locally
ping = ChiNetPingTest(provider, domain, port, exec_info.mod(hostfile=None), 2)
ping = ChiNetPingTest(provider, domain, port, "local", exec_info, 2)
net['shared'] = False
if ping.exit_code != 0:
print(f'Testing the network {provider}://{domain}/[{fabric}]:{port}: FAILED {ping.exit_code}')
return
self.results[idx] = net
# Test if the network works across hosts
ping = ChiNetPingTest(provider, domain, port, exec_info, net_sleep)
ping = ChiNetPingTest(provider, domain, port, "all", exec_info, net_sleep)
if ping.exit_code == 0:
net['shared'] = True
print(f'Testing the network {provider}://{domain}/[{fabric}]:{port}: SUCCESS')
Expand Down
4 changes: 4 additions & 0 deletions jarvis_util/util/hostfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, hostfile=None, all_hosts=None, all_hosts_ip=None,

# From hostfile path
elif hostfile is not None:
self.path = os.path.abspath(hostfile)
self._load_hostfile(self.path)

# From hostfile text
Expand Down Expand Up @@ -80,6 +81,9 @@ def parse(self, text):
lines = text.strip().splitlines()
hosts = []
for line in lines:
line = line.strip()
if len(line) == 0 or line[0] == '#':
continue
self._expand_line(hosts, line)
self._set_hosts(hosts)

Expand Down

0 comments on commit ae799eb

Please sign in to comment.