Support to delete instance from network topology view

When try to delete an instance in network topology view, horizon would
try to load project/instance table in background, then do the delete
row action to the instance.
But the project instance table was paginated, it only load the first
page instances. The delete action would not work if you try to delete
an instance that are not in the first page.
The patch try to fix the bug.

Change-Id: I317bd1ee418d19c075ae3ac8d39563a0514b1795
Closes-Bug: #1597677
This commit is contained in:
MinSun 2016-09-07 13:14:42 +08:00
parent e5dac64cb0
commit 73f8675148
3 changed files with 19 additions and 4 deletions

View File

@ -159,6 +159,19 @@ class InstanceView(i_views.IndexView):
table_class = instances_tables.InstancesTable
template_name = 'project/network_topology/iframe.html'
def get_data(self):
self._more = False
# Get instance by id, return a list of one instance
# If failed to retrieve the instance, return an empty list
try:
instance_id = self.request.GET.get("id", "")
instance = api.nova.server_get(self.request, instance_id)
return [instance]
except Exception:
exceptions.handle(self.request,
_('Unable to retrieve the instance.'))
return []
class RouterView(r_views.IndexView):
table_class = routers_tables.RoutersTable

View File

@ -493,9 +493,10 @@ horizon.flat_network_topology = {
}
return str;
},
delete_device: function(type, device_id) {
delete_device: function(device_type, device_id) {
var message = {id:device_id};
horizon.networktopologymessager.post_message(device_id,type,message,type,'delete',data={});
var target = device_type === 'instance' ? 'instance?id=' + device_id : device_type;
horizon.networktopologymessager.post_message(device_id, target, message, device_type, 'delete', data={});
},
delete_port: function(router_id, port_id, network_id) {
var message = {id:port_id};

View File

@ -853,9 +853,10 @@ horizon.network_topology = {
return this.vis.selectAll('line.link').data(this.links).exit().remove();
},
delete_device: function(type, deviceId) {
delete_device: function(device_type, deviceId) {
var message = {id:deviceId};
horizon.networktopologymessager.post_message(deviceId,type,message,type,'delete',data={});
var target = device_type === 'instance' ? 'instance?id=' + deviceId : device_type;
horizon.networktopologymessager.post_message(deviceId, target, message, device_type, 'delete', data={});
},
remove_node_on_delete: function(deleteData) {