This command extract all resources from our HQ Server:
hqapi resource list -prototype Linux --children > allresources.xml
The XPath to extract all resources of type "FileServer Directory" is:
//Resource[./ResourcePrototype/@name="FileServer Directory"]
and the syntax to execute it in XmlStarlet is:
c:\apps\xmlstarlet-1.3.1\xml sel -t -c "//Resource[./ResourcePrototype/@name='FileServer Directory']" allresources.xml
This resource is a child element of another Resource:
<Resource id="10916" name="myserver.acme.com Linux FileServer" description="" location="" instanceId="10007" typeId="2">
which in turn is inside
<Resource id="10882" name="myserver.acme.com" description="Red Hat Enterprise Linux 5" location="" instanceId="10001" typeId="1">
To create a resource, the easy way is:
hqapi resource createService --prototype="FileServer Directory" --resourceId=10882 --name="/data/acme/" path="/data/acme/"
XmlStarlet doc is available here
Tuesday, May 1, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment