本文整理汇总了Python中empower.persistence.Session.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Session.delete方法的具体用法?Python Session.delete怎么用?Python Session.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类empower.persistence.Session
的用法示例。
在下文中一共展示了Session.delete方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_pnfdev
# 需要导入模块: from empower.persistence import Session [as 别名]
# 或者: from empower.persistence.Session import delete [as 别名]
def remove_pnfdev(self, pnfdev):
"""Remove a PNFDev from the Tenant.
Args:
addr, a PNFDev object
Returns:
None
Raises:
KeyError, if the pnfdev is not available
"""
pnfdevs = getattr(self, pnfdev.ALIAS)
if pnfdev.addr not in pnfdevs:
return
del pnfdevs[pnfdev.addr]
belongs = Session().query(TblBelongs) \
.filter(TblBelongs.tenant_id == self.tenant_id,
TblBelongs.addr == pnfdev.addr) \
.first()
session = Session()
session.delete(belongs)
session.commit()
示例2: reject_tenant
# 需要导入模块: from empower.persistence import Session [as 别名]
# 或者: from empower.persistence.Session import delete [as 别名]
def reject_tenant(cls, tenant_id):
"""Reject previously requested Tenant."""
pending = Session().query(TblPendingTenant) \
.filter(TblPendingTenant.tenant_id == tenant_id) \
.first()
if not pending:
raise KeyError(tenant_id)
session = Session()
session.delete(pending)
session.commit()
示例3: remove_denied
# 需要导入模块: from empower.persistence import Session [as 别名]
# 或者: from empower.persistence.Session import delete [as 别名]
def remove_denied(self, sta_addr):
""" Remove entry from ACL. """
deny = Session().query(TblDeny) \
.filter(TblDeny.addr == sta_addr) \
.first()
if not deny:
raise KeyError(sta_addr)
session = Session()
session.delete(deny)
session.commit()
del self.denied[sta_addr]
示例4: remove_allowed
# 需要导入模块: from empower.persistence import Session [as 别名]
# 或者: from empower.persistence.Session import delete [as 别名]
def remove_allowed(self, sta_addr):
""" Remove entry from ACL. """
allow = Session().query(TblAllow) \
.filter(TblAllow.addr == sta_addr) \
.first()
if not allow:
raise KeyError(sta_addr)
session = Session()
session.delete(allow)
session.commit()
del self.allowed[sta_addr]
示例5: remove_imsi2mac
# 需要导入模块: from empower.persistence import Session [as 别名]
# 或者: from empower.persistence.Session import delete [as 别名]
def remove_imsi2mac(self, imsi):
"""Remove IMSI to MAC mapped value from table."""
imsi2mac = Session().query(TblIMSI2MAC) \
.filter(TblIMSI2MAC.imsi == imsi) \
.first()
if not imsi2mac:
raise KeyError(imsi)
session = Session()
session.delete(imsi2mac)
session.commit()
del self.imsi2mac[imsi]
示例6: remove_feed
# 需要导入模块: from empower.persistence import Session [as 别名]
# 或者: from empower.persistence.Session import delete [as 别名]
def remove_feed(self, feed_id):
"""Remove Feed."""
if feed_id not in RUNTIME.feeds:
raise KeyError(feed_id)
self.bind_feed(feed_id)
del RUNTIME.feeds[feed_id]
feed = Session().query(TblFeed) \
.filter(TblFeed.feed_id == feed_id) \
.first()
session = Session()
session.delete(feed)
session.commit()
示例7: remove_tenant
# 需要导入模块: from empower.persistence import Session [as 别名]
# 或者: from empower.persistence.Session import delete [as 别名]
def remove_tenant(self, tenant_id):
"""Delete existing Tenant."""
if tenant_id not in self.tenants:
raise KeyError(tenant_id)
tenant = self.tenants[tenant_id]
# remove pnfdev in this tenant
devs = Session().query(TblBelongs) \
.filter(TblBelongs.tenant_id == tenant_id)
for dev in devs:
session = Session()
session.delete(dev)
session.commit()
# remove tenant
del self.tenants[tenant_id]
tenant = Session().query(TblTenant) \
.filter(TblTenant.tenant_id == tenant_id) \
.first()
session = Session()
session.delete(tenant)
session.commit()
# remove running modules
for component in self.components.values():
if not hasattr(component, 'modules'):
continue
to_be_removed = []
for module in component.modules.values():
if module.tenant_id == tenant_id:
to_be_removed.append(module.module_id)
for module_id in to_be_removed:
component.remove_module(module_id)
示例8: remove_account
# 需要导入模块: from empower.persistence import Session [as 别名]
# 或者: from empower.persistence.Session import delete [as 别名]
def remove_account(self, username):
"""Remove an account."""
if username == 'root':
raise ValueError("Cannot removed root account")
account = Session().query(TblAccount) \
.filter(TblAccount.username == str(username)) \
.first()
if not account:
raise KeyError(username)
session = Session()
session.delete(account)
session.commit()
del self.accounts[username]
to_be_deleted = [x.tenant_id for x in self.tenants.values()
if x.owner == username]
for tenant_id in to_be_deleted:
self.remove_tenant(tenant_id)
示例9: remove_pnfdev
# 需要导入模块: from empower.persistence import Session [as 别名]
# 或者: from empower.persistence.Session import delete [as 别名]
def remove_pnfdev(self, addr):
"""Remove PNFDev."""
if addr not in self.pnfdevs:
raise KeyError(addr)
pnfdev = self.pnfdevs[addr]
for tenant in RUNTIME.tenants.values():
tenant_pnfdevs = getattr(tenant, self.PNFDEV.ALIAS)
if addr in tenant_pnfdevs:
tenant.remove_pnfdev(pnfdev)
del self.pnfdevs[addr]
pnfdev = Session().query(self.TBL_PNFDEV) \
.filter(self.TBL_PNFDEV.addr == addr) \
.first()
session = Session()
session.delete(pnfdev)
session.commit()