community.general icon indicating copy to clipboard operation
community.general copied to clipboard

Add SetSessionService to redfish_config

Open tejabailey opened this issue 1 year ago • 3 comments

adding SetSessionService command to redfish_config to set BMC default session timeout policy.

Fixes #5008

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

redfish_config

tejabailey avatar Jul 26 '22 15:07 tejabailey

(venv) tj@C02GF4NZMD6R Tests % ANSIBLE_COLLECTIONS_PATH=/Users/tj/ansible ansible-playbook -i s2r8node65.s2r8, SetSessionServiceTests.yml
[WARNING]: Collection community.general does not support Ansible version 2.10.7

PLAY [all] **********************************************************************************************************************************************************************************************************************

TASK [Gather initial BMC lan information] ***************************************************************************************************************************************************************************************
ok: [s2r8node65.s2r8]

TASK [Set BMC IP address as fact] ***********************************************************************************************************************************************************************************************
ok: [s2r8node65.s2r8]

TASK [Set something for SessionService] *****************************************************************************************************************************************************************************************
changed: [s2r8node65.s2r8]

TASK [debug] ********************************************************************************************************************************************************************************************************************
ok: [s2r8node65.s2r8] => {
    "redfish_set_sessionservice": {
        "changed": true,
        "failed": false,
        "msg": "Modified SessionService"
    }
}

PLAY RECAP **********************************************************************************************************************************************************************************************************************
s2r8node65.s2r8            : ok=4    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

(venv) tj@C02GF4NZMD6R Tests % cat SetSessionServiceTests.yml 
---
- hosts: all
  gather_facts: false
  vars:
    bmc_username: root
    bmc_password: hunter2
    default_uri_timeout: 50
    default_uri_retries: 5
  tasks:
  - name: Gather initial BMC lan information
    command: ipmitool lan print
    register: ipmitool_output
    changed_when: ipmitool_output.rc != 0
    become: true

  - name: Set BMC IP address as fact
    set_fact:
      bmc_address: "{{ ipmitool_output.stdout | regex_search('IP Address\\s+:\\s+(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})', '\\1')
                                              | first }}"

  - name: Set something for SessionService
    community.general.redfish_config:
      category: SessionService
      command: SetSessionService
      sessionservice_config:
        SessionTimeout: 800
      baseuri: "{{ bmc_address }}"
      username: "{{ bmc_username }}"
      password: "{{ bmc_password }}"
      timeout: "{{ default_uri_timeout }}"
    retries: "{{ default_uri_retries }}"
    register: redfish_set_sessionservice

  - debug:
      var: redfish_set_sessionservice

tejabailey avatar Jul 26 '22 15:07 tejabailey

cc @bhavya06 @mraineri @rajeevkallur @renxulei @tomasg2012 @xmadsen click here for bot help

ansibullbot avatar Jul 26 '22 15:07 ansibullbot

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

github-actions[bot] avatar Jul 26 '22 15:07 github-actions[bot]

The test ansible-test sanity --test pylint [explain] failed with 4 errors:

plugins/module_utils/redfish_utils.py:3085:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3089:36: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3098:35: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3102:40: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

The test ansible-test sanity --test pylint [explain] failed with 4 errors:

plugins/module_utils/redfish_utils.py:3085:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3089:36: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3098:35: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3102:40: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

The test ansible-test sanity --test pylint [explain] failed with 4 errors:

plugins/module_utils/redfish_utils.py:3085:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3089:36: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3098:35: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3102:40: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

click here for bot help

ansibullbot avatar Aug 23 '22 19:08 ansibullbot

@felixfontein I missed the discussion about this Docs Build feature in the PRs. Why do they get so long? It is quite annoying to work in the PR having to scroll multiple pages in the browser up and down.

russoz avatar Aug 25 '22 09:08 russoz

@felixfontein I missed the discussion about this Docs Build feature in the PRs. Why do they get so long? It is quite annoying to work in the PR having to scroll multiple pages in the browser up and down.

See https://github.com/ansible-community/github-docs-build/issues/3 and https://github.com/ansible-community/github-docs-build/issues/36 for some background. @briantist since this is still happening (and can be very annoying, see the above comment which basically mentions every single plugin and module in this repository), should we reopen one of them, or create a new issue?

felixfontein avatar Aug 27 '22 09:08 felixfontein

@felixfontein I missed the discussion about this Docs Build feature in the PRs. Why do they get so long? It is quite annoying to work in the PR having to scroll multiple pages in the browser up and down.

See ansible-community/github-docs-build#3 and ansible-community/github-docs-build#36 for some background. @briantist since this is still happening (and can be very annoying, see the above comment which basically mentions every single plugin and module in this repository), should we reopen one of them, or create a new issue?

It has probably been long enough to open up a new issue.

We're really kind of stuck between the pros and cons of the virtual merge branch, the PR HEAD commit, or the "merge commit sha" (which has all kinds of other problems as we've seen).

I'm wondering if the next step is that we decide on a cut-off X for the number of changed files, and if it's > X then we put the file list in an expanding section with <details></details>.

While we're not really addressing the underlying issue of what changes are the correct ones, it does address any case where the number of changes (legitimate or not) is large and cumbersome to scroll through.

What do you think?

briantist avatar Aug 27 '22 13:08 briantist

I think we might as well put it in a

section regardless of the size.

russoz avatar Aug 27 '22 20:08 russoz

@russoz @briantist I think <details> only make sense if there are more than, say, 5 changed filenames. Having it there all the time makes it unnecessary hard to use in the common case.

felixfontein avatar Aug 28 '22 10:08 felixfontein

@russoz @briantist I think <details> only make sense if there are more than, say, 5 changed filenames. Having it there all the time makes it unnecessary hard to use in the common case.

Right, this is my thinking as well (although I think 5 is too small haha), but our collective disagreement on it is why I want it to be configurable. Most collections are not c.g and don't need to worry about this. I'd rather let every collection decide the threshold for themselves.


EDIT: I will unsubscribe from this PR for now, please @ me if anything more is needed from me :)

briantist avatar Aug 28 '22 14:08 briantist

The test ansible-test sanity --test pylint [explain] failed with 3 errors:

plugins/module_utils/redfish_utils.py:3114:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3118:36: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3131:40: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

The test ansible-test sanity --test pylint [explain] failed with 3 errors:

plugins/module_utils/redfish_utils.py:3114:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3118:36: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3131:40: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

The test ansible-test sanity --test pylint [explain] failed with 3 errors:

plugins/module_utils/redfish_utils.py:3114:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3118:36: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3131:40: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

click here for bot help

ansibullbot avatar Sep 01 '22 18:09 ansibullbot

@tejabailey please note that the tests are failing. This needs to be fixed before this can be merged.

felixfontein avatar Sep 12 '22 18:09 felixfontein

@felixfontein working on it, thank you.

tejabailey avatar Sep 13 '22 17:09 tejabailey

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

plugins/module_utils/redfish_utils.py:3114:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3131:40: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

plugins/module_utils/redfish_utils.py:3114:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3131:40: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

plugins/module_utils/redfish_utils.py:3114:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead
plugins/module_utils/redfish_utils.py:3131:40: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

click here for bot help

ansibullbot avatar Sep 20 '22 17:09 ansibullbot

The test ansible-test sanity --test pylint [explain] failed with 1 error:

plugins/module_utils/redfish_utils.py:3114:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

The test ansible-test sanity --test pylint [explain] failed with 1 error:

plugins/module_utils/redfish_utils.py:3114:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

The test ansible-test sanity --test pylint [explain] failed with 1 error:

plugins/module_utils/redfish_utils.py:3114:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

The test ansible-test sanity --test pylint [explain] failed with 1 error:

plugins/module_utils/redfish_utils.py:3114:31: unnecessary-dict-index-lookup: Unnecessary dictionary index lookup, use 'set_value' instead

click here for bot help

ansibullbot avatar Sep 21 '22 14:09 ansibullbot

Hi! I The last pylint error has been corrected. Is this PR ok to merge now?

tejabailey avatar Sep 21 '22 14:09 tejabailey

One last change request, then we can merge (assuming that @mraineri does not have further comments).

I do not have anything else; everything looks good to me so far.

mraineri avatar Sep 22 '22 12:09 mraineri

(The REUSE fail is because the test was changed to not rebase. That way I don't have to manually approve every run :) At least for this PR it can be safely ignored.)

felixfontein avatar Sep 25 '22 15:09 felixfontein

Backport to stable-5: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-5/d9d830a1680f7dec4601b41200323a9e1534a4bb/pr-5009

Backported as https://github.com/ansible-collections/community.general/pull/5311

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

patchback[bot] avatar Sep 25 '22 15:09 patchback[bot]

@tejabailey thanks for this contribution! @mraineri @russoz thanks for reviewing!

felixfontein avatar Sep 25 '22 15:09 felixfontein