def resconf_keywords(configuration, output_objects): """All resource configuration keywords""" resource_keywords = \ resconfkeywords.get_resource_keywords(configuration) exenode_keywords = \ resconfkeywords.get_exenode_keywords(configuration) storenode_keywords = \ resconfkeywords.get_storenode_keywords(configuration) topics = [('Resource configuration', resource_keywords), ('Execution node configuration', exenode_keywords), ('Storage node configuration', storenode_keywords)] for (title, keywords_dict) in topics: output_objects.append({'object_type': 'header', 'text': title}) sorted_keys = keywords_dict.keys() sorted_keys.sort() for keyword in sorted_keys: info = keywords_dict[keyword] output_objects.append({ 'object_type': 'sectionheader', 'text': keyword }) entries = [] for (field, val) in info.items(): entries.append(field + ': ' + str(val)) output_objects.append({'object_type': 'list', 'list': entries})
def build_resitem_object_from_res_dict(configuration, unique_resource_name, res_dict, vgrid_access): """Build a resource object based on input res_dict""" res_keywords = get_resource_keywords(configuration) exe_keywords = get_exenode_keywords(configuration) store_keywords = get_storenode_keywords(configuration) res_fields = ['PUBLICNAME', 'PUBLICINFO', 'CPUCOUNT', 'NODECOUNT', 'MEMORY', 'DISK', 'ARCHITECTURE', 'JOBTYPE', 'MAXUPLOADBANDWIDTH', 'MAXDOWNLOADBANDWIDTH', 'SANDBOX'] exe_fields = ['cputime', 'nodecount'] store_fields = ['storage_disk', 'storage_protocol'] res_item = { 'object_type': 'resource_info', 'unique_resource_name': unique_resource_name, 'fields': [], 'exes': {}, 'stores': {}, } for name in res_fields: res_item['fields'].append((res_keywords[name]['Title'], res_dict.get(name, 'UNKNOWN'))) rte_spec = res_dict.get('RUNTIMEENVIRONMENT', []) res_item['fields'].append((res_keywords['RUNTIMEENVIRONMENT']['Title'], ', '.join([name for (name, val) in rte_spec]))) for exe in res_dict.get('EXECONFIG', []): exe_name = exe['name'] if not exe_name: continue exe_spec = res_item['exes'][exe_name] = [] for name in exe_fields: exe_spec.append((exe_keywords[name]['Title'], exe.get(name, 'UNKNOWN'))) exec_vgrids = exe.get('vgrid', []) visible_vgrids = [i for i in exec_vgrids if i in vgrid_access] if visible_vgrids != exec_vgrids: visible_vgrids.append('%d undisclosed' % \ (len(exec_vgrids) - len(visible_vgrids))) exe_spec.append((exe_keywords['vgrid']['Title'], ', '.join(visible_vgrids))) for store in res_dict.get('STORECONFIG', []): store_name = store['name'] if not store_name: continue store_spec = res_item['stores'][store_name] = [] for name in store_fields: store_spec.append((store_keywords[name]['Title'], store.get(name, 'UNKNOWN'))) storage_vgrids = store.get('vgrid', []) visible_vgrids = [i for i in storage_vgrids if i in vgrid_access] if visible_vgrids != storage_vgrids: visible_vgrids.append('%d undisclosed' % \ (len(storage_vgrids) - len(visible_vgrids))) store_spec.append((store_keywords['vgrid']['Title'], ', '.join(visible_vgrids))) return res_item
def build_resitem_object_from_res_dict(configuration, unique_resource_name, res_dict, allow_vgrids): """Build a resource object based on input res_dict""" res_keywords = get_resource_keywords(configuration) exe_keywords = get_exenode_keywords(configuration) store_keywords = get_storenode_keywords(configuration) res_fields = ['PUBLICNAME', 'PUBLICINFO', 'CPUCOUNT', 'NODECOUNT', 'MEMORY', 'DISK', 'ARCHITECTURE', 'JOBTYPE', 'MAXUPLOADBANDWIDTH', 'MAXDOWNLOADBANDWIDTH', 'SANDBOX'] exe_fields = ['cputime', 'nodecount'] store_fields = ['storage_disk', 'storage_protocol'] res_item = { 'object_type': 'resource_info', 'unique_resource_name': unique_resource_name, 'fields': [], 'exes': {}, 'stores': {}, } for name in res_fields: res_item['fields'].append((res_keywords[name]['Title'], res_dict.get(name, 'UNKNOWN'))) rte_spec = res_dict.get('RUNTIMEENVIRONMENT', []) res_item['fields'].append((res_keywords['RUNTIMEENVIRONMENT']['Title'], ', '.join([name for (name, val) in rte_spec]))) for exe in res_dict.get('EXECONFIG', []): exe_name = exe['name'] if not exe_name: continue exe_spec = res_item['exes'][exe_name] = [] for name in exe_fields: exe_spec.append((exe_keywords[name]['Title'], exe.get(name, 'UNKNOWN'))) exec_vgrids = exe.get('vgrid', []) visible_vgrids = [i for i in exec_vgrids if i in allow_vgrids] if visible_vgrids != exec_vgrids: visible_vgrids.append('%d undisclosed' % \ (len(exec_vgrids) - len(visible_vgrids))) exe_spec.append((exe_keywords['vgrid']['Title'], ', '.join(visible_vgrids))) for store in res_dict.get('STORECONFIG', []): store_name = store['name'] if not store_name: continue store_spec = res_item['stores'][store_name] = [] for name in store_fields: store_spec.append((store_keywords[name]['Title'], store.get(name, 'UNKNOWN'))) storage_vgrids = store.get('vgrid', []) visible_vgrids = [i for i in storage_vgrids if i in allow_vgrids] if visible_vgrids != storage_vgrids: visible_vgrids.append('%d undisclosed' % \ (len(storage_vgrids) - len(visible_vgrids))) store_spec.append((store_keywords['vgrid']['Title'], ', '.join(visible_vgrids))) return res_item
def empty_resource_config(configuration): """Prepares a basic resource configuration for use in creation of new resources. """ conf = {'frontendhome': ''} for (field, spec) in resconfkeywords.get_resource_keywords(configuration).items(): conf[field] = spec['Value'] conf['all_exes'] = {'executionnodes': '', 'executionhome': ''} for (field, spec) in resconfkeywords.get_exenode_keywords(configuration).items(): conf['all_exes'][field] = spec['Value'] conf['all_stores'] = {'storagenodes': '', 'storagehome': ''} for (field, spec) in resconfkeywords.get_storenode_keywords(configuration).items(): conf['all_stores'][field] = spec['Value'] return conf
def empty_resource_config(configuration): """Prepares a basic resource configuration for use in creation of new resources. """ conf = {'frontendhome': ''} for (field, spec) in resconfkeywords.get_resource_keywords(configuration).items(): conf[field] = spec['Value'] conf['all_exes'] = {'executionnodes': '', 'executionhome': ''} for (field, spec) in resconfkeywords.get_exenode_keywords(configuration).items(): conf['all_exes'][field] = spec['Value'] conf['all_stores'] = {'storagenodes': '', 'storagehome': ''} for (field, spec ) in resconfkeywords.get_storenode_keywords(configuration).items(): conf['all_stores'][field] = spec['Value'] return conf
def resconf_keywords(configuration, output_objects): """All resource configuration keywords""" resource_keywords = \ resconfkeywords.get_resource_keywords(configuration) exenode_keywords = \ resconfkeywords.get_exenode_keywords(configuration) storenode_keywords = \ resconfkeywords.get_storenode_keywords(configuration) topics = [('Resource configuration', resource_keywords), ('Execution node configuration', exenode_keywords), ('Storage node configuration', storenode_keywords)] for (title, keywords_dict) in topics: output_objects.append({'object_type': 'header', 'text': title}) sorted_keys = keywords_dict.keys() sorted_keys.sort() for keyword in sorted_keys: info = keywords_dict[keyword] output_objects.append({'object_type': 'sectionheader', 'text' : keyword}) entries = [] for (field, val) in info.items(): entries.append(field + ': ' + str(val)) output_objects.append({'object_type': 'list', 'list' : entries})
def main(client_id, user_arguments_dict): """Main function used by front end""" (configuration, logger, output_objects, op_name) = \ initialize_main_variables(client_id, op_header=False) defaults = signature()[1] (validate_status, accepted) = validate_input_and_cert( user_arguments_dict, defaults, output_objects, client_id, configuration, allow_rejects=False, ) if not validate_status: return (accepted, returnvalues.CLIENT_ERROR) status = returnvalues.OK resource_keywords = resconfkeywords.get_resource_keywords(configuration) exenode_keywords = resconfkeywords.get_exenode_keywords(configuration) storenode_keywords = resconfkeywords.get_storenode_keywords(configuration) title_entry = find_entry(output_objects, 'title') title_entry['text'] = 'Resource administration help' output_objects.append({ 'object_type': 'header', 'text': 'Resource administration help' }) output_objects.append({'object_type': 'sectionheader', 'text' : 'Welcome to the %s resource administration help' % \ configuration.short_title }) output_objects.append({ 'object_type': 'text', 'text': 'Help for each of the resource editor fields is available below.' }) res_fields = resconfkeywords.get_resource_specs(configuration) exe_fields = resconfkeywords.get_exenode_specs(configuration) store_fields = resconfkeywords.get_storenode_specs(configuration) # Resource overall fields output_objects.append({'object_type': 'html_form', 'text' : """ <b><a name='%s'>%s:</a></b><br /> %s<br /> <br />""" % ('frontendhome', 'Frontend Home Path', """The %s user home directory on the frontend""" % \ configuration.short_title ) }) for (field, spec) in res_fields: if 'invisible' == spec['Editor']: continue title = spec['Title'] output_objects.append({ 'object_type': 'html_form', 'text': """ <b><a name='res-%s'>%s:</a></b><br /> %s<br /> <br /> Example: %s<br /> <br />""" % (field, title, resource_keywords[field]['Description'], resource_keywords[field]['Example']) }) # Execution node fields output_objects.append({ 'object_type': 'html_form', 'text': """ <b><a name='exe-%s'>%s:</a></b><br /> %s<br /> <br /> Example: %s<br /> <br />""" % ('executionnodes', 'Execution Node(s)', exenode_keywords['name']['Description'], """ This fields configures all the job execution nodes in one %(site)s resource.<br /> It is possible to specify several execution nodes by seperating them with ';'<br /> and it's possible to denote ranges of execution nodes by using '->'.<br /> <br /> Example: n0->n8 ; n10 ; n12->n24<br /> <br /> Specifies the nodes n0 to n8, n10 and n12 to n24.<br /> <br /> Please note that the following node count field specifies the number of actual physical hosts associated with each of these %(site)s execution nodes. In case of a one-to-one mapping between %(site)s execution nodes and actual nodes, it should just be set to 1. Only if each %(site)s execution node gives access to multiple nodes e.g. in a cluster or batch system, should it be set higher.<br /> """ % { 'site': configuration.short_title }) }) output_objects.append({'object_type': 'html_form', 'text' : """ <b><a name='exe-%s'>%s:</a></b><br /> %s<br /> <br />""" % ('executionhome', 'Execution Home Path', """The %s user home directory on execution nodes""" % \ configuration.short_title ) }) for (field, spec) in exe_fields: if 'invisible' == spec['Editor']: continue title = spec['Title'] output_objects.append({ 'object_type': 'html_form', 'text': """ <b><a name='exe-%s'>%s:</a></b><br /> %s<br /> <br /> Example: %s<br /> <br />""" % (field, title, exenode_keywords[field]['Description'], exenode_keywords[field]['Example']) }) # Storage node fields output_objects.append({ 'object_type': 'html_form', 'text': """ <b><a name='store-%s'>%s:</a></b><br /> %s<br /> <br /> Example: %s<br /> <br />""" % ('store-storagenodes', 'Storage Node(s)', storenode_keywords['name']['Description'], """ This fields configures all the storage nodes in one %(site)s resource.<br /> It is possible to specify several storage nodes by seperating them with ';'<br /> and it's possible to denote ranges of storage nodes by using '->'.<br /> <br /> Example: n0->n8 ; n10 ; n12->n24<br /> <br /> Specifies the nodes n0 to n8, n10 and n12 to n24.<br /> <br /> Please note that the following disk field specifies the amount of actual physical storage reserved for %(site)s on each of these %(site)s storage nodes.<br /> """ % { 'site': configuration.short_title }) }) output_objects.append({'object_type': 'html_form', 'text' : """ <b><a name='store-%s'>%s:</a></b><br /> %s<br /> <br />""" % ('storagehome', 'Storage Home Path', """The %s user home directory on storage nodes""" % \ configuration.short_title ) }) for (field, spec) in store_fields: if 'invisible' == spec['Editor']: continue title = spec['Title'] output_objects.append({ 'object_type': 'html_form', 'text': """ <b><a name='store-%s'>%s:</a></b><br /> %s<br /> <br /> Example: %s<br /> <br />""" % (field, title, storenode_keywords[field]['Description'], storenode_keywords[field]['Example']) }) return (output_objects, status)
def main(client_id, user_arguments_dict): """Main function used by front end""" (configuration, logger, output_objects, op_name) = \ initialize_main_variables(client_id, op_header=False) defaults = signature()[1] (validate_status, accepted) = validate_input_and_cert( user_arguments_dict, defaults, output_objects, client_id, configuration, allow_rejects=False, ) if not validate_status: return (accepted, returnvalues.CLIENT_ERROR) status = returnvalues.OK resource_keywords = resconfkeywords.get_resource_keywords(configuration) exenode_keywords = resconfkeywords.get_exenode_keywords(configuration) storenode_keywords = resconfkeywords.get_storenode_keywords(configuration) title_entry = find_entry(output_objects, 'title') title_entry['text'] = 'Resource administration help' output_objects.append({'object_type': 'header', 'text': 'Resource administration help' }) output_objects.append({'object_type': 'sectionheader', 'text' : 'Welcome to the %s resource administration help' % \ configuration.short_title }) output_objects.append({'object_type': 'text', 'text' : 'Help for each of the resource editor fields is available below.' }) res_fields = resconfkeywords.get_resource_specs(configuration) exe_fields = resconfkeywords.get_exenode_specs(configuration) store_fields = resconfkeywords.get_storenode_specs(configuration) # Resource overall fields output_objects.append({'object_type': 'html_form', 'text' : """ <b><a name='%s'>%s:</a></b><br /> %s<br /> <br />""" % ('frontendhome', 'Frontend Home Path', """The %s user home directory on the frontend""" % \ configuration.short_title ) }) for (field, spec) in res_fields: if 'invisible' == spec['Editor']: continue title = spec['Title'] output_objects.append({'object_type': 'html_form', 'text' : """ <b><a name='res-%s'>%s:</a></b><br /> %s<br /> <br /> Example: %s<br /> <br />""" % (field, title, resource_keywords[field]['Description'], resource_keywords[field]['Example']) }) # Execution node fields output_objects.append({'object_type': 'html_form', 'text' : """ <b><a name='exe-%s'>%s:</a></b><br /> %s<br /> <br /> Example: %s<br /> <br />""" % ('executionnodes', 'Execution Node(s)', exenode_keywords['name']['Description'], """ This fields configures all the job execution nodes in one %(site)s resource.<br /> It is possible to specify several execution nodes by seperating them with ';'<br /> and it's possible to denote ranges of execution nodes by using '->'.<br /> <br /> Example: n0->n8 ; n10 ; n12->n24<br /> <br /> Specifies the nodes n0 to n8, n10 and n12 to n24.<br /> <br /> Please note that the following node count field specifies the number of actual physical hosts associated with each of these %(site)s execution nodes. In case of a one-to-one mapping between %(site)s execution nodes and actual nodes, it should just be set to 1. Only if each %(site)s execution node gives access to multiple nodes e.g. in a cluster or batch system, should it be set higher.<br /> """ % {'site' : configuration.short_title} ) }) output_objects.append({'object_type': 'html_form', 'text' : """ <b><a name='exe-%s'>%s:</a></b><br /> %s<br /> <br />""" % ('executionhome', 'Execution Home Path', """The %s user home directory on execution nodes""" % \ configuration.short_title ) }) for (field, spec) in exe_fields: if 'invisible' == spec['Editor']: continue title = spec['Title'] output_objects.append({'object_type': 'html_form', 'text' : """ <b><a name='exe-%s'>%s:</a></b><br /> %s<br /> <br /> Example: %s<br /> <br />""" % (field, title, exenode_keywords[field]['Description'], exenode_keywords[field]['Example']) }) # Storage node fields output_objects.append({'object_type': 'html_form', 'text' : """ <b><a name='store-%s'>%s:</a></b><br /> %s<br /> <br /> Example: %s<br /> <br />""" % ('store-storagenodes', 'Storage Node(s)', storenode_keywords['name']['Description'], """ This fields configures all the storage nodes in one %(site)s resource.<br /> It is possible to specify several storage nodes by seperating them with ';'<br /> and it's possible to denote ranges of storage nodes by using '->'.<br /> <br /> Example: n0->n8 ; n10 ; n12->n24<br /> <br /> Specifies the nodes n0 to n8, n10 and n12 to n24.<br /> <br /> Please note that the following disk field specifies the amount of actual physical storage reserved for %(site)s on each of these %(site)s storage nodes.<br /> """ % { 'site' : configuration.short_title} ) }) output_objects.append({'object_type': 'html_form', 'text' : """ <b><a name='store-%s'>%s:</a></b><br /> %s<br /> <br />""" % ('storagehome', 'Storage Home Path', """The %s user home directory on storage nodes""" % \ configuration.short_title ) }) for (field, spec) in store_fields: if 'invisible' == spec['Editor']: continue title = spec['Title'] output_objects.append({'object_type': 'html_form', 'text' : """ <b><a name='store-%s'>%s:</a></b><br /> %s<br /> <br /> Example: %s<br /> <br />""" % (field, title, storenode_keywords[field]['Description'], storenode_keywords[field]['Example']) }) return (output_objects, status)