Lines Matching refs:self

110     def dirty(self):
111 return self._dirty
116 def dirty(self, value):
119 if value != self._dirty:
120 self._debug('dirty => %s', value)
121 self._dirty = value
125 def config_dir(self):
130 def __init__(self, **kwargs):
131 self._dirty = False
132 self._boot_config = kwargs.get('bootconfig')
133 self._bl_props = {}
134 self.firmware = None
135 self.version = kwargs.get('version')
136 self.data_source_boot_instance = None
137 self.artifacts = kwargs.get('artifacts', [])
139 selected_fwnames = self.__class__._validate_platform_and_firmware(
140 self._boot_config, self, kwargs.get('fwtype'))
141 self.setprop(BootLoader.PROP_BOOT_TARGS, selected_fwnames)
146 if (not self._boot_config is None and
147 not self._boot_config.get_root() is None):
148 bc_sysroot = self._boot_config.get_root()
150 self.rootpath = kwargs.get('rootpath', bc_sysroot)
194 def _get_boot_loader_data_root(self):
196 if (not self.data_source_boot_instance is None and
197 not self.data_source_boot_instance.rootpath is None):
198 return self.data_source_boot_instance.rootpath
199 return self.rootpath # Initted in __init__; incl. the fallback to '/'
201 def _write_config(self, basepath):
206 def _write_loader(self, devname, data_root, force, verbose_file, platdict):
211 def load_config(self, do_add=True):
217 def new_config(self):
222 boot_targs = self._bl_props[BootLoader.PROP_BOOT_TARGS]
223 self._bl_props = {BootLoader.PROP_BOOT_TARGS: boot_targs}
225 def migrate_config(self):
232 def _prop_validate(self, key, value=None, validate_value=False):
236 props = getattr(self, 'SUPPORTED_PROPS', [])
243 validators = {BootLoader.PROP_BOOT_TARGS: self._validate_boot_targs,
245 self._validate_serial_params,
246 BootLoader.PROP_THEME: self._validate_theme_name}
255 def _validate_theme_name(self, value=None):
264 def _validate_serial_params(self, value=None):
339 def _validate_boot_targs(self, value=None):
345 platname = self._boot_config.platform_requested
348 fwlist = self.SUPPORTED_PLATFORMS[platname]
352 self.__class__.__name__)
354 def setprop(self, key, value):
358 newvalue = self._prop_validate(key, value, True)
360 self._debug('_prop_validate returned a different value (%s vs %s)',
365 if self._bl_props.get(key) != value:
366 self._bl_props[key] = value
367 self.dirty = True
369 def getprop(self, key):
372 self._prop_validate(key, validate_value=False)
373 return self._bl_props.get(key)
375 def delprop(self, key):
378 self._prop_validate(key, validate_value=False)
385 del self._bl_props[key]
386 self.dirty = True
391 def install(self, location, force=False, verbose_file=None, platdict=None):
437 data_root = self._get_boot_loader_data_root()
450 tuples = self._write_config(location)
454 self._write_loader(location, data_root, force, verbose_file,
457 self._write_config(None)
464 self._debug('location is empty: Loader will NOT be written')
471 self._debug('Error stat()ing %s: %s', (devname, err))
475 self._write_loader(devname, data_root, force, verbose_file,
481 self._write_config(None)
493 def __init__(self, primary_loader, secondary_loader):
507 self.__data_source_boot_instance = \
509 self._boot_config = primary_loader._boot_config
510 self.__primary = primary_loader
511 self.__secondary = secondary_loader
512 self.__data_source_boot_instance = None
513 self.__load_source = None
514 self.__prim_boot_instances = []
515 self.__sec_boot_instances = []
520 # Interpose on self._boot_config's delete_boot_instance method so we
523 instmethtype = type(self._boot_config.delete_boot_instance)
524 self.__saved_dbi_method = self._boot_config.delete_boot_instance
525 newmeth = instmethtype(getattr(self, 'interposed_delete_boot_instance'),
526 self._boot_config, self._boot_config.__class__)
527 self._boot_config.delete_boot_instance = newmeth
530 def __del__(self):
533 self._boot_config.delete_boot_instance = self.__saved_dbi_method
535 def interposed_delete_boot_instance(self, bcself, filter_func, all=True):
538 to this method are (a) self, the ProxyBootConfig instance (which is
554 instances_deleted = self.__saved_dbi_method(filter_func, all)
555 self._debug('Deleted %d instances from the primary boot loader',
557 if self.__sec_boot_instances:
559 bcself.boot_instances = self.__sec_boot_instances
560 sec_deleted = self.__saved_dbi_method(filter_func, all)
561 self._debug('Deleted %d instances from the secondary boot loader',
563 self.__sec_boot_instances = bcself.boot_instances
568 def load_config(self, do_add=True):
581 self.__reevaluate_artifacts()
583 load_rv = self.__primary.load_config(False)
588 self.__prim_boot_instances = list(load_rv)
589 self.__load_source = self.__primary
591 self.__sec_boot_instances = []
594 self.__secondary.artifacts):
596 self.__secondary.new_config()
599 self.__primary.artifacts and
601 self.__secondary.artifacts):
604 for inst in self.__prim_boot_instances:
607 self.__sec_boot_instances.append(sec_inst)
610 props_to_copy = set(self.__primary.SUPPORTED_PROPS).intersection(
611 set(self.__secondary.SUPPORTED_PROPS))
614 propval = self.__primary.getprop(propname)
615 self.__secondary.setprop(propname, propval)
617 self._debug('Exception while copying properties: %s',
622 self.__secondary.dirty = True
624 self.__secondary.artifacts):
629 self.__sec_boot_instances = self.__secondary.load_config(False)
630 if not self.__sec_boot_instances:
631 self.__sec_boot_instances = []
640 for prim_inst in self.__prim_boot_instances:
641 for sec_inst in self.__sec_boot_instances:
648 self._boot_config.add_boot_instance(load_rv)
651 def new_config(self):
655 self.__primary.new_config()
656 self.__secondary.new_config()
658 def setprop(self, key, value):
661 self.__primary.setprop(key, value)
663 def getprop(self, key):
665 return self.__primary.getprop(key)
667 def delprop(self, key):
669 self.__primary.delprop(key)
671 def install(self, location, force=False, verbose_file=None, platdict=None):
681 self.__reevaluate_artifacts()
688 if (self.__secondary.WEIGHT < self.__primary.WEIGHT and
690 self.__secondary.artifacts):
696 self.__synch_primary_to_secondary()
704 if self.__load_source:
705 self._debug('Load source is %s', self.__load_source.name)
707 if self.__load_source is self.__secondary:
711 self._debug('Installing secondary boot loader %s files only',
712 self.__secondary.name)
720 sec_inst_rv = self.__secondary.install(secinst, False, verbose_file,
723 bc_boot_instances = self._boot_config.boot_instances
724 self._boot_config.boot_instances = self.__sec_boot_instances
726 self._debug('Installing primary boot loader %s',
727 self.__primary.name)
728 prim_inst_rv = self.__primary.install(location, force, verbose_file,
731 self._boot_config.boot_instances = bc_boot_instances
736 self._debug('Installing secondary boot loader %s files only',
737 self.__secondary.name)
754 bc_boot_instances = self._boot_config.boot_instances
755 self._boot_config.boot_instances = self.__sec_boot_instances
757 sec_inst_rv = self.__secondary.install(secinst, False,
760 self._boot_config.boot_instances = bc_boot_instances
764 self._debug('Installing primary boot loader %s',
765 self.__primary.name)
766 prim_inst_rv = self.__primary.install(location, force, verbose_file,
777 def __synch_primary_to_secondary(self):
789 bc_boot_instances = self._boot_config.boot_instances
790 self._boot_config.boot_instances = self.__sec_boot_instances
800 if inst not in self.__prim_boot_instances: # Addition!
801 self._debug('Adding new boot instance to secondary loader'
813 deflist = [x for x in self.__sec_boot_instances
818 self.__sec_boot_instances.append(sec_inst)
822 self.__prim_boot_instances.append(inst)
824 self._debug('Found a linked boot instance')
826 self._debug('cmp = %s for %s vs %s', (cmpval, inst,
830 self._debug('Update needed for boot instance %s\n'
840 deflist = [x for x in self.__sec_boot_instances
848 self._boot_config.boot_instances = bc_boot_instances
853 def dirty(self):
854 return self.__primary.dirty
859 def dirty(self, value):
860 self.__primary.dirty = value
865 def SUPPORTED_PROPS(self):
868 return self.__primary.SUPPORTED_PROPS
872 def artifacts(self):
875 return self.__primary.artifacts
878 def pkg_names(self):
881 return getattr(self.__primary, 'pkg_names', [])
884 def config_dir(self):
887 if hasattr(self.__primary, 'config_dir'):
888 return self.__primary.config_dir
892 def name(self):
895 return self.__primary.name
899 def firmware(self):
902 return self.__primary.firmware
905 def rootpath(self):
908 return self.__primary.rootpath
912 def rootpath(self, val):
916 self.__primary.rootpath = val
917 self.__secondary.rootpath = val
919 self.__reevaluate_artifacts()
923 def version(self):
926 return self.__primary.version
930 def version(self, version_str):
933 self.__primary.version = version_str
937 def data_source_boot_instance(self):
941 return self.__data_source_boot_instance
945 def data_source_boot_instance(self, new_dsbi):
950 self.__primary.data_source_boot_instance = new_dsbi
951 self.__secondary.data_source_boot_instance = new_dsbi
952 self.__data_source_boot_instance = new_dsbi
953 self.__reevaluate_artifacts()
990 def __reevaluate_artifacts(self):
995 if self.__primary.data_source_boot_instance is not \
996 self.__data_source_boot_instance:
997 new_dsbi = self.__data_source_boot_instance
998 self.__primary.data_source_boot_instance = new_dsbi
999 self.__secondary.data_source_boot_instance = new_dsbi
1000 prim_artifacts = self.__primary.probe_artifacts(self._boot_config)
1001 self._debug('Primary bootloader artifacts: %s', str(prim_artifacts))
1002 sec_artifacts = self.__secondary.probe_artifacts(self._boot_config)
1003 self._debug('Secondary bootloader artifacts: %s', str(sec_artifacts))
1004 self.__primary.artifacts = prim_artifacts
1005 self.__secondary.artifacts = sec_artifacts
1009 which = self.__bootloader_with_images(self.__primary, self.__secondary)
1010 if which is self.__secondary:
1011 self._debug('Swapping boot loaders [%s <=> %s]',
1012 (repr(self.__primary), repr(self.__secondary)))
1013 self.__primary, self.__secondary = self.__secondary, self.__primary