Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, commcell):
"""Initializes DisasterRecovery object
Args:
commcell (object) -- instance of commcell
"""
self.commcell = commcell
self.client = Client(self.commcell, self.commcell.commserv_name)
self.path = self.client.install_directory
self._RESTORE = self.commcell._services['RESTORE']
self._CREATE_TASK = self.commcell._services['CREATE_TASK']
self.advbackup = False
self._disaster_recovery_management = None
self.reset_to_defaults()
if failed to initialize job
if response is empty
if response is not success
"""
from cvpysdk.client import Client
if not ((isinstance(client, basestring) or isinstance(client, Client)) and
isinstance(destination_path, basestring) and
isinstance(paths, list) and
isinstance(overwrite, bool) and
isinstance(restore_data_and_acl, bool)):
raise SDKException('Subclient', '101')
if isinstance(client, Client):
client = client
elif isinstance(client, basestring):
client = Client(self._commcell_object, client)
else:
raise SDKException('Subclient', '105')
paths = self._filter_paths(paths)
destination_path = self._filter_paths([destination_path], True)
if paths == []:
raise SDKException('Subclient', '104')
request_json = self._restore_json(
paths=paths,
in_place=False,
"""Returns the index server client set for the subclient. None if no Index Server is set"""
if 'indexSettings' not in self._commonProperties:
return None
index_settings = self._commonProperties['indexSettings']
index_server = None
if ('currentIndexServer' in index_settings and
'clientName' in index_settings['currentIndexServer']):
index_server = index_settings['currentIndexServer']['clientName']
if index_server is None:
return None
return Client(self._commcell_object, client_name=index_server)
client_from_hostname = self._get_client_from_hostname(name)
elif self.has_hidden_client(name):
client_from_hostname = self._get_hidden_client_from_hostname(name)
else:
raise SDKException(
'Client', '102', 'No client exists with given name/hostname: {0}'.format(name)
)
client_name = name if client_from_hostname is None else client_from_hostname
try:
client_id = self.all_clients[client_name]['id']
except KeyError:
client_id = self.hidden_clients[client_name]['id']
return Client(self._commcell_object, client_name, client_id)
elif isinstance(name, int):
name = str(name)
client_name = [client_name for client_name in self.all_clients
if name in self.all_clients[client_name].values()]
if client_name:
return self.get(client_name[0])
raise SDKException('Client', '102', 'No client exists with the given ID: {0}'.format(name))
raise SDKException('Client', '101')
Args:
class_object (object) -- instance of the client/commcell class
"""
from .commcell import Commcell
from .client import Client
if isinstance(class_object, Commcell):
self._commcell_object = class_object
self._display_name = self._commcell_object.clients.get(self._commcell_object.
commserv_hostname).display_name
self._commcell_name = self._commcell_object.clients.get(self._commcell_object.
commserv_hostname).commcell_name
self._is_client = False
elif isinstance(class_object, Client):
self._client_object = class_object
self._commcell_object = class_object._commcell_object
self._client_hostname = self._client_object.client_hostname
self._display_name = self._client_object.display_name
self._client_name = self._client_object.client_name
self._commcell_name = self._client_object.commcell_name
self._new_name = None
self._is_client = True
self._cvpysdk_object = self._commcell_object._cvpysdk_object
self._services = self._commcell_object._services
self._update_response_ = self._commcell_object._update_response_
if destination backupset does not exist
if user does not provide staging database details
"""
file_restore_option = {}
if sf_options is None:
sf_options = {}
# check if client name is correct
if destination_client is None:
destination_client = self._backupset_object._agent_object._client_object
if isinstance(destination_client, Client):
dest_client = destination_client
elif isinstance(destination_client, basestring):
dest_client = Client(self._commcell_object, destination_client)
else:
raise SDKException('Subclient', '105')
dest_agent = Agent(dest_client, 'Cloud Apps')
# check if instance name is correct
if destination_instance is None:
destination_instance = self._backupset_object._instance_object
if isinstance(destination_instance, Instance):
dest_instance = destination_instance
elif isinstance(destination_instance, basestring):
dest_instance = dest_agent.instances.get(destination_instance)
SDKException:
if client is not a string or Client instance
if destination_path is not a string
if paths is not a list
if failed to initialize job
if response is empty
if response is not success
"""
self._backupset_object._instance_object._restore_association = self._subClientEntity
if not isinstance(client, (basestring, Client)):
raise SDKException('Subclient', '101')
if isinstance(client, basestring):
client = Client(self._commcell_object, client)
if fs_options is not None and fs_options.get('no_of_streams', 1) > 1 and not fs_options.get('destination_appTypeId', False):
fs_options['destination_appTypeId'] = int(client.agents.all_agents.get('file system', client.agents.all_agents.get('windows file system', client.agents.all_agents.get('linux file system', client.agents.all_agents.get('big data apps', client.agents.all_agents.get('cloud apps'))))))
if not fs_options['destination_appTypeId']:
del fs_options['destination_appTypeId']
# check to find whether file level Restore/ Volume level restore for blocklevel.
if fs_options is not None and fs_options.get('is_vlr_restore', False):
if not (isinstance(paths, list) and
isinstance(overwrite, bool) and
isinstance(restore_data_and_acl, bool)):
if destination instance does not exist on commcell
"""
if sap_options is None:
sap_options = {}
# check if client name is correct
if destination_client is None:
destination_client = self._agent_object._client_object.client_name
if isinstance(destination_client, Client):
destination_client = destination_client
elif isinstance(destination_client, str):
destination_client = Client(self._commcell_object, destination_client)
#print(destination_client)
else:
raise SDKException('Instance', '101')
dest_agent = Agent(destination_client, 'sap for oracle','61')
# check if instance name is correct
if destination_instance is None:
destination_instance = self.instance_name
if isinstance(destination_instance, Instance):
destination_instance = destination_instance
elif isinstance(destination_instance, str):
destination_instance = dest_agent.instances.get(destination_instance)
else:
raise SDKException('Instance', '101')
"""
file_restore_option = {}
if sf_options is None:
sf_options = {}
# check if client name is correct
if destination_client is None:
destination_client = self._backupset_object._instance_object.proxy_client
if isinstance(destination_client, Client):
client = destination_client
elif isinstance(destination_client, basestring):
client = Client(self._commcell_object, destination_client)
else:
raise SDKException('Subclient', '105')
file_restore_option["client_name"] = client.client_name
file_restore_option["destination_path"] = sf_options.get(
"destination_path", self._backupset_object.download_cache_path
)
self._restore_destination_json(file_restore_option)
# process the objects to restore
if isinstance(objects_to_restore, list):
objects_to_restore_list = objects_to_restore
else:
objects_to_restore_list = [objects_to_restore]