Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __new__(cls, instance_object, backupset_name, backupset_id=None):
"""Decides which instance object needs to be created"""
instance_name = instance_object.instance_name
instance_name = re.sub('[^A-Za-z0-9_]+', '', instance_name.replace(" ", "_"))
try:
backupset_module = import_module("cvpysdk.backupsets._virtual_server.{}".format(instance_name))
except ImportError:
return object.__new__(cls)
classes = getmembers(backupset_module, lambda m: isclass(m) and not isabstract(m))
for name, _class in classes:
if issubclass(_class, Backupset) and _class.__module__.rsplit(".", 1)[-1] == instance_name:
return object.__new__(_class)
#. Add the import statement inside the __new__ method.
**NOTE:** If you add the import statement at the top,
it'll cause cyclic import, and the call will fail
#. After adding the import statement:
- In the **instance_type** dict
- Add the cloud apps instance type as the key, and the class as its value
"""
from __future__ import unicode_literals
from ..backupset import Backupset
class CloudAppsBackupset(Backupset):
"""Class for representing a Backupset of the Cloud Apps agent."""
def __new__(cls, instance_object, backupset_name, backupset_id=None):
from .cloudapps.salesforce_backupset import SalesforceBackupset
instance_types = {
3: SalesforceBackupset
}
cloud_apps_instance_type = instance_object._properties['cloudAppsInstance']['instanceType']
if cloud_apps_instance_type in instance_types:
instance_type = instance_types[cloud_apps_instance_type]
else:
instance_type = cls
backupset_name = backupset_name.lower()
if self.has_backupset(backupset_name):
if self._instance_object is None:
self._instance_object = self._agent_object.instances.get(
self._backupsets[backupset_name]['instance']
)
if self._agent_object.agent_name in self._backupsets_dict.keys():
return self._backupsets_dict[self._agent_object.agent_name](
self._instance_object,
backupset_name,
self._backupsets[backupset_name]["id"]
)
else:
return Backupset(
self._instance_object,
backupset_name,
self._backupsets[backupset_name]["id"]
)
raise SDKException(
'Backupset', '102', 'No backupset exists with name: "{0}"'.format(backupset_name)
)
restore_entire_database() -- runs the restore job for specified backupset
DB2Backupset instance Attributes:
=================================
**db2_db_status** -- returns db2 database status
"""
from __future__ import unicode_literals
from ..backupset import Backupset
class DB2Backupset(Backupset):
"""Derived class from Backupset Base class, representing a db2 backupset,
and to perform operations on that backupset."""
@property
def db2_db_status(self):
"""
returns db2 database status
Returns:
(str) -- Status of db as connected or disconnected
"""
return self._properties.get('db2BackupSet', {}).get('dB2DBStatus', "")
def restore_entire_database(
self,
HANABackupset:
restore() -- runs the restore job for specified backupset
"""
from __future__ import absolute_import
from __future__ import unicode_literals
from past.builtins import basestring
from ..backupset import Backupset
from ..exception import SDKException
class HANABackupset(Backupset):
"""Derived class from Backupset Base class, representing a SAP HANA backupset,
and to perform operations on that backupset.
"""
def restore(
self,
pseudo_client,
instance,
backup_prefix=None,
point_in_time=None,
initialize_log_area=False,
use_hardware_revert=False,
clone_env=False,
check_access=True,
destination_instance_dir=None,
ignore_delta_backups=True):
Usage
=====
Limitation:
* current , update subclient content failed. this is limitation in sp12.will tyr in sp13
"""
from __future__ import unicode_literals
from ..backupset import Backupset
from ..exception import SDKException
class ADBackupset(Backupset):
""" AD agent backupset class """
def check_subclient(self,
backupset_ins,
subclientname,
storagepolicy=None,
subclientcontent=None,
deleteexist=False):
"""check if the subclient exsit, will create new one if not found
Args:
backupset_ins (instance) inherite backupset instance
subclientname (string) subclient name
The Virtual Server 'Hyper-V' is named as 'hyperv.py'
"""
from __future__ import unicode_literals
import re
import time
from importlib import import_module
from inspect import isabstract, isclass, getmembers
from ..backupset import Backupset
from ..exception import SDKException
class VSBackupset(Backupset):
"""Derived class from Backupset Base class, representing a vs backupset,
and to perform operations on that backupset."""
def __new__(cls, instance_object, backupset_name, backupset_id=None):
"""Decides which instance object needs to be created"""
instance_name = instance_object.instance_name
instance_name = re.sub('[^A-Za-z0-9_]+', '', instance_name.replace(" ", "_"))
try:
backupset_module = import_module("cvpysdk.backupsets._virtual_server.{}".format(instance_name))
except ImportError:
return object.__new__(cls)
classes = getmembers(backupset_module, lambda m: isclass(m) and not isabstract(m))
for name, _class in classes:
create_granular_replica_copy() -- Triggers Granular replication permanent mount
"""
from __future__ import unicode_literals
from past.builtins import basestring
from ..backupset import Backupset
from ..client import Client
from ..exception import SDKException
from ..job import Job
from ..schedules import Schedules
class FSBackupset(Backupset):
"""Derived class from Backupset Base class, representing a fs backupset,
and to perform operations on that backupset."""
def restore_in_place(
self,
paths,
overwrite=True,
restore_data_and_acl=True,
copy_precedence=None,
from_time=None,
to_time=None,
fs_options=None,
restore_jobs=None
):
"""Restores the files/folders specified in the input paths list to the same location.