Topic
  • 11 replies
  • Latest Post - ‏2013-09-05T20:45:25Z by JoshPena
cwmenard
cwmenard
9 Posts

Pinned topic Programmatic export of content

‏2012-09-28T15:47:56Z |
Anyone have any pointers or tips on how to programmatically export content? Fixlets and tasks for an example and retain/return them to the proper XML format.
  • SystemAdmin
    SystemAdmin
    757 Posts

    Re: Programmatic export of content

    ‏2012-10-01T19:14:22Z  
    I have thought about making a tool which will export all custom content for backup and file system uses.

    I haven't gotten anywhere with developing it but my first thoughts turn to the console API for doing this.

    https://www.ibm.com/developerworks/mydeveloperworks/wikis/home?lang=en#/wiki/Tivoli%20Endpoint%20Manager/page/BigFix%20Platform%20API
  • SystemAdmin
    SystemAdmin
    757 Posts

    Re: Programmatic export of content

    ‏2012-10-02T21:25:08Z  
    You can use the SOAP API with WebReports. That will let you evaluate session relevance against the Web Reports data which can be used to get Fixlet XML.

    This is an example SOAP request for relevance evaluation:
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <GetRelevanceResult xmlns="http://schemas.bigfix.com/Relevance">
    <relevanceExpr>bes fixlet whose (id of it is 701) as xml</relevanceExpr>
    <username>bigfix</username>
    <password>bigfix</password>
    </GetRelevanceResult>
    </s:Body>
    </s:Envelope>

    Q: bes fixlet whose (id of it is 701) as xml

    Multiple results can be returned as well.

    An example response would be:

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
    <GetRelevanceResultResponse xmlns="http://schemas.bigfix.com/Relevance">
    BES FIXLET XML
    </GetRelevanceResultResponse>
    </soapenv:Body>
    </soapenv:Envelope>
  • cwmenard
    cwmenard
    9 Posts

    Re: Programmatic export of content

    ‏2012-10-10T11:58:25Z  
    You can use the SOAP API with WebReports. That will let you evaluate session relevance against the Web Reports data which can be used to get Fixlet XML.

    This is an example SOAP request for relevance evaluation:
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <GetRelevanceResult xmlns="http://schemas.bigfix.com/Relevance">
    <relevanceExpr>bes fixlet whose (id of it is 701) as xml</relevanceExpr>
    <username>bigfix</username>
    <password>bigfix</password>
    </GetRelevanceResult>
    </s:Body>
    </s:Envelope>

    Q: bes fixlet whose (id of it is 701) as xml

    Multiple results can be returned as well.

    An example response would be:

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
    <GetRelevanceResultResponse xmlns="http://schemas.bigfix.com/Relevance">
    BES FIXLET XML
    </GetRelevanceResultResponse>
    </soapenv:Body>
    </soapenv:Envelope>
    Q: bes fixlet whose (id of it is 701) as xml
    E: The operator "string" is not defined.

    That doesn't seem to work in web reports.
  • PeterLoer
    PeterLoer
    5 Posts

    Re: Programmatic export of content

    ‏2012-10-11T22:04:39Z  
    • cwmenard
    • ‏2012-10-10T11:58:25Z
    Q: bes fixlet whose (id of it is 701) as xml
    E: The operator "string" is not defined.

    That doesn't seem to work in web reports.
    The issue here is that the xml string returned is of a relevance type "utf8 string" that doesn't coerce into a normal relevance string... you can see the same problem if you put that same relevance into the presentation debugger inside the console.

    As an example of how it is still possible to work with the data, in the console you can't evaluate this relevance as string, but you the following will work if you put it into the "evaluate as presentation" mode:

    <script>
    var xmlString = String( EvaluateRelevance("bes fixlets whose (id of it is 701) as xml") )
    xmlString = xmlString.replace(/</g, "<")
    xmlString = xmlString.replace(/>/g, ">")
    document.write( xmlString )
    </script>

    Basically, because this data type does not coerce to string, it is hard to work with it in the relevance tools, but if you are actually interacting with it programmatically through the apis you should be fine.

    (we have opened an internal issue to add the coerce to string capability in the future to make this easier to work with)

    cheers,

    peter
  • cwmenard
    cwmenard
    9 Posts

    Re: Programmatic export of content

    ‏2012-10-24T13:52:02Z  
    • PeterLoer
    • ‏2012-10-11T22:04:39Z
    The issue here is that the xml string returned is of a relevance type "utf8 string" that doesn't coerce into a normal relevance string... you can see the same problem if you put that same relevance into the presentation debugger inside the console.

    As an example of how it is still possible to work with the data, in the console you can't evaluate this relevance as string, but you the following will work if you put it into the "evaluate as presentation" mode:

    <script>
    var xmlString = String( EvaluateRelevance("bes fixlets whose (id of it is 701) as xml") )
    xmlString = xmlString.replace(/</g, "<")
    xmlString = xmlString.replace(/>/g, ">")
    document.write( xmlString )
    </script>

    Basically, because this data type does not coerce to string, it is hard to work with it in the relevance tools, but if you are actually interacting with it programmatically through the apis you should be fine.

    (we have opened an internal issue to add the coerce to string capability in the future to make this easier to work with)

    cheers,

    peter
    Thanks for the update Peter. Shouldn't this work through SOAP though?

    My SOAP request:
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <GetRelevanceResult xmlns="http://schemas.bigfix.com/Relevance">
    <relevanceExpr>bes fixlets whose (id of it is 411802) as xml</relevanceExpr>
    <username>username</username>
    <password>password</password>
    </GetRelevanceResult>
    </s:Body>
    </s:Envelope>

    My XML return:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
    <env:Fault>
    <faultcode>env:Client</faultcode>
    <faultstring xml:lang="ENU">The operator "string" is not defined.</faultstring>
    </env:Fault>
    </env:Body>
    </env:Envelope>

    The Raw return:
    HTTP/1.1 200 OK
    Content-type: text/xml
    Transfer-Encoding: chunked

    <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
    <env:Fault>
    <faultcode>env:Client</faultcode>
    <faultstring xml:lang="ENU">The operator "string" is not defined.</faultstring>
    </env:Fault>
    </env:Body>
    </env:Envelope>
  • JoshPena
    JoshPena
    3 Posts

    Re: Programmatic export of content

    ‏2013-09-05T16:55:23Z  
    You can use the SOAP API with WebReports. That will let you evaluate session relevance against the Web Reports data which can be used to get Fixlet XML.

    This is an example SOAP request for relevance evaluation:
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <GetRelevanceResult xmlns="http://schemas.bigfix.com/Relevance">
    <relevanceExpr>bes fixlet whose (id of it is 701) as xml</relevanceExpr>
    <username>bigfix</username>
    <password>bigfix</password>
    </GetRelevanceResult>
    </s:Body>
    </s:Envelope>

    Q: bes fixlet whose (id of it is 701) as xml

    Multiple results can be returned as well.

    An example response would be:

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
    <GetRelevanceResultResponse xmlns="http://schemas.bigfix.com/Relevance">
    BES FIXLET XML
    </GetRelevanceResultResponse>
    </soapenv:Body>
    </soapenv:Envelope>

    Has anyone been able to provide a working model of this yet?  I am using a PHP script to execute a SOAP query that would ideally return the fixlets as xml so I can programmitcally parse the various fields.  I can get any session relevance query to execute successfully except the "<bes fixlet> as xml" as described above.

  • cwmenard
    cwmenard
    9 Posts

    Re: Programmatic export of content

    ‏2013-09-05T17:21:49Z  
    • JoshPena
    • ‏2013-09-05T16:55:23Z

    Has anyone been able to provide a working model of this yet?  I am using a PHP script to execute a SOAP query that would ideally return the fixlets as xml so I can programmitcally parse the various fields.  I can get any session relevance query to execute successfully except the "<bes fixlet> as xml" as described above.

    If you're on version 9.x you can use the RESTAPI for this quite easily.  For some good info http://www.bigfix.me/restapi

  • JoshPena
    JoshPena
    3 Posts

    Re: Programmatic export of content

    ‏2013-09-05T18:26:28Z  
    • cwmenard
    • ‏2013-09-05T17:21:49Z

    If you're on version 9.x you can use the RESTAPI for this quite easily.  For some good info http://www.bigfix.me/restapi

    Thank you for the quick response.  Unfortunately, our entire environment (consisting of at least nine TEM servers) is using version 8.2.  Anything else you're aware of that might help me get this working?

  • cwmenard
    cwmenard
    9 Posts

    Re: Programmatic export of content

    ‏2013-09-05T18:32:03Z  
    • JoshPena
    • ‏2013-09-05T18:26:28Z

    Thank you for the quick response.  Unfortunately, our entire environment (consisting of at least nine TEM servers) is using version 8.2.  Anything else you're aware of that might help me get this working?

    Before we upgraded to 9, I used the BESAPI COM objects to do this.  You may look in that direction. That was the only way I was able to get the complete Fixlet/Task xml out.

  • Lee Wei 2
    Lee Wei 2
    1 Post

    Re: Programmatic export of content

    ‏2013-09-05T20:34:17Z  
    • JoshPena
    • ‏2013-09-05T16:55:23Z

    Has anyone been able to provide a working model of this yet?  I am using a PHP script to execute a SOAP query that would ideally return the fixlets as xml so I can programmitcally parse the various fields.  I can get any session relevance query to execute successfully except the "<bes fixlet> as xml" as described above.

    Here is one idea.

    Web Reports actually has an HTTP XML interface, where you can send Session Relevance queries via HTTP and get results back in XML.

    This should be documented in the Web Reports User's Guide. It has the following form.

    http://[webreports_server]:[port_number]/webreports?page=EvaluateRelevanceOnly&Username=leewei&Password=welcome&expr=[Session Relevance Statement]

    An example would be:

    http://localhost:52312/webreports?page=EvaluateRelevanceOnly&Username=leewei&Password=welcome&expr=number of bes computers

    Or:

    http://localhost:52312/webreports?page=EvaluateRelevanceOnly&Username=leewei&Password=welcome&expr=(name of it, id of it, source severity of it) of bes fixlets whose (current date  - source release date of it < 43 * day)

     

  • JoshPena
    JoshPena
    3 Posts

    Re: Programmatic export of content

    ‏2013-09-05T20:45:25Z  
    • Lee Wei 2
    • ‏2013-09-05T20:34:17Z

    Here is one idea.

    Web Reports actually has an HTTP XML interface, where you can send Session Relevance queries via HTTP and get results back in XML.

    This should be documented in the Web Reports User's Guide. It has the following form.

    http://[webreports_server]:[port_number]/webreports?page=EvaluateRelevanceOnly&Username=leewei&Password=welcome&expr=[Session Relevance Statement]

    An example would be:

    http://localhost:52312/webreports?page=EvaluateRelevanceOnly&Username=leewei&Password=welcome&expr=number of bes computers

    Or:

    http://localhost:52312/webreports?page=EvaluateRelevanceOnly&Username=leewei&Password=welcome&expr=(name of it, id of it, source severity of it) of bes fixlets whose (current date  - source release date of it < 43 * day)

     

    Interesting, I was unaware of that (I typically just use the web reports QNA for adhoc session relevance queries).

    Unfortunately, this still returns the same error, because it is expecting a "normal string" to be returned, but the "<bes fixlet> as xml" inspector returns a "utf8 string" containing the actual xml document that represents the fixlet.