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

Adding CreateVolume functionality #6813

Merged

Conversation

TSKushal
Copy link
Contributor

SUMMARY
Adding functionality to create volumes on Gen11 servers.

ISSUE TYPE

  • Feature Pull Request

COMPONENT NAME
redfish_config.py
redfish_utils.py

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added feature This issue/PR relates to a feature request module module module_utils module_utils plugins plugin (any type) labels Jun 29, 2023
@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Jun 29, 2023
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-7 labels Jun 29, 2023
@ansibullbot ansibullbot added stale_ci CI is older than 7 days, rerun before merging and removed stale_ci CI is older than 7 days, rerun before merging labels Jul 15, 2023
@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Jul 19, 2023
@TSKushal
Copy link
Contributor Author

@mraineri any further comments on this?

@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label Jul 28, 2023
'msg': "Provided Storage Subsystem ID %s does not exist on the server" % storage_subsystem_id}

# Validate input parameters
required_parameters = ['RAIDType', 'Drives']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add CapacityBytes to the required list; I can't think of a practical reason as to why we'd let the Redfish service decide the capacity on behalf of the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since CapacityBytes parameter is not needed from the API side, should we be restricting it from a code perspective. Also, since the drive link is a mandatory parameter from the API, users have to check the capacity before providing the drives as input.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically none of these parameters are needed from the API side. Redfish has no required properties in the standard when a user is trying to create a volume. If you look at the Volume schema (https://redfish.dmtf.org/schemas/swordfish/v1/Volume_v1.xml), there are no properties marked as "Redfish.RequiredOnCreate".

A request like this is perfectly acceptable per the specification:

POST /redfish/v1/Systems/1/Storage/1/Volumes
Content-Type: application/json

{}

With an empty request like this, the client is deferring everything to the service (including the drive selection, RAID type, and size of the volume).

However, is it practical from an Ansible perspective to let a user attempt to create a new Volume without specifying the size? I'm not sure I'm willing to make that leap yet (maybe @felixfontein has an opinion about this).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious what use-cases are there for creating a volume without a specified size. If not specifying the size would mean "use the maximum available" that would make sense to me, but if not specifying it means "pick something for me, I don't really care" (which as far as I understand is the case here?) and there's no other option which implicitly defines the size (like a boolean flag "use the maximum available"), then it feels strange.

One thing to remember is that it's easier to remove restrictions (like initially require the size, and later drop that restriction when someone provides a good argument for it) than adding them (which is usually a breaking change).

Copy link
Contributor Author

@TSKushal TSKushal Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply.
When we check the API /redfish/v1/Systems/1/Storage/DE00C000/Volumes/Capabilities
We see the following response.

{
    "@odata.etag": "\"6ed17d03\"",
    "@odata.id": "/redfish/v1/Systems/1/Storage/DE00C000/Volumes/Capabilities",
    "@odata.type": "#Volume.v1_6_2.Volume",
    "Id": "Capabilities",
    "Name": "Capabilities for VolumeCollection",
    "CapacityBytes@Redfish.OptionalOnCreate": true, --> Optional
    "DisplayName@Redfish.OptionalOnCreate": true,
    "DisplayName@Redfish.UpdatableAfterCreate": true,
    "InitializeMethod@Redfish.OptionalOnCreate": true,
    "InitializeMethod@Redfish.AllowableValues": [
        "Foreground",
        "Background"
    ],
    "Links@Redfish.RequiredOnCreate": true, --> Required
    "Links": {
        "Drives@Redfish.RequiredOnCreate": true,
        "DedicatedSpareDrives@Redfish.OptionalOnCreate": true,
        "DedicatedSpareDrives@Redfish.UpdatableAfterCreate": true
    },
    "MediaSpanCount@Redfish.OptionalOnCreate": true,
    "Name@Redfish.OptionalOnCreate": true, --> Required
    "RAIDType@Redfish.RequiredOnCreate": true,  --> Required
    "RAIDType@Redfish.AllowableValues": [
        "None",
        "RAID0",
        "RAID1",
        "RAID10",
        "RAID5",
        "RAID50",
        "RAID6",
        "RAID60"
    ],
    "ReadCachePolicy@Redfish.OptionalOnCreate": true,
    "ReadCachePolicy@Redfish.UpdatableAfterCreate": true,
    "ReadCachePolicy@Redfish.AllowableValues": [
        "Off",
        "ReadAhead"
    ],
    "StripSizeBytes@Redfish.OptionalOnCreate": true,
    "VolumeUsage@Redfish.OptionalOnCreate": true,
    "VolumeUsage@Redfish.AllowableValues": [
        "Data"
    ],
    "WriteCachePolicy@Redfish.OptionalOnCreate": true,
    "WriteCachePolicy@Redfish.UpdatableAfterCreate": true,
    "WriteCachePolicy@Redfish.AllowableValues": [
        "ProtectedWriteBack",
        "UnprotectedWriteBack",
        "WriteThrough"
    ]
}

Our reasoning was based on this response.

When we do a POST request with just Name, RAIDType and Links, the request goes through, so at least from the API end CapacityBytes is not required always.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that your API allows for this; the standard definition technically allows for a completely empty request.

However, from an Ansible perspective, it's not clear what the use case for not specifying the volume size would be. This is not about what the API allows, but rather is it realistic to let an Ansible user create a volume without specifying its size. I can't think of a scenario where a user would not want to specify the size of the volume.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added CapacityBytes as a mandatory parameter.

@ansibullbot ansibullbot removed ci_verified Push fixes to PR branch to re-run CI merge_commit This PR contains at least one merge commit. Please resolve! needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Sep 21, 2023
@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Sep 27, 2023
@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Sep 27, 2023

def create_volume(self, volume_details, storage_subsystem_id):
# Fail message if run for iLO5 or lower server
vendor = self._get_vendor()['Vendor']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this check up front? Isn't the failure to POST to the VolumeCollection sufficient? Doing version checks for capabilities is not a good practice; the interface itself is self-descriptive

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do see your point, but we may benefit from explicitly pointing out that it doesn't work for certain server. Changed the implementation a little, please a have look.

payload = volume_details
response = self.post_request(self.root_uri + data['Volumes']['@odata.id'], payload)
if response['ret'] is False:
# Fail message if run for iLO5 or lower server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't think this is really in our best interest to add... We don't perform additional version checks in failure paths anywhere else, and this seems like it'll be nearly impossible to maintain across the board.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this version specific code only comes into picture for iLO6 RAID/Volume related operations. All other functionalities that we maintain do not have any version dependencies.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not the issue; the issue is establishing a pattern of:

if FAIL:
    if vendor == "X":
        # Add version checks and modify error message for vendor X
    elif vendor == "Y":
        # Add version checks and modify error message for vendor Y
    elif vendor == "Z":
        # Add version checks and modify error message for vendor Z
    elif ...

I don't think this pattern scales well or is very maintainable. The service should already be returning the proper information to convey that it doesn't support the given request, such as a "method not allowed" message, which is a clear indication the service does not support POST to the VolumeCollection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, will defer to your expertise on the matter. Updated the code to remove this.

@mraineri
Copy link
Contributor

mraineri commented Oct 6, 2023

Looks good to me now; thanks!

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Oct 6, 2023
@felixfontein felixfontein merged commit 55893f2 into ansible-collections:main Oct 6, 2023
142 checks passed
@patchback
Copy link

patchback bot commented Oct 6, 2023

Backport to stable-7: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-7/55893f27c99282028069728e2b1e2f44478c0455/pr-6813

Backported as #7359

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Oct 6, 2023
* Adding create volume functionality

* Adding changelog fragment

* Sanity Fix

* Sanity fix

* Update 6813-redfish-config-add-create-volume.yml

* Sanity fix

* Sanity fix

* Removing capabilities check and correcting controllers terminology to storage subsystem

* Updating as per PR suggestions

* sanity fix

* Update plugins/modules/redfish_config.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/redfish_config.py

Agreed

Co-authored-by: Felix Fontein <felix@fontein.de>

* Fixing merge issue

* Fixing sanity issues

* Adding CapacityBytes as a mandatory parameter and adding failure message when run for server below iLO6

* Sanity fix

* Sanity fix

* Updating vendor specific failure

* Update plugins/modules/redfish_config.py

Agreed

Co-authored-by: Felix Fontein <felix@fontein.de>

* Removing vendor specific failure case

* removing unused import

---------

Co-authored-by: Kushal <t-s.kushal@hpe.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 55893f2)
@felixfontein
Copy link
Collaborator

@TSKushal thanks for your contribution!
@mraineri thanks for reviewing!

felixfontein pushed a commit that referenced this pull request Oct 6, 2023
…ity (#7359)

Adding CreateVolume functionality (#6813)

* Adding create volume functionality

* Adding changelog fragment

* Sanity Fix

* Sanity fix

* Update 6813-redfish-config-add-create-volume.yml

* Sanity fix

* Sanity fix

* Removing capabilities check and correcting controllers terminology to storage subsystem

* Updating as per PR suggestions

* sanity fix

* Update plugins/modules/redfish_config.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/redfish_config.py

Agreed

Co-authored-by: Felix Fontein <felix@fontein.de>

* Fixing merge issue

* Fixing sanity issues

* Adding CapacityBytes as a mandatory parameter and adding failure message when run for server below iLO6

* Sanity fix

* Sanity fix

* Updating vendor specific failure

* Update plugins/modules/redfish_config.py

Agreed

Co-authored-by: Felix Fontein <felix@fontein.de>

* Removing vendor specific failure case

* removing unused import

---------

Co-authored-by: Kushal <t-s.kushal@hpe.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 55893f2)

Co-authored-by: TSKushal <44438079+TSKushal@users.noreply.github.com>
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Oct 12, 2023
8.5.0

amazon.aws
~~~~~~~~~~

- ec2_ami - add support for ``org_arns`` and ``org_unit_arns`` in launch_permissions (ansible-collections/amazon.aws#1690).
- elb_application_lb_info - drop redundant ``describe_load_balancers`` call fetching ``ip_address_type`` (ansible-collections/amazon.aws#1768).

community.general
~~~~~~~~~~~~~~~~~

- cargo - add option ``executable``, which allows user to specify path to the cargo binary (ansible-collections/community.general#7352).
- cargo - add option ``locked`` which allows user to specify install the locked version of dependency instead of latest compatible version (ansible-collections/community.general#6134).
- dig lookup plugin - add TCP option to enable the use of TCP connection during DNS lookup (ansible-collections/community.general#7343).
- gitlab_group - add option ``force_delete`` (default: false) which allows delete group even if projects exists in it (ansible-collections/community.general#7364).
- ini_file - add ``ignore_spaces`` option (ansible-collections/community.general#7273).
- newrelic_deployment - add option ``app_name_exact_match``, which filters results for the exact app_name provided (ansible-collections/community.general#7355).
- onepassword lookup plugin - introduce ``account_id`` option which allows specifying which account to use (ansible-collections/community.general#7308).
- onepassword_raw lookup plugin - introduce ``account_id`` option which allows specifying which account to use (ansible-collections/community.general#7308).
- parted - on resize, use ``--fix`` option if available (ansible-collections/community.general#7304).
- pnpm - set correct version when state is latest or version is not mentioned. Resolves previous idempotency problem (ansible-collections/community.general#7339).
- proxmox - add ``vmid`` (and ``taskid`` when possible) to return values (ansible-collections/community.general#7263).
- random_string - added new ``ignore_similar_chars`` and ``similar_chars`` option to ignore certain chars (ansible-collections/community.general#7242).
- redfish_command - add new option ``update_oem_params`` for the ``MultipartHTTPPushUpdate`` command (ansible-collections/community.general#7331).
- redfish_config - add ``CreateVolume`` command to allow creation of volumes on servers (ansible-collections/community.general#6813).
- redfish_config - adding ``SetSecureBoot`` command (ansible-collections/community.general#7129).
- redfish_info - add support for ``GetBiosRegistries`` command (ansible-collections/community.general#7144).
- redfish_info - adds ``LinkStatus`` to NIC inventory (ansible-collections/community.general#7318).
- redis_info - refactor the redis_info module to use the redis module_utils enabling to pass TLS parameters to the Redis client (ansible-collections/community.general#7267).
- supervisorctl - allow to stop matching running processes before removing them with ``stop_before_removing=true`` (ansible-collections/community.general#7284).

community.libvirt
~~~~~~~~~~~~~~~~~

- virt - add `mutate_flags` parameter to enable XML mutation (add UUID, MAC addresses from existing domain) (ansible-collections/community.libvirt#142).
- virt - support ``--diff`` for ``define`` command (ansible-collections/community.libvirt#142).

community.routeros
~~~~~~~~~~~~~~~~~~

- api_info - add new ``include_read_only`` option to select behavior for read-only values. By default these are not returned (ansible-collections/community.routeros#213).
- api_info, api_modify - add support for ``address-list`` and ``match-subdomain`` introduced by RouterOS 7.7 in the ``ip dns static`` path (ansible-collections/community.routeros#197).
- api_info, api_modify - add support for ``user``, ``time`` and ``gmt-offset`` under the ``system clock`` path (ansible-collections/community.routeros#210).
- api_info, api_modify - add support for the ``interface ppp-client`` path (ansible-collections/community.routeros#199).
- api_info, api_modify - add support for the ``interface wireless`` path (ansible-collections/community.routeros#195).
- api_info, api_modify - add support for the ``iot modbus`` path (ansible-collections/community.routeros#205).
- api_info, api_modify - add support for the ``ip dhcp-server option`` and ``ip dhcp-server option sets`` paths (ansible-collections/community.routeros#223).
- api_info, api_modify - add support for the ``ip upnp interfaces``, ``tool graphing interface``, ``tool graphing resource`` paths (ansible-collections/community.routeros#227).
- api_info, api_modify - add support for the ``ipv6 firewall nat`` path (ansible-collections/community.routeros#204).
- api_info, api_modify - add support for the ``mode`` property in ``ip neighbor discovery-settings`` introduced in RouterOS 7.7 (ansible-collections/community.routeros#198).
- api_info, api_modify - add support for the ``port remote-access`` path (ansible-collections/community.routeros#224).
- api_info, api_modify - add support for the ``routing filter rule`` and ``routing filter select-rule`` paths (ansible-collections/community.routeros#200).
- api_info, api_modify - add support for the ``routing table`` path in RouterOS 7 (ansible-collections/community.routeros#215).
- api_info, api_modify - add support for the ``tool netwatch`` path in RouterOS 7 (ansible-collections/community.routeros#216).
- api_info, api_modify - add support for the ``user settings`` path (ansible-collections/community.routeros#201).
- api_info, api_modify - add support for the ``user`` path (ansible-collections/community.routeros#211).
- api_info, api_modify - finalize fields for the ``interface wireless security-profiles`` path and enable it (ansible-collections/community.routeros#203).
- api_info, api_modify - finalize fields for the ``ppp profile`` path and enable it (ansible-collections/community.routeros#217).
- api_modify - add new ``handle_read_only`` and ``handle_write_only`` options to handle the module's behavior for read-only and write-only fields (ansible-collections/community.routeros#213).
- api_modify, api_info - support API paths ``routing id``, ``routing bgp connection`` (ansible-collections/community.routeros#220).

community.vmware
~~~~~~~~~~~~~~~~

- add moid property in the return value for the module(ansible-collections/community.vmware#1855).
- add new snapshot_id option to the vmware_guest_snapshot module(ansible-collections/community.vmware#1847).

dellemc.powerflex
~~~~~~~~~~~~~~~~~

- Added Ansible role to support installation and uninstallation of Gateway.
- Added Ansible role to support installation and uninstallation of SDR.
- Added Ansible role to support installation and uninstallation of Web UI.

grafana.grafana
~~~~~~~~~~~~~~~

- Add check for Curl and failure step if Agent Version is not retrieved
- Allow alert resource provisioning in Grafana Role
- Bump cryptography from 39.0.2 to 41.0.3
- Bump cryptography from 41.0.3 to 41.0.4
- Bump semver from 5.7.1 to 5.7.2
- Bump word-wrap from 1.2.3 to 1.2.5
- Create local dashboard directory in check mode
- Create missing notification directory in Grafana Role
- Remove check_mode from create local directory task in Grafana Role
- Remove dependency on local-fs.target from Grafana Agent role
- Update CI Testing
- Update Cloud Stack Module failures
- Use 'ansible_system' env variable to detect os typ in Grafana Agent Role
- hange grafana Agent Wal and Positions Directory in Grafana Agent Role

ovirt.ovirt
~~~~~~~~~~~

- ovirt_vm - Add tpm_enabled (oVirt/ovirt-ansible-collection#722).
- storage_error_resume_behaviour - Support VM storage error resume behaviour "auto_resume", "kill", "leave_paused". (oVirt/ovirt-ansible-collection#721)
- vm_infra - Support boot disk renaming and resizing. (oVirt/ovirt-ansible-collection#705)

purestorage.flashblade
~~~~~~~~~~~~~~~~~~~~~~

- purefb_bucket_replica - Added support for cascading replica links
- purefb_info - New fields to display free space (remaining quota) for Accounts and Buckets. Space used by destroyed buckets is split out from virtual field to new destroyed_virtual field
- purefb_info - Report encryption state in SMB client policy rules
- purefb_info - Report more detailed space data from Purity//FB 4.3.0
- purefb_policy - Add deny effect for object store policy rules. Requires Purity//FB 4.3.0+
- purefb_policy - Added parameter to define object store policy description

vultr.cloud
~~~~~~~~~~~

- inventory - Added VPC/VPC 2.0 support by adding ``internal_ip`` to the attributes (vultr/ansible-collection-vultr#86).
etrombly pushed a commit to etrombly/community.general that referenced this pull request Oct 25, 2023
* Adding create volume functionality

* Adding changelog fragment

* Sanity Fix

* Sanity fix

* Update 6813-redfish-config-add-create-volume.yml

* Sanity fix

* Sanity fix

* Removing capabilities check and correcting controllers terminology to storage subsystem

* Updating as per PR suggestions

* sanity fix

* Update plugins/modules/redfish_config.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/redfish_config.py

Agreed

Co-authored-by: Felix Fontein <felix@fontein.de>

* Fixing merge issue

* Fixing sanity issues

* Adding CapacityBytes as a mandatory parameter and adding failure message when run for server below iLO6

* Sanity fix

* Sanity fix

* Updating vendor specific failure

* Update plugins/modules/redfish_config.py

Agreed

Co-authored-by: Felix Fontein <felix@fontein.de>

* Removing vendor specific failure case

* removing unused import

---------

Co-authored-by: Kushal <t-s.kushal@hpe.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request module_utils module_utils module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants