def getPropValueMap(): """ Return all possible values for some assignment arguments """ prop_value_map = {'CMSSWVersion': releases(), 'SiteWhitelist': SITE_CACHE.getData(), 'SiteBlacklist': SITE_CACHE.getData(), 'SubscriptionPriority': ['Low', 'Normal', 'High'], 'CustodialSites': PNN_CACHE.getData(), 'CustodialSubType': ['Move', 'Replica'], 'NonCustodialSites': PNN_CACHE.getData(), 'NonCustodialSubType': ['Move', 'Replica'], 'AutoApproveSubscriptionSites': PNN_CACHE.getData(), 'MergedLFNBase': lfn_bases(), 'UnmergedLFNBase': lfn_unmerged_bases(), 'TrustPUSitelists': [True, False], 'TrustSitelists': [True, False], 'Dashboard': dashboardActivities()} return prop_value_map
def fetch(self, rid): "Fetch document for given id" rid = rid.replace('request-', '') doc = self.reqmgr.getRequestByNames(rid) transitions = [] tst = time.time() # get request tasks tasks = self.reqmgr.getRequestTasks(rid) if len(doc) == 1: try: doc = doc[rid] except: pass name = doc.get('RequestName', 'NA') title = 'Request %s' % name status = doc.get('RequestStatus', '') transitions = REQUEST_STATE_TRANSITION.get(status, []) if status in transitions: transitions.remove(status) visible_attrs = get_modifiable_properties(status) filterout_attrs = get_protected_properties() #extend filterout list with "RequestStatus" since it is passed separately filterout_attrs.append("RequestStatus") if visible_attrs == "all_attributes": filteredDoc = doc for prop in filterout_attrs: if prop in filteredDoc: del filteredDoc[prop] else: filteredDoc = {} for prop in visible_attrs: filteredDoc[prop] = doc.get(prop, "") listPNNs = PNN_CACHE.getData() prop_value_map = { 'CMSSWVersion': releases(), 'SiteWhitelist': SITE_CACHE.getData(), 'SiteBlacklist': SITE_CACHE.getData(), 'SubscriptionPriority': ['Low', 'Normal', 'High'], 'CustodialSites': listPNNs, 'CustodialSubType': ['Move', 'Replica'], 'NonCustodialSites': listPNNs, 'NonCustodialSubType': ['Move', 'Replica'], 'AutoApproveSubscriptionSites': listPNNs, 'MergedLFNBase': lfn_bases(), 'UnmergedLFNBase': lfn_unmerged_bases(), 'TrustPUSitelists': [True, False], 'TrustSitelists': [True, False], 'Dashboard': dashboardActivities(), 'Team': self.getTeams() } selected = {} for prop in prop_value_map: if prop in filteredDoc: filteredDoc[prop], selected[prop] = reorder_list( prop_value_map[prop], filteredDoc[prop]) content = self.templatepage( 'doc', title=title, status=status, name=name, rid=rid, tasks=json2form(tasks, indent=2, keep_first_value=False), table=json2table(filteredDoc, web_ui_names(), visible_attrs, selected), jsondata=json2form(doc, indent=2, keep_first_value=False), doc=json.dumps(doc), time=time, transitions=transitions, ts=tst, user=user(), userdn=user_dn()) elif len(doc) > 1: jsondata = [pprint.pformat(d) for d in doc] content = self.templatepage('doc', title='Series of docs: %s' % rid, table="", jsondata=jsondata, time=time, transitions=transitions, ts=tst, user=user(), userdn=user_dn()) else: doc = 'No request found for name=%s' % rid return self.abs_page('request', content)
def fetch(self, rid): "Fetch document for given id" rid = rid.replace('request-', '') doc = self.reqmgr.getRequestByNames(rid) transitions = [] tst = time.time() # get request tasks tasks = self.reqmgr.getRequestTasks(rid) if len(doc) == 1: try: doc = doc[rid] except: pass name = doc.get('RequestName', 'NA') title = 'Request %s' % name status = doc.get('RequestStatus', '') transitions = REQUEST_STATE_TRANSITION.get(status, []) if status in transitions: transitions.remove(status) visible_attrs = get_modifiable_properties(status) filterout_attrs = get_protected_properties() #extend filterout list with "RequestStatus" since it is passed separately filterout_attrs.append("RequestStatus") if visible_attrs == "all_attributes": filteredDoc = doc for prop in filterout_attrs: if prop in filteredDoc: del filteredDoc[prop] else: filteredDoc = {} for prop in visible_attrs: filteredDoc[prop] = doc.get(prop, "") listPNNs = PNN_CACHE.getData() prop_value_map = {'CMSSWVersion': releases(), 'SiteWhitelist': SITE_CACHE.getData(), 'SiteBlacklist': SITE_CACHE.getData(), 'SubscriptionPriority': ['Low', 'Normal', 'High'], 'CustodialSites': listPNNs, 'CustodialSubType': ['Move', 'Replica'], 'NonCustodialSites': listPNNs, 'NonCustodialSubType': ['Move', 'Replica'], 'AutoApproveSubscriptionSites': listPNNs, 'MergedLFNBase': lfn_bases(), 'UnmergedLFNBase': lfn_unmerged_bases(), 'TrustPUSitelists': [True, False], 'TrustSitelists': [True, False], 'Dashboard': dashboardActivities(), 'Team': self.getTeams()} selected = {} for prop in prop_value_map: if prop in filteredDoc: filteredDoc[prop], selected[prop] = reorder_list(prop_value_map[prop], filteredDoc[prop]) content = self.templatepage('doc', title=title, status=status, name=name, rid=rid, tasks=json2form(tasks, indent=2, keep_first_value=False), table=json2table(filteredDoc, web_ui_names(), visible_attrs, selected), jsondata=json2form(doc, indent=2, keep_first_value=False), doc=json.dumps(doc), time=time, transitions=transitions, ts=tst, user=user(), userdn=user_dn()) elif len(doc) > 1: jsondata = [pprint.pformat(d) for d in doc] content = self.templatepage('doc', title='Series of docs: %s' % rid, table="", jsondata=jsondata, time=time, transitions=transitions, ts=tst, user=user(), userdn=user_dn()) else: doc = 'No request found for name=%s' % rid return self.abs_page('request', content)