Operations for the Developer SDK for Python

The Python SDK includes common operations for entities. For detailed documentation on the available operations, review the documentation included in the Python SDK:

  • To view documentation for a module, from the Python command line, type the following command:

    >>> from cvpysdk import module_name >>> help(module_name)

    where module_name is the name of the module, for example, commcell. For a list of modules, see the following table.

  • To view documentation for a class, from the Python command line, type the following command:

    >>> from cvpysdk.module_name import class_name >>> help(class_name)

    where:

    • module_name is the name of the module, for example, usergroup. For a list of modules, see the following table.

    • class_name is the name of the class, for example, UserGroup. For a list of classes, see the following table.

The following table lists common modules and classes included in the Python SDK. For a complete listing, go to the Commvault Developer SDK - Python GitHub site.

Class

Module

Description

Examples

Agent

agent

Performs operations for an agent associated with a client

  • agent.enable_backup()

  • agent.enable_backup_at_time(2017-05-10 23:00:00)

  • agent.disable_backup()

  • agent.enable_restore()

  • agent.enable_restore_at_time(2017-05-10 23:10:30)

  • agent.disable_restore()

Agents

agent

Performs operations on all agents associated with a client

  • boolean_value = client.agents.has_agent(agent_name)

  • agent = client.agents.get(agent_name)

Alert

alert

Performs operations on an alert

  • alert.enable()

  • alert.disable()

  • alert.enable_notification_type()

  • alert.disable_notification_type()

Alerts

alert

Performs operations on all alerts

  • boolean_value = commcell.alerts.has_alert(alert_name)

  • alert = commcell.alerts.get(alert_name)

  • alert = commcell.alerts.get(alert_name=‘Index State’)

  • commcell.alerts.delete(alert_name)

  • console_alerts = commcell.alerts.console_alerts()

ApiLibrary

services

Service URLs for REST API operations

Backupset

backupset

Performs operations on a backup set

  • Update backup set Name: backupset.backupset_name = new_backupset_name

  • Update backup set description: backupset.backupset_description = new_backupset_description

  • backupset.set_default_backupset()

  • jobs_list = backupset.backup()

Backupsets

backupset

Performs operations on all backup sets associated with an agent

  • boolean_value1 = agent.backupsets.has_backupset(backupset_name)

  • boolean_value2 = instance.backupsets.has_backupset(backupset_name)

  • backupset1 = agent.backupsets.get(backupset_name)

  • backupset = agent.backupsets.get(backupset_name='defaultBackupSet')

  • backupset2 = instance.backupsets.get(backupset_name)

  • agent.backupsets.delete(backupset_name)

  • instance.backupsets.delete(backupset_name)

  • backupset1 = agent.backupsets.add(backupset_name)

  • backupset2 = instance.backupsets.add(backupset_name)

Client

client

Performs operations on a client

  • client.enable_backup()

  • client.enable_backup_at_time(2017-05-10 23:00:00)

  • client.disable_backup()

  • client.enable_restore()

  • client.enable_restore_at_time(2017-05-10 23:10:30)

  • client.disable_restore()

  • client.enable_data_aging()

  • client.enable_data_aging_at_time(2017-05-10 23:10:30)

  • client.disable_data_aging()

Clients

client

Performs operations on all clients

  • client = commcell.clients.get(client_name='Client001')

  • boolean_value = commcell.clients.has_client(client_name)

  • client = commcell.clients.get(client_name)

  • commcell.clients.delete(client_name)

  • vmware_client = commcell.clients.add_vmware_client(client_name, vcenter_hostname, vcenter_username, vcenter_password, clients)

ClientGroup

clientgroup

Performs operations on a client computer group

  • clientgroup.enable_backup()

  • clientgroup.enable_backup_at_time(2017-05-10 23:00:00)

  • clientgroup.disable_backup()

  • clientgroup.enable_restore()

  • clientgroup.enable_restore_at_time(2017-05-10 23:10:30)

  • clientgroup.disable_restore()

  • clientgroup.enable_data_aging()

  • clientgroup.enable_data_aging_at_time(2017-05-10 23:10:30)

  • clientgroup.disable_data_aging()

  • clientgroup.add_clients()

  • clientgroup.remove_clients()

  • clientgroup.remove_all_clients()

ClientGroups

clientgroup

Performs operations on all client computer groups

  • boolean_value = commcell.client_groups.has_clientgroup(clientgroup_name)

  • clientgroup = commcell.client_groups.get(clientgroup_name)

  • commcell.client_groups.delete(clientgroup_name)

  • clientgroup = commcell.client_groups.add(clientgroup_name, clients, clientgroup_description, enable_backup, enable_restore, enable_data_aging)

Commcell

commcell

Initializes a connection to the CommCell environment and is the wrapper for all CommCell operations

  • commcell = Commcell(client.mydomain.com, admin, 123abc)

  • commcell.logout()

CVPySDK

cvpysdk

Logs on and off of the CommCell environment and runs the HTTP request

DiskLibrary

storage

Performs operations on a disk library

Read-only attributes:

  • disk_library.library_id

  • disk_library.library_name

DiskLibraries

storage

Performs operations on all disk libraries associated with the CommCell environment

  • disk_library = commcell.disk_libraries.add(library_name='lib001', media_agent='MA0712', mount_path='C:\\Lib001', username='jsmith', password='C2#uzI8p')

  • boolean_value = commcell.disk_libraries.has_library(library_name)

  • disk_library = commcell.disk_libraries.get(library_name)

Instance

instance

Performs operations on an instance

Read-only attributes:

  • instance.instance_id

  • instance.instance_name

Instances

instance

Performs operations on all instances

  • instance = agent.instances.get(instance_name='instance001')

  • boolean_value = agent.instances.has_instance(instance_name)

Job

job

Performs operations on a job and reports the job status

  • job.pause()

  • job.resume()

  • job.kill()

  • job.status

  • job.finished

  • job.job_type

  • job.pending_reason

  • job.delay_reason

  • job.start_time

  • job.end_time

MediaAgent

storage

Performs operations on a MediaAgent

Read-only attributes:

  • media_agent.media_agent_id

  • media_agent.media_agent_name

MediaAgents

storage

Performs operations on all MediaAgents associated with the CommCell environment

  • media_agent = commcell.media_agents.get(media_agent_name='MA0712')

  • boolean_value = commcell.media_agents.has_media_agent(media_agent_name)

Schedules

schedules

Performs operations on all schedules associated with the CommCell environment

  • commcell.schedules.has_schedule(schedule_name='Data Aging')

  • print(client.schedules)

  • boolean_value = client.schedules.has_schedule(schedule_name)

  • print(agent.schedules)

  • boolean_value = agent.schedules.has_schedule(schedule_name)

  • print(backupset.schedules)

  • boolean_value = backupset.schedules.has_schedule(schedule_name)

  • print(subclient.schedules)

  • boolean_value = subclient.schedules.has_schedule(schedule_name)

SchedulePolicies

storage

Performs operations on all schedule policies associated with an entity

boolean_value = commcell.schedule_policies.has_policy(policy_name='FS_monthly')

SDKException

exception

Handles all exceptions for the CVPySDK Python package

StoragePolicies

storage

Performs operations on all storage policies associated with the CommCell environment

  • boolean_value = commcell.storage_policies.has_policy(policy_name)

  • commcell.storage_policies.delete(policy_name)

  • commcell.storage_policies.add(policy_name, library, media_agent, dedup_path, incremental_sp, retention_period)

Subclient

subclient

Performs operations on one subclient and performs operations on the subclient

  • Update Subclient Description: subclient.description = new_description

  • Update Subclient content: subclient.content = new_content

  • subclient.enable_backup()

  • subclient.enable_backup_at_time()

  • subclient.disable_backup()

  • job = subclient.backup(backup_level='Full')

  • paths, dictionary = subclient.browse(path='C:\\Users\\jsmith\\Documents', show_deleted_files=False)

  • paths, dictionary = subclient.browse_in_time(path='C:\\Users\\jsmith\\Documents', show_deleted_files=False, from_date='29/07/2016', to_date='31/12/2016')

  • paths, dictionary = subclient.find(file_or_folder_name=”setup”)

  • job = subclient.restore_in_place(paths=[“Folder1”, “Folder2”, “File1”, “File2”])

  • job = subclient.restore_out_of_place(client, destination_path, paths=[“Folder1”, “Folder2”, “File1”, “File2”])

Subclients

subclient

Performs operations on all subclients associated with a backup set

  • boolean_value1 = instance.subclients.has_subclient(subclient_name)

  • boolean_value2 = backupset.subclients.has_subclient(subclient_name)

  • subclient1 = instance.subclients.get(subclient_name)

  • subclient2 = backupset.subclients.get(subclient_name)

  • subclient = backupset.subclients.get(subclient_name='default')

  • instance.subclients.delete(subclient_name)

  • backupset.subclients.delete(subclient_name)

  • subclient1 = instance.subclients.add(subclient_name, storage_policy, description)

  • subclient2 = backupset.subclients.add(subclient_name, storage_policy, description)

UserGroup

usergroup

Performs operations on one user group

Read-only attributes:

  • usergroup.user_group_id

  • usergroup.user_group_name

  • usergroup.description

  • usergroup.email

  • usergroup.users

  • usergroup.associations

UserGroups

usergroup

Performs operations on all user groups associated with the CommCell environment

  • commcell.user_groups.delete(user_group_name='sales')

  • boolean_value = commcell.user_groups.has_user_group(usergroup_name)

  • user_group = commcell.user_groups.get(usergroup_name)

Workflow

workflow

Handles all workflows and runs workflow jobs.

  • boolean_value = commcell.workflows.has_workflow(workflow_name)

  • job = commcell.workflows.execute_workflow(workflow_name)

Loading...