def execute(self, *keys, **options): validate_domain_level(self.api) masters = self.api.Command.server_find('', sizelimit=0, no_members=False)['result'] masters = map_masters_to_suffixes(masters).get(keys[0], []) segments = self.api.Command.topologysegment_find(keys[0], sizelimit=0)['result'] graph = create_topology_graph(masters, segments) master_cns = [m['cn'][0] for m in masters] master_cns.sort() # check if each master can contact others connect_errors = get_topology_connection_errors(graph) # check if suggested maximum number of agreements per replica max_agmts_errors = [] for m in master_cns: # chosen direction doesn't matter much given that 'both' is the # only allowed direction suppliers = graph.get_tails(m) if len(suppliers) > self.api.env.recommended_max_agmts: max_agmts_errors.append((m, suppliers)) return dict(result={ 'in_order': not connect_errors and not max_agmts_errors, 'connect_errors': connect_errors, 'max_agmts_errors': max_agmts_errors, 'max_agmts': self.api.env.recommended_max_agmts }, )
def execute(self, *keys, **options): validate_domain_level(self.api) masters = self.api.Command.server_find( '', sizelimit=0, no_members=False)['result'] masters = map_masters_to_suffixes(masters).get(keys[0], []) segments = self.api.Command.topologysegment_find( keys[0], sizelimit=0)['result'] graph = create_topology_graph(masters, segments) master_cns = [m['cn'][0] for m in masters] master_cns.sort() # check if each master can contact others connect_errors = get_topology_connection_errors(graph) # check if suggested maximum number of agreements per replica max_agmts_errors = [] for m in master_cns: # chosen direction doesn't matter much given that 'both' is the # only allowed direction suppliers = graph.get_tails(m) if len(suppliers) > self.api.env.recommended_max_agmts: max_agmts_errors.append((m, suppliers)) return dict( result={ 'in_order': not connect_errors and not max_agmts_errors, 'connect_errors': connect_errors, 'max_agmts_errors': max_agmts_errors, 'max_agmts': self.api.env.recommended_max_agmts }, )
def validate_nodes(self, ldap, dn, entry_attrs, suffix): leftnode = entry_attrs.get('iparepltoposegmentleftnode') rightnode = entry_attrs.get('iparepltoposegmentrightnode') if not leftnode and not rightnode: return # nothing to check # check if nodes are IPA servers masters = self.api.Command.server_find('', sizelimit=0, no_members=False)['result'] m_hostnames = [master['cn'][0].lower() for master in masters] if leftnode and leftnode not in m_hostnames: raise errors.ValidationError( name='leftnode', error=_('left node is not a topology node: %(leftnode)s') % dict(leftnode=leftnode)) if rightnode and rightnode not in m_hostnames: raise errors.ValidationError( name='rightnode', error=_('right node is not a topology node: %(rightnode)s') % dict(rightnode=rightnode)) # prevent creation of reflexive relation key = 'leftnode' if not leftnode or not rightnode: # get missing end _entry_attrs = ldap.get_entry(dn, ['*']) if not leftnode: key = 'rightnode' leftnode = _entry_attrs['iparepltoposegmentleftnode'][0] else: rightnode = _entry_attrs['iparepltoposegmentrightnode'][0] if leftnode == rightnode: raise errors.ValidationError( name=key, error=_('left node and right node must not be the same')) # don't allow segment between nodes where both don't have the suffix masters_to_suffix = map_masters_to_suffixes(masters) suffix_masters = masters_to_suffix.get(suffix, []) suffix_m_hostnames = [m['cn'][0].lower() for m in suffix_masters] if leftnode not in suffix_m_hostnames: raise errors.ValidationError( name='leftnode', error=_("left node ({host}) does not support " "suffix '{suff}'").format(host=leftnode, suff=suffix)) if rightnode not in suffix_m_hostnames: raise errors.ValidationError( name='rightnode', error=_("right node ({host}) does not support " "suffix '{suff}'").format(host=rightnode, suff=suffix))
def validate_nodes(self, ldap, dn, entry_attrs, suffix): leftnode = entry_attrs.get('iparepltoposegmentleftnode') rightnode = entry_attrs.get('iparepltoposegmentrightnode') if not leftnode and not rightnode: return # nothing to check # check if nodes are IPA servers masters = self.api.Command.server_find( '', sizelimit=0, no_members=False)['result'] m_hostnames = [master['cn'][0].lower() for master in masters] if leftnode and leftnode not in m_hostnames: raise errors.ValidationError( name='leftnode', error=_('left node is not a topology node: %(leftnode)s') % dict(leftnode=leftnode) ) if rightnode and rightnode not in m_hostnames: raise errors.ValidationError( name='rightnode', error=_('right node is not a topology node: %(rightnode)s') % dict(rightnode=rightnode) ) # prevent creation of reflexive relation key = 'leftnode' if not leftnode or not rightnode: # get missing end _entry_attrs = ldap.get_entry(dn, ['*']) if not leftnode: key = 'rightnode' leftnode = _entry_attrs['iparepltoposegmentleftnode'][0] else: rightnode = _entry_attrs['iparepltoposegmentrightnode'][0] if leftnode == rightnode: raise errors.ValidationError( name=key, error=_('left node and right node must not be the same') ) # don't allow segment between nodes where both don't have the suffix masters_to_suffix = map_masters_to_suffixes(masters) suffix_masters = masters_to_suffix.get(suffix, []) suffix_m_hostnames = [m['cn'][0].lower() for m in suffix_masters] if leftnode not in suffix_m_hostnames: raise errors.ValidationError( name='leftnode', error=_("left node ({host}) does not support " "suffix '{suff}'" .format(host=leftnode, suff=suffix)) ) if rightnode not in suffix_m_hostnames: raise errors.ValidationError( name='rightnode', error=_("right node ({host}) does not support " "suffix '{suff}'" .format(host=rightnode, suff=suffix)) )