Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation and playbook for writable snapshot #105

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ff5b470
Documenattion and playbook for writable snapshot
Kritika-Bhateja-03 Aug 5, 2024
8ea3285
Updated doc
Kritika-Bhateja-03 Aug 6, 2024
8fa5e6a
Added code for create operation
Kritika-Bhateja-03 Aug 8, 2024
1727229
Merge branch 'dell:main' into usr/Kritika-Bhateja-03/ANSISILON-1991_w…
Kritika-Bhateja-03 Aug 8, 2024
ec8cba4
Create and delete operation alson with checkmode
Kritika-Bhateja-03 Aug 9, 2024
f5859f5
Added UT
Kritika-Bhateja-03 Aug 12, 2024
2b94336
Adding diff mode
Kritika-Bhateja-03 Aug 12, 2024
ba937f3
Diff mode support + UT
Kritika-Bhateja-03 Aug 13, 2024
aa4a0f5
UT
Kritika-Bhateja-03 Aug 13, 2024
fea392c
Sonar fix
Kritika-Bhateja-03 Aug 13, 2024
12cec53
Minor changes in diff mode
Kritika-Bhateja-03 Aug 14, 2024
b3027f1
output var change
Kritika-Bhateja-03 Aug 14, 2024
4480e95
Module name changes
Kritika-Bhateja-03 Aug 14, 2024
7f8ef86
minor changes in output
Kritika-Bhateja-03 Aug 14, 2024
68d97cc
modified idempotence case
Kritika-Bhateja-03 Aug 16, 2024
02399ea
minor code changes for idempotemcy
Kritika-Bhateja-03 Aug 19, 2024
c115a34
Updated method name
Kritika-Bhateja-03 Aug 19, 2024
3be6416
Sonar fixes
Kritika-Bhateja-03 Aug 19, 2024
fefc1e8
Sonar fix
Kritika-Bhateja-03 Aug 19, 2024
063ff9c
Added doc strings and updated UT
Kritika-Bhateja-03 Aug 20, 2024
56bc23d
UT
Kritika-Bhateja-03 Aug 20, 2024
8474de1
defect fix
Kritika-Bhateja-03 Aug 20, 2024
fbf7f29
Defect fix
Kritika-Bhateja-03 Aug 21, 2024
c768034
Doc changes
Kritika-Bhateja-03 Aug 21, 2024
74ef339
Minor update in message
Kritika-Bhateja-03 Aug 21, 2024
ee6fe89
Update tests/unit/plugins/module_utils/mock_writable_snapshots_api.py
Kritika-Bhateja-03 Aug 21, 2024
4c4f594
Update tests/unit/plugins/module_utils/mock_writable_snapshots_api.py
Kritika-Bhateja-03 Aug 21, 2024
3235473
Update plugins/modules/writable_snapshots.py
Kritika-Bhateja-03 Aug 21, 2024
f4e3052
Update docs/modules/writable_snapshots.rst
Kritika-Bhateja-03 Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
223 changes: 223 additions & 0 deletions docs/modules/writable_snapshots.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
.. _writable_snapshots_module:


writable_snapshots -- Manage writable snapshots on PowerScale
=============================================================

.. contents::
:local:
:depth: 1


Synopsis
--------

You can perform the following operations.

Managing snapshots on PowerScale.

Create a writable snapshot.

Delete a writable snapshot.



Requirements
------------
The below requirements are needed on the host that executes this module.

- A Dell PowerScale Storage system.
- Ansible-core 2.15 or later.
- Python 3.10, 3.11 or 3.12.



Parameters
----------

writable_snapshots (False, list, None)
List of writable snapshots details.


state (optional, str, present)
The state of the writable snapshot to create or delete.

\ :emphasis:`state`\ is \ :literal:`present`\ - To create a writable snapshot.

\ :emphasis:`state`\ is \ :literal:`absent`\ - To delete the writable snapshot.


dst_path (True, path, None)
The /ifs of the writable snapshot.

The destination path should be non-existing path and it is absolute path.


src_snap (False, str, None)
The source snapshot name or ID.

This option is required \ :emphasis:`state`\ is \ :literal:`present`\ .



onefs_host (True, str, None)
IP address or FQDN of the PowerScale cluster.


port_no (False, str, 8080)
Port number of the PowerScale cluster.It defaults to 8080 if not specified.


verify_ssl (True, bool, None)
boolean variable to specify whether to validate SSL certificate or not.

\ :literal:`true`\ - indicates that the SSL certificate should be verified.

\ :literal:`false`\ - indicates that the SSL certificate should not be verified.


api_user (True, str, None)
username of the PowerScale cluster.


api_password (True, str, None)
the password of the PowerScale cluster.





Notes
-----

.. note::
- The \ :emphasis:`writable\_snapshots`\ parameter will follow the order of deleting operations before creating operations.
- The modules present in this collection named as 'dellemc.powerscale' are built to support the Dell PowerScale storage platform.




Examples
--------

.. code-block:: yaml+jinja


- name: To create a writable snapshot using ID
dellemc.powerscale.writable_snapshots:
onefs_host: "{{ onefs_host }}"
verify_ssl: "{{ verify_ssl }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
writable_snapshots:
- dst_path: "/ifs/test_one"
src_snap: 2
state: present
- dst_path: "/ifs/test_two"
src_snap: 2
state: present

- name: To create a writable snapshot using Name
dellemc.powerscale.writable_snapshots:
onefs_host: "{{ onefs_host }}"
verify_ssl: "{{ verify_ssl }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
writable_snapshots:
- dst_path: "/ifs/test_one"
src_snap: "Snapshot: 2024Apr15, 4:40 PM"
state: present
- dst_path: "/ifs/test_two"
src_snap: "Snapshot: 2024Apr15, 4:40 PM"
state: present

- name: To delete writable snapshot
dellemc.powerscale.writable_snapshots:
onefs_host: "{{ onefs_host }}"
verify_ssl: "{{ verify_ssl }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
writable_snapshots:
- dst_path: "/ifs/test_one"
state: absent
- dst_path: "/ifs/test_two"
sstate: absent

- name: To create and delete writable snapshot
dellemc.powerscale.writable_snapshots:
onefs_host: "{{ onefs_host }}"
verify_ssl: "{{ verify_ssl }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
writable_snapshots:
- dst_path: "/ifs/test_test"
src_snap: 2
state: present
- dst_path: "/ifs/test_one"
state: absent



Return Values
-------------

changed (always, bool, True)
Whether or not the resource has changed.


writable_snapshots_details (When writable snapshot is created., complex, [{'created': 1719895971, 'dst_path': '/ifs/test_test', 'id': 23, 'log_size': 0, 'phys_size': 2048, 'src_id': 2, 'src_path': '/ifs/tfacc_file_system_test', 'src_snap': 'Snapshot: 2024Apr15, 4:40 PM', 'state': 'active'}])
The writable snapshot details.


created (, int, 1578514373)
The creation timestamp.


dst_path (, str, /ifs/ansible/)
The directory path of the writable snapshot.


id (, int, 23)
The writable snapshot ID.


log_size (, int, 2048)
The logical size of the writable snapshot.


phys_size (, int, 2048)
The physical size of the writable snapshot.


src_id (, int, 2)
the source snapshot ID.


src_path (, str, /ifs/tfacc_file_system_test)
The directory path of the source snapshot.


src_snap (, str, Snapshot: 2024Apr15, 4:40 PM)
The directory path of the source snapshot.


state (, str, active)
The name of the source snapshot.






Status
------





Authors
~~~~~~~

- Kritika Bhateja(@Kritika-Bhateja-03) <ansible.team.dell.com>

72 changes: 72 additions & 0 deletions playbooks/modules/writable_snapshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
- name: Sample playbook for managing Snapshots on Dell PowerScale.
hosts: localhost
connection: local
vars:
onefs_host: '10.**.**.**'
verify_ssl: false
api_user: 'user'
api_password: 'password'
owner: 'ansible_owner'
group: 'ansible_group'
access_control: 'private_read'
dst_path1: "/ifs/test_one"
dst_path2: "/ifs/test_two"
src_snap_id: 2
src_snap_name: "Snapshot: 2024Apr15, 4:40 PM"
state_present: 'present'
state_absent: 'absent'

tasks:
- name: Create a writable snapshot using ID
dellemc.powerscale.writable_snapshots:
onefs_host: "{{ onefs_host }}"
verify_ssl: "{{ verify_ssl }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
writable_snapshots:
- dst_path: "{{ dst_path1 }}"
src_snap: "{{ src_snap_id }}"
state: "{{ state_present }}"
- dst_path: "{{ dst_path2 }}"
src_snap: "{{ src_snap_id }}"
state: "{{ state_present }}"

- name: Create a writable snapshot using Name.
dellemc.powerscale.writable_snapshots:
onefs_host: "{{ onefs_host }}"
verify_ssl: "{{ verify_ssl }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
writable_snapshots:
- dst_path: "{{ dst_path1 }}"
src_snap: "{{ src_snap_name }}"
state: "{{ state_present }}"
- dst_path: "{{ dst_path2 }}"
src_snap: "{{ src_snap_name }}"
state: "{{ state_present }}"

- name: Delete writable snapshot.
dellemc.powerscale.writable_snapshots:
onefs_host: "{{ onefs_host }}"
verify_ssl: "{{ verify_ssl }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
writable_snapshots:
- dst_path: "{{ dst_path1 }}"
state: "{{ state_absent }}"
- dst_path: "{{ dst_path2 }}"
state: "{{ state_absent }}"

- name: Create and delete writable snapshot
dellemc.powerscale.writable_snapshots:
onefs_host: "{{ onefs_host }}"
verify_ssl: "{{ verify_ssl }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
writable_snapshots:
- dst_path: "{{ dst_path2 }}"
src_snap: "{{ src_snap_id }}"
state: "{{ state_present }}"
- dst_path: "{{ dst_path1 }}"
state: "{{ state_absent }}"
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, ansible_module, ansible_module_params):
self._zones_summary_api = None
self._support_assist_api = None
self._event_api = None
self._snapshot_api = None

@property
def protocol_api(self):
Expand Down Expand Up @@ -144,3 +145,13 @@ def event_api(self):
if self._event_api is None:
self._event_api = self.isi_sdk.EventApi(self.api_client)
return self._event_api

@property
def snapshot_api(self):
"""Returns the snapshot API object.
:return: The snapshot API object.
:rtype: isi_sdk.SnapshotApi
"""
if self._snapshot_api is None:
self._snapshot_api = self.isi_sdk.SnapshotApi(self.api_client)
return self._snapshot_api
Loading
Loading