<?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 Python client library: Volume.get_collection(): Validation Error when volume is restricted in Python Discussions</title>
    <link>https://community.netapp.com/t5/Python-Discussions/Python-client-library-Volume-get-collection-Validation-Error-when-volume-is/m-p/168493#M60</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We just found that the&amp;nbsp; Volume.get_collection() method throws an exception when executed against a SVM containing restricted volumes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a function calling the method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;def getvolumeuuids(vserver, pattern):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; uuidlist = []&lt;BR /&gt;&amp;nbsp; &amp;nbsp; try:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for volume in Volume.get_collection(**{"svm.name": vserver}, fields="*"):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if root_match(str(volume.name)):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if reg_match(str(volume.name), pattern):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; uuidlist.append(('{}'.format(volume.name), '{}'.format(volume.uuid), '{}'.format(volume.aggregates[0].name)))&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; except NetAppRestError as error:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print('Error: exception raised when calling Volume.get_collection for vserver {0}: [{1}]'.format(vserver, str(error)))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return []&lt;BR /&gt;&amp;nbsp; &amp;nbsp; else:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return uuidlist&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When called given a vserver with restricted volumes, we get this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error: exception raised when calling Volume.get_collection for vserver xxxxx-xxx-xxxx: [Caused by ValidationError({'state': ['"restricted" is not one of [\'error\', \'mixed\', \'offline\', \'online\']']},)]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue was found to exist within version 9.7.3 and 9.9.1 of the netapp_ontap package.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please have a look at why the restricted status is not considered as a valid returned value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pierre Kestremond&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jun 2025 10:18:44 GMT</pubDate>
    <dc:creator>pierrekestremond</dc:creator>
    <dc:date>2025-06-04T10:18:44Z</dc:date>
    <item>
      <title>Python client library: Volume.get_collection(): Validation Error when volume is restricted</title>
      <link>https://community.netapp.com/t5/Python-Discussions/Python-client-library-Volume-get-collection-Validation-Error-when-volume-is/m-p/168493#M60</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We just found that the&amp;nbsp; Volume.get_collection() method throws an exception when executed against a SVM containing restricted volumes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a function calling the method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;def getvolumeuuids(vserver, pattern):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; uuidlist = []&lt;BR /&gt;&amp;nbsp; &amp;nbsp; try:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for volume in Volume.get_collection(**{"svm.name": vserver}, fields="*"):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if root_match(str(volume.name)):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if reg_match(str(volume.name), pattern):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; uuidlist.append(('{}'.format(volume.name), '{}'.format(volume.uuid), '{}'.format(volume.aggregates[0].name)))&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; except NetAppRestError as error:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print('Error: exception raised when calling Volume.get_collection for vserver {0}: [{1}]'.format(vserver, str(error)))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return []&lt;BR /&gt;&amp;nbsp; &amp;nbsp; else:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return uuidlist&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When called given a vserver with restricted volumes, we get this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error: exception raised when calling Volume.get_collection for vserver xxxxx-xxx-xxxx: [Caused by ValidationError({'state': ['"restricted" is not one of [\'error\', \'mixed\', \'offline\', \'online\']']},)]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue was found to exist within version 9.7.3 and 9.9.1 of the netapp_ontap package.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please have a look at why the restricted status is not considered as a valid returned value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pierre Kestremond&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 10:18:44 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Python-Discussions/Python-client-library-Volume-get-collection-Validation-Error-when-volume-is/m-p/168493#M60</guid>
      <dc:creator>pierrekestremond</dc:creator>
      <dc:date>2025-06-04T10:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Python client library: Volume.get_collection(): Validation Error when volume is restricted</title>
      <link>https://community.netapp.com/t5/Python-Discussions/Python-client-library-Volume-get-collection-Validation-Error-when-volume-is/m-p/168498#M61</link>
      <description>&lt;P&gt;The issue here is that the /storage/volumes API declares that the valid state values must be one of "error", "mixed", "offline", or "online":&lt;/P&gt;&lt;P&gt;&lt;A href="https://library.netapp.com/ecmdocs/ECMLP2876964/html/index.html#/storage/volume_collection_get" target="_blank"&gt;https://library.netapp.com/ecmdocs/ECMLP2876964/html/index.html#/storage/volume_collection_get&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RobertBlackhart_0-1626444185604.png" style="width: 400px;"&gt;&lt;img src="https://community.netapp.com/t5/image/serverpage/image-id/11825iF10444EAA8A61F60/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RobertBlackhart_0-1626444185604.png" alt="RobertBlackhart_0-1626444185604.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So when ONTAP returned something else, the library raised this validation error. This is something that should be addressed as a bug in ONTAP since the library appears to be doing the correct thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, until that is addressed, you would have to work around it. The easiest way is if you don't need the state field (it didn't seem like you were actually using it here), then you could change your get_collection() call like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Volume.get_collection(**{"svm.name": vserver}, fields="*,!state")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This tells ONTAP to return all non-expensive fields except for state.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 14:11:33 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Python-Discussions/Python-client-library-Volume-get-collection-Validation-Error-when-volume-is/m-p/168498#M61</guid>
      <dc:creator>RobertBlackhart</dc:creator>
      <dc:date>2021-07-16T14:11:33Z</dc:date>
    </item>
  </channel>
</rss>

