← Back to team overview

openstack team mailing list archive

Re: [NOVA] Snapshotting may require significant disk space (in /tmp). How to properly solve disk space issues?

 

On Fri, Mar 16, 2012, Vishvananda Ishaya <vishvananda@xxxxxxxxx> wrote:
> Now that we have the temdir context manager I was thinking something like:
> 
> diff --git a/nova/utils.py b/nova/utils.py
> index e375f11..a3ac896 100644
> --- a/nova/utils.py
> +++ b/nova/utils.py
> @@ -61,9 +61,11 @@ ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
>  PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
>  FLAGS = flags.FLAGS
>  
> -FLAGS.register_opt(
> +FLAGS.register_opts([
>      cfg.BoolOpt('disable_process_locking', default=False,
> -                help='Whether to disable inter-process locks'))
> +                help='Whether to disable inter-process locks'),
> +    cfg.StrOpt('tempdir_location', default=None,
> +                help='Path where tempdirs will be created')])
>  
>  
>  def import_class(import_str):
> @@ -1611,6 +1613,7 @@ def temporary_chown(path, owner_uid=None):
>  
>  @contextlib.contextmanager
>  def tempdir(**kwargs):
> +    kwargs['dir'] = kwargs.get('dir', FLAGS.tempdir_location)
>      tmpdir = tempfile.mkdtemp(**kwargs)
>      try:
>          yield tmpdir
> 
> And get rid of the other flags that are used.

This may not be necessary. tempfile will use the TMPDIR, TEMP and TMP
environment variables to determine which directory to use as well.

JE



References