state: don't issue $set/$unset with empty set

Mongo 2.6 complains if you attempt to perform
a $set or $unset operation with an empty set.
If the set is dynamic, we must be careful to
only issue the operation if non-empty.
Refactor to use bson.M, utility function
Fix LP-1355521 :: update config before making the worker
Merge pull request #500 from johnweldon/LP-1355521

Fix LP-1355521 :: update config before making the worker

Fixes lp-1355521

s.updateConfig was happening *after* the suite already set up the worker.  This resulted in the environment not being consistently initialized, and resulted in the test timing out after 10 minutes on my machine.

Moving the s.updateConfig call to the beginning of the test, like all the other tests in this file, resolved the issue.
fix panic about float in storage port, and add a test that verifies it
Merge pull request #501 from natefinch/fix-1347715

fix panic about float in storage port, and add a test that verifies it

So, this __fixes-1347715__ - at least the most problem thing to crop up.  We have tests in the code that were checking to make sure that if a float gets into the config via json deserialization, that we handle it correctly.  However, it wasn't doing precisely the same thing the production code does, so it wasn't actually getting the value into the right area of the environConfig, and wasn't actually calling storagePort().  The test I added does this, and I verified it fails with a panic with the old code for manualConfig... then fixed the code the do a type assertion first, handling float64 and int... reran the test and now the test passes.

My only concern is that I don't know what changed to cause this error to suddenly start occurring.  I'm going to look into it and see if I can find the change that revealed this error.
Cleaned up manual provider float storage port test

Avoid copying an existing test and just extend the existing one
that tests the same scenario.
Revert PR 449

PR 449 by @voidspace breaks CI, restore is using StatePort
so all restore related tests break.
Reverting until we find a solution so it does not block
CI
Merge pull request #503 from perrito666/revert_PR_449

Revert PR 449

PR 449 by @voidspace breaks CI, restore is using StatePort
so all restore related tests break.
Reverting until we find a solution so it does not block
CI
this fixes-1355324
Merge pull request #502 from mjs/float-storage-port-test

Cleaned up manual provider float storage port test

Avoid copying an existing test and just extend the existing one that tests the same scenario instead.
provider/manual: don't verify bootstrap-host from inside env

StateServerInstances was attempting to verify the bootstrap
host by SSHing to itself; this fails if it does not have
authorized_keys set up appropriately. We use use-sshstorage
to detect whether we're inside the bootstrap host, and then
elide the verification if so.
provider/manual: test that Bootstrap sets use-sshstorage=false
environs/manual: revert error annotation

Leave the error alone, just log an error message.
Merge pull request #504 from axw/lp1347715-manual-stateserverinstances-noverifyinenv

provider/manual: don't verify bootstrap-host from inside env

StateServerInstances was attempting to verify the bootstrap
host by SSHing to itself; this fails if it does not have
authorized_keys set up appropriately. We use use-sshstorage
to detect whether we're inside the bootstrap host, and then
elide the verification if so.

Fixes https://bugs.launchpad.net/juju-core/+bug/1347715
Only set Safe.{J,WMode} in production

As of Mongo 2.6, attempting to set Safe.J
fails if journaling is disabled in mongod.
Similarly, WMode=majority will cause problems
if a replicaset is not configured. We need
to only set these in production, where those
conditions are guaranteed to be true.
Merge pull request #488 from axw/state-nosetunsetempty

state: don't issue $set/$unset with empty set

Mongo 2.6 complains if you attempt to perform
a $set or $unset operation with an empty set.
If the set is dynamic, we must be careful to
only issue the operation if non-empty.
Merge pull request #487 from axw/mongo-postdial-setsafe

Only set Safe.{J,WMode} in production

As of Mongo 2.6, attempting to set Safe.J
fails if journaling is disabled in mongod.
Similarly, WMode=majority will cause problems
if a replicaset is not configured. We need
to only set these in production, where those
conditions are guaranteed to be true.
agent: initialise mongo admin user before initialising state

This allows us to open mongo fully authenticated when opening
state, thus allowing the use of session.Copy.
state: remove unit.SetMongoPassword
Only login to "admin" mongo database

We create a user in the admin database
with read/write privileges to all databases,
so there's no need to add users to each
other database. Consequently, we can remove
the mongo.SetMongoPassword function and
change state.Machine.SetMongoPassword to
just call mongo.SetAdminMongoPassword.

mongo.SetAdminMongoPassword no longer
calls Login itself.