def ex_get_target_by_source(self, source): return BackupTarget(id=source, name=source, address=source, type=BackupTargetType.VOLUME, driver=self.connection.driver, extra={"source": source})
def ex_get_target_by_volume_id(self, volume_id): return BackupTarget(id=volume_id, name=volume_id, address=volume_id, type=BackupTargetType.VOLUME, driver=self.connection.driver, extra={"volume-id": volume_id})
def create_target(self, name, address, type=BackupTargetType.VIRTUAL, extra=None): """ Creates a new backup target :param name: Name of the target (not used) :type name: ``str`` :param address: The ID of the node in Dimension Data Cloud :type address: ``str`` :param type: Backup target type, only Virtual supported :type type: :class:`BackupTargetType` :param extra: (optional) Extra attributes (driver specific). :type extra: ``dict`` :rtype: Instance of :class:`BackupTarget` """ if extra is not None: service_plan = extra.get('servicePlan', DEFAULT_BACKUP_PLAN) else: service_plan = DEFAULT_BACKUP_PLAN extra = {'servicePlan': service_plan} create_node = ET.Element('NewBackup', {'xmlns': BACKUP_NS}) create_node.set('servicePlan', service_plan) response = self.connection.request_with_orgId_api_1( 'server/%s/backup' % (address), method='POST', data=ET.tostring(create_node)).object asset_id = None for info in findall(response, 'additionalInformation', GENERAL_NS): if info.get('name') == 'assetId': asset_id = findtext(info, 'value', GENERAL_NS) return BackupTarget( id=asset_id, name=name, address=address, type=type, extra=extra, driver=self )
def _to_target(self, element): backup = findall(element, 'backup', TYPES_URN) if len(backup) == 0: return extra = { 'description': findtext(element, 'description', TYPES_URN), 'sourceImageId': findtext(element, 'sourceImageId', TYPES_URN), 'datacenterId': element.get('datacenterId'), 'deployedTime': findtext(element, 'createTime', TYPES_URN), 'servicePlan': backup[0].get('servicePlan') } n = BackupTarget(id=backup[0].get('assetId'), name=findtext(element, 'name', TYPES_URN), address=element.get('id'), driver=self.connection.driver, type=BackupTargetType.VIRTUAL, extra=extra) return n
def _to_target(self, element): backup = findall(element, "backup", TYPES_URN) if len(backup) == 0: return extra = { "description": findtext(element, "description", TYPES_URN), "sourceImageId": findtext(element, "sourceImageId", TYPES_URN), "datacenterId": element.get("datacenterId"), "deployedTime": findtext(element, "createTime", TYPES_URN), "servicePlan": backup[0].get("servicePlan"), } n = BackupTarget( id=backup[0].get("assetId"), name=findtext(element, "name", TYPES_URN), address=element.get("id"), driver=self.connection.driver, type=BackupTargetType.VIRTUAL, extra=extra, ) return n