本文整理汇总了Python中empower.main.RUNTIME.load_tenant方法的典型用法代码示例。如果您正苦于以下问题:Python RUNTIME.load_tenant方法的具体用法?Python RUNTIME.load_tenant怎么用?Python RUNTIME.load_tenant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类empower.main.RUNTIME
的用法示例。
在下文中一共展示了RUNTIME.load_tenant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _handle_status_lvap
# 需要导入模块: from empower.main import RUNTIME [as 别名]
# 或者: from empower.main.RUNTIME import load_tenant [as 别名]
#.........这里部分代码省略.........
LOG.info("LVAP status update from %s", sta_addr)
# If the LVAP does not exists, then create a new one
if sta_addr not in RUNTIME.lvaps:
net_bssid_addr = EtherAddress(status.net_bssid)
lvap_bssid_addr = EtherAddress(status.lvap_bssid)
lvap = LVAP(sta_addr, net_bssid_addr, lvap_bssid_addr)
# TODO: This should be built starting from the status message
lvap.supports.add(ResourceBlock(lvap, sta_addr, 1, BT_L20))
lvap.supports.add(ResourceBlock(lvap, sta_addr, 2, BT_L20))
lvap.supports.add(ResourceBlock(lvap, sta_addr, 3, BT_L20))
lvap.supports.add(ResourceBlock(lvap, sta_addr, 4, BT_L20))
lvap.supports.add(ResourceBlock(lvap, sta_addr, 5, BT_L20))
lvap.supports.add(ResourceBlock(lvap, sta_addr, 6, BT_L20))
lvap.supports.add(ResourceBlock(lvap, sta_addr, 7, BT_L20))
lvap.supports.add(ResourceBlock(lvap, sta_addr, 8, BT_L20))
lvap.supports.add(ResourceBlock(lvap, sta_addr, 9, BT_L20))
lvap.supports.add(ResourceBlock(lvap, sta_addr, 10, BT_L20))
lvap.supports.add(ResourceBlock(lvap, sta_addr, 11, BT_L20))
lvap.supports.add(ResourceBlock(lvap, sta_addr, 36, BT_L20))
lvap.supports.add(ResourceBlock(lvap, sta_addr, 48, BT_L20))
RUNTIME.lvaps[sta_addr] = lvap
lvap = RUNTIME.lvaps[sta_addr]
# incoming block
pool = ResourcePool()
pool.add(block)
match = wtp.supports & pool
if not match:
LOG.error("Incoming block %s is invalid", block)
return
# this will try to updated the lvap object with the resource block
# coming in this status update message.
try:
if set_mask:
# set downlink+uplink block
lvap._downlink.setitem(block, RadioPort(lvap, block))
else:
# set uplink only blocks
lvap._uplink.setitem(block, RadioPort(lvap, block))
except ValueError:
LOG.error("Error while importing block %s, removing.", block)
block.radio.connection.send_del_lvap(lvap)
return
lvap.authentication_state = bool(status.flags.authenticated)
lvap.association_state = bool(status.flags.associated)
lvap._assoc_id = status.assoc_id
lvap._encap = EtherAddress(status.encap)
ssids = [SSID(x.ssid) for x in status.ssids]
if lvap.ssid:
# Raise LVAP leave event
LOG.info("LVAP LEAVE %s (%s)", lvap.addr, lvap.ssid)
for handler in self.server.pt_types_handlers[PT_LVAP_LEAVE]:
handler(lvap)
# removing LVAP from tenant, need first to look for right tenant
if lvap.addr in lvap.tenant.lvaps:
LOG.info("Removing %s from tenant %s", lvap.addr, lvap.ssid)
del lvap.tenant.lvaps[lvap.addr]
lvap._tenant = None
if ssids[0]:
# setting tenant without seding out add lvap message
lvap._tenant = RUNTIME.load_tenant(ssids[0])
# adding LVAP to tenant
LOG.info("Adding %s to tenant %s", lvap.addr, ssids[0])
lvap.tenant.lvaps[lvap.addr] = lvap
# Raise LVAP join event
LOG.info("LVAP JOIN %s (%s)", lvap.addr, lvap.ssid)
for handler in self.server.pt_types_handlers[PT_LVAP_JOIN]:
handler(lvap)
# update remaining ssids
lvap._ssids = ssids[1:]
# set ports
lvap.set_ports()
LOG.info("LVAP status %s", lvap)
示例2: _handle_assoc_request
# 需要导入模块: from empower.main import RUNTIME [as 别名]
# 或者: from empower.main.RUNTIME import load_tenant [as 别名]
def _handle_assoc_request(self, request):
"""Handle an incoming ASSOC_REQUEST message.
Args:
request, a ASSOC_REQUEST message
Returns:
None
"""
wtp_addr = EtherAddress(request.wtp)
try:
wtp = RUNTIME.wtps[wtp_addr]
except KeyError:
LOG.info("Assoc request from unknown WTP %s", wtp_addr)
return
if not wtp.connection:
LOG.info("Assoc request from disconnected WTP %s", wtp_addr)
return
sta = EtherAddress(request.sta)
if sta not in RUNTIME.lvaps:
LOG.info("Assoc request from unknown LVAP %s", sta)
return
lvap = RUNTIME.lvaps[sta]
if not RUNTIME.is_allowed(sta):
LOG.info("Assoc request from %s ignored (white list)", sta)
return
if RUNTIME.is_denied(sta):
LOG.info("Assoc request from %s ignored (black list)", sta)
return
ssid = SSID(request.ssid.decode('UTF-8'))
bssid = EtherAddress(request.bssid)
tenant_name = None
# look for ssid in shared tenants
for tenant_id in RUNTIME.tenants:
tenant = RUNTIME.tenants[tenant_id]
if tenant.bssid_type == T_TYPE_UNIQUE:
continue
if bssid in tenant.vaps and ssid == tenant.tenant_name:
tenant_name = tenant.tenant_name
# otherwise this must be the lvap unique bssid
if lvap.net_bssid == bssid and ssid in lvap.ssids:
tenant_name = ssid
if not tenant_name:
LOG.info("Assoc request sta %s for ssid %s bssid %s, ignoring",
lvap.addr, lvap.ssid, lvap.lvap_bssid)
return
# this will trigger an add lvap message to update the ssid
lvap.tenant = RUNTIME.load_tenant(tenant_name)
# this will trigger an add lvap message to update the assoc id
lvap.assoc_id = self.server.assoc_id
LOG.info("Assoc request sta %s ssid %s bssid %s assoc id %u, replying",
lvap.addr, lvap.ssid, lvap.lvap_bssid, lvap.assoc_id)
self.send_assoc_response(lvap)