'Checks the mounted modules and if necessary mounts them into tmp
mountdir.
:param _modules: Desired modules.\'memory\',\'cpu,cpuset\'...
:return: Number of initialized modules.'

def init(self, _modules):

    logging.debug('Desired    cgroup    modules:    %s', _modules)
    mounts = []
    proc_mounts = open('/proc/mounts', 'r')
    line = proc_mounts.readline().split()
    while line:
        if (line[2] == 'cgroup'):
            mounts.append(line)
        line = proc_mounts.readline().split()
    proc_mounts.close()
    for module in _modules:
        i = False
        _module = set(module.split(','))
        for mount in mounts:
            if _module.issubset(mount[3].split(',')):
                self.modules[0].append(module)
                self.modules[1].append(mount[1])
                self.modules[2].append(False)
                i = True
                break
        if (not i):
            module_path = os.path.join(self.mountdir, module)
            if (not os.path.exists(module_path)):
                os.mkdir(module_path)
            cmd = ('mount    -t    cgroup    -o    %s    %s    %s' % (module, module, module_path))
            try:
                utils.run(cmd)
                self.modules[0].append(module)
                self.modules[1].append(module_path)
                self.modules[2].append(True)
            except error.CmdError:
                logging.info("Cgroup    module    '%s'    not    available", module)
    logging.debug('Initialized    cgroup    modules:    %s', self.modules[0])
    return len(self.modules[0])
