Riaan's SysAdmin Blog

My tips, howtos, gotchas, snippets and stuff. Use at your own risk!

Solaris

Solaris DLMP Test VLAN

As usual use at own risk!

This may not apply to many people but I have an instance where we use DLMP which I really like. However one weakness I have in my environment if someone screw up a VLAN port configuration on a switch you may have serious networking issues and not understand what is happening. DLMP is not going to disable a port in an aggregation because there is link and it does not know if VLAN's are set or not. So I wrote a quick script I may play with more later to improve but this already helps with speeding up testing. Time is something you may not have a lot of when you have intermittent and very odd network behavior.

And of course you will need to take these ports you want to test out of the aggregation for testing and add back in if you need to.

Let me know if anyone find a better way for example DLMP built-in test or testing at a lower level in the networking model etc.

# cat check_vlans.py 
#!/usr/bin/python
import subprocess,re,sys

vlans={}
vlans[1915] = {'IP': '10.2.12.230/24', 'name': 'DR'}
vlans[1953] = {'IP': '10.2.13.230/24', 'name': 'PPE'}
vlans[1954] = {'IP': '10.2.16.230/23', 'name': 'TST'}
vlans[1912] = {'IP': '10.2.14.230/23', 'name': 'DEV'}
vlans[1913] = {'IP': '10.2.10.230/24', 'name': 'MGMT'}

def get_aggr_nets():
  ls_lines = subprocess.Popen(['dladm', 'show-link','xgaggr1'], stdout=subprocess.PIPE).communicate()[0].splitlines()
  line = re.sub(' +',' ',ls_lines[1])
  props = line.split(' ')
  print "LINK: {} CLASS: {} MTU: {} STATE: {} NETS: ".format(props[0],props[1],props[2],props[3]),
  print props[4:]

def vlan_test(nets):
  for net in nets:
      result = subprocess.Popen(['dladm', 'create-vlan','-l',str(net),'-v','1912','vlan1'], stdout=subprocess.PIPE).communicate()[0].splitlines()

      for i,v in vlans.iteritems() :
        print "Testing interface: {} over vlan id: {} {} using IP: {} Result: ".format(net,i,v['name'],v['IP']),

        result = subprocess.Popen(['dladm', 'modify-vlan','-v',str(i),'vlan1'], stdout=subprocess.PIPE).communicate()[0].splitlines()

        result = subprocess.Popen(['ipadm', 'create-ip','vlan1'], stdout=subprocess.PIPE).communicate()[0].splitlines()

        result = subprocess.Popen(['ipadm', 'create-addr','-T','static','-a',v['IP'],'vlan1/v4'], stdout=subprocess.PIPE).communicate()[0].splitlines()

        subnet=v['IP'].split('.')
        gateway='10.2.' + str(subnet[2]) + '.1'

        #result = subprocess.Popen(['ping', '-i','vlan1',gateway], stdout=subprocess.PIPE).communicate()[0].splitlines()
        result = subprocess.Popen(['ping', '-i','vlan1',gateway,'57','1'], stdout=subprocess.PIPE).communicate()[0].splitlines()
        print result

        result = subprocess.Popen(['ipadm', 'delete-ip','vlan1'], stdout=subprocess.PIPE).communicate()[0].splitlines()

      result = subprocess.Popen(['dladm', 'delete-vlan','vlan1'], stdout=subprocess.PIPE).communicate()[0].splitlines()

print "\n\nShow nets in xgaggr1:"
get_aggr_nets()
print "\n\nTesting net: " + sys.argv[1]
test_nets = [sys.argv[1]]
print test_nets
vlan_test(test_nets)

Example run.

root@usli-psvm-ld01 # python check_vlans.py net3

Show nets in xgaggr1:
LINK: xgaggr1 CLASS: aggr MTU: 1500 STATE: up NETS:  ['net1']

Testing net: net3
['net3']
Testing interface: net3 over vlan id: 1912 DEV using IP: 10.2.14.230/23 Result:  ['no answer from 10.2.14.1']
Testing interface: net3 over vlan id: 1953 PPE using IP: 10.2.13.230/24 Result:  ['no answer from 10.2.13.1']
Testing interface: net3 over vlan id: 1954 TST using IP: 10.2.16.230/23 Result:  ['no answer from 10.2.16.1']
Testing interface: net3 over vlan id: 1915 DR using IP: 10.2.12.230/24 Result:  ['no answer from 10.2.12.1']
Testing interface: net3 over vlan id: 1913 MGMT using IP: 10.2.10.230/24 Result:  ['no answer from 10.2.10.1']
root@usli-psvm-ld01 # python check_vlans.py net0

Show nets in xgaggr1:
LINK: xgaggr1 CLASS: aggr MTU: 1500 STATE: up NETS:  ['net1']

Testing net: net0
['net0']
Testing interface: net0 over vlan id: 1912 DEV using IP: 10.2.14.230/23 Result:  ['10.2.14.1 is alive']
Testing interface: net0 over vlan id: 1953 PPE using IP: 10.2.13.230/24 Result:  ['10.2.13.1 is alive']
Testing interface: net0 over vlan id: 1954 TST using IP: 10.2.16.230/23 Result:  ['10.2.16.1 is alive']
Testing interface: net0 over vlan id: 1915 DR using IP: 10.2.12.230/24 Result:  ['10.2.12.1 is alive']
Testing interface: net0 over vlan id: 1913 MGMT using IP: 10.2.10.230/24 Result:  ['10.2.10.1 is alive']

admin

Bio Info for Riaan