4 Replies Latest reply on Sep 20, 2012 1:24 PM by arunrsivaram

    VLAN Change through UDT & NCM using Orion SDK

    arunrsivaram

      Hi,

       

      We have installed the UDT and NCM modules, we have a requirement like,

       

        1. User will given an input as IP Address.

        2. Through UDT with this IP Adrress, we need to identify the Port and VLAN.

        3. We need to pass the identifed port, VLAN from UDT, along with new VLAN to NCM module for changing the VLAN.

       

        We are using .net for this requirement, while going through the SDK, its clearly mentioning about the Invoke mentod for acknowledgeing an Alert.

        So can we achive our requirement of changing a VLAN with this Invoke method ?

       

        While going through the discussion fourm,  http://thwack.solarwinds.com/message/178759#178759

         we found the PowerShell script, it attached herewith.

         In this script we identified below line,

           Invoke-SwisVerb $swis Cirrus.ConfigArchive Execute @($nodeIdList, $script, $username) | Out-Null

         Is there any similar code available in .net, like

           swis.Invoke("Cirrus.ConfigArchive", "Execute", System.Xml.XmlElement[] parameters),  we don't know what is the format of this XmlElement[] parameters.

           Please provide the sample XmlElement[] for this. It will be very helpful.

       

        Also with this Invoke method, our requirement of changing a VLAN will work?

       

        Please help us to find out the solution for this requirement.

       

      Thanks,

      Arun

        • Re: VLAN Change through UDT & NCM using Orion SDK
          tdanner

          For getting the arguments into the "XmlElement[]" format in C#, try something like this:

           

                  private static XmlElement[] PrepareInvokeArguments(params object[] args)

                  {

                      var elements = new List<XmlElement>(args.Length);

                      foreach (var arg in args)

                      {

                          var dcs = new DataContractSerializer(arg.GetType());

                          var doc = new XmlDocument();

                          using (var writer = doc.CreateNavigator().AppendChild())

                          {

                              dcs.WriteObject(writer, arg);

                          }

                          elements.Add(doc.DocumentElement);

                      }

                      return elements.ToArray();

                  }

           

          Yes, you should be able to change a VLAN using Cirrus.ConfigArchive.Execute, but your code will need to prepare the appropriate command line script for the switch in question. If you use switches from different vendors, this will mean generating a different script using different syntax according to which switch you are updating.

          1 of 1 people found this helpful
            • Re: VLAN Change through UDT & NCM using Orion SDK
              arunrsivaram

              Thanks for the support...

               

              In the specified method, PrepareInvokeArgument(param object[] args) what values we need to pass as args?

               

                Whether the parameter "args" will contain the values of port, vlanid and new vlanid for changing the vlan? or any specific format for args?

               

              Also how do identify the switch to run the script? It will be very helpful for us if you are providing the vendor specific command line script.

               

              Thanks,

               

              Arun

               

               

               

               

               

               


                • Re: VLAN Change through UDT & NCM using Orion SDK
                  adat

                  Here is a Pearl script to do the same ...Cisco and Juniper..., You need to pass few inputs-- Vendor, Interface Name, Cisco VLAN ID (if vendor is Cisco), Juniper VLAN member (if vendor is Juniper) and existing VLAN . And yes another input is "Switch IP" to which script will do ssh/telnet with credentials.Now not sure whether similar script can run through this SDK or not.

                   

                  # BEGIN-INTERNAL-SCRIPT-BLOCK

                  # Script:

                  # vlan_change_automation

                   

                   

                  # END-INTERNAL-SCRIPT-BLOCK

                   

                   

                  # BEGIN-SCRIPT-BLOCK

                  #

                  #Script-Filter:

                  # $Vendor in ["Cisco","Juniper"]

                  #

                  #Script-Variables:

                  # $interface_name string

                  # $vlan_id_cisco string

                  # $juniper_vlan_member string

                  #

                  #

                  ##

                  # END-SCRIPT-BLOCK

                   

                   

                   

                   

                  our $vlan_name_check;

                   

                   

                  # VLAN Change Process

                    message_and_exit("Interface name is required.") unless $interface_name;

                   

                  #Cisco device VLAN change process

                   

                   

                    if($vendor eq "Cisco"){

                              message_and_exit("VLAN id is required. Please re-try.") unless $vlan_id_cisco;         

                  # Get the VLAN information of the interface

                    my $response = send_command("show interface $interface_name switchport | include Access Mode VLAN:");

                    if ($response =~ /Access Mode VLAN:\s* (\d+)/)

                    {

                    $vlan_name_check= $1;

                    }

                    $easy->log_message("info", "Before VLAN change: vlan name check value is: $vlan_name_check");

                   

                  # Un-assign the existing VLAN

                    send_command("config t");

                    send_command("interface $interface_name");

                    send_command("no switchport access vlan $vlan_name_check");

                    send_command("end");

                   

                  # Change the VLAN membership

                    send_command("config t");

                    send_command("interface $interface_name");

                    send_command("switchport access vlan $vlan_id_cisco");

                    send_command("shut");

                    sleep(5);

                    send_command("no shut");

                    send_command("end");

                    sleep(5);

                    send_command("clear arp");

                   

                   

                  # Validate the VLAN change

                    my $response = send_command("show interface $interface_name switchport | include Access Mode VLAN:");

                    if ($response =~ /Access Mode VLAN:\s* (\d+)/)

                    {

                    $vlan_name_check= $1;

                    }

                    $easy->log_message("info", "After VLAN change: vlan name check value is: $vlan_name_check");

                  }

                  #Juniper device VLAN change process

                  if($vendor eq "Juniper"){

                    message_and_exit("Juniper vlan member field is required. Please re-try") unless $juniper_vlan_member;

                              $vlan_id_cisco=$juniper_vlan_member; # Assigning juniper_vlan_member to vlan_id_cisco variable to verify the VLAN change at the end.

                   

                  # Get the VLAN information of the interface

                    my $response = send_command("show ethernet-switching interfaces brief | match $interface_name");

                              my @vlan_info = split(' ', $response);

                    $easy->log_message("info", "Before VLAN change: vlan name check value is: $vlan_info[2]");

                              $vlan_name_check=$vlan_info[2];

                   

                   

                  # Delete the existing VLAN membership

                    send_command("configure private");

                    send_command("delete vlans $vlan_name_check interface $interface_name");

                    send_command("commit");

                    send_command("exit");

                   

                   

                  # Change the VLAN membership

                    send_command("configure private");

                    send_command("set vlans $juniper_vlan_member interface $interface_name");

                    send_command("commit");

                    send_command("exit");

                   

                   

                  # Validate the VLAN ID change

                    my $response = send_command("show ethernet-switching interfaces brief | match $interface_name");

                              my @vlan_info = split(' ', $response);

                    $easy->log_message("info", "After VLAN Change: vlan name check value is: $vlan_info[2]");

                    $vlan_name_check=$vlan_info[2];

                  }

                   

                   

                  # Compare the VLAN info

                   

                   

                              if ($vlan_name_check eq $vlan_id_cisco)

                    {

                    $easy->log_message("info", "VLAN names are in sync.... VLAN change is a success")

                    }

                    else

                    {

                       message_and_exit("VLAN names are not in sync... VLAN Membership change has been failed. Please visit the logs for more information.");

                    }

                   

                   

                    my $device_broker = $easy->broker->device;

                    $easy->_log_message_no_login("info","Executing on demand poll on $ipaddress.");

                • Re: VLAN Change through UDT & NCM using Orion SDK
                  arunrsivaram

                  Please help us to find out the solution for VLAN change,

                   

                  Through SDK, we found out for Cirrus.ConfigArchive.Execute, expects 3 parameters,

                   

                  1. NodeID

                  2. Script

                  3. User

                   

                  Node Id and User parameter we will get, but

                  We have the doubt like what value need to pass as Script, in the above post in Perl, handled two vendors Cisco and Juniper.

                  If so then we need to have separate scripts for these two.

                   

                  It will be very helpful, if you provide the scripts that need to pass through .net framework.

                   

                  Thanks

                   

                  Arun