Exemple #1
0
def set(key, value):
    """ Sets the key to the vale
        @param key is the configuration key
        @param value is what to set it to
    """
    global CONFIG
    if key in CONFIG.opts:
        # sometimes we gotta do stuff with the key
        if key == 'iface':
            if not util.verify_iface(value):
                util.Error('\'%s\' is not a valid interface.' % (value))
                return

            # valid iface, set new ipconfig
            new_ip = util.get_local_ip(value)
            if new_ip is not None:
                set('iface',value)
                set('ip_addr', new_ip)
        else:
            res = util.eval_type(value, CONFIG.opts[key]['type'])
            if res[0]:
                CONFIG.opts[key]['value'] = res[1]
    elif key in CONFIG._opts:
        # options not available in CLI
        res = util.eval_type(value, CONFIG._opts[key]['type'])
        if res[0]:
            CONFIG._opts[key]['value'] = res[1]
        else:
            return
    else:
        util.Error('Key "%s" not found.  \'opts\' for options.' % (key))
Exemple #2
0
def set(key, value):
    """ Sets the key to the vale
        @param key is the configuration key
        @param value is what to set it to
    """
    global CONFIG
    if key in CONFIG.opts:
        # sometimes we gotta do stuff with the key
        if key == 'iface':
            if not util.verify_iface(value):
                util.Error('\'%s\' is not a valid interface.' % (value))
                return

            # valid iface, set new ipconfig
            new_ip = util.get_local_ip(value)
            if new_ip is not None:
                set('iface',value)
                set('ip_addr', new_ip)
        else:
            res = util.eval_type(value, CONFIG.opts[key]['type'])
            if res[0]:
                CONFIG.opts[key]['value'] = res[1]
    elif key in CONFIG._opts:
        # options not available in CLI
        res = util.eval_type(value, CONFIG._opts[key]['type'])
        if res[0]:
            CONFIG._opts[key]['value'] = res[1]
        else:
            return
    else:
        util.Error('Key "%s" not found.  \'opts\' for options.' % (key))
Exemple #3
0
def set(key, value):
    """ Sets the key to the vale
        @param key is the configuration key
        @param value is what to set it to
    """
    global CONFIG
    if key in CONFIG.opts:
        # sometimes we gotta do stuff with the key
        if key == "iface":
            if not util.verify_iface(value):
                util.Error("'%s' is not a valid interface." % (value))
                return

            # valid iface, set new ipconfig
            new_ip = util.get_local_ip(value)
            if new_ip is not None:
                set("iface", value)
                set("ip_addr", new_ip)
        else:
            res = util.eval_type(value, CONFIG.opts[key]["type"])
            if res[0]:
                CONFIG.opts[key]["value"] = res[1]
    elif key in CONFIG._opts:
        # options not available in CLI
        res = util.eval_type(value, CONFIG._opts[key]["type"])
        if res[0]:
            CONFIG._opts[key]["value"] = res[1]
        else:
            return
    else:
        util.Error("Key \"%s\" not found.  'opts' for options." % (key))
Exemple #4
0
def set(key, value):
	global CONFIG
	if key in CONFIG.opts:
		# sometimes we gotta do stuff with the key
		if key == 'iface':
			if not util.verify_iface(value):
				util.Error('\'%s\' is not a valid interface.'%(value))
				return
		elif key == 'debug':
		  	value = util.isDebug if evalBool(value) is None else evalBool(value)
		  	util.isDebug = value
		CONFIG.opts[key] = value
	else:
		util.Error('Key "%s" not found.  \'opts\' for options.'%(key))
Exemple #5
0
def set(key, value):
	""" Sets the key to the vale
		@param key is the configuration key
		@param value is what to set it to
	"""
	global CONFIG
	if key in CONFIG.opts:
		# sometimes we gotta do stuff with the key
		if key == 'iface':
			if not util.verify_iface(value):
				util.Error('\'%s\' is not a valid interface.'%(value))
				return
		if CONFIG.opts[key]['type'] is bool:
			if evalBool(value) is not None: value = evalBool(value)
			else: return
		CONFIG.opts[key]['value'] = value
	else:
		util.Error('Key "%s" not found.  \'opts\' for options.'%(key))
Exemple #6
0
def set(key, value):
    """ Sets the key to the vale
        @param key is the configuration key
        @param value is what to set it to
    """
    global CONFIG
    if key in CONFIG.opts:
        # sometimes we gotta do stuff with the key
        if key == 'iface':
            if not util.verify_iface(value):
                util.Error('\'%s\' is not a valid interface.' % (value))
                return

            # valid iface, set new ipconfig
            new_ip = util.get_local_ip(value)
            if new_ip is not None:
                set('iface', new_ip)
        if CONFIG.opts[key]['type'] is bool:
            if evalBool(value) is not None:
                value = evalBool(value)
            else:
                return
        CONFIG.opts[key]['value'] = value
    elif key in CONFIG._opts:
        # options not available in CLI
        if CONFIG._opts[key]['type'] is bool:
            if evalBool(value) is not None:
                value = evalBool(value)
            else:
                return
        elif CONFIG._opts[key]['type'] is int:
            if not evalInt(value):
                return
        CONFIG._opts[key]['value'] = value
    else:
        util.Error('Key "%s" not found.  \'opts\' for options.' % (key))
Exemple #7
0
def set(key, value):
    """ Sets the key to the vale
        @param key is the configuration key
        @param value is what to set it to
    """
    global CONFIG
    if key in CONFIG.opts:
        # sometimes we gotta do stuff with the key
        if key == 'iface':
            if not util.verify_iface(value):
                util.Error('\'%s\' is not a valid interface.' % (value))
                return

            # valid iface, set new ipconfig
            new_ip = util.get_local_ip(value)
            if new_ip is not None:
                set('iface', new_ip)
        if CONFIG.opts[key]['type'] is bool:
            if evalBool(value) is not None:
                value = evalBool(value)
            else:
                return
        CONFIG.opts[key]['value'] = value
    elif key in CONFIG._opts:
        # options not available in CLI
        if CONFIG._opts[key]['type'] is bool:
            if evalBool(value) is not None:
                value = evalBool(value)
            else:
                return
        elif CONFIG._opts[key]['type'] is int:
            if not evalInt(value):
                return
        CONFIG._opts[key]['value'] = value
    else:
        util.Error('Key "%s" not found.  \'opts\' for options.' % (key))