Revision 8ade203a xseg/tools/archipelago/archipelago/common.py

b/xseg/tools/archipelago/archipelago/common.py
53 53
import socket
54 54
import random
55 55
from select import select
56
import ConfigParser
56 57

  
57 58
random.seed()
58 59
hostname = socket.gethostname()
......
642 643
        return lock
643 644
    return wrap
644 645

  
646
def createBDict(cfg, section):
647
	sec_dic = {}
648
	sec_dic['portno_start'] = cfg.getint(section, 'portno_start')
649
	sec_dic['portno_end'] = cfg.getint(section, 'portno_end')
650
	sec_dic['log_level'] = cfg.getint(section, 'log_level')
651
	sec_dic['nr_ops'] = cfg.getint(section, 'nr_ops')
652
	try:
653
		sec_dic['nr_threads'] = cfg.getint(section, 'nr_threads')
654
		sec_dic['archip_dir'] = cfg.get(section, 'archip_dir')
655
		sec_dic['fdcache'] = cfg.getint(section, 'fdcache')
656
	except:
657
		sec_dic['pool'] = cfg.get(section, 'pool')
658
	return sec_dic
659

  
660
def createMDict(cfg, section):
661
	sec_dic = {}
662
	sec_dic['portno_start'] = cfg.getint(section, 'portno_start')
663
	sec_dic['portno_end'] = cfg.getint(section, 'portno_end')
664
	sec_dic['log_level'] = cfg.getint(section, 'log_level')
665
	sec_dic['nr_ops'] = cfg.getint(section, 'nr_ops')
666
	sec_dic['blockerb_port'] = cfg.getint(section, 'blockerb_port')
667
	sec_dic['blockerm_port'] = cfg.getint(section, 'blockerm_port')
668
	return sec_dic
669

  
670
def createVDict(cfg, section):
671
	sec_dic = {}
672
	sec_dic['portno_start'] = cfg.getint(section, 'portno_start')
673
	sec_dic['portno_end'] = cfg.getint(section, 'portno_end')
674
	sec_dic['log_level'] = cfg.getint(section, 'log_level')
675
	sec_dic['nr_ops'] = cfg.getint(section, 'nr_ops')
676
	sec_dic['blocker_port'] = cfg.getint(section, 'blocker_port')
677
	sec_dic['mapper_port'] = cfg.getint(section, 'mapper_port')
678
	return sec_dic
679

  
680

  
645 681
def loadrc(rc):
646 682
    try:
647 683
        if rc is None:
648
            execfile(os.path.expanduser(DEFAULTS), config)
684
	    cfg_dir = os.path.expanduser(DEFAULTS)
649 685
        else:
650
            execfile(rc, config)
686
	    cfg_dir = rc
687
	cfg_fd = open(cfg_dir)
651 688
    except:
652 689
        raise Error("Cannot read config file")
653 690

  
691
    cfg = ConfigParser.ConfigParser()
692
    cfg.readfp(cfg_fd)
693
    config['SEGMENT_PORTS'] = cfg.getint('XSEG','SEGMENT_PORTS')
694
    config['SEGMENT_SIZE'] = cfg.getint('XSEG','SEGMENT_SIZE')
695
    config['XSEGBD_START'] = cfg.getint('XSEG','XSEGBD_START')
696
    config['XSEGBD_END'] = cfg.getint('XSEG','XSEGBD_END')
697
    config['VTOOL_START'] = cfg.getint('XSEG','VTOOL_START')
698
    config['VTOOL_END'] = cfg.getint('XSEG','VTOOL_END')
699
    config['roles'] = eval(cfg.get('ROLES','order'))
700
    config['blockerb'] = createBDict(cfg, 'BLOCKERB')
701
    config['blockerm'] = createBDict(cfg, 'BLOCKERM')
702
    config['mapperd'] = createMDict(cfg, 'MAPPERD')
703
    config['vlmcd'] = createVDict(cfg, 'VLMCD')
704

  
654 705
    if not check_conf():
655 706
        raise Error("Invalid conf file")
656 707

  

Also available in: Unified diff