Example #1
0
 def __init__(self, reactor):
     """ Initialize the Container Manager.
         
         @raise:         ValueError, if the paths/names are invalid.
     """
     super(ContainerManager, self).__init__(reactor)
     
     self._relayID = None
     
     # Keys:    Container tag
     # Values:  bool (True = ok; False = delete again)
     self._pending = {}
     
     self._rootfs = self._ROOTFS
     self._confDir = self._CONF_DIR
     self._dataDir = self._DATA_DIR
     self._srcDir = self._ROOT_SRC_DIR
     
     # Validate directory paths
     pathUtil.checkPath(self._confDir, 'Configuration')
     pathUtil.checkPath(self._dataDir, 'Data')
     pathUtil.checkPath(self._rootfs, 'Container file system')
     pathUtil.checkPath(self._srcDir, 'RCE source')
     
     # Validate executable paths
     pathUtil.checkExe(self._srcDir, 'environment.py')
     pathUtil.checkExe(self._srcDir, 'launcher.py')
     
     # Process ROS package paths
     self._pkgDir = pathUtil.processPackagePaths(self._ROOT_PKG_DIR)
     
     for _, path in self._pkgDir:
         os.mkdir(os.path.join(self._rootfs, path))
Example #2
0
def down():
    mounts = [os.path.join(settings.ROOTFS, pkg[1])
              for pkg in pathUtil.processPackagePaths(settings.ROOT_PKG_DIR)]
    
    stdDir = _STD_DIR[:]
    stdDir.reverse()
    
    # Add the system relevant directories which have to be unmounted as well in
    # reversed order and unmount all directories
    for target in mounts + [os.path.join(settings.ROOTFS, path[1:])
                            for path in stdDir]:
        try:
            subprocess.check_output(['umount', target])
        except subprocess.CalledProcessError as e:
            sys.stderr.write("Could not unmount '{0}'.\n\tExitcode: "
                             '{1}'.format(target, e.returncode))
            
            if e.output:
                sys.stderr.write('\tOutput: {0}'.format(e.output))
    
    # Delete all the extra created mount points
    for mount in mounts:
        os.rmdir(mount)
Example #3
0
def up():
    mounts = [(pkg[0], os.path.join(settings.ROOTFS, pkg[1]))
              for pkg in pathUtil.processPackagePaths(settings.ROOT_PKG_DIR)]
    
    # Create all the necessary mount points
    for mount in mounts:
        os.mkdir(mount[1])
    
    # Add the system relevant directories which have to be mounted as well and
    # mount all directories
    for source, target in [(path, os.path.join(settings.ROOTFS, path[1:]))
                           for path in _STD_DIR] + mounts:
        try:
            subprocess.check_output(['mount', '--bind', source, target])
        except subprocess.CalledProcessError as e:
            sys.stderr.write("Could not mount '{0}'.\n\tExitcode: "
                             '{1}'.format(source, e.returncode))
            
            if e.output:
                sys.stderr.write('\tOutput: {0}'.format(e.output))
    
    # Return the directory to the root filesystem
    sys.stdout.write(settings.ROOTFS)