diff --git a/src/app.py b/src/app.py index 9104e29ba..aa746cf40 100755 --- a/src/app.py +++ b/src/app.py @@ -167,13 +167,13 @@ def homepage(): @app.route('/map/iframe') def map(): - rgsummary = global_data.get_topology().get_resource_summary(contacts=None) + rgsummary = global_data.get_topology().get_resource_summary(contacts_data=None) return _fix_unicode(render_template('iframe.html.j2', resourcegroups=rgsummary["ResourceSummary"]["ResourceGroup"])) @app.route('/api/resource_group_summary') def resource_summary(): - data = global_data.get_topology().get_resource_summary(contacts=None)["ResourceSummary"]["ResourceGroup"] + data = global_data.get_topology().get_resource_summary(contacts_data=None)["ResourceSummary"]["ResourceGroup"] return Response( to_json_bytes(simplify_attr_list(data, namekey='GroupName', del_name=False)), @@ -358,7 +358,7 @@ def miscresource_json(): "Site": rg.site.name, "Facility": rg.site.facility.name, "ResourceGroup": rg.name, - **resource.get_tree(contacts=contacts_) + **resource.get_tree(contacts_data=contacts_) } return Response(to_json_bytes(resources), mimetype='application/json') @@ -1098,13 +1098,13 @@ def filter_value(filter_key): return filters -def _get_xml_or_fail(getter_function, contacts_, args): +def _get_xml_or_fail(getter_function, contacts_data, args): try: filters = get_filters_from_args(args) except InvalidArgumentsError as e: return Response("Invalid arguments: " + str(e), status=400) return Response( - to_xml_bytes(getter_function(contacts_, _get_authorized(), filters)), + to_xml_bytes(getter_function(contacts_data, _get_authorized(), filters)), mimetype="text/xml" ) diff --git a/src/webapp/rg_reader.py b/src/webapp/rg_reader.py index 75fe6fe14..a70bab74a 100755 --- a/src/webapp/rg_reader.py +++ b/src/webapp/rg_reader.py @@ -56,8 +56,8 @@ def get_rgsummary_rgdowntime(indir, contacts_file=None, authorized=False, strict topology = get_topology(indir, strict=strict) filters = Filters() filters.past_days = -1 - return topology.get_resource_summary(contacts=contacts_data, authorized=authorized, filters=filters), \ - topology.get_downtimes(contacts=contacts_data, authorized=authorized, filters=filters) + return topology.get_resource_summary(contacts_data=contacts_data, authorized=authorized, filters=filters), \ + topology.get_downtimes(contacts_data=contacts_data, authorized=authorized, filters=filters) def get_topology(indir="../topology", strict=False): diff --git a/src/webapp/topology.py b/src/webapp/topology.py index b0eb066d3..a063ad0e3 100644 --- a/src/webapp/topology.py +++ b/src/webapp/topology.py @@ -201,7 +201,7 @@ def get_stashcache_files(self, global_data, legacy): return stashcache_files - def get_tree(self, contacts: Optional[ContactsData], authorized=False, filters: Filters = None) -> Optional[OrderedDict]: + def get_tree(self, contacts_data: Optional[ContactsData], authorized=False, filters: Filters = None) -> Optional[OrderedDict]: if filters is None: filters = Filters() @@ -246,7 +246,7 @@ def get_tree(self, contacts: Optional[ContactsData], authorized=False, filters: if "FQDNAliases" in self.data: new_res["FQDNAliases"] = {"FQDNAlias": self.data["FQDNAliases"]} if not is_null(self.data, "ContactLists"): - new_res["ContactLists"] = self._expand_contactlists(self.data["ContactLists"], authorized, contacts=contacts) + new_res["ContactLists"] = self._expand_contactlists(self.data["ContactLists"], authorized, contacts_data=contacts_data) new_res["Name"] = self.name if "WLCGInformation" in self.data and isinstance(self.data["WLCGInformation"], dict): new_res["WLCGInformation"] = self._expand_wlcginformation(self.data["WLCGInformation"]) @@ -324,15 +324,15 @@ def _get_charturl(ownership): ("ChartURL", _get_charturl(voownership.items())) ]) - def _expand_contactlists(self, contactlists: Dict, authorized: bool, contacts: Optional[ContactsData]) -> Dict: + def _expand_contactlists(self, contactlists: Dict, authorized: bool, contacts_data: Optional[ContactsData]) -> Dict: """Return the data structure for an expanded ContactLists for a single Resource.""" new_contactlists = [] - for contact_type, contact_data in contactlists.items(): - contact_data = expand_attr_list(contact_data, "ContactRank", ["Name", "ID", "ContactRank"], ignore_missing=True) - for contact in contact_data: + for contact_type, contact_info in contactlists.items(): + contact_info = expand_attr_list(contact_info, "ContactRank", ["Name", "ID", "ContactRank"], ignore_missing=True) + for contact in contact_info: contact_id = contact.pop("ID", None) # ID is for internal use - don't put it in the results - if contacts and contact_id in contacts.users_by_id: - user = contacts.users_by_id[contact_id] # type: User + if contacts_data and contact_id in contacts_data.users_by_id: + user = contacts_data.users_by_id[contact_id] # type: User contact["CILogonID"] = user.cilogon_id if authorized: contact["Email"] = user.email @@ -343,7 +343,7 @@ def _expand_contactlists(self, contactlists: Dict, authorized: bool, contacts: O contact["DN"] = dns[0] contact.move_to_end("ContactRank", last=True) new_contactlists.append( - OrderedDict([("ContactType", contact_type), ("Contacts", {"Contact": contact_data})])) + OrderedDict([("ContactType", contact_type), ("Contacts", {"Contact": contact_info})])) return {"ContactList": new_contactlists} @staticmethod @@ -396,7 +396,7 @@ def resources(self): def itb(self): return not self.production - def get_tree(self, contacts: Optional[ContactsData], authorized=False, filters: Filters = None) -> Optional[OrderedDict]: + def get_tree(self, contacts_data: Optional[ContactsData], authorized=False, filters: Filters = None) -> Optional[OrderedDict]: if filters is None: filters = Filters() for filter_list, attribute in [(filters.facility_id, self.site.facility.id), @@ -412,7 +412,7 @@ def get_tree(self, contacts: Optional[ContactsData], authorized=False, filters: filtered_resources = [] for res in self.resources: try: - tree = res.get_tree(contacts, authorized, filters) + tree = res.get_tree(contacts_data, authorized, filters) if tree: filtered_resources.append(tree) except (AttributeError, KeyError, ValueError) as err: @@ -690,14 +690,14 @@ def get_resource_group_list(self): """ return self.rgs.values() - def get_resource_summary(self, contacts: Optional[ContactsData], authorized=False, filters: Filters = None) -> Dict: + def get_resource_summary(self, contacts_data: Optional[ContactsData], authorized=False, filters: Filters = None) -> Dict: if filters is None: filters = Filters() rglist = [] for rgkey in sorted(self.rgs.keys(), key=lambda x: x[1].lower()): rgval = self.rgs[rgkey] assert isinstance(rgval, ResourceGroup) - rgtree = rgval.get_tree(contacts, authorized, filters) + rgtree = rgval.get_tree(contacts_data, authorized, filters) if rgtree: rglist.append(rgtree) return {"ResourceSummary": @@ -705,9 +705,9 @@ def get_resource_summary(self, contacts: Optional[ContactsData], authorized=Fals "@xsi:schemaLocation": RGSUMMARY_SCHEMA_URL, "ResourceGroup": rglist}} - def get_downtimes(self, contacts: Optional[ContactsData], authorized=False, filters: Filters = None) -> Dict: + def get_downtimes(self, contacts_data: Optional[ContactsData], authorized=False, filters: Filters = None) -> Dict: _ = authorized - _ = contacts + _ = contacts_data if filters is None: filters = Filters() diff --git a/src/webapp/vo_reader.py b/src/webapp/vo_reader.py index 5c536d8cf..e1040cc3e 100755 --- a/src/webapp/vo_reader.py +++ b/src/webapp/vo_reader.py @@ -59,7 +59,7 @@ def main(argv): if args.contacts: contacts_data = get_contacts_data(args.contacts) xml = to_xml( - get_vos_data(args.indir, strict=args.strict).get_tree(contacts=contacts_data, authorized=True)) + get_vos_data(args.indir, strict=args.strict).get_tree(contacts_data=contacts_data, authorized=True)) if args.outfile: with open(args.outfile, "w") as fh: fh.write(xml) diff --git a/src/webapp/vos_data.py b/src/webapp/vos_data.py index c9afd3a9b..3708c8642 100644 --- a/src/webapp/vos_data.py +++ b/src/webapp/vos_data.py @@ -65,13 +65,13 @@ def get_expansion(self, contacts_data: Optional[ContactsData], authorized=False, return expanded_vo_list - def get_tree(self, contacts: Optional[ContactsData], authorized=False, filters: Filters = None) -> Dict: + def get_tree(self, contacts_data: Optional[ContactsData], authorized=False, filters: Filters = None) -> Dict: if not filters: filters = Filters() expanded_vo_list = [] for vo_name in sorted(self.vos.keys(), key=lambda x: x.lower()): try: - expanded_vo_data = self._expand_vo(vo_name, contacts_data=contacts, authorized=authorized, + expanded_vo_data = self._expand_vo(vo_name, contacts_data=contacts_data, authorized=authorized, filters=filters) if expanded_vo_data: if 'DataFederations' in expanded_vo_data: