Dettach network from Internet gateway
        :Param  req
        :Type   object Request
777660
def dettach_igw(self, req, driver):
        
        response = driver.dettach_igw(req.params)
        data = {
            'action': 'attach_igw',
            'controller': 'network',
            'id': id,
            'cloud': req.environ['calplus.cloud'],
            'response': response
        }
        return data
928393
def connection_lost(self, exc):
        """"""
        _LOGGER.debug('Connection lost with %s', self.transport)
        if self.gateway.cancel_check_conn:
            self.gateway.cancel_check_conn()
            self.gateway.cancel_check_conn = None
        if exc:
            _LOGGER.error(exc)
            self.conn_lost_callback()
        self.transport = None
549574
def handle_get_request(self, environ, start_response):
        """"""
        connections = [
            s.strip()
            for s in environ.get('HTTP_CONNECTION', '').lower().split(',')]
        transport = environ.get('HTTP_UPGRADE', '').lower()
        if 'upgrade' in connections and transport in self.upgrade_protocols:
            self.server.logger.info('%s: Received request to upgrade to %s',
                                    self.sid, transport)
            return getattr(self, '_upgrade_' + transport)(environ,
                                                          start_response)
        try:
            packets = self.poll()
        except exceptions.QueueEmpty:
            exc = sys.exc_info()
            self.close(wait=False)
            six.reraise(*exc)
        return packets
968211
function middlewareFunction (req,res,next){

  return ipToLocation(req.ip)
    .then(function (location) {
      req.location = location;
      next();
    })
    .catch(function (error) {
      req.locationError = error;
      next();
    })

}
540023
def remove(self):
        
        LOGGER.debug("IPAddress.remove")
        if self.id is None:
            return None
        else:
            params = {
                'id': self.id
            }
            args = {'http_operation': 'GET', 'operation_path': 'delete', 'parameters': params}
            response = IPAddressService.requester.call(args)
            if response.rc != 0:
                LOGGER.warning(
                    'IPAddress.remove - Problem while deleting IP Address' + self.ip_address +
                    '. Reason: ' + str(response.response_content) + '-' + str(response.error_message) +
                    " (" + str(response.rc) + ")"
                )
                return self
            else:
                return None
749979
async def create_tunnel_connection(self, req):
        
        tunnel_address = req.tunnel_address
        connection = await self.create_connection(tunnel_address)
        response = connection.current_consumer()
        for event in response.events().values():
            event.clear()
        response.start(HttpTunnel(self, req))
        await response.event('post_request').waiter()
        if response.status_code != 200:
            raise ConnectionRefusedError(
                'Cannot connect to tunnel: status code %s'
                % response.status_code
            )
        raw_sock = connection.transport.get_extra_info('socket')
        if raw_sock is None:
            raise RuntimeError('Transport without socket')
        # duplicate socket so we can close transport
        raw_sock = raw_sock.dup()
        connection.transport.close()
        await connection.event('connection_lost').waiter()
        self.sessions -= 1
        self.requests_processed -= 1
        #
        connection = await self.create_connection(
            sock=raw_sock, ssl=req.ssl(self), server_hostname=req.netloc
        )
        return connection
1315983
async def detach(self, discard=True):
        '''
        '''
        if discard:
            return self.close(True)
        else:
            self.connection._exit_ = False
            return self
1018182
def remove_router_interface(self, context, router_id, interface_info):
        """"""

        router_to_del = (
            super(AristaL3ServicePlugin, self).remove_router_interface(
                context,
                router_id,
                interface_info)
            )

        # Get network information of the subnet that is being removed
        core = directory.get_plugin()
        subnet = core.get_subnet(context, router_to_del['subnet_id'])
        network_id = subnet['network_id']

        # For SVI removal from Arista HW, segmentation ID is needed
        ml2_db = NetworkContext(self, context, {'id': network_id})
        seg_id = ml2_db.network_segments[0]['segmentation_id']

        router = self.get_router(context, router_id)
        router_info = copy.deepcopy(router_to_del)
        router_info['seg_id'] = seg_id
        router_info['name'] = router['name']

        try:
            self.driver.remove_router_interface(context, router_info)
            return router_to_del
        except Exception as exc:
            LOG.error(_LE("Error removing interface %(interface)s from "
                          "router %(router_id)s on Arista HW"
                          "Exception =(exc)s"),
                      {'interface': interface_info, 'router_id': router_id,
                       'exc': exc})
915571
def request_done(self, request):
        """"""
        if self._requests is None:
            # Channel been cleaned up because the connection was lost.
            return

        assert request == self._requests[0], "Unexpected request done"
        del self._requests[0]

        if request.persistent:
            # Activate the next request in the pipeline if any
            if self._requests:
                self._requests[0].activate()
        else:
            self.transport.loseConnection()
538781
def _disconnect(self):
        """"""
        if not self.protocol or not self.protocol.transport:
            self.protocol = None  # Make sure protocol is None
            return
        _LOGGER.info('Disconnecting from gateway')
        self.protocol.transport.close()
        self.protocol = None
69749
def req(self, timeout):
        ''''''
        self.connection.req(self.id, timeout)
        self.processed = True
1019661
def disconnect_all(self):
        
        addresses = deepcopy(self._addresses)

        for ip, port in addresses:
            self.disconnect(ip, port)

        return self
216044
def delete(self, req, driver):
        
        response = driver.delete_network(req.params, id)
        data = {
            'action': "delete",
            'controller': "network",
            'id': id,
            'cloud': req.environ['calplus.cloud'],
            'response': response
        }
        return data
151864
async def teardown_conn(self, context):
        """"""

        client_id = context.user_data

        self._logger.info("Tearing down client connection: %s", client_id)
        if client_id not in self.clients:
            self._logger.warning("client_id %s did not exist in teardown_conn", client_id)
        else:
            del self.clients[client_id]
1118733
private void removePendingRequest(ResourceRequestInfo req) {
    ResourceRequestInfo removed = idToPendingRequests.remove(req.getId());
    if (removed != null) {
      if (req.getHosts() != null && req.getHosts().size() > 0) {
        Context c = getContext(req.getType());
        for (RequestedNode node : req.getRequestedNodes()) {
          String host = node.getHost();
          List<ResourceRequestInfo> hostReqs =
            c.hostToPendingRequests.get(host);
          Utilities.removeReference(hostReqs, req);
          if (hostReqs.isEmpty()) {
            c.hostToPendingRequests.remove(host);
          }
          Node rack = node.getRack();
          List<ResourceRequestInfo> rackReqs =
            c.rackToPendingRequests.get(rack);
          Utilities.removeReference(rackReqs, req);
          if (rackReqs.isEmpty()) {
            c.rackToPendingRequests.remove(rack);
          }
        }
      }
      Context c = getContext(req.getType());
      Utilities.removeReference(c.anyHostRequests, req);
    }

    removePendingRequestForType(req);
  }
433072
def _delete_request(self, url, headers, data=None):
        
        return self._session.delete(url, headers=headers, data=data)
176934
def _request(self, request, proxies, timeout, verify, **_):
        

        settings = self.http.merge_environment_settings(
            request.url, proxies, False, verify, None)

        self._delay()
        response = self.http.send(
            request, timeout=timeout, allow_redirects=False, **settings)
        self._update(response.headers)

        return response