I propose to do all the following (not everthing at once)
We can add driver or transport to drive (which currently supports size and name).
We can add id to partition (which currently supports size, name and number).
And so on for logical volumes names and types, etc.
It would look like this:
{
"search": {
"condition": {
"and": [
{ "transport": "scsi" },
{ "size": { "less": "1TiB" } }
]
}
}
}Let's say I want to check whether the transport is "scsi" or "usb". There is an obvious way that is using or like this:
{
"search": {
"condition": {
"or": [
{ "transport": "scsi" },
{ "transport": "usb" }
]
}
}
}But I wonder whether we should also add a syntax with an array like this:
{
"search": {
"condition": {
"transport": ["scsi", "usb"]
}
}
}Right now, if you want to skip a disk that matches a condition, you need an empty drive entry. For example, let's say you want to make sure USB disks are ignored. I fear then you need something like this:
{
"storage": {
"drives": [
{
"search": { "condition": { "transport": "usb" } },
"alias": "thisMatchesTheDisksIWantToIgnore"
},
{
"alias": "thisIsTheRealDriveEntryWithMyConfig"
"partitions": [{ "search": "*", "delete": true }]
}
],
}
}Having not would make this case more natural.
{
"storage": {
"drives": [
{
"search": { "condition": { "not": { "transport": "usb" } } },
"alias": "thisIsTheRealDriveEntryWithMyConfig",
"partitions": [{ "search": "*", "delete": true }]
}
],
}
}Having not is also beneficial for filesystems (keep reading).
Add a filesystem field that can be true or a condition with type, label, and, or or not.
That is, checking whether the device is formatted:
{
"search": {
"condition": {
"filesystem": true
}
}
}Checking that is not formatted:
{
"search": {
"condition": {
"not": { "filesystem": true }
}
}
}Checking that is formatted as XFS.
{
"search": {
"condition": {
"filesystem": { "type": "xfs" }
}
}
}Checking that is formatted, but not as XFS.
{
"search": {
"condition": {
"filesystem": { "not": { "type": "xfs" } }
}
}
}Checking that is not formatted as XFS.
{
"search": {
"condition": {
"not": { "filesystem": { "type": "xfs" } }
}
}
}Would also work similarly for searching VGs based on their LVs or any other "collection".
It would work by adding a partitions key that can contain: "some", "none" or an object.
The object form has the fields min, max or condition (it must contain at least one of them). If condition is omitted, then it matches any partition. If both min and max are omitted, then it means "all partitions in the drive". The value for min and max has to be bigger than 0.
If partitions is an object, then it assumes there should be at least one partition.
{
"search": {
"condition": {
"partitions": "none"
}
}
}{
"search": {
"condition": {
"partitions": "some"
}
}
}equivalent to:
{
"search": {
"condition": {
"partitions": { "min": 1 }
}
}
}{
"search": {
"condition": {
"partitions": {
"condition": {
"size": {
"greater": "10 GiB"
}
}
}
}
}
}{
"search": {
"condition": {
"partitions": {
"condition": {
"size": {
"greater": "10 GiB"
},
"min": 1
}
}
}
}
}{
"search": {
"condition": {
"partitions": {
"condition": {
"size": {
"greater": "10 GiB"
},
"min": 2,
"max": 2
}
}
}
}
}{
"search": {
"condition": {
"partitions": {
"condition": {
"size": {
"greater": "10 GiB"
},
"min": 2,
"max": 3
}
}
}
}
}Checking if none of the partition matches a condition (it does not matches if there are no partitions)
{
"search": {
"condition": {
"partitions": {
"condition": {
"not": {
"size": {
"greater": "10 GiB"
}
}
}
}
}
}
}
{
"search": {
"condition": {
"partitions": {
"condition": {
"not": {
"size": {
"greater": "10 GiB"
}
}
},
"min": 1
}
}
}
}