def wrapper(self, context, group, *args, **kwargs):
     if not utils.is_group_a_cg_snapshot_type(group):
         msg = _("%s, the group or group snapshot is not cg or "
                 "cg_snapshot") % func.__name__
         LOG.debug(msg)
         raise NotImplementedError(msg)
     return func(self, context, group, *args, **kwargs)
예제 #2
0
 def test_is_group_a_cg_snapshot_type_is_false(self, spec_value):
     with mock.patch('cinder.volume.group_types'
                     '.get_group_type_specs') as mock_get_specs:
         mock_get_specs.return_value = spec_value
         group = fake_group.fake_group_obj(
             None, group_type_id=fake.GROUP_TYPE_ID)
         self.assertFalse(volume_utils.is_group_a_cg_snapshot_type(group))
예제 #3
0
파일: infinidat.py 프로젝트: mahak/cinder
    def create_group_from_src(self, context, group, volumes,
                              group_snapshot=None, snapshots=None,
                              source_group=None, source_vols=None):
        """Creates a group from source."""
        # The source is either group_snapshot+snapshots or
        # source_group+source_vols. The target is group+voluems
        # we assume the source (source_vols / snapshots) are in the same
        # order as the target (volumes)

        # let generic volume group support handle non-cgsnapshots
        if not vol_utils.is_group_a_cg_snapshot_type(group):
            raise NotImplementedError()
        self.create_group(context, group)
        new_infinidat_group = self._get_infinidat_cg(group)
        if group_snapshot is not None and snapshots is not None:
            for volume, snapshot in zip(volumes, snapshots):
                self.create_volume_from_snapshot(volume, snapshot)
                new_infinidat_volume = self._get_infinidat_volume(volume)
                new_infinidat_group.add_member(new_infinidat_volume)
        elif source_group is not None and source_vols is not None:
            for volume, src_vol in zip(volumes, source_vols):
                self.create_cloned_volume(volume, src_vol)
                new_infinidat_volume = self._get_infinidat_volume(volume)
                new_infinidat_group.add_member(new_infinidat_volume)
        return None, None
예제 #4
0
 def wrapper(self, context, group, *args, **kwargs):
     if not utils.is_group_a_cg_snapshot_type(group):
         msg = _("%s, the group or group snapshot is not cg or "
                 "cg_snapshot") % func.__name__
         LOG.debug(msg)
         raise NotImplementedError(msg)
     return func(self, context, group, *args, **kwargs)
예제 #5
0
    def create_group_snapshot(self, context, group_snapshot, snapshots):
        """Creates a Cinder group snapshot object.

        The Cinder group snapshot object is created by making use of an ONTAP
        consistency group snapshot in order to provide write-order consistency
        for a set of flexvols snapshots. First, a list of the flexvols backing
        the given Cinder group must be gathered. An ONTAP group-snapshot of
        these flexvols will create a snapshot copy of all the Cinder volumes in
        the generic volume group. For each Cinder volume in the group, it is
        then necessary to clone its backing file from the ONTAP cg-snapshot.
        The naming convention used to for the clones is what indicates the
        clone's role as a Cinder snapshot and its inclusion in a Cinder group.
        The ONTAP cg-snapshot of the flexvols is deleted after the cloning
        operation is completed.

        :returns: An implicit update for the group snapshot and snapshot models
                 that is then used by the manager to set the models to
                 available.
        """
        try:
            if volume_utils.is_group_a_cg_snapshot_type(group_snapshot):
                self._create_consistent_group_snapshot(group_snapshot,
                                                       snapshots)
            else:
                for snapshot in snapshots:
                    self._clone_backing_file_for_volume(
                        snapshot['volume_name'], snapshot['name'],
                        snapshot['volume_id'], is_snapshot=True)
        except Exception as ex:
            err_msg = (_("Create group snapshot failed (%s).") % ex)
            LOG.exception(err_msg, resource=group_snapshot)
            raise exception.NetAppDriverException(err_msg)

        return None, None
예제 #6
0
    def create_group_snapshot(self, context, group_snapshot, snapshots):
        """Creates a Cinder group snapshot object.

        The Cinder group snapshot object is created by making use of an ONTAP
        consistency group snapshot in order to provide write-order consistency
        for a set of flexvols snapshots. First, a list of the flexvols backing
        the given Cinder group must be gathered. An ONTAP group-snapshot of
        these flexvols will create a snapshot copy of all the Cinder volumes in
        the generic volume group. For each Cinder volume in the group, it is
        then necessary to clone its backing file from the ONTAP cg-snapshot.
        The naming convention used to for the clones is what indicates the
        clone's role as a Cinder snapshot and its inclusion in a Cinder group.
        The ONTAP cg-snapshot of the flexvols is deleted after the cloning
        operation is completed.

        :returns: An implicit update for the group snapshot and snapshot models
                 that is then used by the manager to set the models to
                 available.
        """
        try:
            if volume_utils.is_group_a_cg_snapshot_type(group_snapshot):
                self._create_consistent_group_snapshot(group_snapshot,
                                                       snapshots)
            else:
                for snapshot in snapshots:
                    self._clone_backing_file_for_volume(
                        snapshot['volume_name'], snapshot['name'],
                        snapshot['volume_id'], is_snapshot=True)
        except Exception as ex:
            err_msg = (_("Create group snapshot failed (%s).") % ex)
            LOG.exception(err_msg, resource=group_snapshot)
            raise exception.NetAppDriverException(err_msg)

        return None, None
예제 #7
0
    def create_group_from_src(self,
                              context,
                              group,
                              volumes,
                              group_snapshot=None,
                              snapshots=None,
                              source_group=None,
                              source_vols=None):
        """Creates a group from source."""
        # The source is either group_snapshot+snapshots or
        # source_group+source_vols. The target is group+voluems
        # we assume the source (source_vols / snapshots) are in the same
        # order as the target (volumes)

        # let generic volume group support handle non-cgsnapshots
        if not vol_utils.is_group_a_cg_snapshot_type(group):
            raise NotImplementedError()
        self.create_group(context, group)
        new_infinidat_group = self._get_infinidat_cg(group)
        if group_snapshot is not None and snapshots is not None:
            for volume, snapshot in zip(volumes, snapshots):
                self.create_volume_from_snapshot(volume, snapshot)
                new_infinidat_volume = self._get_infinidat_volume(volume)
                new_infinidat_group.add_member(new_infinidat_volume)
        elif source_group is not None and source_vols is not None:
            for volume, src_vol in zip(volumes, source_vols):
                self.create_cloned_volume(volume, src_vol)
                new_infinidat_volume = self._get_infinidat_volume(volume)
                new_infinidat_group.add_member(new_infinidat_volume)
        return None, None
예제 #8
0
파일: block_cmode.py 프로젝트: mahak/cinder
    def create_group_snapshot(self, group_snapshot, snapshots):
        """Creates a Cinder group snapshot object.

        The Cinder group snapshot object is created by making use of an
        ephemeral ONTAP consistency group snapshot in order to provide
        write-order consistency for a set of flexvol snapshots. First, a list
        of the flexvols backing the given Cinder group must be gathered. An
        ONTAP group-snapshot of these flexvols will create a snapshot copy of
        all the Cinder volumes in the generic volume group. For each Cinder
        volume in the group, it is then necessary to clone its backing LUN from
        the ONTAP cg-snapshot. The naming convention used for the clones is
        what indicates the clone's role as a Cinder snapshot and its inclusion
        in a Cinder group. The ONTAP cg-snapshot of the flexvols is no longer
        required after having cloned the LUNs backing the Cinder volumes in
        the Cinder group.

        :returns: An implicit update for group snapshot and snapshots models
                 that is interpreted by the manager to set their models to
                 available.
        """
        try:
            if volume_utils.is_group_a_cg_snapshot_type(group_snapshot):
                self._create_consistent_group_snapshot(group_snapshot,
                                                       snapshots)
            else:
                for snapshot in snapshots:
                    self._create_snapshot(snapshot)
        except Exception as ex:
            err_msg = (_("Create group snapshot failed (%s).") % ex)
            LOG.exception(err_msg, resource=group_snapshot)
            raise na_utils.NetAppDriverException(err_msg)

        return None, None
예제 #9
0
 def test_is_group_a_cg_snapshot_type_is_false(self, spec_value):
     with mock.patch('cinder.volume.group_types'
                     '.get_group_type_specs') as mock_get_specs:
         mock_get_specs.return_value = spec_value
         group = fake_group.fake_group_obj(
             None, group_type_id=fake.GROUP_TYPE_ID)
         self.assertFalse(volume_utils.is_group_a_cg_snapshot_type(group))
예제 #10
0
    def create_group_snapshot(self, group_snapshot, snapshots):
        """Creates a Cinder group snapshot object.

        The Cinder group snapshot object is created by making use of an
        ephemeral ONTAP consistency group snapshot in order to provide
        write-order consistency for a set of flexvol snapshots. First, a list
        of the flexvols backing the given Cinder group must be gathered. An
        ONTAP group-snapshot of these flexvols will create a snapshot copy of
        all the Cinder volumes in the generic volume group. For each Cinder
        volume in the group, it is then necessary to clone its backing LUN from
        the ONTAP cg-snapshot. The naming convention used for the clones is
        what indicates the clone's role as a Cinder snapshot and its inclusion
        in a Cinder group. The ONTAP cg-snapshot of the flexvols is no longer
        required after having cloned the LUNs backing the Cinder volumes in
        the Cinder group.

        :returns: An implicit update for group snapshot and snapshots models
                 that is interpreted by the manager to set their models to
                 available.
        """
        try:
            if volume_utils.is_group_a_cg_snapshot_type(group_snapshot):
                self._create_consistent_group_snapshot(group_snapshot,
                                                       snapshots)
            else:
                for snapshot in snapshots:
                    self._create_snapshot(snapshot)
        except Exception as ex:
            err_msg = (_("Create group snapshot failed (%s).") % ex)
            LOG.exception(err_msg, resource=group_snapshot)
            raise na_utils.NetAppDriverException(err_msg)

        return None, None
예제 #11
0
 def __init__(self, group, is_snapshot=False):
     self.id = group.id
     self.host = group.host
     if is_snapshot:
         self.snapshots = group.snapshots
     else:
         self.volumes = group.volumes
     self.consisgroup_enabled = utils.is_group_a_cg_snapshot_type(group)
예제 #12
0
    def create_group(self, context, group):
        """Creates a group."""
        if volume_utils.is_group_a_cg_snapshot_type(group):
            return self.common.create_consistencygroup(context, group, True)

        # If the group is not consistency group snapshot enabled, then
        # we shall rely on generic volume group implementation
        raise NotImplementedError()
예제 #13
0
    def delete_group_snapshot(self, context, group_snapshot, snapshots):
        """Deletes a group snapshot."""
        if volume_utils.is_group_a_cg_snapshot_type(group_snapshot):
            return self.common.delete_cgsnapshot(group_snapshot, snapshots)

        # If the group is not consistency group snapshot enabled, then
        # we shall rely on generic volume group implementation
        raise NotImplementedError()
예제 #14
0
파일: fc.py 프로젝트: CoprHD/cinder-driver
    def delete_group_snapshot(self, context, group_snapshot, snapshots):
        """Deletes a group snapshot."""
        if volume_utils.is_group_a_cg_snapshot_type(group_snapshot):
            return self.common.delete_cgsnapshot(group_snapshot, snapshots)

        # If the group is not consistency group snapshot enabled, then
        # we shall rely on generic volume group implementation
        raise NotImplementedError()
예제 #15
0
    def create_group(self, context, group):
        """Creates a group."""
        if volume_utils.is_group_a_cg_snapshot_type(group):
            return self.common.create_consistencygroup(context, group)

        # If the group is not consistency group snapshot enabled, then
        # we shall rely on generic volume group implementation
        raise NotImplementedError()
예제 #16
0
 def create_group(self, context, group):
     """Creates a group."""
     # let generic volume group support handle non-cgsnapshots
     if not vol_utils.is_group_a_cg_snapshot_type(group):
         raise NotImplementedError()
     self._system.cons_groups.create(name=self._make_cg_name(group),
                                     pool=self._get_infinidat_pool())
     return {'status': fields.GroupStatus.AVAILABLE}
예제 #17
0
    def inner(self, *args, **kwargs):
        # Only used to decorating the second argument is `group`
        if utils.is_group_a_cg_snapshot_type(args[1]):
            return func(self, *args, **kwargs)

        LOG.debug('Group is not a consistency group. Unity driver does '
                  'nothing.')
        # This exception will let cinder handle it as a generic group
        raise NotImplementedError()
예제 #18
0
파일: infinidat.py 프로젝트: mahak/cinder
 def create_group(self, context, group):
     """Creates a group."""
     # let generic volume group support handle non-cgsnapshots
     if not vol_utils.is_group_a_cg_snapshot_type(group):
         raise NotImplementedError()
     obj = self._system.cons_groups.create(name=self._make_cg_name(group),
                                           pool=self._get_infinidat_pool())
     self._set_cinder_object_metadata(obj, group)
     return {'status': fields.GroupStatus.AVAILABLE}
예제 #19
0
    def update_group(self, context, group, add_volumes=None,
                     remove_volumes=None):
        """Updates volumes in group."""
        if volume_utils.is_group_a_cg_snapshot_type(group):
            return self.common.update_consistencygroup(group, add_volumes,
                                                       remove_volumes)

        # If the group is not consistency group snapshot enabled, then
        # we shall rely on generic volume group implementation
        raise NotImplementedError()
예제 #20
0
    def create_group_snapshot(self, context, group_snapshot, snapshots):
        """Creates a group snapshot."""
        if volume_utils.is_group_a_cg_snapshot_type(group_snapshot):
            LOG.debug("creating a group snapshot")
            return self.common.create_cgsnapshot(group_snapshot, snapshots,
                                                 True)

        # If the group is not consistency group snapshot enabled, then
        # we shall rely on generic volume group implementation
        raise NotImplementedError()
예제 #21
0
    def update_group(self, context, group, add_volumes=None,
                     remove_volumes=None):
        """Updates volumes in group."""
        if volume_utils.is_group_a_cg_snapshot_type(group):
            return self.common.update_consistencygroup(group, add_volumes,
                                                       remove_volumes)

        # If the group is not consistency group snapshot enabled, then
        # we shall rely on generic volume group implementation
        raise NotImplementedError()
예제 #22
0
    def create_group_snapshot(self, context, group_snapshot, snapshots):
        """Creates a group snapshot."""
        if volume_utils.is_group_a_cg_snapshot_type(group_snapshot):
            LOG.debug("creating a group snapshot")
            return self.common.create_cgsnapshot(group_snapshot, snapshots,
                                                 True)

        # If the group is not consistency group snapshot enabled, then
        # we shall rely on generic volume group implementation
        raise NotImplementedError()
예제 #23
0
 def create_group_from_src(self, ctxt, group, volumes,
                           group_snapshot=None, snapshots=None,
                           source_group=None, source_vols=None):
     """Creates a group from source."""
     if volume_utils.is_group_a_cg_snapshot_type(group):
         message = _("create group from source is not supported "
                     "for CoprHD if the group type supports "
                     "consistent group snapshot.")
         raise exception.VolumeBackendAPIException(data=message)
     else:
         raise NotImplementedError()
예제 #24
0
 def create_group_from_src(self, ctxt, group, volumes,
                           group_snapshot=None, snapshots=None,
                           source_group=None, source_vols=None):
     """Creates a group from source."""
     if volume_utils.is_group_a_cg_snapshot_type(group):
         message = _("create group from source is not supported "
                     "for CoprHD if the group type supports "
                     "consistent group snapshot.")
         raise exception.VolumeBackendAPIException(data=message)
     else:
         raise NotImplementedError()
예제 #25
0
파일: infinidat.py 프로젝트: mahak/cinder
 def delete_group(self, context, group, volumes):
     """Deletes a group."""
     # let generic volume group support handle non-cgsnapshots
     if not vol_utils.is_group_a_cg_snapshot_type(group):
         raise NotImplementedError()
     try:
         infinidat_cg = self._get_infinidat_cg(group)
     except exception.InvalidGroup:
         pass      # group not found
     else:
         infinidat_cg.safe_delete()
     for volume in volumes:
         self.delete_volume(volume)
     return None, None
예제 #26
0
 def delete_group(self, context, group, volumes):
     """Deletes a group."""
     # let generic volume group support handle non-cgsnapshots
     if not vol_utils.is_group_a_cg_snapshot_type(group):
         raise NotImplementedError()
     try:
         infinidat_cg = self._get_infinidat_cg(group)
     except exception.InvalidGroup:
         pass  # group not found
     else:
         infinidat_cg.safe_delete()
     for volume in volumes:
         self.delete_volume(volume)
     return None, None
예제 #27
0
 def delete_group_snapshot(self, context, group_snapshot, snapshots):
     """Deletes a group_snapshot."""
     # let generic volume group support handle non-cgsnapshots
     if not vol_utils.is_group_a_cg_snapshot_type(group_snapshot):
         raise NotImplementedError()
     cgsnap_name = self._make_group_snapshot_name(group_snapshot)
     infinidat_cgsnap = self._system.cons_groups.safe_get(name=cgsnap_name)
     if infinidat_cgsnap is not None:
         if not infinidat_cgsnap.is_snapgroup():
             msg = _('Group "%s" is not a snapshot group') % cgsnap_name
             LOG.error(msg)
             raise exception.InvalidGroupSnapshot(message=msg)
         infinidat_cgsnap.safe_delete()
     for snapshot in snapshots:
         self.delete_snapshot(snapshot)
     return None, None
예제 #28
0
파일: infinidat.py 프로젝트: mahak/cinder
 def delete_group_snapshot(self, context, group_snapshot, snapshots):
     """Deletes a group_snapshot."""
     # let generic volume group support handle non-cgsnapshots
     if not vol_utils.is_group_a_cg_snapshot_type(group_snapshot):
         raise NotImplementedError()
     cgsnap_name = self._make_group_snapshot_name(group_snapshot)
     infinidat_cgsnap = self._system.cons_groups.safe_get(name=cgsnap_name)
     if infinidat_cgsnap is not None:
         if not infinidat_cgsnap.is_snapgroup():
             msg = _('Group "%s" is not a snapshot group') % cgsnap_name
             LOG.error(msg)
             raise exception.InvalidGroupSnapshot(message=msg)
         infinidat_cgsnap.safe_delete()
     for snapshot in snapshots:
         self.delete_snapshot(snapshot)
     return None, None
예제 #29
0
파일: infinidat.py 프로젝트: mahak/cinder
 def update_group(self, context, group,
                  add_volumes=None, remove_volumes=None):
     """Updates a group."""
     # let generic volume group support handle non-cgsnapshots
     if not vol_utils.is_group_a_cg_snapshot_type(group):
         raise NotImplementedError()
     add_volumes = add_volumes if add_volumes else []
     remove_volumes = remove_volumes if remove_volumes else []
     infinidat_cg = self._get_infinidat_cg(group)
     for vol in add_volumes:
         infinidat_volume = self._get_infinidat_volume(vol)
         infinidat_cg.add_member(infinidat_volume)
     for vol in remove_volumes:
         infinidat_volume = self._get_infinidat_volume(vol)
         infinidat_cg.remove_member(infinidat_volume)
     return None, None, None
예제 #30
0
 def update_group(self, context, group,
                  add_volumes=None, remove_volumes=None):
     """Updates a group."""
     # let generic volume group support handle non-cgsnapshots
     if not vol_utils.is_group_a_cg_snapshot_type(group):
         raise NotImplementedError()
     add_volumes = add_volumes if add_volumes else []
     remove_volumes = remove_volumes if remove_volumes else []
     infinidat_cg = self._get_infinidat_cg(group)
     for vol in add_volumes:
         infinidat_volume = self._get_infinidat_volume(vol)
         infinidat_cg.add_member(infinidat_volume)
     for vol in remove_volumes:
         infinidat_volume = self._get_infinidat_volume(vol)
         infinidat_cg.remove_member(infinidat_volume)
     return None, None, None
예제 #31
0
 def create_group_snapshot(self, context, group_snapshot, snapshots):
     """Creates a group_snapshot."""
     # let generic volume group support handle non-cgsnapshots
     if not vol_utils.is_group_a_cg_snapshot_type(group_snapshot):
         raise NotImplementedError()
     infinidat_cg = self._get_infinidat_cg(group_snapshot.group)
     group_snap_name = self._make_group_snapshot_name(group_snapshot)
     new_group = infinidat_cg.create_snapshot(name=group_snap_name)
     # update the names of the individual snapshots in the new snapgroup
     # to match the names we use for cinder snapshots
     for infinidat_snapshot in new_group.get_members():
         parent_name = infinidat_snapshot.get_parent().get_name()
         for cinder_snapshot in snapshots:
             if cinder_snapshot.volume_id in parent_name:
                 snapshot_name = self._make_snapshot_name(cinder_snapshot)
                 infinidat_snapshot.update_name(snapshot_name)
     return None, None
예제 #32
0
파일: infinidat.py 프로젝트: mahak/cinder
 def create_group_snapshot(self, context, group_snapshot, snapshots):
     """Creates a group_snapshot."""
     # let generic volume group support handle non-cgsnapshots
     if not vol_utils.is_group_a_cg_snapshot_type(group_snapshot):
         raise NotImplementedError()
     infinidat_cg = self._get_infinidat_cg(group_snapshot.group)
     group_snap_name = self._make_group_snapshot_name(group_snapshot)
     new_group = infinidat_cg.create_snapshot(name=group_snap_name)
     # update the names of the individual snapshots in the new snapgroup
     # to match the names we use for cinder snapshots
     for infinidat_snapshot in new_group.get_members():
         parent_name = infinidat_snapshot.get_parent().get_name()
         for cinder_snapshot in snapshots:
             if cinder_snapshot.volume_id in parent_name:
                 snapshot_name = self._make_snapshot_name(cinder_snapshot)
                 infinidat_snapshot.update_name(snapshot_name)
     return None, None
예제 #33
0
 def test_is_group_a_cg_snapshot_type_is_true(self, mock_get_specs):
     mock_get_specs.return_value = '<is> True'
     group = fake_group.fake_group_obj(
         None, group_type_id=fake.GROUP_TYPE_ID)
     self.assertTrue(volume_utils.is_group_a_cg_snapshot_type(group))
예제 #34
0
파일: adapter.py 프로젝트: hnusdr/cinder-1
 def is_in_cg(self):
     if self._is_in_cg is None:
         self._is_in_cg = (self._volume.group
                           and vol_utils.is_group_a_cg_snapshot_type(
                               self._volume.group))
     return self._is_in_cg
예제 #35
0
파일: utils.py 프로젝트: zhen00fa/cinder
 def inner(self, *args, **kwargs):
     if not vol_utils.is_group_a_cg_snapshot_type(args[1]):
         raise NotImplementedError
     return func(self, *args, **kwargs)
예제 #36
0
 def test_is_group_a_cg_snapshot_type_is_true(self, mock_get_specs):
     mock_get_specs.return_value = '<is> True'
     group = fake_group.fake_group_obj(
         None, group_type_id=fake.GROUP_TYPE_ID)
     self.assertTrue(volume_utils.is_group_a_cg_snapshot_type(group))