csc/Hanlon — pull request #178 by tjmcs (2014-09-12 18:54:37+00:00)
Title: Fixes #176 (Add ability to search for node/active_model via hardware_id)

The changes in this pull request give users the ability to find a node based on its `hardware_id` value or to find an active_model based on the `hardware_id` of the node that is bound to that active_model (in both cases, this is accomplished by adding a query string that looks like `?uuid=[UUID-VAL]` to a `GET` against that slice's root endpoint (eg. `GET /active_model?uuid=564DB508-F51E-1B77-1F5E-3C9413AD7CF2`). A second set of changes in this PR add the ability to trigger this same functionality from the Hanlon CLI (by adding an optional `[--hw_id,-i HW_ID]` CLI option to both of these slices). Here is an example of using this functionality with the node slice my local system:
```bash
$ hanlon node --hw_id 564DB508-F51E-1B77-1F5E-3C9413AD7CF2
Node:
UUID => 5vtMpqIbVeac2D10ck8mXY
Last Checkin => 09-11-14 15:56:51
Status => bound
Tags => [big_disk,cpus_1,IntelCorporation,memsize_1GiB,nics_1,vmware_vm]
Hardware IDs => [564DB508-F51E-1B77-1F5E-3C9413AD7CF2]

$ hanlon node 5vtMpqIbVeac2D10ck8mXY
Node:
UUID => 5vtMpqIbVeac2D10ck8mXY
Last Checkin => 09-11-14 15:56:51
Status => bound
Tags => [big_disk,cpus_1,IntelCorporation,memsize_1GiB,nics_1,vmware_vm]
Hardware IDs => [564DB508-F51E-1B77-1F5E-3C9413AD7CF2]

$ hanlon node --hw_id 564DB508-F51E-1B77-1F5E-3C9413AD7CF
[node] [get_all_nodes] <-Cannot Find Node with Hardware ID: [564DB508-F51E-1B77-1F5E-3C9413AD7CF]
$
```
Note that the output from the first two commands is identical in both cases (regardless of whether Hanlon's node UUID was used or the new hardware_id functionality was used to obtain the reference to this node). The output from the third command shows . Here is the output from a similar set of commands showing the new functionality that this PR adds to the active_model slice:
```bash
$ hanlon active_model --hw_id 564DB508-F51E-1B77-1F5E-3C9413AD7CF2
Active Model:
UUID => 61cP9lino5RWWVtpe7dLpQ
Label => Default Local Boot Policy
Template => boot_local
Node UUID => 5vtMpqIbVeac2D10ck8mXY
Model Label => Boot Local
Model Name => boot_local
Current State => complete_no_broker
Broker Target => none
Bound Number => 1
Bind Time => 15:56:22 09-11-2014

$ hanlon active_model 61cP9lino5RWWVtpe7dLpQ
Active Model:
UUID => 61cP9lino5RWWVtpe7dLpQ
Label => Default Local Boot Policy
Template => boot_local
Node UUID => 5vtMpqIbVeac2D10ck8mXY
Model Label => Boot Local
Model Name => boot_local
Current State => complete_no_broker
Broker Target => none
Bound Number => 1
Bind Time => 15:56:22 09-11-2014

$ hanlon active_model --hw_id 564DB508-F51E-1B77-1F5E-3C9413AD7CF
[active_model] [get_all_active_models] <-Cannot Find Node with Hardware ID: [564DB508-F51E-1B77-1F5E-3C9413AD7CF]

$ hanlon node --hw_id 564D4B74-704D-5459-0C22-D19E4A1A252E
Node:
UUID => 2kJY89IQ2Lmbn2rWIWcyY4
Last Checkin => 09-12-14 11:42:03
Status => active
Tags => [big_disk,cpus_1,IntelCorporation,memsize_384MiB,nics_1,vmware_vm]
Hardware IDs => [564D4B74-704D-5459-0C22-D19E4A1A252E]

$ hanlon active_model --hw_id 564D4B74-704D-5459-0C22-D19E4A1A252E
[active_model] [get_all_active_models] <-Node [564D4B74-704D-5459-0C22-D19E4A1A252E] is not bound to an active_model

$
```
As you can see, the first two commands show the output from the active_model slice is the same, regardless of whether you obtained the active_model reference using a match to a bound node or obtained the active_model reference directly using Hanlon's active_model UUID. As was the case with the first set of commands, we've also included three commands at the end of that sequence to demonstrate that errors triggered when there are no matching nodes (based on the hardware_id) or when there is a matching node but it is not bound to an active_model instance are caught and handled properly.

With these changes we will be able to quickly obtain a reference to a node or to the active_model instance bound to a node from within any system that is using this `hardware_id` value (typically this will be the SMBIOS UUID value) to identify nodes (a Configuration Management or Reservation system, for example).