Skip to content

Commit

Permalink
[Module][1717]new_module_zfs_resize (#1767)
Browse files Browse the repository at this point in the history
* Remove Hardcoded hlq

* Fix removal

* Add some solution

* First version module

* Get size correctly

* Refactor module and add new module_utils

* Add comments

* Fix documentation

* Less code, working with verbose

* Fix comments

* Fix comments and verbose

* Fix comments

* Fix documentation

* Fix trc and cyl

* Generate file

* Fix names and operations

* Update plugins/modules/zos_zfs_resize.py

Co-authored-by: Fernando Flores <[email protected]>

* Update plugins/modules/zos_zfs_resize.py

Co-authored-by: Fernando Flores <[email protected]>

* hange to space_type

* Update plugins/modules/zos_zfs_resize.py

Co-authored-by: Fernando Flores <[email protected]>

* Update plugins/modules/zos_zfs_resize.py

Co-authored-by: Fernando Flores <[email protected]>

* Update plugins/modules/zos_zfs_resize.py

Co-authored-by: Fernando Flores <[email protected]>

* Update plugins/modules/zos_zfs_resize.py

Co-authored-by: Fernando Flores <[email protected]>

* Change names

* Add comments

* Return size of space_type given by the user

* Add obj as name

* Add first two basic test cases

* Fix documentation

* Fix documentation

* Fix documentation

* Fix documentation

* Fix comments and add trace_path

* Fix verbose

* Add validation to full traceback

* Fix error message

* Add fix type

* Add test case

* Remove cp

* Fix dir_path

* Add fragment

* Fix tracks and cylinder

* Add test case of space_type

* Add test cases for all positives cases

* Update Github bug and enhancement templates with latest versions (#1820)

* Updated bug issue

* Updated collaboration issue

* Updated doc issue

* Update plugins/modules/zos_fetch.py

Co-authored-by: Fernando Flores <[email protected]>

* Update plugins/modules/zos_fetch.py

Co-authored-by: Fernando Flores <[email protected]>

* Update plugins/modules/zos_fetch.py

Co-authored-by: Fernando Flores <[email protected]>

* Fix execpton handle

* Fix sanity

* Adjust best practices

* Add negative correct error

* Fix sanity

* Use raises

* Update mounts.env (#1826)

Swapped old zoau v1.1.0 to use as zoau 1.3.4 ga build

* [zos_mvs_raw] Find VSAM cluster when DISP=OLD and find data and index resource types (#1822)

* Added fix for zos_find

* Added tests for fix

* Updated changelog

* Fix error messages and more

* Fix test cases issues positives and add negatives

* Fix resize call

* End portability

* Add fragment

* [enabler][zos_copy]Add_error_message (#1821)

* Add enhance error message

* Add fragment

* Update plugins/modules/zos_copy.py

Co-authored-by: Fernando Flores <[email protected]>

* Update 1821-Add_error_message.yml

* Update zos_copy.py

---------

Co-authored-by: Fernando Flores <[email protected]>

* Get aggregation size available for everyone

* Fix no change on type

* Add validation

* Add extra asserts

* Enhance error message

* Add space

* Updates to release notes and support for ansible-core 2.18 venv for AC tool (#1829)

* Update minimum version of z/OS for the GA of 1.12

Signed-off-by: ddimatos <[email protected]>

* Update AAP link

Signed-off-by: ddimatos <[email protected]>

* Venv for 2.18

Signed-off-by: ddimatos <[email protected]>

* remove merge flags

Signed-off-by: ddimatos <[email protected]>

* Merged release into dev

* fixed test case

* Fixed mvs raw test

---------

Signed-off-by: ddimatos <[email protected]>
Co-authored-by: Fernando Flores <[email protected]>

* [Enabler] [AC tool] Add more options when testing with the AC tool (#1827)

* Change flag used to run specific test

* Add more env vars needed to run tests

* Add verbose option to ac_test

* Add mark and stop options to ac_test

* Refactor pytest call

Also changes how verbosity is handled, as well as adds printing of each pytest command run.

* Update config to support new way of handling env vars in tests

* Add profile option to ac_lint

* Add support to run multiple files in ac_test

* Change boolean options to flags

Options `debug` (ac_test, test_concurrent) and `stop` (ac_test) can be now used simply as flags, without the need to add a `"true"` string after the option.

* Document and clean up arg parser

* Update more boolean options to be flags

* Refactor pytest call

* Add option 'volumes' to ac_test

* Add user option and tweak verbosity

* Add ac-test-required command

* Add changelog fragment

* Fix trace dataset

* Add trace

* Add space

* [Enabler] [module_utils/copy.py] Replace calls to cp for dcp's Python API (#1831)

* Replace calls to cp for dcp

* Replace copy functions in copy.py

* Replace copy calls in modules

* Fix typo

* Fix return statement

* Add changelog fragment

* Fix sanity issues

* Add test cases

* Add test case to validate test lineinfile

* Add fragment

* Update tests/functional/modules/test_zos_lineinfile_func.py

Co-authored-by: Fernando Flores <[email protected]>

* Update changelogs/fragments/1842-Add_test_case_to_validate_advance_regular_expression.yml

Co-authored-by: Fernando Flores <[email protected]>

* Update test_zos_lineinfile_func.py

* Validate use of members

* Add pds pdse and member fails

* Fix sanity issues

* Fix error message and space_Type in lower case

* Change names

* Add docstring

* Add documentation

* fix upper case

* Add comments

* Add ignore

* Add documentation

* Try to fix the lint

* Final test case

* Fix two runs

* Delete uneccesary validation

* Fix test case and add to github templates

* Fix error return message

* Add test case

* Return functions

* Add member

* Add test case

* Add test case

* Add missing import

* Add missing import

* Add documentation

* Fix playbook

* Fix error test case

* Fix version of inventory

* Remove repeitive test case

* Update plugins/module_utils/zfsadm.py

Co-authored-by: Alex Moreno <[email protected]>

* Add validation to avoid no auto increment

* Fix a comment

* Fix documentation

* Apply suggestions from code review

Co-authored-by: Alex Moreno <[email protected]>

* Add notes

* Scape points

* Scape points

* Scape points

* Update plugins/modules/zos_zfs_resize.py

Co-authored-by: Fernando Flores <[email protected]>

* Update plugins/modules/zos_zfs_resize.py

Co-authored-by: Fernando Flores <[email protected]>

* Add 2025 and adjust to comments

* Add notes

* Fix errors

* Fix documentation problem

* Fix comment and test case

* Fix comment

* Fix comment

* Fix comment

* Fix error when creating one

* Fix error when creating one

* Fix error messaging

* Fix documentation

* Fix output

* Add extra validations

* Fix resize

* Ensure proper size creation

* Fix eror assertion

* Add documenation and full verification

* Fix PDS and PDSE

* Fix documentation

* Fix validation

* Fix documentation and stderr for SEQ dataset

* Update documentation

* Fix names

* Fix lint

* Update word increment to increase

Signed-off-by: ddimatos <[email protected]>

* Fix all type of names for uss trace destination

* Check trace uss on other size

---------

Signed-off-by: ddimatos <[email protected]>
Co-authored-by: Fernando Flores <[email protected]>
Co-authored-by: Rich Parker <[email protected]>
Co-authored-by: Demetri <[email protected]>
Co-authored-by: Alex Moreno <[email protected]>
  • Loading branch information
5 people authored Jan 13, 2025
1 parent 6b107fd commit 42a8071
Show file tree
Hide file tree
Showing 12 changed files with 1,797 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ body:
- zos_tso_command
- zos_unarchive
- zos_volume_init
- zos_zfs_resize
validations:
required: false
- type: textarea
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/collaboration_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,6 @@ body:
- zos_tso_command
- zos_unarchive
- zos_volume_init
- zos_zfs_resize
validations:
required: false
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/doc_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,6 @@ body:
- zos_tso_command
- zos_unarchive
- zos_volume_init
- zos_zfs_resize
validations:
required: false
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/enabler_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ body:
- zos_tso_command
- zos_unarchive
- zos_volume_init
- zos_zfs_resize
validations:
required: false

1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/enhancement_feature.issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ body:
- zos_tso_command
- zos_unarchive
- zos_volume_init
- zos_zfs_resize
validations:
required: true

84 changes: 84 additions & 0 deletions plugins/module_utils/zfsadm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright (c) IBM Corporation 2025
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import, division, print_function
__metaclass__ = type


class zfsadm:
"""Provides an interface to execute zfsadm commands.
"""
def __init__(self, aggregate_name, module):
"""Initialize a class with its zfs dataset and allow modules to be executed.
Parameters
----------
aggregate_name : str
Name of the zfs dataset.
module : object
Ansible object to execute commands.
"""
self.aggregate_name = aggregate_name.upper()
self.module = module

def execute_resizing(self, operation, size, noai, verbose):
"""Execute a grow or shrink operation on a zfs dataset.
Parameters
----------
operation : str
Whether the operation to execute is grow or shrink
size : int
Size to be assigned to the zfs
noai : str
Value for the no auto increase (noai) option when shrinking a dataset
verbose : str
Value for zfsadm's trace option specifying the output file for the command
Returns
-------
rc : int
The RC of the command executed.
stdout : str
The stdout of the executed command.
stderr : str
The stderr of the executed command.
cmd_str : str
The full command that was executed.
"""
if operation != "grow":
if operation != "shrink":
self.module.fail_json(msg=f"There is no operator {operation}")

cmd = f"-size {size}{noai}{verbose}"
cmd_str = f"zfsadm {operation} -aggregate {self.aggregate_name} {cmd}"

rc, stdout, stderr = self.module.run_command(cmd_str)

return rc, stdout, stderr, cmd_str

@staticmethod
def get_aggregate_size(aggregate_name, module):
"""Execute a command to get the size of a zfs dataset.
Returns
-------
rc : int
The rc of the executed command.
stdout : str
The stdout of the executed command
stderr : str
The stderr of the executed command.
"""
cmd = f"zfsadm aggrinfo {aggregate_name}"

rc, stdout, stderr = module.run_command(cmd)

return rc, stdout, stderr
Loading

0 comments on commit 42a8071

Please sign in to comment.