def get_vnc_port(session):
 min_port = CONF.vmware.vnc_port
 port_total = CONF.vmware.vnc_port_total
 allocated_ports = _get_allocated_vnc_ports(session)
 max_port = (min_port + port_total)
 for port in range(min_port, max_port):
  if (port not in allocated_ports):
   return port
 raise exception.ConsolePortRangeExhausted(min_port=min_port, max_port=max_port)

def get_vnc_port ( session ) : min_port = CONF . vmware . vnc_port port_total = CONF . vmware . vnc_port_total allocated_ports = _get_allocated_vnc_ports ( session ) max_port = ( min_port + port_total ) for port in range ( min_port , max_port ) : if ( port not in allocated_ports ) : return port raise exception . ConsolePortRangeExhausted ( min_port = min_port , max_port = max_port )
return vnc port for an vm or none if there is no available port .