Created
September 21, 2012 09:49
-
-
Save bmoussaud/3760670 to your computer and use it in GitHub Desktop.
Deployit: Create or Update a dictionary from a property file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from java.io import File | |
from java.io import FileInputStream | |
from java.util import Properties | |
#Load properties file in java.util.Properties | |
def loadPropsFil(propsFil): | |
properties={} | |
propFil = Properties() | |
propFil.load(FileInputStream(propsFil)) | |
properties.update(propFil) | |
return properties | |
propertyfile='/opt/data/myfile.properties' | |
properties = loadPropsFil(propertyfile) | |
for key, value in properties.iteritems(): | |
print "%s=%s" % (key, value) | |
dictName="MyDictDev2" | |
dictId='Environments/%s'%dictName | |
if repository.exists(dictId): | |
print "update dictionary '%s'" % dictId | |
dict=repository.read(dictId) | |
dict.values['entries'].putAll(properties) | |
repository.update(dict) | |
else: | |
print "new dictionary created '%s'" % dictId | |
dict=repository.create(factory.configurationItem(dictId, 'udm.Dictionary', {'entries':properties})) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment