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