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 optionally contain min, max or condition.
It must contain at least one of them.
If condition is omitted, then it matches any partition. Allows to check for presence.
If both min and max are omitted, then it means "all partitions in the drive".
Checking whether there is any partition.
{
"search": {
"condition": {
"partitions": { "min": 1 }
}
}
}Checking whether there are no partitions.
{
"search": {
"condition": {
"partitions": { "max": 0 }
}
}
}Checking if all partitions are of id "Linux" (I guess it also matches if there are no partitions).
{
"search": {
"condition": {
"partitions": { "condition": { "id": "linux" } }
}
}
}Checking that if does not contain any partition of type "linux".
{
"search": {
"condition": {
"partitions": { "max": 0, "condition": { "id": "linux" } }
}
}
}Checking that it contains at least one partition of type "linux".
{
"search": {
"condition": {
"partitions": { "min": 1, "condition": { "id": "linux" } }
}
}
}Checking that it contains at least one partition that is not "linux".
{
"search": {
"condition": {
"partitions": { "min": 1, "condition": { "not": { "id": "linux" } } }
}
}
}
Yes. All "search" admits those. But this gist is not about adding new kinds of "search", it is about adding new possibilities to "condition".