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

Add "production" boolean to resources in namespaces JSON (SOFTWARE-5862) #3900

Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ Each cache in the list contains the following attributes:
- `endpoint`: The `<HOST>:<PORT>` of the public (`xrootd@stash-cache`) service
- `auth_endpoint`: The `<HOST>:<PORT>` of the authenticated (`xrootd@stash-cache-auth`) service
- `resource`: The resource name of the cache.
- `production`: true if the resource is in "production" (as opposed to ITB)

The JSON also contains an attribute `namespaces` that is a list of namespaces with the following attributes:
- `path` is the path of the namespace
Expand Down Expand Up @@ -553,11 +554,13 @@ The final result looks like
{
"auth_endpoint": "osg-gftp.pace.gatech.edu:8443",
"endpoint": "osg-gftp.pace.gatech.edu:8000",
"production": true,
"resource": "Georgia_Tech_PACE_GridFTP"
},
{
"auth_endpoint": "osg-gftp2.pace.gatech.edu:8443",
"endpoint": "osg-gftp2.pace.gatech.edu:8000",
"production": true,
"resource": "Georgia_Tech_PACE_GridFTP2"
}
],
Expand All @@ -567,6 +570,7 @@ The final result looks like
{
"auth_endpoint": "rds-cache.sdsc.edu:8443",
"endpoint": "rds-cache.sdsc.edu:8000",
"production": true,
"resource": "RDS_AUTH_OSDF_CACHE"
}
],
Expand Down
12 changes: 11 additions & 1 deletion src/stashcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,17 @@ def _service_resource_dict(
if not is_null(svc, "Details", "auth_endpoint_override"):
auth_endpoint = svc["Details"]["auth_endpoint_override"]
break
return {"endpoint": endpoint, "auth_endpoint": auth_endpoint, "resource": r.name}
production = None
try:
production = bool(r.rg.production)
except AttributeError:
pass
return {
"endpoint": endpoint,
"auth_endpoint": auth_endpoint,
"resource": r.name,
"production": production,
}

def _cache_resource_dict(r: Resource):
return _service_resource_dict(r=r, service_name=XROOTD_CACHE_SERVER, auth_port_default=8443, unauth_port_default=8000)
Expand Down
11 changes: 6 additions & 5 deletions src/webapp/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def is_ccstar(self):
return self._is_ccstar

class Resource(object):
def __init__(self, name: str, yaml_data: ParsedYaml, common_data: CommonData):
def __init__(self, name: str, yaml_data: ParsedYaml, common_data: CommonData, rg: "ResourceGroup"):
self.name = name
self.service_types = common_data.service_types
self.common_data = common_data
Expand All @@ -124,6 +124,7 @@ def __init__(self, name: str, yaml_data: ParsedYaml, common_data: CommonData):
raise ValueError(f"Resource {name} does not have an FQDN")
self.fqdn = self.data["FQDN"]
self.id = self.data["ID"]
self.rg = rg

def get_stashcache_files(self, global_data, legacy):
"""Gets a resources Cache files as a dictionary"""
Expand Down Expand Up @@ -378,14 +379,14 @@ def __init__(self, name: str, yaml_data: ParsedYaml, site: Site, common_data: Co
self.support_center = OrderedDict([("ID", scid), ("Name", scname)])

self.resources_by_name = {}
for name, res in yaml_data["Resources"].items():
for res_name, res in yaml_data["Resources"].items():
try:
if not isinstance(res, dict):
raise TypeError("expecting a dict")
res_obj = Resource(name, ParsedYaml(res), self.common_data)
self.resources_by_name[name] = res_obj
res_obj = Resource(res_name, ParsedYaml(res), self.common_data, rg=self)
self.resources_by_name[res_name] = res_obj
except (AttributeError, KeyError, TypeError, ValueError) as err:
log.exception("Error with resource %s: %r", name, err)
log.exception("Error with resource %s: %r", res_name, err)
continue

self.data = yaml_data
Expand Down
Loading