[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.



On Fri, 2011-01-07 at 15:28 -0500, Chris Lumens wrote:
> > 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.

It would be good. I'll combine immutable and protected at some point,
maybe at fudcon.

> 
> > @@ -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?

We could probably do something like add methods for _preSetup,
_preTeardown, _postCreate, &c.

Dave



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