From 078905df8a38be7d7c65869c71429131eca57364 Mon Sep 17 00:00:00 2001 From: HongWeipeng <961365124@qq.com> Date: Mon, 11 Jun 2018 12:41:46 +0800 Subject: [PATCH] fix:sorted btween 'dict' and 'dict' --- instances/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instances/views.py b/instances/views.py index 0d6dfab..a00e5b1 100644 --- a/instances/views.py +++ b/instances/views.py @@ -330,7 +330,7 @@ def instance(request, compute_id, vname): console_type = conn.get_console_type() console_port = conn.get_console_port() console_keymap = conn.get_console_keymap() - snapshots = sorted(conn.get_snapshot(), reverse=True) + snapshots = sorted(conn.get_snapshot(), reverse=True, key=lambda k:k['date']) inst_xml = conn._XMLDesc(VIR_DOMAIN_XML_SECURE) has_managed_save_image = conn.get_managed_save_image() clone_disks = show_clone_disk(disks, vname) @@ -955,7 +955,7 @@ def delete_instance(instance, delete_disk=False): print("Forcing shutdown") conn.force_shutdown() if delete_disk: - snapshots = sorted(conn.get_snapshot(), reverse=True) + snapshots = sorted(conn.get_snapshot(), reverse=True, key=lambda k:k['date']) for snap in snapshots: print("Deleting snapshot {}".format(snap['name'])) conn.snapshot_delete(snap['name'])