You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gm...@apache.org on 2018/03/01 17:22:09 UTC
qpid-dispatch git commit: DISPATCH-918 - Modified schema code to
allow the 'dir' attribute of autoLink and linkRoute to be used from qdmanage
Repository: qpid-dispatch
Updated Branches:
refs/heads/master 7a306e7a6 -> bb0093e92
DISPATCH-918 - Modified schema code to allow the 'dir' attribute of autoLink and linkRoute to be used from qdmanage
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/bb0093e9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/bb0093e9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/bb0093e9
Branch: refs/heads/master
Commit: bb0093e92ce9bf184dc7c42e241e2169a6f8383e
Parents: 7a306e7
Author: Ganesh Murthy <gm...@redhat.com>
Authored: Thu Mar 1 12:21:42 2018 -0500
Committer: Ganesh Murthy <gm...@redhat.com>
Committed: Thu Mar 1 12:21:42 2018 -0500
----------------------------------------------------------------------
.../qpid_dispatch_internal/management/schema.py | 27 ++++++++++++++++----
src/parse.c | 3 +++
src/router_core/agent_config_auto_link.c | 22 +++++++++++-----
src/router_core/agent_config_auto_link.h | 2 +-
src/router_core/agent_config_link_route.c | 14 ++++++++--
src/router_core/agent_config_link_route.h | 2 +-
tests/system_tests_qdmanage.py | 16 ++++++++++++
7 files changed, 70 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/bb0093e9/python/qpid_dispatch_internal/management/schema.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/schema.py b/python/qpid_dispatch_internal/management/schema.py
index f2a487b..d1ca2b9 100644
--- a/python/qpid_dispatch_internal/management/schema.py
+++ b/python/qpid_dispatch_internal/management/schema.py
@@ -321,10 +321,23 @@ class EntityType(object):
self.name = self.short_name = name
self.attributes = OrderedDict((k, AttributeType(k, defined_in=self, **v))
for k, v in (attributes or {}).iteritems())
- self.deprecation_names = []
- for attr in self.attributes.itervalues():
- self.deprecation_names.append(attr.deprecation_name)
+ self.deprecated_attributes = OrderedDict()
+ for key, value in self.attributes.items():
+ if value.deprecation_name:
+ self.deprecated_attributes[value.deprecation_name] = AttributeType(value.deprecation_name,
+ type=value.type, defined_in=self,
+ default=value.default,
+ required=value.required,
+ unique=value.unique,
+ hidden=value.hidden,
+ deprecated=True,
+ deprecationName=None,
+ value=value.value,
+ description="(DEPRECATED) " + value.description,
+ create=value.create,
+ update=value.update,
+ graph=value.graph)
self.operations = operations or []
# Bases are resolved in self.init()
self.base = extends
@@ -373,9 +386,13 @@ class EntityType(object):
def attribute(self, name):
"""Get the AttributeType for name"""
- if not name in self.attributes and not name in self.deprecation_names:
+ if not name in self.attributes and not name in self.deprecated_attributes.keys():
raise ValidationError("Unknown attribute '%s' for '%s'" % (name, self))
- return self.attributes[name]
+ if self.attributes.get(name):
+ return self.attributes[name]
+ if self.deprecated_attributes.get(name):
+ return self.deprecated_attributes[name]
+ return None
def log(self, level, text):
self.schema.log(level, text)
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/bb0093e9/src/parse.c
----------------------------------------------------------------------
diff --git a/src/parse.c b/src/parse.c
index 056d164..4aed853 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -565,6 +565,9 @@ int qd_parse_is_scalar(qd_parsed_field_t *field)
qd_parsed_field_t *qd_parse_value_by_key(qd_parsed_field_t *field, const char *key)
{
+ if (!key)
+ return 0;
+
uint32_t count = qd_parse_sub_count(field);
for (uint32_t idx = 0; idx < count; idx++) {
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/bb0093e9/src/router_core/agent_config_auto_link.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent_config_auto_link.c b/src/router_core/agent_config_auto_link.c
index 651b596..20d7bbf 100644
--- a/src/router_core/agent_config_auto_link.c
+++ b/src/router_core/agent_config_auto_link.c
@@ -28,13 +28,14 @@
#define QDR_CONFIG_AUTO_LINK_TYPE 2
#define QDR_CONFIG_AUTO_LINK_ADDR 3
#define QDR_CONFIG_AUTO_LINK_DIRECTION 4
-#define QDR_CONFIG_AUTO_LINK_PHASE 5
-#define QDR_CONFIG_AUTO_LINK_CONNECTION 6
-#define QDR_CONFIG_AUTO_LINK_CONTAINER_ID 7
-#define QDR_CONFIG_AUTO_LINK_EXT_ADDR 8
-#define QDR_CONFIG_AUTO_LINK_LINK_REF 9
-#define QDR_CONFIG_AUTO_LINK_OPER_STATUS 10
-#define QDR_CONFIG_AUTO_LINK_LAST_ERROR 11
+#define QDR_CONFIG_AUTO_LINK_DIR 5
+#define QDR_CONFIG_AUTO_LINK_PHASE 6
+#define QDR_CONFIG_AUTO_LINK_CONNECTION 7
+#define QDR_CONFIG_AUTO_LINK_CONTAINER_ID 8
+#define QDR_CONFIG_AUTO_LINK_EXT_ADDR 9
+#define QDR_CONFIG_AUTO_LINK_LINK_REF 10
+#define QDR_CONFIG_AUTO_LINK_OPER_STATUS 11
+#define QDR_CONFIG_AUTO_LINK_LAST_ERROR 12
const char *qdr_config_auto_link_columns[] =
{"name",
@@ -42,6 +43,7 @@ const char *qdr_config_auto_link_columns[] =
"type",
"addr",
"direction",
+ "dir",
"phase",
"connection",
"containerId",
@@ -87,6 +89,7 @@ static void qdr_config_auto_link_insert_column_CT(qdr_auto_link_t *al, int col,
qd_compose_insert_null(body);
break;
+ case QDR_CONFIG_AUTO_LINK_DIR:
case QDR_CONFIG_AUTO_LINK_DIRECTION:
text = al->dir == QD_INCOMING ? "in" : "out";
qd_compose_insert_string(body, text);
@@ -369,6 +372,11 @@ void qdra_config_auto_link_create_CT(qdr_core_t *core,
//
qd_parsed_field_t *addr_field = qd_parse_value_by_key(in_body, qdr_config_auto_link_columns[QDR_CONFIG_AUTO_LINK_ADDR]);
qd_parsed_field_t *dir_field = qd_parse_value_by_key(in_body, qdr_config_auto_link_columns[QDR_CONFIG_AUTO_LINK_DIRECTION]);
+ if (! dir_field) {
+ dir_field = qd_parse_value_by_key(in_body, qdr_config_auto_link_columns[QDR_CONFIG_AUTO_LINK_DIR]);
+ if (dir_field)
+ qd_log(core->agent_log, QD_LOG_WARNING, "The 'dir' attribute of autoLink has been deprecated. Use 'direction' instead");
+ }
qd_parsed_field_t *phase_field = qd_parse_value_by_key(in_body, qdr_config_auto_link_columns[QDR_CONFIG_AUTO_LINK_PHASE]);
qd_parsed_field_t *connection_field = qd_parse_value_by_key(in_body, qdr_config_auto_link_columns[QDR_CONFIG_AUTO_LINK_CONNECTION]);
qd_parsed_field_t *container_field = qd_parse_value_by_key(in_body, qdr_config_auto_link_columns[QDR_CONFIG_AUTO_LINK_CONTAINER_ID]);
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/bb0093e9/src/router_core/agent_config_auto_link.h
----------------------------------------------------------------------
diff --git a/src/router_core/agent_config_auto_link.h b/src/router_core/agent_config_auto_link.h
index 1251135..f01b471 100644
--- a/src/router_core/agent_config_auto_link.h
+++ b/src/router_core/agent_config_auto_link.h
@@ -32,7 +32,7 @@ void qdra_config_auto_link_get_CT(qdr_core_t *core,
qd_iterator_t *identity,
qdr_query_t *query,
const char *qdr_config_auto_link_columns[]);
-#define QDR_CONFIG_AUTO_LINK_COLUMN_COUNT 12
+#define QDR_CONFIG_AUTO_LINK_COLUMN_COUNT 13
const char *qdr_config_auto_link_columns[QDR_CONFIG_AUTO_LINK_COLUMN_COUNT + 1];
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/bb0093e9/src/router_core/agent_config_link_route.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent_config_link_route.c b/src/router_core/agent_config_link_route.c
index d7f47bd..981d142 100644
--- a/src/router_core/agent_config_link_route.c
+++ b/src/router_core/agent_config_link_route.c
@@ -31,8 +31,9 @@
#define QDR_CONFIG_LINK_ROUTE_CONNECTION 5
#define QDR_CONFIG_LINK_ROUTE_CONTAINER_ID 6
#define QDR_CONFIG_LINK_ROUTE_DIRECTION 7
-#define QDR_CONFIG_LINK_ROUTE_OPER_STATUS 8
-#define QDR_CONFIG_LINK_ROUTE_PATTERN 9
+#define QDR_CONFIG_LINK_ROUTE_DIR 8
+#define QDR_CONFIG_LINK_ROUTE_OPER_STATUS 9
+#define QDR_CONFIG_LINK_ROUTE_PATTERN 10
const char *qdr_config_link_route_columns[] =
{"name",
@@ -43,6 +44,7 @@ const char *qdr_config_link_route_columns[] =
"connection",
"containerId",
"direction",
+ "dir",
"operStatus",
"pattern",
0};
@@ -129,6 +131,7 @@ static void qdr_config_link_route_insert_column_CT(qdr_link_route_t *lr, int col
qd_compose_insert_null(body);
break;
+ case QDR_CONFIG_LINK_ROUTE_DIR:
case QDR_CONFIG_LINK_ROUTE_DIRECTION:
text = lr->dir == QD_INCOMING ? "in" : "out";
qd_compose_insert_string(body, text);
@@ -383,6 +386,7 @@ void qdra_config_link_route_create_CT(qdr_core_t *core,
break;
}
+
//
// Extract the fields from the request
//
@@ -392,6 +396,12 @@ void qdra_config_link_route_create_CT(qdr_core_t *core,
qd_parsed_field_t *connection_field = qd_parse_value_by_key(in_body, qdr_config_link_route_columns[QDR_CONFIG_LINK_ROUTE_CONNECTION]);
qd_parsed_field_t *container_field = qd_parse_value_by_key(in_body, qdr_config_link_route_columns[QDR_CONFIG_LINK_ROUTE_CONTAINER_ID]);
qd_parsed_field_t *dir_field = qd_parse_value_by_key(in_body, qdr_config_link_route_columns[QDR_CONFIG_LINK_ROUTE_DIRECTION]);
+ if (! dir_field) {
+ dir_field = qd_parse_value_by_key(in_body, qdr_config_link_route_columns[QDR_CONFIG_LINK_ROUTE_DIR]);
+ if (dir_field)
+ qd_log(core->agent_log, QD_LOG_WARNING, "The 'dir' attribute of linkRoute has been deprecated. Use 'direction' instead");
+ }
+
//
// Both connection and containerId cannot be specified because both can represent different connections. Only one those
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/bb0093e9/src/router_core/agent_config_link_route.h
----------------------------------------------------------------------
diff --git a/src/router_core/agent_config_link_route.h b/src/router_core/agent_config_link_route.h
index 6824697..57f6f0d 100644
--- a/src/router_core/agent_config_link_route.h
+++ b/src/router_core/agent_config_link_route.h
@@ -33,7 +33,7 @@ void qdra_config_link_route_get_CT(qdr_core_t *core,
qdr_query_t *query,
const char *qdr_config_link_route_columns[]);
-#define QDR_CONFIG_LINK_ROUTE_COLUMN_COUNT 10
+#define QDR_CONFIG_LINK_ROUTE_COLUMN_COUNT 11
const char *qdr_config_link_route_columns[QDR_CONFIG_LINK_ROUTE_COLUMN_COUNT + 1];
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/bb0093e9/tests/system_tests_qdmanage.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_qdmanage.py b/tests/system_tests_qdmanage.py
index f9834ff..c6fa186 100644
--- a/tests/system_tests_qdmanage.py
+++ b/tests/system_tests_qdmanage.py
@@ -297,6 +297,7 @@ class QdmanageTest(TestCase):
output = json.loads(self.run_qdmanage(query_command))
self.assertEqual(output[0]['name'], "test-link-route")
self.assertEqual(output[0]['direction'], "in")
+ self.assertEqual(output[0]['dir'], "in")
self.assertEqual(output[0]['prefix'], "xyz")
def test_specify_container_id_connection_link_route(self):
@@ -319,6 +320,21 @@ class QdmanageTest(TestCase):
output = json.loads(self.run_qdmanage(create_command))
self.assertEqual(output['phase'], 2)
+ def test_create_auto_link_with_dir(self):
+ long_type = 'org.apache.qpid.dispatch.router.config.autoLink'
+ create_command = 'CREATE --type=' + long_type + ' addr=defgh containerId=id2 dir=out phase=2'
+ output = json.loads(self.run_qdmanage(create_command))
+ self.assertEqual(output['dir'], 'out')
+ self.assertEqual(output['direction'], 'out')
+
+ def test_create_link_route_with_dir(self):
+ long_type = 'org.apache.qpid.dispatch.router.config.linkRoute'
+ create_command = 'CREATE --type=' + long_type + ' pattern=mnb dir=out'
+ output = json.loads(self.run_qdmanage(create_command))
+ self.assertEqual(output['dir'], 'out')
+ self.assertEqual(output['direction'], 'out')
+
+
def test_specify_container_id_connection_auto_link(self):
long_type = 'org.apache.qpid.dispatch.router.config.autoLink'
create_command = 'CREATE --type=' + long_type + ' addr=abc containerId=id1 connection=conn1 direction=out'
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org