Пример #1
0
 def get_clients(self, endpoint):
     """
     Get Clients for an endpoint
     :param endpoint: endpoint ip
     :type endpoint: str
     """
     with session_scope() as session:
         return self._repository.connected_state.get_clients(
             session, endpoint)
Пример #2
0
 def get_connected_state(self, endpoint=None):
     """
     Get connected state for an endpoint if specified
     :param endpoint: endpoint ip
     :type endpoint: str
     """
     with session_scope() as session:
         filters = {}
         if endpoint:
             filters['endpoint'] = endpoint
         return self._repository.connected_state.get_all(session, **filters)
Пример #3
0
 def delete_connected_state(self, endpoint=None):
     """
     Delete connected state for an endpoint
     :param endpoint: endpoint ip
     :type endpoint: str
     """
     with session_scope() as session:
         if endpoint:
             self._repository.connected_state.delete(session,
                                                     endpoint=endpoint)
         else:
             self._repository.connected_state.delete_all(session)
         session.commit()
Пример #4
0
 def update_connected_state(self, endpoint, servers=None, clients=None):
     """
     Update connected state for an endpoint
     :param endpoint: endpoint ip
     :type endpoint: str
     :param servers: list of (protocol, port) tuple
     :type servers: list
     :param clients: list of clients
     :type clients: list
     """
     with session_scope() as session:
         self._repository.connected_state.update(session,
                                                 endpoint,
                                                 servers=servers,
                                                 clients=clients)