Ejemplo n.º 1
0
    def _send_new_identity(self):
        """
        Send created identity to the identity server to register it.

        TODO: need to close transport and gateway after that
        """
        lg.out(4, 'id_registrator._send_new_identity ')
        from transport import gateway
        from transport import network_transport
        from transport.tcp import tcp_interface
        gateway.init()
        interface = tcp_interface.GateInterface()
        transport = network_transport.NetworkTransport('tcp', interface)
        transport.automat('init', gateway.listener())
        transport.automat('start')
        gateway.start()
        sendfilename = settings.LocalIdentityFilename() + '.new'
        dlist = []
        for idurl in self.new_identity.sources:
            self.free_idurls.remove(idurl)
            _, host, _, _ = nameurl.UrlParse(idurl)
            _, tcpport = known_servers.by_host().get(
                host, (settings.IdentityWebPort(), settings.IdentityServerPort()))
            srvhost = '%s:%d' % (host, tcpport)
            dlist.append(gateway.send_file_single(
                idurl, 'tcp', srvhost, sendfilename, 'Identity'))
        assert len(self.free_idurls) == 0
        return DeferredList(dlist)
Ejemplo n.º 2
0
 def _send_new_identity(self):
     """
     Send created identity to the identity server to register it.
     TODO: need to close transport and gateway after that
     """
     lg.out(4, 'id_registrator._send_new_identity ')
     from transport import gateway
     from transport import network_transport
     from transport.tcp import tcp_interface
     gateway.init()
     interface = tcp_interface.GateInterface()
     transport = network_transport.NetworkTransport('tcp', interface)
     transport.automat('init', gateway.listener())
     transport.automat('start')
     gateway.start()
     sendfilename = settings.LocalIdentityFilename() + '.new'
     dlist = []
     for idurl in self.new_identity.sources:
         self.free_idurls.remove(strng.to_bin(idurl))
         _, host, _, _ = nameurl.UrlParse(idurl)
         _, tcpport = known_servers.by_host().get(
             host,
             (settings.IdentityWebPort(), settings.IdentityServerPort()))
         srvhost = net_misc.pack_address((
             host,
             tcpport,
         ))
         dlist.append(
             gateway.send_file_single(idurl, 'tcp', srvhost, sendfilename,
                                      'Identity'))
     # assert len(self.free_idurls) == 0
     return DeferredList(dlist, fireOnOneCallback=True)