Exemplo n.º 1
0
def plcUpdateConfig(variables, configFile=DEF_PLC_CONFIG_FILE):
    """
    Update the default planetlab config file.
    Arguments:
      variables = list of dicts or lists
      configFile = alternate planetlab config file

      Example: to set plc_www/host (i.e., PLC_WWW_HOST in myplc docs), do

      variables[0] = { 'category' : 'plc_www',
                       'variable' : 'host',
                       'value'    : <value> }
        or
      variables[0] = [ 'plc_www','host',<value> ]
    """

    plcc = PLCConfiguration(configFile)

    for obj in variables:
        catDict = dict()
        varDict = dict()

        if type(obj) == list:
            catDict['id'] = obj[0]
            varDict['id'] = obj[1]
            varDict['value'] = obj[2]
            pass
        elif type(obj) == dict:
            catDict['id'] = obj['category']
            varDict['id'] = obj['variable']
            varDict['value'] = obj['value']
            pass
        else:
            raise "Unsupported variable object!"

        plcc.set(catDict, varDict)
        pass

    plcc.save()
    pass
Exemplo n.º 2
0
def plcUpdateConfig(variables,configFile=DEF_PLC_CONFIG_FILE):
    """
    Update the default planetlab config file.
    Arguments:
      variables = list of dicts or lists
      configFile = alternate planetlab config file

      Example: to set plc_www/host (i.e., PLC_WWW_HOST in myplc docs), do

      variables[0] = { 'category' : 'plc_www',
                       'variable' : 'host',
                       'value'    : <value> }
        or
      variables[0] = [ 'plc_www','host',<value> ]
    """
    
    plcc = PLCConfiguration(configFile)
    
    for obj in variables:
        catDict = dict()
        varDict = dict()
        
        if type(obj) == list:
            catDict['id'] = obj[0]
            varDict['id'] = obj[1]
            varDict['value'] = obj[2]
            pass
        elif type(obj) == dict:
            catDict['id'] = obj['category']
            varDict['id'] = obj['variable']
            varDict['value'] = obj['value']
            pass
        else:
            raise "Unsupported variable object!"
        
        plcc.set(catDict,varDict)
        pass
    
    plcc.save()
    pass