Fewer, more precise error messages for datatype mismatch

Per RAZOR-144: When a matching expression can yield multiple datatypes that are not allowed, multiple error messages were generated.  This changes the matcher to generate a single error message that includes the function name, the argument position, the accepted datatypes, and the not-allowed-but-possibly-provided datatypes.
Updated api.md with node collection query

The node collection (/api/collections/nodes) supports queries against
hostnames and hw_info attributes. Added documentation of this including an
example.
* README.md: fix typo
* NEWS.md: fix typos
* README.md: changed "recipes" reference to "tasks
Prevent duplicate tempfiles when streaming download

Per RAZOR-73: When downloading a file for a repo, the code would create two temporary files: one from open-uri and one the code created explicitly. This now moves open-uri's tempfile in an attempt to avoid creating a duplicate.
Update os_boot.erb

Using the underscore character "_" for the separator can be problematic - if the <%= repo_url %> value contains an underscore .

My example, the repo was named "ubuntu_server" and of course the sed command would work out when hitting the underscore in the url (http://192.168.1.5:8080/svc/repo/ubuntu_server)

I replaced the delimiter with the character that has the octal value 001 - in ASCII it's the SOH character (start of heading) - which is extremely unlikely to appear in the repo name.

I think it is safer to use this.
Fix intermittent test failure due to content ordering

One of the IPMI tests would very occasionally fail because the order of data
was not what was expected.  This was a situation I considered theoretical,
rather than practical, when the test was first written -- and the order does
not matter, just the unordered set of values.

This updates the test to use an order-insensitive comparison, ensuring it will
always pass regardless of random chance altering the order.

https://tickets.puppetlabs.com/browse/RAZOR-177

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Make `json_name_from_ruby` available in Object

We regularly need to present the user with a name for something they
submitted, for type checking and so forth.  Since this is so common, and
happens in so many places, it seems reasonable to have a single central method
to expose this translation capability to the world.

By design this should take everything -- classes, and instances -- and return
the correct string for the user.  Returned strings are not translated, since
these are technical terms, not internal jargon.

https://tickets.puppetlabs.com/browse/RAZOR-118

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Initial command validation DSL and implementation

This adds a DSL for command validation, along with an implementation covering
the most basic validation needs.  This is obviously incomplete, but serves to
replace a number of current command validations.

https://tickets.puppetlabs.com/browse/RAZOR-118

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Realize node name in the database

We previously had a fairly universal concept of a node "name" through the
code, but it was only constructed in the application logic, not in
the database.

This means that various database level operations were simply impossible when
using the name, and that a complex set of deconstructions had to be used
through the codebase to deal with this.

Now, we simply have the column in the database, and use it.  This fixes that
non-uniform API, a win alone, but also paves the way for a future when users
can assign more meaningful names to nodes without violating the expectations
of the overall system.

https://tickets.puppetlabs.com/browse/RAZOR-118

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Use object reference validation for node reinstall commands

This moves to using the validation DSL to pre-check the node is a valid
reference when we issue a node-reinstall command.  That avoids the need to
handle it in the code specifically.

This also changes the return code from 202 to 404 if you issue the command
against a node that does not exist, which seems reasonable as that is
ultimately a user intent failure: we can't do what they wanted, and they
presumably expected *something* to be reinstalled when they issued
the command.

https://tickets.puppetlabs.com/browse/RAZOR-118

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Add validation for the IPMI credential command

This adds validation, along with the additional validation feature that some
attributes may cause others to be required, but only if they are present.

https://tickets.puppetlabs.com/browse/RAZOR-118

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Validate more commands, and add "value in set" operation

In order to validate the "set desired power state" value for a node, we need
to restrict the value to a small subset of legal values.  This implements that
check in the validator, and then applies that to the problem at hand.

https://tickets.puppetlabs.com/browse/RAZOR-118

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Validate `create-task`, adding nested object support

In order to handle the `create-task` command several features were added to
the validation language: nested object support, and the ability to define
additional attributes based on patterns when the set are not knowable ahead
of time.

https://tickets.puppetlabs.com/browse/RAZOR-118

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Validate `create-tag` command

This adds validation for the `create-tag` command.  This simply uses the
existing tooling, adding nothing, in a pleasant break.

https://tickets.puppetlabs.com/browse/RAZOR-118

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Validate `delete-tag`, adding boolean attribute support

In order to validate the `delete-tag` we need support for boolean attributes;
since Ruby splits into TrueClass and FalseClass, rather than a unified Boolean
class, we add the `type: :bool` tag to attribute checks, and restructure the
code to handle this additional special case a little better.

Then, implement `delete-tag` validation using this new capability.

https://tickets.puppetlabs.com/browse/RAZOR-118

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Validate `update_tag_rule` command.

https://tickets.puppetlabs.com/browse/RAZOR-118

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Validate `create-broker`, and make `references` mode liberal

This adds validation for the `create-broker` command.  Unlike previous
commands, this one has a field that references an object that is not stored in
the database, the BrokerType.

Supporting that made for two new features required in the validation code:
 * use a duck-type interface to check if the object exists
 * support different "search key" and "attribute name" in references

Finally, since we needed a unified interface for everything that we reference,
this updates the BrokerType `find` method to follow the same conventions as
the Sequel::Model classes.  That eliminates various special case code, and
lets us treat them polymorphicly.

https://tickets.puppetlabs.com/browse/RAZOR-118

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Validate `create-policy`, and add array attribute validation

This is a large change, because array attribute validation behaves somewhat
differently to hash attribute validation, resulting in the final split between
the two.

This was necessary to implement validation of the `create-policy` command,
which uses an array of nested objects.  Now that is done, we should have all
the major features required for validation in place.

https://tickets.puppetlabs.com/browse/RAZOR-118

Signed-off-by: Daniel Pittman <daniel@rimspace.net>