コード例 #1
0
    def __init__(self, commcell_object, job_id):
        """Initialise the DR job"""
        self._replication_job_stats = None

        self._REPLICATION_STATS = commcell_object._services[
            'DR_JOB_STATS'] % job_id

        Job.__init__(self, commcell_object, job_id)
コード例 #2
0
    def _process_drbackup_response(self, flag, response):
        """DR Backup response will be processed.

            Args:
                flag, response  (str)  --  results of DR backup JSON request

            Returns:
                object - instance of the Job class for this restore job

            Raises:
                SDKException:
                    if job initialization failed

                    if response is empty

                    if response is not success
        """
        if flag:
            if response.json():
                if "jobIds" in response.json():
                    return Job(self.commcell, response.json()['jobIds'][0])
                elif "errorCode" in response.json():
                    o_str = 'Initializing backup failed\nError: "{0}"'.format(
                        response.json()['errorMessage'])
                    raise SDKException('Response', '102', o_str)
            else:
                raise SDKException('Response', '102')
        else:
            response_string = self.commcell._update_response_(response.text)
            raise SDKException('Response', '101', response_string)
コード例 #3
0
ファイル: OptionsHelper.py プロジェクト: Sowmyacv/VSACode
 def browse_from_restore_job(self, job_id):
     """
     set the Job id from which the disk restore needs to be done
     Args:
         job_id (int)    - Backup job id from disk restore needs to be done
     """
     _job = Job(self.auto_subclient.auto_subclient.commcell, job_id)
     self._start_time = _job.start_time
     self._end_time = _job.end_time
コード例 #4
0
ファイル: OptionsHelper.py プロジェクト: Sowmyacv/VSACode
 def restore_backup_job(self, job_id):
     self._restore_backup_job = Job(
         self.auto_subclient.auto_commcell.commcell, job_id)
     self.advanced_restore_options['from_time'] = str(
         datetime.strftime(
             datetime.strptime(self._restore_backup_job.start_time,
                               "%a %b %d %H:%M:%S %Y"),
             "%Y-%m-%d %H:%M:%S"))
     self.advanced_restore_options['to_time'] = str(
         datetime.strftime(
             datetime.strptime(self._restore_backup_job.end_time,
                               "%a %b %d %H:%M:%S %Y"),
             "%Y-%m-%d %H:%M:%S"))
コード例 #5
0
ファイル: teams_instance.py プロジェクト: Commvault/cvpysdk
    def restore_out_of_place(self, source_team, destination_team):
        """Restore a team to another location.

            Args:
                source_team         (str)   --  The email ID of the team that needs to be restored.
                destination_team    (str)   --  The email ID of the team to be restored to.

            Returns:
                obj   --  Instance of Restore job.

            Raises:
                SDKException:
                    If restore failed to run.
                    If response is empty.
                    If response is not success.

        """

        discovered_teams = self.discover()
        source_team = discovered_teams[source_team]
        destination_team = discovered_teams[destination_team]

        request_json = self._restore_json()
        request_json['taskInfo']['subTasks'][0]['options']['restoreOptions']['destination']['inPlace'] = False
        request_json['taskInfo']['subTasks'][0]['options']['restoreOptions']['cloudAppsRestoreOptions'] = self._cloud_apps_restore_json(source_team=source_team, destination_team=destination_team)

        url = self._services['CREATE_TASK']

        flag, response = self._cvpysdk_object.make_request('POST', url, request_json)

        if flag:

            if response.json():

                if 'jobIds' in response.json():
                    return Job(self._commcell_object, response.json()['jobIds'][0])

                elif "errorCode" in response.json():
                    error_message = response.json()['errorMessage']
                    raise SDKException('Subclient', '102', f"Restore failed, error message : {error_message}")

                raise SDKException('Response', '102')

            response_string = self._commcell_object._update_response_(response.text)
            raise SDKException('Response', '101', response_string)
コード例 #6
0
    def _process_createtask_response(self, request_json):
        """Runs the CreateTask API with the request JSON provided for DR backup,
            and returns the contents after parsing the response.

            Args:
                request_json    (dict)  --  JSON request to run for the API

            Returns:
                object - instance of the Job class for this restore job

            Raises:
                SDKException:
                    if restore job failed

                    if response is empty

                    if response is not success
        """
        flag, response = self.commcell._cvpysdk_object.make_request(
            'POST', self._CREATE_TASK, request_json)
        if flag:
            if response.json():
                if "jobIds" in response.json():
                    return Job(self.commcell, response.json()['jobIds'][0])
                elif "errorCode" in response.json():
                    error_message = response.json()['errorMessage']

                    o_str = 'DR backup job failed\nError: "{0}"'.format(
                        error_message)
                    raise SDKException('Response', '102', o_str)
                else:
                    raise SDKException('Response', '102',
                                       'Failed to run the DR backup job')
            else:
                raise SDKException('Response', '102')
        else:
            response_string = self.commcell._update_response_(response.text)
            raise SDKException('Response', '101', response_string)
コード例 #7
0
ファイル: teams_subclient.py プロジェクト: Commvault/cvpysdk
    def backup(self, teams):
        """Run an Incremental backup.
            Args:
                teams               (list)  --  List of team Email IDs.

            Returns:
                obj   --  Instance of job.

            Raises:
                SDKException:

                    If backup failed to run.
                    If response is empty.
                    If response is not success.

        """

        discovered_teams = self._instance_object.discover()
        teams = [discovered_teams[team] for team in teams]

        url = self._services['CREATE_TASK']

        team_json_list = []

        for team in teams:

            team_json = copy(const.BACKUP_TEAM_JSON)
            team_json['displayName'] = team['displayName']
            team_json['smtpAddress'] = team['smtpAddress']
            team_json['msTeamsInfo']['teamsCreatedTime'] = team['msTeamsInfo'][
                'teamsCreatedTime']
            team_json['user'] = {"userGUID": team['user']['userGUID']}
            team_json_list.append(team_json)

        associations = copy(const.ASSOCIATIONS)
        associations["subclientId"] = int(self._subClientEntity['subclientId'])
        associations["applicationId"] = int(
            self._subClientEntity['applicationId'])
        associations["clientName"] = self._subClientEntity['clientName']
        associations["displayName"] = self._subClientEntity['displayName']
        associations["backupsetId"] = self._subClientEntity['backupsetId']
        associations["instanceId"] = self._subClientEntity['instanceId']
        associations["subclientGUID"] = self.subclient_guid
        associations["clientId"] = int(self._client_object.client_id)
        associations["clientGUID"] = self._client_object.client_guid
        associations["subclientName"] = self.subclient_name
        associations["backupsetName"] = self._subClientEntity['backupsetName']
        associations["instanceName"] = self._subClientEntity['instanceName']
        associations["_type_"] = self._subClientEntity['_type_']

        backup_subtask_json = copy(const.BACKUP_SUBTASK_JSON)
        backup_subtask_json['options']['backupOpts']['cloudAppOptions'][
            'userAccounts'] = team_json_list

        request_json = deepcopy(const.BACKUP_REQUEST_JSON)
        request_json['taskInfo']['associations'].append(associations)
        request_json['taskInfo']['subTasks'].append(backup_subtask_json)

        flag, response = self._cvpysdk_object.make_request(
            'POST', url, request_json)

        if flag:

            if response.json():

                if 'jobIds' in response.json():
                    return Job(self._commcell_object,
                               response.json()['jobIds'][0])

                elif "errorCode" in response.json():
                    error_message = response.json()['errorMessage']
                    raise SDKException(
                        'Subclient', '102',
                        f"Backup failed, error message : {error_message}")

            else:
                raise SDKException('Response', '102')

        else:
            response_string = self._commcell_object._update_response_(
                response.text)
            raise SDKException('Response', '101', response_string)
コード例 #8
0
    def create_replica_copy(self,
                            destination_volumes,
                            copy_volumes,
                            timestamp=None):
        """Perform the DR operation for the BLR pair
            Args:
                destination_volumes (list)  : The destination volumes list
                copy_volumes (list)         : The copy volumes list
                timestamp (int)             : The timestamp of the RPstore, only for granular pairs
            Returns:

            Raises:
            SDKException:
            if response is empty
            if response is not success
        """
        restore_point = None
        if self.pair_recovery_type == BLRPairs.RecoveryType.GRANULARV2:
            if timestamp is not None:
                restore_point = [
                    replica_point
                    for replica_point in self.get_recovery_point_stores()
                    if int(replica_point['timeStamp']) == timestamp
                ][0]
            else:
                restore_point = self.get_recovery_point_stores()[-1]

        destination_client = self._commcell_object.clients.get(
            int(self.destination['client_id']))
        destination_volumes = destination_client.get_mount_volumes(
            destination_volumes)
        copy_volumes = destination_client.get_mount_volumes(copy_volumes)

        request_json = {
            "taskInfo": {
                "task": {
                    "ownerId": 1,
                    "taskType": 1,
                    "ownerName": "",
                    "initiatedFrom": 1,
                    "taskFlags": {
                        "disabled": False
                    }
                },
                "subTasks": [{
                    "subTaskOperation": 1,
                    "subTask": {
                        "subTaskType": 1,
                        "operationType": 4047
                    },
                    "options": {
                        "backupOpts": {
                            "mediaOpt": {
                                "auxcopyJobOption": {
                                    "maxNumberOfStreams": 0,
                                    "allCopies": True,
                                    "useMaximumStreams": True,
                                    "useScallableResourceManagement": False
                                }
                            }
                        },
                        "adminOpts": {
                            "blockOperation": {
                                "operations": [{
                                    "appId":
                                    int(self.subclient_props['subclientId']),
                                    "opType":
                                    8,
                                    "dstProxyClientId":
                                    int(self.destination['client_id']),
                                    "fsMountInfo": {
                                        "doLiveMount":
                                        True,
                                        "lifeTimeInSec":
                                        7200,
                                        "blrPairId":
                                        int(self._pair_id),
                                        "mountPathPairs": [{
                                            "mountPath":
                                            copy['accessPathList'][0],
                                            "srcPath":
                                            destination['accessPathList'][0],
                                            "srcGuid":
                                            destination['guid'],
                                            "dstGuid":
                                            copy['guid']
                                        } for destination, copy in zip(
                                            destination_volumes, copy_volumes)
                                                           ],
                                        "rp": {
                                            "timeStamp":
                                            int(restore_point['timeStamp']),
                                            "sequenceNumber":
                                            int(restore_point['sequenceNumber']
                                                ),
                                            "rpType":
                                            1,
                                            "appConsistent":
                                            False,
                                            "dataChangedSize":
                                            int(restore_point[
                                                'dataChangedSize'])
                                        }
                                        if restore_point is not None else None
                                    }
                                }]
                            }
                        },
                    }
                }]
            }
        }
        if restore_point is None:
            admin_opts = request_json['taskInfo']['subTasks'][0]['options'][
                'adminOpts']
            del admin_opts['blockOperation']['operations'][0]['fsMountInfo'][
                'rp']

        flag, response = self._commcell_object._cvpysdk_object.make_request(
            'POST', self._services['RESTORE'], request_json)
        if flag:
            if response.json():
                if "jobIds" in response.json():
                    return Job(self._commcell_object,
                               response.json()['jobIds'][0])

                elif "taskId" in response.json():
                    return Schedules(self._commcell_object).get(
                        task_id=response.json()['taskId'])

                elif "errorCode" in response.json():
                    error_message = response.json()['errorMessage']

                    o_str = 'Restore job failed\nError: "{0}"'.format(
                        error_message)
                    raise SDKException('Job', '102', o_str)
                else:
                    raise SDKException('Job', '102',
                                       'Failed to run the restore job')
            else:
                raise SDKException('Response', '102')
        else:
            response_string = self._commcell_object._update_response_(
                response.text)
            raise SDKException('Response', '101', response_string)
コード例 #9
0
 def _initialize_job_properties(self):
     """Initialises the job properties and then initialises the DR job details"""
     Job._initialize_job_properties(self)
     self._replication_job_stats = self._get_replication_job_stats()
コード例 #10
0
 def BrowseFromRestoreJob(self, job_id):
     _job = Job(self.auto_subclient.auto_subclient.commcell, job_id)
     self._start_time = _job.start_time
     self._end_time = _job.end_time