mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 15:15:22 +00:00
commit
44fcb4b748
7 changed files with 38 additions and 28 deletions
|
@ -375,7 +375,7 @@ __check_end_of_life_versions
|
|||
#
|
||||
install_centos() {
|
||||
if [ $DISTRO_MAJOR_VERSION -ge 6 ]; then
|
||||
yum -y install qemu-kvm libvirt bridge-utils python-libguestfs supervisor cyrus-sasl-md5 || return 1
|
||||
yum -y install qemu-kvm libvirt bridge-utils python-libguestfs libguestfs-tools supervisor cyrus-sasl-md5 epel-release || return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@
|
|||
<button type="button" class="btn btn-lg btn-success " onclick="open_console('lite')">Console</button>
|
||||
<button type="button" class="btn btn-lg btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">Toggle Dropdown</span>
|
||||
<span class="sr-only">{% trans 'Toggle Dropdown' %}</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#" title="Console port: {{ console_port }}" onclick="open_console('lite')">{% trans "Console - Lite" %}</a></li>
|
||||
|
@ -537,10 +537,10 @@
|
|||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if request.user.is_superuser or userinstance.is_vnc %}
|
||||
{% if request.user.is_superuser or request.user.is_staff or userinstance.is_vnc %}
|
||||
<li role="presentation">
|
||||
<a href="#vncsettings" aria-controls="vncsettings" role="tab" data-toggle="tab">
|
||||
{% trans "VNC" %}
|
||||
{% trans "Console" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
@ -963,7 +963,7 @@
|
|||
<div class="clearfix"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if request.user.is_superuser or userinstance.is_vnc %}
|
||||
{% if request.user.is_superuser or request.user.is_staff or userinstance.is_vnc %}
|
||||
<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 %}
|
||||
|
|
|
@ -645,7 +645,7 @@ def instance(request, compute_id, vname):
|
|||
addlogmsg(request.user.username, instance.name, msg)
|
||||
return HttpResponseRedirect(request.get_full_path() + '#xmledit')
|
||||
|
||||
if request.user.is_superuser or userinstance.is_vnc:
|
||||
if request.user.is_superuser or request.user.is_staff or userinstance.is_vnc:
|
||||
if 'set_console_passwd' in request.POST:
|
||||
if request.POST.get('auto_pass', ''):
|
||||
passwd = randomPasswd()
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" name="name" placeholder="{% trans "Name" %}" required pattern="[a-zA-Z0-9\.\-_]+">
|
||||
</div>
|
||||
<label class="col-sm-1 control-label">.img</label>
|
||||
</div>
|
||||
<div class="form-group" id="image_format">
|
||||
<label class="col-sm-3 control-label">{% trans "Format" %}</label>
|
||||
|
|
|
@ -132,7 +132,6 @@
|
|||
<input type="text" class="form-control" name="name" placeholder="{% trans "Name" %}" required pattern="[a-zA-Z0-9\.\-_]+">
|
||||
<input type="hidden" name="image" value="{{ volume.name }}">
|
||||
</div>
|
||||
<label class="col-sm-1 control-label">.img</label>
|
||||
</div>
|
||||
<div class="form-group" id="image_format">
|
||||
<label class="col-sm-3 control-label">{% trans "Convert" %}</label>
|
||||
|
|
|
@ -155,8 +155,8 @@ def storage(request, compute_id, pool):
|
|||
if data['meta_prealloc'] and data['format'] == 'qcow2':
|
||||
meta_prealloc = True
|
||||
try:
|
||||
conn.create_volume(data['name'], data['size'], data['format'], meta_prealloc)
|
||||
messages.success(request, _("Image file {} is created successfully".format(data['name']+".img")))
|
||||
name = conn.create_volume(data['name'], data['size'], data['format'], meta_prealloc)
|
||||
messages.success(request, _("Image file {} is created successfully".format(name)))
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err)
|
||||
|
@ -184,10 +184,10 @@ def storage(request, compute_id, pool):
|
|||
form = CloneImage(request.POST)
|
||||
if form.is_valid():
|
||||
data = form.cleaned_data
|
||||
img_name = data['name'] + '.img'
|
||||
img_name = data['name']
|
||||
meta_prealloc = 0
|
||||
if img_name in conn.update_volumes():
|
||||
msg = _("Name of volume name already use")
|
||||
msg = _("Name of volume already in use")
|
||||
error_messages.append(msg)
|
||||
if not error_messages:
|
||||
if data['convert']:
|
||||
|
@ -197,8 +197,8 @@ def storage(request, compute_id, pool):
|
|||
else:
|
||||
format = None
|
||||
try:
|
||||
conn.clone_volume(data['image'], data['name'], format, meta_prealloc)
|
||||
messages.success(request, _("{} image cloned as {} successfully".format(data['image'], data['name'] + ".img")))
|
||||
name = conn.clone_volume(data['image'], data['name'], format, meta_prealloc)
|
||||
messages.success(request, _("{} image cloned as {} successfully".format(data['image'], name)))
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err)
|
||||
|
|
|
@ -230,22 +230,31 @@ class wvmStorage(wvmConnect):
|
|||
<group>%s</group>
|
||||
<mode>0644</mode>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>
|
||||
<compat>1.1</compat>
|
||||
<features>
|
||||
<lazy_refcounts/>
|
||||
</features>
|
||||
</target>
|
||||
</volume>""" % (name, size, alloc, vol_fmt, owner['uid'], owner['guid'])
|
||||
</permissions>""" % (name, size, alloc, vol_fmt, owner['uid'], owner['guid'])
|
||||
if vol_fmt == 'qcow2':
|
||||
xml += """
|
||||
<compat>1.1</compat>
|
||||
<features>
|
||||
<lazy_refcounts/>
|
||||
</features>"""
|
||||
xml += """
|
||||
</target>
|
||||
</volume>"""
|
||||
self._createXML(xml, metadata)
|
||||
return name
|
||||
|
||||
def clone_volume(self, name, target_file, vol_fmt=None, metadata=False, owner=owner):
|
||||
storage_type = self.get_type()
|
||||
if storage_type == 'dir':
|
||||
target_file += '.img'
|
||||
vol = self.get_volume(name)
|
||||
if not vol_fmt:
|
||||
vol_fmt = self.get_volume_type(name)
|
||||
|
||||
storage_type = self.get_type()
|
||||
if storage_type == 'dir':
|
||||
if vol_fmt in ('qcow', 'qcow2'):
|
||||
target_file += '.' + vol_fmt
|
||||
else:
|
||||
target_file += '.img'
|
||||
|
||||
xml = """
|
||||
<volume>
|
||||
<name>%s</name>
|
||||
|
@ -258,11 +267,14 @@ class wvmStorage(wvmConnect):
|
|||
<group>%s</group>
|
||||
<mode>0644</mode>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>
|
||||
</permissions>""" % (target_file, vol_fmt, owner['uid'], owner['guid'])
|
||||
if vol_fmt == 'qcow2':
|
||||
xml += """
|
||||
<compat>1.1</compat>
|
||||
<features>
|
||||
<lazy_refcounts/>
|
||||
</features>
|
||||
</target>
|
||||
</volume>""" % (target_file, vol_fmt, owner['uid'],owner['guid'])
|
||||
</features>"""
|
||||
xml += """ </target>
|
||||
</volume>"""
|
||||
self._createXMLFrom(xml, vol, metadata)
|
||||
return target_file
|
||||
|
|
Loading…
Reference in a new issue