Guest User

Untitled

a guest
Mar 28th, 2016
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. def _get_active_port_count(session, agent_host, network_id, model):
  2.     query = session.query(models_v2.Port)
  3.     query = query.join(model)
  4.     query = query.filter(
  5.         models_v2.Port.network_id == network_id,
  6.         models_v2.Port.status == const.PORT_STATUS_ACTIVE,
  7.         ml2_models.PortBinding.host == agent_host)
  8.     return query
  9.  
  10.  
  11. def get_nondistributed_active_port_count(session, agent_host, network_id):
  12.     query = _get_active_port_count(ml2_models.PortBinding).filter(
  13.         ~models_v2.Port.device_owner.in_(DISTRIBUTED_INTERFACE_OWNERS))
  14.     return query.count()
  15.  
  16.  
  17. def get_dvr_active_port_count(session, agent_host, network_id):
  18.     query = _get_active_port_count(ml2_models.PortBinding).filter(
  19.         models_v2.Port.device_owner == const.DEVICE_OWNER_DVR_INTERFACE)
  20.     return query.count()
Advertisement
Add Comment
Please, Sign In to add comment