Controller: Improve Kimchi Specific Exception Reporting

The resource and collection class catches exception in the index method
and translates to HTTP error code with error message. While this is good
and friendly to the user, the exception handling code is somewhat
ad-hoc.

The first problem is that it does not catch and translate all the Kimchi
exception. When new code or feature is added to Kimchi, it's possible
that the new code raises an exception that is not expected before. In
this case it fails to translate the error message, so the cherrypy
framework translates it to HTTP code 500 with a vague message saying "The
server encountered an internal error". This is not friendly to the user.
In this patch it "except KimchiException" at the last of the except
sequence, and translates it into HTTP error code 500 with specific error
message, so that the user knows what's going on.

The second problem is that the index method handles GET, POST, PUT and
DELETE requests, and the error translating code for each type of request
is duplicated. This is not necessary. So this patch merges the error
handling code.

Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Skip 'screendump' for vms no video device configured

It's observed that if a vm is created by external tool and doesn't
have video device, libivrt will keep reporting the following error
message:

	"internal error: unable to execute QEMU command 'screendump':
	 There is no QemuConsole I can screendump from."

This patch skips screendump for that kinds of vms to avoid the error
message and repeately sending the black images. On UI side, it changes
to display vm's icon instead of the black image if it doesn't have
video device.

Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Grid Loading Mask - Some Elements are Missing

Some elements were lost and add them back here:
1) Show a message under the icon
2) Put the icon and text in the center both horizontally and vertically
3) Give the mask a opacity value
4) Hide the mask initially

Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
Fix multiple pep8

Make check fails with pep8 version  1.3.3.
Fix files revolve to comply with pep8.

Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com>
Fix Bug - Text Overlapped in Template Add Window

Aline found the bug which is caused by commit 23b5850.

  Fix it in this patch.

Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
Remove bridge and vlan interface unconditionally on removing vlan network

It's observed that the low layer interfaces could be down for some reason,
such as that the physical interface is in disconnected state. In this case,
we still need destroy the interfaces to avoid that they're left on the system
util reboot.

Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Changes to help

Added information for software updates, adding storage device, and replacing contents of CDROM. Plus a couple of clean up things.

Signed-off-by: Kersten Richter <kersten@us.ibm.com>
Software Update: Enable "Update All" Button when Task Fails

"Update All" Button stays disabled even when the updating task fails.
Fix it in this patch.

Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
Fix issue 348: NFS pool creation times out

Adding a 15 second timeout instead of two seconds. This makes kimchi
more robust in the face of NFS issues such as the one described in
Red Hat Bug 1023059.

Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com>
Doc: add work around to handle NFS root squash problem

Tested:
    1. make
    2. nfs pool and vm creation
Default NFS server export path is configured as root squash,
mapping root user to nobody.
This results:
1. Root user cannot step into mount point if export path
   does not allow other to read/execute.
   So create volume will fail.
2. Even with other permission open,
   owner/group of volume created by root is still nobody/nogrp,
   and qemu permission is denied on such img.
This work around instruct user to enable squash to given libvirt user
to address the above problems.

Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com>
Do not show success messages

When the user performs some operations (like updating guest CD-ROMs), a green
success message is displayed on top of the screen. This behavior is not common
in Kimchi; when an operation performs successfully, nothing is shown.

In order to make Kimchi more consistent, remove the code that displays
success messages.

This patch enforces what was applied by 57f9f9f.

Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com>
Apply Kimchi standard error message

Currently, Kimchi uses different ways of displaying error messages.

Use the standard message (kimchi.message) to display HTML errors.

This is one step towards the solution of issue #215.

Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com>
Display the error code when displaying error msgs

Error messages which are associated to error codes should display
their error codes as well, in order to make problems
identification easier.

Use a different error function to display the error code in the
error message.

Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com>
sudo: run sudo with a pseudo controlling terminal

In commit 456018a, we assign a TTY to kimchid in the SystemD service
file. This is because sudo requires a TTY by default for security
reason.

Usually Linux daemon detaches from controlling terminal so that it makes
use of the SIGHUP signal to reload its settings. If the daemon has a
console interface for the admin to interact (like a QEMU monitor), it
can have a TTY to run the console interface. At lease for now, Kimchi is
a traditional plain daemon that needs no TTY.

This patch creates a temporary PTY and assigns the slave to the sudo
process as the controlling terminal each time it runs sudo. In this way
we do not have to assign a TTY to kimchid. Maybe it's more portable than
specifying TTY in a SystemD service file.

Before running sudo, it creates a subprocess to make sure the child is
not the session leader. Then the child creates a new session and PYT,
and sets the slave as the controlling termial. At last the child calls
sudo. The result from the child is delivered to the parent via a shared
memory object.

Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Fix iso streaming functions and feature tests

The qemu dns test function was using IP instead of full hostname. This
makes the function always return True. Also, changed the streaming
protocols checking function supported by libvirt.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com>
VLAN: Do not allow bridge to be the trunk device

In Linux networking, a usual VLAN + bridge network setup is as the
following.

eth0 |-> eth0.10 -> br10 -> vnet101, vnet102, ...
     |-> eth0.20 -> br20 -> vnet201, vnet202, ...

While the eth0 trunk and VLAN interfaces provide the isolation service,
the bridges provide the switching inside the respective VLAN.

It's not very useful to have a bridge device as the trunk because the
VLAN interfaces on a trunk should be isolated.

This patch contains changes to the back-end and front-end.

The back-end checks if the front-end submits an invalid setup to use a
bridge as the VLAN trunk device and raises exception.

Before this patch, if the user creates a bridged network over an
existing bridge with VLAN tag set. The back-end just ignores the VLAN
and creates an ordinary bridged network. After this patch, the back-end
raises an exception with an explanation in this case.

The front-end also checks the currently selected interface type. If the
selected interface is a bridge, it disables the vlan check box,
otherwise it enables the vlan check box.

V2
Add front-end code to disable vlan check box if the selected interface
is a bridge.

V3
Clear the vlan check box and vlan id input box value when disabling them.

Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
bug fix: Expose repository management tool name

More than expose if there is a repository management tool recognized by
Kimchi, we also need to expose which tool is it.
The repository information depends on its type and UI needs to know it
to properly build the view.

Signed-off-by: Aline Manera <alinefm@br.ibm.com>
bug fix: Reorganize repository information

There are some specific repository data according to its type.
'deb' repositories have dist and componenets and that information does
not make sense for a 'yum' repository.
The same way a 'yum' repository has name, mirrorlist, gpgcheck,
gpgkey that only make sense for this type of repo.

Signed-off-by: Aline Manera <alinefm@br.ibm.com>
mockmodel: Move specific repository data under 'config'

There are some specific repository data according to its type.
'deb' repositories have dist and componenets and that information does
not make sense for a 'yum' repository.
The same way a 'yum' repository has name, id, mirrorlist, gpgcheck,
gpgkey that only make sense for this type of repo.

Also let the exception comming from the backend be raised. As it
contains more details about the problem. Otherwise, we will always show
generic error message "Unable to update repository"

Signed-off-by: Aline Manera <alinefm@br.ibm.com>
Update messages used in the repositories management feature

There is no need to have generic error messages.
We should provide the most detailed message we can.
Also update the .po files to reflect those changes

Signed-off-by: Aline Manera <alinefm@br.ibm.com>