Do not try to show L3 agent action when enable_router is False

When enable_router settings is False, 'routers' panel is not
registered and URL resolver of L3 agent action in the network
agent table will result in a failure.
As a result, System Information panel cannot be displayed.

This commit adds a check whether the router panel is enabled or not.

Change-Id: I67aba79f61870b093d4c1d9c7527003704483d50
Closes-Bug: #1671785
This commit is contained in:
Akihiro Motoki 2017-03-13 08:51:54 +00:00
parent 1a1dd88904
commit f54c52418b

View File

@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.conf import settings
from django.core import urlresolvers
from django import template
from django.template import defaultfilters as filters
@ -179,6 +180,9 @@ class NetworkL3AgentRoutersLinkAction(tables.LinkAction):
verbose_name = _("View Routers")
def allowed(self, request, datum):
network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {})
if not network_config.get('enable_router', True):
return False
# Determine whether this action is allowed for the current request.
return datum.agent_type == "L3 agent"