HPE OneView
1770848 Members
3438 Online
109001 Solutions
New Discussion юеВ

pyrhon script to create new ilo user from oneview

 
Enrico_IT
Occasional Visitor

pyrhon script to create new ilo user from oneview

Hi everyone,

I'm trying to create a python script to create a user on ILO5 managed directly by oneview.

The restrictions I have are these:
1. I don't have an ilo username and password.
2. To access the ILO I have to go through oneview or the onboard administrator of the C7000.
3. The script must work for any blade>.

This is my script but it gives an error when I try to connect to the ILO from oneview.

I'm trying to consult the oneview 6.6 REST API but I can't find any solution.

Can you help me? I've been looking for a solution for days without success.

 

 

import requests
from requests.auth import HTTPBasicAuth

# OneView Login
oneview_host = "https://<IP>"
oneview_username = "<username>"
oneview_password = "<pass>"

# Token from OneView
def get_oneview_session_token():
auth_url = f"{oneview_host}/rest/login-sessions"
auth_data = {"userName": oneview_username, "password": oneview_password}
response = requests.post(auth_url, json=auth_data, verify=False)  # Disabilita la verifica SSL se necessario
if response.status_code == 200:
return response.json()['sessionID']
else:
raise Exception("Failed to authenticate with OneView")

# Function to create the iLO user
def create_ilo_user(ilo_ip, username, password, user_login="test", user_password="test"
ilo_url = f"https://{ilo_ip}/redfish/v1/AccountService/Accounts/"
new_user_data = {
"UserName": user_login,
"Password": user_password,
"Oem": {
"Hp": {
"LoginName": user_login,
"Privileges": {
"LoginPriv": True,
"RemoteConsolePriv": True,
"UserConfigPriv": True,
"VirtualMediaPriv": True,
"iLOConfigPriv": True,
"VirtualPowerAndResetPriv": True
                }
            }
        }
    }
response = requests.post(ilo_url, json=new_user_data, auth=HTTPBasicAuth(username, password), verify=False)  # disable SSL check if necessary
if response.status_code in [200, 201]:
print(f"User {user_login} created successfully on {ilo_ip}.")
else:
print(f"Failed to create user on {ilo_ip}. Response: {response.text}")

# Ilo login
token = get_oneview_session_token()
ilo_ip_list = ["<iplist,iplist>"

for ilo_ip in ilo_ip_list:
create_ilo_user(ilo_ip, oneview_username, oneview_password)
 
 
3 REPLIES 3
support_s
System Recommended

Query: pyrhon script to create new ilo user from oneview

System recommended content:

1. HPE iLO 6 1.56 User Guide | Other iLO configuration tools

2. HPE iLO 5 3.01 User Guide | Other iLO configuration tools

 

Please click on "Thumbs Up/Kudo" icon to give a "Kudo".

 

Thank you for being a HPE valuable community member.


Accept or Kudo

Enrico_IT
Occasional Visitor

Re: Query: pyrhon script to create new ilo user from oneview

Hi,

I have already viewed both solutions, but unfortunately isn't good because I don't have the ilo password, and the same procedure I need to improve in ~400 blades.

 

the idea is to reduce the procedure using a script and Oneview user. but I have a problem to forward the request

ChrisLynch
HPE Pro

Re: Query: pyrhon script to create new ilo user from oneview

You can manage user accounts directly from a Server Profile, without needing to develop a script to accomplish this task.  Please review this documentation on iLO Settings that can be managed by server profiles here (v8.70) or here (v6.60). As you are asking for HPE BladeSystem c-Class support, you need to read the 6.60 Online Help.


I am an HPE employee

Accept or Kudo