mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-25 15:45:23 +00:00
Merge pull request #542 from catborise/master
add description to snapshots. Stress out live snapshot risks
This commit is contained in:
commit
7b33f511cf
3 changed files with 29 additions and 11 deletions
|
@ -17,16 +17,20 @@
|
||||||
<!-- Tab panes -->
|
<!-- Tab panes -->
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="takesnapshot">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="takesnapshot">
|
||||||
<p>{% 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.." %}</p>
|
{% if instance.status != 5 %}
|
||||||
|
<p>{% 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." %} </p>
|
||||||
|
<p class="text-danger">{% trans "Live snapshot could cause server timeout and instance might be paused!!!" %}</p>
|
||||||
|
{% else %}
|
||||||
|
<p>{% trans "Create an internal snapshot" %}</p>
|
||||||
|
{% endif %}
|
||||||
<form action="{% url 'instances:snapshot' instance.id %}" method="post" role="form" aria-label="Create snapshot form">
|
<form action="{% url 'instances:snapshot' instance.id %}" method="post" role="form" aria-label="Create snapshot form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
<input type="text" class="form-control form-control-lg" name="name" placeholder="{% trans "Enter Snapshot Name" %}" maxlength="14">
|
<input type="text" class="form-control form-control-lg" name="name" placeholder="{% trans "Snapshot Name" %}" maxlength="14">
|
||||||
|
<span class="input-group-text">|</span>
|
||||||
|
<input type="text" class="form-control form-control-lg" name="description" placeholder="{% trans "Snapshot Description" %}" maxlength="45">
|
||||||
<input type="submit" class="btn btn-lg btn-success float-end" name="snapshot" value="{% trans "Take Snapshot" %}" onclick="showPleaseWaitDialog();">
|
<input type="submit" class="btn btn-lg btn-success float-end" name="snapshot" value="{% trans "Take Snapshot" %}" onclick="showPleaseWaitDialog();">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -36,15 +40,17 @@
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<th scope="col">{% trans "Name" %}</th>
|
|
||||||
<th scope="col">{% trans "Date" %}</th>
|
<th scope="col">{% trans "Date" %}</th>
|
||||||
|
<th scope="col">{% trans "Name" %}</th>
|
||||||
|
<th scope="col">{% trans "Description" %}</th>
|
||||||
<th scope="colgroup" colspan="2">{% trans "Action" %}</th>
|
<th scope="colgroup" colspan="2">{% trans "Action" %}</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for snap in instance.snapshots %}
|
{% for snap in instance.snapshots %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>{{ snap.name }}</strong></td>
|
|
||||||
<td>{{ snap.date|date:"M d H:i:s" }}</td>
|
<td>{{ snap.date|date:"M d H:i:s" }}</td>
|
||||||
|
<td><strong>{{ snap.name }}</strong></td>
|
||||||
|
<td>{{ snap.description }}</td>
|
||||||
<td style="width:30px;">
|
<td style="width:30px;">
|
||||||
<form action="{% url 'instances:revert_snapshot' instance.id %}" method="post" role="form" aria-label="Restore snapshot form">
|
<form action="{% url 'instances:revert_snapshot' instance.id %}" method="post" role="form" aria-label="Restore snapshot form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
|
@ -816,7 +816,8 @@ def snapshot(request, pk):
|
||||||
|
|
||||||
if allow_admin_or_not_template and request.user.has_perm("instances.snapshot_instances"):
|
if allow_admin_or_not_template and request.user.has_perm("instances.snapshot_instances"):
|
||||||
name = request.POST.get("name", "")
|
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}
|
msg = _("Create snapshot: %(snap)s") % {"snap": name}
|
||||||
addlogmsg(request.user.username, instance.compute.name, instance.name, msg)
|
addlogmsg(request.user.username, instance.compute.name, instance.name, msg)
|
||||||
return redirect(request.META.get("HTTP_REFERER") + "#managesnapshot")
|
return redirect(request.META.get("HTTP_REFERER") + "#managesnapshot")
|
||||||
|
|
|
@ -1207,12 +1207,16 @@ class wvmInstance(wvmConnect):
|
||||||
def _snapshotCreateXML(self, xml, flag):
|
def _snapshotCreateXML(self, xml, flag):
|
||||||
self.instance.snapshotCreateXML(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 = """<domainsnapshot>
|
xml = """<domainsnapshot>
|
||||||
<name>%s</name>
|
<name>%s</name>
|
||||||
<state>shutoff</state>
|
<description>%s</description>
|
||||||
|
<state>%s</state>
|
||||||
<creationTime>%d</creationTime>""" % (
|
<creationTime>%d</creationTime>""" % (
|
||||||
name,
|
name,
|
||||||
|
desc,
|
||||||
|
state,
|
||||||
time.time(),
|
time.time(),
|
||||||
)
|
)
|
||||||
self.change_snapshot_xml()
|
self.change_snapshot_xml()
|
||||||
|
@ -1235,8 +1239,15 @@ class wvmInstance(wvmConnect):
|
||||||
snapshot_list = self.instance.snapshotListNames(0)
|
snapshot_list = self.instance.snapshotListNames(0)
|
||||||
for snapshot in snapshot_list:
|
for snapshot in snapshot_list:
|
||||||
snap = self.instance.snapshotLookupByName(snapshot, 0)
|
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")
|
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
|
return snapshots
|
||||||
|
|
||||||
def snapshot_delete(self, snapshot):
|
def snapshot_delete(self, snapshot):
|
||||||
|
|
Loading…
Reference in a new issue