diff options
-rw-r--r-- | ryu/app/quantum_adapter.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ryu/app/quantum_adapter.py b/ryu/app/quantum_adapter.py index b6ea8b80..f6b267d0 100644 --- a/ryu/app/quantum_adapter.py +++ b/ryu/app/quantum_adapter.py @@ -132,16 +132,11 @@ class OVSPort(object): class OVSSwitch(object): def __init__(self, dpid, nw, ifaces, logger): # TODO: clean up - token = None - if CONF.neutron_auth_strategy: - token = _get_auth_token(logger) - q_api = _get_quantum_client(token) - self.dpid = dpid self.network_api = nw self.ifaces = ifaces self.logger = logger - self.q_api = q_api + self._q_api = None # lazy initialization self.ctrl_addr = CONF.neutron_controller_addr if not self.ctrl_addr: raise ValueError('option neutron_controler_addr must be speicfied') @@ -154,6 +149,15 @@ class OVSSwitch(object): super(OVSSwitch, self).__init__() + @property + def q_api(self): + if self._q_api is None: + token = None + if CONF.neutron_auth_strategy: + token = _get_auth_token(self.logger) + self._q_api = _get_quantum_client(token) + return self._q_api + def set_ovsdb_addr(self, dpid, ovsdb_addr): # easy check if the address format valid self.logger.debug('set_ovsdb_addr dpid %s ovsdb_addr %s', |