veyron/services/mgmt/node: refactor the code and clean up the unit test.

Main changes:
- separate out the 'contract' for the node manager (in terms of what it expects as configuration, what it passes along to its next version, and how the soft link is supposed to be used); make it easier to replace the environment variable based mechanism to pass this config state with e.g. cmd-line flags or a file. Make it clear what node manager implementation can hide and what is public API
- make the soft link point to the actual node manager script rather than its containing workspace. This is again to clean up the contract -- whoever invokes node manager shouldn't assume node manager internally uses workspaces with noded.sh scripts inside of them
- make unit test setup simpler, and make the unit test do more things
- along the way, fixing some small issues that I noticed
Other than that, behavior-wise nothing much changes as far as how node manager works.

Change-Id: I4684c4de7f5e9ab952ca7f7ac0a239f4810d8b8c
diff --git a/services/mgmt/node/impl/callback.go b/services/mgmt/node/impl/callback.go
new file mode 100644
index 0000000..787425d
--- /dev/null
+++ b/services/mgmt/node/impl/callback.go
@@ -0,0 +1,34 @@
+package impl
+
+import (
+	"veyron/services/mgmt/lib/exec"
+	inode "veyron/services/mgmt/node"
+
+	"veyron2/mgmt"
+	"veyron2/rt"
+	"veyron2/vlog"
+)
+
+// InvokeCallback provides the parent node manager with the given name (which is
+// expected to be this node manager's object name).
+func InvokeCallback(name string) {
+	handle, err := exec.GetChildHandle()
+	switch err {
+	case nil:
+		// Node manager was started by self-update, notify the parent.
+		callbackName, err := handle.Config.Get(mgmt.ParentNodeManagerConfigKey)
+		if err != nil {
+			vlog.Fatalf("Failed to get callback name from config: %v", err)
+		}
+		nmClient, err := inode.BindNode(callbackName)
+		if err != nil {
+			vlog.Fatalf("BindNode(%v) failed: %v", callbackName, err)
+		}
+		if err := nmClient.Set(rt.R().NewContext(), mgmt.ChildNodeManagerConfigKey, name); err != nil {
+			vlog.Fatalf("Set(%v, %v) failed: %v", mgmt.ChildNodeManagerConfigKey, name, err)
+		}
+	case exec.ErrNoVersion:
+	default:
+		vlog.Fatalf("GetChildHandle() failed: %v", err)
+	}
+}