DMTF / Redfish-Service-Validator

The Redfish Service Validator is a Python3 tool for checking conformance of any "device" with a Redfish service interface against Redfish CSDL schema
Other
42 stars 34 forks source link

KeyError: 'uri' #14

Closed jbobzin-insyde closed 7 years ago

jbobzin-insyde commented 7 years ago

Can you explain what is wrong? Could it be my subdirectory with schema is not right name?

G:_Redfish_git\Redfish-Service-Validator-Test\Redfish-Service-Validator>py -3 RedfishServiceValidator.py RedfishServiceValidator Config details: (True, 'https://192.168.2.15', 'admin', 'metadata', False, False)

*** ServiceRoot, /redfish/v1 Starting new HTTPS connection (1): 192.168.2.15 C:\python35\lib\site-packages\requests\packages\urllib3\connectionpool.py:821: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning) @odata.context @odata.id @odata.type @Redfish.Copyright

ServiceRoot.1.0.0.ServiceRoot

Starting new HTTPS connection (1): 192.168.2.15 C:\python35\lib\site-packages\requests\packages\urllib3\connectionpool.py:821: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning) Traceback (most recent call last): File "RedfishServiceValidator.py", line 809, in success, counts, results = validateURI('/redfish/v1', 'ServiceRoot') File "RedfishServiceValidator.py", line 703, in validateURI refDict = getReferenceDetails(SchemaSoup) File "RedfishServiceValidator.py", line 174, in getReferenceDetails refDict[item['namespace']] = (item['namespace'], ref['uri']) File "C:\python35\lib\site-packages\bs4\element.py", line 997, in getitem return self.attrs[key] KeyError: 'uri'

ComplianceLog_04_24_2017_191927.txt

tomasg2012 commented 7 years ago

Actually, whatever service you are using seems to have returned something from "/redfish/v1/$metadata". By default, the program will attempt to get schema from the service itself, then fallsback to local schema (should make this a toggle), it seems based on Line 19 it gave a response, but failed because of the getReferences function can't work with it. If you want to grab only from schema XML files you placed in ./metadata, then you must enable LocalOnly

The program itself assumes the schema grabbed makes sense However, the debug output doesn't show what it has from Line 19. What does your service return on "/redfish/v1/$metadata"? Mode.

jbobzin-insyde commented 7 years ago

Changing config.ini so LocalOnlyMode = True changed the error. ComplianceLog_04_24_2017_195021.txt

G:_Redfish_git\Redfish-Service-Validator-Test\Redfish-Service-Validator>py -3 RedfishServiceValidator.py RedfishServiceValidator Config details: (True, 'https://192.168.2.15', 'admin', 'metadata', False, True)

*** ServiceRoot, /redfish/v1 Starting new HTTPS connection (1): 192.168.2.15 C:\python35\lib\site-packages\requests\packages\urllib3\connectionpool.py:821: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning) @odata.context @odata.id @odata.type @Redfish.Copyright

ServiceRoot.1.0.0.ServiceRoot

Traceback (most recent call last): File "RedfishServiceValidator.py", line 728, in validateURI SchemaSoup, refDict, SchemaFullType, 'entitytype') File "RedfishServiceValidator.py", line 217, in getTypeDetails for element in innerschema.find_all(tagType, attrs={'name': SchemaType}): AttributeError: 'NoneType' object has no attribute 'find_all'

Traceback (most recent call last): File "RedfishServiceValidator.py", line 728, in validateURI SchemaSoup, refDict, SchemaFullType, 'entitytype') File "RedfishServiceValidator.py", line 217, in getTypeDetails for element in innerschema.find_all(tagType, attrs={'name': SchemaType}): AttributeError: 'NoneType' object has no attribute 'find_all'

1 Counter({'exceptionGetType': 1, 'passGet': 1}) Validation has failed: 1 problems found

G:_Redfish_git\Redfish-Service-Validator-Test\Redfish-Service-Validator>

jbobzin-insyde commented 7 years ago

here is the $metadata returned by the system under test metadata.txt

tomasg2012 commented 7 years ago

Ah, I see the problem now, this is more of an issue that the program doesn't fail gracefully on certain expectations of a service.

For the first comment after my response, the problem is that the newest DMTF schema does not match the old namespaces. Ordinarily this is not a problem if you locally own the old schemas, but the new type format "#ServiceRoot.v1_0_0.ServiceRoot" does not match "#ServiceRoot.1.0.0.ServiceRoot", and thus doesn't work. This is something we've been discussing, and if your mockup or service is not up to date it might get past ServiceRoot but have issues down the line.

Now the metadata returned in the second comment has issues. One being that I suspect the tags use the acronym url when default schema uses uri, the difference being the third letter. Secondary to that, the namespace includes aren't accurate. Refer to the XML with a search to find the namespace strings inside, eg "ServiceRoot.v1_0_0" or just "ServiceRoot" Your service metadata must explicitly include the namespace of your JSON payload's type, such as:

``

</edmx:Reference>``

You current metadata refers to an early version of schema such as http://redfish.dmtf.org/schemas/v1/ServiceRoot.xml , note the lack of v1 in the xml name. Compare this to http://redfish.dmtf.org/schemas/v1/ServiceRoot_v1.xml , a later release.

jbobzin-insyde commented 7 years ago

Do you have a mockup with correct $metadata for 2016.3? In general I have had trouble finding samples to study.

Thanks, ---Jeff

From: tomasg2012 [mailto:notifications@github.com] Sent: Monday, April 24, 2017 8:16 PM To: DMTF/Redfish-Service-Validator Redfish-Service-Validator@noreply.github.com Cc: Jeff Bobzin jeff.bobzin@insyde.com; Author author@noreply.github.com Subject: Re: [DMTF/Redfish-Service-Validator] KeyError: 'uri' (#14)

Ah, I see the issues now.

For the first comment, the problem is that the newest DMTF schema does not match the old namespaces. Ordinarily this is not a problem if you locally own the old schemas, but the new type format "#ServiceRoot.v1_0_0.ServiceRoot" does not match "#ServiceRoot.1.0.0.ServiceRoot", and thus doesn't work. This is something we've been discussing, and if your mockup or service is not up to date it might get past ServiceRoot but have issues down the line.

Now the metadata returned in the second comment has issues. One being that I suspect the tags use the acronym url when default schema uses uri, the difference being the third letter. Secondary to that, the namespace includes aren't accurate. Refer to the XML with a search to find the namespace strings inside, eg "ServiceRoot.v1_0_0" or just "ServiceRoot" Your service metadata must explicitly include the namespace of your JSON payload's type.

You current metadata refers to a previous version of schema such as http://redfish.dmtf.org/schemas/v1/ServiceRoot.xml , note the lack of v1 in the xml name.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/DMTF/Redfish-Service-Validator/issues/14#issuecomment-296856169, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHyHgXe61UtiV0ZQhtruGOUYAn7-Wss_ks5rzTtFgaJpZM4NG1CK.

mraineri commented 7 years ago

It might be good to do key tests and fail if something doesn't exist; that way you can build a more understandable error rather than relying on an exception with a stack trace.

tomasg2012 commented 7 years ago

I apologize as I keep editing my comments at the automatic emails may not be accurate. But that is true, this is an exercise in service expectations that the program either should not have or should check for.

As it stands, $metadata itself is dependent on the service, but as an expectation, the root document "/redfish/v1/$metadata" returns something like this:

metadataNow.txt

And should be similar, with exceptions to the namespaces and file destinations, which can be hosted on the service via a uri (/redfish/v1/...) or a url (as in http://etc), but must use the tag attribute "uri"

jbobzin-insyde commented 7 years ago

changing the config.ini setting to LocalOnlyMode = True changed the error. ComplianceLog_04_24_2017_195021.txt

jbobzin-insyde commented 7 years ago

Problem in the test system

tomasg2012 commented 7 years ago

http://www.dmtf.org/standards/redfish

If you wish to try the appropriate 1.0.0 schema, it is located on this page as DSP8010. Then you would have to put those in your local XML, they might need to be renamed with _v1 in the title. I don't have access to a 1.0.0 service, but should be able to work with 1.0.0 services to some degree.

There are also mockups if you still need reference material, as the latest DSP2043 zip file.

jbobzin-insyde commented 7 years ago

I did some patching today in Redfish implementation today. Will test tomorrow. Might take a couple days to avoid blowing up your program. Our implementation is targeting 2016.3 release.

From: tomasg2012 [mailto:notifications@github.com] Sent: Tuesday, April 25, 2017 10:01 PM To: DMTF/Redfish-Service-Validator Redfish-Service-Validator@noreply.github.com Cc: Jeff Bobzin jeff.bobzin@insyde.com; State change state_change@noreply.github.com Subject: Re: [DMTF/Redfish-Service-Validator] KeyError: 'uri' (#14)

http://www.dmtf.org/standards/redfish

If you wish to try the appropriate 1.0.0 schema, it is located on this page as DSP8010. Then you would have to put those in your local XML, they might need to be renamed with _v1 in the title. I don't have access to a 1.0.0 service. It should be able to work with 1.0.0 services to some degree.

There are also mockups if you still need reference material, as the latest DSP2043 zip file.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/DMTF/Redfish-Service-Validator/issues/14#issuecomment-297216054, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHyHgdX9MjOFzf3sKRd8Ig3cLlUGC1rcks5rzqVzgaJpZM4NG1CK.