From 5ca99316f287e22d149e48992b1c033532636363 Mon Sep 17 00:00:00 2001 From: Ming He Date: Mon, 11 Jan 2016 18:07:48 -0800 Subject: [PATCH] fix external nic name miss match bug Change-Id: I5a490cf381fd13c674717e1360de2066e24e9faa --- .../app/controllers/wizardController.coffee | 24 +++++++++++-------- .../src/app/controllers/wizardController.js | 21 ++++++++++------ 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/v2.5/src/app/controllers/wizardController.coffee b/v2.5/src/app/controllers/wizardController.coffee index 6d91087..ae1faa5 100644 --- a/v2.5/src/app/controllers/wizardController.coffee +++ b/v2.5/src/app/controllers/wizardController.coffee @@ -333,16 +333,20 @@ define(['./baseController'], ()-> $scope.updateExternalNetwork = (network_name) -> nic = $scope.external[network_name] - $scope.ips[network_name].cidr = $scope.interfaces[nic].subnet - $scope.ips[network_name].start = $scope.ips[network_name].cidr.split('.').slice(0,3).join('.') + - '.' + $scope.ips[network_name].start.split('.')[3] - $scope.ips[network_name].end = $scope.ips[network_name].cidr.split('.').slice(0,3).join('.') + - '.' + $scope.ips[network_name].end.split('.')[3] - if network_name == 'external' - $scope.ips.external.public_vip = $scope.ips[network_name].cidr.split('.').slice(0,3).join('.') + - '.' + $scope.ips.external.public_vip.split('.')[3] - $scope.ips.external.gw_ip = $scope.ips[network_name].cidr.split('.').slice(0,3).join('.') + - '.' + $scope.ips.external.gw_ip.split('.')[3] + try + if $scope.interfaces[nic] + $scope.ips[network_name].cidr = $scope.interfaces[nic].subnet + $scope.ips[network_name].start = $scope.ips[network_name].cidr.split('.').slice(0,3).join('.') + + '.' + $scope.ips[network_name].start.split('.')[3] + $scope.ips[network_name].end = $scope.ips[network_name].cidr.split('.').slice(0,3).join('.') + + '.' + $scope.ips[network_name].end.split('.')[3] + if network_name == 'external' + $scope.ips.external.public_vip = $scope.ips[network_name].cidr.split('.').slice(0,3).join('.') + + '.' + $scope.ips.external.public_vip.split('.')[3] + $scope.ips.external.gw_ip = $scope.ips[network_name].cidr.split('.').slice(0,3).join('.') + + '.' + $scope.ips.external.gw_ip.split('.')[3] + catch error + console.log(error) return defaultCfg = -> diff --git a/v2.5/target/src/app/controllers/wizardController.js b/v2.5/target/src/app/controllers/wizardController.js index b3db457..45241b0 100644 --- a/v2.5/target/src/app/controllers/wizardController.js +++ b/v2.5/target/src/app/controllers/wizardController.js @@ -428,14 +428,21 @@ } }; $scope.updateExternalNetwork = function(network_name) { - var nic; + var error, nic; nic = $scope.external[network_name]; - $scope.ips[network_name].cidr = $scope.interfaces[nic].subnet; - $scope.ips[network_name].start = $scope.ips[network_name].cidr.split('.').slice(0, 3).join('.') + '.' + $scope.ips[network_name].start.split('.')[3]; - $scope.ips[network_name].end = $scope.ips[network_name].cidr.split('.').slice(0, 3).join('.') + '.' + $scope.ips[network_name].end.split('.')[3]; - if (network_name === 'external') { - $scope.ips.external.public_vip = $scope.ips[network_name].cidr.split('.').slice(0, 3).join('.') + '.' + $scope.ips.external.public_vip.split('.')[3]; - $scope.ips.external.gw_ip = $scope.ips[network_name].cidr.split('.').slice(0, 3).join('.') + '.' + $scope.ips.external.gw_ip.split('.')[3]; + try { + if ($scope.interfaces[nic]) { + $scope.ips[network_name].cidr = $scope.interfaces[nic].subnet; + } + $scope.ips[network_name].start = $scope.ips[network_name].cidr.split('.').slice(0, 3).join('.') + '.' + $scope.ips[network_name].start.split('.')[3]; + $scope.ips[network_name].end = $scope.ips[network_name].cidr.split('.').slice(0, 3).join('.') + '.' + $scope.ips[network_name].end.split('.')[3]; + if (network_name === 'external') { + $scope.ips.external.public_vip = $scope.ips[network_name].cidr.split('.').slice(0, 3).join('.') + '.' + $scope.ips.external.public_vip.split('.')[3]; + $scope.ips.external.gw_ip = $scope.ips[network_name].cidr.split('.').slice(0, 3).join('.') + '.' + $scope.ips.external.gw_ip.split('.')[3]; + } + } catch (_error) { + error = _error; + console.log(error); } }; defaultCfg = function() {