示例#1
0
    def __init__(self,structure,server=None,cluster=None):
        #self.structure = structure
        if server:
            self.data = server.copy()
            _cluster = self.CLUSTER = cluster or structure.CLUSTERS[server.get('cluster')] or structure.CLUSTERS.get('live',structure.FALLBACK_CLUSTER)
            self.known = True
            self.public_access = server.get('domains',False)
        else:
            self.data = {
                'mac' : net.get_mac_address_hex(),
                'pool_ip' : net.get_ip4_address(),
                'own_ip' : net.get_ip4_address(),
                'nick' : 'unknown',
            }
            _cluster = self.CLUSTER = cluster or structure.CLUSTERS.get('live',structure.FALLBACK_CLUSTER)
            self.known = False
        self.data.update(_cluster)

        if self.data['shard_user'] == '~': self.data['shard_user'] = structure.PROJECT_NAME
        if self.data['etc_user'] == '~': self.data['etc_user'] = structure.PROJECT_NAME
        if self.data['log_user'] == '~': self.data['log_user'] = structure.PROJECT_NAME
        self.DOMAINS = [name.strip('.') for name in self.data['domains']]  
        if self.known:
            self.NICK = self.data['NICK']
            
        self.effective_uid = os.getuid()
        self.effective_user = getpwuid(self.effective_uid)[0]
示例#2
0
 def handle(self, *args, **options):
     from thepian.conf import structure
     
     print net.get_mac_addresses()
     print 'mac  '+net.get_mac_address_hex()
     print 'ip   '+net.get_ip4_address()
     if structure.machine.known:
         machine = structure.machine
         print 'name '+machine['NICK'] + ' in ' + machine['cluster']
         print 'as   '+ ' '.join(machine['domains'] or [])