@@ -223,7 +223,7 @@ def handle_network_change(self):
223
223
with self .network_lock :
224
224
225
225
# if the topology hasn't changed, ignore
226
- if self .network . topology == self .prev_network . topology :
226
+ if self .network == self .prev_network :
227
227
return
228
228
229
229
# otherwise copy the network object
@@ -880,9 +880,7 @@ def nuclear_install(new_rules, curr_classifier_no):
880
880
:param classifier: the input classifer
881
881
:type classifier: Classifier
882
882
"""
883
- switch_attrs_tuples = self .network .topology .nodes (data = True )
884
- switch_to_attrs = { k : v for (k ,v ) in switch_attrs_tuples }
885
- switches = switch_to_attrs .keys ()
883
+ switches = self .network .switch_list ()
886
884
887
885
for s in switches :
888
886
self .send_barrier (s )
@@ -915,9 +913,7 @@ def add_version(rules, version):
915
913
new_rules .append (r + (version ,))
916
914
return new_rules
917
915
918
- switch_attrs_tuples = self .network .topology .nodes (data = True )
919
- switch_to_attrs = { k : v for (k ,v ) in switch_attrs_tuples }
920
- switches = switch_to_attrs .keys ()
916
+ switches = self .network .switch_list ()
921
917
922
918
classifier = switchify (classifier ,switches )
923
919
classifier = concretize (classifier )
@@ -1016,9 +1012,7 @@ def install_diff_lists(diff_lists, classifier_version_no):
1016
1012
:type classifier_version_no: int
1017
1013
"""
1018
1014
(to_add , to_delete , to_modify , to_stay ) = diff_lists
1019
- switch_attrs_tuples = self .network .topology .nodes (data = True )
1020
- switch_to_attrs = { k : v for (k ,v ) in switch_attrs_tuples }
1021
- switches = switch_to_attrs .keys ()
1015
+ switches = self .network .switch_list ()
1022
1016
1023
1017
# If the controller just came up, clear out the switches.
1024
1018
if classifier_version_no == 1 or self .mode == 'proactive0' :
@@ -1118,10 +1112,10 @@ def pull_switches_for_preds(self, concrete_preds, bucket):
1118
1112
if 'switch' in concrete_pred :
1119
1113
switch_id = concrete_pred ['switch' ]
1120
1114
if ((not switch_id in switch_list ) and
1121
- (switch_id in self .network .topology . nodes ())):
1115
+ (switch_id in self .network .switch_list ())):
1122
1116
switch_list .append (switch_id )
1123
1117
else :
1124
- switch_list = self .network .topology . nodes ()
1118
+ switch_list = self .network .switch_list ()
1125
1119
break
1126
1120
self .log .info ('Pulling stats from switches '
1127
1121
+ str (switch_list ) + ' for bucket ' +
@@ -1282,7 +1276,7 @@ def send_clear(self,switch):
1282
1276
1283
1277
def clear_all (self ):
1284
1278
def f ():
1285
- switches = self .network .topology . nodes ()
1279
+ switches = self .network .switch_list ()
1286
1280
for s in switches :
1287
1281
self .send_barrier (s )
1288
1282
self .send_clear (s )
@@ -1309,11 +1303,11 @@ def handle_switch_join(self,switch_id):
1309
1303
def handle_switch_part (self ,switch_id ):
1310
1304
self .network .handle_switch_part (switch_id )
1311
1305
1312
- def handle_port_join (self ,switch_id ,port_id ,conf_up ,stat_up ):
1313
- self .network .handle_port_join (switch_id ,port_id ,conf_up ,stat_up )
1306
+ def handle_port_join (self ,switch_id ,port_id ,conf_up ,stat_up , port_type ):
1307
+ self .network .handle_port_join (switch_id ,port_id ,conf_up ,stat_up , port_type )
1314
1308
1315
- def handle_port_mod (self , switch , port_no , config , status ):
1316
- self .network .handle_port_mod (switch , port_no , config , status )
1309
+ def handle_port_mod (self ,switch_id , port_id , conf_up , stat_up , port_type ):
1310
+ self .network .handle_port_mod (switch_id , port_id , conf_up , stat_up , port_type )
1317
1311
1318
1312
def handle_port_part (self , switch , port_no ):
1319
1313
self .network .handle_port_part (switch , port_no )
@@ -1569,10 +1563,10 @@ def handle_switch_part(self, switch):
1569
1563
self .debug_log .debug (str (self .next_topo ))
1570
1564
self .queue_update (self .get_update_no ())
1571
1565
1572
- def handle_port_join (self , switch , port_no , config , status ):
1566
+ def handle_port_join (self , switch , port_no , config , status , port_type ):
1573
1567
self .debug_log .debug ("handle_port_joins %s:%s:%s:%s" % (switch , port_no , config , status ))
1574
1568
this_update_no = self .get_update_no ()
1575
- self .next_topo .add_port (switch ,port_no ,config ,status )
1569
+ self .next_topo .add_port (switch ,port_no ,config ,status , port_type )
1576
1570
if config or status :
1577
1571
self .inject_discovery_packet (switch ,port_no )
1578
1572
self .debug_log .debug (str (self .next_topo ))
@@ -1588,12 +1582,13 @@ def handle_port_part(self, switch, port_no):
1588
1582
except KeyError :
1589
1583
pass # THE SWITCH HAS ALREADY BEEN REMOVED BY handle_switch_parts
1590
1584
1591
- def handle_port_mod (self , switch , port_no , config , status ):
1585
+ def handle_port_mod (self , switch , port_no , config , status , port_type ):
1592
1586
self .debug_log .debug ("handle_port_mods %s:%s:%s:%s" % (switch , port_no , config , status ))
1593
1587
# GET PREV VALUES
1594
1588
try :
1595
1589
prev_config = self .next_topo .node [switch ]["ports" ][port_no ].config
1596
1590
prev_status = self .next_topo .node [switch ]["ports" ][port_no ].status
1591
+ prev_port_type = self .next_topo .node [switch ]["ports" ][port_no ].port_type
1597
1592
except KeyError :
1598
1593
self .log .warning ("KeyError CASE!!!!!!!!" )
1599
1594
self .port_down (switch , port_no )
@@ -1602,6 +1597,8 @@ def handle_port_mod(self, switch, port_no, config, status):
1602
1597
# UPDATE VALUES
1603
1598
self .next_topo .node [switch ]["ports" ][port_no ].config = config
1604
1599
self .next_topo .node [switch ]["ports" ][port_no ].status = status
1600
+ self .next_topo .node [switch ]["ports" ][port_no ].port_type = port_type
1601
+
1605
1602
1606
1603
# DETERMINE IF/WHAT CHANGED
1607
1604
if (prev_config and not config ):
@@ -1665,7 +1662,13 @@ def handle_link_update(self, s1, p_no1, s2, p_no2):
1665
1662
if p1 .possibly_up () and p2 .possibly_up ():
1666
1663
self .next_topo .node [s1 ]["ports" ][p_no1 ].linked_to = Location (s2 ,p_no2 )
1667
1664
self .next_topo .node [s2 ]["ports" ][p_no2 ].linked_to = Location (s1 ,p_no1 )
1668
- self .next_topo .add_edge (s1 , s2 , {s1 : p_no1 , s2 : p_no2 })
1665
+ pt1 = self .next_topo .node [s1 ]["ports" ][p_no1 ].port_type
1666
+ pt2 = self .next_topo .node [s2 ]["ports" ][p_no2 ].port_type
1667
+ if pt1 != pt2 :
1668
+ print "MISMATCH " ,
1669
+ print pt1
1670
+ print pt2
1671
+ self .next_topo .add_edge (s1 , s2 , {s1 : p_no1 , s2 : p_no2 , 'type' : pt1 })
1669
1672
1670
1673
# IF REACHED, WE'VE REMOVED AN EDGE, OR ADDED ONE, OR BOTH
1671
1674
self .debug_log .debug (self .next_topo )
0 commit comments