diff --git a/instances/templates/instances/snapshots_tab.html b/instances/templates/instances/snapshots_tab.html index 803fac3..d6eb88e 100644 --- a/instances/templates/instances/snapshots_tab.html +++ b/instances/templates/instances/snapshots_tab.html @@ -17,16 +17,20 @@
-

{% trans "This may take more than an hour, depending on how much content is on your instance and how large the disk is. It could cause web server timeout.." %}

+ {% if instance.status != 5 %} +

{% trans "With running machine, internal snapshots may take more than an hour, depending on how much memory has on your instance and how large the disk is." %}

+

{% trans "Live snapshot could cause server timeout and instance might be paused!!!" %}

+ {% else %} +

{% trans "Create an internal snapshot" %}

+ {% endif %}
{% csrf_token %} -
- + + | +
- -
@@ -36,15 +40,17 @@
- + + {% for snap in instance.snapshots %} - + +
{% trans "Name" %} {% trans "Date" %}{% trans "Name" %}{% trans "Description" %} {% trans "Action" %}
{{ snap.name }} {{ snap.date|date:"M d H:i:s" }}{{ snap.name }}{{ snap.description }}
{% csrf_token %} diff --git a/instances/views.py b/instances/views.py index fc04ee4..d19cba3 100644 --- a/instances/views.py +++ b/instances/views.py @@ -816,7 +816,8 @@ def snapshot(request, pk): if allow_admin_or_not_template and request.user.has_perm("instances.snapshot_instances"): name = request.POST.get("name", "") - instance.proxy.create_snapshot(name) + desc = request.POST.get("description", "") + instance.proxy.create_snapshot(name, desc) msg = _("Create snapshot: %(snap)s") % {"snap": name} addlogmsg(request.user.username, instance.compute.name, instance.name, msg) return redirect(request.META.get("HTTP_REFERER") + "#managesnapshot") diff --git a/vrtManager/instance.py b/vrtManager/instance.py index f392402..0931a98 100644 --- a/vrtManager/instance.py +++ b/vrtManager/instance.py @@ -1207,12 +1207,16 @@ class wvmInstance(wvmConnect): def _snapshotCreateXML(self, xml, flag): self.instance.snapshotCreateXML(xml, flag) - def create_snapshot(self, name): + def create_snapshot(self, name, desc=None): + state = 'shutoff' if self.get_status()==5 else 'running' xml = """ %s - shutoff + %s + %s %d""" % ( name, + desc, + state, time.time(), ) self.change_snapshot_xml() @@ -1235,8 +1239,15 @@ class wvmInstance(wvmConnect): snapshot_list = self.instance.snapshotListNames(0) for snapshot in snapshot_list: snap = self.instance.snapshotLookupByName(snapshot, 0) + snap_description = util.get_xml_path(snap.getXMLDesc(0), "/domainsnapshot/description") snap_time_create = util.get_xml_path(snap.getXMLDesc(0), "/domainsnapshot/creationTime") - snapshots.append({"date": datetime.fromtimestamp(int(snap_time_create)), "name": snapshot}) + snapshots.append( + { + "date": datetime.fromtimestamp(int(snap_time_create)), + "name": snapshot, + "description": snap_description, + } + ) return snapshots def snapshot_delete(self, snapshot):