Example #1
0
    def _create_group_snapshot(self, snapshots):
        snapshots_model_update = []
        created_snapshots = []

        for snapshot in snapshots:
            try:
                snapshot_id, snapshot_wwn = huawei_flow.create_snapshot(
                    snapshot, self.local_cli, self.support_capability)
            except Exception:
                LOG.exception("Failed to create snapshot %s of group.",
                              snapshot.id)
                for snap_id in created_snapshots:
                    self.local_cli.delete_snapshot(snap_id)
                raise

            location = huawei_utils.to_string(huawei_snapshot_id=snapshot_id,
                                              huawei_snapshot_wwn=snapshot_wwn)
            snap_model_update = {
                'id': snapshot.id,
                'status': fields.SnapshotStatus.AVAILABLE,
                'provider_location': location,
            }
            snapshots_model_update.append(snap_model_update)
            created_snapshots.append(snapshot_id)

        try:
            self.local_cli.activate_snapshot(created_snapshots)
        except Exception:
            LOG.exception("Failed to activate group snapshots %s.",
                          created_snapshots)
            for snap_id in created_snapshots:
                self.local_cli.delete_snapshot(snap_id)
            raise

        return snapshots_model_update
Example #2
0
    def create_snapshot(self, snapshot):
        snapshot_id, snapshot_wwn = huawei_flow.create_snapshot(
            snapshot, self.local_cli, self.support_capability)
        self.local_cli.activate_snapshot(snapshot_id)

        location = huawei_utils.to_string(huawei_snapshot_id=snapshot_id,
                                          huawei_snapshot_wwn=snapshot_wwn)
        return {'provider_location': location}