Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/libvirt-bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions instances/templates/instance.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ <h3>
<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>
Expand Down Expand Up @@ -537,10 +537,10 @@ <h3>
</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 %}
Expand Down Expand Up @@ -963,7 +963,7 @@ <h3>
<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 %}
Expand Down
2 changes: 1 addition & 1 deletion instances/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ def migrate_instance(new_compute, instance, live=False, unsafe=False, xml_del=Fa
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()
Expand Down
1 change: 0 additions & 1 deletion storages/templates/create_stg_vol_block.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ <h4 class="modal-title">{% trans "Add New Volume" %}</h4>
<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>
Expand Down
1 change: 0 additions & 1 deletion storages/templates/storage.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ <h4 class="modal-title">{% trans "Clone image" %} <span class="text-danger">{{ v
<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>
Expand Down
12 changes: 6 additions & 6 deletions storages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def handle_uploaded_file(path, f_name):
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)
Expand Down Expand Up @@ -184,10 +184,10 @@ def handle_uploaded_file(path, f_name):
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']:
Expand All @@ -197,8 +197,8 @@ def handle_uploaded_file(path, f_name):
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)
Expand Down
40 changes: 26 additions & 14 deletions vrtManager/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,22 +230,31 @@ def create_volume(self, name, size, vol_fmt='qcow2', metadata=False, owner=owner
<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>
Expand All @@ -258,11 +267,14 @@ def clone_volume(self, name, target_file, vol_fmt=None, metadata=False, owner=ow
<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