Example #1
0
 def doConnectSuppliers(self, *args, **kwargs):
     """
     Action method.
     """
     self.connect_list = []
     my_current_family = list(contactsdb.suppliers())
     for pos, supplier_idurl in enumerate(my_current_family):
         if not supplier_idurl:
             continue
         sc = supplier_connector.by_idurl(supplier_idurl)
         if sc is None:
             sc = supplier_connector.create(
                 supplier_idurl=supplier_idurl,
                 customer_idurl=my_id.getLocalID(),
             )
         sc.set_callback('fire_hire',
                         self._on_supplier_connector_state_changed)
         self.connect_list.append(supplier_idurl)
         sc.automat(
             'connect',
             family_position=pos,
             ecc_map=eccmap.Current().name,
             family_snapshot=my_current_family,
         )
         supplier_contact_status = contact_status.getInstance(
             supplier_idurl)
         if supplier_contact_status:
             supplier_contact_status.addStateChangedCallback(
                 self._on_supplier_contact_status_state_changed,
                 newstate='OFFLINE',
             )
 def init(self):
     """
     Method to initialize additional variables and flags at creation of the
     state machine.
     """
     contact_peer = contact_status.getInstance(self.supplier_idurl)
     if contact_peer:
         contact_peer.addStateChangedCallback(
             self._on_contact_status_state_changed)
Example #3
0
 def init(self):
     """
     Method to initialize additional variables and flags at creation of the
     state machine.
     """
     self._last_known_family_position = None
     self._last_known_ecc_map = None
     self._last_known_family_snapshot = None
     contact_peer = contact_status.getInstance(self.supplier_idurl)
     if contact_peer:
         contact_peer.addStateChangedCallback(self._on_contact_status_state_changed)
Example #4
0
 def doDestroyMe(self, *args, **kwargs):
     """
     Action method.
     """
     contact_peer = contact_status.getInstance(self.supplier_idurl)
     if contact_peer:
         contact_peer.removeStateChangedCallback(self._on_contact_status_state_changed)
     connectors(self.customer_idurl).pop(self.supplier_idurl)
     self.request_packet_id = None
     self.supplier_idurl = None
     self.customer_idurl = None
     self.queue_subscribe = None
     self.destroy()
Example #5
0
 def doDisconnectSuppliers(self, arg):
     """
     Action method.
     """
     lg.out(10, 'fire_hire.doDisconnectSuppliers %r' % self.dismiss_list)
     self.dismiss_results = []
     for supplier_idurl in self.dismiss_list:
         sc = supplier_connector.by_idurl(supplier_idurl)
         if sc:
             sc.set_callback('fire_hire',
                             self._on_supplier_connector_state_changed)
             sc.automat('disconnect')
         else:
             lg.warn('supplier_connector must exist, but not found %s' % supplier_idurl)
         supplier_contact_status = contact_status.getInstance(supplier_idurl)
         if supplier_contact_status:
             supplier_contact_status.removeStateChangedCallback(self._on_supplier_contact_status_state_changed)
Example #6
0
 def doConnectSuppliers(self, arg):
     """
     Action method.
     """
     self.connect_list = []
     for supplier_idurl in contactsdb.suppliers():
         if supplier_idurl == '':
             continue
         sc = supplier_connector.by_idurl(supplier_idurl)
         if sc is None:
             sc = supplier_connector.create(supplier_idurl)
         sc.set_callback('fire_hire', self._on_supplier_connector_state_changed)
         self.connect_list.append(supplier_idurl)
         sc.automat('connect')
         supplier_contact_status = contact_status.getInstance(supplier_idurl)
         if supplier_contact_status:
             supplier_contact_status.addStateChangedCallback(
                 self._on_supplier_contact_status_state_changed,
                 newstate='OFFLINE',
             )