def _validateUpstreamServerRegistration(self,registration): # eventually this will validate the user facing hostname ezRPRegistration.get_ngx_server_name(registration) # eventually this will validate the user facing location ezRPRegistration.get_ngx_location(registration) if registration.contentServiceType != ContentServiceType.STATIC_ONLY: # validates upstream portnumber - not yet host ezRPRegistration.getUpstreamHostAndPort(registration) # eventually will validate the upstream path ezRPRegistration.getUpstreamPath(registration) # validate timeout and timeoutTries try: assert registration.timeout > 0 assert registration.timeout <=120 except: raise RegistrationInvalidException("timeout: %d not in range [1,120]" % (registration.timeout)) try: assert registration.timeoutTries > 0 assert registration.timeoutTries <=10 except: raise RegistrationInvalidException("timeoutTries: %d not in range [1,10]" % (registration.timeoutTries)) if gConfig.defaultEznginxOps not in registration.authOperations: raise RegistrationInvalidException("%s authorization operation is required. Specified operations are: %s" % (AuthorizationOperation._VALUES_TO_NAMES[gConfig.defaultEznginxOps], ' ,'.join([AuthorizationOperation._VALUES_TO_NAMES[x] for x in registration.authOperations])))
def removeUpstreamServerRegistration(self, registration): """ Parameters: - registration """ self._logger.info("thrift interface received a call to removeUpstreamServerRegistration with a registration value of %s" % (registration)) self._validateUpstreamServerRegistration(registration) self._validateNoConflictingUpstreamPath(registration) nodeName = ezRPKazoo.KZCONFLOC + '/' + ezRPRegistration.getNodeName(registration) serverName = ezRPRegistration.get_ngx_server_name(registration) sslConfigNodeName = ezRPKazoo.KZSSLCONFLOC + '/' + serverName with self.lock: lock = self.kz.Lock(ezRPKazoo.KZLOCKFILE,"another contender") with lock: if not self.kz.exists(nodeName): raise RegistrationNotFoundException("no registration found for %s" % (nodeName)) else: self._logger.info("removeUpstreamServerRegistration removing %s" % (nodeName)) self.kz.delete(nodeName) if self.kz.exists(sslConfigNodeName) and self._isServerUnique(registration): try: #remove certs if server registration is unique self.kz.delete(sslConfigNodeName) self.ac.remove(serverName) self._logger.info("removed certs for server %s" % serverName) except EzRPCertStoreException as ex: self._logger.exception('Exception in removing certs for server %s' % serverName) self.kz.set(ezRPKazoo.KZWATCHLOC, str(gConfig.current_milli_time()))
def _validateUpstreamServerRegistration(self, registration): # eventually this will validate the user facing hostname ezRPRegistration.get_ngx_server_name(registration) # eventually this will validate the user facing location ezRPRegistration.get_ngx_location(registration) if registration.contentServiceType != ContentServiceType.STATIC_ONLY: # validates upstream portnumber - not yet host ezRPRegistration.getUpstreamHostAndPort(registration) # eventually will validate the upstream path ezRPRegistration.getUpstreamPath(registration) # validate timeout and timeoutTries try: assert registration.timeout > 0 assert registration.timeout <= 120 except: raise RegistrationInvalidException( "timeout: %d not in range [1,120]" % (registration.timeout)) try: assert registration.timeoutTries > 0 assert registration.timeoutTries <= 10 except: raise RegistrationInvalidException( "timeoutTries: %d not in range [1,10]" % (registration.timeoutTries)) if gConfig.defaultEznginxOps not in registration.authOperations: raise RegistrationInvalidException( "%s authorization operation is required. Specified operations are: %s" % (AuthorizationOperation._VALUES_TO_NAMES[ gConfig.defaultEznginxOps], ' ,'.join([ AuthorizationOperation._VALUES_TO_NAMES[x] for x in registration.authOperations ])))
def _validateUpstreamServerRegistration(self,registration): # eventually this will validate the user facing hostname ezRPRegistration.get_ngx_server_name(registration) # eventually this will validate the user facing location ezRPRegistration.get_ngx_location(registration) # validates upstream portnumber - not yet host ezRPRegistration.getUpstreamHostAndPort(registration) # eventually will validate the upstream path ezRPRegistration.getUpstreamPath(registration) # validate timeout and timeoutTries try: assert registration.timeout > 0 assert registration.timeout <=120 except: raise EzReverseProxy.RegistrationInvalidException("timeout: %d not in range [1,120]" % (registration.timeout)) try: assert registration.timeoutTries > 0 assert registration.timeoutTries <=10 except: raise EzReverseProxy.RegistrationInvalidException("timeoutTries: %d not in range [1,10]" % (registration.timeoutTries))
def removeUpstreamServerRegistration(self, registration): """ Parameters: - registration """ self._logger.info( "thrift interface received a call to removeUpstreamServerRegistration with a registration value of %s" % (registration)) self._validateUpstreamServerRegistration(registration) self._validateNoConflictingUpstreamPath(registration) nodeName = ezRPKazoo.KZCONFLOC + '/' + ezRPRegistration.getNodeName( registration) serverName = ezRPRegistration.get_ngx_server_name(registration) sslConfigNodeName = ezRPKazoo.KZSSLCONFLOC + '/' + serverName with self.lock: lock = self.kz.Lock(ezRPKazoo.KZLOCKFILE, "another contender") with lock: if not self.kz.exists(nodeName): raise RegistrationNotFoundException( "no registration found for %s" % (nodeName)) else: self._logger.info( "removeUpstreamServerRegistration removing %s" % (nodeName)) self.kz.delete(nodeName) if self.kz.exists(sslConfigNodeName ) and self._isServerUnique(registration): try: #remove certs if server registration is unique self.kz.delete(sslConfigNodeName) self.ac.remove(serverName) self._logger.info("removed certs for server %s" % serverName) except EzRPCertStoreException as ex: self._logger.exception( 'Exception in removing certs for server %s' % serverName) self.kz.set(ezRPKazoo.KZWATCHLOC, str(gConfig.current_milli_time()))