add timeout for sessions

The default timeout of sessions is 60 minutes.

Set the timeout of sessions 10 minutes explicitly.

Kimchi should have 10 minutes of time out value for the browser login
session.
If session got inactive for 10 minutes then it should expire
automatically.
And should ask user for relogin. This is required for the security
reason.

But this timeout will not take effect on some tabs, such as guest tab.
The root cause is because the front end refreshes the vm list every 5
seconds
by sending the "GET /vms" REST API call to the server.

The follow patch will solve this problem.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
auth enhancement: expire the session when the request access periodically

Now UI will access the vms and host periodically.
That will never make the session expire.
This patch fix this problem.
Now the UI can set "Kimchi-Robot" header when it wants to access the vms
and host periodically.
If the all requests with "Kimchi-Robot" header access for a long time, kimchi
will expire the session.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
UI: set kimchi robot header for some request.

Then session will expire when these request access periodically.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com>
session expire: update test case

update test_config.py.in

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Refreshing an inactive pool causes exception

When an update request to extend a inactive storagepool is
finished sucessfully, an exception will be raised complaining
the pool is inactive. The exception response to the clinet is
quite misleading for a successful request.
issue #312: Check volume group exists while creating a logical pool

When creating a logical storage pool, a volume group is created with the same
name.
And when deleting the storage pool the volume group keeps on the system. Which
is the correct behavior as the storage pool is only a concept and deleting it
should not affect the file system.
To avoid problems while creating a pool with an existent volume group name,
verify if a volume group exists with the given pool name and if so, warn the
user about it.

Also convert an error message parameter to string instead of virStoragePool
instance and update the po files as new messages were added.

Signed-off-by: Aline Manera <alinefm@br.ibm.com>
Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com>
issue #330: Make sure exception argument is a string to convert it to unicode

The unicode() operation is only available for strings.
So make sure the exception argument is a string before converting it to
unicode.

Signed-off-by: Aline Manera <alinefm@br.ibm.com>
Support ppc64 isos in Templates: Add arch and urls to distro jsons

If Kimchi is running in a PPC machine, user can create a template
that uses a remote x86_64 iso.
Adding an os_arch field to the distro so we can filter distros
on systems with other architectures. This prevents a user from
creating unusable templates.
This patch also changes the name field of Fedora distros.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com>
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com>
Support ppc64 isos in Templates: Filter remote isos and change UI

This patch filters remote isos that should be showed to user by the
system architecture. The UI now shows the architecture of the remote
iso and sort the names of the distros.
If host architecture is not found, all remote ISOs will be showed.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com>
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com>
Support ppc64 isos in Templates: Fix test cases

This patch includes distro test in PPC environment and fixes problems due
to new Fedora distro names, encoding the name.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com>
storage volume: fix xml parsing of logical volume format type

Not all types of libvirt storage volume provide format information.
Particularly, the volume in logical pool doesn't have format information
in the dumped XML description. StorageVolumeModel.lookup assumes there
is a format tag, but for logical pool volumes it does not exist. So an
exception is raised when it lookup a logical volume.

To trigger this problem, firstly create a guest using a logical pool. Then
click the logical pool from the "storage" tab, and it would fail to list
the volumes.

This patch catches the exception when parsing the format tag, and
returns an 'raw' for the format attribute if there is no available format
information in the XML.

v2
Return 'raw' instead of return empty string, because the only supported
volume format of a logical pool is 'raw'.

Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Issue #222: add python-xml to suse require list

check on suse
xml.etree module is from python-xml on suse.
need to add python-xml to require list

This is different from fedora distro.
xml.etree module is from python standlib python-libs on fedora

issue:
https://github.com/kimchi-project/kimchi/issues/222

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
bug fix: Set default flags for virDomain.state() function

Some libvirt versions do not set the default value for flags, so we need to
explicity set it.

libvirt.virDomain.state = state(self, flags) unbound libvirt.virDomain method

Otherwise, the following error will be raised

[06/Mar/2014:23:40:05] HTTP Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 656, in respond
    response.body = self.handler()
  File "/usr/lib/python2.7/dist-packages/cherrypy/lib/encoding.py", line 188, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/cherrypy/_cpdispatch.py", line 34, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/home/alinefm/kimchi/src/kimchi/control/base.py", line 71, in wrapper
    ident = fn(*model_args)
  File "/home/alinefm/kimchi/src/kimchi/model/networks.py", line 214, in deactivate
    if self._get_vms_attach_to_a_network(name, "running"):
  File "/home/alinefm/kimchi/src/kimchi/model/networks.py", line 199, in _get_vms_attach_to_a_network
    state == dom.state()[0]):
  File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py", line 62, in wrapper
    ret = f(*args, **kwargs)
TypeError: state() takes exactly 2 arguments (1 given)

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

This patch changes the order of two rollback calls, avoiding the chance of
tests left a test file or a test vm in the system.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com>
Fix issue #339: Enable backend to handle not persistent pools

This patch changes the error message when storage pool is not found and
adds the isPersistent checkings, in order to return correctly from
deactivate function.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com>
Fix issue #339: Changes UI to handle deactivation of non-persistent pools

This patch implements a checking in the UI in order to warn the user
that if pool is not persistent it will be removed when deactivated.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com>
Fix issue #339: Change mock and add test to check persistent variable

This patch fixes the problems in the tests due to the inclusion of new
persistent variable in pools information. It also adds a minor test.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com>
Increase memory size for vm template on ppc platform

The minimum memory size required by graphics installer is 1280. So
to allow user install vm in graphics, this patch increases it to
1280.

Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
issue #301: Only list remote ISOs with valid URL

The remote ISO path may become invalid after some time and it prevents
user to create a template from it.
To avoid those kind of errors, only list the distros with valid URL.

Signed-off-by: Aline Manera <alinefm@br.ibm.com>
issue #301: Add a loading message while listing default remote ISOs

The remote ISO path may become invalid and we check it on backend to
only return valid data to UI.
But checking the remote ISO path for each distro can take some time so
UI needs to properly display it to user.
Do that by adding a loading message until get the backend response.

Also update the .po files as new messages were added.

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