DX NetOps

  • 1.  Finding which discovery profile added a device

    Posted May 19, 2015 09:07 AM

    I'm working on building our maintenance procedures and one of the things we'd like to do to keep things clean is figure out how a device got added to Spectrum. In particular, we'd like to be able to remove a device without that device getting rediscovered when one of the discovery profiles reruns according to its schedule. I've devised a pretty complicated way of doing it, but I was wondering if there was something built into the product that already does it. Essentially, I need a way to find which discovery profile (on which landscape) contains a given IP address.

     

    In the event that there is no way to do this, I want to find out if there is a way to use the modelinggateway to export all the discovery profile XML files. My current process looks like this:

     

    1. Export all the discovery profiles to XML manually from the discovery console <--this is what I'd like to see if i can automate through the modeling gateway
    2. Run a perl script to dump the IP addresses, discovery profile names, and landscape names into a single CSV
    3. Search the CSV to find out in which discovery profile(s) and landscape(s) the IP address exists

     

    Since I'm exporting manually, I end up with a single XML file for each landscape. So, I have a batch file that calls the perl script for each XML:

    for %%A in (*.xml) do (
      perl parserparser.pl %%A
      type %%A.csv >> output.csv
      del /q %%A.csv
    )
    

     

    Here's the perl script:

    #!/usr/bin/perl
    my $currlscape;$currentdp;open (INFILE, @ARGV[0]);open (OUTFILE, ">" . @ARGV[0] . ".csv"); 
    while (<INFILE>) {
      chomp;
      if ($_ =~ m!<SPECTRUM_Export landscape_name="(.*)" landscape_handle="0x......">!) {$currlscape = $1;}
      if ($_ =~ m!<Discovery_Model name="(.*)" model_type=".*" model_handle="0x......" >!) {$currentdp = $1;}
      if ($_ =~ m!<value>(\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)</value>!){print OUTFILE "$1,\"$currentdp\",$currlscape\n";}
    }
    close (INFILE);close (OUTFILE);
    

     

    Eventually, I'd use a cron job to run the modelling gateway to export the discovery profile, then run the perl script, then post the data to some web page where my process workers can reference it.

     

    Another question I'd have is whether or not I'd be able to do this all from the MLS or if I'd have to set it up on each landscape then aggregate them together somehow.



  • 2.  Re: Finding which discovery profile added a device
    Best Answer

    Broadcom Employee
    Posted May 28, 2015 01:24 PM
      |   view attached

    Hello Stuart_Weenig,

     

    Thanks for attending CA Spectrum office hours. As mentioned on the call we do not have any inbuilt Spectrum functionality to know from which discovery configuration a model was modeled from.

     

    I am attaching an example Perl utility, which will export all discovery configurations (only). Hope this is helps.

     

    Thanks,

    Nagesh

    Attachment(s)



  • 3.  Re: Finding which discovery profile added a device

    Posted Jun 17, 2015 12:58 PM

    Haven't tried it yet, but line 68 will have a problem since we're running on Linux. Looks like someone attempted to make this cross platform but didn't do the check for the actual modeling gateway executable. modelinggateway.bat doesn't exist on a linux system. It's just modelinggateway.  Looks like I should be able to combine this script with my perl script to just run the whole thing once with a single output. If I get it working, I'll paste it back here.



  • 4.  Re: Finding which discovery profile added a device

    Posted Jun 17, 2015 02:27 PM

    Here's my final version after tweaking it and adding the CSV parsing. Now I get a single CSV with one line per IP in all discovery profiles, with columns for IP, landscape, and discovery profile.

    http://pastebin.com/gpS72Au6

    I did run into a problem where one of my landscapes wouldn't export. It showed this error:

    Modeling Gateway export started.  Wed, Jun 17, 2015, at 01:08:02 PM CDT
    Failed to bind model domain "sgdc1spclv01": org.omg.CORBA.OBJECT_NOT_EXISTorg.omg.CORBA.OBJECT_NOT_EXIST:  vmcid: 0x0  minor code: 0  completed: No