qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject qpid-dispatch git commit: Rename policy handler to PolicyLocal. Add writeup doc with pictures.
Date Tue, 05 Jan 2016 17:07:27 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/crolke-DISPATCH-188-1 3256a51c8 -> 189d1c16c


Rename policy handler to PolicyLocal. Add writeup doc with pictures.


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/189d1c16
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/189d1c16
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/189d1c16

Branch: refs/heads/crolke-DISPATCH-188-1
Commit: 189d1c16c1fa7c7e502b8b37ffce78bbd4fe9620
Parents: 3256a51
Author: Chuck Rolke <crolke@redhat.com>
Authored: Tue Jan 5 12:05:31 2016 -0500
Committer: Chuck Rolke <crolke@redhat.com>
Committed: Tue Jan 5 12:05:31 2016 -0500

----------------------------------------------------------------------
 doc/notes/qdr-policy-01.odt                        | Bin 0 -> 29805 bytes
 doc/notes/qdr-policy-01.pdf                        | Bin 0 -> 98054 bytes
 doc/notes/qdr-policy-diagrams-01.odg               | Bin 0 -> 26640 bytes
 python/qpid_dispatch/management/qdrouter.json      |   6 ++++++
 python/qpid_dispatch_internal/management/policy.py |  15 +++------------
 src/dispatch.c                                     |   5 ++++-
 src/policy.c                                       |  14 +++++++++++++-
 tests/system_tests_policy.py                       |   5 ++---
 8 files changed, 28 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/189d1c16/doc/notes/qdr-policy-01.odt
----------------------------------------------------------------------
diff --git a/doc/notes/qdr-policy-01.odt b/doc/notes/qdr-policy-01.odt
new file mode 100644
index 0000000..a41c5f2
Binary files /dev/null and b/doc/notes/qdr-policy-01.odt differ

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/189d1c16/doc/notes/qdr-policy-01.pdf
----------------------------------------------------------------------
diff --git a/doc/notes/qdr-policy-01.pdf b/doc/notes/qdr-policy-01.pdf
new file mode 100644
index 0000000..426d04b
Binary files /dev/null and b/doc/notes/qdr-policy-01.pdf differ

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/189d1c16/doc/notes/qdr-policy-diagrams-01.odg
----------------------------------------------------------------------
diff --git a/doc/notes/qdr-policy-diagrams-01.odg b/doc/notes/qdr-policy-diagrams-01.odg
new file mode 100644
index 0000000..93aca7b
Binary files /dev/null and b/doc/notes/qdr-policy-diagrams-01.odg differ

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/189d1c16/python/qpid_dispatch/management/qdrouter.json
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch/management/qdrouter.json b/python/qpid_dispatch/management/qdrouter.json
index 74f9b77..eb8e599 100644
--- a/python/qpid_dispatch/management/qdrouter.json
+++ b/python/qpid_dispatch/management/qdrouter.json
@@ -1012,6 +1012,12 @@
                     "required": false,
                     "create": true
                 },
+                "policyDb": {
+                    "type": "path",
+                    "description": "The path to the folder that holds policy definition files.",
+		    "required": false,
+                    "create": true
+                },
                 "connectionsProcessed": {"type": "integer", "graph": true},
                 "connectionsDenied": {"type": "integer", "graph": true},
                 "connectionsCurrent": {"type": "integer", "graph": true}

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/189d1c16/python/qpid_dispatch_internal/management/policy.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/policy.py b/python/qpid_dispatch_internal/management/policy.py
index 185b60c..501dd16 100644
--- a/python/qpid_dispatch_internal/management/policy.py
+++ b/python/qpid_dispatch_internal/management/policy.py
@@ -144,12 +144,8 @@ class PolicyCompiler():
         PolicyKeys.KW_ROLES
         )
         ]
-    schema_disallowed_options = [(),
-        ()
-        ]
 
     allowed_opts = ()
-    disallowed_opts = ()
     crud_compiler_fn = None
 
 
@@ -165,7 +161,6 @@ class PolicyCompiler():
                 "Illegal policy schema version %s. Must be '1'." % schema_version)
         self.schema_version  = schema_version
         self.allowed_opts    = self.schema_allowed_options[schema_version]
-        self.disallowed_opts = self.schema_disallowed_options[schema_version]
 
 
     def validateNumber(self, val, v_min, v_max, errors):
@@ -298,10 +293,6 @@ class PolicyCompiler():
             if key not in self.allowed_opts:
                 warnings.append("Application '%s' option '%s' is ignored." %
                                 (name, key))
-            if key in self.disallowed_opts:
-                errors.append("Application '%s' option '%s' is disallowed." %
-                              (name, key))
-                return False
             if key == PolicyKeys.KW_VERSION:
                 if not int(self.schema_version) == int(val):
                     errors.append("Application '%s' expected schema version '%s' but is '%s'."
%
@@ -353,7 +344,7 @@ class PolicyCompiler():
                     return False
         return True
 
-class Policy():
+class PolicyLocal():
     """
     The policy database.
     """
@@ -725,7 +716,7 @@ def main_except(argv):
 
     (options, args) = parser.parse_args()
 
-    policy = Policy(options.folder)
+    policy = PolicyLocal(options.folder)
 
     print("policy names: %s" % policy.policy_db_get_names())
 
@@ -734,7 +725,7 @@ def main_except(argv):
 
     # Exercise a few functions
     # Empty policy
-    policy2 = Policy()
+    policy2 = PolicyLocal()
 
     print("Policy details:")
     for pname in policy.policy_db_get_names():

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/189d1c16/src/dispatch.c
----------------------------------------------------------------------
diff --git a/src/dispatch.c b/src/dispatch.c
index 15b3b97..765918a 100644
--- a/src/dispatch.c
+++ b/src/dispatch.c
@@ -143,7 +143,10 @@ qd_error_t qd_dispatch_configure_lrp(qd_dispatch_t *qd, qd_entity_t *entity)
{
 
 qd_error_t qd_dispatch_configure_policy(qd_dispatch_t *qd, qd_entity_t *entity)
 {
-    qd_entity_configure_policy(qd->policy, entity);
+    qd_error_t err;
+    err = qd_entity_configure_policy(qd->policy, entity);
+    if (err)
+        return err;
     return QD_ERROR_NONE;
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/189d1c16/src/policy.c
----------------------------------------------------------------------
diff --git a/src/policy.c b/src/policy.c
index dbade77..45908bd 100644
--- a/src/policy.c
+++ b/src/policy.c
@@ -88,6 +88,7 @@ struct qd_policy_t {
     qd_log_source_t      *log_source;
                           // configured settings
     int                   max_connection_limit;
+    char                 *policyDb;
                           // live statistics
     int                   connections_processed;
     int                   connections_denied;
@@ -102,6 +103,7 @@ qd_policy_t *qd_policy(qd_dispatch_t *qd)
     policy->qd                   = qd;
     policy->log_source           = qd_log_source("POLICY");
     policy->max_connection_limit = 0;
+    policy->policyDb             = 0;
     policy->connections_processed= 0;
     policy->connections_denied   = 0;
     policy->connections_current  = 0;
@@ -113,18 +115,28 @@ qd_policy_t *qd_policy(qd_dispatch_t *qd)
 
 void qd_policy_free(qd_policy_t *policy)
 {
+    if (policy->policyDb)
+        free(policy->policyDb);
     free(policy);
 }
 
+#define CHECK() if (qd_error_code()) goto error
+
 //
 //
 qd_error_t qd_entity_configure_policy(qd_policy_t *policy, qd_entity_t *entity)
 {
-    policy->max_connection_limit = qd_entity_opt_long(entity, "maximumConnections", 0);
QD_ERROR_RET();
+    policy->max_connection_limit = qd_entity_opt_long(entity, "maximumConnections", 0);
CHECK();
     if (policy->max_connection_limit < 0)
         return qd_error(QD_ERROR_CONFIG, "maximumConnections must be >= 0");
+    policy->policyDb =
+        qd_entity_opt_string(entity, "policyDb", 0); CHECK();
     qd_log(policy->log_source, QD_LOG_INFO, "Configured maximumConnections: %d", policy->max_connection_limit);
     return QD_ERROR_NONE;
+
+error:
+    qd_policy_free(policy);
+    return qd_error_code();
 }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/189d1c16/tests/system_tests_policy.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_policy.py b/tests/system_tests_policy.py
index 0ef7356..46a20d2 100644
--- a/tests/system_tests_policy.py
+++ b/tests/system_tests_policy.py
@@ -32,8 +32,7 @@ from system_test import TIMEOUT
 
 from qpid_dispatch_internal.management.policy_util import \
     HostAddr, PolicyError, HostStruct, PolicyAppConnectionMgr
-from qpid_dispatch_internal.management.policy import \
-    Policy
+from qpid_dispatch_internal.management.policy import PolicyLocal
 
 class AbsoluteConnectionCountLimit(TestCase):
     """
@@ -163,7 +162,7 @@ class PolicyHostAddrTest(TestCase):
 
 class PolicyFile(TestCase):
 
-    policy = Policy("../../../tests/policy-1")
+    policy = PolicyLocal("../../../tests/policy-1")
 
     def dict_compare(self, d1, d2):
         d1_keys = set(d1.keys())


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message