本文整理匯總了Python中cloudhands.common.connectors.Registry.expire方法的典型用法代碼示例。如果您正苦於以下問題:Python Registry.expire方法的具體用法?Python Registry.expire怎麽用?Python Registry.expire使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cloudhands.common.connectors.Registry
的用法示例。
在下文中一共展示了Registry.expire方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: publish_uidnumber
# 需要導入模塊: from cloudhands.common.connectors import Registry [as 別名]
# 或者: from cloudhands.common.connectors.Registry import expire [as 別名]
def publish_uidnumber(self):
log = logging.getLogger(__name__ + ".uidnumber")
session = Registry().connect(sqlite3, self.args.db).session
initialise(session)
actor = session.query(Component).filter(
Component.handle=="identity.controller").one()
while True:
try:
unpublished = [
r for r in session.query(Registration).all() if (
r.changes[-1].state.name ==
"user_posixaccount")]
for reg in unpublished:
resources = [r for c in reversed(reg.changes)
for r in c.resources]
emailAddr = next(i for i in resources
if isinstance(i, EmailAddress))
uid = next(i for i in resources if isinstance(i, PosixUId))
uidNumber = next(i for i in resources
if isinstance(i, PosixUIdNumber))
record = LDAPRecord(
dn={("cn={},ou=jasmin2,"
"ou=People,o=hpc,dc=rl,dc=ac,dc=uk").format(uid.value)},
objectclass={"posixAccount"},
uid={uid.value},
uidNumber={uidNumber.value},
gidNumber={uidNumber.value},
gecos={"{} <{}>".format(uid.value, emailAddr.value)},
homeDirectory={
self.config.get(
"mount", "home", fallback="/home/{}"
).format(uid.value)
},
loginShell={"/bin/bash"},
)
log.debug(record)
msg = LDAPProxy.WriteUIdNumber(record, reg.uuid)
yield from self.ldapQ.put(msg)
session.expire(reg)
except Exception as e:
log.error(e)
finally:
log.debug("Waiting for {}s".format(self.args.interval))
yield from asyncio.sleep(self.args.interval)
示例2: publish_uuid
# 需要導入模塊: from cloudhands.common.connectors import Registry [as 別名]
# 或者: from cloudhands.common.connectors.Registry import expire [as 別名]
def publish_uuid(self):
log = logging.getLogger(__name__ + ".uuid")
session = Registry().connect(sqlite3, self.args.db).session
initialise(session)
actor = session.query(Component).filter(
Component.handle=="identity.controller").one()
while True:
try:
unpublished = [
r for r in session.query(Registration).all() if (
r.changes[-1].state.name ==
"pre_user_inetorgperson_dn")]
for reg in unpublished:
# TODO: Get latest PosixUId resource
try:
uid = next(r for c in reversed(reg.changes)
for r in c.resources if isinstance(r, PosixUId))
except StopIteration:
continue
log.debug(uid)
user = reg.changes[0].actor
surname = user.surname or "UNKNOWN"
record = LDAPRecord(
dn={("cn={},ou=jasmin2,"
"ou=People,o=hpc,dc=rl,dc=ac,dc=uk").format(reg.uuid)},
objectclass={"top", "person", "organizationalPerson",
"inetOrgPerson"},
description={"cluster:jasmin-login"},
cn={reg.uuid},
sn={surname},
)
resources = [
r for i in reg.changes for r in i.resources
if isinstance(r, EmailAddress)]
if resources:
record["mail"].add(resources[0].value)
msg = LDAPProxy.WriteCommonName(record, reg.uuid)
yield from self.ldapQ.put(msg)
session.expire(reg)
except Exception as e:
log.error(e)
finally:
log.debug("Waiting for {}s".format(self.args.interval))
yield from asyncio.sleep(self.args.interval)