Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RestPy: RestPy equivalent for HLTAPI DisableSuppressArpAllPorts proc #38

Closed
muthvar1 opened this issue Feb 27, 2019 · 1 comment
Closed

Comments

@muthvar1
Copy link

Hi Team,
Is there a restPy equivalent for disabling suppress arp on all ports? In HLTAPI, we had the function below. Please let me know if there is a corresponding restAPI equivalent.

def disable_suppress_arp(self):
results = self.tcl.eval('DisableSuppressArpAllPorts false')
results = self.tcl.eval('DisableSuppressArpAllPorts false ipv6')
return results

proc DisableSuppressArpAllPorts { action {ipType ipv4} } {
# Description:
# This API will automatically disable or enable
# suppress ARP for duplicate gateway on all the
# ports with ipv4.

# action = true or false

# Psuedo code:
#    - Verify if the multiValue -pattern is "counter"
#    - If not, make it counter (so that we could create overlays to modify things.)
#    - If it is counter, verify if there is any overlay.
#    - If there are overlays, verify if the correct portName index exists.
#    - If yes, then change its value true/false.
#    - If no, create an overlay and set true/false for the portIndex number.

set root [ixNet getRoot]
set globals $root\globals
set globalTopology $globals/topology
set globalTopologyIp $globalTopology/$ipType

if { $ipType eq "ipv4" } {
    set suppressKey -suppressArpForDuplicateGateway
} else {
    set suppressKey -suppressNsForDuplicateGateway
}

set portNameList [ixNet getAttribute $globalTopologyIp -rowNames]

foreach portName $portNameList {
    set multiValue [ixNet getAttribute $globalTopologyIp $suppressKey]
    set portIndex [expr [lsearch $portNameList $portName] + 1]

    if {$portIndex != -1} {
        set overlayDiscoveredFlag 0

        # currentValues = true true
        # portList = 1/1/1 1/1/2
        set overlayList [ixNet getList $multiValue overlay]
        if {$overlayList != ""} {
            foreach overlay $overlayList {
                set currentIndex [ixNet getAttribute $overlay -index]

                if {$portIndex == $currentIndex} {
                    set overlayDiscoveredFlag 1
                    puts "\nEnableDisableSuppressArpAllPorts = $action"
                    catch {ixNet setMultiAttribute $overlay -value $action -valueStep $action -count 1 -indexStep 0} errMsg
                    if {$errMsg != "::ixNet::OK"} {
                        puts "Error EnableDisableSuppressArp setAttr: $errMsg"
                    }

                    catch {ixNet commit} errMsg
                    if {$errMsg != "::ixNet::OK"} {
                        puts "Error EnableDisableSuppressArp: $errMsg"
                    } else {
                        puts "EnableDisableSuppressArp: Set to $action: $errMsg"
                    }
                }
            }

            if {$overlayDiscoveredFlag == 0} {
                # Getting here means no overlay index found for the $portIndex.
                # Have to create an overlay with the proper -index number.
                puts "\nEnableDisableSuppressArpAllPorts: No overlay found for: $portName"
                puts "Creating an overlay ..."
                set currentOverlay [ixNet add $multiValue overlay]
                ixNet setMultiAttr $currentOverlay -value $action -valueStep $action -count 1 -index $portIndex
                ixNet commit
            }

        } else {
            # Getting here means there is no overlays.
            # Change the multiValue pattern to counter so that we
            # are able to modify anything
            ixNet setAttribute $multiValue -pattern counter
            ixNet commit
            ixNet setAttribute $multiValue/counter -start true
            ixNet commit

            puts "\nEnableDisableSuppressArpAllPorts: Creating overlay: $portName -index $portIndex -value $action"
            # Create Overlays with proper index number based on the portIndex
            # in $root/globals/topology/ipv4 -rowNames indexes
            set currentOverlay [ixNet add $multiValue overlay]
            ixNet setMultiAttr $currentOverlay -value $action -valueStep $action -count 1 -index $portIndex
            ixNet commit
        }
    } else {
        puts "Error: No such port configured: $portName"
        return 1
    }
}
return 0

}

@ajbalogh
Copy link

ipv4_suppress_arp = ...Ixnetwork.Globals.Topology.Ipv4.SuppressArpForDuplicateGateway
ipv4_suppress_arp.Single(False)

ipv6_suppress_arp = ...Ixnetwork.Globals.Topology.Ipv6.SuppressArpForDuplicateGateway
ipv6_suppress_arp.Single(False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants