From 973b7ea6b747c5a8b7e5b5511ea350448625a7f6 Mon Sep 17 00:00:00 2001 From: Anderson Mesquita Date: Tue, 16 Dec 2014 15:10:18 -0800 Subject: [PATCH] Fix doc generation for Rackspace::Cloud::Network Since contrib plugins may not be installed at the time the docs are generated, the resource_mapping function needs to return all resource types defined by the resource module. To selectively load such resource types - based on requirements being met, for instance, the available_resource_mapping function should be used instead. This makes the necessary changes to Rackspace::Cloud::Network so that its docs are generated correctly. Related-Bug: 1403897 Change-Id: I7c12c055924e7a16a5b9cc573d91c12089a2395d --- .../rackspace/resources/cloudnetworks.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/contrib/rackspace/rackspace/resources/cloudnetworks.py b/contrib/rackspace/rackspace/resources/cloudnetworks.py index 8f4effeb6..4769fcc05 100644 --- a/contrib/rackspace/rackspace/resources/cloudnetworks.py +++ b/contrib/rackspace/rackspace/resources/cloudnetworks.py @@ -24,17 +24,13 @@ from heat.openstack.common import log as logging try: from pyrax.exceptions import NotFound # noqa + PYRAX_INSTALLED = True except ImportError: + PYRAX_INSTALLED = False class NotFound(Exception): """Dummy pyrax exception - only used for testing.""" - def resource_mapping(): - return {} -else: - - def resource_mapping(): - return {'Rackspace::Cloud::Network': CloudNetwork} LOG = logging.getLogger(__name__) @@ -137,3 +133,13 @@ class CloudNetwork(resource.Resource): if net: return unicode(getattr(net, name)) return "" + + +def resource_mapping(): + return {'Rackspace::Cloud::Network': CloudNetwork} + + +def available_resource_mapping(): + if PYRAX_INSTALLED: + return resource_mapping() + return {}