def __init__(self, client, nr, uid, data):
        self._client = client
        self._nr = nr
        self._name = name = 'C{0}'.format(nr)
        self._terminating = None

        # Additional container parameters to use
        # TODO: At the moment not used; currently data also does not contain
        #       these information
#        self._size = data.get('size', 1)
#        self._cpu = data.get('cpu', 0)
#        self._memory = data.get('memory', 0)
#        self._bandwidth = data.get('bandwidth', 0)
#        self._specialFeatures = data.get('specialFeatures', [])

        client.registerContainer(self)

        # Create the directories for the container
        self._confDir = confDir = pjoin(client.confDir, name)
        self._dataDir = dataDir = pjoin(client.dataDir, name)

        if os.path.isdir(confDir):
            raise ValueError('There is already a configuration directory for '
                             "'{0}' \n Please remove it manually if the engine "
                             'did not shut down correctly on last execution and '
                             'you are sure it is not in use. \n dir: {1}.'.format(name, confDir))

        if os.path.isdir(dataDir):
            raise ValueError('There is already a data directory for '
                             "'{0}' \n Please remove it manually if the engine "
                             'did not shut down correctly on last execution and '
                             'you are sure it is not in use. \n dir: {1}.'.format(name, dataDir))
        os.mkdir(confDir)
        os.mkdir(dataDir)

        # Create additional folders for the container
        rceDir = pjoin(dataDir, 'rce')
        rosDir = pjoin(dataDir, 'ros')

        os.mkdir(rceDir)
        os.mkdir(rosDir)

        if client.rosRel > 'fuerte':
            # TODO: Switch to user 'ros' when the launcher is used again
            shutil.copytree(pjoin(client.rootfs, 'root/.ros/rosdep'),
                            pjoin(rceDir, '.ros/rosdep'))

        # Create network variables
        bridgeIP = client.bridgeIP
        ip = '{0}.{1}'.format(bridgeIP.rsplit('.', 1)[0], nr)
        self._address = '{0}:{1}'.format(ip, client.envPort)
        self._rosproxyAddress = '{0}:{1}'.format(ip, client.rosproxyPort)
        self._fwdPort = str(nr + 8700)
        self._rosproxyFwdPort = str(nr + 10700)

        ovsname = data.get('name')
        ovsip = data.get('ip')

        if ovsname and ovsip:
            ovsif = 'eth1'
            ovsup = pjoin(confDir, 'ovsup')

            if client.ubuntuRel > 'quantal':
                ovsdown = pjoin(confDir, 'ovsdown')
            else:
                ovsdown = None
        else:
            ovsif = ovsup = ovsdown = None

        # Construct password
        passwd = encodeAES(cipher(client.masterPassword),
                           salter(uid, client.infraPassword))

        # Create upstart scripts
        upComm = pjoin(confDir, 'upstartComm')
        with open(upComm, 'w') as f:
            f.write(_UPSTART_COMM.format(masterIP=client.masterIP,
                                         masterPort=client.masterPort,
                                         internalPort=client.envPort,
                                         uid=uid, passwd=passwd))

        upRosapi = pjoin(confDir, 'upstartRosapi')
        with open(upRosapi, 'w') as f:
            f.write(_UPSTART_ROSAPI.format(proxyPort=client.rosproxyPort))

        # TODO: For the moment there is no upstart script for the launcher.
#        upLauncher = pjoin(confDir, 'upstartLauncher')
#        with open(upLauncher, 'w') as f:
#            f.write(_UPSTART_LAUNCHER)

        # Setup network
        networkIF = pjoin(confDir, 'networkInterfaces')
        with open(networkIF, 'w') as f:
            f.write('auto lo\n')
            f.write('iface lo inet loopback\n')
            f.write('\n')
            f.write('auto eth0\n')
            f.write('iface eth0 inet static\n')
            f.write('    address {0}\n'.format(ip))
            f.write('    gateway {0}\n'.format(bridgeIP))
            f.write('    dns-nameservers {0} 127.0.0.1\n'.format(bridgeIP))

            if ovsif:
                f.write('\n')
                f.write('auto {0}\n'.format(ovsif))
                f.write('iface {0} inet static\n'.format(ovsif))
                f.write('    address {0}\n'.format(ovsip))

        # Create up/down script for virtual network interface if necessary
        if ovsup:
            with open(ovsup, 'w') as f:
                f.write(_LXC_NETWORK_SCRIPT.format(if_op='up', ovs_op='add',
                                                   name=ovsname))

            os.chmod(ovsup, stat.S_IRWXU)

        if ovsdown:
            with open(ovsdown, 'w') as f:
                f.write(_LXC_NETWORK_SCRIPT.format(if_op='down', ovs_op='del',
                                                   name=ovsname))

            os.chmod(ovsdown, stat.S_IRWXU)

        # TODO: SSL stuff
#        if self._USE_SSL:
#            # Create a new certificate and key for environment node
#            caCertPath = pjoin(self._SSL_DIR, 'Container.cert')
#            caCert = loadCertFile(caCertPath)
#            caKey = loadKeyFile(pjoin(self._SSL_DIR, 'container/env.key'))
#            (cert, key) = createKeyCertPair(commID, caCert, caKey)
#
#            # Copy/save file to data directory
#            shutil.copyfile(caCertPath, os.path.join(rceDir, 'ca.pem'))
#            writeCertToFile(cert, os.path.join(rceDir, 'cert.pem'))
#            writeKeyToFile(key, os.path.join(rceDir, 'key.pem'))

        # Create the container
        self._container = container = Container(client.reactor, client.rootfs,
                                                confDir, name)

        # Add lxc bridge
        container.addNetworkInterface('eth0', client.bridgeIF, ip)

        # Add the virtual network bridge if necessary
        if ovsname and ovsip:
            container.addNetworkInterface(ovsif, None, ovsip, ovsup, ovsdown)

        # Add additional lines to fstab file of container
        container.extendFstab(rosDir, 'home/ros', False)
        container.extendFstab(rceDir, 'opt/rce/data', False)
        container.extendFstab(upComm, 'etc/init/rceComm.conf', True)
        # TODO: For the moment there is no upstart script for the launcher.
#        container.extendFstab(upLauncher, 'etc/init/rceLauncher.conf', True)
        container.extendFstab(upRosapi, 'etc/init/rceRosapi.conf', True)
        container.extendFstab(networkIF, 'etc/network/interfaces', True)

        for srcPath, destPath in client.pkgDirIter:
            container.extendFstab(srcPath, destPath, True)
Nick/channel is temporarily unavailable
dataset/ETHPy150Open rapyuta/rce/rce-core/rce/container.py/RCEContainer.__init__--crossover with--dataset/ETHPy150Open ProgVal/Limnoria/plugins/NickCapture/plugin.py/NickCapture.do437