Show category as "default" if none is given

Fixes issue 870.

Signed-off-by: Aaron Karper <akarper@google.com>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>
Fix LXC hypervisor tests

This patch fixes the LXC hypervisor tests, which were failing on
Squeeze due to multiple reasons.

* Factor out the directory creation, and mock it when invoking tests
* Replace AssertNone with AssertEqual(..., None)

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Fix lens version number in documentation

lens version 3.0 does not support Control.Lens.At module. The version
3.10 is used in the example of 'cabal install' in this documentation.

Signed-off-by: Jun Futagawa <jfut@integ.jp>
Reviewed-by: Helga Velroyen <helgav@google.com>
LXC: Make the drop capabilities list as a hvparam

This patch adds the new hvparam "lxc_drop_capabilities" to the LXC
hypervisor.
This parameter specifies the list of capabilities should be dropped for
the LXC container.
The default value of this parameter was hardcoded, but making this
parameter as a hvparam is worth for users customizability.
LXC: Implement RebootInstance of LXCHypervisor

This patch implements RebootInstance function of the LXCHypervisor.
Reboot of the LXC container can be done by using lxc-stop command with
--reboot swtich. Internally this is just sending SIGINT for the init
process of the container.
Since the init process is working on the host machine natively, it
requires CAP_SYS_BOOT capability to call the reboot(2) system call.
This function detects if the CAP_SYS_BOOT is dropped from the container
and raise an error to claim that requirement.
It is up to users if they use the soft reboot of the LXC container with
allowing CAP_SYS_BOOT or drop it and do not use the soft reboot.
LXC: Split _GetCgroupInstanceValue function

Add the _GetCgroupInstanceParamPath function which returns the path of
the specified cgroup parameter file and change the
_GetCgroupInstanceValue to use this function.
By this patch, "subsystem" argument for this function was reduced
because it can be determined by the param_name argument.
LXC: Add _SetCgroupInstanceValue function

Add the _SetCgroupInstanceValue function which can be used to set the
value to the instance cgroup parameter.
LXC: Implement BalloonInstanceMemory

This patch implements BalloonInstanceMemory function of the
LXCHypervisor.
Memory ballooning for the LXC container can be done by using
memory.limit_in_bytes and memory.memsw.limit_in_bytes cgroup parameter.
The Linux kernel does not kill the process inside a cgroup which is
tried to shrink its memory accounted, so the update for
memory.memsw.limit_in_bytes can be fail even if the update for
memory.limit_in_bytes was succeed, so this function must care about
all cgroup memory limit parameters consistency for update.
Fix CheckPrereq function of the LUInstanceSetParams wrt cpu_mask

Once I try to modify a hvparam of the LXC hypervisor, I got this error:

    ValueError: max() arg is an empty sequence

This is because the current default value of cpu_mask hypervisor
parameter for the LXC hypervisor is the zero-length string, so the
cpu_list which returned by the ParseMultiCpuMask is the blank list.
The zero-length string is a valid for the cpu_mask hvparam, so we need
to skip this check if the cpu_list is the blank list.
LXC: Make devices ACL list as a hvparam

This patch adds new hvparam "lxc_devices" to the LXC hypervisor.
This parameter specifies the access control list for direct device
access from inside the LXC container.
The default value of this parameter was hardcoded, but making this
parameter as a hvparam is worth for users customizability.
LXC: Include cputime in return value of GetInstanceInfo

Read the cputime(usage) of the LXC instance from the cpuacct.usage
cgroup parameter and return it as the "time" field of GetInstanceInfo.
This commit also discards the TODO comment wrt something which is not
accurate today.
LXC: Remove comment

This commit discards comments in LXCHypervisor which are already
solved, or not accurate today.
LXC: Remove unused function

Remove the unused _GetMountSubdirs function from LXCHypervisor class.
LXC: Add lxc_extra_config hvparam

Add the new hvparam lxc_extra_config which is used to specify additional
LXC container config parameters that is not supported by the Ganeti LXC
hypervisor natively.
LXC: Raise an error if failed to read cgroup memory limit

Since we have supported the memory limit for the LXC container, we
should always have the memory subsystem mounted somewere, so getting
memory limit from cgroup fs is not an acceptable situation.
Fix invalid use of RpcResult.Raise

Fix statements using result.Raise in invalid form.
Change comma to '%' operator to provide formatted string as this line
originally expected.