[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [PATCH 5/7] Add flag indicating whether a device can be activated/deactivated.



> diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
> index 5462eee..e723dcf 100644
> --- a/pyanaconda/storage/devices.py
> +++ b/pyanaconda/storage/devices.py
> @@ -478,6 +478,7 @@ class StorageDevice(Device):
>  
>          self.protected = False
>          self.immutable = None
> +        self.controllable = True
>  
>          self.format = format
>          self.originalFormat = self.format

Oof, now a third setting that sounds exactly the same.  I'd love to see
one of these be on the way out in a future patch set.

> @@ -627,10 +628,14 @@ class StorageDevice(Device):
>  
>      def setup(self, intf=None, orig=False):
>          """ Open, or set up, a device. """
> -        log_method_call(self, self.name, orig=orig, status=self.status)
> +        log_method_call(self, self.name, orig=orig, status=self.status,
> +                        controllable=self.controllable)
>          if not self.exists:
>              raise DeviceError("device has not been created", self.name)
>  
> +        if not self.controllable:
> +            return
> +
>          self.setupParents(orig=orig)
>          for parent in self.parents:
>              if orig:
> @@ -640,10 +645,14 @@ class StorageDevice(Device):
>  
>      def teardown(self, recursive=None):
>          """ Close, or tear down, a device. """
> -        log_method_call(self, self.name, status=self.status)
> +        log_method_call(self, self.name, status=self.status,
> +                        controllable=self.controllable)
>          if not self.exists and not recursive:
>              raise DeviceError("device has not been created", self.name)
>  
> +        if not self.controllable:
> +            return
> +
>          if self.status:
>              if self.originalFormat.exists:
>                  self.originalFormat.teardown()

I noticed a *lot* of code that looks just like this in subclasses.  Can
we not consolidate into superclasses a little bit?

- Chris


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]