本文整理汇总了Python中uds.core.util.log.doLog函数的典型用法代码示例。如果您正苦于以下问题:Python doLog函数的具体用法?Python doLog怎么用?Python doLog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了doLog函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: readyReceived
def readyReceived(self, userService, data):
# No group to add
if self._group == '':
return
if not '.' in self._domain:
logger.info('Adding to a group for a non FQDN domain is not supported')
return
try:
l = self.__connectLdap()
except dns.resolver.NXDOMAIN: # No domain found, log it and pass
logger.warn('Could not find _ldap._tcp.' + self._domain)
log.doLog(service, log.WARN, "Could not remove machine from domain (_ldap._tcp.{0} not found)".format(self._domain), log.OSMANAGER)
except ldap.LDAPError:
logger.exception('Ldap Exception caught')
log.doLog(service, log.WARN, "Could not remove machine from domain (invalid credentials for {0})".format(self._account), log.OSMANAGER)
try:
machine = self.__getMachine(l, userService.friendly_name)
group = self.__getGroup(l)
l.modify_s(group, ((ldap.MOD_ADD, 'member', machine),))
except ldap.ALREADY_EXISTS:
# Already added this machine to this group, pass
pass
except Exception:
logger.error('Got exception trying to add machine to group')
开发者ID:joaoguariglia,项目名称:openuds,代码行数:27,代码来源:WinDomainOsManager.py
示例2: checkAndUpdateState
def checkAndUpdateState(userService, userServiceInstance, state):
"""
Checks the value returned from invocation to publish or checkPublishingState, updating the servicePoolPub database object
Return True if it has to continue checking, False if finished
"""
try:
if State.isFinished(state):
checkLater = False
userServiceInstance.finish()
userService.updateData(userServiceInstance)
userService.setState(State.USABLE) # Wi will only migrate fully functional services
elif State.isErrored(state):
checkLater = False
userService.updateData(userServiceInstance)
userService.setState(State.ERROR)
else:
checkLater = True # The task is running
userService.updateData(userServiceInstance)
userService.save()
if checkLater:
ClusterMigrationTask.checkLater(userService, userServiceInstance)
except Exception as e:
logger.exception('Migrating service')
log.doLog(userService, log.ERROR, 'Exception: {0}'.format(e), log.INTERNAL)
userService.setState(State.ERROR)
userService.save()
开发者ID:glyptodon,项目名称:openuds,代码行数:26,代码来源:ClusteredProviderManagement.py
示例3: loggedOut
def loggedOut(self, userService, userName=None, save=True):
'''
This method:
- Add log in event to stats
- Sets service in use
- Invokes userLoggedIn for user service instance
'''
uniqueId = userService.unique_id
userService.setInUse(False)
si = userService.getInstance()
si.userLoggedOut(userName)
userService.updateData(si)
serviceIp = si.getIp()
fullUserName = 'unknown'
if userService.user is not None:
fullUserName = userService.user.manager.name + '\\' + userService.user.name
knownUserIP = userService.src_ip + ':' + userService.src_hostname
knownUserIP = knownUserIP if knownUserIP != ':' else 'unknown'
addEvent(userService.deployed_service, ET_LOGOUT, fld1=userName, fld2=knownUserIP, fld3=serviceIp, fld4=fullUserName)
log.doLog(userService, log.INFO, "User {0} has logged out", log.OSMANAGER)
log.useLog('logout', uniqueId, serviceIp, userName, knownUserIP, fullUserName)
if save:
userService.save()
开发者ID:aiminickwong,项目名称:openuds,代码行数:30,代码来源:BaseOsManager.py
示例4: sernotify
def sernotify(request, idUserService, notification):
try:
if notification == 'hostname':
hostname = request.GET.get('hostname', None)[:64] # Cuts host name to 64 chars
ip = request.ip
if GlobalConfig.HONOR_CLIENT_IP_NOTIFY.getBool(True) is True:
ip = request.GET.get('ip', ip)
if ip is not None and hostname is not None:
us = UserService.objects.get(uuid=idUserService)
us.setConnectionSource(ip, hostname)
else:
return HttpResponse('Invalid request!', 'text/plain')
elif notification == "log":
message = request.GET.get('message', None)
level = request.GET.get('level', None)
if message is not None and level is not None:
us = UserService.objects.get(uuid=idUserService)
log.doLog(us, level, message, log.TRANSPORT)
else:
return HttpResponse('Invalid request!', 'text/plain')
except Exception as e:
logger.exception("Exception")
return errors.errorView(request, e)
return HttpResponse('ok', content_type='text/plain')
开发者ID:aiminickwong,项目名称:openuds,代码行数:26,代码来源:service.py
示例5: deleteItem
def deleteItem(self, parent, item): # This is also used by CachedService, so we use "userServices" directly and is valid for both
service = None
try:
service = parent.userServices.get(uuid=processUuid(item))
except Exception:
logger.exception('deleteItem')
self.invalidItemException()
if service.user:
logStr = 'Deleted assigned service {} to user {} by {}'.format(service.friendly_name, service.user.pretty_name, self._user.pretty_name)
else:
logStr = 'Deleted cached service {} by {}'.format(service.friendly_name, self._user.pretty_name)
if service.state in (State.USABLE, State.REMOVING):
service.remove()
elif service.state == State.PREPARING:
service.cancel()
elif service.state == State.REMOVABLE:
self.invalidItemException(_('Item already being removed'))
else:
self.invalidItemException(_('Item is not removable'))
log.doLog(parent, log.INFO, logStr, log.ADMIN)
return self.success()
开发者ID:dkmstr,项目名称:openuds,代码行数:25,代码来源:user_services.py
示例6: growL1Cache
def growL1Cache(self, sp, cacheL1, cacheL2, assigned):
'''
This method tries to enlarge L1 cache.
If for some reason the number of deployed services (Counting all, ACTIVE
and PREPARING, assigned, L1 and L2) is over max allowed service deployments,
this method will not grow the L1 cache
'''
logger.debug("Growing L1 cache creating a new service for {0}".format(sp))
# First, we try to assign from L2 cache
if cacheL2 > 0:
valid = None
with transaction.atomic():
for n in sp.cachedUserServices().select_for_update().filter(UserServiceManager.getCacheStateFilter(services.UserDeployment.L2_CACHE)).order_by('creation_date'):
if n.needsOsManager():
if State.isUsable(n.state) is False or State.isUsable(n.os_state):
valid = n
break
else:
valid = n
break
if valid is not None:
valid.moveToLevel(services.UserDeployment.L1_CACHE)
return
try:
UserServiceManager.manager().createCacheFor(sp.activePublication(), services.UserDeployment.L1_CACHE)
except MaxServicesReachedException as e:
log.doLog(sp, log.ERROR, 'Max number of services reached for this service', log.INTERNAL)
logger.error(str(e))
except:
logger.exception('Exception')
开发者ID:aiminickwong,项目名称:openuds,代码行数:32,代码来源:ServiceCacheUpdater.py
示例7: loggedIn
def loggedIn(self, userService, userName=None):
"""
This method:
- Add log in event to stats
- Sets service in use
- Invokes userLoggedIn for user service instance
"""
uniqueId = userService.unique_id
userService.setInUse(True)
si = userService.getInstance()
si.userLoggedIn(userName)
userService.updateData(si)
serviceIp = si.getIp()
fullUserName = 'unknown'
if userService.user is not None:
fullUserName = userService.user.manager.name + '\\' + userService.user.name
knownUserIP = userService.src_ip + ':' + userService.src_hostname
knownUserIP = knownUserIP if knownUserIP != ':' else 'unknown'
if userName is None:
userName = 'unknown'
addEvent(userService.deployed_service, ET_LOGIN, fld1=userName, fld2=knownUserIP, fld3=serviceIp, fld4=fullUserName)
log.doLog(userService, log.INFO, "User {0} has logged in".format(userName), log.OSMANAGER)
log.useLog('login', uniqueId, serviceIp, userName, knownUserIP, fullUserName, userService.friendly_name, userService.deployed_service.name)
counter = int(userService.getProperty('loginsCounter', '0')) + 1
userService.setProperty('loginsCounter', six.text_type(counter))
开发者ID:dkmstr,项目名称:openuds,代码行数:33,代码来源:BaseOsManager.py
示例8: release
def release(self, service):
'''
service is a db user service object
'''
super(WinDomainOsManager, self).release(service)
if not '.' in self._domain:
logger.info('Releasing from a not FQDN domain is not supported')
return
try:
l = self.__connectLdap()
except dns.resolver.NXDOMAIN: # No domain found, log it and pass
logger.warn('Could not find _ldap._tcp.' + self._domain)
log.doLog(service, log.WARN, "Could not remove machine from domain (_ldap._tcp.{0} not found)".format(self._domain), log.OSMANAGER)
except ldap.LDAPError:
logger.exception('Ldap Exception caught')
log.doLog(service, log.WARN, "Could not remove machine from domain (invalid credentials for {0})".format(self._account), log.OSMANAGER)
try:
res = self.__getMachine(l, service.friendly_name)
if res is None:
raise Exception('Machine {} not found on AD (permissions?)'.format(service.friendly_name))
l.delete_s(res) # Remove by DN, SYNC
except IndexError:
logger.error('Error deleting {} from BASE {}'.format(service.friendly_name, ou))
except Exception:
logger.exception('Deleting from AD: ')
开发者ID:joaoguariglia,项目名称:openuds,代码行数:28,代码来源:WinDomainOsManager.py
示例9: saveItem
def saveItem(self, parent, item):
# If already exists
uuid = processUuid(item) if item is not None else None
try:
calendar = Calendar.objects.get(uuid=processUuid(self._params['calendarId']))
access = self._params['access'].upper()
if access not in ('ALLOW', 'DENY'):
raise Exception()
except Exception:
self.invalidRequestException(_('Invalid parameters on request'))
priority = int(self._params['priority'])
if uuid is not None:
calAccess = parent.calendarAccess.get(uuid=uuid)
calAccess.calendar = calendar
calAccess.service_pool = parent
calAccess.access = access
calAccess.priority = priority
calAccess.save()
else:
parent.calendarAccess.create(calendar=calendar, access=access, priority=priority)
log.doLog(parent, log.INFO, "Added access calendar {}/{} by {}".format(calendar.name, access, self._user.pretty_name), log.ADMIN)
return self.success()
开发者ID:dkmstr,项目名称:openuds,代码行数:26,代码来源:op_calendars.py
示例10: cancel
def cancel(self, servicePoolPub): # pylint: disable=no-self-use
'''
Invoked to cancel a publication.
Double invokation (i.e. invokation over a "cancelling" item) will lead to a "forced" cancellation (unclean)
:param servicePoolPub: Service pool publication (db object for a publication)
'''
servicePoolPub = DeployedServicePublication.objects.get(pk=servicePoolPub.id)
if servicePoolPub.state not in State.PUBLISH_STATES:
if servicePoolPub.state == State.CANCELING: # Double cancel
logger.info('Double cancel invoked for a publication')
log.doLog(servicePoolPub.deployed_service, log.WARN, 'Forced cancel on publication, you must check uncleaned resources manually', log.ADMIN)
servicePoolPub.setState(State.CANCELED)
servicePoolPub.save()
return
else:
raise PublishException(_('Can\'t cancel non running publication'))
if servicePoolPub.state == State.LAUNCHING:
servicePoolPub.state = State.CANCELED
servicePoolPub.save()
return servicePoolPub
try:
pubInstance = servicePoolPub.getInstance()
state = pubInstance.cancel()
servicePoolPub.setState(State.CANCELING)
PublicationFinishChecker.checkAndUpdateState(servicePoolPub, pubInstance, state)
return servicePoolPub
except Exception, e:
raise PublishException(str(e))
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:30,代码来源:PublicationManager.py
示例11: checkAndUpdateState
def checkAndUpdateState(userService, userServiceInstance, state):
"""
Checks the value returned from invocation to publish or checkPublishingState, updating the servicePoolPub database object
Return True if it has to continue checking, False if finished
"""
try:
# Fills up basic data
userService.unique_id = userServiceInstance.getUniqueId() # Updates uniqueId
userService.friendly_name = userServiceInstance.getName() # And name, both methods can modify serviceInstance, so we save it later
userService.save(update_fields=['unique_id', 'friendly_name'])
updater = {
State.PREPARING: UpdateFromPreparing,
State.REMOVING: UpdateFromRemoving,
State.CANCELING: UpdateFromCanceling
}.get(userService.state, UpdateFromOther)
logger.debug('Updating from {} with updater {} and state {}'.format(State.toString(userService.state), updater, state))
updater(userService, userServiceInstance).run(state)
except Exception as e:
logger.exception('Checking service state')
log.doLog(userService, log.ERROR, 'Exception: {0}'.format(e), log.INTERNAL)
userService.setState(State.ERROR)
userService.save(update_fields=['data'])
开发者ID:dkmstr,项目名称:openuds,代码行数:26,代码来源:opchecker.py
示例12: run
def run(self):
logger.debug('Checking user service finished {0}'.format(self._svrId))
uService = None
try:
uService = UserService.objects.get(pk=self._svrId)
if uService.state != self._state:
logger.debug('Task overrided by another task (state of item changed)')
# This item is no longer valid, returning will not check it again (no checkLater called)
return
ci = uService.getInstance()
logger.debug("uService instance class: {0}".format(ci.__class__))
state = ci.checkState()
UserServiceOpChecker.checkAndUpdateState(uService, ci, state)
except UserService.DoesNotExist as e:
logger.error('User service not found (erased from database?) {0} : {1}'.format(e.__class__, e))
except Exception as e:
# Exception caught, mark service as errored
logger.exception("Error {0}, {1} :".format(e.__class__, e))
if uService is not None:
log.doLog(uService, log.ERROR, 'Exception: {0}'.format(e), log.INTERNAL)
try:
uService.setState(State.ERROR)
uService.save(update_fields=['data', 'state', 'state_date'])
except Exception:
logger.error('Can\'t update state of uService object')
开发者ID:dkmstr,项目名称:openuds,代码行数:25,代码来源:opchecker.py
示例13: genPassword
def genPassword(self, service):
import random
import string
randomPass = service.recoverValue('winOsRandomPass')
if randomPass is None:
randomPass = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(16))
service.storeValue('winOsRandomPass', randomPass)
log.doLog(service, log.INFO, "Password set to \"{}\"".format(randomPass), log.OSMANAGER)
return randomPass
开发者ID:joaoguariglia,项目名称:openuds,代码行数:9,代码来源:WinRandomPassOsManager.py
示例14: deleteItem
def deleteItem(self, parent: MetaPool, item: str):
member = parent.members.get(uuid=processUuid(self._args[0]))
logStr = "Removed meta pool member {} by {}".format(member.pool.name, self._user.pretty_name)
member.delete()
log.doLog(parent, log.INFO, logStr, log.ADMIN)
return self.success()
开发者ID:dkmstr,项目名称:openuds,代码行数:9,代码来源:meta_service_pools.py
示例15: checkAndUpdateState
def checkAndUpdateState(userService, userServiceInstance, state):
'''
Checks the value returned from invocation to publish or checkPublishingState, updating the servicePoolPub database object
Return True if it has to continue checking, False if finished
'''
try:
prevState = userService.state
userService.unique_id = userServiceInstance.getUniqueId() # Updates uniqueId
userService.friendly_name = userServiceInstance.getName() # And name, both methods can modify serviceInstance, so we save it later
if State.isFinished(state):
checkLater = False
userServiceInstance.finish()
if State.isPreparing(prevState):
if userServiceInstance.service().publicationType is None or userService.publication == userService.deployed_service.activePublication():
userService.setState(State.USABLE)
# and make this usable if os manager says that it is usable, else it pass to configuring state
if userServiceInstance.osmanager() is not None and userService.os_state == State.PREPARING: # If state is already "Usable", do not recheck it
stateOs = userServiceInstance.osmanager().checkState(userService)
# If state is finish, we need to notify the userService again that os has finished
if State.isFinished(stateOs):
state = userServiceInstance.notifyReadyFromOsManager('')
userService.updateData(userServiceInstance)
else:
stateOs = State.FINISHED
if State.isRuning(stateOs):
userService.setOsState(State.PREPARING)
else:
userService.setOsState(State.USABLE)
else:
# We ignore OsManager info and if userService don't belong to "current" publication, mark it as removable
userService.setState(State.REMOVABLE)
elif State.isRemoving(prevState):
if userServiceInstance.osmanager() is not None:
userServiceInstance.osmanager().release(userService)
userService.setState(State.REMOVED)
else:
# Canceled,
logger.debug("Canceled us {2}: {0}, {1}".format(prevState, State.toString(state), State.toString(userService)))
userService.setState(State.CANCELED)
userServiceInstance.osmanager().release(userService)
userService.updateData(userServiceInstance)
elif State.isErrored(state):
checkLater = False
userService.updateData(userServiceInstance)
userService.setState(State.ERROR)
else:
checkLater = True # The task is running
userService.updateData(userServiceInstance)
userService.save()
if checkLater:
UserServiceOpChecker.checkLater(userService, userServiceInstance)
except Exception as e:
logger.exception('Checking service state')
log.doLog(userService, log.ERROR, 'Exception: {0}'.format(e), log.INTERNAL)
userService.setState(State.ERROR)
userService.save()
开发者ID:aiminickwong,项目名称:openuds,代码行数:57,代码来源:UserServiceManager.py
示例16: deleteItem
def deleteItem(self, parent, item):
calendarAccess = parent.calendarAccess.get(uuid=processUuid(self._args[0]))
logStr = "Removed access calendar {} by {}".format(calendarAccess.calendar.name, self._user.pretty_name)
calendarAccess.delete()
log.doLog(parent, log.INFO, logStr, log.ADMIN)
return self.success()
开发者ID:dkmstr,项目名称:openuds,代码行数:9,代码来源:op_calendars.py
示例17: run
def run(self):
since_state = getSqlDatetime() - timedelta(seconds=MAX_STUCK_TIME)
# Filter for locating machine not ready
for ds in DeployedService.objects.filter(service__provider__maintenance_mode=False):
logger.debug('Searching for stuck states for {0}'.format(ds))
# Info states are removed on UserServiceCleaner and VALID_STATES are ok, or if "hanged", checked on "HangedCleaner"
for us in ds.userServices.filter(state_date__lt=since_state).exclude(state__in=State.INFO_STATES + State.VALID_STATES):
logger.debug('Found stuck user service {0}'.format(us))
log.doLog(ds, log.ERROR, 'User service {0} has been hard removed because it\'s stuck'.format(us.friendly_name))
us.delete()
开发者ID:dkmstr,项目名称:openuds,代码行数:10,代码来源:StuckCleaner.py
示例18: run
def run(self):
since_state = getSqlDatetime() - timedelta(seconds=GlobalConfig.MAX_INITIALIZING_TIME.getInt())
# Filter for locating machine not ready
flt = Q(state_date__lt=since_state, state=State.PREPARING) | Q(state_date__lt=since_state, state=State.USABLE, os_state=State.PREPARING)
for ds in DeployedService.objects.exclude(osmanager=None, state__in=State.VALID_STATES, service__provider__maintenance_mode=True):
logger.debug('Searching for hanged services for {0}'.format(ds))
for us in ds.userServices.filter(flt):
logger.debug('Found hanged service {0}'.format(us))
log.doLog(us, log.ERROR, 'User Service seems to be hanged. Removing it.', log.INTERNAL)
log.doLog(ds, log.ERROR, 'Removing user service {0} because it seems to be hanged'.format(us.friendly_name))
us.removeOrCancel()
开发者ID:aiminickwong,项目名称:openuds,代码行数:12,代码来源:HangedCleaner.py
示例19: doLog
def doLog(self, service, data, origin=log.OSMANAGER):
# Stores a log associated with this service
try:
msg, level = data.split('\t')
try:
level = int(level)
except Exception:
logger.debug('Do not understand level {}'.format(level))
level = log.INFO
log.doLog(service, level, msg, origin)
except Exception:
log.doLog(service, log.ERROR, "do not understand {0}".format(data), origin)
开发者ID:dkmstr,项目名称:openuds,代码行数:12,代码来源:LinuxOsManager.py
示例20: release
def release(request, idService):
logger.debug('ID Service: {}'.format(idService))
userService = userServiceManager().locateUserService(request.user, idService, create=False)
logger.debug('UserSrvice: >{}<'.format(userService))
if userService is not None and userService.deployed_service.allow_users_remove:
log.doLog(
userService.deployed_service,
log.INFO,
"Removing User Service {} as requested by {} from {}".format(userService.friendly_name, request.user.pretty_name, request.ip),
log.WEB
)
userServiceManager().requestLogoff(userService)
userService.release()
return HttpResponseRedirect(reverse('Index'))
开发者ID:glyptodon,项目名称:openuds,代码行数:15,代码来源:service.py
注:本文中的uds.core.util.log.doLog函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论