- Community Home
- >
- Software
- >
- HPE OneView
- >
- REST API creating new profile from profile templat...
-
-
Forums
- Products
- Servers and Operating Systems
- Storage
- Software
- Services
- HPE GreenLake
- Company
- Events
- Webinars
- Partner Solutions and Certifications
- Local Language
- China - 简体中文
- Japan - 日本語
- Korea - 한국어
- Taiwan - 繁體中文
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Blog, Poland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Forums
-
Blogs
-
Information
-
English
- 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.
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2022 Hewlett Packard Enterprise Development LP