From: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
v2:
- fixed issue found by Aline
This patch set filters the VEPA interfaces to be used
in network creation by eliminating the ConnectX-4
cards.
Unit tests, docs and UI changes included.
Daniel Henrique Barboza (2):
Filter VEPA interfaces: adding 'module' to interfaces API
Filter VEPA interfaces: JS changes
control/interfaces.py | 3 ++-
docs/API.md | 2 ++
tests/test_rest.py | 2 +-
ui/js/src/kimchi.api.js | 14 ++++++++++++++
ui/js/src/kimchi.network_add_main.js | 12 ++++++++++--
5 files changed, 29 insertions(+), 4 deletions(-)
--
2.5.5
Show replies by date
From: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
This patch adds the 'module' key to the interfaces API. This
information was already being retrieved by the model but
the control class was ignoring it.
Docs and test changes included.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
---
control/interfaces.py | 3 ++-
docs/API.md | 2 ++
tests/test_rest.py | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/control/interfaces.py b/control/interfaces.py
index b04fc26..c65839a 100644
--- a/control/interfaces.py
+++ b/control/interfaces.py
@@ -43,4 +43,5 @@ class Interface(Resource):
'type': self.info['type'],
'ipaddr': self.info['ipaddr'],
'netmask': self.info['netmask'],
- 'status': self.info['status']}
+ 'status': self.info['status'],
+ 'module': self.info['module']}
diff --git a/docs/API.md b/docs/API.md
index 9d42c53..3a0cf02 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -663,6 +663,8 @@ A interface represents available interface on host.
* bonding: The combination of network interfaces on one host for redundancy
and/or increased throughput.
* bridge: A network device that connects multiple network segments.
+ * module: the name of the kernel module used to load this interface. Returns
+ 'unknown' if not applicable (ex: interface is a vlan).
* **POST**: *See Interface Actions*
diff --git a/tests/test_rest.py b/tests/test_rest.py
index b73d16c..c1294ee 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -1271,7 +1271,7 @@ class RestTests(unittest.TestCase):
resp = self.request('/plugins/kimchi/interfaces').read()
self.assertIn('name', resp)
interfaces = json.loads(resp)
- keys = ['name', 'type', 'ipaddr', 'netmask',
'status']
+ keys = ['name', 'type', 'ipaddr', 'netmask',
'status', 'module']
for interface in interfaces:
self.assertEquals(sorted(keys), sorted(interface.keys()))
--
2.5.5
From: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
This patch adds a new call in kimchi.api.js to fetch only
the interfaces that has VEPA support and changes
kimchi.network_add_main.js to call this new function
when network type is VEPA.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
---
ui/js/src/kimchi.api.js | 14 ++++++++++++++
ui/js/src/kimchi.network_add_main.js | 12 ++++++++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 3a94631..83d1cc7 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -634,6 +634,20 @@ var kimchi = {
});
},
+ getVEPAInterfaces : function(suc, err) {
+ wok.requestJSON({
+ url :
'plugins/kimchi/interfaces?module=^(?!mlx5_core|mlx5-core).*$',
+ type : 'GET',
+ contentType : 'application/json',
+ dataType : 'json',
+ resend : true,
+ success : suc,
+ error : err ? err : function(data) {
+ wok.message.error(data.responseJSON.reason);
+ }
+ });
+ },
+
deleteNetwork : function(name, suc, err) {
wok.requestJSON({
url : 'plugins/kimchi/networks/' + encodeURIComponent(name),
diff --git a/ui/js/src/kimchi.network_add_main.js b/ui/js/src/kimchi.network_add_main.js
index 4eb5c5b..e12f1df 100644
--- a/ui/js/src/kimchi.network_add_main.js
+++ b/ui/js/src/kimchi.network_add_main.js
@@ -169,7 +169,8 @@ kimchi.enableBridgeOptions = function(enable, networkType,
networkDestinationTyp
};
kimchi.loadInterfaces = function(interfaceFilterArray) {
- kimchi.getInterfaces(function(result) {
+
+ var loadInterfacesHTML = function(result) {
var options = [];
$selectDestination = $('#networkDestinationID');
var nics = {};
@@ -194,5 +195,12 @@ kimchi.loadInterfaces = function(interfaceFilterArray) {
$('#networkDestinationID').selectpicker('refresh');
kimchi.setDefaultNetworkType(result.length!==0);
kimchi.changeNetworkDestination();
- });
+ };
+
+ var networkType = $("#networkType").val();
+ if (networkType === kimchi.NETWORK_TYPE_VEPA) {
+ kimchi.getVEPAInterfaces(loadInterfacesHTML);
+ } else {
+ kimchi.getInterfaces(loadInterfacesHTML);
+ }
};
--
2.5.5
Applied. Thanks.
Regards,
Aline Manera