-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #RHIROS-1269 - feature flags for backend
- Loading branch information
1 parent
052f950
commit 1d6405c
Showing
9 changed files
with
398 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
from ros.lib.models import System | ||
from flask import request | ||
from ros.lib.feature_flags import FLAG_INVENTORY_GROUPS, get_flag_value | ||
from ros.lib.config import get_logger | ||
|
||
logger = get_logger(__name__) | ||
|
||
|
||
def group_filtered_query(query): | ||
if hasattr(request, "host_groups"): | ||
host_groups = [gid for gid in request.host_groups if gid is not None] | ||
if len(host_groups) >= 1: | ||
query = query.filter(System.groups[0]['id'].astext.in_(host_groups) | (System.groups == '[]')) | ||
if get_flag_value(FLAG_INVENTORY_GROUPS): | ||
if len(get_host_groups()) >= 1: | ||
query = query.filter(System.groups[0]['id'].astext.in_(get_host_groups()) | (System.groups == '[]')) | ||
else: | ||
query = query.filter((System.groups == '[]')) | ||
return query | ||
|
||
|
||
def get_host_groups(): | ||
host_groups = [] | ||
try: | ||
host_groups = [gid for gid in request.host_groups if gid is not None] | ||
except AttributeError as e: | ||
logger.debug(f"Can't parse the host groups, inventory groups feature is not available?: {e}") | ||
return host_groups |
Oops, something went wrong.