HewlettPackard / ilo-ansible-collection

Ansible Collection and Sample Playbooks for HPE iLO
Apache License 2.0
43 stars 23 forks source link

ilo_oem_utils.py is missing #19

Open ckirim1 opened 1 year ago

ckirim1 commented 1 year ago

Hello Dear, I performed all prerequisites. but when I run my playbook I am facing with the following error below;

fatal: [localhost]: FAILED! => {"changed": false, "msg": "missing required fucntions in ilo_oem_utils.py"}

Bhavya06 commented 1 year ago

Hi @ckirim1 !

Could you tell us which playbooks you are trying to run?

ckirim1 commented 1 year ago

I am trying use ;


rajeevkallur commented 1 year ago

Did you do all the below setup?

Ansible set up To install Ansible and Community general package use:

sudo python -m pip install ansible ansible-galaxy collection install community.general pip install python-ilorest-library

ckirim1 commented 1 year ago

hi,

all requirements or dependencies are installed. like below;

hpe@sapdeploy:~/ansible$ python3 -m pip install ansible Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: ansible in /usr/local/lib/python3.10/dist-packages (8.1.0) Requirement already satisfied: ansible-core~=2.15.1 in /usr/local/lib/python3.10/dist-packages (from ansible) (2.15.1) Requirement already satisfied: PyYAML>=5.1 in /usr/lib/python3/dist-packages (from ansible-core~=2.15.1->ansible) (5.4.1) Requirement already satisfied: cryptography in /usr/lib/python3/dist-packages (from ansible-core~=2.15.1->ansible) (3.4.8) Requirement already satisfied: jinja2>=3.0.0 in /usr/lib/python3/dist-packages (from ansible-core~=2.15.1->ansible) (3.0.3) Requirement already satisfied: packaging in /usr/lib/python3/dist-packages (from ansible-core~=2.15.1->ansible) (21.3) Requirement already satisfied: resolvelib<1.1.0,>=0.5.3 in /usr/local/lib/python3.10/dist-packages (from ansible-core~=2.15.1->ansible) (1.0.1)

hpe@sapdeploy:~/ansible$ ansible --version ansible [core 2.15.1] config file = None configured module search path = ['/home/hpe/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible ansible collection location = /home/hpe/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible python version = 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] (/usr/bin/python3) jinja version = 3.0.3 libyaml = True

hpe@sapdeploy:~/ansible$ ansible-galaxy collection install community.general Starting galaxy collection install process Nothing to do. All requested collections are already installed. If you want to reinstall them, consider using --force.

hpe@sapdeploy:~/ansible$ pip install python-ilorest-library Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: python-ilorest-library in /home/hpe/.local/lib/python3.10/site-packages (4.3.0.0) Requirement already satisfied: six in /usr/lib/python3/dist-packages (from python-ilorest-library) (1.16.0) Requirement already satisfied: jsonpatch in /home/hpe/.local/lib/python3.10/site-packages (from python-ilorest-library) (1.33) Requirement already satisfied: urllib3 in /usr/lib/python3/dist-packages (from python-ilorest-library) (1.26.5) Requirement already satisfied: jsonpath-rw in /home/hpe/.local/lib/python3.10/site-packages (from python-ilorest-library) (1.4.0) Requirement already satisfied: jsonpointer in /home/hpe/.local/lib/python3.10/site-packages (from python-ilorest-library) (2.4) Requirement already satisfied: ply in /home/hpe/.local/lib/python3.10/site-packages (from jsonpath-rw->python-ilorest-library) (3.11) Requirement already satisfied: decorator in /home/hpe/.local/lib/python3.10/site-packages (from jsonpath-rw->python-ilorest-library) (5.1.1)

Bhavya06 commented 1 year ago

Hi @ckirim1 , We have made the appropriate changes and released a new build on Ansible galaxy. Could you verify using the new files? Kindly notice the changes done to the readme as well. We have added 2 new modules to install.

dblviking commented 1 year ago

Hi @ckirim1 , We have made the appropriate changes and released a new build on Ansible galaxy. Could you verify using the new files? Kindly notice the changes done to the readme as well. We have added 2 new modules to install.

why are the repos out of sync? Should I not trust the github repo?

Bhavya06 commented 1 year ago

Hi @dblviking , The code is uniform throughout Ansible galaxy and this GitHub repository. We just use Ansible galaxy as our main point of contact.

sai438 commented 1 year ago

I seem to have same issue and after troubleshooting, and fixing the following code, everything started to work

diff --git a/plugins/module_utils/ilo_oem_utils.py b/plugins/module_utils/ilo_oem_utils.py
index 48d627f..ad05889 100644
--- a/plugins/module_utils/ilo_oem_utils.py
+++ b/plugins/module_utils/ilo_oem_utils.py
@@ -2784,12 +2784,13 @@ class iLOOemUtils(RedfishUtils):
     def get_phy_nic_info(self):

         # Get on self.root_uri + self.service_root + /systems/1
-        response = self.get_systems_data()
+        #response = self.get_systems_data()
+        response = self.get_request(self.root_uri + self.systems_uri)

         if not response["ret"]:
             return response

-        json_data = response["msg"]["data"]
+        json_data = response["data"]
         # check whether gen11 server or not
         if "Gen11" not in json_data["Model"]:
             nic = []

Otherwise i was getting the following error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'iLOOemUtils' object has no attribute 'get_systems_data'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1701068368.6391258-2277-114105298413712/AnsiballZ_ilo_network.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1701068368.6391258-2277-114105298413712/AnsiballZ_ilo_network.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1701068368.6391258-2277-114105298413712/AnsiballZ_ilo_network.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.hpe.ilo.plugins.modules.ilo_network', init_globals=dict(_module_fqn='ansible_collections.hpe.ilo.plugins.modules.ilo_network', _modlib_path=modlib_path),\n  File \"/usr/lib64/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib64/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_hpe.ilo.ilo_network_payload_j202uv9r/ansible_hpe.ilo.ilo_network_payload.zip/ansible_collections/hpe/ilo/plugins/modules/ilo_network.py\", line 228, in <module>\n  File \"/tmp/ansible_hpe.ilo.ilo_network_payload_j202uv9r/ansible_hpe.ilo.ilo_network_payload.zip/ansible_collections/hpe/ilo/plugins/modules/ilo_network.py\", line 219, in main\n  File \"/tmp/ansible_hpe.ilo.ilo_network_payload_j202uv9r/ansible_hpe.ilo.ilo_network_payload.zip/ansible_collections/hpe/ilo/plugins/module_utils/ilo_oem_utils.py\", line 2787, in get_phy_nic_info\nAttributeError: 'iLOOemUtils' object has no attribute 'get_systems_data'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

and if we are using delegate_to to delegate the task to another node then you are expected to have python redfish module on the destination host. which seems to be missing from the README

rajeevkallur commented 1 year ago

@sai438 Will take a look.