WSMAN enumerate fails to return all entries
When querying an enumeration using the WSMAN enumerate method, not all entries are returned if there are more than max_elems (default of 100) in the enumeration. When querying an enumeration, the first response returns <wsman:Items> in the body. Successive pulls, however, contain <wsen:Items>. The old code always queried for <wsen:Items>, which caused the first batch of attributes to be dropped only when the number of entries in the enumeration exceeded max_elems. This patch queries for <wsman:Items> in the first response, and for <wsen:Items> in successive responses. Change-Id: I2e9036b562c7d7ba5af188dd552b6c67388bb02c Closes-Bug: #1659052
This commit is contained in:
parent
5b987d4495
commit
0c1d56dde5
@ -68,7 +68,7 @@ class ClientTestCase(base.BaseTest):
|
||||
foo_resource_uri = 'http://FooResource'
|
||||
bar_resource_uri = 'http://BarResource'
|
||||
self.assertEqual(
|
||||
3, len(resp_xml.findall('.//{%s}FooResource' % foo_resource_uri)))
|
||||
4, len(resp_xml.findall('.//{%s}FooResource' % foo_resource_uri)))
|
||||
self.assertEqual(
|
||||
1, len(resp_xml.findall('.//{%s}BazResource' % bar_resource_uri)))
|
||||
self.assertEqual(
|
||||
|
@ -1,6 +1,8 @@
|
||||
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
|
||||
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
|
||||
xmlns:wsen="http://schemas.xmlsoap.org/ws/2004/09/enumeration">
|
||||
xmlns:wsen="http://schemas.xmlsoap.org/ws/2004/09/enumeration"
|
||||
xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"
|
||||
xmlns:n1="http://FooResource">
|
||||
<s:Header>
|
||||
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
|
||||
<wsa:Action>http://schemas.xmlsoap.org/ws/2004/09/enumeration/EnumerateResponse</wsa:Action>
|
||||
@ -10,6 +12,11 @@
|
||||
<s:Body>
|
||||
<wsen:EnumerateResponse>
|
||||
<wsen:EnumerationContext>enum-context-uuid</wsen:EnumerationContext>
|
||||
<wsman:Items>
|
||||
<n1:FooResource>
|
||||
<n1:InstanceID>1</n1:InstanceID>
|
||||
</n1:FooResource>
|
||||
</wsman:Items>
|
||||
</wsen:EnumerateResponse>
|
||||
</s:Body>
|
||||
</s:Envelope>
|
||||
|
@ -14,7 +14,7 @@
|
||||
<wsen:EnumerationContext>enum-context-uuid</wsen:EnumerationContext>
|
||||
<wsen:Items>
|
||||
<n1:FooResource>
|
||||
<n1:InstanceID>1</n1:InstanceID>
|
||||
<n1:InstanceID>2</n1:InstanceID>
|
||||
</n1:FooResource>
|
||||
</wsen:Items>
|
||||
</wsen:PullResponse>
|
||||
|
@ -13,10 +13,10 @@
|
||||
<wsen:EnumerationContext>enum-context-uuid</wsen:EnumerationContext>
|
||||
<wsen:Items>
|
||||
<n1:FooResource>
|
||||
<n1:InstanceID>2</n1:InstanceID>
|
||||
<n1:InstanceID>3</n1:InstanceID>
|
||||
</n1:FooResource>
|
||||
<n1:FooResource>
|
||||
<n1:InstanceID>3</n1:InstanceID>
|
||||
<n1:InstanceID>4</n1:InstanceID>
|
||||
</n1:FooResource>
|
||||
</wsen:Items>
|
||||
</wsen:PullResponse>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<wsen:PullResponse>
|
||||
<wsen:Items>
|
||||
<n1:BazResource>
|
||||
<n1:InstanceID>4</n1:InstanceID>
|
||||
<n1:InstanceID>5</n1:InstanceID>
|
||||
</n1:BazResource>
|
||||
</wsen:Items>
|
||||
<wsen:EndOfSequence/>
|
||||
|
@ -105,21 +105,23 @@ class Client(object):
|
||||
resp_xml = ElementTree.fromstring(resp.content)
|
||||
|
||||
if auto_pull:
|
||||
find_items_query = './/{%s}Items' % NS_WSMAN_ENUM
|
||||
# The first response returns "<wsman:Items>"
|
||||
find_items_wsman_query = './/{%s}Items' % NS_WSMAN
|
||||
|
||||
# Successive pulls return "<wsen:Items>"
|
||||
find_items_enum_query = './/{%s}Items' % NS_WSMAN_ENUM
|
||||
|
||||
full_resp_xml = resp_xml
|
||||
items_xml = full_resp_xml.find(find_items_wsman_query)
|
||||
|
||||
context = self._enum_context(full_resp_xml)
|
||||
while context is not None:
|
||||
resp_xml = self.pull(resource_uri, context, max_elems)
|
||||
context = self._enum_context(resp_xml)
|
||||
|
||||
items_xml = full_resp_xml.find(find_items_query)
|
||||
if items_xml is not None:
|
||||
# merge enumeration items
|
||||
for item in resp_xml.find(find_items_query):
|
||||
items_xml.append(item)
|
||||
else:
|
||||
full_resp_xml = resp_xml
|
||||
# Merge in next batch of enumeration items
|
||||
for item in resp_xml.find(find_items_enum_query):
|
||||
items_xml.append(item)
|
||||
|
||||
# remove enumeration context because items are already merged
|
||||
enum_context_elem = full_resp_xml.find('.//{%s}EnumerationContext'
|
||||
|
Loading…
Reference in New Issue
Block a user