mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +00:00
Added some funcitons
This commit is contained in:
parent
a2a679857c
commit
64b43f1385
3 changed files with 468 additions and 87 deletions
|
@ -120,7 +120,7 @@ def instance(request, compute_id, vname):
|
||||||
{'dev': disk['dev'], 'storage': disk['storage'], 'image': image, 'format': disk['format']})
|
{'dev': disk['dev'], 'storage': disk['storage'], 'image': image, 'format': disk['format']})
|
||||||
return clone_disk
|
return clone_disk
|
||||||
|
|
||||||
errors = []
|
error_messages = []
|
||||||
messages = []
|
messages = []
|
||||||
compute = Compute.objects.get(id=compute_id)
|
compute = Compute.objects.get(id=compute_id)
|
||||||
computes = Compute.objects.all()
|
computes = Compute.objects.all()
|
||||||
|
@ -164,8 +164,8 @@ def instance(request, compute_id, vname):
|
||||||
has_managed_save_image = conn.get_managed_save_image()
|
has_managed_save_image = conn.get_managed_save_image()
|
||||||
clone_disks = show_clone_disk(disks)
|
clone_disks = show_clone_disk(disks)
|
||||||
console_passwd = conn.get_console_passwd()
|
console_passwd = conn.get_console_passwd()
|
||||||
except libvirtError as err:
|
except libvirtError as lib_err:
|
||||||
errors.append(err)
|
error_messages.append(lib_err)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
instance = Instance.objects.get(compute_id=compute_id, name=vname)
|
instance = Instance.objects.get(compute_id=compute_id, name=vname)
|
||||||
|
@ -178,25 +178,19 @@ def instance(request, compute_id, vname):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if 'start' in request.POST:
|
if 'poweron' in request.POST:
|
||||||
conn.start()
|
conn.start()
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#shutdown')
|
return HttpResponseRedirect(request.get_full_path() + '#poweron')
|
||||||
if 'power' in request.POST:
|
if 'powercycle' in request.POST:
|
||||||
if 'shutdown' == request.POST.get('power', ''):
|
|
||||||
conn.shutdown()
|
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#shutdown')
|
|
||||||
if 'destroy' == request.POST.get('power', ''):
|
|
||||||
conn.force_shutdown()
|
conn.force_shutdown()
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#forceshutdown')
|
conn.start()
|
||||||
if 'managedsave' == request.POST.get('power', ''):
|
return HttpResponseRedirect(request.get_full_path() + '#powercycle')
|
||||||
conn.managedsave()
|
if 'poweroff' == request.POST.get('power', ''):
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#managedsave')
|
conn.shutdown()
|
||||||
if 'deletesaveimage' in request.POST:
|
return HttpResponseRedirect(request.get_full_path() + '#poweroff')
|
||||||
conn.managed_save_remove()
|
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#managedsave')
|
|
||||||
if 'suspend' in request.POST:
|
if 'suspend' in request.POST:
|
||||||
conn.suspend()
|
conn.suspend()
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#suspend')
|
return HttpResponseRedirect(request.get_full_path() + '#resume')
|
||||||
if 'resume' in request.POST:
|
if 'resume' in request.POST:
|
||||||
conn.resume()
|
conn.resume()
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#suspend')
|
return HttpResponseRedirect(request.get_full_path() + '#suspend')
|
||||||
|
@ -204,13 +198,13 @@ def instance(request, compute_id, vname):
|
||||||
if conn.get_status() == 1:
|
if conn.get_status() == 1:
|
||||||
conn.force_shutdown()
|
conn.force_shutdown()
|
||||||
try:
|
try:
|
||||||
instance = Instance.objects.get(compute_id=host_id, name=vname)
|
instance = Instance.objects.get(compute_id=compute_id, name=vname)
|
||||||
instance.delete()
|
instance.delete()
|
||||||
if request.POST.get('delete_disk', ''):
|
if request.POST.get('delete_disk', ''):
|
||||||
conn.delete_disk()
|
conn.delete_disk()
|
||||||
finally:
|
finally:
|
||||||
conn.delete()
|
conn.delete()
|
||||||
return HttpResponseRedirect(reverse('instances', args=[host_id]))
|
return HttpResponseRedirect(reverse('instances', args=[compute_id]))
|
||||||
if 'snapshot' in request.POST:
|
if 'snapshot' in request.POST:
|
||||||
name = request.POST.get('name', '')
|
name = request.POST.get('name', '')
|
||||||
conn.create_snapshot(name)
|
conn.create_snapshot(name)
|
||||||
|
@ -231,7 +225,7 @@ def instance(request, compute_id, vname):
|
||||||
if 'unset_autostart' in request.POST:
|
if 'unset_autostart' in request.POST:
|
||||||
conn.set_autostart(0)
|
conn.set_autostart(0)
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#instancesettings')
|
return HttpResponseRedirect(request.get_full_path() + '#instancesettings')
|
||||||
if 'change_settings' in request.POST:
|
if 'resize' in request.POST:
|
||||||
description = request.POST.get('description', '')
|
description = request.POST.get('description', '')
|
||||||
vcpu = request.POST.get('vcpu', '')
|
vcpu = request.POST.get('vcpu', '')
|
||||||
cur_vcpu = request.POST.get('cur_vcpu', '')
|
cur_vcpu = request.POST.get('cur_vcpu', '')
|
||||||
|
@ -243,7 +237,7 @@ def instance(request, compute_id, vname):
|
||||||
cur_memory_custom = request.POST.get('cur_memory_custom', '')
|
cur_memory_custom = request.POST.get('cur_memory_custom', '')
|
||||||
if cur_memory_custom:
|
if cur_memory_custom:
|
||||||
cur_memory = cur_memory_custom
|
cur_memory = cur_memory_custom
|
||||||
conn.change_settings(description, cur_memory, memory, cur_vcpu, vcpu)
|
conn.resize(cur_memory, memory, cur_vcpu, vcpu)
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#instancesettings')
|
return HttpResponseRedirect(request.get_full_path() + '#instancesettings')
|
||||||
if 'change_xml' in request.POST:
|
if 'change_xml' in request.POST:
|
||||||
xml = request.POST.get('inst_xml', '')
|
xml = request.POST.get('inst_xml', '')
|
||||||
|
@ -260,11 +254,11 @@ def instance(request, compute_id, vname):
|
||||||
passwd = ''
|
passwd = ''
|
||||||
if not passwd and not clear:
|
if not passwd and not clear:
|
||||||
msg = _("Enter the console password or select Generate")
|
msg = _("Enter the console password or select Generate")
|
||||||
errors.append(msg)
|
error_messages.append(msg)
|
||||||
if not errors:
|
if not error_messages:
|
||||||
if not conn.set_console_passwd(passwd):
|
if not conn.set_console_passwd(passwd):
|
||||||
msg = _("Error setting console password. You should check that your instance have an graphic device.")
|
msg = _("Error setting console password. You should check that your instance have an graphic device.")
|
||||||
errors.append(msg)
|
error_messages.append(msg)
|
||||||
else:
|
else:
|
||||||
return HttpResponseRedirect(request.get_full_path() + '#console_pass')
|
return HttpResponseRedirect(request.get_full_path() + '#console_pass')
|
||||||
|
|
||||||
|
@ -315,11 +309,11 @@ def instance(request, compute_id, vname):
|
||||||
clone_data[post] = request.POST.get(post, '')
|
clone_data[post] = request.POST.get(post, '')
|
||||||
|
|
||||||
conn.clone_instance(clone_data)
|
conn.clone_instance(clone_data)
|
||||||
return HttpResponseRedirect(reverse('instance', args=[host_id, clone_data['name']]))
|
return HttpResponseRedirect(reverse('instance', args=[compute_id, clone_data['name']]))
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
except libvirtError as err:
|
except libvirtError as err:
|
||||||
errors.append(err)
|
error_messages.append(err)
|
||||||
|
|
||||||
return render(request, 'instance.html', locals())
|
return render(request, 'instance.html', locals())
|
|
@ -109,14 +109,14 @@
|
||||||
{% ifequal status 3 %}
|
{% ifequal status 3 %}
|
||||||
<li role="presentation" class="active">
|
<li role="presentation" class="active">
|
||||||
<a href="#resume" aria-controls="resume" role="tab" data-toggle="tab">
|
<a href="#resume" aria-controls="resume" role="tab" data-toggle="tab">
|
||||||
{% trans "Reboot" %}
|
{% trans "Resume" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endifequal %}
|
{% endifequal %}
|
||||||
{% ifequal status 5 %}
|
{% ifequal status 5 %}
|
||||||
<li role="presentation" class="active">
|
<li role="presentation" class="active">
|
||||||
<a href="#boot" aria-controls="boot" role="tab" data-toggle="tab">
|
<a href="#boot" aria-controls="boot" role="tab" data-toggle="tab">
|
||||||
{% trans "Boot" %}
|
{% trans "Power On" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endifequal %}
|
{% endifequal %}
|
||||||
|
@ -159,7 +159,7 @@
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="boot">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="boot">
|
||||||
<p>{% trans "Click on Boot button to start this instance." %}</p>
|
<p>{% trans "Click on Boot button to start this instance." %}</p>
|
||||||
<form action="" method="post" role="form">{% csrf_token %}
|
<form action="" method="post" role="form">{% csrf_token %}
|
||||||
<input type="submit" name="boot" class="btn btn-lg btn-success pull-right" value="{% trans "Boot" %}">
|
<input type="submit" name="poweron" class="btn btn-lg btn-success pull-right" value="{% trans "Power On" %}">
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -204,7 +204,68 @@
|
||||||
<!-- Tab panes -->
|
<!-- Tab panes -->
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resizevm">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="resizevm">
|
||||||
<p>Resize Instance</p>
|
<form class="form-horizontal" method="post" role="form">{% csrf_token %}
|
||||||
|
<p style="font-weight:bold;">{% trans "Logical host CPUs:" %} {{ vcpu_host }}</p>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label" style="font-weight:normal;"> {% trans "Current allocation" %}</label>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<select name="cur_vcpu" class="form-control">
|
||||||
|
{% for cpu in vcpu_range %}
|
||||||
|
{% if cur_vcpu %}
|
||||||
|
<option value="{{ cpu }}" {% if cpu == cur_vcpu %}selected{% endif %}>{{ cpu }}</option>
|
||||||
|
{% else %}
|
||||||
|
<option value="{{ cpu }}" {% if cpu == vcpu %}selected{% endif %}>{{ cpu }}</option>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label" style="font-weight:normal;">{% trans "Maximum allocation" %}</label>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<select name="vcpu" class="form-control">
|
||||||
|
{% for cpu in vcpu_range %}
|
||||||
|
<option value="{{ cpu }}" {% if cpu == vcpu %}selected{% endif %}>{{ cpu }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p style="font-weight:bold;">{% trans "Total host memory:" %} {{ memory_host|filesizeformat }}</p>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label" style="font-weight:normal;">{% trans "Current allocation" %} ({% trans "MB" %})</label>
|
||||||
|
<div class="col-sm-4 js-custom__container">
|
||||||
|
<select name="cur_memory" class="form-control js-custom__toggle">
|
||||||
|
{% for mem in memory_range %}
|
||||||
|
<option value="{{ mem }}"
|
||||||
|
{% if mem == cur_memory %}selected{% endif %}>{{ mem }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<input type="text" name="cur_memory_custom" class="form-control js-custom__toggle" style="display: none" />
|
||||||
|
<small><input type="checkbox" class="js-custom__checkbox" /> {% trans "Custom value" %}</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label"
|
||||||
|
style="font-weight:normal;">{% trans "Maximum allocation" %} ({% trans "MB" %})</label>
|
||||||
|
|
||||||
|
<div class="col-sm-4 js-custom__container">
|
||||||
|
<select name="memory" class="form-control js-custom__toggle">
|
||||||
|
{% for mem in memory_range %}
|
||||||
|
<option value="{{ mem }}"
|
||||||
|
{% if mem == memory %}selected{% endif %}>{{ mem }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<input type="text" name="memory_custom" class="form-control js-custom__toggle" style="display: none" />
|
||||||
|
<small><input type="checkbox" class="js-custom__checkbox" /> {% trans "Custom value" %}</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% ifequal status 5 %}
|
||||||
|
<button type="submit" class="btn btn-lg btn-success pull-right" name="resize">{% trans "Resize" %}</button>
|
||||||
|
{% else %}
|
||||||
|
<button class="btn btn-lg btn-success pull-right disabled">{% trans "Resize" %}</button>
|
||||||
|
{% endifequal %}
|
||||||
|
</form>
|
||||||
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -231,8 +292,8 @@
|
||||||
<p>{% trans "This may take more than an hour, depending on how much content is on your droplet and how large the disk is." %}</p>
|
<p>{% trans "This may take more than an hour, depending on how much content is on your droplet and how large the disk is." %}</p>
|
||||||
<form class="form-inline" method="post" role="form">{% csrf_token %}
|
<form class="form-inline" method="post" role="form">{% csrf_token %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-6">
|
||||||
<input type="text" class="form-control" name="name" placeholder="{% trans "Enter Snapshot Name" %}" maxlength="14">
|
<input type="text" class="form-control input-lg" name="name" placeholder="{% trans "Enter Snapshot Name" %}" maxlength="14">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% ifequal status 5 %}
|
{% ifequal status 5 %}
|
||||||
|
@ -249,9 +310,11 @@
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="restoresnapshot">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="restoresnapshot">
|
||||||
{% ifequal status 5 %}
|
{% ifequal status 5 %}
|
||||||
{% if snapshots %}
|
{% if snapshots %}
|
||||||
<table class="table table-bordered">
|
<p>{% trans "Choose a snapshot for restore" %}</p>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="active">
|
<tr>
|
||||||
<th>{% trans "Name" %}</th>
|
<th>{% trans "Name" %}</th>
|
||||||
<th>{% trans "Date" %}</th>
|
<th>{% trans "Date" %}</th>
|
||||||
<th colspan="2">{% trans "Action" %}</th>
|
<th colspan="2">{% trans "Action" %}</th>
|
||||||
|
@ -266,12 +329,12 @@
|
||||||
<form action="" method="post" style="height:10px" role="form">{% csrf_token %}
|
<form action="" method="post" style="height:10px" role="form">{% csrf_token %}
|
||||||
<input type="hidden" name="name" value="{{ snap.name }}">
|
<input type="hidden" name="name" value="{{ snap.name }}">
|
||||||
{% ifequal status 5 %}
|
{% ifequal status 5 %}
|
||||||
<button type="submit" class="btn btn-sm btn-primary" name="revert_snapshot" onclick="return confirm('Are you sure?')">
|
<button type="submit" class="btn btn-sm btn-default" name="revert_snapshot" onclick="return confirm('Are you sure?')">
|
||||||
{% trans "Revert" %}
|
<span class="glyphicon glyphicon-save"></span>
|
||||||
</button>
|
</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
<button type="button" class="btn btn-sm btn-primary disabled">
|
<button type="button" class="btn btn-sm btn-default disabled">
|
||||||
{% trans "Revert" %}
|
<span class="glyphicon glyphicon-save"></span>
|
||||||
</button>
|
</button>
|
||||||
{% endifequal %}
|
{% endifequal %}
|
||||||
</form>
|
</form>
|
||||||
|
@ -279,8 +342,8 @@
|
||||||
<td style="width:30px;">
|
<td style="width:30px;">
|
||||||
<form action="" method="post" role="form">{% csrf_token %}
|
<form action="" method="post" role="form">{% csrf_token %}
|
||||||
<input type="hidden" name="name" value="{{ snap.name }}">
|
<input type="hidden" name="name" value="{{ snap.name }}">
|
||||||
<button type="submit" class="btn btn-sm btn-danger" name="delete_snapshot" onclick="return confirm('{% trans "Are you sure?" %}')">
|
<button type="submit" class="btn btn-sm btn-default" name="delete_snapshot" onclick="return confirm('{% trans "Are you sure?" %}')">
|
||||||
{% trans "Delete" %}
|
<span class="glyphicon glyphicon-trash"></span>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
|
@ -288,6 +351,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>{% trans "You do not have any snapshots" %}</p>
|
<p>{% trans "You do not have any snapshots" %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -303,23 +367,275 @@
|
||||||
<!-- Nav tabs -->
|
<!-- Nav tabs -->
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
<li role="presentation" class="active">
|
<li role="presentation" class="active">
|
||||||
|
<a href="#media" aria-controls="media" role="tab" data-toggle="tab">
|
||||||
|
{% trans "Media" %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li role="presentation">
|
||||||
<a href="#autostart" aria-controls="autostart" role="tab" data-toggle="tab">
|
<a href="#autostart" aria-controls="autostart" role="tab" data-toggle="tab">
|
||||||
{% trans "Autostart" %}
|
{% trans "Autostart" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li role="presentation">
|
<li role="presentation">
|
||||||
<a href="#media" aria-controls="media" role="tab" data-toggle="tab">
|
<a href="#vncsettings" aria-controls="vncsettings" role="tab" data-toggle="tab">
|
||||||
{% trans "Media" %}
|
{% trans "VNC" %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li role="presentation">
|
||||||
|
<a href="#clone" aria-controls="clone" role="tab" data-toggle="tab">
|
||||||
|
{% trans "Clone" %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li role="presentation">
|
||||||
|
<a href="#migrate" aria-controls="migrate" role="tab" data-toggle="tab">
|
||||||
|
{% trans "Migrate" %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li role="presentation">
|
||||||
|
<a href="#xmledit" aria-controls="xmledit" role="tab" data-toggle="tab">
|
||||||
|
{% trans "XML" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- Tab panes -->
|
<!-- Tab panes -->
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="autostart">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="media">
|
||||||
<p>Autostart</p>
|
<form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
|
||||||
|
{% for cd in media %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label">{% trans "CDROM" %} {{ forloop.counter }}</label>
|
||||||
|
{% if not cd.image %}
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<select name="media" class="form-control">
|
||||||
|
{% if media_iso %}
|
||||||
|
{% for iso in media_iso %}
|
||||||
|
<option value="{{ iso }}">{{ iso }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<option value="none">{% trans "None" %}</option>
|
||||||
|
{% endif %}
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="media">
|
<div class="col-sm-2">
|
||||||
<p>Cdrome</p>
|
{% if media_iso %}
|
||||||
|
<button type="submit" class="btn btn-sm btn-success pull-left" name="mount_iso" value="{{ cd.dev }}" style="margin-top: 2px;">{% trans "Mount" %}</button>
|
||||||
|
{% else %}
|
||||||
|
<button class="btn btn-sm btn-success pull-left disabled" name="mount_iso" style="margin-top: 2px;">{% trans "Mount" %}</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="col-sm-5">
|
||||||
|
<p>{{ cd.image }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<input type="hidden" name="path" value="{{ cd.path }}">
|
||||||
|
<button type="submit" class="btn btn-sm btn-success pull-left" value="{{ cd.dev }}" name="umount_iso" style="margin-top: 2px;">{% trans "Umount" %}</button>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</form>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="autostart">
|
||||||
|
<p>{% trans "Autostart your instance when host server is power on" %}</p>
|
||||||
|
<form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
|
||||||
|
{% ifequal autostart 0 %}
|
||||||
|
<input type="submit" class="btn btn-lg btn-success pull-right" name="set_autostart" value="{% trans "Enable" %}">
|
||||||
|
{% else %}
|
||||||
|
<input type="submit" class="btn btn-lg btn-success pull-right" name="unset_autostart" value="{% trans "Disable" %}">
|
||||||
|
{% endifequal %}
|
||||||
|
</form>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="vncsettings">
|
||||||
|
<p>{% trans "To set console's type, shutdown the instance." %}</p>
|
||||||
|
<form class="form-horizontal" method="post" role="form">{% csrf_token %}
|
||||||
|
<div class="form-group" id="console_type_selection">
|
||||||
|
<label for="console_select_type" class="col-sm-2 control-label">{% trans "Type" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<select id="console_select_type" class="form-control" name="console_type">
|
||||||
|
<option value="" style="font-weight: bold">{% trans "please choose" %}</option>
|
||||||
|
{% for ctype in console_types %}
|
||||||
|
<option value="{{ ctype }}">{{ ctype }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
{% ifequal status 5 %}
|
||||||
|
<button type="submit" class="btn btn-success " name="set_console_type">{% trans "Set" %}</button>
|
||||||
|
{% else %}
|
||||||
|
<button class="btn btn-success disabled" name="set_console_type">{% trans "Set" %}</button>
|
||||||
|
{% endifequal %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<p>{% trans "To create console password, shutdown the instance." %}</p>
|
||||||
|
<form class="form-horizontal" method="post" role="form">{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="auto_pass" value="true" id="console_passwd_gen">{% trans "Generate" %}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="clear_pass" value="true" id="console_passwd_clear">{% trans "Clear" %}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group" id="console_passwd_manual">
|
||||||
|
<label for="inputPassword1" class="col-sm-2 control-label">{% trans "Password" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input id="console_show_pass" type="password" class="form-control" name="console_passwd"
|
||||||
|
{% if console_passwd %}
|
||||||
|
value="{{ console_passwd }}"
|
||||||
|
{% else %}
|
||||||
|
placeholder="{% trans "Password" %}"
|
||||||
|
{% endif %} maxlength="14">
|
||||||
|
</div>
|
||||||
|
{% if console_passwd %}
|
||||||
|
<a href="#" name="console_show" class="btn btn-primary btn-md" onclick="show_console()">{% trans "Show" %}</a>
|
||||||
|
{% endif %}
|
||||||
|
<div class="col-sm-3">
|
||||||
|
{% ifequal status 5 %}
|
||||||
|
<button type="submit" class="btn btn-success" name="set_console_passwd">{% trans "Set" %}</button>
|
||||||
|
{% else %}
|
||||||
|
<button class="btn btn-success disabled" name="set_console_passwd">{% trans "Set" %}</button>
|
||||||
|
{% endifequal %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<p>{% trans "To set console's keymap, shutdown the instance." %}</p>
|
||||||
|
<form class="form-horizontal" method="post" role="form">{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="clear_keymap" value="true" id="console_keymap_clear">{% trans "Clear" %}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group" id="console_keymap_selection">
|
||||||
|
<label for="console_select_keymap" class="col-sm-2 control-label">{% trans "Keymap" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<select id="console_select_keymap" class="form-control" name="console_keymap">
|
||||||
|
<option value="" style="font-weight: bold">{% trans "please choose" %}</option>
|
||||||
|
{% for keymap in keymaps %}
|
||||||
|
<option value="{{ keymap }}">{{ keymap }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
{% ifequal status 5 %}
|
||||||
|
<button type="submit" class="btn btn-success" name="set_console_keymap">{% trans "Set" %}</button>
|
||||||
|
{% else %}
|
||||||
|
<button class="btn btn-success disabled" name="set_console_keymap">{% trans "Set" %}</button>
|
||||||
|
{% endifequal %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="clone">
|
||||||
|
<p style="font-weight:bold;">{% trans "Create a clone" %}</p>
|
||||||
|
<form class="form-horizontal" action="" method="post" role="form">{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label" style="font-weight:normal;">{% trans "Clone Name" %}</label>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<input type="text" class="form-control" name="name" value="{{ vname }}-clone"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p style="font-weight:bold;">{% trans "Network devices" %}</p>
|
||||||
|
{% for network in networks %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label" style="font-weight:normal;">eth{{ forloop.counter0 }} ({{ network.nic }})</label>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<input type="text" class="form-control" name="net-{{ forloop.counter0 }}" value="{{ network.mac }}"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-1">
|
||||||
|
<button type="button" class="btn btn-sm btn-success pull-left" name="random-mac-{{ forloop.counter0 }}"
|
||||||
|
onclick="random_mac({{ forloop.counter0 }})" style="margin-top: 2px;">{% trans "Random" %}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<p style="font-weight:bold;">{% trans "Storage devices" %}</p>
|
||||||
|
{% for disk in clone_disks %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label" style="font-weight:normal;">{{ disk.dev }} ({{ disk.storage }})</label>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<input type="text" class="form-control" name="disk-{{ disk.dev }}" value="{{ disk.image }}"/>
|
||||||
|
</div>
|
||||||
|
{% ifequal disk.format 'qcow2' %}
|
||||||
|
<label class="col-sm-2 control-label" style="font-weight:normal;margin-left:-35px;">Metadata</label>
|
||||||
|
<div class="col-sm-1">
|
||||||
|
<input type="checkbox" name="meta-{{ disk.dev }}" value="true" style="margin-top: 10px;">
|
||||||
|
</div>
|
||||||
|
{% endifequal %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% ifequal status 5 %}
|
||||||
|
<button type="submit" class="btn btn-lg btn-success pull-right" name="clone">{% trans "Clone" %}</button>
|
||||||
|
{% else %}
|
||||||
|
<button class="btn btn-lg btn-success pull-right disabled" name="clone">{% trans "Clone" %}</button>
|
||||||
|
{% endifequal %}
|
||||||
|
</form>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="migrate">
|
||||||
|
<p>{% trans "For migration both host servers must have equal settings and OS type" %}</p>
|
||||||
|
<form class="form-horizontal" method="post" role="form">{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Original host" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<p style="margin: 10px -10px 0 0;">{{ compute.name }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Host migration" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<select name="compute_id" class="form-control">
|
||||||
|
{% if computes_count != 1 %}
|
||||||
|
{% for comp in computes %}
|
||||||
|
{% if comp.id != compute.id %}
|
||||||
|
<option value="{{ comp.id }}">{{ comp.name }}</option>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Live migration" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="checkbox" name="live_migrate" value="true" id="vm_live_migrate">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Unsafe migration" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="checkbox" name="unsafe_migrate" value="true" id="vm_unsafe_migrate">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Delete original" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="checkbox" name="xml_delete" value="true" id="xml_delete">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% if computes_count != 1 %}
|
||||||
|
<button type="submit" class="btn btn-lg btn-success pull-right" name="migrate">{% trans "Migrate" %}</button>
|
||||||
|
{% else %}
|
||||||
|
<button class="btn btn-lg btn-success pull-right disabled">{% trans "Migrate" %}</button>
|
||||||
|
{% endif %}
|
||||||
|
</form>
|
||||||
|
<div class="clearfix"></div></p>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="xmledit">
|
||||||
|
<p>XML</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -355,7 +671,17 @@
|
||||||
<!-- Tab panes -->
|
<!-- Tab panes -->
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="destroy">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="destroy">
|
||||||
<p>Destroy Instance</p>
|
<p>{% trans "Delete storage for instance?" %}</p>
|
||||||
|
<form class="form-group" method="post" role="form">{% csrf_token %}
|
||||||
|
<div class="checkbox" style="margin-left: 8px;">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="delete_disk" value="true">
|
||||||
|
<strong>{% trans "Remove Instance's data" %}</strong>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-lg btn-success pull-right" name="delete">{% trans "Destroy" %}</button>
|
||||||
|
</form>
|
||||||
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -371,4 +697,73 @@
|
||||||
window.open('{% url 'console' %}?token={{ compute_id }}-{{ uuid }}', '', 'width=850,height=485')
|
window.open('{% url 'console' %}?token={{ compute_id }}-{{ uuid }}', '', 'width=850,height=485')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
function random_mac(net) {
|
||||||
|
var hexDigits = "0123456789abcdef";
|
||||||
|
var macAddress="52:54:00:";
|
||||||
|
for (var i=0; i<3; i++) {
|
||||||
|
macAddress+=hexDigits.charAt(Math.round(Math.random()*16));
|
||||||
|
macAddress+=hexDigits.charAt(Math.round(Math.random()*16));
|
||||||
|
if (i != 2) macAddress+=":";
|
||||||
|
}
|
||||||
|
$('input[name="net-'+net+'"]').val(macAddress);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
function show_console() {
|
||||||
|
if ($('#console_show_pass').attr('type') == 'password') {
|
||||||
|
$('#console_show_pass').attr('type', 'text');
|
||||||
|
} else {
|
||||||
|
$('#console_show_pass').attr('type', 'password');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
$(document).on('change', '#console_passwd_gen', function () {
|
||||||
|
if ($(this).prop('checked')) {
|
||||||
|
$('#console_passwd_manual').hide();
|
||||||
|
$('#console_passwd_clear').prop('checked', false);
|
||||||
|
} else {
|
||||||
|
$('#console_passwd_manual').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(document).on('change', '#console_passwd_clear', function () {
|
||||||
|
if ($(this).prop('checked')) {
|
||||||
|
$('#console_passwd_manual').hide();
|
||||||
|
$('#console_passwd_gen').prop('checked', false);
|
||||||
|
} else {
|
||||||
|
$('#console_passwd_manual').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(document).on('change', '#console_keymap_clear', function () {
|
||||||
|
if ($(this).prop('checked')) {
|
||||||
|
$('#console_keymap_selection').hide();
|
||||||
|
} else {
|
||||||
|
$('#console_keymap_selection').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(document).ready(function () {
|
||||||
|
// set current console keymap or fall back to default
|
||||||
|
var keymap = "{{ console_keymap }}"
|
||||||
|
if (keymap != '') {
|
||||||
|
$("#console_select_keymap option[value='" + keymap + "']").prop('selected', true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(document).ready(function () {
|
||||||
|
// set current console type or fall back to default
|
||||||
|
var console_type = "{{ console_type }}"
|
||||||
|
if (console_type != '') {
|
||||||
|
$("#console_select_type option[value='" + console_type + "']").prop('selected', true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
$('.js-custom__checkbox').change(function () {
|
||||||
|
var container = $(this).closest('.js-custom__container');
|
||||||
|
var toggles = container.find('.js-custom__toggle');
|
||||||
|
toggles.toggle();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -470,7 +470,7 @@ class wvmInstance(wvmConnect):
|
||||||
return util.get_xml_path(self._XMLDesc(VIR_DOMAIN_XML_SECURE),
|
return util.get_xml_path(self._XMLDesc(VIR_DOMAIN_XML_SECURE),
|
||||||
"/domain/devices/graphics/@keymap") or ''
|
"/domain/devices/graphics/@keymap") or ''
|
||||||
|
|
||||||
def change_settings(self, description, cur_memory, memory, cur_vcpu, vcpu):
|
def resize(self, cur_memory, memory, cur_vcpu, vcpu):
|
||||||
"""
|
"""
|
||||||
Function change ram and cpu on vds.
|
Function change ram and cpu on vds.
|
||||||
"""
|
"""
|
||||||
|
@ -484,18 +484,10 @@ class wvmInstance(wvmConnect):
|
||||||
set_mem.text = str(memory)
|
set_mem.text = str(memory)
|
||||||
set_cur_mem = tree.find('currentMemory')
|
set_cur_mem = tree.find('currentMemory')
|
||||||
set_cur_mem.text = str(cur_memory)
|
set_cur_mem.text = str(cur_memory)
|
||||||
set_desc = tree.find('description')
|
|
||||||
set_vcpu = tree.find('vcpu')
|
set_vcpu = tree.find('vcpu')
|
||||||
set_vcpu.text = vcpu
|
set_vcpu.text = vcpu
|
||||||
set_vcpu.set('current', cur_vcpu)
|
set_vcpu.set('current', cur_vcpu)
|
||||||
|
|
||||||
if not set_desc:
|
|
||||||
tree_desc = ElementTree.Element('description')
|
|
||||||
tree_desc.text = description
|
|
||||||
tree.insert(2, tree_desc)
|
|
||||||
else:
|
|
||||||
set_desc.text = description
|
|
||||||
|
|
||||||
new_xml = ElementTree.tostring(tree)
|
new_xml = ElementTree.tostring(tree)
|
||||||
self._defineXML(new_xml)
|
self._defineXML(new_xml)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue