Example #1
0
 def __init__(self,hostname=get_hostname()):
     '''
     Constructor
     '''
     self.server=hostname
     self.kernel=Essential()    
     self.db_name =self.kernel.get_db_name()
     self.db_port = self.kernel.get_db_port()
     self.connection = MongoClient(hostname, self.db_port)
     self.db=self.connection[self.db_name]
Example #2
0
 def am_i_a_member_of_this(self,coordinator):  
     """Checks if this node is member of the
     'coordinator' storage domain. Port and 
     database name come from the main configuration
     file (/etc/yanoama.conf). 
 
     Keyword arguments:
     nodes -- coordinator hostname
 
     Returns:
     boolean -- member or not
     """
     connection = MongoClient(coordinator, self.db_port)
     db = connection[self.db_name]
     recovered_peers = self.recover_dict_keys_from_colons_to_dots(db['peers'].find_one({}, {'_id': False}))
     return get_hostname() in recovered_peers.keys()
 
     
Example #3
0
 def get_peers(self,hostname=get_hostname()):  
     """Connects to a coordinator MongoBD database
     and retrieves the list of member nodes of
     this storage domain. It gets information from
     db['nodes_latency_measurements'] entry. Port 
     number and  database name come from the main 
     configuration file (yanoama.conf)
 
     Keyword arguments:
     coordinator  -- coordinator to connect and
     retrieve information (default localhost)
 
     Returns:
     dictionary -- members information where keys 
     are the hostnames
 
     """
     if hostname == self.server:
         return self.recover_dict_keys_from_colons_to_dots(self.db['nodes_latency_measurements'].find_one({}, {'_id': False}).copy())
     else:
         connection = MongoClient(hostname, self.db_port)
         db=connection[self.db_name]
         return self.recover_dict_keys_from_colons_to_dots(db['nodes_latency_measurements'].find_one({}, {'_id': False}).copy())
Example #4
0
    from yanoama.core.essential import Essential, \
                    get_hostname, log
    from yanoama.backend.mongo import Mongo
except ImportError:
    sys.path.append(get_install_path()) 
    #import yanoama modules alternatively
    from yanoama.core.essential import Essential, \
                    get_hostname, log
    from yanoama.backend.mongo import Mongo





if __name__ == '__main__':
    kernel=Essential()
    db = Mongo()
    local_peers=db.get_peers()
    for coordinator in kernel.get_coordinators(get_hostname()):
        peers=db.get_peers(coordinator)
        to_be_removed=[]
        for hostname in peers.keys():
            if hostname in local_peers:
                if local_peers[hostname]>peers[hostname]:
                    to_be_removed.append(hostname)
        for hostname in to_be_removed:
            del local_peers[hostname]
    db.save_peers(local_peers)
    #log/print out to the standard output
    log('current number of members:'+str(len(local_peers.keys()))+', done.')
Example #5
0
    """Deploy yanoama based on the node role,
    either peer or coordinator.

    """
    kernel=Essential()
    #update services file with temp file, 
    #rest must be done by command line
    temp_services_file='/tmp/services'
    f = open(temp_services_file, 'w')  
    f.write('#local services'+'\n')
    f.write('pilot\t\t'+str(kernel.get_pilot_port())+'/tcp\n')
    f.write('mongo\t\t'+str(kernel.get_db_port())+'/tcp\n')
    f.write('mongo_replication\t\t'+str(kernel.get_db_replication_port())+'/tcp\n')
    f.close()
    
    if get_hostname() in kernel.get_coordinators().keys():
        """this is a coordinator
        #here the two-step installation procedure
        #1) install cron jobs: get_rtt.py and
        #                    peering.py
        #2) install mongodb database as part of amen
        #                    monitoring system.
    
        """
        #
        #
        #(1)installing cron jobs
        ##    get_rtt
        kernel.install_runnable_script('/yanoama/monitoring/get_rtt.py')
        #install as a cron job
        install_cron_job("get_rtt.py > /tmp/get_rtt_output.log 2>&1")