Merge "Fix subnets can not be deleted from network topology panel"

This commit is contained in:
Jenkins 2017-10-03 22:31:20 +00:00 committed by Gerrit Code Review
commit a37d9f08b0
2 changed files with 22 additions and 4 deletions

View File

@ -139,6 +139,10 @@ class DetailView(tabs.TabbedTableView):
redirect=self.get_redirect_url()) redirect=self.get_redirect_url())
return network return network
def get_subnets_data(self):
# MultiTableMixin requires this method to be defined
pass
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs) context = super(DetailView, self).get_context_data(**kwargs)
network = self._get_data() network = self._get_data()

View File

@ -850,13 +850,13 @@ horizon.network_topology = {
self.removeNode(self.data.networks[deviceId]); self.removeNode(self.data.networks[deviceId]);
break; break;
case 'port': case 'port':
self.removePort(deviceId, deleteData.device_data); self.removePortOrSubnet(deviceId, deleteData.device_data);
break; break;
} }
self.delete_balloon(); self.delete_balloon();
}, },
removePort: function(portId, deviceData) { removePortOrSubnet: function(portId, deviceData) {
var self = this; var self = this;
var routerId = deviceData.router_id; var routerId = deviceData.router_id;
var networkId = deviceData.network_id; var networkId = deviceData.network_id;
@ -881,16 +881,30 @@ horizon.network_topology = {
} }
} }
} }
} else {
var networkData = self.find_by_id(networkId).data;
var subnets = networkData.subnets;
for (var subnet in subnets) {
if (subnets[subnet].id === portId) {
if (subnets.length == 1) {
delete(networkData.subnets);
} else {
subnets.splice(subnet, 1);
}
self.force.start();
break;
}
}
} }
}, },
delete_port: function(routerId, portId, networkId) { delete_port: function(routerId, portId, networkId) {
var message = {id:portId}; var message = {id:portId};
var data = {network_id:networkId,routerId:routerId}; var data = {network_id:networkId,router_id:routerId};
if (routerId) { if (routerId) {
horizon.networktopologymessager.post_message(portId, 'router/' + routerId + '/', message, 'port', 'delete', data); horizon.networktopologymessager.post_message(portId, 'router/' + routerId + '/', message, 'port', 'delete', data);
} else { } else {
horizon.networktopologymessager.post_message(portId, 'network/' + networkId + '/', message, 'port', 'delete', data); horizon.networktopologymessager.post_message(portId, 'network/' + networkId + '/?tab=network_tabs__subnets_tab', message, 'port', 'delete', data);
} }
}, },