From 14024c870bdabcb0fb53c2c16ad32da7b3879d13 Mon Sep 17 00:00:00 2001 From: Victor Tapia Date: Wed, 3 Jun 2020 10:09:45 +0200 Subject: [PATCH] Fix DHCP status for DHCP relay (#1173) --- legacy/src/app/controllers/networks_list.js | 11 ++++++++++- legacy/src/app/controllers/node_details.js | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/legacy/src/app/controllers/networks_list.js b/legacy/src/app/controllers/networks_list.js index 05b1ce45d7..234db1dde3 100644 --- a/legacy/src/app/controllers/networks_list.js +++ b/legacy/src/app/controllers/networks_list.js @@ -286,11 +286,18 @@ function NetworksListController( $scope.newObject = null; }; - // Return the name name for the VLAN. + // Return the short name for the VLAN. $scope.getVLANName = function(vlan) { return VLANsManager.getName(vlan); }; + // Return the full name for the VLAN. + $scope.getFullVLANName = function(vlan_id) { + var vlan = VLANsManager.getItemFromList(vlan_id); + var fabric = FabricsManager.getItemFromList(vlan.fabric); + return FabricsManager.getName(fabric) + "." + VLANsManager.getName(vlan); + }; + // Return the name of the fabric from its given ID. $scope.getFabricNameById = function(fabricId) { return FabricsManager.getName(FabricsManager.getItemFromList(fabricId)); @@ -310,6 +317,8 @@ function NetworksListController( if (vlan.dhcp_on) { return "MAAS-provided"; + } else if (vlan.relay_vlan) { + return "Relayed via " + $scope.getFullVLANName(vlan.relay_vlan); } return "No DHCP"; diff --git a/legacy/src/app/controllers/node_details.js b/legacy/src/app/controllers/node_details.js index c1cc0af3cf..2f5cdae70a 100644 --- a/legacy/src/app/controllers/node_details.js +++ b/legacy/src/app/controllers/node_details.js @@ -1519,6 +1519,13 @@ function NodeDetailsController( return text; }; + // Return the full name for the VLAN. + $scope.getFullVLANName = function(vlan_id) { + var vlan = VLANsManager.getItemFromList(vlan_id); + var fabric = FabricsManager.getItemFromList(vlan.fabric); + return FabricsManager.getName(fabric) + "." + VLANsManager.getName(vlan); + }; + $scope.getDHCPStatus = iface => { const { vlans } = $scope; const vlan = vlans.find(vlan => vlan.id === iface.vlan_id); @@ -1529,7 +1536,10 @@ function NodeDetailsController( if (vlan.dhcp_on) { return "MAAS-provided"; + } else if (vlan.relay_vlan) { + return "Relayed via " + $scope.getFullVLANName(vlan.relay_vlan); } + } return "No DHCP"; };