[autotest] Factor mounting code into lxc_config.

Move the mount management into the DeployConfigManager, to reduce coupling
between it, the Container, and the ContainerBucket.

Add tests.

BUG=chromium:720219
TEST=sudo python lxc_config_unittest.py -v

Change-Id: I6abd539bab65760330cbdc99487557bd349052f4
Reviewed-on: https://chromium-review.googlesource.com/574974
Commit-Ready: Ben Kwa <[email protected]>
Tested-by: Ben Kwa <[email protected]>
Reviewed-by: Ilja H. Friedel <[email protected]>
diff --git a/site_utils/lxc/config.py b/site_utils/lxc/config.py
index e071273..dbff416 100644
--- a/site_utils/lxc/config.py
+++ b/site_utils/lxc/config.py
@@ -203,20 +203,26 @@
         return c
 
 
-    def __init__(self, container):
+    def __init__(self, container, config_file=None):
         """Initialize the deploy config manager.
 
         @param container: The container needs to deploy config.
-
+        @param config_file: An optional config file.  For testing.
         """
         self.container = container
         # If shadow config is used, the deployment procedure will skip some
         # special handling of config file, e.g.,
         # 1. Set enable_master_ssh to False in autotest shadow config.
         # 2. Set ssh logleve to ERROR for all hosts.
-        self.is_shadow_config = os.path.exists(SSP_DEPLOY_SHADOW_CONFIG_FILE)
-        config_file = (SSP_DEPLOY_SHADOW_CONFIG_FILE if self.is_shadow_config
-                       else SSP_DEPLOY_CONFIG_FILE)
+        if config_file is None:
+            self.is_shadow_config = os.path.exists(
+                    SSP_DEPLOY_SHADOW_CONFIG_FILE)
+            config_file = (
+                    SSP_DEPLOY_SHADOW_CONFIG_FILE if self.is_shadow_config
+                    else SSP_DEPLOY_CONFIG_FILE)
+        else:
+            self.is_shadow_config = False
+
         with open(config_file) as f:
             deploy_configs = json.load(f)
         self.deploy_configs = [self.validate(c) for c in deploy_configs
@@ -391,6 +397,9 @@
             if (mount_config.force_create and
                 not os.path.exists(mount_config.source)):
                 utils.run('mkdir -p %s' % mount_config.source)
+            self.container.mount_dir(mount_config.source,
+                                     mount_config.target,
+                                     mount_config.readonly)
 
 
     def deploy_post_start(self):