Ejemplo n.º 1
0
 def __init__(self, id, manager, ruleset):
     self.my_id = id
     self._manager = manager
     self.conn_mgr = PolicyAppConnectionMgr(
         ruleset[PolicyKeys.KW_MAXCONN],
         ruleset[PolicyKeys.KW_MAXCONNPERUSER],
         ruleset[PolicyKeys.KW_MAXCONNPERHOST])
     self._cstats = self._manager.get_agent(
     ).qd.qd_dispatch_policy_c_counts_alloc()
     self._manager.get_agent().add_implementation(self, "vhostStats")
Ejemplo n.º 2
0
 def __init__(self, id, manager, ruleset):
     self.my_id = id
     self._manager = manager
     self.conn_mgr = PolicyAppConnectionMgr(
             ruleset[PolicyKeys.KW_MAXCONN],
             ruleset[PolicyKeys.KW_MAXCONNPERUSER],
             ruleset[PolicyKeys.KW_MAXCONNPERHOST])
     self._cstats = self._manager.get_agent().qd.qd_dispatch_policy_c_counts_alloc()
     self._manager.get_agent().add_implementation(self, "vhostStats")
Ejemplo n.º 3
0
class AppStats(object):
    """
    Maintain live state and statistics for an vhost.
    """
    def __init__(self, id, manager, ruleset):
        self.my_id = id
        self._manager = manager
        self.conn_mgr = PolicyAppConnectionMgr(
            ruleset[PolicyKeys.KW_MAXCONN],
            ruleset[PolicyKeys.KW_MAXCONNPERUSER],
            ruleset[PolicyKeys.KW_MAXCONNPERHOST])
        self._cstats = self._manager.get_agent(
        ).qd.qd_dispatch_policy_c_counts_alloc()
        self._manager.get_agent().add_implementation(self, "vhostStats")

    def update_ruleset(self, ruleset):
        """
        The parent ruleset has changed.
        Propagate settings into the connection manager.
        @param ruleset: new ruleset
        @return:
        """
        self.conn_mgr.update(ruleset[PolicyKeys.KW_MAXCONN],
                             ruleset[PolicyKeys.KW_MAXCONNPERHOST],
                             ruleset[PolicyKeys.KW_MAXCONNPERUSER])

    def refresh_entity(self, attributes):
        """Refresh management attributes"""
        entitymap = {}
        entitymap[PolicyKeys.KW_VHOST_NAME] = self.my_id
        entitymap[PolicyKeys.KW_VHOST_DEPRECATED_ID] = self.my_id
        entitymap[PolicyKeys.
                  KW_CONNECTIONS_APPROVED] = self.conn_mgr.connections_approved
        entitymap[PolicyKeys.
                  KW_CONNECTIONS_DENIED] = self.conn_mgr.connections_denied
        entitymap[PolicyKeys.
                  KW_CONNECTIONS_CURRENT] = self.conn_mgr.connections_active
        entitymap[PolicyKeys.KW_PER_USER_STATE] = self.conn_mgr.per_user_state
        entitymap[PolicyKeys.KW_PER_HOST_STATE] = self.conn_mgr.per_host_state
        self._manager.get_agent().qd.qd_dispatch_policy_c_counts_refresh(
            self._cstats, entitymap)
        attributes.update(entitymap)

    def can_connect(self, conn_id, user, host, diags):
        return self.conn_mgr.can_connect(conn_id, user, host, diags)

    def disconnect(self, conn_id, user, host):
        self.conn_mgr.disconnect(conn_id, user, host)

    def count_other_denial(self):
        self.conn_mgr.count_other_denial()

    def get_cstats(self):
        return self._cstats
Ejemplo n.º 4
0
class AppStats(object):
    """
    Maintain live state and statistics for an vhost.
    """
    def __init__(self, id, manager, ruleset):
        self.my_id = id
        self._manager = manager
        self.conn_mgr = PolicyAppConnectionMgr(
                ruleset[PolicyKeys.KW_MAXCONN],
                ruleset[PolicyKeys.KW_MAXCONNPERUSER],
                ruleset[PolicyKeys.KW_MAXCONNPERHOST])
        self._cstats = self._manager.get_agent().qd.qd_dispatch_policy_c_counts_alloc()
        self._manager.get_agent().add_implementation(self, "vhostStats")

    def update_ruleset(self, ruleset):
        """
        The parent ruleset has changed.
        Propagate settings into the connection manager.
        @param ruleset: new ruleset
        @return:
        """
        self.conn_mgr.update(
            ruleset[PolicyKeys.KW_MAXCONN],
            ruleset[PolicyKeys.KW_MAXCONNPERHOST],
            ruleset[PolicyKeys.KW_MAXCONNPERUSER])

    def refresh_entity(self, attributes):
        """Refresh management attributes"""
        entitymap = {}
        entitymap[PolicyKeys.KW_VHOST_NAME] =     self.my_id
        entitymap[PolicyKeys.KW_CONNECTIONS_APPROVED] = self.conn_mgr.connections_approved
        entitymap[PolicyKeys.KW_CONNECTIONS_DENIED] =   self.conn_mgr.connections_denied
        entitymap[PolicyKeys.KW_CONNECTIONS_CURRENT] =  self.conn_mgr.connections_active
        entitymap[PolicyKeys.KW_PER_USER_STATE] =       self.conn_mgr.per_user_state
        entitymap[PolicyKeys.KW_PER_HOST_STATE] =       self.conn_mgr.per_host_state
        self._manager.get_agent().qd.qd_dispatch_policy_c_counts_refresh(self._cstats, entitymap)
        attributes.update(entitymap)

    def can_connect(self, conn_id, user, host, diags):
        return self.conn_mgr.can_connect(conn_id, user, host, diags)

    def disconnect(self, conn_id, user, host):
        self.conn_mgr.disconnect(conn_id, user, host)

    def count_other_denial(self):
        self.conn_mgr.count_other_denial()

    def get_cstats(self):
        return self._cstats