Ejemplo n.º 1
0
 def __init__(self, domain, traffic_type, policy_type, src_dvg, dst_dvg, ttl, action):
     '''
     Constructor:
     @param domain: The Domain Object
     @type domain: Domain
     @param traffic_type: The Traffic Type (0: Unicast, 1:Multicast)
     @type traffic_type: Integer
     @param policy_type: The Policy Type
     @type policy_type: Integer
     @param src_dvg: The Source DVG Object
     @type src_dvg: DVG
     @param dst_dvg: The Destination DVG Object
     @type dst_dvg: DVG
     @param ttl: Time-To-Live cached in DPS client
     @type ttl: Integer
     @param action: Action taken to traffic from Source DVG to destination DVG
     @type action: IPAddressList or Integer depends on action_type
     @raise DOVE_STATUS_INVALID_POLICY: Bad policy type
     '''
     #Based on Object Model Chapter 5: Policy Object
     if policy_type <= 0 or policy_type >= self.type_bad:
         raise DOVEStatus.DOVE_STATUS_INVALID_POLICY
     if policy_type == self.type_ip_list:
         raise DOVEStatus.DOVE_STATUS_NOT_SUPPORTED
     self.domain = domain
     self.traffic_type = traffic_type
     self.type = policy_type
     self.src_dvg = src_dvg
     self.dst_dvg = dst_dvg
     self.ttl = ttl
     self.action = action
     action_struct  = struct.unpack(self.fmt_action_struct_hdr,
                                    self.action[:self.fmt_action_struct_hdr_size])
     self.action_connectivity = self.action_drop
     if self.type == self.type_connectivity:
         self.action_connectivity = action_struct[2] #3rd parameter
     self.version = action_struct[0]
     self.key = self.key_fmt%(src_dvg.unique_id, dst_dvg.unique_id)
     #TODO: Store the Policy result in a packed data format that
     #      can be sent to the C Code when needed.
     #
     #############################################################
     dcs_object.__init__(self, self.key)
     #############################################################
     #Add the policy into a Policy_Hash table in a domain,
     #source DVG and destination DVG
     #############################################################
     Domain.policy_add(self.domain, self)
     DVG.policy_add_src(src_dvg, dst_dvg.unique_id, self)
     DVG.policy_add_dst(dst_dvg, src_dvg.unique_id, self)
Ejemplo n.º 2
0
 def __init__(self, domain, traffic_type, policy_type, src_dvg, dst_dvg, ttl, action):
     """
     Constructor:
     @param domain: The Domain Object
     @type domain: Domain
     @param traffic_type: The Traffic Type (0: Unicast, 1:Multicast)
     @type traffic_type: Integer
     @param policy_type: The Policy Type
     @type policy_type: Integer
     @param src_dvg: The Source DVG Object
     @type src_dvg: DVG
     @param dst_dvg: The Destination DVG Object
     @type dst_dvg: DVG
     @param ttl: Time-To-Live cached in DPS client
     @type ttl: Integer
     @param action: Action taken to traffic from Source DVG to destination DVG
     @type action: IPAddressList or Integer depends on action_type
     @raise DOVE_STATUS_INVALID_POLICY: Bad policy type
     """
     # Based on Object Model Chapter 5: Policy Object
     if policy_type <= 0 or policy_type >= self.type_bad:
         raise DOVEStatus.DOVE_STATUS_INVALID_POLICY
     if policy_type == self.type_ip_list:
         raise DOVEStatus.DOVE_STATUS_NOT_SUPPORTED
     self.domain = domain
     self.traffic_type = traffic_type
     self.type = policy_type
     self.src_dvg = src_dvg
     self.dst_dvg = dst_dvg
     self.ttl = ttl
     self.action = action
     action_struct = struct.unpack(self.fmt_action_struct_hdr, self.action[: self.fmt_action_struct_hdr_size])
     self.action_connectivity = self.action_drop
     if self.type == self.type_connectivity:
         self.action_connectivity = action_struct[2]  # 3rd parameter
     self.version = action_struct[0]
     self.key = self.key_fmt % (src_dvg.unique_id, dst_dvg.unique_id)
     # TODO: Store the Policy result in a packed data format that
     #      can be sent to the C Code when needed.
     #
     #############################################################
     dcs_object.__init__(self, self.key)
     #############################################################
     # Add the policy into a Policy_Hash table in a domain,
     # source DVG and destination DVG
     #############################################################
     Domain.policy_add(self.domain, self)
     DVG.policy_add_src(src_dvg, dst_dvg.unique_id, self)
     DVG.policy_add_dst(dst_dvg, src_dvg.unique_id, self)