summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinSun <minsu@cisco.com>2016-09-07 13:14:42 +0800
committerMinSun <minsu@cisco.com>2017-01-20 21:19:54 +0800
commit73f867514864954cca49e957e15011ab8b6e90aa (patch)
treedbb076c09df254687c05ab14259a0746809df345
parente5dac64cb0aac2176d5a608b155976f5375d6a7e (diff)
downloadhorizon-73f867514864954cca49e957e15011ab8b6e90aa.tar.gz
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
-rw-r--r--openstack_dashboard/dashboards/project/network_topology/views.py13
-rw-r--r--openstack_dashboard/static/js/horizon.flatnetworktopology.js5
-rw-r--r--openstack_dashboard/static/js/horizon.networktopology.js5
3 files changed, 19 insertions, 4 deletions
diff --git a/openstack_dashboard/dashboards/project/network_topology/views.py b/openstack_dashboard/dashboards/project/network_topology/views.py
index b7c3955c4..4bc3b4d83 100644
--- a/openstack_dashboard/dashboards/project/network_topology/views.py
+++ b/openstack_dashboard/dashboards/project/network_topology/views.py
@@ -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
diff --git a/openstack_dashboard/static/js/horizon.flatnetworktopology.js b/openstack_dashboard/static/js/horizon.flatnetworktopology.js
index 7e56562c8..0d0f27749 100644
--- a/openstack_dashboard/static/js/horizon.flatnetworktopology.js
+++ b/openstack_dashboard/static/js/horizon.flatnetworktopology.js
@@ -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};
diff --git a/openstack_dashboard/static/js/horizon.networktopology.js b/openstack_dashboard/static/js/horizon.networktopology.js
index 995f4f60c..d6b817594 100644
--- a/openstack_dashboard/static/js/horizon.networktopology.js
+++ b/openstack_dashboard/static/js/horizon.networktopology.js
@@ -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) {