[CRIU] [PATCH 1/3] p.haul: minor style changes in p_haul_vz.py
Pavel Emelyanov
xemul at parallels.com
Mon Nov 30 01:16:44 PST 2015
On 11/26/2015 03:52 PM, Nikita Spiridonov wrote:
> Rename parse_vz_config and expand_veid_var functions of p_haul_vz.py
> (add leading underscore) to make it formally private module
> function.
Single underbar doesn't make a method private.
[pavel at xemulnb ~]$ cat x.py
#!/bin/env python
class foo:
def one():
pass
def _two():
pass
def __three():
pass
f = foo()
print dir(f)
[pavel at xemulnb ~]$ ./x.py
['__doc__', '__module__', '_foo__three', '_two', 'one']
See? Both one() and _two() preserved their names, but in order to
call __tree() you have to use "some other name" for it.
> Signed-off-by: Nikita Spiridonov <nspiridonov at odin.com>
> ---
> phaul/p_haul_vz.py | 16 ++++++++--------
> 1 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/phaul/p_haul_vz.py b/phaul/p_haul_vz.py
> index 70a4620..b9ca5b7 100644
> --- a/phaul/p_haul_vz.py
> +++ b/phaul/p_haul_vz.py
> @@ -36,11 +36,11 @@ class p_haul_type:
>
> # Read container config
> with open(self.__ct_config_path(path)) as ifd:
> - config = parse_vz_config(ifd.read())
> + config = _parse_vz_config(ifd.read())
>
> # Read global config
> with open(vz_global_conf) as ifd:
> - global_config = parse_vz_config(ifd.read())
> + global_config = _parse_vz_config(ifd.read())
>
> # Extract veth pairs, later we will equip restore request with this
> # data and will use it while (un)locking the network
> @@ -60,16 +60,16 @@ class p_haul_type:
>
> # Extract private path from config
> if "VE_PRIVATE" in config:
> - self._ct_priv = expand_veid_var(config["VE_PRIVATE"], self._ctid)
> + self._ct_priv = _expand_veid_var(config["VE_PRIVATE"], self._ctid)
> else:
> - self._ct_priv = expand_veid_var(global_config["VE_PRIVATE"],
> + self._ct_priv = _expand_veid_var(global_config["VE_PRIVATE"],
> self._ctid)
>
> # Extract root path from config
> if "VE_ROOT" in config:
> - self._ct_root = expand_veid_var(config["VE_ROOT"], self._ctid)
> + self._ct_root = _expand_veid_var(config["VE_ROOT"], self._ctid)
> else:
> - self._ct_root = expand_veid_var(global_config["VE_ROOT"],
> + self._ct_root = _expand_veid_var(global_config["VE_ROOT"],
> self._ctid)
>
> def __load_ct_config_dst(self, path):
> @@ -240,7 +240,7 @@ class p_haul_type:
> return True
>
>
> -def parse_vz_config(body):
> +def _parse_vz_config(body):
> """Parse shell-like virtuozzo config file"""
>
> config_values = dict()
> @@ -250,6 +250,6 @@ def parse_vz_config(body):
> return config_values
>
>
> -def expand_veid_var(value, ctid):
> +def _expand_veid_var(value, ctid):
> """Replace shell-like VEID variable with actual container id"""
> return value.replace("$VEID", ctid).replace("${VEID}", ctid)
>
More information about the CRIU
mailing list