コード例 #1
0
ファイル: ovsdbmanager.py プロジェクト: vtanrun/vlcp
 def waitconnection(self, datapathid, timeout=30, vhost=''):
     "Wait for a datapath connection"
     for m in self.getconnection(datapathid, vhost):
         yield m
     c = self.apiroutine.retvalue
     if c is None:
         for m in self.apiroutine.waitWithTimeout(
                 timeout,
                 OVSDBBridgeSetup.createMatcher(state=OVSDBBridgeSetup.UP,
                                                datapathid=datapathid,
                                                vhost=vhost)):
             yield m
         if self.apiroutine.timeout:
             raise ConnectionResetException('Datapath is not connected')
         self.apiroutine.retvalue = self.apiroutine.event.connection
     else:
         self.apiroutine.retvalue = c
コード例 #2
0
 def waitconnection(self, datapathid, auxiliaryid=0, timeout=30, vhost=''):
     "Wait for a datapath connection"
     for m in self._wait_for_sync():
         yield m
     c = self._getconnection(datapathid, auxiliaryid, vhost)
     if c is None:
         for m in self.apiroutine.waitWithTimeout(
                 timeout,
                 OpenflowConnectionStateEvent.createMatcher(
                     datapathid,
                     auxiliaryid,
                     OpenflowConnectionStateEvent.CONNECTION_SETUP,
                     _ismatch=lambda x: x.createby.vhost == vhost)):
             yield m
         if self.apiroutine.timeout:
             raise ConnectionResetException(
                 'Datapath %016x is not connected' % datapathid)
         self.apiroutine.retvalue = self.apiroutine.event.connection
     else:
         self.apiroutine.retvalue = c
コード例 #3
0
ファイル: ovsdbmanager.py プロジェクト: missuzhang/vlcp
 def waitbridgebyuuid(self, connection, uuid, timeout = 30):
     "Wait for bridge with specified _uuid appears and return the datapath-id"
     for m in self.getbridgebyuuid(connection, uuid):
         yield m
     if self.apiroutine.retvalue is None:
         bridge_setup = OVSDBBridgeSetup.createMatcher(state = OVSDBBridgeSetup.UP,
                                                      connection = connection,
                                                      bridgeuuid = uuid
                                                      )
         conn_down = JsonRPCConnectionStateEvent.createMatcher(JsonRPCConnectionStateEvent.CONNECTION_DOWN,
                                                               connection,
                                                               connection.connmark)
         for m in self.apiroutine.waitWithTimeout(timeout, bridge_setup, conn_down):
             yield m
         if self.apiroutine.timeout:
             raise OVSDBBridgeNotAppearException('Bridge ' + repr(uuid) + ' does not appear')
         elif self.apiroutine.matcher is conn_down:
             raise ConnectionResetException('Connection is down before bridge ' + repr(uuid) + ' appears')
         else:
             self.apiroutine.retvalue = self.apiroutine.event.datapathid
コード例 #4
0
ファイル: ofpmanager.py プロジェクト: sinofeng/vlcp
 async def waitconnection(self,
                          datapathid,
                          auxiliaryid=0,
                          timeout=30,
                          vhost=''):
     "Wait for a datapath connection"
     await self._wait_for_sync()
     c = self._getconnection(datapathid, auxiliaryid, vhost)
     if c is None:
         timeout_, ev, _ = await self.apiroutine.wait_with_timeout(
             timeout,
             OpenflowConnectionStateEvent.createMatcher(
                 datapathid,
                 auxiliaryid,
                 OpenflowConnectionStateEvent.CONNECTION_SETUP,
                 _ismatch=lambda x: x.createby.vhost == vhost))
         if timeout_:
             raise ConnectionResetException(
                 'Datapath %016x is not connected' % datapathid)
         return ev.connection
     else:
         return c
コード例 #5
0
 async def waitbridgebyuuid(self, connection, uuid, timeout=30):
     "Wait for bridge with specified _uuid appears and return the datapath-id"
     dpid = await self.getbridgebyuuid(connection, uuid)
     if dpid is None:
         bridge_setup = OVSDBBridgeSetup.createMatcher(
             state=OVSDBBridgeSetup.UP,
             connection=connection,
             bridgeuuid=uuid)
         conn_down = JsonRPCConnectionStateEvent.createMatcher(
             JsonRPCConnectionStateEvent.CONNECTION_DOWN, connection,
             connection.connmark)
         timeout_, ev, m = await self.apiroutine.wait_with_timeout(
             timeout, bridge_setup, conn_down)
         if timeout_:
             raise OVSDBBridgeNotAppearException('Bridge ' + repr(uuid) +
                                                 ' does not appear')
         elif m is conn_down:
             raise ConnectionResetException(
                 'Connection is down before bridge ' + repr(uuid) +
                 ' appears')
         else:
             return ev.datapathid
     else:
         return dpid