modify l2-proxy to get token when it was expired
Change-Id: I392f96e2b47e19dc1c959994c02ab7d445da2e37
This commit is contained in:
@@ -54,6 +54,8 @@ from neutron.plugins.l2_proxy.common import constants
|
|||||||
from neutron.plugins.l2_proxy.agent import neutron_proxy_context
|
from neutron.plugins.l2_proxy.agent import neutron_proxy_context
|
||||||
from neutron.plugins.l2_proxy.agent import clients
|
from neutron.plugins.l2_proxy.agent import clients
|
||||||
from neutron.openstack.common import timeutils
|
from neutron.openstack.common import timeutils
|
||||||
|
from neutronclient.common import exceptions
|
||||||
|
from neutron.openstack.common import excutils
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@@ -69,6 +71,8 @@ class DeviceListRetrievalError(exceptions.NeutronException):
|
|||||||
|
|
||||||
class QueryPortsInfoInterface:
|
class QueryPortsInfoInterface:
|
||||||
|
|
||||||
|
cascaded_neutron_client = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.context = n_context.get_admin_context_without_session()
|
self.context = n_context.get_admin_context_without_session()
|
||||||
|
|
||||||
@@ -100,15 +104,26 @@ class QueryPortsInfoInterface:
|
|||||||
filters['page_reverse'] = 'False'
|
filters['page_reverse'] = 'False'
|
||||||
if(pagination_marker):
|
if(pagination_marker):
|
||||||
filters['marker'] = pagination_marker
|
filters['marker'] = pagination_marker
|
||||||
neutronClient = self._get_cascaded_neutron_client()
|
portResponse = None
|
||||||
portResponse = neutronClient.get('/ports', params=filters)
|
if(not QueryPortsInfoInterface.cascaded_neutron_client):
|
||||||
LOG.debug(_('list ports, filters:%s, since_time:%s, limit=%s, marker=%s,'
|
QueryPortsInfoInterface.cascaded_neutron_client = \
|
||||||
'Response:%s'), str(filters), str(since_time),
|
self._get_cascaded_neutron_client()
|
||||||
str(pagination_limit), str(pagination_marker), str(portResponse))
|
try:
|
||||||
if(not portResponse or
|
portResponse = QueryPortsInfoInterface.\
|
||||||
(portResponse and ('ports' not in portResponse.keys()))):
|
cascaded_neutron_client.get('/ports', params=filters)
|
||||||
LOG.error(_("ERR: list ports failed, Response: %s."),
|
LOG.debug(_('list ports, filters:%s, since_time:%s, limit=%s, '
|
||||||
str(portResponse))
|
'marker=%s, Response:%s'), str(filters),
|
||||||
|
str(since_time), str(pagination_limit),
|
||||||
|
str(pagination_marker), str(portResponse))
|
||||||
|
except exceptions.Unauthorized:
|
||||||
|
QueryPortsInfoInterface.cascaded_neutron_client = \
|
||||||
|
self._get_cascaded_neutron_client()
|
||||||
|
return self._list_ports(since_time,
|
||||||
|
pagination_limit,
|
||||||
|
pagination_marker)
|
||||||
|
except Exception:
|
||||||
|
with excutils.save_and_reraise_exception():
|
||||||
|
LOG.error(_('ERR: list ports failed!'))
|
||||||
return None
|
return None
|
||||||
return portResponse
|
return portResponse
|
||||||
|
|
||||||
@@ -150,6 +165,7 @@ class QueryPortsInfoInterface:
|
|||||||
ports = self._get_ports_pagination(since_time)
|
ports = self._get_ports_pagination(since_time)
|
||||||
return ports.get("ports", [])
|
return ports.get("ports", [])
|
||||||
|
|
||||||
|
|
||||||
class RemotePort:
|
class RemotePort:
|
||||||
|
|
||||||
def __init__(self, port_id, port_name, mac, binding_profile, ips=None):
|
def __init__(self, port_id, port_name, mac, binding_profile, ips=None):
|
||||||
@@ -459,6 +475,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
|
|||||||
if not self.l2_pop:
|
if not self.l2_pop:
|
||||||
self._setup_tunnel_port(self.tun_br, tun_name, tunnel_ip,
|
self._setup_tunnel_port(self.tun_br, tun_name, tunnel_ip,
|
||||||
tunnel_type)
|
tunnel_type)
|
||||||
|
|
||||||
def _create_port(self, context, network_id, binding_profile, port_name,
|
def _create_port(self, context, network_id, binding_profile, port_name,
|
||||||
mac_address, ips):
|
mac_address, ips):
|
||||||
if(not network_id):
|
if(not network_id):
|
||||||
@@ -679,8 +696,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
|
|||||||
LOG.error(_("No local VLAN available for net-id=%s"), net_uuid)
|
LOG.error(_("No local VLAN available for net-id=%s"), net_uuid)
|
||||||
return
|
return
|
||||||
lvid = self.available_local_vlans.pop()
|
lvid = self.available_local_vlans.pop()
|
||||||
self.local_vlan_map[net_uuid] = LocalVLANMapping(
|
self.local_vlan_map[net_uuid] = LocalVLANMapping(network_type,
|
||||||
network_type,
|
|
||||||
physical_network,
|
physical_network,
|
||||||
segmentation_id,
|
segmentation_id,
|
||||||
cascaded_net_id)
|
cascaded_net_id)
|
||||||
@@ -776,8 +792,6 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
|
|||||||
cascaded_port_info['id'],
|
cascaded_port_info['id'],
|
||||||
cascaded_port_info['mac_address'])
|
cascaded_port_info['mac_address'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def port_unbound(self, vif_id, net_uuid=None):
|
def port_unbound(self, vif_id, net_uuid=None):
|
||||||
'''Unbind port.
|
'''Unbind port.
|
||||||
|
|
||||||
@@ -1082,7 +1096,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
|
|||||||
return cur_ports
|
return cur_ports
|
||||||
|
|
||||||
def scan_ports(self, registered_ports, updated_ports=None):
|
def scan_ports(self, registered_ports, updated_ports=None):
|
||||||
if(self.first_scan_flag == True):
|
if(self.first_scan_flag):
|
||||||
ports_info = self.query_ports_info_inter.get_update_net_port_info()
|
ports_info = self.query_ports_info_inter.get_update_net_port_info()
|
||||||
self.first_scan_flag = False
|
self.first_scan_flag = False
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user