HPE OneView
1832274 Members
2241 Online
110041 Solutions
New Discussion

OneView REST API force discover hardware server

 
SOLVED
Go to solution
HPESeven
Advisor

OneView REST API force discover hardware server

Hello Guys,

I'd like to know if that is possible to force discover hardware server via OneView REST API?
Since I have 100+ HPE servers managed by another Oneview Instance(crashed ), I don't like to click the option "force add hardware server " one by one when I add them into my new Instance, 

Is there something like below, by adding parameters like force Ture?

POST https://{appl}/rest/server-hardware/discovery

Auth: abcdefghijklmnopqrstuvwxyz012345
X-Api-Version: 3600
Content-Type: application/json
Accept-Language: en_US
{
"mpHostsAndRanges" : ["enc-ilo.corp.com", "172.1.1.1-172.1.1.10"],
"username" : "Administrator",
"password" : "mypassword",
"licensingIntent":"OneView",
"configurationState":"Managed",
"force": ture,
"initialScopeUris": ["/rest/scopes/13c1606f-f1cb-473b-9c01-02e3a1a54589"]
}

I very much appreciate it if there is any update, thanks in advance.
Best Regards
Seven 


BTW the failed error logs FYI

Validate server information.

  1. Issue 

    Server already monitored
    Server {0} cannot be added as it is already being monitored.

    Resolution 

    Release the server from its current manager and try again, or retry the request using force option.

5 REPLIES 5
support_s
System Recommended

Query: OneView REST API force discover hardware server

System recommended content:

1. HP OneView REST API Reference

2. HPE StoreOnce REST API and SDK version 3.18.x User Guide

 

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

 

Thank you for being a HPE valuable community member.


Accept or Kudo

HPESeven
Advisor

Re: Query: OneView REST API force discover hardware server

HI, 

Thanks for your updates, 
I have lookup the API reference and the Links you provide, it doesn't work.

Based on Powershell HPEOneView.600 Add-OVServer help:
-Confirm <SwitchParameter>
When attempting to add a Server to the appliance, the appliance will validate the target Server is not already claimed. If it is, this parameter is used when the server has been claimed by another appliance to bypass the confirmation prompt, and force add the server resource.

It still doesn't work.

Add-OVServer -Hostname $IP -Confirm -LicensingIntent OneView -Password $passwd -Username $user
Add-OVServer : "The server hardware has already been added as "". Release the server from its current manager and try again, or retry the
request using force option. If the server is orphaned, use Remove-OVServer -Force Cmdlet, and then try your add again.
At line:1 char:1
+ Add-OVServer -Hostname IP -LicensingIntent OneView -Pass ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (Hostname:String) [Add-OVServer], ServerHardwareResourceException
+ FullyQualifiedErrorId : ServerResourceExists,Add-OVServer

Thanks
Seven

ChrisLynch
HPE Pro
Solution

Re: Query: OneView REST API force discover hardware server

Your use of the Cmdlet is off.  It should be:

Add-OVServer -Hostname $IP -Confirm -LicensingIntent OneView -Password $passwd -Username $user -Confirm:$false

The -Confirm switch is a common PowerShell parameter.

As for a native REST API call, one does not exist.  We never scoped the add host range to force claim.  This would cause severe sideaffects we didn't want customers to get themselves into.  Instead, you need to loop through a collection of iLO addresses and use the JSON force property instead.

I work at HPE
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
HPESeven
Advisor

Re: Query: OneView REST API force discover hardware server

Hi Chris, 

Thanks, much, for the REST API, refer to your recommendations, I can do it now via the script below:

for i in {10..100}
do
data="{ \"hostname\":\192.168.1.${i}\",\"username\":\"admin\",\"password\":\"passwd\",\"force\":true,\"licensingIntent\":\"OneView\",\"configurationState\":\"Managed\" }"
echo $data
curl -k -H "accept: application/json" -H "content-type: application/json" -d "${data}" -H "auth: $sessionID" -X POST https://{appl}/rest/server-hardware
done


For the Cmdlet,  It also works  via cmd below:

PS> Add-OVServer -Hostname 192.168.1.100-Password passwd -Username admin -Confirm:$true
Appliance    Name Owner         Created              Duration TaskState PercentComplete
---------    ---- -----         -------              -------- --------- ---------------
appl Add  administrator 3/21/2022 3:38:45 AM 00:00:29 Completed 100            


Thanks again,  have a great day.
Best Regards
Seven

BradV
Esteemed Contributor

Re: Query: OneView REST API force discover hardware server

Hi Seven,

Just a throught - an alternative to using all of the backslashes:

data="{ \"hostname\":\192.168.1.${i}\",\"username\":\"admin\",\"password\":\"passwd\",\"force\":true,\"licensingIntent\":\"OneView\",\"configurationState\":\"Managed\" }"

try:

data='{"hostname":"192.168.1.'${i}'","username":"admin","password":"passwd","force":true,"licensingIntent":"OneView","configurationState":"Managed"}'