Session Client
- class pyCSM.clients.session_client.sessionClient(server_address, server_port, username, password)
The sessionClient class can be used to call various session level commands such as creating sessions, adding or removing copy sets, running commands against the session or scheduled task, etc. By using the sessionClient class you enter the username and password only when you instantiate the class which will obtain a token to the server that will be used on all calls using the class. In the event that the token expires, the client will automatically handle the error and retrieve a new token prior to retrying the call.
The client makes RESTAPI calls to the server and returns the results. For more details on what is returned from a call, see the CSM Documentation for the specific release.- add_copysets(name, copyset, roleorder=None)
Add copy sets to a given session
- Parameters
name (str) – The name of the session.
copysets (list) –
List of copysets to add to a session ex. (Single Copy set with two volumes)
[[“DS8000:2107.GXZ91:VOL:D000”,”DS8000:2107.GXZ91:VOL:D001”]]
- ex. (Two Copy sets with two volumes each)
- ”[[DS8000:1245.KTLM:VOL:0001”,”DS8000:1245.KTLM:VOL:0101”],
[“DS8000:2107.GXZ91:VOL:D004”,”DS8000:2107.GXZ91:VOL:D005”]]”
roleorder (list) – Optional list of the role names depicting the order of the volumes passed in on copysets ex. [“H1”, “H2”]
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- static change_properties(property_dictionary)
Takes a dictionary of properties and the values that user wants to change and changes them in the file.
- Parameters
property_dictionary (dict) – Dictionary of the keys and values that need
file. (to be changed in the) –
{"language" (ex.) – “en-UK”, “verify”:True}
- Returns
Returns the new properties dictionary.
- create_scheduled_task(json)
Creates a new task with given task info
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- create_session(name, sess_type, desc)
Create a copy services manager session. A session must be created before copy sets can be placed into the session and managed by the server.
- Parameters
name (str) – The name of the session that will be created.
sess_type – The type of session to create.
desc (str) (Optional) – description for the session
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- create_session_by_volgroup_name(volgroup, type, desc=None)
Create a copy services manager session and automatically creates a session name and populates the session based on the passed in volume group
- Parameters
volgroup (str) – The name of the specv volume group that will be created.
type (str) – type The type of session to create. Only Spec V Snapshot supports this today. Type is the “shortname” for the copy type returned in the /system/sessiontypes query.
desc (str) – description Optional description for the session
- Returns
JSON String representing the result of the command.
- delete_session(name)
Deletes a copy services manager session. Only inactive sessions can be deleted.
- Args:
name (str): The name of the session that will be deleted.
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- disable_scheduled_task(taskid)
Disable a scheduled task from running automatically.
- Parameters
taskid (str) – ID of the schedule task to enable. Use the get_scheduled_task() command to get the task id
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- duplicate_scheduled_task(taskid)
Duplicates scheduled task of a given id
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- enable_scheduled_task(taskid)
Enable a scheduled task to run based off the schedule defined on the task.
- Parameters
taskid (str) – ID of the schedule task to enable. Use the get_scheduled_task() command to get the task id
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- enable_scheduled_task_at_time(task_id, start_time)
Enable the task at the given time
- Parameters
task_id (int) – ID of the schedule task to enable
start_time (str) – Time to enable the task. Format of yyyy-MM-dd’T’HH-mm (ex. “2022-07-04T12-00”)
- Returns
JSON String representing the result of the command. ‘I’ = successful,’W’ = warning, ‘E’ = error.
- export_copysets(name, file_name)
Exports copysets from given session as a csv file and downloads it to the calling system.
- Parameters
name – Name of the session to export copysets for
file_name – Name for the csv file location (ex. “”/Users/myuser/CSM/Export/myexport.csv”)
- Returns
JSON String representing the result of the command.
- export_device_writeio_history(name, start_time, end_time)
Export ESE Box History for a session in csv format to a file
- Parameters
name (str) – The name of the session.
start_time (str) – Start time YYYY-MM-DD
end_time (str) – End time YYYY-MM-DD
- Returns
JSON String representing the result of the command.
- export_lss_oos_history(name, rolepair, start_time, end_time)
Export LSS OOS History for a session in csv format to a file.
- Parameters
name (str) – The name of the session.
rolepair (str) – The role pair name to query
start_time (str) – Start time YYYY-MM-DD
end_time (str) – End time YYYY-MM-DD
- Returns
JSON String representing the result of the command.
- get_available_commands(name)
Returns the list of available commands for a session based on the session’s current state
- Parameters
name (str) – The name of the session.
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- get_backup_details(name, role, backup_id)
Gets detailed information for a given backup in a session.
- Parameters
name (str) – The name of the session.
role – The name of role where the backups reside.
backup_id – The ID of the backup to send to the run command.
- Returns
JSON String representing the result of the command.
- get_copysets(name)
Gets all copy sets and their info for a given session.
- Parameters
name (str) – The name of the session.
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- get_pair_info(name, rolepair)
Get all the pairs for the session in a given role pair.
- Parameters
url (str) – Base url of csm server. ex. https://servername:port/CSM/web.
tk (str) – Rest token for the CSM server.
name (str) – The name of the session.
rolepair (str) – The name of the role pair to query in the session
- Returns
JSON String representing the result of the command. ‘I’ = successful,’W’ = warning, ‘E’ = error.
- static get_properties()
Returns a dictionary of the current properties and their values set for the file.
- get_recovered_backup_details(name, backup_id)
Gets the pair information for a specific recovered backup on a specific session
- Parameters
name (str) – The name of the session.
backup_id (int) – the backupid to get the detailed info for
- Returns
JSON String representing the result of the command.
- get_recovered_backups(name)
Gets all recovered backups for Spec V Safeguarded Copy session.
- Parameters
name (str) – The name of the session.
- Returns
JSON String representing the result of the command.
- get_rolepair_info(name, rolepair)
Gets a summary for a given role pair in a session.
- Parameters
name (str) – The name of the session.
rolepair (str) – The name of the role pair.
- Returns
JSON String representing the result of the command.
- get_rpo_history(name, rolepair, start_time, end_time)
Export ESE Box History for a session in csv format to a file
- Parameters
url (str) – Base url of CSM server. ex. https://servername:port/CSM/web.
tk (str) – Rest token for the CSM server.
name (str) – The name of the session.
start_time (str) – Start time YYYY-MM-DD (ex. “2020-04-22”)
end_time (str) – End time YYYY-MM-DD (ex. “2020-04-22”)
- Returns
JSON String representing the result of the command.
- get_scheduled_task(taskid)
Returns the scheduled task info of a given task id
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- get_scheduled_tasks()
Returns a list of scheduled tasks defined on the server
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- get_session_info(name)
This method returns the detailed information for a given session.
- Parameters
name (str) – The name of the session.
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- get_session_options(name)
Gets the options for the given session. The results returned from this method will vary depending on the session type.
- Parameters
name (str) – The name of the session.
- Returns
JSON String representing the result of the command.
- get_session_overviews()
This method returns the overview summary information for all sessions managed by the server
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- get_session_overviews_short()
This method returns minimal overview summary information for all sessions managed by the server.
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- get_snapshot_clone_details_by_name(name, snapshot_name)
Gets the pair details for the thin clone of the specified snapshot in the session
- Parameters
name (str) – The name of the session.
snapshot_name (str) – the name of the snapshot to get clone details for
- Returns
JSON String representing the result of the command.
- get_snapshot_clones(name)
Gets all clones for snapshots in for Spec V Safeguarded Copy session.
- Parameters
name (str) – The name of the session.
- Returns
JSON String representing the result of the command.
- get_snapshot_details_by_name(name, role, snapshot_name)
Gets detailed information for a given snapshot in a session.
- Parameters
name (str) – The name of the session.
role – The name of role where the snapshot resides.
snapshot_name – The name of the snapshot to return
- Returns
JSON String representing the result of the command.
- modify_session_description(name, desc)
Changes the description field for a given session.
- Parameters
name (str) – The name of the session.
desc (str) – description for the session
- Returns
JSON String representing the result of the command.
- remove_copysets(name, copysets, force=None, soft=None)
Removes Copy Sets from the given session.
- Parameters
name (str) – The name of the session.
copyset (str) – List of copy sets to add to the session. ex. “DS8000:1245.KTLM:VOL:0001”, “DS8000:1245.KTLM:VOL:0101”
force (boolean) – Force Set to true if you wish to remove the pair from CSM ignoring hardware errors.
soft (boolean) – Keep base relationships on the hardware but remove the copy set from the session.
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- run_backup_command(name, role, backup_id, cmd)
Used to perform a recover or expire for the specified backup.
- Parameters
name (str) – The name of the session.
role – The name of role where the backups reside.
backup_id – The ID of the backup to send to the run command.
cmd (str) – command to run (ex. “Recover Backup”, “Expire Backup”)
- Returns
JSON String representing the result of the command.
- run_scheduled_task(taskid, synchronous=False)
Run a scheduled task immediately. Synchronous value set to true if call should not return until task is complete. False if you want it to run in the asynchronous after the call completes.
- Parameters
taskid (str) – ID of the schedule task to enable.
synchronous (boolean) – True if you don’t want the command to complete until the task completes
- Returns
JSON String representing the result of the command. ‘I’ = successful, ‘W’ = warning, ‘E’ = error.
- run_scheduled_task_at_time(task_id, start_time)
Run a scheduled task immediately.
- Parameters
task_id (int) – ID of the schedule task to enable
start_time (str) – Time to enable the task. Format of yyyy-MM-dd’T’HH-mm (ex. “2022-07-04T12-00”)
- Returns
JSON String representing the result of the command. ‘I’ = successful,’W’ = warning, ‘E’ = error.
- run_session_command(ses_name, com_name)
Run a command against a session.
- Parameters
ses_name (str) – The name of the session.
com_name (str) – The name of the command.
- Returns
JSON String representing the result of the command.
- sgc_recover(ses_name, com_name, role, backup_id)
Run a Recover command to the specified Safeguarded Copy backup ID.
- Parameters
ses_name (str) – The name of the session.
com_name (str) – The name of the command.
role – The name of role where the backups reside.
backup_id – The ID of the backup to send to the run command.
- Returns
JSON String representing the result of the command.
- wait_for_state(ses_name, state, minutes, debug=False)
Runs until the session is in a given state or until it times out and returns the results.
- Parameters
ses_name (str) – The name of the session.
state (str) – state of the server that user wants to wait for.
minutes (double) – number of minutes before it times out
debug (boolean) – True if you want the state and status to print in console
- Returns
boolean for whether the state was reached and “session_info”: JSON string representing the response of the command
- Return type
A dictionary with “state_reached”