huskar_api/models/route/hijack.py
def hijack_request(self, request_data):
        """Checks or hijacks the request arguments."""
        if self.route_mode == ROUTE_MODE_ROUTE:
            return request_data

        if (self.hijack_mode is self.Mode.disabled and
                not self._force_enable_dest_apps):
            return request_data

        request_data = copy.deepcopy(request_data)
        for type_name, application_names in request_data.items():
            if type_name != SERVICE_SUBDOMAIN:
                continue
            for application_name, cluster_names in application_names.items():
                intent_map = _build_intent_map(cluster_names)
                self.hijack_map[application_name] = intent_map
                if self.hijack_mode in (self.Mode.checking, self.Mode.enabled):
                    self._check_request(application_name, intent_map)
                if (self.hijack_mode in (
                        self.Mode.enabled, self.Mode.standalone) or
                        application_name in self._force_enable_dest_apps):
                    application_names[application_name] = [
                        intent for intent, icluster_names in intent_map.items()
                        if icluster_names]
                    logger.info(
                        'Hijack: %s %s -> %s %s', self.from_application_name,
                        self.from_cluster_name, application_name, intent_map)
        return request_data
Checks or hijacks the request arguments.
Checks or hijacks the request arguments.
Checks or hijacks the request arguments .
def hijack_request(self, request_data):
        if self.route_mode == ROUTE_MODE_ROUTE:
            return request_data
        if (self.hijack_mode is self.Mode.disabled and
                not self._force_enable_dest_apps):
            return request_data
        request_data = copy.deepcopy(request_data)
        for type_name, application_names in request_data.items():
            if type_name != SERVICE_SUBDOMAIN:
                continue
            for application_name, cluster_names in application_names.items():
                intent_map = _build_intent_map(cluster_names)
                self.hijack_map[application_name] = intent_map
                if self.hijack_mode in (self.Mode.checking, self.Mode.enabled):
                    self._check_request(application_name, intent_map)
                if (self.hijack_mode in (
                        self.Mode.enabled, self.Mode.standalone) or
                        application_name in self._force_enable_dest_apps):
                    application_names[application_name] = [
                        intent for intent, icluster_names in intent_map.items()
                        if icluster_names]
                    logger.info(
                        'Hijack: %s %s -> %s %s', self.from_application_name,
                        self.from_cluster_name, application_name, intent_map)
        return request_data
def hijack_request ( self , request_data ) : if self . route_mode == ROUTE_MODE_ROUTE : return request_data if ( self . hijack_mode is self . Mode . disabled and not self . _force_enable_dest_apps ) : return request_data request_data = copy . deepcopy ( request_data ) for type_name , application_names in request_data . items ( ) : if type_name != SERVICE_SUBDOMAIN : continue for application_name , cluster_names in application_names . items ( ) : intent_map = _build_intent_map ( cluster_names ) self . hijack_map [ application_name ] = intent_map if self . hijack_mode in ( self . Mode . checking , self . Mode . enabled ) : self . _check_request ( application_name , intent_map ) if ( self . hijack_mode in ( self . Mode . enabled , self . Mode . standalone ) or application_name in self . _force_enable_dest_apps ) : application_names [ application_name ] = [ intent for intent , icluster_names in intent_map . items ( ) if icluster_names ] logger . info ( 'Hijack: %s %s -> %s %s' , self . from_application_name , self . from_cluster_name , application_name , intent_map ) return request_data
Checks or hijacks the request arguments.
Checks or hijacks the request arguments .
"""Checks or hijacks the request arguments."""
self
request_data