- Community Home
- >
- Software
- >
- HPE OneView
- >
- REST API creating new profile from profile templat...
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
08-21-2019 08:20 AM
08-21-2019 08:20 AM
I'm not getting any output when trying to create a new server profile from a profile template. This is the process I am using:
# Create a new profile from a server profile template:
UUID='28fa126e-bd5b-43fe-9b3c-1710554f8dcc'
NEW_PROF=$(curl --insecure \
--header "X-API-Version: ${currentVersion}" \
--header "auth: ${sessionID}" \
--request GET ${OneView}/rest/server-profile-templates/${UUID}/new-profile)
#
# Need to modify the returned object.
SRV=my-servername
SRVURI=$(curl --insecure \
--header "X-API-Version: ${currentVersion}" \
--header "auth: ${sessionID}" \
--request GET ${OneView}/rest/server-hardware?filter=%22%27serverName%27%20-%20%27${SRV}%27%22 | jq -r '.members[] | .uri')
SRVNAM=$(curl --insecure \
--header "X-API-Version: ${currentVersion}" \
--header "auth: ${sessionID}" \
--request GET ${OneView}/rest/server-hardware?filter=%22%27serverName%27%20-%20%27${SRV}%27%22 | jq -r '.members[] | .serverName')
echo "Creating a server profile for, ${SRVNAM}, at uri: ${SRVURI}"
#
# Add in the uri:
NEW_PROF1=$(echo ${NEW_PROF} | jq -r '.serverHardwareUri="'${SRVURI}'"')
NEW_PROF=$(echo ${NEW_PROF1} | jq -r '.name="'${SRVNAM}'"')
echo "The new profile will be: $(echo ${NEW_PROF} | jq -r '.')"
curl --insecure \
--header "content-type: application/json" \
--header "X-API-Version: ${currentVersion}" \
--header "auth: ${sessionID}" \
--data "${NEW_PROF}" \
--request GET ${OneView}/rest/server-profiles
The echo just before trying to create looks good. No error messages from jq. So, I think the json is OK. OneView is complaining about anything - just no output and no profile created. Any ideas what I am doing wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2019 08:50 AM
08-21-2019 08:50 AM
SolutionChris's response to another post prompted me to add "--include" to my curl call. I first modified the supplied data to be on one line by changing this line:
NEW_PROF=$(echo ${NEW_PROF1} | jq -r '.name="'${SRVNAM}'"' | jq -c '.')
Note piping it to jq -c. Then I added a '--include' to my curl command:
curl --insecure \
--include \
--header "content-type: application/json" \
--header "X-API-Version: ${currentVersion}" \
--header "auth: ${sessionID}" \
--data "${NEW_PROF}" \
--request GET ${OneView}/rest/server-profiles
and got back:
HTTP/1.1 100 Continue
HTTP/1.1 200 Accepted
Date: Wed, 21 Aug 2019 15:40:33 GMT
Server: Apache
Location: /rest/tasks/0E325C85-7E5E-4112-939E-2F21215D0B6728
Content-Length: 0
cache-control: no-cache
The Location line with the rest task uri is the important one.