github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/plugins/device/proto/device.proto (about)

     1  syntax = "proto3";
     2  package hashicorp.nomad.plugins.device;
     3  option go_package = "proto";
     4  
     5  import "google/protobuf/timestamp.proto";
     6  
     7  // DevicePlugin is the API exposed by device plugins
     8  service DevicePlugin {
     9    // Fingerprint allows the device plugin to return a set of   
    10    // detected devices and provide a mechanism to update the state of
    11    // the device.
    12    rpc Fingerprint(FingerprintRequest) returns (stream FingerprintResponse) {}
    13  
    14    // Reserve is called by the client before starting an allocation
    15    // that requires access to the plugin’s devices. The plugin can use
    16    // this to run any setup steps and provides the mounting details to 
    17    // the Nomad client
    18    rpc Reserve(ReserveRequest) returns (ReserveResponse) {}
    19  
    20    // Stats returns a stream of device statistics.
    21    rpc Stats(StatsRequest) returns (stream StatsResponse) {}
    22  }
    23  
    24  // FingerprintRequest is used to request for devices to be fingerprinted.
    25  message FingerprintRequest {}
    26  
    27  // FingerprintResponse returns a set of detected devices.
    28  message FingerprintResponse {
    29      // device_group is a group of devices that share a vendor, device_type, and
    30      // device_name. This is returned as a set so that a single plugin could
    31      // potentially detect several device types and models.
    32      repeated DeviceGroup device_group = 1;
    33  }
    34  
    35  // DeviceGroup is a group of devices that share a vendor, device type and name.
    36  message DeviceGroup {
    37    // vendor is the name of the vendor of the device
    38    string vendor = 1;
    39  
    40    // device_type is the type of the device (gpu, fpga, etc).
    41    string device_type = 2;
    42    
    43    // device_name is the name of the device.
    44    string device_name = 3;
    45  
    46    // devices is the set of devices detected by the plugin.
    47    repeated DetectedDevice devices = 4;
    48  
    49    // attributes allows adding attributes to be used for constraints or
    50    // affinities.
    51    map<string, string> attributes = 5;
    52  }
    53  
    54  // DetectedDevice is a single detected device.
    55  message DetectedDevice {
    56    // ID is the ID of the device. This ID is used during allocation and must be
    57    // stable across restarts of the device driver.
    58    string ID = 1;
    59  
    60    // Health of the device.
    61    bool healthy = 2;
    62    
    63    // health_description allows the device plugin to optionally 
    64    // annotate the health field with a human readable reason.
    65    string health_description = 3;
    66  
    67    // hw_locality is optionally set to expose hardware locality information for
    68    // more optimal placement decisions.
    69    DeviceLocality hw_locality = 4;
    70  }
    71  
    72  // DeviceLocality is used to expose HW locality information about a device.
    73  message DeviceLocality {
    74    // pci_bus_id is the PCI bus ID for the device. If reported, it
    75    // allows Nomad to make NUMA aware optimizations.
    76    string pci_bus_id = 1; 
    77  }
    78  
    79  
    80  // ReserveRequest is used to ask the device driver for information on 
    81  // how to allocate the requested devices.
    82  message ReserveRequest {
    83    // device_ids are the requested devices.
    84    repeated string device_ids = 1;
    85  }
    86  
    87  // ReserveResponse informs Nomad how to expose the requested devices
    88  // to the the task.
    89  message ReserveResponse {
    90    // container_res contains information on how to mount the device
    91    // into a task isolated using container technologies (where the 
    92    // host is shared)
    93    ContainerReservation container_res = 1;
    94  }
    95  
    96  // ContainerReservation returns how to mount the device into a 
    97  // container that shares the host OS.
    98  message ContainerReservation {
    99    // List of environment variable to be set
   100    map<string, string> envs = 1;
   101  
   102    // Mounts for the task.
   103    repeated Mount mounts = 2;
   104  
   105    // Devices for the task.
   106    repeated DeviceSpec devices = 3;
   107  }
   108  
   109  // Mount specifies a host volume to mount into a task.
   110  // where device library or tools are installed on host and task
   111  message Mount {
   112    // Path of the mount within the task.
   113    string task_path = 1;
   114  
   115    // Path of the mount on the host.
   116    string host_path = 2;
   117  
   118    // If set, the mount is read-only.
   119    bool read_only = 3;
   120  }
   121  
   122  // DeviceSpec specifies a host device to mount into a task.
   123  message DeviceSpec {
   124    // Path of the device within the task.
   125    string task_path = 1;
   126  
   127    // Path of the device on the host.
   128    string host_path = 2;
   129  
   130    // Cgroups permissions of the device, candidates are one or more of
   131    // * r - allows task to read from the specified device.
   132    // * w - allows task to write to the specified device.
   133    // * m - allows task to create device files that do not yet exist
   134    string permissions = 3;
   135  }
   136  
   137  
   138  // StatsRequest is used to parameterize the retrieval of statistics.
   139  message StatsRequest {}
   140  
   141  // StatsResponse returns the statistics for each device group.
   142  message StatsResponse {
   143    // groups contains statistics for each device group.
   144    repeated DeviceGroupStats groups = 1;
   145  }
   146  
   147  // DeviceGroupStats contains statistics for each device of a particular
   148  // device group, identified by the vendor, type and name of the device.
   149  message DeviceGroupStats {
   150    string vendor = 1;
   151    string type = 2;
   152    string name = 3;
   153  
   154    // instance_stats is a mapping of each device ID to its statistics.
   155    map<string, DeviceStats> instance_stats = 4;
   156  }
   157  
   158  // DeviceStats is the statistics for an individual device
   159  message DeviceStats {
   160    // summary exposes a single summary metric that should be the most  
   161    // informative to users.
   162    StatValue summary = 1;
   163  
   164    // stats contains the verbose statistics for the device.
   165    StatObject stats = 2;
   166  
   167    // timestamp is the time the statistics were collected.
   168    google.protobuf.Timestamp timestamp = 3;
   169  }
   170  
   171  // StatObject is a collection of statistics either exposed at the top 
   172  // level or via nested StatObjects.
   173  message StatObject {
   174    // nested is a mapping of object name to a nested stats object.
   175    map<string, StatObject> nested = 1;
   176  
   177    // attributes is a mapping of statistic name to its value.
   178    map<string, StatValue> attributes  = 2;
   179  }
   180  
   181  // StatValue exposes the values of a particular statistic. The value may 
   182  // be of type double, integer, string or boolean. Numeric types can be 
   183  // exposed as a single value or as a fraction.
   184  message StatValue {
   185    // float_numerator_val exposes a floating point value. If denominator 
   186    // is set it is assumed to be a fractional value, otherwise it is a 
   187    // scalar.
   188    double float_numerator_val = 1;
   189    double float_denominator_val = 2;
   190  
   191    // int_numerator_val exposes a int value. If denominator 
   192    // is set it is assumed to be a fractional value, otherwise it is a 
   193    // scalar.
   194    int64 int_numerator_val = 3;
   195    int64 int_denominator_val = 4;
   196  
   197    // string_val exposes a string value. These are likely annotations.
   198    string string_val = 5;
   199  
   200    // bool_val exposes a boolean statistic. 
   201    bool bool_val = 6;
   202    
   203    // unit gives the unit type: °F, %, MHz, MB, etc.
   204    string unit = 7;
   205  
   206    // desc provides a human readable description of the statistic.
   207    string desc = 8;
   208  }