Skip to content

Instantly share code, notes, and snippets.

@Mierdin
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save Mierdin/2876bf926e5121b0a166 to your computer and use it in GitHub Desktop.

Select an option

Save Mierdin/2876bf926e5121b0a166 to your computer and use it in GitHub Desktop.
Example Filter in Python for Cisco UCS
#This was not documented at all. I had to use the UCS Visore tool to get the XML needed to do filtering,
#Then I took that request and used the PowerShell ConvertTo-UcsCmdlet function to convert to Python.
# PS C:\Users\Mierdin> ConvertTo-UcsCmdlet -Xml -Request '<configResolveClass classId="lsServer" cookie="1414451334/d63131a4-a4bc-420b-beba-f59e0b520d33" inHierarchical="false"><inFilter><and><eq class="lsServer" property="type" value="instance" /><wcard class="lsServer" property="dn" value="^org-root/" /></and></inFilter></configResolveClass>' -Python
inFilter = FilterFilter()
andFilter0 = AndFilter()
eqFilter = EqFilter()
eqFilter.Class = "lsServer"
eqFilter.Property = "type"
eqFilter.Value = "instance"
andFilter0.AddChild(eqFilter)
wcardFilter = WcardFilter()
wcardFilter.Class = "lsServer"
wcardFilter.Property = "dn"
wcardFilter.Value = "^org-root/"
andFilter0.AddChild(wcardFilter)
inFilter.AddChild(andFilter0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment