Beispiel #1
0
    def delete_snapshot(self,
                        volume_name,
                        snapshot_name,
                        recursively_children=False,
                        recursively_dependents=False,
                        force_umount=False):
        """delete_snapshot.

        DELETE /volumes/<string:volumename>/snapshots/
            <string:snapshotname>
        :param volume_name: volume that snapshot belongs to
        :param snapshot_name: snapshot name
        :param recursively_children: boolean indicating if zfs should
            recursively destroy all children of resource, in case of snapshot
            remove all snapshots in descendant file system (default false).
        :param recursively_dependents: boolean indicating if zfs should
            recursively destroy all dependents, including cloned file systems
            outside the target hierarchy (default false).
        :param force_umount: boolean indicating if volume should be forced to
            umount (defualt false).
        :return:
        """

        req = '/volumes/%(vol)s/snapshots/%(snap)s' % {
            'vol': volume_name,
            'snap': snapshot_name}
        LOG.debug("delete snapshot %(snap)s of volume %(vol)s",
                  {'snap': snapshot_name,
                   'vol': volume_name})

        jbody = {}
        if recursively_children:
            jbody['recursively_children'] = True

        if recursively_dependents:
            jbody['recursively_dependents'] = True

        if force_umount:
            jbody['force_umount'] = True

        resp = dict()
        if len(jbody) > 0:
            resp = self.rproxy.pool_request('DELETE', req, json_data=jbody)
        else:
            resp = self.rproxy.pool_request('DELETE', req)

        if resp["code"] in (200, 201, 204):
            LOG.debug("snapshot %s deleted", snapshot_name)
            return

        if resp["code"] == 500:
            if resp["error"]:
                if resp["error"]["errno"] == 1000:
                    raise jexc.JDSSSnapshotIsBusyException(
                        snapshot=snapshot_name)
        self._general_error(req, resp)
Beispiel #2
0
    def test_clone_object_exists(self):
        jdssd, ctx = self.get_driver(CONFIG_OK)

        origin = jcom.vname(UUID_1)
        clone = jcom.vname(UUID_2)

        jdssd.ra.create_snapshot.side_effect = (
            jexc.JDSSSnapshotExistsException(snapshot=clone))

        jdssd.ra.delete_snapshot.side_effect = (
            jexc.JDSSSnapshotIsBusyException(snapshot=clone))

        self.assertRaises(exception.Duplicate, jdssd._clone_object, origin,
                          clone)
        jdssd.ra.delete_snapshot.assert_called_once_with(origin, clone)
        jdssd.ra.create_snapshot.assert_called_once_with(origin, clone)
Beispiel #3
0
def get_jdss_exceptions():

    out = [
        jexc.JDSSException(reason="Testing"),
        jexc.JDSSRESTException(request="ra request", reason="Testing"),
        jexc.JDSSRESTProxyException(host="test_host", reason="Testing"),
        jexc.JDSSResourceNotFoundException(res="test_resource"),
        jexc.JDSSVolumeNotFoundException(volume="test_volume"),
        jexc.JDSSSnapshotNotFoundException(snapshot="test_snapshot"),
        jexc.JDSSResourceExistsException(res="test_resource"),
        jexc.JDSSSnapshotExistsException(snapshot="test_snapshot"),
        jexc.JDSSVolumeExistsException(volume="test_volume"),
        jexc.JDSSSnapshotIsBusyException(snapshot="test_snapshot")
    ]

    return out