Browse Source

Fix for network delete failure

Ticket:  CM-12268
Reviewed By: None
Testing Done: ML2 demo setup

The vxlan delete rest api command was failing when network was being deleted because the rest api url was missing the network id. Fixed the Url syntax.
radhika 2 years ago
parent
commit
35cd1a6774
1 changed files with 28 additions and 25 deletions
  1. 28
    25
      cumulus_ml2/mech_driver/driver.py

+ 28
- 25
cumulus_ml2/mech_driver/driver.py View File

@@ -60,34 +60,37 @@ class CumulusMechanismDriver(MechanismDriver):
60 60
 
61 61
         # remove vxlan from all hosts - a little unpleasant
62 62
         for _switch_ip in self.switches:
63
-            try:
64
-                actions = [
65
-                    VXLAN_URL.format(
66
-                        scheme=self.scheme,
67
-                        base=_switch_ip,
68
-                        port=self.protocol_port,
69
-                        vni=vni
70
-                    ),
71
-                    NETWORKS_URL.format(
72
-                        scheme=self.scheme,
73
-                        base=_switch_ip,
74
-                        port=self.protocol_port,
75
-                        network=network_id
76
-                    )
77
-                ]
78 63
 
79
-                for action in actions:
80
-                    r = requests.delete(action)
64
+            r = requests.delete(
65
+                VXLAN_URL.format(
66
+                    scheme=self.scheme,
67
+                    base=_switch_ip,
68
+                    port=self.protocol_port,
69
+                    network=network_id,
70
+                    vni=vni
71
+                )
72
+            )
81 73
 
82
-                    if r.status_code != requests.codes.ok:
83
-                        LOG.info(
84
-                            _LI('Error during %s delete. HTTP Error:%s'),
85
-                            action, r.status_code
86
-                        )
74
+            if r.status_code != requests.codes.ok:
75
+                LOG.info(
76
+                    _LI('Error during vxlan delete. HTTP Error:%d'),
77
+                    r.status_code
78
+                )
87 79
 
88
-            except Exception, e:
89
-                # errors might be normal, but should improve this
90
-                LOG.info(_LI('Error during net delete. Error %s'), e)
80
+            r = requests.delete(
81
+                NETWORKS_URL.format(
82
+                    scheme=self.scheme,
83
+                    base=_switch_ip,
84
+                    port=self.protocol_port,
85
+                    network=network_id
86
+                )
87
+            )
88
+
89
+            if r.status_code != requests.codes.ok:
90
+                LOG.info(
91
+                    _LI('Error during network delete. HTTP Error:%d'),
92
+                    r.status_code
93
+                )
91 94
 
92 95
     def create_port_postcommit(self, context):
93 96
         if context.segments_to_bind:

Loading…
Cancel
Save