Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the list_hosts to return the online hosts #104

Merged
merged 5 commits into from
May 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion nebula2/mclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
)
from nebula2.common.ttypes import HostAddr, ErrorCode
from nebula2.meta.ttypes import (
HostStatus,
ListTagsReq,
ListEdgesReq,
ListSpacesReq,
Expand Down Expand Up @@ -139,7 +140,11 @@ def list_hosts(self):
continue
raise RuntimeError("List spaces failed, error code: {}"
.format(ErrorCode._VALUES_TO_NAMES.get(resp.code)))
return resp.hosts
valid_hosts = []
for host in resp.hosts:
if host.status == HostStatus.ONLINE:
valid_hosts.append(host)
return valid_hosts
raise RuntimeError("List spaces failed, error code: {}"
.format(ErrorCode._VALUES_TO_NAMES.get(resp.code)))

Expand Down