libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [3/4] libcloud git commit: Removal of client
Date Sun, 14 Feb 2016 02:45:13 GMT
Removal of client


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/a42e0f64
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/a42e0f64
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/a42e0f64

Branch: refs/heads/trunk
Commit: a42e0f649237b73ef25663e86eff67c6a196fd0d
Parents: 2bca79b
Author: Jeffrey Dunham <jeffrey.a.dunham@gmail.com>
Authored: Thu Feb 11 13:48:45 2016 -0500
Committer: anthony-shaw <anthony.p.shaw@gmail.com>
Committed: Sun Feb 14 13:44:39 2016 +1100

----------------------------------------------------------------------
 libcloud/backup/drivers/dimensiondata.py | 58 ++++++++++++++++++++++-----
 1 file changed, 49 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a42e0f64/libcloud/backup/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/backup/drivers/dimensiondata.py b/libcloud/backup/drivers/dimensiondata.py
index c634a70..6c30d36 100644
--- a/libcloud/backup/drivers/dimensiondata.py
+++ b/libcloud/backup/drivers/dimensiondata.py
@@ -215,12 +215,13 @@ class DimensionDataBackupDriver(BackupDriver):
         Delete a backup target
 
         :param target: Backup target to delete
-        :type  target: Instance of :class:`BackupTarget`
+        :type  target: Instance of :class:`BackupTarget` or ``str``
 
         :rtype: ``bool``
         """
+        address = self._target_to_target_address(target)
         response = self.connection.request_with_orgId_api_1(
-            'server/%s/backup?disable' % (target.address),
+            'server/%s/backup?disable' % (address),
             method='GET').object
         response_code = findtext(response, 'result', GENERAL_NS)
         return response_code in ['IN_PROGRESS', 'SUCCESS']
@@ -401,10 +402,7 @@ class DimensionDataBackupDriver(BackupDriver):
         :rtype: ``bool``
         """
 
-        if isinstance(target, BackupTarget):
-            server_id = target.address
-        else:
-            server_id = target
+        server_id = self._target_to_target_address(target)
 
         backup_elm = ET.Element('NewBackupClient',
                                 {'xmlns': BACKUP_NS})
@@ -438,14 +436,34 @@ class DimensionDataBackupDriver(BackupDriver):
         response_code = findtext(response, 'result', GENERAL_NS)
         return response_code in ['IN_PROGRESS', 'SUCCESS']
 
+    def ex_remove_client_from_target(self, target, backup_client):
+        """
+        Removes a client from a backup target
+
+        :param  target: The backup target to remove the client from
+        :type   target: :class:`BackupTarget` or ``str``
+
+        :param  backup_client: The backup client to remove
+        :type   backup_client: :class:`DimensionDataBackupClient` or ``str``
+
+        :rtype: ``bool``
+        """
+        server_id = self._target_to_target_address(target)
+        client_id = self._client_to_client_id(backup_client)
+        response = self.connection.request_with_orgId_api_1(
+            'server/%s/backup/client/%s?disable' % (server_id, client_id),
+            method='GET').object
+        response_code = findtext(response, 'result', GENERAL_NS)
+        return response_code in ['IN_PROGRESS', 'SUCCESS']
+
     def ex_get_backup_details_for_target(self, target):
         """
-        Returns a list of available backup client types
+        Returns a backup details object for a target
 
-        :param  target: The backup target to list available types for
+        :param  target: The backup target to get details for
         :type   target: :class:`BackupTarget` or ``str``
 
-        :rtype: ``list`` of :class:`DimensionDataBackupDetails`
+        :rtype: :class:`DimensionDataBackupDetails`
         """
 
         if isinstance(target, BackupTarget):
@@ -609,3 +627,25 @@ class DimensionDataBackupDriver(BackupDriver):
                          type=BackupTargetType.VIRTUAL,
                          extra=extra)
         return n
+
+    @staticmethod
+    def _client_to_client_id(backup_client):
+        if isinstance(backup_client, DimensionDataBackupClient):
+            return backup_client.id
+        elif isinstance(backup_client, basestring):
+            return backup_client
+        else:
+            raise TypeError(
+                "Invalid backup_client type for _client_to_client_id()"
+            )
+
+    @staticmethod
+    def _target_to_target_address(target):
+        if isinstance(target, BackupTarget):
+            return target.address
+        elif isinstance(target, basestring):
+            return target
+        else:
+            raise TypeError(
+                "Invalid target type for _target_to_target_address()"
+            )


Mime
View raw message