Set LANG to ensure correct Unicode handling

We pre-set the LANG variable in the environment to ensure that the JVM, JRuby,
Java libraries, and all the other moving parts will correctly handle
Unicode input.

Without this you risk getting replacement characters (typically `?`)
substituted (correctly, of course) for the Unicode characters in any input,
thanks to Ruby fallback encoding handling.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Don't intern strings to compare them

Interning strings is at least as expensive as comparing them, and brings no
significant advantage to the API.  This replaces the symbol comparison with a
simple string comparison.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Avoid member variables in spec tests

Member variables in spec tests are a trap: they preserve state in
unpredictable ways, and can trivially result in state moving between tests
leading to broken tests that appear to work, or vice-versa.

This replaces the member variables with `let` methods, which provide the same
stability, but lazily initialize, and ensure that the object is reset
correctly between tests regardless of other action.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Fix unstable "before" moving of policies.

This ensures that policy movement is stable when trying to place one policy
ahead of another in the database.  Previously it would incorrectly swap the
two policies regardless of relative position; now it is correctly idempotent.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Correctly implement node reboots

The previous implementation of node reboots, embarrassingly, showed off my
inability to read -- offering features that simply don't exist in IPMI, and
requesting the OS power off rather than reboot.

This replaces that with the correct version, using a hard power cycle to
restart the node on demand.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Make repository code Unicode aware

This updates the `filesystem_safe_name` code for repositories to handle UTF-8
correctly; the previous version would simply fail if non-ASCII characters were
present, thankfully making compatibility trivial.

The new code now handles two additional cases that the first version did not:
 * Unicode characters (UTF-8) now work correctly end-to-end
 * DOS/Windows reserved filenames are encoded to avoid failure

Unicode handling is done by more or less ignoring it: we use UTF-8 as our
filesystem encoding in Razor, so we pass through the characters unchanged.

Reserved characters, and filenames, are encoded URI style: percent encoding
with the hex value of the ASCII (aka UTF-8) character.  Only basic reserved
characters, and DOS special files, are encoded; Windows / NTFS reserved
filenames are handled by encoding the `$` character.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Include check for os_version in task inheritance

Per RAZOR-117: This adds extra verification that the child task's properties override the parent task's properties by checking os_version.
Flag all source files as UTF-8

Unfortunately, some of our UTF-8 support was working through lucky accidents
where Ruby encodings didn't mange the content, or where correctly encoded
strings were merged and promoted the US-ASCII encoding to where it should be.

This adds a header to all our Ruby files flagging them as UTF-8, ensuring that
our static strings default to the same.  This should result in more consistent
and correct behaviour across the product.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Add {fast_,}gettext to Razor server

This adds gettext infrastructure to our product: now we can translate text
using gettext, with an efficient engine that works directly from the po files.

This allows us to have all the benefits of gettext including standardization,
while retaining the overall flex and utility of our Ruby infrastructure.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Gettext-ize all our fixed strings

This updates all the fixed, user-facing strings to use gettext to translate
and gettext-friendly interpolation methods in inject dynamic content into
the strings.

We should now be able to produce translations of our text in a
meaningful fashion.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Create our initial pot translation table

This is the baseline that specific localized translations are created from.
When new strings are added, this needs to be extended with:

    rxgettext -o locales/razor-server.pot \
      --no-wrap --sort-output *.rb $(find lib -name '*.rb')

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Document POT maintenance and coding standards

This includes some brief notes on how to work with the gettext gem in Ruby,
and also how to update the translation template.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
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>