def set_network(self,network): self.vmap = self.make_vmap() self.ingress_policy.vmap = self.vmap self.fabric_policy.vmap = self.vmap self.egress_policy.vmap = self.vmap self.locate_in_underlying.vmap = self.vmap self.ingress_policy.set_network(network) self.fabric_policy.set_network(network) self.egress_policy.set_network(network) self.derived.injection_policy = ( str_print("-- " + str(self.vtag) + " injection_policy start ",self.DEBUG) >> pkt_print(str(self.vtag) + " injected packet",self.DEBUG) >> str_print("-- " + str(self.vtag) + " lower packet",self.DEBUG) >> lower_packet(self.vtag) >> pkt_print(str(self.vtag) + " after lower:",self.DEBUG) >> str_print("-- " + str(self.vtag) + " locate packet",self.DEBUG) >> self.locate_in_underlying >> pkt_print(str(self.vtag) + " after locate:",self.DEBUG) >> if_(match(outport=-1) | match(outport=None), # IF NO OUTPORT str_print("-- " + str(self.vtag) + " apply fabric policy",self.DEBUG) >> self.fabric_policy >> # THEN WE NEED TO RUN THE FABRIC POLICY pkt_print(str(self.vtag) + " after fabric:",self.DEBUG), passthrough) >> # OTHERWISE WE PASSTHROUGH TO EGRESS POLICY str_print("-- " + str(self.vtag) + " apply egress policy",self.DEBUG) >> self.egress_policy >> pkt_print(str(self.vtag) + " after egress:",self.DEBUG) >> str_print("-- " + str(self.vtag) + " injection_policy end ",self.DEBUG) )
def __init__(self, vpolicy, vdef, DEBUG=no_packets): self.vpolicy = vpolicy self.vnetwork = None self.vtag = new_vtag() self.vdef = vdef self.DEBUG = DEBUG self.vdef.DEBUG = self.DEBUG self.vdef.vtag = self.vtag ### THE VIRTUALIZED POLICY if self.DEBUG == no_packets: super(virtualize, self).__init__( if_(match(outport=None), push(outport=-1)) >> self.vdef.ingress_policy >> # set vlocation ### IF INGRESSING LIFT AND EVALUATE if_(match(vtag='ingress'), lift_packet >> self.vpolicy >> lower_packet(self.vtag)) >> ### IF IN INTERIOR NETWORK ROUTE ON FABRIC AND IF APPLICABLE EGRESS if_(match(vtag=self.vtag), self.vdef.fabric_policy >> self.vdef.egress_policy, self.vpolicy)) ### THE VIRTUALIZED POLICY W/ DEBUGGING else: super(virtualize, self).__init__( (self.DEBUG & pkt_print(repr(self))) + if_(match(outport=None), push(outport=-1)) >> (self.DEBUG & str_print("-- " + str(self.vtag) + " apply ingress policy")) + self.vdef.ingress_policy >> # set vlocation (self.DEBUG & pkt_print(str(self.vtag) + " after ingress:")) + ### IF INGRESSING LIFT AND EVALUATE if_(match(vtag='ingress'), (self.DEBUG & str_print( "-- " + str(self.vtag) + " lift packet")) + lift_packet >> (self.DEBUG & (pkt_print(str(self.vtag) + " after lift:") + str_print( "-- " + str(self.vtag) + " run derived policy"))) + self.vpolicy >> (self.DEBUG & (pkt_print(str(self.vtag) + " after derived policy:") + str_print("-- " + str(self.vtag) + " lower packet"))) + lower_packet(self.vtag) >> (self.DEBUG & pkt_print( str(self.vtag) + " after lower:")) + passthrough, (self.DEBUG & str_print("-- " + str(self.vtag) + " non_ingress")) + passthrough) >> ### IF IN INTERIOR NETWORK ROUTE ON FABRIC AND IF APPLICABLE EGRESS if_(match(vtag=self.vtag), (self.DEBUG & str_print( "-- " + str(self.vtag) + " run fabric policy")) + self.vdef.fabric_policy >> (self.DEBUG & (pkt_print(str(self.vtag) + " after fabric:") + str_print("-- " + str(self.vtag) + " run egress policy")) ) + self.vdef.egress_policy >> (self.DEBUG & pkt_print( str(self.vtag) + " after egress:")) + passthrough, (self.DEBUG & str_print("-- " + str(self.vtag) + " run derived policy on inherited nodes")) + self.vpolicy >> (self.DEBUG & pkt_print( str(self.vtag) + " after derived policy on inherited nodes:")) + passthrough))
def set_network(self, network): self.vmap = self.make_vmap() self.ingress_policy.vmap = self.vmap self.fabric_policy.vmap = self.vmap self.egress_policy.vmap = self.vmap self.locate_in_underlying.vmap = self.vmap self.ingress_policy.set_network(network) self.fabric_policy.set_network(network) self.egress_policy.set_network(network) ### THE INJECTION POLICY if self.DEBUG == no_packets: self.derived.injection_policy = ( lower_packet(self.vtag) >> self.locate_in_underlying >> if_( match(outport=-1) | match(outport=None), # IF NO OUTPORT self.fabric_policy) >> # THEN WE NEED TO RUN THE FABRIC POLICY self.egress_policy) ### THE INJECTION POLICY W/ DEBUGGING else: self.derived.injection_policy = ( (self.DEBUG & (str_print("-- " + str(self.vtag) + " injection_policy start " ) + pkt_print(str(self.vtag) + " injected packet") + str_print("-- " + str(self.vtag) + " lower packet"))) + lower_packet(self.vtag) >> (self.DEBUG & (pkt_print(str(self.vtag) + " after lower:") + str_print("-- " + str(self.vtag) + " locate packet"))) + self.locate_in_underlying >> (self.DEBUG & pkt_print(str(self.vtag) + " after locate:")) + if_( match(outport=-1) | match(outport=None), # IF NO OUTPORT (self.DEBUG & str_print("-- " + str(self.vtag) + " apply fabric policy")) + self. fabric_policy >> # THEN WE NEED TO RUN THE FABRIC POLICY (self.DEBUG & pkt_print(str(self.vtag) + " after fabric:")) + passthrough) >> # OTHERWISE WE PASSTHROUGH TO EGRESS POLICY (self.DEBUG & str_print("-- " + str(self.vtag) + " apply egress policy")) + self.egress_policy >> (self.DEBUG & (pkt_print(str(self.vtag) + " after egress:") + str_print("-- " + str(self.vtag) + " injection_policy end ")) ) + passthrough)
def __init__(self, vpolicy, vdef, DEBUG=False): self.vpolicy = vpolicy self.vnetwork = None self.vtag = new_vtag() if DEBUG: self.DEBUG = all_packets else: self.DEBUG = no_packets self.vdef = vdef self.vdef.DEBUG = self.DEBUG self.vdef.vtag = self.vtag super(virtualize,self).__init__( pkt_print(repr(self),self.DEBUG) >> if_(match(outport=None),push(outport=-1)) >> str_print("-- " + str(self.vtag) + " apply ingress policy",self.DEBUG) >> self.vdef.ingress_policy >> # set vlocation pkt_print(str(self.vtag) + " after ingress:",self.DEBUG) >> ### IF INGRESSING LIFT AND EVALUATE if_(match(vtag='ingress'), str_print("-- " + str(self.vtag) + " lift packet",self.DEBUG) >> lift_packet >> pkt_print(str(self.vtag) + " after lift:",self.DEBUG) >> str_print("-- " + str(self.vtag) + " run derived policy",self.DEBUG) >> self.vpolicy >> pkt_print(str(self.vtag) + " after derived policy:",self.DEBUG) >> str_print("-- " + str(self.vtag) + " lower packet",self.DEBUG) >> lower_packet(self.vtag) >> pkt_print(str(self.vtag) + " after lower:",self.DEBUG), passthrough >> str_print("-- " + str(self.vtag) + " non_ingress",self.DEBUG)) >> ### IF IN INTERIOR NETWORK ROUTE ON FABRIC AND IF APPLICABLE EGRESS if_(match(vtag=self.vtag), str_print("-- " + str(self.vtag) + " run fabric policy",self.DEBUG) >> self.vdef.fabric_policy >> pkt_print(str(self.vtag) + " after fabric:",self.DEBUG) >> str_print("-- " + str(self.vtag) + " run egress policy",self.DEBUG) >> self.vdef.egress_policy >> pkt_print(str(self.vtag) + " after egress:",self.DEBUG), str_print("-- " + str(self.vtag) + " run derived policy on inherited nodes",self.DEBUG) >> self.vpolicy >> pkt_print(str(self.vtag) + " after derived policy on inherited nodes:",self.DEBUG) ) )
def __init__(self, vpolicy, vdef, DEBUG=no_packets): self.vpolicy = vpolicy self.vnetwork = None self.vtag = new_vtag() self.vdef = vdef self.DEBUG = DEBUG self.vdef.DEBUG = self.DEBUG self.vdef.vtag = self.vtag ### THE VIRTUALIZED POLICY if self.DEBUG == no_packets: super(virtualize, self).__init__( if_(match(outport=None), push(outport=-1)) >> self.vdef.ingress_policy >> # set vlocation ### IF INGRESSING LIFT AND EVALUATE if_(match(vtag="ingress"), lift_packet >> self.vpolicy >> lower_packet(self.vtag)) >> ### IF IN INTERIOR NETWORK ROUTE ON FABRIC AND IF APPLICABLE EGRESS if_(match(vtag=self.vtag), self.vdef.fabric_policy >> self.vdef.egress_policy, self.vpolicy) ) ### THE VIRTUALIZED POLICY W/ DEBUGGING else: super(virtualize, self).__init__( (self.DEBUG & pkt_print(repr(self))) + if_(match(outport=None), push(outport=-1)) >> (self.DEBUG & str_print("-- " + str(self.vtag) + " apply ingress policy")) + self.vdef.ingress_policy >> (self.DEBUG & pkt_print(str(self.vtag) + " after ingress:")) + # set vlocation ### IF INGRESSING LIFT AND EVALUATE if_( match(vtag="ingress"), (self.DEBUG & str_print("-- " + str(self.vtag) + " lift packet")) + lift_packet >> ( self.DEBUG & ( pkt_print(str(self.vtag) + " after lift:") + str_print("-- " + str(self.vtag) + " run derived policy") ) ) + self.vpolicy >> ( self.DEBUG & ( pkt_print(str(self.vtag) + " after derived policy:") + str_print("-- " + str(self.vtag) + " lower packet") ) ) + lower_packet(self.vtag) >> (self.DEBUG & pkt_print(str(self.vtag) + " after lower:")) + passthrough, (self.DEBUG & str_print("-- " + str(self.vtag) + " non_ingress")) + passthrough, ) >> ### IF IN INTERIOR NETWORK ROUTE ON FABRIC AND IF APPLICABLE EGRESS if_( match(vtag=self.vtag), (self.DEBUG & str_print("-- " + str(self.vtag) + " run fabric policy")) + self.vdef.fabric_policy >> ( self.DEBUG & ( pkt_print(str(self.vtag) + " after fabric:") + str_print("-- " + str(self.vtag) + " run egress policy") ) ) + self.vdef.egress_policy >> (self.DEBUG & pkt_print(str(self.vtag) + " after egress:")) + passthrough, (self.DEBUG & str_print("-- " + str(self.vtag) + " run derived policy on inherited nodes")) + self.vpolicy >> (self.DEBUG & pkt_print(str(self.vtag) + " after derived policy on inherited nodes:")) + passthrough, ) )
def set_network(self, network): self.vmap = self.make_vmap() self.ingress_policy.vmap = self.vmap self.fabric_policy.vmap = self.vmap self.egress_policy.vmap = self.vmap self.locate_in_underlying.vmap = self.vmap self.ingress_policy.set_network(network) self.fabric_policy.set_network(network) self.egress_policy.set_network(network) ### THE INJECTION POLICY if self.DEBUG == no_packets: self.derived.injection_policy = ( lower_packet(self.vtag) >> self.locate_in_underlying >> if_(match(outport=-1) | match(outport=None), self.fabric_policy) # IF NO OUTPORT >> self.egress_policy # THEN WE NEED TO RUN THE FABRIC POLICY ) ### THE INJECTION POLICY W/ DEBUGGING else: self.derived.injection_policy = ( ( self.DEBUG & ( str_print("-- " + str(self.vtag) + " injection_policy start ") + pkt_print(str(self.vtag) + " injected packet") + str_print("-- " + str(self.vtag) + " lower packet") ) ) + lower_packet(self.vtag) >> ( self.DEBUG & ( pkt_print(str(self.vtag) + " after lower:") + str_print("-- " + str(self.vtag) + " locate packet") ) ) + self.locate_in_underlying >> (self.DEBUG & pkt_print(str(self.vtag) + " after locate:")) + if_( match(outport=-1) | match(outport=None), # IF NO OUTPORT (self.DEBUG & str_print("-- " + str(self.vtag) + " apply fabric policy")) + self.fabric_policy >> ( # THEN WE NEED TO RUN THE FABRIC POLICY self.DEBUG & pkt_print(str(self.vtag) + " after fabric:") ) + passthrough, ) >> ( # OTHERWISE WE PASSTHROUGH TO EGRESS POLICY self.DEBUG & str_print("-- " + str(self.vtag) + " apply egress policy") ) + self.egress_policy >> ( self.DEBUG & ( pkt_print(str(self.vtag) + " after egress:") + str_print("-- " + str(self.vtag) + " injection_policy end ") ) ) + passthrough )