Author: aconway Date: Thu Jan 8 15:19:11 2015 New Revision: 1650307 URL: http://svn.apache.org/r1650307 Log: DISPATCH-95: Connector and listener identity does not show address and port.
Previously connectors and listeners were identified using a counter, e.g. "listener/0" Now they are identified by host and port, e.g. "listener/0.0.0.0:amqp" Modified: qpid/dispatch/trunk/config.sh qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py qpid/dispatch/trunk/python/qpid_dispatch_internal/management/schema.py qpid/dispatch/trunk/tests/system_tests_management.py Modified: qpid/dispatch/trunk/config.sh URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/config.sh?rev=1650307&r1=1650306&r2=1650307&view=diff ============================================================================== --- qpid/dispatch/trunk/config.sh (original) +++ qpid/dispatch/trunk/config.sh Thu Jan 8 15:19:11 2015 @@ -23,8 +23,8 @@ if [[ ! -f config.sh ]]; then fi export SOURCE_DIR=$(pwd) -export BUILD_DIR=$SOURCE_DIR/build -export INSTALL_DIR=$SOURCE_DIR/install +export BUILD_DIR=$SOURCE_DIR/${1:-build} +export INSTALL_DIR=$SOURCE_DIR/${2:-install} PYTHON_LIB=$(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(prefix='$INSTALL_DIR')") Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py?rev=1650307&r1=1650306&r2=1650307&view=diff ============================================================================== --- qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py (original) +++ qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py Thu Jan 8 15:19:11 2015 @@ -111,15 +111,15 @@ class AgentEntity(SchemaEntity): # Set default identity and name if not already set. prefix = self.entity_type.short_name + "/" if self.attributes.get('identity') is None: - self.attributes['identity'] = prefix + str(self._identifier(self.attributes)) + self.attributes['identity'] = prefix + str(self._identifier()) elif not self.attributes['identity'].startswith(prefix): self.attributes['identity'] = prefix + self.attributes['identity'] self.attributes.setdefault('name', self.attributes['identity']) super(AgentEntity, self).validate() - def _identifier(self, attributes): + def _identifier(self): """ - Generate identifier from attributes. identity=type/identifier. + Generate identifier. identity=type/identifier. Default is per-type counter, derived classes can override. """ try: counter = type(self)._identifier_count @@ -185,8 +185,8 @@ class RouterEntity(AgentEntity): # FIXME aconway 2014-12-19: clean this up. self._set_pointer(self._dispatch) - def _identifier(self, attributes): - return attributes.get('routerId') + def _identifier(self): + return self.attributes.get('routerId') def create(self): self._qd.qd_dispatch_configure_router(self._dispatch, self) @@ -200,7 +200,7 @@ class LogEntity(AgentEntity): attributes = dict(defaults, **attributes) super(LogEntity, self).__init__(agent, entity_type, attributes, validate=True) - def _identifier(self, attributes): return attributes.get('module') + def _identifier(self): return self.attributes.get('module') def create(self): self._qd.qd_log_entity(self) @@ -212,17 +212,25 @@ class LogEntity(AgentEntity): """Can't actually delete a log source but return it to the default state""" self._qd.qd_log_source_reset(self.attributes['module']) +def _addr_port_identifier(entity): + for attr in ['addr', 'port']: # Set default values if need be + entity.attributes.setdefault( + attr, entity.entity_type.attribute(attr).missing_value()) + return "%s:%s" % (entity.attributes['addr'], entity.attributes['port']) + class ListenerEntity(AgentEntity): def create(self): self._qd.qd_dispatch_configure_listener(self._dispatch, self) self._qd.qd_connection_manager_start(self._dispatch) + def _identifier(self): return _addr_port_identifier(self) class ConnectorEntity(AgentEntity): def create(self): self._qd.qd_dispatch_configure_connector(self._dispatch, self) self._qd.qd_connection_manager_start(self._dispatch) + def _identifier(self): return _addr_port_identifier(self) class FixedAddressEntity(AgentEntity): def create(self): Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/management/schema.py URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/schema.py?rev=1650307&r1=1650306&r2=1650307&view=diff ============================================================================== --- qpid/dispatch/trunk/python/qpid_dispatch_internal/management/schema.py (original) +++ qpid/dispatch/trunk/python/qpid_dispatch_internal/management/schema.py Thu Jan 8 15:19:11 2015 @@ -207,7 +207,8 @@ class AttributeType(object): self.description = description self.annotation = annotation if self.value is not None and self.default is not None: - raise ValidationError("Attribute '%s' has default value and fixed value"%self.name) + raise ValidationError("Attribute '%s' has default value and fixed value" % + self.name) def missing_value(self, check_required=True, add_default=True, **kwargs): """ @@ -221,8 +222,7 @@ class AttributeType(object): 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)) - + raise ValidationError("Missing required attribute '%s'" % (self.name)) def validate(self, value, resolve=lambda x: x, check_unique=None, **kwargs): """ @@ -403,6 +403,11 @@ class EntityType(AttrsAndOps): raise ValidationError("Unresolved circular reference '%s'"%values) values.append(value) + 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] def validate(self, attributes, check_singleton=None, **kwargs): """ @@ -429,11 +434,9 @@ class EntityType(AttrsAndOps): # Validate attributes. for name, value in attributes.iteritems(): - if name not in self.attributes: - raise ValidationError("%s has unknown attribute '%s'"%(self, name)) if name == 'type': value = self.schema.long_name(value) - attributes[name] = self.attributes[name].validate( + attributes[name] = self.attribute(name).validate( value, lambda v: self.resolve(v, attributes), **kwargs) except ValidationError, e: raise ValidationError, "%s: %s"%(self, e), sys.exc_info()[2] @@ -493,6 +496,7 @@ class Schema(object): 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 Modified: qpid/dispatch/trunk/tests/system_tests_management.py URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_tests_management.py?rev=1650307&r1=1650306&r2=1650307&view=diff ============================================================================== --- qpid/dispatch/trunk/tests/system_tests_management.py (original) +++ qpid/dispatch/trunk/tests/system_tests_management.py Thu Jan 8 15:19:11 2015 @@ -224,6 +224,13 @@ class ManagementTest(system_test.TestCas self.assert_create_ok(*c) assert retry(lambda: self.router.is_connected, wp_router.ports[0]) + # Verify the entities + id = 'connector/0.0.0.0:%s' % wp_router.ports[0] + connector = self.node.read(identity=id) + self.assertEqual( + [connector.name, connector.addr, connector.port, connector.role], + ['wp_connector', '0.0.0.0', str(wp_router.ports[0]), 'on-demand']) + # Send a message through self.router, verify it goes via wp_router address=self.router.addresses[0]+"/foo" mr = self.messenger() @@ -249,7 +256,8 @@ class ManagementTest(system_test.TestCas self.assertEqual('l0', entity.name) self.assertEqual(str(self.router.ports[0]), entity.port) - entity = self.node.read(type=LISTENER, identity='listener/1') + entity = self.node.read( + type=LISTENER, identity='listener/0.0.0.0:%s' % self.router.ports[1]) self.assertEqual('l1', entity.name) self.assertEqual(str(self.router.ports[1]), entity.port) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org