Skip to content

Commit

Permalink
feat: cloud-only now supports filtering hosts
Browse files Browse the repository at this point in the history
closes: #400

Change-Id: I008e23808d2fe5a76569bb9247e60e6f474186cb
  • Loading branch information
dominikvagner authored and grafuls committed Oct 14, 2022
1 parent 90b5782 commit 11a264f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,12 @@ quads-cli --ls-available --schedule-start "2020-08-02 22:00" --schedule-end "202
quads-cli --ls-hosts --filter "retired==True"
```

* Listing specific hosts from a certain cloud:

```
quads-cli --cloud-only cloud13 --filter "model==FC640"
```

#### Find Available Web Preview

* We now have a Flask-based `--ls-available` web interface available on `quadshost:5001` if your firewall rules are open for `TCP/5001`.
Expand Down
24 changes: 21 additions & 3 deletions quads/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1619,8 +1619,14 @@ def action_cloudonly(self):
).isoformat()
schedules = Schedule.current_schedule(**_kwargs)
if schedules:
_kwargs = {}
if self.cli_args["filter"]:
filter_args = self._filter_kwargs(self.cli_args["filter"])
_kwargs.update(filter_args)
_hosts = Host.objects(**_kwargs).all()
for schedule in sorted(schedules, key=lambda k: k["host"]["name"]):
self.logger.info(schedule.host.name)
if schedule.host in _hosts:
self.logger.info(schedule.host.name)
else:
if _kwargs.get("date") and self.cli_args["cloudonly"] == "cloud01":
data = {
Expand All @@ -1635,10 +1641,22 @@ def action_cloudonly(self):
"Could not connect to the quads-server, verify service is up and running."
)

_kwargs = {}
if self.cli_args["filter"]:
filter_args = self._filter_kwargs(self.cli_args["filter"])
_kwargs.update(filter_args)
_hosts = []
for host in sorted(Host.objects(**_kwargs).all(), key=lambda k: k["name"]):
_hosts.append(host.name)
for host in sorted(available_hosts):
self.logger.info(host)
if host in _hosts:
self.logger.info(host)
else:
_hosts = Host.objects(cloud=_cloud)
_kwargs = {"cloud": _cloud}
if self.cli_args["filter"]:
filter_args = self._filter_kwargs(self.cli_args["filter"])
_kwargs.update(filter_args)
_hosts = Host.objects(**_kwargs).all()
for host in sorted(_hosts, key=lambda k: k["name"]):
self.logger.info(host.name)

Expand Down

0 comments on commit 11a264f

Please sign in to comment.