qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gmur...@apache.org
Subject [5/9] qpid-dispatch git commit: DISPATCH-437 - Work in progress
Date Thu, 11 Aug 2016 17:42:58 GMT
DISPATCH-437 - Work in progress


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

Branch: refs/heads/DISPATCH-437-1
Commit: 697d0c37dee445a6dcfd4519ef992124b46a6093
Parents: 0beb839
Author: Ganesh Murthy <gmurthy@redhat.com>
Authored: Fri Aug 5 10:34:39 2016 -0400
Committer: Ganesh Murthy <gmurthy@redhat.com>
Committed: Fri Aug 5 10:34:39 2016 -0400

----------------------------------------------------------------------
 config.sh                                       |   1 +
 doc/CMakeLists.txt                              |   2 +-
 doc/book/schema_txt.py                          |   6 +-
 doc/man/qdrouterd.conf.5.py                     |   7 +-
 .../management/agent/agent.py                   |  11 +-
 .../qpid_dispatch_internal/management/config.py |   4 +-
 .../management/schema/schema.py                 | 700 -------------------
 .../management/schema/schema_doc.py             |   2 +-
 router/src/main.c                               |   2 +
 src/CMakeLists.txt                              |   8 +-
 src/agent.c                                     |  31 +-
 src/schema_c.py                                 |   3 +-
 tools/qdstat                                    |   2 +-
 13 files changed, 48 insertions(+), 731 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/config.sh
----------------------------------------------------------------------
diff --git a/config.sh b/config.sh
index 7e5e97f..b96ecbf 100644
--- a/config.sh
+++ b/config.sh
@@ -30,4 +30,5 @@ PYTHON_LIB=$(python -c "from distutils.sysconfig import get_python_lib;
print ge
 
 export LD_LIBRARY_PATH=$INSTALL_DIR/lib64:$INSTALL_DIR/lib:$LD_LIBRARY_PATH
 export PYTHONPATH=$PYTHON_LIB:$PYTHONPATH
+echo 'PYTHONPATH' $PYTHONPATH
 export PATH=$INSTALL_DIR/sbin:$INSTALL_DIR/bin:$SOURCE_DIR/bin:$PATH

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/doc/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 62a80fd..3455c35 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -42,7 +42,7 @@ if(BUILD_DOCS)
   set(tools ${CMAKE_SOURCE_DIR}/tools)
   set(schema ../python/qpid_dispatch/management/qdrouter.json)
   set(py_management ../python/qpid_dispatch_internal/management)
-  set(schema_depends ${schema} ${py_management}/schema/schema_doc.py ${py_management}/schema/schema.py)
+  set(schema_depends ${schema} ${py_management}/schema/schema_doc.py ${py_management}/schema/qd_schema.py)
 
   # Flags for doc tools, based on cmake options
   set(ADOC_FLAGS "--conf-file=${bin}/asciidoc.conf")

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/doc/book/schema_txt.py
----------------------------------------------------------------------
diff --git a/doc/book/schema_txt.py b/doc/book/schema_txt.py
index 76c0246..0baad17 100644
--- a/doc/book/schema_txt.py
+++ b/doc/book/schema_txt.py
@@ -21,9 +21,9 @@
 Generate the schema.md chapter for the dispatch book from the qdrouter.json schema.
 """
 
-import sys, re
-from qpid_dispatch_internal.management.schema.schema import QdSchema
-from qpid_dispatch_internal.management.schema_doc import SchemaWriter
+import sys
+from qpid_dispatch_internal.management.schema.qd_schema import QdSchema
+from qpid_dispatch_internal.management.schema.schema_doc import SchemaWriter
 
 class BookSchemaWriter(SchemaWriter):
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/doc/man/qdrouterd.conf.5.py
----------------------------------------------------------------------
diff --git a/doc/man/qdrouterd.conf.5.py b/doc/man/qdrouterd.conf.5.py
index e71f7a1..faa07d8 100644
--- a/doc/man/qdrouterd.conf.5.py
+++ b/doc/man/qdrouterd.conf.5.py
@@ -22,11 +22,8 @@ Generate the qdrouterd.conf. man page from the qdrouterd management schema.
 """
 
 import sys
-from qpid_dispatch_internal.management.qdrouter import QdSchema
-from qpid_dispatch_internal.management.schema_doc import SchemaWriter
-from qpid_dispatch_internal.management.schema import AttributeType
-
-from qpid_dispatch_internal.compat import OrderedDict
+from qpid_dispatch_internal.management.schema.qd_schema import QdSchema
+from qpid_dispatch_internal.management.schema.schema_doc import SchemaWriter
 
 CONNECTOR = 'org.apache.qpid.dispatch.connector'
 LISTENER = 'org.apache.qpid.dispatch.listener'

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/python/qpid_dispatch_internal/management/agent/agent.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/agent/agent.py b/python/qpid_dispatch_internal/management/agent/agent.py
index a552296..be87f94 100644
--- a/python/qpid_dispatch_internal/management/agent/agent.py
+++ b/python/qpid_dispatch_internal/management/agent/agent.py
@@ -79,15 +79,14 @@ from cStringIO import StringIO
 from ctypes import c_void_p, py_object, c_long
 from subprocess import Popen
 
-from python.qpid_dispatch_internal.dispatch import IoAdapter, LogAdapter, LOG_INFO, LOG_WARNING,
LOG_DEBUG, LOG_ERROR, TREATMENT_ANYCAST_CLOSEST
+from qpid_dispatch_internal.dispatch import IoAdapter, LogAdapter, LOG_INFO, LOG_WARNING,
LOG_DEBUG, LOG_ERROR, TREATMENT_ANYCAST_CLOSEST
 from qpid_dispatch.management.error import ManagementError, OK, CREATED, NO_CONTENT, STATUS_TEXT,
\
     BadRequestStatus, InternalServerErrorStatus, NotImplementedStatus, NotFoundStatus, ForbiddenStatus
 from qpid_dispatch.management.entity import camelcase
-from python.qpid_dispatch_internal.management.schema.schema import ValidationError, SchemaEntity,
EntityType
-from schema.schema import QdSchema
-from python.qpid_dispatch_internal.router.message import Message
-from python.qpid_dispatch_internal.router.address import Address
-from python.qpid_dispatch_internal.policy.policy_manager import PolicyManager
+from qpid_dispatch_internal.management.schema.qd_schema import ValidationError, SchemaEntity,
EntityType, QdSchema
+from qpid_dispatch_internal.router.message import Message
+from qpid_dispatch_internal.router.address import Address
+from qpid_dispatch_internal.policy.policy_manager import PolicyManager
 
 
 def dictstr(d):

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/python/qpid_dispatch_internal/management/config.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/config.py b/python/qpid_dispatch_internal/management/config.py
index a3571cc..91833db 100644
--- a/python/qpid_dispatch_internal/management/config.py
+++ b/python/qpid_dispatch_internal/management/config.py
@@ -28,7 +28,7 @@ import os
 
 from qpid_dispatch.management.entity import camelcase
 from ..dispatch import QdDll
-from python.qpid_dispatch_internal.management.schema.qdrouter import QdSchema
+from qid_dispatch_internal.management.schema.schema import QdSchema
 
 
 class Config(object):
@@ -130,7 +130,7 @@ def configure_dispatch(dispatch, lib_handle, filename):
     config = Config(filename)
 
     # NOTE: Can't import agent till dispatch C extension module is initialized.
-    from python.qpid_dispatch_internal.management.agent.agent import Agent
+    from qpid_dispatch_internal.management.agent.agent import Agent
     agent = Agent(dispatch, qd)
     qd.qd_dispatch_set_agent(dispatch, agent)
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/python/qpid_dispatch_internal/management/schema/schema.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/schema/schema.py b/python/qpid_dispatch_internal/management/schema/schema.py
deleted file mode 100644
index 6f68f29..0000000
--- a/python/qpid_dispatch_internal/management/schema/schema.py
+++ /dev/null
@@ -1,700 +0,0 @@
-##
-## Licensed to the Apache Software Foundation (ASF) under one
-## or more contributor license agreements.  See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership.  The ASF licenses this file
-## to you under the Apache License, Version 2.0 (the
-## "License"); you may not use this file except in compliance
-## with the License.  You may obtain a copy of the License at
-##
-##   http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing,
-## software distributed under the License is distributed on an
-## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-## KIND, either express or implied.  See the License for the
-## specific language governing permissions and limitations
-## under the License
-##
-
-"""
-Schema for AMQP management entity types.
-
-Schema validation will validate and transform values, add default values and
-check for uniqueness of enties/attributes that are specified to be unique.
-
-A Schema can be loaded/dumped to a json file.
-"""
-
-import sys
-from qpid_dispatch.management.entity import EntityBase
-from qpid_dispatch.management.error import NotImplementedStatus
-from ...compat import OrderedDict, JSON_LOAD_KWARGS
-import json
-from pkgutil import get_data
-
-from python.qpid_dispatch_internal.management.schema import schema
-
-
-class ValidationError(Exception):
-    """Error raised if schema validation fails"""
-    pass
-
-def quotestr(value, quote="'"):
-    """Quote value if it is a string type, str() it if not """
-    if isinstance(value, basestring): return "'%s'" % value
-    else: return str(value)
-
-
-class Type(object):
-    """Base class for schema types.
-
-    @ivar name: The type name.
-    @ivar pytype: The python type for this schema type.
-    """
-    def __init__(self, name, pytype):
-        """
-        @param name: The type name.
-        @param pytype: The python type for this schema type.
-        """
-        self.name, self.pytype = name, pytype
-
-    def validate(self, value, **kwargs): # pylint: disable=unused-argument
-        """
-        Convert value to the correct python type.
-
-        @param kwargs: See L{Schema.validate_all}
-        """
-        return self.pytype(value)
-
-    def dump(self):
-        """
-        @return: Representation of the type to dump to json. Normally the type name,
-            EnumType.dump is the exception.
-        """
-        return self.name
-
-    def __str__(self):
-        """String name of type."""
-        return str(self.dump())
-
-
-class BooleanType(Type):
-    """A boolean schema type"""
-
-    def __init__(self):
-        super(BooleanType, self).__init__("boolean", bool)
-
-    VALUES = {"yes":1, "true":1, "on":1, "no":0, "false":0, "off":0}
-
-    def validate(self, value, **kwargs):
-        """
-        @param value: A string such as "yes", "false" etc. is converted appropriately.
-            Any other type is converted using python's bool()
-        @param kwargs: See L{Schema.validate_all}
-        @return A python bool.
-        """
-        try:
-            if isinstance(value, basestring):
-                return self.VALUES[value.lower()]
-            return bool(value)
-        except:
-            raise ValidationError("Invalid Boolean value '%r'"%value)
-
-
-class EnumValue(str):
-    """A string that convets to an integer value via int()"""
-
-    def __new__(cls, name, value):
-        s = super(EnumValue, cls).__new__(cls, name)
-        setattr(s, 'value', value)
-        return s
-
-    def __int__(self): return self.value
-    def __eq__(self, x): return str(self) == x or int(self) == x
-    def __ne__(self, x): return not self == x
-    def __repr__(self): return "EnumValue('%s', %s)"%(str(self), int(self))
-
-
-class EnumType(Type):
-    """An enumerated type"""
-
-    def __init__(self, tags):
-        """
-        @param tags: A list of string values for the enumerated type.
-        """
-        assert isinstance(tags, list)
-        super(EnumType, self).__init__("enum%s"%([str(t) for t in tags]), int)
-        self.tags = tags
-
-    def validate(self, value, **kwargs):
-        """
-        @param value: May be a string from the set of enum tag strings or anything
-            that can convert to an int - in which case it must be in the enum range.
-        @param kwargs: See L{Schema.validate_all}
-        @return: An EnumValue.
-        """
-        if value in self.tags:
-            return EnumValue(value, self.tags.index(value))
-        else:
-            try:
-                i = int(value)
-                return EnumValue(self.tags[i], i)
-            except (ValueError, IndexError):
-                pass
-        raise ValidationError("Invalid value for %s: %r"%(self.name, value))
-
-    def dump(self):
-        """
-        @return: A list of the enum tags.
-        """
-        return self.tags
-
-    def __str__(self):
-        """String description of enum type."""
-        return "One of [%s]" % ', '.join([quotestr(tag) for tag in self.tags])
-
-BUILTIN_TYPES = OrderedDict(
-    (t.name, t) for t in [Type("string", str),
-                          Type("path", str),
-                          Type("entityId", str),
-                          Type("integer", int),
-                          Type("list", list),
-                          Type("map", dict),
-                          Type("dict", dict),
-                          BooleanType()])
-
-def get_type(rep):
-    """
-    Get a schema type.
-    @param rep: json representation of the type.
-    """
-    if isinstance(rep, list):
-        return EnumType(rep)
-    if rep in BUILTIN_TYPES:
-        return BUILTIN_TYPES[rep]
-    raise ValidationError("No such schema type: %s" % rep)
-
-def _dump_dict(items):
-    """
-    Remove all items with None value from a mapping.
-    @return: Map of non-None items.
-    """
-    return OrderedDict((k, v) for k, v in items if v)
-
-def _is_unique(found, item):
-    """
-    Return true if found is None or item is not in found (adds item to found.)
-    Return false if item is in found.
-    """
-    if found is None or found is False:
-        return True
-    if item not in found:
-        found.add(item)
-        return True
-    return False
-
-class AttributeType(object):
-    """
-    Definition of an attribute.
-
-    @ivar name: Attribute name.
-    @ivar atype: Attribute L{Type}
-    @ivar required: True if the attribute is required.
-    @ivar default: Default value for the attribute or None if no default. Can be a reference.
-    @ivar value: Fixed value for the attribute. Can be a reference.
-    @ivar unique: True if the attribute value is unique.
-    @ivar description: Description of the attribute type.
-    @ivar defined_in: EntityType in which this attribute is defined.
-    @ivar create: If true the attribute can be set by CREATE.
-    @ivar update: If true the attribute can be modified by UPDATE.
-    @ivar graph: If true the attribute could be graphed by a console.
-    """
-
-    def __init__(self, name, type=None, defined_in=None, default=None,
-                 required=False, unique=False, hidden=False, deprecated=False,
-                 value=None, description="", create=False, update=False, graph=False, ordinality=0):
-        """
-        See L{AttributeType} instance variables.
-        """
-        try:
-            self.name = name
-            self.type = type
-            self.defined_in = defined_in
-            self.atype = get_type(self.type)
-            self.required = required
-            self.hidden = hidden
-            self.deprecated = deprecated
-            self.default = default
-            self.value = value
-            self.unique = unique
-            self.description = description
-            self.ordinality = ordinality
-            if self.value is not None and self.default is not None:
-                raise ValidationError("Attribute '%s' has default value and fixed value"
%
-                                      self.name)
-            self.create=create
-            self.update=update
-            self.graph=graph
-        except:
-            ex, msg, trace = sys.exc_info()
-            raise ValidationError, "Attribute '%s': %s" % (name, msg), trace
-
-    def missing_value(self, check_required=True, add_default=True, **kwargs):
-        """
-        Fill in missing default and fixed values.
-        @keyword check_required: Raise an exception if required attributes are misssing.
-        @keyword add_default:  Add a default value for missing attributes.
-        @param kwargs: See L{Schema.validate_all}
-        """
-        if self.value is not None: # Fixed value attribute
-            return self.value
-        if add_default and self.default is not None:
-            return self.default
-        if check_required and self.required:
-            raise ValidationError("Missing required attribute '%s'" % (self.name))
-
-    def validate(self, value, check_unique=None, **kwargs):
-        """
-        Validate value for this attribute definition.
-        @param value: The value to validate.
-        @keyword check_unique: set of (name, value) to check for attribute uniqueness.
-            None means don't check for uniqueness.
-        @param create: if true, check that the attribute allows create
-        @param update: if true, check that the attribute allows update
-        @param kwargs: See L{Schema.validate_all}
-        @return: value converted to the correct python type. Rais exception if any check
fails.
-        """
-        if self.unique and not _is_unique(check_unique, (self.name, value)):
-            raise ValidationError("Duplicate value '%s' for unique attribute '%s'"%(value,
self.name))
-        if self.value and value != self.value:
-            raise ValidationError("Attribute '%s' has fixed value '%s' but given '%s'"%(
-                self.name, self.value, value))
-        try:
-            return self.atype.validate(value, **kwargs)
-        except (TypeError, ValueError), e:
-            raise ValidationError, str(e), sys.exc_info()[2]
-
-    def dump(self):
-        """
-        @return: Json-friendly representation of an attribute type
-        """
-        return _dump_dict([
-            ('type', self.atype.dump()),
-            ('default', self.default),
-            ('required', self.required),
-            ('unique', self.unique),
-            ('deprecated', self.deprecated),
-            ('description', self.description),
-            ('graph', self.graph)
-        ])
-
-    def __str__(self):
-        return self.name
-
-
-class MessageDef(object):
-    """A request or response message"""
-    def __init__(self, body=None, properties=None):
-        self.body = None
-        if body: self.body = AttributeType("body", **body)
-        self.properties = dict((name, AttributeType(name, **value))
-                               for name, value in (properties or {}).iteritems())
-
-
-class OperationDef(object):
-    """An operation definition"""
-    def __init__(self, name, description=None, request=None, response=None):
-        try:
-            self.name = name
-            self.description = description
-            self.request = self.response = None
-            if request: self.request = MessageDef(**request)
-            if response: self.response = MessageDef(**response)
-        except:
-            ex, msg, trace = sys.exc_info()
-            raise ValidationError, "Operation '%s': %s" % (name, msg), trace
-
-
-class EntityType(object):
-    """
-    An entity type defines a set of attributes for an entity.
-
-    @ivar name: Fully qualified entity type name.
-    @ivar short_name: Un-prefixed short name.
-    @ivar attributes: Map of L{AttributeType} for entity.
-    @ivar singleton: If true only one entity of this type is allowed.
-    @ivar referential: True if an entity can be referred to by name from another entity.
-    """
-    def __init__(self, name, schema, attributes=None, operations=None, operationDefs=None,
description="",
-                 fullName=True, singleton=False, deprecated=False, extends=None, referential=False,
ordinality=0, **kwargs):
-        """
-        @param name: name of the entity type.
-        @param schema: schema for this type.
-        @param singleton: True if entity type is a singleton.
-        @param attributes: Map of attributes {name: {type:, default:, required:, unique:}}
-        @param description: Human readable description.
-        @param operations: Allowed operations, list of operation names.
-        """
-        try:
-            self.schema = schema
-            self.description = description
-            if fullName:
-                self.name = schema.long_name(name)
-                self.short_name = schema.short_name(name)
-
-                if self.short_name.startswith("router.config."):
-                    self.short_name = self.short_name.replace("router.config.", "")
-            else:
-                self.name = self.short_name = name
-
-            self.attributes = OrderedDict((k, AttributeType(k, defined_in=self, **v))
-                                          for k, v in (attributes or {}).iteritems())
-            self.operations = operations or []
-            # Bases are resolved in self.init()
-            self.base = extends
-            self.all_bases = []
-
-            self.references = []
-            self.singleton = singleton
-            self.deprecated = deprecated
-            self.referential = referential
-            self.ordinality = ordinality
-            self._init = False      # Have not yet initialized from base and attributes.
-            # Operation definitions
-            self.operation_defs = dict((name, OperationDef(name, **op))
-                                  for name, op in (operationDefs or {}).iteritems())
-        except:
-            ex, msg, trace = sys.exc_info()
-            raise ValidationError, "%s '%s': %s" % (type(self).__name__, name, msg), trace
-
-    def init(self):
-        """Find bases after all types are loaded."""
-        if self._init: return
-        self._init = True
-        if self.base:
-            self.base = self.schema.entity_type(self.base)
-            self.base.init()
-            self.all_bases = [self.base] + self.base.all_bases
-            self._extend(self.base, 'extend')
-
-    def _extend(self, other, how):
-        """Add attributes and operations from other"""
-        def check(a, b, what):
-            overlap = set(a) & set(b)
-            if overlap:
-                raise ValidationError("'%s' cannot %s '%s', re-defines %s: %s"
-                                      % (self.name, how, other.short_name, what, ",".join(overlap)))
-        check(self.operations, other.operations, "operations")
-        self.operations += other.operations
-        check(self.attributes.iterkeys(), other.attributes.itervalues(), "attributes")
-        self.attributes.update(other.attributes)
-
-        if other.name == 'entity':
-            # Fill in entity "type" attribute automatically.
-            self.attributes["type"]["value"] = self.name
-
-        ordinality = 0
-        for attrib in self.attributes.values():
-            attrib.ordinality = ordinality
-            ordinality += 1
-
-    def extends(self, base):
-        return base in self.all_bases
-
-    def is_a(self, type):
-        return type == self or self.extends(type)
-
-    def attribute(self, name):
-        """Get the AttributeType for name"""
-        if not name in self.attributes:
-            raise ValidationError("Unknown attribute '%s' for '%s'" % (name, self))
-        return self.attributes[name]
-
-    @property
-    def my_attributes(self):
-        """Return only attribute types defined in this entity type"""
-        return [a for a in self.attributes.itervalues() if a.defined_in == self]
-
-    def validate(self, attributes, check_singleton=None, **kwargs):
-        """
-        Validate attributes for entity type.
-        @param attributes: Map attributes name:value or Entity with attributes property.
-            Modifies attributes: adds defaults, converts values.
-        @param check_singleton: set of entity-type name to enable singleton checking.
-            None to disable.
-        @param kwargs: See L{Schema.validate_all}
-        """
-
-        if isinstance(attributes, SchemaEntity): attributes = attributes.attributes
-
-        if self.singleton and not _is_unique(check_singleton, self.name):
-            raise ValidationError("Multiple instances of singleton '%s'"%self.name)
-        try:
-            # Add missing values
-            for attr in self.attributes.itervalues():
-                if attributes.get(attr.name) is None:
-                    value = attr.missing_value(**kwargs)
-                    if value is not None: attributes[attr.name] = value
-                    if value is None and attr.name in attributes:
-                        del attributes[attr.name]
-
-            # Validate attributes.
-            for name, value in attributes.iteritems():
-                if name == 'type':
-                    value = self.schema.long_name(value)
-                attributes[name] = self.attribute(name).validate(value, **kwargs)
-        except ValidationError, e:
-            raise  ValidationError, "%s: %s"%(self, e), sys.exc_info()[2]
-
-        return attributes
-
-    def allowed(self, op):
-        """Raise exception if op is not a valid operation on entity."""
-        op = op.upper()
-        if not op in self.operations:
-            raise NotImplementedStatus("Operation '%s' not implemented for '%s' %s" % (
-                op, self.name, self.operations))
-
-    def create_check(self, attributes):
-        for a in attributes:
-            if not self.attribute(a).create:
-                raise ValidationError("Cannot set attribute '%s' in CREATE" % a)
-
-    def update_check(self, new_attributes, old_attributes):
-        for a, v in new_attributes.iteritems():
-            # Its not an error to include an attribute in UPDATE if the value is not changed.
-            if not self.attribute(a).update and \
-               not (a in old_attributes and old_attributes[a] == v):
-                raise ValidationError("Cannot update attribute '%s' in UPDATE" % a)
-
-    def dump(self):
-        """Json friendly representation"""
-        return _dump_dict([
-            ('attributes', OrderedDict(
-                (k, v.dump()) for k, v in self.attributes.iteritems()
-                if k != 'type')), # Don't dump 'type' attribute, dumped separately.
-            ('operations', self.operations),
-            ('description', self.description or None),
-            ('fullyQualifiedType', self.name or None),
-            ('references', self.references),
-            ('deprecated', self.deprecated),
-            ('singleton', self.singleton)
-        ])
-
-    def __repr__(self):
-        return "%s(%s)" % (type(self).__name__, self.name)
-
-    def __str__(self):
-        return self.name
-
-    def name_is(self, name):
-        return self.name == self.schema.long_name(name)
-
-
-
-class Schema(object):
-    """
-    Schema defining entity types.
-    Note: keyword arguments come from schema so use camelCase
-
-    @ivar prefix: Prefix to prepend to short entity type names.
-    @ivar entityTypes: Map of L{EntityType} by name.
-    @ivar description: Text description of schema.
-    """
-    def __init__(self, prefix="", entityTypes=None, description=""):
-        """
-        @param prefix: Prefix for entity names.
-        @param entity_types: Map of  { entityTypeName: { singleton:, attributes:{...}}}
-        @param description: Human readable description.
-        """
-        if prefix:
-            self.prefix = prefix.strip('.')
-            self.prefixdot = self.prefix + '.'
-        else:
-            self.prefix = self.prefixdot = ""
-        self.description = description
-
-        def parsedefs(cls, defs):
-            return OrderedDict((self.long_name(k), cls(k, self, **v))
-                               for k, v in (defs or {}).iteritems())
-
-        self.entity_types = parsedefs(EntityType, entityTypes)
-
-        self.all_attributes = set()
-
-        ordinality = 0
-        for e in self.entity_types.itervalues():
-            e.init()
-            e.ordinality = ordinality
-            self.all_attributes.update(e.attributes.keys())
-            ordinality += 1
-
-    def short_name(self, name):
-        """Remove prefix from name if present"""
-        if not name:
-            return name
-        if name.startswith(self.prefixdot):
-            name = name[len(self.prefixdot):]
-        return name
-
-    def long_name(self, name):
-        """Add prefix to unqualified name"""
-        if not name:
-            return name
-        if not name.startswith(self.prefixdot):
-            name = self.prefixdot + name
-        return name
-
-    def is_long_name(self, name):
-        if not name:
-            return False
-        if self.prefixdot in name:
-            return True
-        return False
-
-    def dump(self):
-        """Return json-friendly representation"""
-        return OrderedDict([
-            ('prefix', self.prefix),
-            ('entityTypes',
-             OrderedDict((e.short_name, e.dump()) for e in self.entity_types.itervalues()))
-        ])
-
-    def _lookup(self, map, name, message, error):
-        found = map.get(name) or map.get(self.long_name(name))
-        if not found and error:
-            raise ValidationError(message % name)
-        return found
-
-    def entity_type(self, name, error=True):
-        return self._lookup(self.entity_types, name, "No such entity type '%s'", error)
-
-    def validate_entity(self, attributes, check_required=True, add_default=True,
-                        check_unique=None, check_singleton=None):
-        """
-        Validate a single entity.
-
-        @param attributes: Map of attribute name: value
-        @keyword check_required: Raise exception if required attributes are missing.
-        @keyword add_default: Add defaults for missing attributes.
-        @keyword check_unique: Used by L{validate_all}
-        @keyword check_singleton: Used by L{validate_all}
-        """
-        attributes['type'] = self.long_name(attributes['type'])
-        entity_type = self.entity_type(attributes['type'])
-        entity_type.validate(
-            attributes,
-            check_required=check_required,
-            add_default=add_default,
-            check_unique=check_unique,
-            check_singleton=check_singleton)
-
-    def validate_all(self, attribute_maps, check_required=True, add_default=True,
-                     check_unique=True, check_singleton=True):
-        """
-        Validate a list of attribute maps representing entity attributes.
-        Verify singleton entities and unique attributes are unique.
-        Modifies attribute_maps, adds default values, converts values.
-
-        @param attribute_maps: List of attribute name:value maps.
-        @keyword check_required: Raise exception if required attributes are missing.
-        @keyword add_default: Add defaults for missing attributes.
-        @keyword check_unique: Raise exception if unique attributes are duplicated.
-        @keyword check_singleton: Raise exception if singleton entities are duplicated
-        """
-        if check_singleton: check_singleton = set()
-        if check_unique: check_unique = set()
-
-        for e in attribute_maps:
-            self.validate_entity(e,
-                                 check_required=check_required,
-                                 add_default=add_default,
-                                 check_unique=check_unique,
-                                 check_singleton=check_singleton)
-
-    def entity(self, attributes):
-        """Convert an attribute map into an L{SchemaEntity}"""
-        attributes = dict((k, v) for k, v in attributes.iteritems() if v is not None)
-        return SchemaEntity(self.entity_type(attributes['type']), attributes)
-
-    def entities(self, attribute_maps):
-        """Convert a list of attribute maps into a list of L{SchemaEntity}"""
-        return [self.entity(m) for m in attribute_maps]
-
-    def filter(self, predicate):
-        """Return an iterator over entity types that satisfy predicate."""
-        if predicate is None: return self.entity_types.itervalues()
-        return (t for t in self.entity_types.itervalues() if predicate(t))
-
-    def by_type(self, type):
-        """Return an iterator over entity types that extend or are type.
-        If type is None return all entities."""
-        if not type:
-            return self.entity_types.itervalues()
-        else:
-            return self.filter(lambda t: t.is_a(type))
-
-
-class QdSchema(Schema):
-    """
-    Qpid Dispatch Router management schema.
-    """
-
-    CONFIGURATION_ENTITY = u"configurationEntity"
-    OPERATIONAL_ENTITY = u"operationalEntity"
-
-    def __init__(self):
-        """Load schema."""
-        qd_schema = get_data('qpid_dispatch.management', 'qdrouter.json')
-        try:
-            super(QdSchema, self).__init__(**json.loads(qd_schema, **JSON_LOAD_KWARGS))
-        except Exception,e:
-            raise ValueError("Invalid schema qdrouter.json: %s" % e)
-        self.configuration_entity = self.entity_type(self.CONFIGURATION_ENTITY)
-        self.operational_entity = self.entity_type(self.OPERATIONAL_ENTITY)
-
-    def validate_full(self, entities, **kwargs):
-        """
-        In addition to L{schema.Schema.validate}, check the following:
-
-        listeners and connectors can only have role=inter-router if the
-        router has mode=interior.
-
-
-        @param entities: List of attribute name:value maps.
-        @param kwargs: See L{schema.Schema.validate}
-        """
-        entities = list(entities) # Need to traverse twice
-        super(QdSchema, self).validate_all(entities, **kwargs)
-        inter_router = not_interior = None
-        for e in entities:
-            if self.short_name(e.type) == "router" and e.mode != "interior":
-                not_interior = e.mode
-            if self.short_name(e.type) in ["listener", "connector"] and e.role == "inter-router":
-                inter_router = e
-            if not_interior and inter_router:
-                raise schema.ValidationError(
-                    "role='inter-router' only allowed with router mode='interior' for %s."
% inter_router)
-
-    def is_configuration(self, entity_type):
-        return entity_type and self.configuration_entity in entity_type.all_bases
-
-    def is_operational(self, entity_type):
-        return entity_type and self.operational_entity in entity_type.all_bases
-
-
-class SchemaEntity(EntityBase):
-    """A map of attributes associated with an L{EntityType}"""
-    def __init__(self, entity_type, attributes=None, validate=True, **kwattrs):
-        super(SchemaEntity, self).__init__(attributes, **kwattrs)
-        self.__dict__['entity_type'] = entity_type
-        self.attributes.setdefault('type', entity_type.name)
-        if validate: self.validate()
-
-    def _set(self, name, value):
-        super(SchemaEntity, self)._set(name, value)
-        self.validate()
-
-    def validate(self, **kwargs):
-        self.entity_type.validate(self.attributes, **kwargs)

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/python/qpid_dispatch_internal/management/schema/schema_doc.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/schema/schema_doc.py b/python/qpid_dispatch_internal/management/schema/schema_doc.py
index b65392a..308bf73 100644
--- a/python/qpid_dispatch_internal/management/schema/schema_doc.py
+++ b/python/qpid_dispatch_internal/management/schema/schema_doc.py
@@ -22,7 +22,7 @@
 from collections import namedtuple
 import sys
 
-from python.qpid_dispatch_internal.management.schema.schema import quotestr
+from .qd_schema import quotestr
 
 
 class SchemaWriter(object):

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/router/src/main.c
----------------------------------------------------------------------
diff --git a/router/src/main.c b/router/src/main.c
index fa895d4..d361653 100644
--- a/router/src/main.c
+++ b/router/src/main.c
@@ -108,6 +108,7 @@ static void check(int fd) {
 
 static void main_process(const char *config_path, const char *python_pkgdir, int fd)
 {
+    printf ("In main_process\n");
     qd_error_clear();
     struct stat st;
     if (stat(python_pkgdir, &st))
@@ -279,6 +280,7 @@ void usage(char **argv) {
 
 int main(int argc, char **argv)
 {
+    printf ("In main of dispatch\n");
     argv0 = argv[0];
     const char *config_path   = DEFAULT_CONFIG_PATH;
     const char *python_pkgdir = DEFAULT_DISPATCH_PYTHON_DIR;

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 310ebc9..7367e96 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -31,10 +31,10 @@ set(GENERATOR_DEPENDS ${GENERATOR_DEPENDS} ${GENERATOR_SRC})
 file (GLOB GENERATOR_SRC ${CMAKE_SOURCE_DIR}/python/qpid_dispatch/management/*.py)
 set(GENERATOR_DEPENDS ${GENERATOR_DEPENDS} ${GENERATOR_SRC})
 
-#add_custom_command (
-#  OUTPUT ${GENERATED_SOURCES}
-#  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/tests/run.py -s ${CMAKE_CURRENT_SOURCE_DIR}/schema_c.py
-#  DEPENDS ${GENERATOR_DEPENDS})
+add_custom_command (
+  OUTPUT ${GENERATED_SOURCES}
+  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/tests/run.py -s ${CMAKE_CURRENT_SOURCE_DIR}/schema_c.py
+  DEPENDS ${GENERATOR_DEPENDS})
 
 include_directories(
   ${CMAKE_CURRENT_SOURCE_DIR}

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/src/agent.c
----------------------------------------------------------------------
diff --git a/src/agent.c b/src/agent.c
index c050479..1540438 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -30,7 +30,8 @@
 #include "schema_enum.h"
 #include "compose_private.h"
 
-#define MANAGEMENT_MODULE "qpid_dispatch_internal.management"
+#define MANAGEMENT_INTERNAL_MODULE "qpid_dispatch_internal.management.agent"
+#define MANAGEMENT_MODULE "qpid_dispatch.management"
 
 //static PyObject *qd_post_management_request(PyObject *self,
 //                                            PyObject *args,
@@ -114,7 +115,7 @@ static PyMethodDef AgentAdapter_functions[] = {
 static PyTypeObject AgentAdapterType = {
     PyObject_HEAD_INIT(0)
     0,                              /* ob_size*/
-    MANAGEMENT_MODULE ".AgentAdapter",  /* tp_name*/
+    MANAGEMENT_INTERNAL_MODULE ".AgentAdapter",  /* tp_name*/
     sizeof(AgentAdapter),    /* tp_basicsize*/
     0,                              /* tp_itemsize*/
     0,                              /* tp_dealloc*/
@@ -198,28 +199,43 @@ static PyTypeObject AgentAdapterType = {
 
 qd_agent_t* qd_agent(qd_dispatch_t *qd, char *address, const char *config_path)
 {
+    printf("In qd_agent 1\n");
     //
     // Create a new instance of AgentAdapterType
     //
     AgentAdapterType.tp_new = PyType_GenericNew;
     PyType_Ready(&AgentAdapterType);
 
+    PyObject *module1 = PyImport_ImportModule(MANAGEMENT_MODULE);
     // Load the qpid_dispatch_internal.management Python module
-    PyObject *module = PyImport_ImportModule(MANAGEMENT_MODULE);
+    PyObject *module = PyImport_ImportModule(MANAGEMENT_INTERNAL_MODULE);
+
+    printf("In qd_agent 2\n");
+
+    if (!module1) {
+            printf("In qd_agent 2.1\n");
+        qd_error_py();
+        //qd_log(log_source, QD_LOG_CRITICAL, "Cannot load dispatch extension module '%s'",
MANAGEMENT_INTERNAL_MODULE);
+        abort();
+    }
 
     if (!module) {
+            printf("In qd_agent 2.0\n");
         qd_error_py();
-        //qd_log(log_source, QD_LOG_CRITICAL, "Cannot load dispatch extension module '%s'",
MANAGEMENT_MODULE);
+        //qd_log(log_source, QD_LOG_CRITICAL, "Cannot load dispatch extension module '%s'",
MANAGEMENT_INTERNAL_MODULE);
         abort();
     }
 
+
     PyTypeObject *agentAdapterType = &AgentAdapterType;
     Py_INCREF(agentAdapterType);
 
     //Use the "AgentAdapter" name to add the AgentAdapterType to the management
     PyModule_AddObject(module, "AgentAdapter", (PyObject*) &AgentAdapterType);
     PyObject *adapterType     = PyObject_GetAttrString(module, "AgentAdapter");
+    printf("In qd_agent 3\n");
     PyObject *adapterInstance = PyObject_CallObject(adapterType, 0);
+    printf("In qd_agent 4\n");
 
     //
     //Instantiate the new agent and return it
@@ -254,8 +270,11 @@ qd_agent_t* qd_agent(qd_dispatch_t *qd, char *address, const char *config_path)
 
 qd_error_t qd_agent_start(qd_agent_t *agent)
 {
+    printf("In qd_agent_start 0 \n");
     // Load the qpid_dispatch_internal.management Python module
-    PyObject *module = PyImport_ImportModule(MANAGEMENT_MODULE);
+    PyObject *module = PyImport_ImportModule(MANAGEMENT_INTERNAL_MODULE);
+
+    printf("In qd_agent_start 1\n");
 
     char *class = "ManagementAgent";
 
@@ -290,7 +309,7 @@ qd_error_t qd_agent_start(qd_agent_t *agent)
    PyObject* pyManagementInstance = PyInstance_New(pClass, pArgs, 0); QD_ERROR_PY_RET();
    printf("Hello world 3\n");
    if (!pyManagementInstance) {
-       qd_log(agent->log_source, QD_LOG_CRITICAL, "Cannot create instance of Python class
'%s.%s'", MANAGEMENT_MODULE, class);
+       qd_log(agent->log_source, QD_LOG_CRITICAL, "Cannot create instance of Python class
'%s.%s'", MANAGEMENT_INTERNAL_MODULE, class);
    }
    Py_DECREF(pArgs);
    Py_DECREF(pClass);

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/src/schema_c.py
----------------------------------------------------------------------
diff --git a/src/schema_c.py b/src/schema_c.py
index 092b41b..e8269e6 100644
--- a/src/schema_c.py
+++ b/src/schema_c.py
@@ -22,8 +22,7 @@ Generate C code from the router schema.
 """
 
 import re
-from qpid_dispatch_internal.management.schema import EnumType
-from qpid_dispatch_internal.management.qdrouter import QdSchema
+from qpid_dispatch_internal.management.schema.qd_schema import EnumType, QdSchema
 
 copyright="""/*
  * Licensed to the Apache Software Foundation (ASF) under one

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/697d0c37/tools/qdstat
----------------------------------------------------------------------
diff --git a/tools/qdstat b/tools/qdstat
index e2f341a..9ba01f4 100755
--- a/tools/qdstat
+++ b/tools/qdstat
@@ -28,7 +28,7 @@ import re
 from time import ctime
 import  qpid_dispatch_site
 from qpid_dispatch.management.client import Url, Node, Entity
-from qpid_dispatch_internal.management.qdrouter import QdSchema
+from qpid_dispatch_internal.management.schema.qd_schema import QdSchema
 from qpid_dispatch_internal.tools import Display, Header, Sorter, YN, Commas, TimeLong
 from qpid_dispatch_internal.tools.command import connection_options, main, OptionParser,
opts_ssl_domain, opts_sasl, \
         opts_url


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


Mime
View raw message