From: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
Documentating the new API 'getAvailableHostPCIDevices', which uses
the existing backend host/devices with a new option.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
---
docs/API.md | 2 ++
src/kimchi/API.json | 6 ++++++
src/kimchi/i18n.py | 1 +
ui/js/src/kimchi.api.js | 14 ++++++++++++++
4 files changed, 23 insertions(+)
diff --git a/docs/API.md b/docs/API.md
index e022c9e..8b7e9ca 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -1013,6 +1013,8 @@ stats history
* _passthrough_affected_by: Filter the affected devices in the same
group of a certain directly assigned device.
The value should be the name of a device.
+ * _available_only: Filter to list only the host devices that are not
+ attached to a VM.
### Resource: Device
diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index e8da7d9..c7ea660 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -814,6 +814,12 @@
"type": "string",
"pattern": "^[_A-Za-z0-9-]+$",
"error": "KCHDEVS0003E"
+ },
+ "_available_only": {
+ "description": "List only devices that are not being
used by any other VM",
+ "type": "string",
+ "pattern": "^true|false$",
+ "error": "KCHDEVS0004E"
}
},
"additionalProperties": false,
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index 54750d9..0a3ebfa 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -45,6 +45,7 @@ messages = {
"KCHDEVS0001E": _('Unknown "_cap" specified'),
"KCHDEVS0002E": _('"_passthrough" should be "true"
or "false"'),
"KCHDEVS0003E": _('"_passthrough_affected_by" should be a
device name string'),
+ "KCHDEVS0004E": _('"_available" should be "true" or
"false"'),
"KCHDISKS0001E": _("Error while getting block devices. Details:
%(err)s"),
"KCHDISKS0002E": _("Error while getting block device information for
%(device)s."),
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index a7c3b2d..44f58d1 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -1179,6 +1179,20 @@ var kimchi = {
});
},
+ getAvailableHostPCIDevices : function(suc, err) {
+ kimchi.requestJSON({
+ url :
'host/devices?_passthrough=true&_cap=pci&_available_only=true',
+ type : 'GET',
+ contentType : 'application/json',
+ dataType : 'json',
+ resend : true,
+ success : suc,
+ error : err ? err : function(data) {
+ kimchi.message.error(data.responseJSON.reason);
+ }
+ });
+ },
+
getPCIDeviceCompanions : function(pcidev, suc, err) {
kimchi.requestJSON({
url : 'host/devices?_passthrough_affected_by=' + pcidev,
--
2.4.3