Try to create HP iLO discovery pattern without much success

anko_wolf
Tera Contributor

Hi All,

I am trying to create a Discovery Pattern for HP iLO devices. I amanged to create a Classifier that classifies IP address as iLO devices and call my new pattern.

From the pattern, I submit a GET request (to "https://xxx.xxx.xxx.xxx/rest/v1" )  and I get back a JSON response. When I try to parse variables out of this response, I get an error message:

CUSTOM PARSING parsing strategy of output text failed due to an unsupported text format. Please choose another parsing strategy to continue.

Most likely due to finding "@" and "." in the JSON attribute names. After replacing "@" and "." in the Custom Parsing strategy script "JSON File", that error message no longer appears. I can now highlight items in the JSON response and assign them to variables. But on run time, I still get an error message about an XML file that cannot be processed. This approach appears to b a dead end, so I am now looking at using regex to extract values from the response. Not sure where that will lead.

Has anybody build a discovery pattern for ilO and encountered (or even better: dealt with) similar issues? 

Many thanks in advance.

Anko

8 REPLIES 8

robertgeen
Tera Guru

I can't say that I've done a custom pattern for these devices but I can share your pain with special characters messing up JSON parser and XML parser. Any way you can give us an example of what the Json looks like? If so I can probably help you with some Regex to parse it.

Hi robert,

 

Thanks for getting back to me. A good example is this:

 

{
  "@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot",
  "@odata.id": "/redfish/v1/",
  "@odata.type": "#ServiceRoot.1.0.0.ServiceRoot",
  "AccountService": {
    "@odata.id": "/rest/v1/AccountService"
  },
  "Chassis": {
    "@odata.id": "/rest/v1/Chassis"
  },
  "EventService": {
    "@odata.id": "/rest/v1/EventService"
  },
  "Id": "v1",
  "JsonSchemas": {
    "@odata.id": "/rest/v1/Schemas"
  },
  "Managers": {
    "@odata.id": "/rest/v1/Managers"
  },
  "Name": "HP RESTful Root Service",
  "Oem": {
    "Hp": {
      "@odata.type": "#HpiLOServiceExt.1.0.0.HpiLOServiceExt",
      "Manager": [
        {
          "DefaultLanguage": "en",
          "FQDN": "ILOHOSTNAME.",
          "HostName": "ILOHOSTNAME1",
          "Languages": [
            {
              "Language": "en",
              "TranslationName": "English",
              "Version": "2.61"
            }
          ],
          "ManagerFirmwareVersion": "2.61",
          "ManagerType": "iLO 4"
        }
      ],
      "Sessions": {
        "CertCommonName": "ILOHOSTNAME",
        "KerberosEnabled": false,
        "LDAPAuthLicenced": true,
        "LDAPEnabled": false,
        "LocalLoginEnabled": true,
        "LoginFailureDelay": 0,
        "LoginHint": {
          "Hint": "POST to /Sessions to login using the following JSON object:",
          "HintPOSTData": {
            "Password": "password",
            "UserName": "username"
          }
        },
        "SecurityOverride": false,
        "ServerName": "MYHOSTNAME"
      },
      "Type": "HpiLOServiceExt.1.0.0",
      "links": {
        "ResourceDirectory": {
          "href": "/rest/v1/ResourceDirectory"
        }
      }
    }
  },
  "RedfishVersion": "1.0.0",
  "Registries": {
    "@odata.id": "/rest/v1/Registries"
  },
  "ServiceVersion": "1.0.0",
  "SessionService": {
    "@odata.id": "/rest/v1/SessionService"
  },
  "Systems": {
    "@odata.id": "/rest/v1/Systems"
  },
  "Time": "2019-01-11T18:24:07Z",
  "Type": "ServiceRoot.1.0.0",
  "UUID": "12345678-abcd-9876-1234-1234567890ab",
  "links": {
    "AccountService": {
      "href": "/rest/v1/AccountService"
    },
    "Chassis": {
      "href": "/rest/v1/Chassis"
    },
    "EventService": {
      "href": "/rest/v1/EventService"
    },
    "Managers": {
      "href": "/rest/v1/Managers"
    },
    "Registries": {
      "href": "/rest/v1/Registries"
    },
    "Schemas": {
      "href": "/rest/v1/Schemas"
    },
    "SessionService": {
      "href": "/rest/v1/SessionService"
    },
    "Sessions": {
      "href": "/rest/v1/SessionService/Sessions"
    },
    "Systems": {
      "href": "/rest/v1/Systems"
    },
    "self": {
      "href": "/rest/v1"
    }
  }
}

At least, this is how it is shown in the Output field on the GET HTTP step. When running REGEX against it, it appears to be ran against the raw source, which looks like this (no spaces, no line breaks, etc.:

 

{"@odata.context":"/redfish/v1/$metadata#ServiceRoot.ServiceRoot","@odata.id":"/redfish/v1/","@odata.type":"#ServiceRoot.1.0.0.ServiceRoot","AccountService":{"@odata.id":"/rest/v1/AccountService"},"Chassis":{"@odata.id":"/rest/v1/Chassis"},"EventService":{"@odata.id":"/rest/v1/EventService"},"Id":"v1","JsonSchemas":{"@odata.id":"/rest/v1/Schemas"},"Managers":{"@odata.id":"/rest/v1/Managers"},"Name":"HP RESTful Root Service","Oem":{"Hp":{"@odata.type":"#HpiLOServiceExt.1.0.0.HpiLOServiceExt","Manager":[{"DefaultLanguage":"en","FQDN":"ILOHOSTNAME.","HostName":"ILOHOSTNAME1","Languages":[{"Language":"en","TranslationName":"English","Version":"2.61"}],"ManagerFirmwareVersion":"2.61","ManagerType":"iLO 4"}],"Sessions":{"CertCommonName":"ILOHOSTNAME","KerberosEnabled":false,"LDAPAuthLicenced":true,"LDAPEnabled":false,"LocalLoginEnabled":true,"LoginFailureDelay":0,"LoginHint":{"Hint":"POST to /Sessions to login using the following JSON object:","HintPOSTData":{"Password":"password","UserName":"username"}},"SecurityOverride":false,"ServerName":"MYHOSTNAME"},"Type":"HpiLOServiceExt.1.0.0","links":{"ResourceDirectory":{"href":"/rest/v1/ResourceDirectory"}}}},"RedfishVersion":"1.0.0","Registries":{"@odata.id":"/rest/v1/Registries"},"ServiceVersion":"1.0.0","SessionService":{"@odata.id":"/rest/v1/SessionService"},"Systems":{"@odata.id":"/rest/v1/Systems"},"Time":"2019-01-11T18:24:07Z","Type":"ServiceRoot.1.0.0","UUID":"12345678-abcd-9876-1234-1234567890ab","links":{"AccountService":{"href":"/rest/v1/AccountService"},"Chassis":{"href":"/rest/v1/Chassis"},"EventService":{"href":"/rest/v1/EventService"},"Managers":{"href":"/rest/v1/Managers"},"Registries":{"href":"/rest/v1/Registries"},"Schemas":{"href":"/rest/v1/Schemas"},"SessionService":{"href":"/rest/v1/SessionService"},"Sessions":{"href":"/rest/v1/SessionService/Sessions"},"Systems":{"href":"/rest/v1/Systems"},"self":{"href":"/rest/v1"}}}

I did manage to get some stuff out of it using regex, for example using:

UUID":"([^"]*)"

But I seem unable to use /g and/or /U switches to make it find multiple occurrences or to make it un-greedy. Going with JSON Parse seems the most logical thing to do. Unless it is indeed not working with this source.

Cheers,

Anko

Yep unfortunately the /g flag isn't available (it's coming in Madrid I heard). You can do it in an eval script but I wouldn't recommend doing that. What you need to do is find a specific start character and do a delimited text strategy and use it as your line splitter. @odata.context may work if that's the start of a new entry. Once you do that your regex will work because each chunk will be in it's own row of a table and the regex will run on each chunk as singular. Then you can do matches like you are doing and it should return it the way you would expect. This is one way to get around not having a /g capability but you have to be able to split it into it's own rows in the variable table before hand. I hope this makes sense to you.

It does make sense to me. And is helpful. Not sure to flag your answer as the correct one (yet), As I am (still) hoping for an answer that tells me how to use the JSON as it was intended to. Maybe such answer does not exist. 😉