summaryrefslogtreecommitdiff
path: root/code/vlanscrape
diff options
context:
space:
mode:
Diffstat (limited to 'code/vlanscrape')
-rwxr-xr-xcode/vlanscrape44
1 files changed, 25 insertions, 19 deletions
diff --git a/code/vlanscrape b/code/vlanscrape
index 5da322e..44411fc 100755
--- a/code/vlanscrape
+++ b/code/vlanscrape
@@ -93,6 +93,9 @@ def look_in_juniper_vlans_section(hostName, hostConfig):
break
else:
j += 1
+ if (i + j) >= len(hostConfig):
+ vlan="none"
+ break
vlanDict[vlan] = name
vlanList=vlanDict.items()
@@ -153,26 +156,29 @@ def write_list_to_file(outFile, outList):
def check_out_vs_dst(hostName, vlanList):
outFile = outputDir + "/" + hostName
outList = []
- for l in sorted(vlanList, key=lambda x: int(x[0])):
- o=''
- for i, sl in enumerate(l):
- if o == '':
- o = str(sl)
- else:
- o = o + ";" + str(sl)
- # we want the resulting 'csv' to have the same number of fields, whether
- # or not the source config has 'interface' for the vlan:
- if i == 1:
- o = o + ";"
- o = o + "\n"
- outList.append(o)
- if os.path.isfile(outFile):
- dstList = open(outFile, 'r').readlines()
- compare = set(sorted(outList)) & set(sorted(dstList))
- if (len(compare) != len(dstList)) or (len(compare) != len(outList)):
- write_list_to_file(outFile, outList)
+ if (len(vlanList) == 1) and ("none" in vlanList[0]):
+ print "no vlans in", hostName
else:
- write_list_to_file(outFile, outList)
+ for l in sorted(vlanList, key=lambda x: int(x[0])):
+ o=''
+ for i, sl in enumerate(l):
+ if o == '':
+ o = str(sl)
+ else:
+ o = o + ";" + str(sl)
+ # we want the resulting 'csv' to have the same number of fields, whether
+ # or not the source config has 'interface' for the vlan:
+ if i == 1:
+ o = o + ";"
+ o = o + "\n"
+ outList.append(o)
+ if os.path.isfile(outFile):
+ dstList = open(outFile, 'r').readlines()
+ compare = set(sorted(outList)) & set(sorted(dstList))
+ if (len(compare) != len(dstList)) or (len(compare) != len(outList)):
+ write_list_to_file(outFile, outList)
+ else:
+ write_list_to_file(outFile, outList)
def is_juniper(hostName):