def _load_assocs(self, firmwareassociations=None, profileassociations=None, associations=None, siteassociations=None): """Load associations to AssociationsMap and set attributes.""" self.firmwareassociations = AssociationsMap.from_list( firmwareassociations, 'firmware', **_NODESMAPKWARGS) self.profileassociations = AssociationsMap.from_list( profileassociations, 'profile', **_NODESMAPKWARGS) self.associations = associationsmapdict_from_dict(associations, **_NODESMAPKWARGS) self.siteassociations = associationsmapdict_from_dict(siteassociations, 'sites')
def _siteassociations(self, assoctype): """Init and return associations[assoctype].""" assocs = setattr_if_none(self, 'siteassociations', {}) return assocs.setdefault(assoctype, AssociationsMap(assoctype, 'sites'))
def _associations(self, assoctype): """Init and return associations[assoctype].""" assocs = setattr_if_none(self, 'associations', {}) return assocs.setdefault(assoctype, AssociationsMap(assoctype, **_NODESMAPKWARGS))
def _profileassociations(self): """Init and return profileassociations.""" return setattr_if_none(self, 'profileassociations', AssociationsMap('profile', **_NODESMAPKWARGS))
def _firmwareassociations(self): """Init and return firmwareassociations.""" return setattr_if_none(self, 'firmwareassociations', AssociationsMap('firmware', **_NODESMAPKWARGS))
def _add_siteassoc_to_dict(assocs, sites, assoctype, assocname): """Add given site association to 'assocs' dict.""" name = site_association_name(assoctype, assocname) assoc = assocs.setdefault(assoctype, AssociationsMap(assoctype, 'sites')) assoc.extendvalues(name, sites)