本文整理汇总了Python中univention.management.console.log.MODULE类的典型用法代码示例。如果您正苦于以下问题:Python MODULE类的具体用法?Python MODULE怎么用?Python MODULE使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MODULE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _thread
def _thread(request):
message = None
success = True
result = []
partition = request.options['partitionDevice']
unicode_user = request.options['user']
user = unicode_user.encode('utf-8')
size_soft = request.options['sizeLimitSoft']
size_hard = request.options['sizeLimitHard']
file_soft = request.options['fileLimitSoft']
file_hard = request.options['fileLimitHard']
self._check_error(request, partition)
failed = tools.setquota(partition, user, tools.byte2block(size_soft),
tools.byte2block(size_hard),
file_soft, file_hard)
if failed:
MODULE.error('Failed to modify quota settings for user %s '
'on partition %s' % (user, partition))
message = _('Failed to modify quota settings for user %s on '
'partition %s') % (user, partition)
request.status = MODULE_ERR
self.finished(request.id, None, message)
message = _('Successfully set quota settings')
return {'result': result, 'message': message, 'success': success}
示例2: install
def install(self, package_manager, component_manager, add_component=True):
try:
# remove all existing component versions
for iapp in self.versions:
# dont remove yourself (if already added)
if iapp is not self:
component_manager.remove_app(iapp)
# add the new repository component for the app
ucr.load()
is_master = ucr.get('server/role') in ('domaincontroller_master', 'domaincontroller_backup') # packages need to be installed on backup AND master systems
to_install = self.get('defaultpackages')
if is_master and self.get('defaultpackagesmaster'):
to_install.extend(self.get('defaultpackagesmaster'))
if add_component:
component_manager.put_app(self)
package_manager.update()
# install + dist_upgrade
package_manager.log('\n== INSTALLING %s AT %s ==\n' % (self.name, datetime.now()))
package_manager.commit(install=to_install, dist_upgrade=True)
# successful installation
status = 200
except:
MODULE.warn(traceback.format_exc())
status = 500
self._send_information('install', status)
return status == 200
示例3: list_jobs
def list_jobs(self,request):
""" returns list of jobs for one printer. """
# ----------- DEBUG -----------------
MODULE.info("printers/jobs/query invoked with:")
pp = pprint.PrettyPrinter(indent=4)
st = pp.pformat(request.options).split("\n")
for s in st:
MODULE.info(" << %s" % s)
# -----------------------------------
printer = request.options.get('printer','')
result = self._job_list(printer)
# ---------- DEBUG --------------
MODULE.info("printers/jobs/query returns:")
pp = pprint.PrettyPrinter(indent=4)
st = ''
if len(result) > 5:
tmp = result[0:5]
MODULE.info(" >> %d entries, first 5 are:" % len(result))
st = pp.pformat(tmp).split("\n")
else:
st = pp.pformat(result).split("\n")
for s in st:
MODULE.info(" >> %s" % s)
# --------------------------------
self.finished(request.id,result)
示例4: getUserAndMailbox
def getUserAndMailbox(userdn):
co, lo, pos = getCoLoPos()
server = univention.admin.modules.get("asterisk/server")
univention.admin.modules.init(lo, pos, server)
objs = server.lookup(co, lo, None)
checkServers = []
for obj in objs:
checkServers.append({
"label": obj["commonName"],
})
MODULE.error('User: server: %s' % len(checkServers))
if len(checkServers) >0 :
co, lo = getCoLo()
user = getUser(co, lo, userdn)
mailbox = user.get("mailbox")
if mailbox:
mailbox = getMailbox(co, lo, mailbox)
return user, mailbox
elif len(checkServers) == 0 :
MODULE.error('Fehler gefunden!')
mailbox = "KeinServer"
user = "KeinServer"
return user, mailbox
示例5: partitions_info
def partitions_info(self, request):
result = {}
message = None
try:
fs = fstab.File()
mt = mtab.File()
except IOError as error:
MODULE.error("Could not open %s" % error.filename)
message = _("Could not open %s") % error.filename
request.status = MODULE_ERR
else:
partition = fs.find(spec=request.options["partitionDevice"])
if partition:
mounted_partition = mt.get(partition.spec)
if mounted_partition:
result["mountPoint"] = mounted_partition.mount_point
result["filesystem"] = mounted_partition.type
result["options"] = mounted_partition.options
request.status = SUCCESS
else:
request.status = MODULE_ERR
message = _("This partition is currently not mounted")
else:
request.status = MODULE_ERR
message = _("No partition found")
self.finished(request.id, result, message)
示例6: partitions_query
def partitions_query(self, request):
result = []
message = None
try:
fs = fstab.File()
mt = mtab.File()
except IOError as error:
MODULE.error("Could not open %s" % error.filename)
message = _("Could not open %s") % error.filename
request.status = MODULE_ERR
else:
partitions = fs.get(["xfs", "ext3", "ext2"], False) # TODO: ext4?
for partition in partitions:
list_entry = {}
list_entry["partitionDevice"] = partition.spec
list_entry["mountPoint"] = partition.mount_point
list_entry["partitionSize"] = None
list_entry["freeSpace"] = None
list_entry["inUse"] = None
mounted_partition = mt.get(partition.spec)
if mounted_partition:
partition_info = df.DeviceInfo(partition.mount_point)
list_entry["partitionSize"] = tools.block2byte(partition_info.size(), "GB", 1)
list_entry["freeSpace"] = tools.block2byte(partition_info.free(), "GB", 1)
if "usrquota" in mounted_partition.options:
list_entry["inUse"] = True
else:
list_entry["inUse"] = False
result.append(list_entry)
request.status = SUCCESS
self.finished(request.id, result, message)
示例7: save
def save( self, request ):
"""Saves the UCS Active Directory Connector configuration
options:
LDAP_Host: hostname of the AD server
LDAP_Base: LDAP base of the AD server
LDAP_BindDN: LDAP DN to use for authentication
KerberosDomain: kerberos domain
PollSleep: time in seconds between polls
RetryRejected: how many time to retry a synchronisation
MappingSyncMode: synchronisation mode
MappingGroupLanguage: language of the AD server
return: { 'success' : (True|False), 'message' : <details> }
"""
self.required_options( request, *map( lambda x: x[ 0 ], Instance.OPTION_MAPPING ) )
self.guessed_baseDN = None
try:
fn = '%s/.htaccess' % DIR_WEB_AD
fd = open( fn, 'w' )
fd.write( 'require user %s\n' % self._username )
fd.close()
os.chmod( fn, 0644 )
os.chown( fn, 0, 0 )
except Exception, e:
message = _( 'An error occured while saving .htaccess (filename=%(fn)s ; exception=%(exception)s)') % { 'fn': fn, 'exception': e.__class__.__name__ }
MODULE.process( 'An error occured while saving .htaccess (filename=%(fn)s ; exception=%(exception)s)' % { 'fn': fn, 'exception': e.__class__.__name__ } )
self.finished( request.id, { 'success' : False, 'message' : message } )
return
示例8: _thread
def _thread(request, obj, username, password):
# acquire the lock until the scripts have been executed
self._finishedResult = False
obj._finishedLock.acquire()
try:
self._progressParser.reset()
# write the profile file and run setup scripts
util.pre_save(values, orgValues)
# on unjoined DC master the nameserver must be set to the external nameserver
if newrole == 'domaincontroller_master' and not orgValues.get('joined'):
for i in range(1,4):
# overwrite these values only if they are set, because the UMC module
# will save only changed values
if values.get( 'dns/forwarder%d'%i ):
values[ 'nameserver%d'%i ] = values.get( 'dns/forwarder%d'%i )
MODULE.info('saving profile values')
util.write_profile(values)
# unjoined DC master (that is not being converted to a basesystem) -> run the join script
MODULE.info('runnning system setup join script')
util.run_joinscript( self._progressParser, username, password )
# done :)
self._finishedResult = True
# we should do a cleanup now
self._cleanup_required = True
return True
finally:
obj._finishedLock.release()
示例9: request
def request( self, command, **kwargs ):
MODULE.info( 'Sending request %s to UVMM daemon ...' % command )
try:
request = eval( 'protocol.Request_%s()' % command )
except NameError, AttributeError:
MODULE.error( 'Failed to create request %s' % command )
raise UVMM_Error( _( 'The given UVMM command is not known' ) )
示例10: _fetch_file
def _fetch_file(self, key, url):
try:
# open the license file
fp = util.urlopen(url)
self._options[key] = ''.join(fp.readlines()).strip()
except (urllib2.HTTPError, urllib2.URLError) as e:
MODULE.warn('No information for %s available (%s): %s' % (key, e, url))
示例11: _thread
def _thread( request ):
result = []
for ldap_dn in request.options:
if request.flavor == 'users/self':
ldap_dn = self._user_dn
module = get_module( request.flavor, ldap_dn )
if module is None:
MODULE.process( 'A module for the LDAP DN %s could not be found' % ldap_dn )
continue
obj = module.get( ldap_dn )
if obj:
props = obj.info
for passwd in module.password_properties:
if passwd in props:
del props[ passwd ]
props[ '$dn$' ] = obj.dn
props[ '$options$' ] = {}
for opt in module.get_options( udm_object = obj ):
props[ '$options$' ][ opt[ 'id' ] ] = opt[ 'value' ]
props[ '$policies$' ] = {}
for policy in obj.policies:
pol_mod = get_module( None, policy )
if pol_mod and pol_mod.name:
props[ '$policies$' ][ pol_mod.name ] = policy
props[ '$labelObjectType$' ] = module.title;
result.append( props )
else:
MODULE.process( 'The LDAP object for the LDAP DN %s could not be found' % ldap_dn )
return result
示例12: colors
def colors( self, request ):
"""Returns a list of all existing colors."""
MODULE.info( 'MODULEID.colors: options: %s' % str( request.options ) )
allColors = set(map(lambda x: x['color'], Instance.entries))
allColors = map(lambda x: { 'id': x, 'label': x }, allColors)
allColors.append({ 'id': 'None', 'label': _('All colors') })
MODULE.info( 'MODULEID.colors: result: %s' % str( allColors ) )
self.finished(request.id, allColors)
示例13: uninstall_dry_run
def uninstall_dry_run(self, package_manager):
MODULE.info('Invoke uninstall_dry_run')
package_manager.reopen_cache()
to_uninstall = package_manager.get_packages(self.get('defaultpackages'))
for package in to_uninstall:
package.mark_delete()
packages = [pkg.name for pkg in package_manager.packages() if pkg.is_auto_removable]
package_manager.reopen_cache()
return packages
示例14: getServer
def getServer(dn):
co, lo, pos = getCoLoPos()
server = univention.admin.modules.get("asterisk/server")
univention.admin.modules.init(lo, pos, server)
obj = server.object(co, lo, None, dn)
MODULE.error("server dn: %s" % dn)
obj.open()
return obj
示例15: _thread_finish_success
def _thread_finish_success( self, thread, result, request ):
"""This method is invoked when a threaded request function is
finished. The result is send back to the client. If the result
is an instance of BaseException an error is returned."""
if self._check_thread_error( thread, result, request ):
return
success, data = result
MODULE.info( 'Got result from UVMMd: success: %s, data: %s' % ( success, data ) )
self.finished( request.id, { 'success' : success, 'data' : data } )