pbs_api_to_cli.py 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. # coding: utf-8
  2. # Copyright (C) 1994-2018 Altair Engineering, Inc.
  3. # For more information, contact Altair at www.altair.com.
  4. #
  5. # This file is part of the PBS Professional ("PBS Pro") software.
  6. #
  7. # Open Source License Information:
  8. #
  9. # PBS Pro is free software. You can redistribute it and/or modify it under the
  10. # terms of the GNU Affero General Public License as published by the Free
  11. # Software Foundation, either version 3 of the License, or (at your option) any
  12. # later version.
  13. #
  14. # PBS Pro is distributed in the hope that it will be useful, but WITHOUT ANY
  15. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16. # FOR A PARTICULAR PURPOSE.
  17. # See the GNU Affero General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU Affero General Public License
  20. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. # Commercial License Information:
  23. #
  24. # For a copy of the commercial license terms and conditions,
  25. # go to: (http://www.pbspro.com/UserArea/agreement.html)
  26. # or contact the Altair Legal Department.
  27. #
  28. # Altair’s dual-license business model allows companies, individuals, and
  29. # organizations to create proprietary derivative works of PBS Pro and
  30. # distribute them - whether embedded or bundled with other software -
  31. # under a commercial license agreement.
  32. #
  33. # Use of Altair’s trademarks, including but not limited to "PBS™",
  34. # "PBS Professional®", and "PBS Pro™" and Altair’s logos is subject to Altair's
  35. # trademark licensing policies.
  36. from ptl.lib.pbs_ifl_mock import *
  37. api_to_cli = {
  38. ATTR_a: 'a',
  39. ATTR_c: 'c',
  40. ATTR_e: 'e',
  41. ATTR_g: 'W group_list=',
  42. ATTR_h: 'h',
  43. ATTR_j: 'j',
  44. ATTR_J: 'J',
  45. ATTR_k: 'k',
  46. ATTR_l: 'l',
  47. ATTR_m: 'm',
  48. ATTR_o: 'o',
  49. ATTR_p: 'p',
  50. ATTR_q: 'q',
  51. ATTR_R: 'R',
  52. ATTR_r: 'r',
  53. ATTR_u: 'u',
  54. ATTR_v: 'v',
  55. ATTR_A: 'A',
  56. ATTR_M: 'M',
  57. ATTR_N: 'N',
  58. ATTR_S: 'S',
  59. ATTR_W: 'W',
  60. ATTR_array_indices_submitted: 'J',
  61. ATTR_depend: 'W depend=',
  62. ATTR_inter: 'I',
  63. ATTR_sandbox: 'W sandbox=',
  64. ATTR_stagein: 'W stagein=',
  65. ATTR_stageout: 'W stageout=',
  66. ATTR_resvTag: 'reserve_Tag',
  67. ATTR_resv_start: 'R',
  68. ATTR_resv_end: 'E',
  69. ATTR_resv_duration: 'D',
  70. ATTR_resv_state: 'reserve_state',
  71. ATTR_resv_substate: 'reserve_substate',
  72. ATTR_auth_u: 'U',
  73. ATTR_auth_g: 'G',
  74. ATTR_auth_h: 'Authorized_Hosts',
  75. ATTR_pwd: 'pwd',
  76. ATTR_cred: 'cred',
  77. ATTR_nodemux: 'no_stdio_sockets',
  78. ATTR_umask: 'W umask=',
  79. ATTR_block: 'W block=',
  80. ATTR_convert: 'W qmove=',
  81. ATTR_DefaultChunk: 'default_chunk',
  82. ATTR_X11_cookie: 'forward_x11_cookie',
  83. ATTR_X11_port: 'forward_x11_port',
  84. ATTR_resv_standing: '',
  85. ATTR_resv_count: 'reserve_count',
  86. ATTR_resv_idx: 'reserve_index',
  87. ATTR_resv_rrule: 'r',
  88. ATTR_resv_execvnodes: 'reserve_execvnodes',
  89. ATTR_resv_timezone: '',
  90. ATTR_ctime: 'c',
  91. ATTR_estimated: 't',
  92. ATTR_exechost: 'exec_host',
  93. ATTR_exechost2: 'exec_host2',
  94. ATTR_execvnode: 'exec_vnode',
  95. ATTR_resv_nodes: 'resv_nodes',
  96. ATTR_mtime: 'm',
  97. ATTR_qtime: 'q',
  98. ATTR_session: 'session_id',
  99. ATTR_jobdir: 'jobdir',
  100. ATTR_euser: 'euser',
  101. ATTR_egroup: 'egroup',
  102. ATTR_project: 'P',
  103. ATTR_hashname: 'hashname',
  104. ATTR_hopcount: 'hop_count',
  105. ATTR_security: 'security',
  106. ATTR_sched_hint: 'sched_hint',
  107. ATTR_SchedSelect: 'schedselect',
  108. ATTR_substate: 'substate',
  109. ATTR_name: 'N',
  110. ATTR_owner: 'Job_Owner',
  111. ATTR_used: 'resources_used',
  112. ATTR_state: 's',
  113. ATTR_queue: 'q',
  114. ATTR_server: 'server',
  115. ATTR_maxrun: 'max_running',
  116. ATTR_max_run: 'max_run',
  117. ATTR_max_run_res: 'max_run_res',
  118. ATTR_max_run_soft: 'max_run_soft',
  119. ATTR_max_run_res_soft: 'max_run_res_soft',
  120. ATTR_total: 'total_jobs',
  121. ATTR_comment: 'W comment=',
  122. ATTR_cookie: 'cookie',
  123. ATTR_qrank: 'queue_rank',
  124. ATTR_altid: 'alt_id',
  125. ATTR_altid2: 'alt_id2',
  126. ATTR_acct_id: 'accounting_id',
  127. ATTR_array: 'J',
  128. ATTR_array_id: 'array_id',
  129. ATTR_array_index: 'array_index',
  130. ATTR_array_state_count: 'array_state_count',
  131. ATTR_array_indices_remaining: 'array_indices_remaining',
  132. ATTR_etime: 'e',
  133. ATTR_gridname: 'gridname',
  134. ATTR_refresh: 'last_context_refresh',
  135. ATTR_ReqCredEnable: 'require_cred_enable',
  136. ATTR_ReqCred: 'require_cred',
  137. ATTR_runcount: 'W run_count=',
  138. ATTR_stime: 's',
  139. ATTR_pset: 'pset',
  140. ATTR_executable: 'executable',
  141. ATTR_Arglist: 'argument_list',
  142. ATTR_version: 'pbs_version',
  143. ATTR_eligible_time: 'g',
  144. ATTR_accrue_type: 'accrue_type',
  145. ATTR_sample_starttime: 'sample_starttime',
  146. ATTR_job_kill_delay: 'job_kill_delay',
  147. ATTR_history_timestamp: 'history_timestamp',
  148. ATTR_stageout_status: 'Stageout_status',
  149. ATTR_exit_status: 'Exit_status',
  150. ATTR_submit_arguments: 'Submit_arguments',
  151. ATTR_resv_name: 'Reserve_Name',
  152. ATTR_resv_owner: 'Reserve_Owner',
  153. ATTR_resv_type: 'reserve_type',
  154. ATTR_resv_Tag: 'reservation_Tag',
  155. ATTR_resv_ID: 'reserve_ID',
  156. ATTR_resv_retry: 'reserve_retry',
  157. ATTR_aclgren: 'acl_group_enable',
  158. ATTR_aclgroup: 'acl_groups',
  159. ATTR_aclhten: 'acl_host_enable',
  160. ATTR_aclhost: 'acl_hosts',
  161. ATTR_acluren: 'acl_user_enable',
  162. ATTR_acluser: 'acl_users',
  163. ATTR_altrouter: 'alt_router',
  164. ATTR_chkptmin: 'checkpoint_min',
  165. ATTR_enable: 'enabled',
  166. ATTR_fromroute: 'from_route_only',
  167. ATTR_HasNodes: 'hasnodes',
  168. ATTR_killdelay: 'kill_delay',
  169. ATTR_maxgrprun: 'max_group_run',
  170. ATTR_maxgrprunsoft: 'max_group_run_soft',
  171. ATTR_maxque: 'max_queuable',
  172. ATTR_max_queued: 'max_queued',
  173. ATTR_max_queued_res: 'max_queued_res',
  174. ATTR_maxuserrun: 'max_user_run',
  175. ATTR_maxuserrunsoft: 'max_user_run_soft',
  176. ATTR_qtype: 'queue_type',
  177. ATTR_rescassn: 'resources_assigned',
  178. ATTR_rescdflt: 'resources_default',
  179. ATTR_rescmax: 'resources_max',
  180. ATTR_rescmin: 'resources_min',
  181. ATTR_rndzretry: 'rendezvous_retry',
  182. ATTR_routedest: 'route_destinations',
  183. ATTR_routeheld: 'route_held_jobs',
  184. ATTR_routewait: 'route_waiting_jobs',
  185. ATTR_routeretry: 'route_retry_time',
  186. ATTR_routelife: 'route_lifetime',
  187. ATTR_rsvexpdt: 'reserved_expedite',
  188. ATTR_rsvsync: 'reserved_sync',
  189. ATTR_start: 'started',
  190. ATTR_count: 'state_count',
  191. ATTR_number: 'number_jobs',
  192. ATTR_SvrHost: 'server_host',
  193. ATTR_aclroot: 'acl_roots',
  194. ATTR_managers: 'managers',
  195. ATTR_dfltque: 'default_queue',
  196. ATTR_defnode: 'default_node',
  197. ATTR_locsvrs: 'location_servers',
  198. ATTR_logevents: 'log_events',
  199. ATTR_logfile: 'log_file',
  200. ATTR_mailfrom: 'mail_from',
  201. ATTR_nodepack: 'node_pack',
  202. ATTR_nodefailrq: 'node_fail_requeue',
  203. ATTR_operators: 'operators',
  204. ATTR_queryother: 'query_other_jobs',
  205. ATTR_resccost: 'resources_cost',
  206. ATTR_rescavail: 'resources_available',
  207. ATTR_maxuserres: 'max_user_res',
  208. ATTR_maxuserressoft: 'max_user_res_soft',
  209. ATTR_maxgroupres: 'max_group_res',
  210. ATTR_maxgroupressoft: 'max_group_res_soft',
  211. ATTR_maxarraysize: 'max_array_size',
  212. ATTR_PNames: 'pnames',
  213. ATTR_schedit: 'scheduler_iteration',
  214. ATTR_scheduling: 'scheduling',
  215. ATTR_status: 'server_state',
  216. ATTR_syscost: 'system_cost',
  217. ATTR_FlatUID: 'flatuid',
  218. ATTR_FLicenses: 'FLicenses',
  219. ATTR_ResvEnable: 'resv_enable',
  220. ATTR_aclResvgren: 'acl_resv_group_enable',
  221. ATTR_aclResvgroup: 'acl_resv_groups',
  222. ATTR_aclResvhten: 'acl_resv_host_enable',
  223. ATTR_aclResvhost: 'acl_resv_hosts',
  224. ATTR_aclResvuren: 'acl_resv_user_enable',
  225. ATTR_aclResvuser: 'acl_resv_users',
  226. ATTR_NodeGroupEnable: 'node_group_enable',
  227. ATTR_NodeGroupKey: 'node_group_key',
  228. ATTR_ssignon_enable: 'single_signon_password_enable',
  229. ATTR_dfltqdelargs: 'default_qdel_arguments',
  230. ATTR_dfltqsubargs: 'default_qsub_arguments',
  231. ATTR_rpp_retry: 'rpp_retry',
  232. ATTR_rpp_highwater: 'rpp_highwater',
  233. ATTR_license_location: 'pbs_license_file_location',
  234. ATTR_pbs_license_info: 'pbs_license_info',
  235. ATTR_license_min: 'pbs_license_min',
  236. ATTR_license_max: 'pbs_license_max',
  237. ATTR_license_linger: 'pbs_license_linger_time',
  238. ATTR_license_count: 'license_count',
  239. ATTR_job_sort_formula: 'job_sort_formula',
  240. ATTR_EligibleTimeEnable: 'eligible_time_enable',
  241. ATTR_resv_retry_init: 'reserve_retry_init',
  242. ATTR_resv_retry_cutoff: 'reserve_retry_cutoff',
  243. ATTR_JobHistoryEnable: 'job_history_enable',
  244. ATTR_JobHistoryDuration: 'job_history_duration',
  245. ATTR_max_concurrent_prov: 'max_concurrent_provision',
  246. ATTR_resv_post_processing: 'resv_post_processing_time',
  247. ATTR_backfill_depth: 'backfill_depth',
  248. ATTR_job_requeue_timeout: 'job_requeue_timeout',
  249. ATTR_SchedHost: 'sched_host',
  250. ATTR_sched_cycle_len: 'sched_cycle_length',
  251. ATTR_do_not_span_psets: 'do_not_span_psets',
  252. ATTR_soft_time: 'Wsoft_limit_time',
  253. ATTR_power_provisioning: 'power_provisioning',
  254. ATTR_max_job_sequence_id: 'max_job_sequence_id',
  255. ATTR_tolerate_node_failures: 'Wtolerate_node_failures=',
  256. ATTR_NODE_Host: 'Host',
  257. ATTR_NODE_Mom: 'Mom',
  258. ATTR_NODE_Port: 'Port',
  259. ATTR_NODE_state: 'state',
  260. ATTR_NODE_ntype: 'ntype',
  261. ATTR_NODE_jobs: 'jobs',
  262. ATTR_NODE_resvs: 'resv',
  263. ATTR_NODE_resv_enable: 'resv_enable',
  264. ATTR_NODE_np: 'np',
  265. ATTR_NODE_pcpus: 'pcpus',
  266. ATTR_NODE_properties: 'properties',
  267. ATTR_NODE_NoMultiNode: 'no_multinode_jobs',
  268. ATTR_NODE_No_Tasks: 'no_tasks',
  269. ATTR_NODE_Sharing: 'sharing',
  270. ATTR_NODE_HPCBP_User_name: 'hpcbp_user_name',
  271. ATTR_NODE_HPCBP_WS_address: 'hpcbp_webservice_address',
  272. ATTR_NODE_HPCBP_Stage_protocol: 'hpcbp_stage_protocol',
  273. ATTR_NODE_HPCBP_enable: 'hpcbp_enable',
  274. ATTR_NODE_ProvisionEnable: 'provision_enable',
  275. ATTR_NODE_current_aoe: 'current_aoe',
  276. ATTR_NODE_in_multivnode_host: 'in_multivnode_host',
  277. ATTR_NODE_License: 'license',
  278. ATTR_NODE_LicenseInfo: 'license_info',
  279. ATTR_NODE_TopologyInfo: 'topology_info',
  280. ATTR_NODE_last_used_time: 'last_used_time',
  281. ATTR_NODE_last_state_change_time: 'last_state_change_time',
  282. ATTR_RESC_TYPE: 'type',
  283. ATTR_RESC_FLAG: 'flag',
  284. SHUT_QUICK: 't quick',
  285. SHUT_DELAY: 't delay',
  286. SHUT_IMMEDIATE: 't immediate',
  287. SHUT_WHO_SCHED: 's',
  288. SHUT_WHO_MOM: 'm',
  289. SHUT_WHO_SECDRY: 'f',
  290. SHUT_WHO_IDLESECDRY: 'i',
  291. SHUT_WHO_SECDONLY: 'F',
  292. }
  293. def convert_api_to_cli(attrs):
  294. ret = []
  295. for a in attrs:
  296. if '.' in a:
  297. (attribute, resource) = a.split('.')
  298. ret.append(api_to_cli[attribute] + resource)
  299. else:
  300. ret.append(api_to_cli[a])
  301. return ret