DX NetOps

 View Only
  • 1.  Method to create multiple SNMP profiles at once

    Posted Jul 17, 2018 01:52 PM

    Hello so were moving from eH to CA PM and part of this we need to move all 200+ snmp profiles into CA PM. 

    We see no import method but we also just tired the CA PM REST call

    http://CA_PM:8181/pc/center/rest/profiles/documentation

    to create a profile:

    save
    Creates or updates an SNMP profile.
    URL: http://hostname:8181/pc/center/webservice/profiles/saveProfile/{rankTiesAscendingByDate}
    where:
    - {rankTiesAscendingByDate} indicates if ties in rank should be sorted by ascending dates.
    HTTP method = POST
    XSD for the provided XML: http://hostname:8181/pc/center/rest/profiles/xsd
    Return type is a string.

     

    yet this method only takes 1 profile at a time. We have 200+ of these to make. Anyone have a suggestion if there's a way to maybe achieve this faster?

    Since the snmp profiles are stored in the CA PC's mysql db table is there a way to do this using sql commands? 

    Just looking for some tips here.

    Thanks,

    Dan



  • 2.  Re: Method to create multiple SNMP profiles at once

    Broadcom Employee
    Posted Jul 17, 2018 02:10 PM

    Dan,

     

    I would highly recommend against playing with the database to accomplish this.  I am unsure what sort of variables are in your snmp profiles but you may be able to do a shell script utilizing a for loop. 

     

    for i in variableName{

          rest call here with $variables

    }

     

    Beyond that, you could use an application like Postman and just start mowing through them, changing the few unique entries on the profiles between each submit.

     

    Troy



  • 3.  Re: Method to create multiple SNMP profiles at once

    Posted Jul 17, 2018 03:05 PM

    Hi Troy,

    Thanks. Yeah I already thought of the script idea with a for loop but the rest call actually I think creates a xml file as the body of the message and then sends with the REST call. If it was just one rest call with different variables yes a script would work but this method won't.



  • 4.  Re: Method to create multiple SNMP profiles at once
    Best Answer

    Broadcom Employee
    Posted Jul 17, 2018 03:20 PM

    Dan,

     

    You could do it for single variable, multiple rest calls as well but like I mentioned I do not know the full scope of all of your changes to each REST call.

     

     

    If you were going to use the for loop script method, you would use curl so the body (in xml) would be in the single line.  For example see a few queries from this KB Article:

     

    Is it possible to override the speed of an interfa - CA Knowledge 

     

    An example of a CURL command to acquire the Interface list in the example above:

     

    curl --header "Content-Type: application/xml" --request POST --data '<FilterSelect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="filter.xsd"><Filter><DeviceComponent.DeviceItemID type="CONTAINS">4810</DeviceComponent.DeviceItemID></Filter><Select use="exclude" isa="exclude"><Item use="include"><Name use="include"/></Item></Select></FilterSelect>' --url http://DAhostname:8581/rest/ports/filtered


    An example of a CURL command to make the change in the example above:
     

    curl --header "Content-Type: application/xml" --request PUT --data '<Port version="1.0.0"><SpeedOutOverride>1.2E8</SpeedOutOverride><SpeedInOverride>1.2E8</SpeedInOverride></Port>' --url http://DAhostname:8581/rest/ports/4830

     

     

     

    That being said, if you are trying to move over 200 discover profiles, it may be easier to mow through them manually as it may take you longer than expected to set of a scripting solution and REST is the only alternative to using the GUI.

     

    Troy



  • 5.  Re: Method to create multiple SNMP profiles at once

    Posted Jul 17, 2018 05:30 PM

    Nice thanks Tony. That worked. We used a combination of the following 200 times and it worked great.

     

    curl --header "Content-Type: application/xml" --request POST --data "<SnmpProfile><name>SNMP_1_RW</name><port>161</port><communityString>SNMPrW</communityString><version>Version1or2C</version><securityLevel>NoAuthNoPriv</securityLevel><enabled>true</enabled><useForSnmpSet>false</useForSnmpSet><tenantID>8</tenantID></SnmpProfile>" -u admin:****** --url http://capm_PC1:8181/pc/center/webservice/profiles/saveProfile/true

     

    Threw them all into a batch file and worked great.



  • 6.  Re: Method to create multiple SNMP profiles at once

    Broadcom Employee
    Posted Jul 18, 2018 04:01 PM

    Dan,

     

    Awesome, great to hear it worked.  Given that everything worked well for you, can we mark your post as the correct answer so that if someone else stumbles to this thread they can find a sample query easily?

     

    Troy



  • 7.  Re: Method to create multiple SNMP profiles at once

    Posted Jul 18, 2018 04:39 PM

    Yes.I marked your reply as correct answer. 

    Thanks for the help.