def createSoftwareDict(prodKey, vendor, description, installDate): """ Create a software dictionary that can be passed as the data parameter when constructing an ObjectMap that represents a Software entity. """ return {"id": Utils.prepId(prodKey), "setProductKey": MultiArgs(prodKey, Utils.prepId(vendor)), "setDescription": description, "setInstallDate": formatDate(installDate)}
def createSoftwareDict(prodKey, vendor, description, installDate): """ Create a software dictionary that can be passed as the data parameter when constructing an ObjectMap that represents a Software entity. """ return { "id": Utils.prepId(prodKey), "setProductKey": MultiArgs(prodKey, Utils.prepId(vendor)), "setDescription": description, "setInstallDate": formatDate(installDate), }
def updateTrigger(self, **data): user = getSecurityManager().getUser() triggerObj = self._guidManager.getObject(data['uuid']) log.debug('Trying to update trigger: %s' % triggerObj.id) if self.triggerPermissions.userCanManageTrigger(user, triggerObj): if 'globalRead' in data: triggerObj.globalRead = data.get('globalRead', False) log.debug('setting globalRead %s' % triggerObj.globalRead) if 'globalWrite' in data: triggerObj.globalWrite = data.get('globalWrite', False) log.debug('setting globalWrite %s' % triggerObj.globalWrite) if 'globalManage' in data: triggerObj.globalManage = data.get('globalManage', False) log.debug('setting globalManage %s' % triggerObj.globalManage) triggerObj.users = data.get('users', []) self.triggerPermissions.clearPermissions(triggerObj) self.triggerPermissions.updatePermissions( self._guidManager, triggerObj ) if self.triggerPermissions.userCanUpdateTrigger(user, triggerObj): if "name" in data: triggerObj.setTitle(cgi.escape(data["name"])) parent = triggerObj.getPrimaryParent() path = triggerObj.absolute_url_path() oldId = triggerObj.getId() newId = triggerObj.title if not isinstance(newId, unicode): newId = Utils.prepId(newId) newId = newId.strip() if not newId: raise Exception("New trigger id cannot be empty.") if newId != oldId: # rename the trigger id since its title changed try: if triggerObj.getDmd().Triggers.findObject(newId): message = 'Trigger %s already exists' % newId # Duplicate trigger found raise Exception(message) except AttributeError as ex: # the newId is not a duplicate pass try: parent.manage_renameObject(oldId, newId) triggerObj.id = newId except CopyError: raise Exception("Trigger rename failed.") trigger = from_dict(zep.EventTrigger, data) response, content = self.triggers_service.updateTrigger(trigger) return content