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

new feature suggestion: OS command and retrieve Operating System Messages #565

Closed
ScYang1991 opened this issue Aug 3, 2022 · 6 comments · Fixed by #819
Closed

new feature suggestion: OS command and retrieve Operating System Messages #565

ScYang1991 opened this issue Aug 3, 2022 · 6 comments · Fixed by #819

Comments

@ScYang1991
Copy link

It would be very helpful if sending OS command and Retrieving Operating System Messages features can be added to this collection. Think IPLs and SHUTDOWNs that require certain OS commands to be executed can be automated.
Those features should be available from HMC web API from 2.14.1.

Thanks.

@andy-maier andy-maier self-assigned this Nov 29, 2022
@andy-maier
Copy link
Member

Hello @ScYang1991
The question is how should an Ansible module be designed for that, since Ansible is normally used to get a system or resource to a desired end state, but this is more action oriented.

Let me give an idea how I think this could be designed, just to have something to discuss, but I'm really interested in your ideas on that:

One idea is to have a module that checks the console for a specific expected OS message, and if present, it sends a particular OS command to the console. Interesting questions are:

  • Does the command to be sent needs to be formed by using items from the actual OS message?
  • How far back in the stream of OS messages shuld the expected message to be looked for?
  • Is regexp pattern matching needed to find the expected OS message?
  • Is a timeout needed to specify for how long the module should wait for the expected message before it fails?

@ScYang1991
Copy link
Author

@andy-maier
Thank you for your response.
I understand that retrieving OS command's system response would be difficult.
Currently I am using combination of playbook and python script for the purpose with below logic.

  1. retrieve OS console message using zhmcclient open_os_message_channel & NotificationReceiver
  2. execute OS command using zhmcclient send_os_command
  3. retrieve OS console message using zhmcclient open_os_message_channel & NotificationReceiver
  4. compare difference between result list of 1. and 3. (loop until it finds a record for given string such as message ID for a given time of attempts & interval) loop is done by using ansible playbook feature as below
  until: after_command.stdout | from_json | difference(before_command.stdout) | map(attribute='message-text') | list is search('expected response message ID')
  delay: 30
  retries: 5

So having "send OS command" and "retrieve OS console message list" independently would be enough for my purpose of use. Dynamically tracking system response would not be required.

Then it would be able to achieve the same result with below logic.

  1. retrieve OS console message using "retrieve OS console message list" module
  2. execute OS command using zhmcclient "send OS command" module
  3. retrieve OS console message using "retrieve OS console message list" module
  4. compare difference between result list of 1. and 3. with same logic as above.

Thanks.

@andy-maier
Copy link
Member

Support for "List OS Messages" is being added to the zhmcclient library in PR zhmcclient/python-zhmcclient#1279 (targeted for zhmcclient 1.12.0)

@andy-maier andy-maier modified the milestones: 1.7.0, 1.8.0 Oct 5, 2023
andy-maier added a commit that referenced this issue Nov 16, 2023
Details:

* Added new Ansible modules 'zhmc_lpar_messages' and 'zhmc_partition_messages'
  that retrieve and return console messages from the operating system running
  in an LPAR or DPM partition. (issue #565)

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
@andy-maier
Copy link
Member

andy-maier commented Nov 16, 2023

PR #819 adds support for new Ansible modules that retrieve OS messages for LPARs and DPM partitions. It is targeted for the ibm_zhmc Ansible collection version 1.8.0.

@ScYang1991 Please review that functionality and speak up as needed.

andy-maier added a commit that referenced this issue Nov 16, 2023
Details:

* Added new Ansible modules 'zhmc_lpar_messages' and 'zhmc_partition_messages'
  that retrieve and return console messages from the operating system running
  in an LPAR or DPM partition. (issue #565)

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
andy-maier added a commit that referenced this issue Nov 16, 2023
Details:

* Added new Ansible modules 'zhmc_lpar_messages' and 'zhmc_partition_messages'
  that retrieve and return console messages from the operating system running
  in an LPAR or DPM partition. (issue #565)

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
andy-maier added a commit that referenced this issue Nov 16, 2023
Details:

* Added new Ansible modules 'zhmc_lpar_messages' and 'zhmc_partition_messages'
  that retrieve and return console messages from the operating system running
  in an LPAR or DPM partition. (issue #565)

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
andy-maier added a commit that referenced this issue Nov 17, 2023
Details:

* Added new Ansible modules 'zhmc_lpar_messages' and 'zhmc_partition_messages'
  that retrieve and return console messages from the operating system running
  in an LPAR or DPM partition. (issue #565)

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
andy-maier added a commit that referenced this issue Nov 23, 2023
Details:

* Added new Ansible modules 'zhmc_lpar_messages' and 'zhmc_partition_messages'
  that retrieve and return console messages from the operating system running
  in an LPAR or DPM partition. (issue #565)

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
andy-maier added a commit that referenced this issue Dec 7, 2023
Details:

* Added new Ansible modules 'zhmc_lpar_messages' and 'zhmc_partition_messages'
  that retrieve and return console messages from the operating system running
  in an LPAR or DPM partition. (issue #565)

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
@andy-maier
Copy link
Member

@ScYang1991 Somehow the request for supporting the sending of OS commands got lost in this discussion. I have created issue #938 for that.

@andy-maier
Copy link
Member

andy-maier commented Jul 13, 2024

@ScYang1991 PR #1033 is adding support for executing OS consosle commands in LPARs and partitions. The new modules return the command output, so you do not have to get and compare the messages in the playbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants