- Community Home
- >
- Software
- >
- HPE OneView
- >
- OneView REST API add server to rack
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 05:52 AM - last edited on 03-23-2023 06:11 PM by support_s
03-07-2023 05:52 AM - last edited on 03-23-2023 06:11 PM by support_s
OneView REST API add server to rack
I'm trying to determine if racks will have any benefit to our OneView appliances. I can create the rack object. Now I want to add the equipment in each rack. That would go under the array rackMounts, but I'm not sure how to identify each server, switch, PDU, etc. The servers at least are already added to OneView. Can anyone explain a little more how to add a server? For example a DL380 G10 at U position 1,
{"rackMounts":["location":"CenterFront","topUSlot":2,"uHeight":2]}
how to identify/link to the server?
- Tags:
- OneView
- power supply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 02:50 AM
03-21-2023 02:50 AM
Re: OneView REST API add server to rack
You may try following the below steps:
Get the URI of the server resource: First, you need to obtain the URI of the server resource that you want to add to the rack. You can retrieve this information by making a GET request to the servers collection resource or by using the search API.
Create a new rack mount resource: You can add a new rack mount resource to the rackMounts array of the rack resource by making a POST request to the rack resource's rackMounts subcollection. The request body should contain the necessary properties, such as the location of the device in the rack (for example, CenterFront), the top USlot (for example, 2), and the U height (for example, 2).
Associate the server with the rack mount resource: Once you have created the rack mount resource, you can associate the server with the rack mount resource by updating the server's associatedResource property with the URI of the rack mount resource. You can update this property by making a PATCH request to the server resource, with the new associatedResource value in the request body.
For example, to add a DL380 G10 server at U position 1 in the CenterFront location of a rack, you can use the following API calls:
- Get the URI of the server resource: GET /rest/server-hardware?filter="model='DL380 G10'" -----This API call retrieves the URI of the server resource with the specified model.
- Create a new rack mount resource:
POST /rest/racks/{rackId}/rack-mounts
Request body:
This API call creates a new rack mount resource with the specified location, top USlot, and U height.
{
"location": "CenterFront",
"topUSlot": 1,
"uHeight": 2
} - Associate the server with the rack mount resource:
PATCH /rest/server-hardware/{serverId}
Request body:
{
"associatedResource": "/rest/racks/{rackId}/rack-mounts/{rackMountId}"
}This API call updates the associatedResource property of the server resource with the URI of the newly created rack mount resource.
Note that you need to replace the {rackId}, {serverId}, and {rackMountId} placeholders in the API calls with the actual IDs of the corresponding resources.
See if this helps you!
Also a NOTE: Am not an expert, I may go wrong. Take a back-up of the data, before you perform any steps. You can give a try on your own risk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 07:10 PM
03-21-2023 07:10 PM
Re: OneView REST API add server to rack
Hi, Try the suggestions given by Vinky_99 . If fails, request you to log a case with HPE so that we can test the same in the lab.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 07:18 AM
04-11-2023 07:18 AM
Re: OneView REST API add server to rack
thanks. I'll work on that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 05:45 AM
04-12-2023 05:45 AM
Re: OneView REST API add server to rack
Unfortunately,
POST /rest/racks/{rackId}/rack-mounts
did not work. Get http_404 error. I also did not find that in the REST API reference anywhere. Good idea though.
What I tried, but did not work (the rack info was already added):
RNAME="RACK1"
RURI=$(curl --insecure --silent --header "X-API-Version: ${currentVersion}" --header "auth: ${sessionID}" --request GET ${OneView}/rest/racks | jq -r '.members[] | select(.name == "'${RNAME}'") | .uri' | cut -d/ -f4)
RDATA=$((curl --insecure --silent --header "X-API-Version: ${currentVersion}" --header "auth: ${sessionID}" --request GET ${OneView}/rest/racks/${RURI} | jq -c '.')
# Add a mount location:
RDATA=$(echo ${RDATA} | jq -r '.rackMounts[.rackMounts| length] |= . + {"location":"CenterBack","topUSlot":17,"uHeight":2}')
# The updated RDATA looks good.
curl --insecure --silent --header "X-API-Version: ${currentVersion}" --header "auth: ${sessionID}" \
--header "content-type: application/json" --data "${RDATA}" --request PUT ${OneView}/rest/racks/${RURI} | jq -r '.'
I get back:
Please contact your authorized support representative and provide them with a support dump. ERM100
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 03:14 AM
04-13-2023 03:14 AM
Re: OneView REST API add server to rack
I thought maybe there was a problem with modifying a rack once it was added. So, I attempted to add a rack with all of its mount positions defined:
RACK='rack3'
DATA='{"name":"'${RACK}'","depth":1660,"height":2295,"width":600,"model":48U Rack","partNumber":"Q7G92A","uHeight":48}'
# Add in server locations. Have 4 DL385s:
for U in {2..8..2}; do
DATA=$(echo ${DATA} | jq -r '.rackMounts[.rackMounts| length] |= . + {"location":"CenterBack","topUSlot":'${U}',"uHeight":2}')
done
# Add in the first group of XL225n's
for U in {10..20..2}; do
DATA=$(echo ${DATA} | jq -r '.rackMounts[.rackMounts| length] |= . + {"location":"CenterBack","topUSlot":'${U}',"uHeight":2}')
done
# Add in second group of XL225n's
for U in {28..48..2}; do
DATA=$(echo ${DATA} | jq -r '.rackMounts[.rackMounts| length] |= . + {"location":"CenterBack","topUSlot":'${U}',"uHeight":2}')
done
# Now, add in the rack:
curl --insecure --silent \
--header "X-API-Version: ${currentVersion}" \
--header "auth: ${sessionID}" \
--header "content-type: application/json" \
--data ${DATA} \
--request POST ${OneView}/rest/racks | jq -r '.'
but that still gives back the ERM100 error message.
It also raises the question of how to specify the positions of the four servers contained in a single XL225n? The only allowed values for the location field, are: CenterBack, CenterFron, Left, and Right. Maybe need to add: TopRight, TopLeft, BottomRight, and BottomLeft?