DX NetOps

Expand all | Collapse all

Web Services and Actions

Jump to Best Answer
  • 1.  Web Services and Actions

    Posted 10-10-2013 10:53 AM
    We're new to web services and the task we're looking to do:

    We are looking to do scheduled discoveries and, by model name or some other definitive search pattern (maybe network address, etc.), we'd like to move the discovered device to specific containers.

    Another group (our midrange group) is looking to be able to use web services to insert a server into a container, and THEN run a discovery after it is IN Spectrum.

    So, two parts to this question:

    a.) Anybody have some existing web services scripts or likewise on how to do the placement into containers based on a certain criteria?

    b.) Anybody know how to invoke an action (discovery) via web services and, if so, what is the action code for discovery? I know that via CLI we can invoke actions but 'discover' is not one that is advertised and I'd prefer to not have to invoke CLI every time we add a server into Spectrum. Since CLI is such old code (old SSAPI single threaded stuff if I remember correctly), it can be painfully slow.

    Thanks for any thoughts.


  • 2.  RE: Web Services and Actions

    Broadcom Employee
    Posted 10-15-2013 12:21 AM
    Hi Brad,

    Let me answer item b.

    We can do 'create model by ip' using Restful Web Services. So this is not exactly the discovery action your asking. We have reconfigure action, i.e. action code = 0x1000e, but not discovery action.
    We can do 'POST model' with the following URL format to do 'create model by ip' using Restful Web Services.

    http://<hostname><:portnumber>/spectrum/restful/model[?landscapeid=<landscape_handle>][&mtypehandle=<mtype_handle>][&port=<snmp_port>][&commstring=<comm_str>][&retry=<retry_cnt>][&timeout=<timeout_val>][&ipaddress=<ip_address>][&parentmh=<model_handle>][&relationid=<rel_handle>][&attr=<attr_id>&val=<num>]

    We can do 'GET action' with the following URL format to send action code using Restful Web Services.

    http://<hostname><:portnumber>/spectrum/restful/action/<action_code>[?mh=<model_handle>][&attr=<attr_ID>&val=<num>][&throttlesize=<num>]

    I hope this helps.

    Regards,
    Widjaja.


  • 3.  RE: Web Services and Actions

    Posted 01-09-2014 09:28 AM

    For anybody that needs it, I did find the discovery action code in order to invoke it via restful services.  Here's the example:

    http://<server>:<port>/spectrum/restful/action/0x25e0022?mh=<model_handle_of_model>

    So mine was:

    http://servername:8443/spectrum/restful/action/0x25e0022?mh=0x18ff183

     

    Brad



  • 4.  Re: Web Services and Actions

    Posted 07-27-2015 11:09 AM

    Chandler,

     

    i believe 0x25e0022 is the action code for discover connections.

     

    Check this as well if it helps

     

    You would need to first find the model handle of the parent container (of type Network) and then use one of the below REST calls :

     

    For the model Handle, you either need to search for the container which contains the device, and get the model handle there, or when you create a container it returns the model handle in the response.

     

    You need to use different attributes for SNMP or ICMP:

     

    For SNMP devices:

     

    HTTP:

    POST

     

    URL:

    http://<SERVER>:<PORT>/spectrum/restful/model?landscapeid=<LANDSCAPE HANDLE>&attr=0x1006e&val=<DEVICE NAME>&ipaddress=<IP ADDRESS>&port=161&commstring=%23v2%2f<SNMP COMMUNITY>&retry=1&timeout=1000&parentmh=<PARENT MODEL HANDLE> 

     

    Just a note, the example shows SNMPv2, if you want to use SNMPv1 you need to remove the '%23v2%2f' - this is the URL friendly '# v 2 /'. There are some characters which you need to convert to HTML friendly codes: e.g.: '<space>' becomes '%20' etc.

     

    For ICMP devices:

     

    HTTP:

    POST

     

     

    URL:

    http://<SERVER>:<PORT>/spectrum/restful/model?landscapeid=<LANDSCAPE HANDLE>&attr=0x1006e&val=<DEVICE NAME>&attr=0x12d7f&val=<IP ADDRESS>&mtypehandle=0x10001&mtypeid=0x10290&attr=0x1000e&val=7&retry=1&timeout=1000&parentmh=<PARENT MODEL HANDLE> 

     

    Note we also set the 'Value_When_Red" so it creates alarms instead of just staying in INITIAL mode for pingable models.

     

    This will add the device, you will still need to send a 'discover connections' action to the device after discovering. This can sometimes time out and you can only run one at a time, so you need to have a script which manages the discover connections. This will error mention that another discover is in progress which you can check for (text to check for is 'Another discovery process is currently in progress.')

     

    HTTP:

    POST

     

    URL: http://<SERVER>:<PORT>/spectrum/restful/action/0x25e0022?mh=<MODEL HANDLE> 



  • 5.  Re: RE: Web Services and Actions

    Posted 07-27-2015 11:53 AM

    Hi Brad,

    Where did you get that action code from? And what's the mh for in this case? In order to discover an SNMP device, you need at least three variables: IP, community string and port. How is that URL you sent supossed to work?



  • 6.  Re: Web Services and Actions
    Best Answer

    Posted 10-26-2015 10:18 AM

    It was on a previous post, which I now cannot find as it appears to have been deleted: 

     

    https://communities.ca.com/web/ca-ehealth-and-ca-spectrum-global-user-community/message-board/-/message_boards/message/101864509%3bjsessionid=8EDFC1330665A0AAA3E7BDB7529C23A0?p_p_auth=iTsBY7lR&%20#p_19

     

    The discovery portion was the second part of what we are doing:  we insert the device and then do a discovery on the device in the container.

     

    Here is the full set of what we are doing:

     

     

    Get landscapes:

    GET /restful/landscapes

     

    Add model:

    POST /restful/modelipaddress={ipAddress}

    &landscapeid={landscapeHandle}

    &commstring={communityString}

    &parentmh={parentModelHandle}

    &attr=0x12bfd&val={marketOwner}

    &attr=0x12bff&val={officeNumber}

    &attr=0x12bfb&val={environment}

    &attr=0x12d7f&val={ipAddress}

    &attr=0x12c03&val={applicationName}

    &attr=0x12c02&val={assetContractEndDate}

    &attr=0x12c01&val={assetContractStartDate}

     

    Trigger discovery:

    GET /restful/action/0x25e0022?mh={modelHandle}

     

    So the url I mention alone won't do anything for discovery unless you have the model created first.

     

    We also have automated deletes w/ web services:

     

     

    Get model handle:

    POST /restful/models

    With XML content:

      <?xml version="1.0" encoding="UTF-8"?>'

    <rs:model-request throttlesize="50"

    xmlns:rs="http://www.ca.com/spectrum/restful/schema/request"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd ">

    <rs:target-models>

    <rs:models-search>

    <rs:search-criteria

                 xmlns="http://www.ca.com/spectrum/restful/schema/filter">

    <devices-only-search />

    <filtered-models>

    <equals>

    <ip-address> {IP Address} </ip-address>

    </equals>

    </filtered-models>

    </rs:search-criteria>

    </rs:models-search>

    </rs:target-models>

    <rs:requested-attribute id="0x1006e" />

    <rs:requested-attribute id="0x10000" />

    <rs:requested-attribute id="0x1295d" />

    </rs:model-request>

     

     

    Delete model:

    DELETE /restful/model/{handle}