[PATCH 1/3] Add a guard for testing if we can modify live system
Chris Lumens
clumens at redhat.com
Tue Sep 25 14:23:25 UTC 2012
> @@ -167,6 +171,29 @@ class BootArgs(OrderedDict):
> result = False # XXX: should noarg=off -> True?
> return result
>
> +def can_touch_live_system(msg):
> + """
> + Guard that should be used before doing actions that modify live system.
> +
> + @param msg: message to be logged in case that live system cannot be touched
> + @rtype: bool
> +
> + """
> +
> + if flags.livecdInstall:
> + log.info("Not doing '%s' in live installation" % msg)
> + return False
> +
> + if flags.imageInstall:
> + log.info("Not doing '%s' in image installation" % msg)
> + return False
> +
> + if flags.testing:
> + log.info("Not doing '%s', because we are just testing" % msg)
> + return False
> +
> + return True
> +
> global flags
> flags = Flags()
I like the idea, but I don't like the name. I think something like
"can_touch_target_system" or "can_touch_dest_system" would be better.
Using "live" in the name of a function that protects against you doing
something on live installs is weird.
- Chris
More information about the anaconda-patches
mailing list