mongoctl/objects/replicaset_cluster.py
def validate_against_current_config(self, current_rs_conf):
        """
        Validates the member document against current rs conf
            1- If there is a member in current config with _id equals to my id
                then ensure hosts addresses resolve to the same host

            2- If there is a member in current config with host resolving to my
               host then ensure that if my id is et then it
               must equal member._id

        """

        # if rs is not configured yet then there is nothing to validate
        if not current_rs_conf:
            return

        my_host = self.get_host()
        current_member_confs = current_rs_conf['members']
        err = None
        for curr_mem_conf in current_member_confs:
            if (self.id and
                        self.id == curr_mem_conf['_id'] and
                    not is_same_address(my_host, curr_mem_conf['host'])):
                err = ("Member config is not consistent with current rs "
                       "config. \n%s\n. Both have the sam _id but addresses"
                       " '%s' and '%s' do not resolve to the same host." %
                       (document_pretty_string(curr_mem_conf),
                        my_host, curr_mem_conf['host'] ))

            elif (is_same_address(my_host, curr_mem_conf['host']) and
                      self.id and
                          self.id != curr_mem_conf['_id']):
                err = ("Member config is not consistent with current rs "
                       "config. \n%s\n. Both addresses"
                       " '%s' and '%s' resolve to the same host but _ids '%s'"
                       " and '%s' are not equal." %
                       (document_pretty_string(curr_mem_conf),
                        my_host, curr_mem_conf['host'],
                        self.id, curr_mem_conf['_id']))

        if err:
            raise MongoctlException("Invalid member configuration:\n%s \n%s" %
                                    (self, err))

        Validates the member document against current rs conf
            1- If there is a member in current config with _id equals to my id
                then ensure hosts addresses resolve to the same host

            2- If there is a member in current config with host resolving to my
               host then ensure that if my id is et then it
               must equal member._id

        
Validates the member document against current rs conf
1- If there is a member in current config with _id equals to my id
then ensure hosts addresses resolve to the same host

2- If there is a member in current config with host resolving to my
host then ensure that if my id is et then it
must equal member._id
Validates the member document against current rs conf 1 - If there is a member in current config with _id equals to my id then ensure hosts addresses resolve to the same host 2 - If there is a member in current config with host resolving to my host then ensure that if my id is et then it must equal member . _id
def validate_against_current_config(self, current_rs_conf):
        if not current_rs_conf:
            return
        my_host = self.get_host()
        current_member_confs = current_rs_conf['members']
        err = None
        for curr_mem_conf in current_member_confs:
            if (self.id and
                        self.id == curr_mem_conf['_id'] and
                    not is_same_address(my_host, curr_mem_conf['host'])):
                err = ("Member config is not consistent with current rs "
                       "config. \n%s\n. Both have the sam _id but addresses"
                       " '%s' and '%s' do not resolve to the same host." %
                       (document_pretty_string(curr_mem_conf),
                        my_host, curr_mem_conf['host'] ))
            elif (is_same_address(my_host, curr_mem_conf['host']) and
                      self.id and
                          self.id != curr_mem_conf['_id']):
                err = ("Member config is not consistent with current rs "
                       "config. \n%s\n. Both addresses"
                       " '%s' and '%s' resolve to the same host but _ids '%s'"
                       " and '%s' are not equal." %
                       (document_pretty_string(curr_mem_conf),
                        my_host, curr_mem_conf['host'],
                        self.id, curr_mem_conf['_id']))
        if err:
            raise MongoctlException("Invalid member configuration:\n%s \n%s" %
                                    (self, err))
def validate_against_current_config ( self , current_rs_conf ) : if not current_rs_conf : return my_host = self . get_host ( ) current_member_confs = current_rs_conf [ 'members' ] err = None for curr_mem_conf in current_member_confs : if ( self . id and self . id == curr_mem_conf [ '_id' ] and not is_same_address ( my_host , curr_mem_conf [ 'host' ] ) ) : err = ( "Member config is not consistent with current rs " "config. \n%s\n. Both have the sam _id but addresses" " '%s' and '%s' do not resolve to the same host." % ( document_pretty_string ( curr_mem_conf ) , my_host , curr_mem_conf [ 'host' ] ) ) elif ( is_same_address ( my_host , curr_mem_conf [ 'host' ] ) and self . id and self . id != curr_mem_conf [ '_id' ] ) : err = ( "Member config is not consistent with current rs " "config. \n%s\n. Both addresses" " '%s' and '%s' resolve to the same host but _ids '%s'" " and '%s' are not equal." % ( document_pretty_string ( curr_mem_conf ) , my_host , curr_mem_conf [ 'host' ] , self . id , curr_mem_conf [ '_id' ] ) ) if err : raise MongoctlException ( "Invalid member configuration:\n%s \n%s" % ( self , err ) )
Validates the member document against current rs conf
1- If there is a member in current config with _id equals to my id
then ensure hosts addresses resolve to the same host
Validates the member document against current rs conf 1 - If there is a member in current config with _id equals to my id then ensure hosts addresses resolve to the same host
"""
        Validates the member document against current rs conf
            1- If there is a member in current config with _id equals to my id
                then ensure hosts addresses resolve to the same host

            2- If there is a member in current config with host resolving to my
               host then ensure that if my id is et then it
               must equal member._id

        """ # if rs is not configured yet then there is nothing to validate
self
current_rs_conf