rendered paste bodyfrom raa import constants
from raa.lib import command
from raa.modules.raasrvplugin import rAASrvPlugin
import raa.service.lib
import simplejson
import os
class cert(object):
alias="DefaultAlias"
info=dict()
class KeyStoreParseError(Exception):
def __str__(self):
return "Could not parse Keystore"
def parseKeyStore():
"""
A function to parse the keystore
"""
try:
f=os.popen('keytool -v --list -alias lpproxy --keystore /home/dev/uclp_certs --storepass uclptrust')
for line in f.readlines():
curcert = cert()
if line.find('Valid')!= -1:
sections = line.split('Valid from:')
sections = sections[1].split('until:')
curcert.info['Valid from']=sections[0].strip()
curcert.info['Valid until']=sections[1].strip()
if line.find(':')!=-1:
sections = line.split(':')
curcert.info[sections[0].strip()]=sections[1].strip()
f.close()
except:
raise KeyStoreParseError
return cert.info
class KeyStore(rAASrvPlugin):
"""
Service class to manage the Java Keystore file for UCLP Network Elements
"""
def getKeyStoreInfo(self, schedId, execId):
try:
certs = {'Owner':'Test'}
except:
certs = ''
return certs
def importCert(self, schedId, execId, certData):
messages = []
errors = []
f = open('cert.tmp','w')
f.write(certData)
f.close()
return True
if __name__=='__main__':
KeyStore.__init__ = lambda *args, **kwargs: None
keystr=KeyStore();
print keystr.getKeyStoreInfo(0,0);