def processPropertySet(self, cmdDict=None, action=None): '''processPropertySet: This method processes a single configuration object. It takes two parameters, a dictionary containing the command and the action (RW)''' self.logger.trace("processPropertySet: cmdDict=%s" % cmdDict) if cmdDict == None: self.logger.error("processPropertySet: No dictionary was passed to the generateCommands method") raise ProcessCommandException("No dictionary was passed to the generateCommands method") #end-if k = cmdDict.keys()[0] v = cmdDict.values()[0] self.logger.trace("processPropertySet: key=%s, value=%s" % (k, v)) try: self.validateScope(v, 'processPropertySet') except ProcessCommandException: self.logger.info("processPropertySet: Skipping propertyset %s:%s " % (k, v)) else: self.propSet = None try: self.logger.trace("processPropertySet: locating property set...") self.propSet=AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'propertySet') self.logger.trace("processPropertySet: property set found.") except ScriptingException, msg: self.logger.trace("processPropertySet: msg=%s" % msg) self.logger.trace("processPropertySet: property set not found.") self.logger.trace("processPropertySet: propSet=%s " % self.propSet) self.propList = AdminConfig.list(k, AdminConfig.getid(v['scope'])).splitlines() self.logger.trace("processPropertySet: self.propList=%s " % self.propList) for key in v.keys(): if key == 'name': self.logger.trace("processPropertySet: key=%s, value=%s" % (key, v[key])) itemFound="1" for item in self.propList: self.logger.trace("processPropertySet: name=%s" % AdminConfig.showAttribute(item, 'name')) if AdminConfig.showAttribute(item, 'name') == v[key]: self.logger.trace("processPropertySet: actual name=%s, value=%s" % (AdminConfig.showAttribute(item, 'name'), AdminConfig.showAttribute(item, 'value'))) self.logger.trace("processPropertySet: config name=%s, value=%s" % (v['name'], v['value'])) if AdminConfig.showAttribute(item, 'value') != v['value']: if action == 'W': self.logger.info("processPropertySet: modifying %s:%s:%s=%s" % (AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'name'), AdminConfig.showAttribute(item, 'name'), 'value', v['value'])) self.logger.debug("processPropertySet: command=AdminConfig.modify(%s, [[%s, %s]])" % (item, 'value', v['value'])) AdminConfig.modify(item, [['value', v['value']]]) else: self.logger.warn("processPropertySet: audit failure %s:%s, actual=%s config=%s" % (AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'name'), (AdminConfig.showAttribute(item, 'name')), AdminConfig.showAttribute(item, 'value'), v['value'])) #end-if else: self.logger.debug("processPropertySet: ignoring %s %s" % (AdminConfig.showAttribute(item, 'name'), AdminConfig.showAttribute(item, 'value'))) #end-if itemFound = "0" break #end-if #end-for if itemFound == "1": if self.propSet != None: self.logger.info("processPropertySet: creating %s:%s:%s=%s" % (AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'name'), v[key], 'value', v['value'])) self.logger.debug("processPropertySet: command=AdminConfig.create(%s, %s, [['name', '%s'],['type', '%s'],['value', '%s'],['required', '%s'])" % (k, self.propSet, v[key], v['type'], v['value'], v['required'])) AdminConfig.create(k, self.propSet, [['name', v[key]],['type', v['type']],['value', v['value']],['required', v['required']]]) else: self.logger.ERROR("processPropertySet: You tried to create a new property but the configuration does not have a property set. You will need to to write some code to deal with this because I haven't done it yet :-)")
def processPropertySet(self, cmdDict=None, action=None): '''processPropertySet: This method processes a single configuration object. It takes two parameters, a dictionary containing the command and the action (RW)''' self.logger.trace("processPropertySet: cmdDict=%s" % cmdDict) if cmdDict == None: self.logger.error("processPropertySet: No dictionary was passed to the generateCommands method") raise ProcessCommandException("No dictionary was passed to the generateCommands method") #end-if k = cmdDict.keys()[0] v = cmdDict.values()[0] self.logger.trace("processPropertySet: key=%s, value=%s" % (k, v)) try: self.validateScope(v, 'processPropertySet') except ProcessCommandException: self.logger.info("processPropertySet: Skipping propertyset %s:%s " % (k, v)) else: self.propSet = None try: self.logger.trace("processPropertySet: locating property set...") self.propSet=AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'propertySet') self.logger.trace("processPropertySet: property set found.") except ScriptingException, msg: self.logger.trace("processPropertySet: msg=%s" % msg) self.logger.trace("processPropertySet: property set not found.") self.logger.trace("processPropertySet: propSet=%s " % self.propSet) self.propList = AdminConfig.list(k, AdminConfig.getid(v['scope'])).split('\r\n') for key in v.keys(): if key == 'name': self.logger.trace("processPropertySet: key=%s, value=%s" % (key, v[key])) itemFound="1" for item in self.propList: self.logger.trace("processPropertySet: name=%s" % AdminConfig.showAttribute(item, 'name')) if AdminConfig.showAttribute(item, 'name') == v[key]: self.logger.trace("processPropertySet: actual name=%s, value=%s" % (AdminConfig.showAttribute(item, 'name'), AdminConfig.showAttribute(item, 'value'))) self.logger.trace("processPropertySet: config name=%s, value=%s" % (v['name'], v['value'])) if AdminConfig.showAttribute(item, 'value') != v['value']: if action == 'W': self.logger.info("processPropertySet: modifying %s:%s:%s=%s" % (AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'name'), AdminConfig.showAttribute(item, 'name'), 'value', v['value'])) self.logger.debug("processPropertySet: command=AdminConfig.modify(%s, [[%s, %s]])" % (item, 'value', v['value'])) AdminConfig.modify(item, [['value', v['value']]]) else: self.logger.warn("processPropertySet: audit failure %s:%s, actual=%s config=%s" % (AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'name'), (AdminConfig.showAttribute(item, 'name')), AdminConfig.showAttribute(item, 'value'), v['value'])) #end-if else: self.logger.debug("processPropertySet: ignoring %s %s" % (AdminConfig.showAttribute(item, 'name'), AdminConfig.showAttribute(item, 'value'))) #end-if itemFound = "0" break #end-if #end-for if itemFound == "1": if self.propSet != None: self.logger.info("processPropertySet: creating %s:%s:%s=%s" % (AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'name'), v[key], 'value', v['value'])) self.logger.debug("processPropertySet: command=AdminConfig.create(%s, %s, [['name', '%s'],['type', '%s'],['value', '%s'],['required', '%s'])" % (k, self.propSet, v[key], v['type'], v['value'], v['required'])) AdminConfig.create(k, self.propSet, [['name', v[key]],['type', v['type']],['value', v['value']],['required', v['required']]]) else: self.logger.ERROR("processPropertySet: You tried to create a new property but the configuration does not have a property set. You will need to to write some code to deal with this because I haven't done it yet :-)")
def set(self, name, value, desc, type): for prop in self.obj.getChildren('resourceProperties'): if prop.getAttribute('name') == name: prop.setAttribute('value', value) return AdminConfig.create('J2EEResourceProperty', self.obj.id, [['name', name], ['value', value], ['description', desc], ['type', type]])
def processSecurity(self, cmdDict=None, action=None): '''Used to process security properties''' self.logger.trace("processPropertySet: cmdDict=%s" % cmdDict) if cmdDict == None: self.logger.error("processPropertySet: No dictionary was passed to the generateCommands method") raise ProcessCommandException("No dictionary was passed to the generateCommands method") #end-if k = cmdDict.keys()[0] v = cmdDict.values()[0] self.logger.trace("processSecrurity: key=%s, value=%s" % (k, v)) if k and v != None: self.validateScope(v, 'processSecurity') self.jaasAuthDataList = AdminConfig.list(k, AdminConfig.getid('%sSecurity:/' % v['scope'])).splitlines() self.logger.trace("processSecrurity: jaasAuthDataList=%s"% self.jaasAuthDataList) for key in v.keys(): if key == 'alias': self.logger.trace("processSecrurity: key=%s, value=%s" % (key, v[key])) itemFound="1" self.logger.trace("processSecrurity: items length is=%s" % len(self.jaasAuthDataList)) for item in self.jaasAuthDataList: self.logger.trace("processSecrurity: item=%s" % item) if item != "": self.logger.trace("processSecrurity: name=%s" % AdminConfig.showAttribute(item, 'alias')) if AdminConfig.showAttribute(item, 'alias') == v[key]: self.logger.trace("processSecrurity: checking alias %s" % AdminConfig.showAttribute(item,'alias')) for key in v.keys(): if key != 'scope': self.logger.trace("processSecrurity: key=%s" % key) if AdminConfig.showAttribute(item, key) != v[key]: self.logger.trace("processSecrurity: alias:%s, key=%s, actual=%s, config=%s" % (AdminConfig.showAttribute(item,'alias'), key, AdminConfig.showAttribute(item, key), v[key])) if action == 'W': self.logger.info("processSecrurity: modifying %s:%s=%s" % (AdminConfig.showAttribute(item,'alias'), key, v[key])) self.logger.debug("processSecrurity: command=AdminConfig.modify(%s, [[%s, %s]])" % (AdminConfig.showAttribute(item,'alias'), key, v[key])) AdminConfig.modify(item, [[key, v[key]]]) else: self.logger.warn("processSecrurity: audit failure %s:, actual=%s config=%s" % (AdminConfig.showAttribute(item,'alias'), AdminConfig.showAttribute(item, key), v[key])) #end-if #end-if #end-if #end-for itemFound = "0" break #end-if #end-if #end-for if itemFound == "1": self.logger.info("processSecrurity: creating %s:%s" % (k, v['alias'])) attrList = [] for key in v.keys(): if key != 'scope': attrList.append([key, v[key]]) if action == 'W': self.logger.debug("processSecrurity: command=AdminConfig.create(%s, %s, %s)" % (k, AdminConfig.getid('%sSecurity:/' % v['scope']), attrList)) AdminConfig.create(k, AdminConfig.getid('%sSecurity:/' % v['scope']), attrList) else: self.logger.warn("processSecrurity: action is %s so this item will not be created %s:%s" % (action, k, v['alias'])) #end-if #end-if #end-for else: self.logger.error("processPropertySet: key and value parameters were not suppled to the method.") raise ProcessCommandException("key and value parameters were not suppled to the method.")
def processConfigItem(self, cmdDict=None, action=None): '''processConfigItem: This method processes a single configuration object. It takes two parameters, a dictionary containing the command and the action (RW)''' self.logger.trace("processConfigItem: cmdDict=%s" % cmdDict) if cmdDict == None: self.logger.error("processConfigItem: No dictionary was passed to the generateCommands method") raise ProcessCommandException("No dictionary was passed to the generateCommands method") #end-if k = cmdDict.keys()[0] v = cmdDict.values()[0] self.logger.trace("processConfigItem: key=%s, value=%s" % (k, v)) template = self.setTemplate(key=k, valueDict=v) self.logger.trace("processConfigItem: template=%s" % template) try: self.validateScope(valueDict=v, method='processConfigItem', key=k) except ProcessCommandException: self.logger.info("processConfigItem: Skipping ConfigItem %s:%s." % (k, v)) else: self.logger.trace("processConfigItem: scope=%s " % AdminConfig.getid(v['scope'])) self.logger.trace("processConfigItem: finding object command=AdminConfig.getid('/%s:%s/') " % (k, v['name'])) obj = AdminConfig.getid('/%s:%s/' % (k, v['name'])) self.logger.trace("processConfigItem: obj=%s " % obj) if obj == "": self.logger.trace("processConfigItem: obj not found, creating...") attrList = [] for key in v.keys(): if key != 'scope': attrList.append([key, v[key]]) #end-if #end-for self.logger.trace("processConfigItem: attrList=%s" % attrList) self.logger.trace("processConfigItem: template=%s" % template) if template == None: self.logger.trace("processConfigItem: template was not found...") if action == 'W': if k == 'J2CActivationSpec': self.logger.trace("processConfigItem: key is J2CActivationSpec so fixing attribute list") attr = AdminConfig.list('ActivationSpec', AdminConfig.getid(v['scope'])) attrList.append(['activationSpec', attr]) elif k == 'J2CAdminObject': self.logger.trace("processConfigItem: key is J2CAdminObject so fixing attribute list") attr = AdminConfig.list('AdminObject', AdminConfig.getid(v['scope'])) attrList.append(['adminObject', attr]) elif k == 'J2CConnectionFactory': self.logger.trace("processConfigItem: key is J2CConnectionFactory so fixing attribute list") attr = AdminConfig.list('ConnectionDefinition', AdminConfig.getid(v['scope'])) attrList.append(['connectionDefinition', attr]) self.logger.info("processConfigItem: creating %s:%s:%s" % (AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'name'), k, v['name'])) self.logger.debug("processConfigItem: command=AdminConfig.create('%s', %s, %s)" % (k, AdminConfig.getid(v['scope']), attrList)) AdminConfig.create('%s' % k, AdminConfig.getid(v['scope']), attrList) else: self.logger.warn("processConfigItem: action is set to %s. Item %s:%s:%s will not be created. Attribute and properties for this object will not exist and may cause failures in this script." % (action, AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'name'), k, v['name'])) #end-if else: self.logger.trace("processConfigItem: template was found...") if action == 'W': self.logger.info("processConfigItem: creating %s:%s:%s" % (AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'name'), k, v['name'])) self.logger.trace("processConfigItem: template=%s" % template) self.logger.debug("processConfigItem: command=AdminConfig.createUsingTemplate('%s', %s, %s, %s)" % (k, AdminConfig.getid(v['scope']), attrList, template)) AdminConfig.createUsingTemplate('%s' % k, AdminConfig.getid(v['scope']), attrList, template) else: self.logger.warn("processConfigItem: action is set to %s. Item %s:%s:%s will not be created. Attribute and properties for this object will not exist and may cause failures in this script." % (action, AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'name'), k, v['name'])) #end-if #end-if #end-if else: for key in v.keys(): if key != 'scope': actual = AdminConfig.showAttribute(obj, key) self.logger.trace("processConfigItem: attribute=%s, value=%s" % (key, actual)) if actual != v[key]: if action == 'W': self.logger.info("processConfigItem: modifying actual=%s to %s" % (actual,v[key])) self.logger.debug("processConfigItem: command=AdminConfig.modify(%s, [['%s', '%s']])" % (obj, key, v[key])) AdminConfig.modify(obj, [[key, v[key]]]) else: self.logger.warn("processPropertySet: audit failure %s:%s, actual=%s config=%s" % (AdminConfig.showAttribute(AdminConfig.getid(v['scope']), 'name'), (AdminConfig.showAttribute(obj, 'name')), (AdminConfig.showAttribute(obj, key)), v[key]))
def processSecurity(self, cmdDict=None, action=None): '''Used to process security properties''' self.logger.trace("processPropertySet: cmdDict=%s" % cmdDict) if cmdDict == None: self.logger.error("processPropertySet: No dictionary was passed to the generateCommands method") raise ProcessCommandException("No dictionary was passed to the generateCommands method") #end-if k = cmdDict.keys()[0] v = cmdDict.values()[0] self.logger.trace("processSecrurity: key=%s, value=%s" % (k, v)) if k and v != None: self.validateScope(v, 'processSecurity') self.jaasAuthDataList = AdminConfig.list(k, AdminConfig.getid('%sSecurity:/' % v['scope'])).split('\r\n') self.logger.trace("processSecrurity: jaasAuthDataList=%s"% self.jaasAuthDataList) for key in v.keys(): if key == 'alias': self.logger.trace("processSecrurity: key=%s, value=%s" % (key, v[key])) itemFound="1" self.logger.trace("processSecrurity: items length is=%s" % len(self.jaasAuthDataList)) for item in self.jaasAuthDataList: self.logger.trace("processSecrurity: item=%s" % item) if item != "": self.logger.trace("processSecrurity: name=%s" % AdminConfig.showAttribute(item, 'alias')) if AdminConfig.showAttribute(item, 'alias') == v[key]: self.logger.trace("processSecrurity: checking alias %s" % AdminConfig.showAttribute(item,'alias')) for key in v.keys(): if key != 'scope': self.logger.trace("processSecrurity: key=%s" % key) if AdminConfig.showAttribute(item, key) != v[key]: self.logger.trace("processSecrurity: alias:%s, key=%s, actual=%s, config=%s" % (AdminConfig.showAttribute(item,'alias'), key, AdminConfig.showAttribute(item, key), v[key])) if action == 'W': self.logger.info("processSecrurity: modifying %s:%s=%s" % (AdminConfig.showAttribute(item,'alias'), key, v[key])) self.logger.debug("processSecrurity: command=AdminConfig.modify(%s, [[%s, %s]])" % (AdminConfig.showAttribute(item,'alias'), key, v[key])) AdminConfig.modify(item, [[key, v[key]]]) else: self.logger.warn("processSecrurity: audit failure %s:, actual=%s config=%s" % (AdminConfig.showAttribute(item,'alias'), AdminConfig.showAttribute(item, key), v[key])) #end-if #end-if #end-if #end-for itemFound = "0" break #end-if #end-if #end-for if itemFound == "1": self.logger.info("processSecrurity: creating %s:%s" % (k, v['alias'])) attrList = [] for key in v.keys(): if key != 'scope': attrList.append([key, v[key]]) if action == 'W': self.logger.debug("processSecrurity: command=AdminConfig.create(%s, %s, %s)" % (k, AdminConfig.getid('%sSecurity:/' % v['scope']), attrList)) AdminConfig.create(k, AdminConfig.getid('%sSecurity:/' % v['scope']), attrList) else: self.logger.warn("processSecrurity: action is %s so this item will not be created %s:%s" % (action, k, v['alias'])) #end-if #end-if #end-for else: self.logger.error("processPropertySet: key and value parameters were not suppled to the method.") raise ProcessCommandException("key and value parameters were not suppled to the method.")