def list(gvar): """ List settings. """ mandatory = [] required = [] optional = ['-H', '-h', '-NV', '-ok', '-r', '-s', '-V', '-VC'] if gvar['retrieve_options']: return mandatory + required + optional # Check for missing arguments or help required. check_keys(gvar, mandatory, required, optional, requires_server=False) # Retrive all possible option names ordered by 'server' and then alphabetically. if os.path.isfile('%s/.csv2/default_server' % gvar['home_dir']): fd = open('%s/.csv2/default_server' % gvar['home_dir']) default_server = fd.read() fd.close report_title = 'Defaults (default server = %s):' % default_server else: report_title = 'Defaults:' # Retrive all possible option names ordered by 'server' and then alphabetically. _keys = ['server,k'] for _ix in range(len(gvar['command_keys'])): key = gvar['command_keys'][_ix][1][2:] if key not in _keys: _keys.append(key) _keys = [_keys[0]] + sorted(_keys[1:]) # Build a queryset of the settings. _queryset = [] for server in os.listdir('%s/.csv2' % gvar['home_dir']): if server[0] == '.': continue server_path = '%s/.csv2//%s' % (gvar['home_dir'], server) if os.path.isdir(server_path): if 'server' not in gvar['command_args'] or server == gvar[ 'command_args']['server']: _fd = open('%s/settings.yaml' % server_path) _settings = yaml.load(_fd.read()) _fd.close() for key in sorted(_keys): if key not in _settings: if key == 'server': _settings[key] = server _queryset.append({'fields': _settings}) # Display results. show_table(gvar, _queryset, _keys, allow_null=False, title=report_title)
def defaults(gvar): """ Modify the specified group defaults. """ mandatory = [] required = [] optional = [ '-CSEP', '-CSV', '-g', '-H', '-h', '-htcf', '-htcn', '-htcu', '-jc', '-jd', '-jr', '-js', '-NV', '-ok', '-r', '-s', '-V', '-VC', '-vf', '-vi', '-vka', '-vk', '-vn', '-xA' ] if gvar['retrieve_options']: return mandatory + required + optional # Check for missing arguments or help required. form_data = check_keys(gvar, mandatory, required, optional, key_map=KEY_MAP) # List the current defaults. If the form_data contains any optional fields, # those values will be updated before the list is retrieved. response = requests(gvar, '/group/defaults/', form_data) if response['message']: print(response['message']) # Print report show_active_user_groups(gvar, response) show_table( gvar, response['defaults_list'], [ 'group_name/Group,k', 'htcondor_fqdn/FQDN/HTCondor', 'htcondor_name/Name/HTCondor', 'htcondor_other_submitters/Users/HTCondor', 'vm_flavor/Flavor/VM', 'vm_image/Image/VM', 'vm_keep_alive/Keep Alive/VM', 'vm_keyname/Keyname/VM', 'vm_network/Network/VM', 'job_cpus/Cores/Job', 'job_disk/Disk (GBs)/Job', 'job_ram/RAM (MBs)/Job', 'job_swap/Swap (GBs)/Job', ], title="Active Group Defaults:", )
def config(gvar): """ Modify the specified group defaults. """ mandatory = [] required = [] optional = [ '-c', '-cc', '-CSEP', '-CSV', '-dci', '-djg', '-eg', '-g', '-H', '-h', '-lf', '-ll', '-nld', '-NV', '-ok', '-r', '-s', '-sic', '-siC', '-sif', '-sii', '-sij', '-sik', '-sil', '-sim', '-sin', '-siv', '-sml', '-sms', '-V', '-VC', '-xA' ] if gvar['retrieve_options']: return mandatory + required + optional # Check for missing arguments or help required. form_data = check_keys(gvar, mandatory, required, optional, key_map=KEY_MAP) # List the current defaults. If the form_data contains any optional fields, # those values will be updated before the list is retrieved. response = requests(gvar, '/server/config/', form_data) if response['message']: print(response['message']) # Print report show_active_user_groups(gvar, response) show_table( gvar, response['config_list'], [ 'category/Category,k', 'config_key/Config Key,k', 'config_type/Type', 'config_value/Value', ], title="Server Configuration:", )
def metadata_list(gvar): """ List clouds for the active group. """ mandatory = [] required = [] optional = [ '-CSEP', '-CSV', '-g', '-H', '-h', '-mn', '-NV', '-ok', '-r', '-s', '-V', '-VC', '-xA' ] if gvar['retrieve_options']: return mandatory + required + optional # Check for missing arguments or help required. check_keys(gvar, mandatory, required, optional) # Retrieve data (possibly after changing the group). response = requests(gvar, '/group/metadata-list/') if response['message']: print(response['message']) # Filter response as requested (or not). group_metadata_list = _filter_by_group_name_and_or_metadata_name( gvar, response['group_metadata_list']) # Print report. show_active_user_groups(gvar, response) show_table( gvar, group_metadata_list, [ 'group_name/Group,k', 'metadata_name/Metadata Filename,k', 'enabled/Enabled', 'priority/Priority', 'mime_type/MIME Type', ], title="Active Group/Metadata:", )
def list(gvar): """ List groups. """ mandatory = [] required = [] optional = [ '-CSEP', '-CSV', '-g', '-gn', '-H', '-h', '-NV', '-ok', '-r', '-s', '-V', '-VC', '-xA' ] if gvar['retrieve_options']: return mandatory + required + optional # Check for missing arguments or help required. check_keys(gvar, mandatory, required, optional) # Retrieve data (possibly after changing the group). response = requests(gvar, '/group/list/') if response['message']: print(response['message']) # Filter response as requested (or not). group_list = _filter_by_group_name_and_or_metadata_name( gvar, response['group_list']) # Print report show_active_user_groups(gvar, response) show_table( gvar, group_list, [ 'group_name/Group,k', 'condor_central_manager/Central Manager', 'metadata_names/Metadata Filenames', ], title="Groups:", )
def list(gvar): """ List users. """ mandatory = [] required = [] optional = ['-CSEP', '-CSV', '-g', '-H', '-h', '-NV', '-ok', '-r', '-s', '-un', '-V', '-VC', '-xA'] if gvar['retrieve_options']: return mandatory + required + optional # Check for missing arguments or help required. check_keys(gvar, mandatory, required, optional) # Retrieve data (possibly after changing the user). response = requests(gvar, '/user/list/') if response['message']: print(response['message']) # Filter response as requested (or not). user_list = _filter_by_user(gvar, response['user_list']) # Print report show_active_user_groups(gvar, response) show_table( gvar, user_list, [ 'username/Username,k', 'cert_cn/Common Name', 'active_group/Active Group', 'user_groups/User Groups', 'available_groups/Not In Groups', 'is_superuser/Super User', 'join_date/Joined', ], title="Users:", )
def list(gvar): """ List clouds for the active group. """ mandatory = [] required = [] optional = ['-cn', '-CSEP', '-CSV', '-g', '-H', '-h', '-jh', '-jI', '-ji', '-jp', '-jR', '-jrc', '-jrd', '-jrr', '-jrs', '-jS', '-jtc', '-ju', '-NV', '-ok', '-r', '-s', '-V', '-VC', '-xA'] if gvar['retrieve_options']: return mandatory + required + optional # Check for missing arguments or help required. check_keys( gvar, mandatory, required, optional) # Retrieve data (possibly after changing the group). response = requests(gvar, '/job/list/') if response['message']: print(response['message']) # Filter response as requested (or not). job_list = _filter(gvar, response['job_list']) # Print report. show_active_user_groups(gvar, response) show_table( gvar, job_list, [ 'group_name/Group,k', 'global_job_id/Job ID,k', 'cluster_id/Cluster ID', 'proc_id/Process ID', 'user/User', 'user_data/User Data', 'requirements/Requirements', 'target_clouds/Target Clouds', 'cloud_name/Cloud', 'instance_type/Instance Type', 'request_cpus/CPUs/Requested', 'request_ram/RAM {MBs}/Requested', 'request_disk/Disk {GBs}/Requested', 'request_swap/Swap (GBs)/Requested', 'job_per_core/Jobs per Core', 'image/Image', 'network/Network', 'job_priority/Priority/Job', 'job_status/Status Code/Job', 'js_idle/Idle/Job Status Flags', 'js_running/Running/Job Status Flags', 'js_completed/Completed/Job Status Flags', 'js_held/Held/Job Status Flags', 'js_other/Other/Job Status Flags', 'keep_alive/Keep Alive (seconds)', 'max_price/Max Spot Price', 'entered_current_status/State Change Date', 'q_date/Queued Date', 'held_reason/Held Job Reason', ], title="Jobs", )
def status(gvar): """ List cloud status for the active group. """ mandatory = [] required = [] optional = ['-cn', '-CSEP', '-CSV', '-g', '-H', '-h', '-NV', '-o', '-ok', '-r', '-s', '-V', '-VC', '-xA'] if gvar['retrieve_options']: return mandatory + required + optional # Check for missing arguments or help required. check_keys(gvar, mandatory, required, optional) # Retrieve data (possibly after changing the group). response = requests(gvar, '/cloud/status/') # Filter response as requested (or not). cloud_status_list = _filter_by_cloud_name_and_or_metadata_name(gvar, response['cloud_status_list']) # Print report show_active_user_groups(gvar, response) show_table( gvar, response['job_status_list'], [ 'group_name/Group,k', 'Jobs', 'Idle', 'Running', 'Completed', 'Other', ], title="Job status:", ) show_table( gvar, cloud_status_list, [ 'group_name/Group,k', 'cloud_name/Cloud,k', 'enabled/Enabled/Defaults', 'default_flavor/Flavor/Defaults', 'default_image/Image/Defaults', 'keep_alive/Keep Alive/Defaults', 'VMs/Total/VMs', 'VMs_starting/Starting/VMs', 'VMs_unregistered/Unregistered/VMs', 'VMs_idle/idle/VMs', 'VMs_running/Running/VMs', 'VMs_retiring/Retiring/VMs', 'VMs_manual/Manual/VMs', 'VMs_in_error/Error/VMs', 'VMs_other/Other/VMs', 'cores_max/Quota/Cores', 'cores_limit/Limit/Cores', 'cores_ctl/Setting/Cores', 'cores_idle/Idle/Cores', 'cores_native/Used/Cores', 'ram_max/Quota/RAM', 'ram_limit/Limit/RAM', 'ram_ctl/Setting/RAM', 'ram_idle/Idle/RAM', 'ram_native/Used/RAM', 'slot_count/Busy/Condor Slots', 'slot_core_count/Busy Cores/Condor Slots', 'slot_idle_core_count/Idle Cores/Condor Slots', 'Foreign_VMs/VMs/Foreign', 'cores_foreign/Cores/Foreign', 'ram_foreign/RAM/Foreign', ], title="Cloud status:", )
def list(gvar): """ List clouds for the active group. """ mandatory = [] required = [] optional = ['-cn', '-CSEP', '-CSV', '-g', '-H', '-h', '-ok', '-r', '-s', '-V', '-VC', '-NV', '-xA'] if gvar['retrieve_options']: return mandatory + required + optional # Check for missing arguments or help required. check_keys(gvar, mandatory, required, optional) # Retrieve data (possibly after changing the group). response = requests(gvar, '/cloud/list/') if response['message']: print(response['message']) # Filter response as requested (or not). cloud_list = _filter_by_cloud_name_and_or_metadata_name(gvar, response['cloud_list']) # Print report. show_active_user_groups(gvar, response) show_table( gvar, cloud_list, [ 'group_name/Group,k', 'cloud_name/Cloud,k', 'enabled/Enabled', 'authurl/URL', 'project_domain_name/Project Domain', 'project/Project', 'user_domain_name/User Domain', 'username/User', 'region/Region', 'spot_price/Spot Price', 'cloud_type/Cloud Type', 'cores_ctl/Control/Cores', 'cores_softmax/SoftMax/Cores', 'cores_max/Max/Cores', 'ram_ctl/Control/RAM', 'ram_max/Max/RAM', 'vm_flavor/Flavor/Cloud Default', 'vm_image/Image/Cloud Default', 'vm_keep_alive/Keep Alive/Cloud Default', 'vm_keyname/Keyname/Cloud Default', 'vm_network/Network/Cloud Default', 'cascading_vm_flavor/Flavor/Cascading Default', 'cascading_vm_image/Image/Cascading Default', 'cascading_vm_keep_alive/Keep Alive/Cascading Default', 'cascading_vm_keyname/Keyname/Cascading Default', 'cascading_vm_network/Network/Cascading Default', 'cacertificate/CA Certificate', 'flavor_exclusions/Flavor Exclusions/Cloud', 'flavor_names/Flavors/Cloud', 'group_exclusions/Group Exclusions/Metadata', 'metadata_names/Filenames/Metadata', ], title="Clouds:", )
def list(gvar): """ List VMs for the active group. """ mandatory = [] required = [] optional = [ '-cn', '-CSEP', '-CSV', '-g', '-H', '-h', '-NV', '-ok', '-r', '-s', '-V', '-VC', '-vc', '-vd', '-vF', '-vf', '-vh', '-vr', '-vS', '-vs', '-xA' ] if gvar['retrieve_options']: return mandatory + required + optional # Check for missing arguments or help required. check_keys(gvar, mandatory, required, optional) # Retrieve data (possibly after changing the group). response = requests(gvar, '/vm/list/%s' % _selector(gvar)) if response['message']: print(response['message']) # Filter response as requested (or not). vm_list = _filter(gvar, response['vm_list']) # Print report. show_active_user_groups(gvar, response) show_table( gvar, vm_list, [ 'group_name/Group,k', 'cloud_name/Cloud,k', 'hostname/Hostname,k', 'vmid/VMID', 'vm_ips/IPs', 'vm_floating_ips/Floating IPs', 'auth_url/Authorization URL', 'project/Project', 'status/Status', 'flavor_id/Flavor ID', 'task/Task', 'power_status/Power Status', 'start_time/Start Time', 'retire_request_time/Retire Request Time', 'retired_time/Retired Time', 'terminate/Terminate', 'terminate_time/Terminate Time', 'status_changed_time/Status Change Time', 'last_updated/Last Updated', 'flavor_name/Flavor', 'condor_slots/Condor Slots', 'foreign_vm/Foreign', 'cores/cores', 'disk/Disk (GBs)', 'ram/Ram (MBs)', 'swap/Swap (GBs)', 'poller_status/Poller Status', 'manual_control/Manual_Control', ], title="VMs:", )