Package actions :: Module up2date_config
[hide private]
[frames] | no frames]

Source Code for Module actions.up2date_config

 1  #!/usr/bin/python2 
 2   
 3  # Copyright (c) 1999--2018 Red Hat, Inc.  Distributed under GPLv2. 
 4  # 
 5  # Author: Adrian Likins <alikins@redhat.com> 
 6  # 
 7   
 8  import os 
 9  import re 
10   
11  from up2date_client import config 
12   
13  cfg = config.initUp2dateConfig() 
14   
15  __rhnexport__ = [ 
16      'update', 
17      'get'] 
18   
19  argVerbose = 0 
20 -def update(configdict, cache_only=None):
21 """Invoke this to change the ondisk configuration of up2date""" 22 if cache_only: 23 return (0, "no-ops for caching", {}) 24 if argVerbose > 1: 25 print("called update_up2date_config") 26 27 if type(configdict) != type({}): 28 return (13, "Invalid arguments passed to function", {}) 29 30 unknownparams = [] 31 if cfg['disallowConfChanges']: 32 skipParams = cfg['disallowConfChanges'] 33 else: 34 skipParams = [] 35 for param in configdict.keys(): 36 # dont touch params in the skip params list 37 if param in skipParams: 38 continue 39 # write out all params, even ones we dont know about 40 # could be useful 41 cfg.set(param, configdict[param]) 42 43 if len(unknownparams): 44 return unknownparams 45 46 cfg.save() 47 48 return (0, "config updated", {})
49
50 -def get(cache_only=None):
51 """Reterieve the current configuration of up2date""" 52 if cache_only: 53 return (0, "no-ops for caching", {}) 54 if argVerbose > 1: 55 print("called get_up2date_config") 56 57 ret = {} 58 for k in cfg.keys(): 59 ret[k] = cfg[k] 60 return (0, "configuration retrived", {'data' : ret})
61 62 63
64 -def main():
65 configdatatup = get() 66 configdata = configdatatup[2]['data'] 67 68 import time 69 timestamp = time.time() 70 71 configdata['timeStampTest'] = timestamp 72 print(configdata) 73 import pprint 74 75 pprint.pprint(update(configdata)) 76 77 configdata['serverURL'] = "http://localhost/XMLRPC" 78 pprint.pprint(update(configdata))
79 80 if __name__ == "__main__": 81 main() 82