LGTM, thanks

On Wed, Jul 30, 2014 at 6:36 PM, Yuto KAWAMURA(kawamuray) <
[email protected]> wrote:

> The current implementation tries to query all entries in lxc root
> directory, so there are several useless queries such as 'instance1.conf'
> as a instance name.
> Filter only .conf files for each instance to list actually available
> instances.
>
> Signed-off-by: Yuto KAWAMURA(kawamuray) <[email protected]>
> ---
>  lib/hypervisor/hv_lxc.py | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/lib/hypervisor/hv_lxc.py b/lib/hypervisor/hv_lxc.py
> index 483394a..21f5b44 100644
> --- a/lib/hypervisor/hv_lxc.py
> +++ b/lib/hypervisor/hv_lxc.py
> @@ -73,6 +73,7 @@ class LXCHypervisor(hv_base.BaseHypervisor):
>      "sys_time",        # Set  system  clock, set real-time (hardware)
> clock
>      ]
>    _DIR_MODE = 0755
> +  _UNIQ_SUFFIX = ".conf"
>
>    PARAMETERS = {
>      constants.HV_CPU_MASK: hv_base.OPT_CPU_MASK_CHECK,
> @@ -200,9 +201,14 @@ class LXCHypervisor(hv_base.BaseHypervisor):
>
>      """
>      data = []
> -    for name in os.listdir(self._ROOT_DIR):
> +    for filename in os.listdir(self._ROOT_DIR):
> +      if not filename.endswith(self._UNIQ_SUFFIX):
> +        # listing all files in root directory will include instance root
> +        # directories, console files, etc, so use .conf as a filter of
> instance
> +        # listings.
> +        continue
>        try:
> -        info = self.GetInstanceInfo(name)
> +        info = self.GetInstanceInfo(filename[0:-len(self._UNIQ_SUFFIX)])
>        except errors.HypervisorError:
>          continue
>        if info:
> --
> 1.8.5.5
>
>


Hrvoje Ribicic
Ganeti Engineering
Google Germany GmbH
Dienerstr. 12, 80331, München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores
Steuernummer: 48/725/00206
Umsatzsteueridentifikationsnummer: DE813741370

Reply via email to