open-nomad/plugins/device/cmd/example
Mahmood Ali c5de71a424 Allow nullable fields in StatValues
In state values, we need to be able to distinguish between zero values
(e.g. `false`) and unset values (e.g. `nil`).

We can alternatively use protobuf `oneOf` and nested map to ensure
consistency of fields that are set together, but the golang
representation does not represent that well and introducing a mismatch
between representations.  Thus, I opted not to use it.
2018-11-14 14:41:19 -05:00
..
cmd Example device plugin and helpers 2018-08-28 13:59:57 -07:00
README.md Device manager 2018-11-07 10:43:15 -08:00
device.go Allow nullable fields in StatValues 2018-11-14 14:41:19 -05:00

README.md

This package provides an example implementation of a device plugin for reference.

Behavior

The example device plugin models files within a specified directory as devices. The plugin will periodically scan the directory for changes and will expose them via the streaming Fingerprint RPC. Device health is set to unhealthy if the file has a specific filemode permission as described by the config unhealthy_perm. Further statistics are also collected on the detected devices.

Config

The configuration should be passed via an HCL file that begins with a top level config stanza:

config {
  dir = "/my/path/to/scan"
  list_period = "1s"
  unhealthy_perm = "-rw-rw-rw-"
}

The valid configuration options are:

  • dir (string: "."): The directory to scan for files that will represent fake devices.
  • list_period (string: "5s"): The interval to scan the directory for changes.
  • unhealthy_perm (string: "-rwxrwxrwx"): The file mode permission that if set on a detected file will casue the device to be considered unhealthy.