[PATCH v3][Kimchi] Issue: #1008 Issues while editing a VEPA network

The list of interfaces was being appended to a non-clean list. Just create it and add the results. Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- Changes: v3: Only list interfaces that are not being used when creating VEPA interface v2: Create empty result var ui/js/src/kimchi.api.js | 2 +- ui/js/src/kimchi.network_edit_main.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js index 55fd55f..3dccfe9 100644 --- a/ui/js/src/kimchi.api.js +++ b/ui/js/src/kimchi.api.js @@ -693,7 +693,7 @@ var kimchi = { getVEPAInterfaces : function(suc, err) { wok.requestJSON({ - url : 'plugins/kimchi/interfaces?module=^(?!mlx5_core|mlx5-core).*$', + url : 'plugins/kimchi/interfaces?_inuse=false&module=^(?!mlx5_core|mlx5-core).*$', type : 'GET', contentType : 'application/json', dataType : 'json', diff --git a/ui/js/src/kimchi.network_edit_main.js b/ui/js/src/kimchi.network_edit_main.js index 4dd830a..21f4c45 100644 --- a/ui/js/src/kimchi.network_edit_main.js +++ b/ui/js/src/kimchi.network_edit_main.js @@ -94,12 +94,13 @@ kimchi.setupNetworkFormEventForEdit = function(network) { var loadIfaces = function(interfaceFilterArray){ var buildInterfaceOpts = function(result) { var currentIfaces = network['interfaces']; + ifaces = []; for (var i = 0; i < currentIfaces.length; i++) { kimchi.getInterface(currentIfaces[i], function(iface) { - result.push(iface); + ifaces.push(iface); } , null, true); } - kimchi.createInterfacesOpts(result, interfaceFilterArray); + kimchi.createInterfacesOpts(ifaces, interfaceFilterArray); for (var i = 0; i < currentIfaces.length; i++) { $("#networkDestinationID option[value='" + currentIfaces[i] + "']").attr('selected','selected'); -- 2.7.4

Hi Ramon, I haven't tested this patch but it seems to have some issues: On 10/19/2016 01:22 PM, Ramon Medeiros wrote:
The list of interfaces was being appended to a non-clean list. Just create it and add the results.
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- Changes:
v3: Only list interfaces that are not being used when creating VEPA interface
v2: Create empty result var
ui/js/src/kimchi.api.js | 2 +- ui/js/src/kimchi.network_edit_main.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js index 55fd55f..3dccfe9 100644 --- a/ui/js/src/kimchi.api.js +++ b/ui/js/src/kimchi.api.js @@ -693,7 +693,7 @@ var kimchi = {
getVEPAInterfaces : function(suc, err) { wok.requestJSON({ - url : 'plugins/kimchi/interfaces?module=^(?!mlx5_core|mlx5-core).*$', + url : 'plugins/kimchi/interfaces?_inuse=false&module=^(?!mlx5_core|mlx5-core).*$', type : 'GET', contentType : 'application/json', dataType : 'json', diff --git a/ui/js/src/kimchi.network_edit_main.js b/ui/js/src/kimchi.network_edit_main.js index 4dd830a..21f4c45 100644 --- a/ui/js/src/kimchi.network_edit_main.js +++ b/ui/js/src/kimchi.network_edit_main.js @@ -94,12 +94,13 @@ kimchi.setupNetworkFormEventForEdit = function(network) { var loadIfaces = function(interfaceFilterArray){ var buildInterfaceOpts = function(result) { var currentIfaces = network['interfaces'];
+ ifaces = []; for (var i = 0; i < currentIfaces.length; i++) { kimchi.getInterface(currentIfaces[i], function(iface) { - result.push(iface); + ifaces.push(iface); } , null, true); } - kimchi.createInterfacesOpts(result, interfaceFilterArray); + kimchi.createInterfacesOpts(ifaces, interfaceFilterArray);
for (var i = 0; i < currentIfaces.length; i++) { $("#networkDestinationID option[value='" + currentIfaces[i] + "']").attr('selected','selected');
The 'result' variable will be a list of all unused interfaces available, ie, it will not contain the value of 'currentIfaces'. If you remove 'result' from the code, you will only list the interfaces in use by this given VEPA network. So how will user change the VEPA interfaces to other not in use? For me, the above changes are not needed! (but again, I have not tested this patch - I am just saying what I can see from this patch). Have you tested it? Is it working as expected with this patch?

Have tested in a machine with 3 interfaces. 1) Interfaces are not being listed twice 2) When creating VEPA network, only unused interfaces are listed On 10/19/2016 02:22 PM, Aline Manera wrote:
e a list of all unused interfaces available, ie, it will not contain the value of 'currentIfaces'.
-- Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com

On 10/19/2016 02:44 PM, Ramon Medeiros wrote:
Have tested in a machine with 3 interfaces.
1) Interfaces are not being listed twice
2) When creating VEPA network, only unused interfaces are listed
Does the same happen when editing a VEPA network?
On 10/19/2016 02:22 PM, Aline Manera wrote:
e a list of all unused interfaces available, ie, it will not contain the value of 'currentIfaces'.
--
Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com

On 10/20/2016 01:05 PM, Aline Manera wrote:
On 10/19/2016 02:44 PM, Ramon Medeiros wrote:
Have tested in a machine with 3 interfaces.
1) Interfaces are not being listed twice
2) When creating VEPA network, only unused interfaces are listed
Does the same happen when editing a VEPA network?
Yeah, tested on VEPA
On 10/19/2016 02:22 PM, Aline Manera wrote:
e a list of all unused interfaces available, ie, it will not contain the value of 'currentIfaces'.
--
Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com
-- Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com

Hi Ramon, I've just tested this patch and I confirmed what I described earlier. When creating a new VEPA network, all the unused interfaces are listed (in my case, eth0 and eth3). But when editing it, only the interfaces already set for the given network is shown (eth1 and eth2). The interfaces eth0 and eth3 should also be displayed when editing the network. You can check the screenshots below: On 10/20/2016 01:20 PM, Ramon Medeiros wrote:
On 10/20/2016 01:05 PM, Aline Manera wrote:
On 10/19/2016 02:44 PM, Ramon Medeiros wrote:
Have tested in a machine with 3 interfaces.
1) Interfaces are not being listed twice
2) When creating VEPA network, only unused interfaces are listed
Does the same happen when editing a VEPA network?
Yeah, tested on VEPA
On 10/19/2016 02:22 PM, Aline Manera wrote:
e a list of all unused interfaces available, ie, it will not contain the value of 'currentIfaces'.
--
Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com
--
Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com
participants (2)
-
Aline Manera
-
Ramon Medeiros