<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic REST API creating new profile from profile template in HPE OneView</title>
    <link>https://community.hpe.com/t5/hpe-oneview/rest-api-creating-new-profile-from-profile-template/m-p/7059385#M4496</link>
    <description>&lt;P&gt;I'm not getting any output when trying to create a new server profile from a profile template.&amp;nbsp; This is the process I am using:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# 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&lt;/LI-CODE&gt;&lt;P&gt;The echo just before trying to create looks good.&amp;nbsp; No error messages from jq.&amp;nbsp; So, I think the json is OK.&amp;nbsp; OneView is complaining about anything - just no output and no profile created.&amp;nbsp; Any ideas what I am doing wrong?&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2019 15:20:30 GMT</pubDate>
    <dc:creator>BradV</dc:creator>
    <dc:date>2019-08-21T15:20:30Z</dc:date>
    <item>
      <title>REST API creating new profile from profile template</title>
      <link>https://community.hpe.com/t5/hpe-oneview/rest-api-creating-new-profile-from-profile-template/m-p/7059385#M4496</link>
      <description>&lt;P&gt;I'm not getting any output when trying to create a new server profile from a profile template.&amp;nbsp; This is the process I am using:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# 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&lt;/LI-CODE&gt;&lt;P&gt;The echo just before trying to create looks good.&amp;nbsp; No error messages from jq.&amp;nbsp; So, I think the json is OK.&amp;nbsp; OneView is complaining about anything - just no output and no profile created.&amp;nbsp; Any ideas what I am doing wrong?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 15:20:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-oneview/rest-api-creating-new-profile-from-profile-template/m-p/7059385#M4496</guid>
      <dc:creator>BradV</dc:creator>
      <dc:date>2019-08-21T15:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: REST API creating new profile from profile template</title>
      <link>https://community.hpe.com/t5/hpe-oneview/rest-api-creating-new-profile-from-profile-template/m-p/7059390#M4497</link>
      <description>&lt;P&gt;Chris's response to another post prompted me to add "--include" to my curl call.&amp;nbsp; I first modified the supplied data to be on one line by changing this line:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;NEW_PROF=$(echo ${NEW_PROF1} | jq -r '.name="'${SRVNAM}'"' | jq -c '.')&lt;/LI-CODE&gt;&lt;P&gt;Note piping it to jq -c.&amp;nbsp; Then I added a '--include' to my curl command:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;and got back:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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&lt;/LI-CODE&gt;&lt;P&gt;The Location line with the rest task uri is the important one.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 15:50:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-oneview/rest-api-creating-new-profile-from-profile-template/m-p/7059390#M4497</guid>
      <dc:creator>BradV</dc:creator>
      <dc:date>2019-08-21T15:50:35Z</dc:date>
    </item>
  </channel>
</rss>

