All, thank you for the input. I really appreciate it. Unfortunately I realized that the way I currently posed the question, it is completely invalid. The keys in d2 correspond to subnet masks, which are not all unique, so the way I had it structured is not even a valid dictionary.
After a lot of fussing, I came up with a working solution:
p = 0
sysNames = ['R3','R2','R1']
d1 = OrderedDict([('200.200.200.2','R3'),('200.200.200.1','R2'),('172.172.172.1','R2'),('172.172.172.100','R1'),('192.168.1.151','R1')])
oid1 = '1.3.6.1.2.1.4.20.1.3.200.200.200.2'
oid2 = '1.3.6.1.2.1.4.20.1.3.200.200.200.1'
oid3 = '1.3.6.1.2.1.4.20.1.3.172.172.172.1'
oid4 = '1.3.6.1.2.1.4.20.1.3.172.172.172.100'
oid5 = '1.3.6.1.2.1.4.20.1.3.192.168.1.151'
d2 = {oid1:'255.255.255.0',oid2:'255.255.255.0',oid3:'255.255.255.0',oid4:'255.255.255.0',oid5:'255.255.255.0'}
d1keys = list(d1.keys())
d1values = list(d1.values())
maskOid = '1.3.6.1.2.1.4.20.1.3.'
d3 = {}
for i in range(len(sysNames)):
ipMaskList = list()
numInterfaces = d1values.count(sysNames[i])
for dummy in range(numInterfaces):
ipMaskList.append({d1keys[p]:d2.get(maskOid+d1keys[p])})
p += 1
d3[sysNames[i]] = ipMaskList
As typical, I'm sure this is a horribly inefficient and convoluted way to accomplish my goal. I am absolutely not a great programmer, and am just happy when things run correctly.
Again thank you guys you your help, and if anybody would like to post a more efficient solution, please feel free :)