Extracted machine agent test upgrade functionality

This is in prepartion for future tests which require the same
functions.
Changed user to run mongo for admin
cmd/jujud: restrict API logins during upgrades

Use the recently introduced API login validation functionality to only
allow client and local machine agent logins while upgrade steps are
running. The goal is minimise database activity during upgrades,
specifically for schema migrations.

As well as the unit tests, this change has been heavily tested
manually.
Merge pull request #147 from perrito666/1332110_restore_broken_with_mongo_refactor

Fix bug #1332110 :restore fails on hp and aws

After a change on how permissions are handled for users (240db2a2), the one executing mongo queries on the restore process became unable to run them. This operations seems to lack a permission failure.
The operation is now run, as others already where, as admin user.
Merge pull request #142 from mjs/client-logins-during-upgrades

cmd/jujud: restrict API logins during upgrades

Use the recently introduced API login validation functionality to only allow client and local machine agent logins while upgrade steps are running. The goal is minimise database activity during upgrades, specifically for schema migrations.

As well as the unit tests, this change has been heavily tested manually.