check for invalid hostnames on update_attributes

Adds the hostname validation and username validation to the
update_attributes code for users to prevent bad data getting
into the system and breaking in unexpected places.

Change-Id: Ib501357e45e99945ab972ceed044efc1e2377de5
Closes-Bug: 1235845
Merge "check for invalid hostnames on update_attributes"