Example #1
0
 def __init__(self, reactor, rootfs, conf, hostname, ip):
     """ Initialize the Container.
         
         @param reactor:     Reference to the twisted::reactor
         @type  reactor:     twisted::reactor
         
         @param rootfs:      Filesystem path of the root directory of the
                             container filesystem.
         @type  rootfs:      str
         
         @param conf:        Filesystem path of folder where configuration
                             files for the container should be stored.
         @type  conf:        str
         
         @param hostname:    Host name of the container.
         @type  hostname:    str
         
         @param ip:          IP address which the container should use.
                             Use '0.0.0.0' for DHCP.
         @type  ip:          str
     """
     self._reactor = reactor
     self._rootfs = rootfs
     self._conf = pjoin(conf, 'config')
     self._fstab = pjoin(conf, 'fstab')
     self._hostname = hostname
     self._ip = ip
     
     checkPath(conf, 'Container Configuration')
     
     if os.path.exists(self._conf):
         raise ValueError('There is already a config file in the given '
                          'configuration folder.')
     
     if os.path.exists(self._fstab):
         raise ValueError('There is already a fstab file in the given '
                          'configuration folder.')
     
     self._fstabExt = []
Example #2
0
 def __init__(self, reactor, masterIP, intIF, bridgeIF, envPort, rootfsDir,
              confDir, dataDir, srcDir, pkgDir):
     """ Initialize the Container Client.
         
         @param reactor:     Reference to the twisted reactor.
         @type  reactor:     twisted::reactor
         
         @param masterIP:    IP address of the Master process.
         @type  masterIP:    str
         
         @param intIF:       Name of the network interface used for the
                             internal network.
         @type  intIF:       str
         
         @param bridgeIF:    Name of the bridge interface used for the
                             container network.
         @type  bridgeIF:    str
         
         @param envPort:     Port where the environment process running
                             inside the container is listening for
                             connections to other endpoints. (Used for
                             port forwarding.)
         @type  envPort:     int
         
         @param rootfsDir:   Filesystem path to the root directory of the
                             container filesystem.
         @type  rootfsDir:   str
         
         @param confDir:     Filesystem path to the directory where
                             container configuration files should be stored.
         @type  confDir:     str
         
         @param dataDir:     Filesystem path to the directory where
                             temporary data of a container should be stored.
         @type  dataDir:     str
         
         @param srcDir:      Filesystem path to the directory where the
                             source of the cloud engine is located.
         @type  srcDir:      str
         
         @param pkgDir:      Filesystem paths to the package directories
                             as a list of tuples where each tuple contains
                             the path to the directory in the host machine
                             and the path to the directory to which the
                             host directory will be bound in the container
                             filesystem (without the @param rootfsDir).
         @type  pkgDir:      [(str, str)]
     """
     self._reactor = reactor
     self._internalIP = getIP(intIF)
     self._envPort = envPort
     
     bridgeIP = getIP(bridgeIF)
     
     if masterIP in ('localhost', '127.0.0.1'):
         self._masterIP = bridgeIP
     else:
         self._masterIP = masterIP
     
     self._rootfs = rootfsDir
     self._confDir = confDir
     self._dataDir = dataDir
     self._srcDir = srcDir
     
     # Validate directory paths
     checkPath(self._confDir, 'Configuration')
     checkPath(self._dataDir, 'Data')
     checkPath(self._rootfs, 'Container file system')
     checkPath(self._srcDir, 'RCE source')
     
     # Validate executable paths
     checkExe(self._srcDir, 'environment.py')
     #checkExe(self._srcDir, 'launcher.py')
     
     # Process ROS package paths
     self._pkgDir = processPkgPath(pkgDir)
     
     for _, path in self._pkgDir:
         os.mkdir(os.path.join(self._rootfs, path))
     
     self._nrs = set(range(100, 200))
     self._containers = set()
     
     # Network configuration
     self._network = bridgeIP[:bridgeIP.rfind('.')]
     self._networkConf = _NETWORK_INTERFACES.format(network=self._network)
     
     # Common iptables references
     nat = iptc.Table(iptc.Table.NAT)
     self._prerouting = iptc.Chain(nat, 'PREROUTING')
     self._output = iptc.Chain(nat, 'OUTPUT')