mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-08 00:04:14 +00:00
add PVE.Utils.forEachBus and use it in qemu/HardwareView
this iterates over all busses or over the ones you specify ( a single or an array ) Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
e31690fac0
commit
abe824aa95
@ -894,6 +894,37 @@ Ext.define('PVE.Utils', { utilities: {
|
|||||||
callback(evt.target.result);
|
callback(evt.target.result);
|
||||||
};
|
};
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
|
},
|
||||||
|
|
||||||
|
bus_counts: { ide: 4, sata: 6, scsi: 16, virtio: 16 },
|
||||||
|
|
||||||
|
// types is either undefined (all busses), an array of busses, or a single bus
|
||||||
|
forEachBus: function(types, func) {
|
||||||
|
var busses = Object.keys(PVE.Utils.bus_counts);
|
||||||
|
var i, j, count, cont;
|
||||||
|
|
||||||
|
if (Ext.isArray(types)) {
|
||||||
|
busses = types;
|
||||||
|
} else if (Ext.isDefined(types)) {
|
||||||
|
busses = [ types ];
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if we only have valid busses
|
||||||
|
for (i = 0; i < busses.length; i++) {
|
||||||
|
if (!PVE.Utils.bus_counts[busses[i]]) {
|
||||||
|
throw "invalid bus: '" + busses[i] + "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < busses.length; i++) {
|
||||||
|
count = PVE.Utils.bus_counts[busses[i]];
|
||||||
|
for (j = 0; j < count; j++) {
|
||||||
|
cont = func(busses[i], j);
|
||||||
|
if (!cont && cont !== undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -147,8 +147,8 @@ Ext.define('PVE.qemu.HardwareView', {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
PVE.Utils.forEachBus(undefined, function(type, id) {
|
||||||
confid = "ide" + i.toString();
|
var confid = type + id;
|
||||||
rows[confid] = {
|
rows[confid] = {
|
||||||
group: 1,
|
group: 1,
|
||||||
tdCls: 'pve-itype-icon-storage',
|
tdCls: 'pve-itype-icon-storage',
|
||||||
@ -157,40 +157,7 @@ Ext.define('PVE.qemu.HardwareView', {
|
|||||||
header: gettext('Hard Disk') + ' (' + confid +')',
|
header: gettext('Hard Disk') + ' (' + confid +')',
|
||||||
cdheader: gettext('CD/DVD Drive') + ' (' + confid +')'
|
cdheader: gettext('CD/DVD Drive') + ' (' + confid +')'
|
||||||
};
|
};
|
||||||
}
|
});
|
||||||
for (i = 0; i < 6; i++) {
|
|
||||||
confid = "sata" + i.toString();
|
|
||||||
rows[confid] = {
|
|
||||||
group: 1,
|
|
||||||
tdCls: 'pve-itype-icon-storage',
|
|
||||||
editor: 'PVE.qemu.HDEdit',
|
|
||||||
never_delete: caps.vms['VM.Config.Disk'] ? false : true,
|
|
||||||
header: gettext('Hard Disk') + ' (' + confid +')',
|
|
||||||
cdheader: gettext('CD/DVD Drive') + ' (' + confid +')'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
for (i = 0; i < 16; i++) {
|
|
||||||
confid = "scsi" + i.toString();
|
|
||||||
rows[confid] = {
|
|
||||||
group: 1,
|
|
||||||
tdCls: 'pve-itype-icon-storage',
|
|
||||||
editor: 'PVE.qemu.HDEdit',
|
|
||||||
never_delete: caps.vms['VM.Config.Disk'] ? false : true,
|
|
||||||
header: gettext('Hard Disk') + ' (' + confid +')',
|
|
||||||
cdheader: gettext('CD/DVD Drive') + ' (' + confid +')'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
for (i = 0; i < 16; i++) {
|
|
||||||
confid = "virtio" + i.toString();
|
|
||||||
rows[confid] = {
|
|
||||||
group: 1,
|
|
||||||
tdCls: 'pve-itype-icon-storage',
|
|
||||||
editor: 'PVE.qemu.HDEdit',
|
|
||||||
never_delete: caps.vms['VM.Config.Disk'] ? false : true,
|
|
||||||
header: gettext('Hard Disk') + ' (' + confid +')',
|
|
||||||
cdheader: gettext('CD/DVD Drive') + ' (' + confid +')'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
confid = "net" + i.toString();
|
confid = "net" + i.toString();
|
||||||
rows[confid] = {
|
rows[confid] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user