PP-1009 : Enhancing sudo usage in PTL

Target Release17.2.1
JIRA

PP-1009 - Enhancing sudo usage in PTL

Document statusInitial version
Document ownerKumar Jakkali (Deactivated)
Designer
Developers
QA
Forum Discussionhttp://community.pbspro.org/t/pp-1009-sudo-enhancements/691


In PTL
- the existing interface to create temporary file return file name and file descriptor (FD). If test case create a file as different users than the current user the file FD is invalid as current user can't make use the returned FD.
- For file copy operation PTL by default does copy file with keeping original permission and then change owner and permissions of file

Enhancements:
- New interface to create a temporary file
- Adding a new parameter 'preserve_permission' to run_copy() to override the default file copy operation.


New Interfaces

Interface 1: create_temp_file
Visibility: Public
Change Control: Stable

Summary: create a temporary file

Details:
create_temp_file(hostname=None, suffix='', prefix='PtlPbs', dir=None, text=True, asuser=None, body=None)

By default create an empty temporary file as current user and return the file name.     

  • hostname : an empty temporary file as current user on the specified host and return the file name (Default: localhost)
  • body : write the content to file. (Default: None)
  • dir: the file will be created in this directory (Default: system temp dir)
  • asuser : create the file as specified user (Default: current user)
  • suffix : the file name will end with this suffix (Default: None)
  • prefix: the file name will begin with this prefix (Default 'PtlPbs')
  • text: the file is opened in text mode is this is true else in binary mode (Default:True)

With this new interface we will remove the existing mkstemp() from library and test cases.

Updating existing interface


Interface 1: create_script
Visibility: Public
Change Control: Stable
Summary: create a job script

Details:

Change in existing interface to accept user name instead of UID and GID
   Existing API : create_script(self, body=None, uid=None, gid=None, hostname=None)

   New API : create_script(self, body=None, asuser=None, hostname=None)

create_script() internally makes use of create_temp_file to create job script. create_temp_file() accepts asuser param.

so updating existing create_script() to accept username instead of UID and GID

Interface 2:run_copy
Visibility: Public
Change Control: Stable
Summary: copy a file

Details:

   Added a new parameter preserve_permission. Default preserve_permission=True.

  The existing interface executes cp command with -p flag which preserves owner,group permissions of source file.

   If the param 'preserve_permission= False' then run_copy() will copy file without keeping original permission (i.e cp without -p flag).

   If the param 'preserve_permission= True' then run_copy() will continue existing behavior as it is (i.e cp with -p flag)



Site Map

Developer Guide Pages