Пример #1
0
 def ip_clear(self, inet_type, ip_value):
     '''
     This deletes a tunnel IP address from this Tunnel and all DVGS and types
     @param dvg: The DVG on which this registration occurred
     @type dvg: DVG
     @param client_type: The Type of Client: should be in DpsClientType.types
     @type client_type: Integer 
     @param inet_type: AF_INET or AF_INET6
     @type inet_type: Integer
     @param ip_value: The IP address value
     @type ip_value: Integer or String
     '''
     while True:
         for client_type in DpsClientType.types.keys():
             #Delete IP from all matching VNIDs and Client Type
             for vnid in self.DVG_Hash[client_type].keys():
                 fRemoveVNID = False
                 try:
                     vnid_hash_ip = self.VNID_Hash_IP[client_type][vnid]
                     del vnid_hash_ip[ip_value]
                     if len(vnid_hash_ip) == 0:
                         del self.VNID_Hash_IP[client_type][vnid]
                         fRemoveVNID = True
                 except Exception:
                     pass
                 #Remove the IP from the DVG
                 try:
                     dvg = self.DVG_Hash[client_type][vnid]
                     DVG.tunnel_endpoint_delete_IP(dvg, client_type,
                                                   inet_type, ip_value)
                     if fRemoveVNID:
                         del self.DVG_Hash[client_type][vnid]
                         if len(self.DVG_Hash[client_type]) == 0:
                             #print 'Delete all Endpoints with client_type %s\r'%client_type
                             self.delete_client_type(client_type)
                 except Exception:
                     pass
             #Delete IP completly from Tunnel
             try:
                 ip_hash_vnid = self.IP_Hash_VNID[client_type][ip_value]
                 ip_hash_vnid.clear()
                 del self.IP_Hash_VNID[client_type][ip_value]
             except Exception:
                 pass
         #Delete the IP from Domain and DPS Clients since no DVGs have it
         if inet_type == socket.AF_INET:
             self.ip_listv4.remove(inet_type, ip_value)
         elif inet_type == socket.AF_INET6:
             self.ip_listv6.remove(inet_type, ip_value)
         #Remove IP to DPS Client
         DPSClient.tunnel_endpoint_delete_IP(self.dps_client, inet_type,
                                             ip_value)
         #Remove IP from Domain
         Domain.tunnel_endpoint_delete_IP(self.domain, inet_type, ip_value)
         #Delete Self if not IP Addresses are present
         if self.ip_listv4.count() == 0 and self.ip_listv6.count() == 0:
             self.delete()
         break
     return
Пример #2
0
 def update(self, dvg, vnid, client_type, transaction_type, version, operation, vIP):
     '''
     This handle Endpoint Update on an Endpoint. The domain and 
     DPS Client (on which the endpoint resides) should have been
     resolved before this step i.e. Migration and New Endpoint
     Scenario handled before this routine is called.
     @param dvg: The DVG based on Endpoint Update Parameters
     @type dvg: DVG
     @param vnid: The VNID (Maybe different from dvg.unique_id for Domain/DVG 0)
     @type vnid: Integer
     @param client_type: The Type of Client: should be in DpsClientType.types
     @type client_type: Integer 
     @param transaction_type: The Type of Transaction: should be in DpsTransactionType
     @type transaction_type: Integer
     @param version: The Object Version Number
     @type version: Integer
     @param operation: Should be a dps_endpoint_update_option
     @type operation: Integer
     @param vIP: The IP Address of the Endpoint
     @type vIP: IPAddressLocation
     '''
     self.in_migration = False #The Delete operation can set it to True.
     #Update client type
     self.client_type = client_type
     self.vnid = vnid
     #Since we got an update on this endpoint from an entity, 
     #we can remove from Endpoint Expiration Timer List
     try:
         del DpsCollection.Endpoint_Expiration_Timer_Queue[self]
     except Exception:
         pass
     if self.dvg != dvg:
         #Remove self from old DVG
         DVG.endpoint_del(self.dvg, self)
         #Remove all old vIPs
         self.vIP_delete_all()
         self.vIP_set_show.clear()
         self.dvg = dvg
         DVG.endpoint_add(self.dvg, self)
     if transaction_type == DpsTransactionType.mass_transfer:
         #Don't verify version for mass transfer. Just stay at the highest rev
         if self.version < version:
             self.version = version
     else:
         if version == Endpoint.version_start:
             self.version = Endpoint.version_start
         elif version == self.version:
             self.version = version
         else:
             if version != self.version + 1:
                 raise Exception('Invalid Version: Expecting %s, got %s!!!'%(self.version + 1, version))
             self.version = version
     try:
         self.update_function_table[operation](self, vIP)
     except Exception:
         #log.warning('update: operation %s not supported\r', operation)
         pass
     return
Пример #3
0
 def ip_add(self, dvg, fregister, client_type, inet_type, ip_value,
            transaction_type):
     '''
     This adds a tunnel IP address
     @param dvg: The DVG on which this registration occurred
     @type dvg: DVG
     @param fregister: Whether this is an explicit tunnel register
     @param fregister: Boolean
     @param client_type: The Type of Client: should be in DpsClientType.types
     @type client_type: Integer 
     @param inet_type: AF_INET or AF_INET6
     @type inet_type: Integer
     @param ip_value: The IP address value
     @type ip_value: Integer or String
     @param transaction_type: The Type of Transaction: should be in DpsTransactionType
     @type transaction_type: Integer
     '''
     while True:
         try:
             client_type_value = DpsClientType.types[client_type]
         except Exception:
             break
         self.DVG_Hash[client_type][dvg.unique_id] = dvg
         #Add to Tunnels List even though it may have come through other DVGs as well
         if inet_type == socket.AF_INET:
             if not self.ip_listv4.search(ip_value):
                 self.ip_listv4.add(inet_type, ip_value)
         elif inet_type == socket.AF_INET6:
             if not self.ip_listv4.search(ip_value):
                 self.ip_listv6.add(inet_type, ip_value)
         #log.info('ip_add: Adding to DPS Client %s', ip_value)
         #Add DVG to self.
         #Add IP to DPS Client
         DPSClient.tunnel_endpoint_add_IP(self.dps_client, self, inet_type,
                                          ip_value)
         #Add IP to this DVGs
         DVG.tunnel_endpoint_add_IP(dvg, fregister, self, client_type,
                                    inet_type, ip_value, transaction_type)
         try:
             vnid_hash_ip = self.VNID_Hash_IP[client_type][dvg.unique_id]
         except Exception:
             self.VNID_Hash_IP[client_type][dvg.unique_id] = {}
             vnid_hash_ip = self.VNID_Hash_IP[client_type][dvg.unique_id]
         vnid_hash_ip[ip_value] = True
         #Add DVGs to IP hash
         try:
             ip_hash_vnid = self.IP_Hash_VNID[client_type][ip_value]
         except Exception:
             self.IP_Hash_VNID[client_type][ip_value] = {}
             ip_hash_vnid = self.IP_Hash_VNID[client_type][ip_value]
         ip_hash_vnid[dvg.unique_id] = True
         #Add IP to Domain
         #log.info('ip_add: Adding to domain %s', self.domain.unique_id)
         Domain.tunnel_endpoint_add_IP(self.domain, self, inet_type,
                                       ip_value)
         break
     return
Пример #4
0
 def ip_clear(self, inet_type, ip_value):
     '''
     This deletes a tunnel IP address from this Tunnel and all DVGS and types
     @param dvg: The DVG on which this registration occurred
     @type dvg: DVG
     @param client_type: The Type of Client: should be in DpsClientType.types
     @type client_type: Integer 
     @param inet_type: AF_INET or AF_INET6
     @type inet_type: Integer
     @param ip_value: The IP address value
     @type ip_value: Integer or String
     '''
     while True:
         for client_type in DpsClientType.types.keys():
             #Delete IP from all matching VNIDs and Client Type
             for vnid in self.DVG_Hash[client_type].keys():
                 fRemoveVNID = False
                 try:
                     vnid_hash_ip = self.VNID_Hash_IP[client_type][vnid]
                     del vnid_hash_ip[ip_value]
                     if len(vnid_hash_ip) == 0:
                         del self.VNID_Hash_IP[client_type][vnid]
                         fRemoveVNID = True
                 except Exception:
                     pass
                 #Remove the IP from the DVG
                 try:
                     dvg = self.DVG_Hash[client_type][vnid]
                     DVG.tunnel_endpoint_delete_IP(dvg, client_type, inet_type, ip_value)
                     if fRemoveVNID:
                         del self.DVG_Hash[client_type][vnid]
                         if len(self.DVG_Hash[client_type]) == 0:
                             #print 'Delete all Endpoints with client_type %s\r'%client_type
                             self.delete_client_type(client_type)
                 except Exception:
                     pass
             #Delete IP completly from Tunnel
             try:
                 ip_hash_vnid = self.IP_Hash_VNID[client_type][ip_value]
                 ip_hash_vnid.clear()
                 del self.IP_Hash_VNID[client_type][ip_value]
             except Exception:
                 pass
         #Delete the IP from Domain and DPS Clients since no DVGs have it
         if inet_type == socket.AF_INET:
             self.ip_listv4.remove(inet_type, ip_value)
         elif inet_type == socket.AF_INET6:
             self.ip_listv6.remove(inet_type, ip_value)
         #Remove IP to DPS Client
         DPSClient.tunnel_endpoint_delete_IP(self.dps_client, inet_type, ip_value)
         #Remove IP from Domain
         Domain.tunnel_endpoint_delete_IP(self.domain, inet_type, ip_value)
         #Delete Self if not IP Addresses are present
         if self.ip_listv4.count() == 0 and self.ip_listv6.count() == 0:
             self.delete()
         break
     return
Пример #5
0
 def __init__(self, domain, dvg, vnid, client_type, transaction_type, 
              tunnel_endpoint, vMac, vIP, version):
     '''
     Constructor:
     @param domain: The Domain Object
     @type domain: Domain
     @param dvg: The DVG Object
     @type dvg: DVG
     @param vnid: The VNID (Maybe different from dvg.unique_id for Domain/DVG 0)
     @type vnid: Integer
     @param client_type: The Type of Client: should be in DpsClientType.types
     @type client_type: Integer 
     @param transaction_type: The Type of Transaction: should be in DpsTransactionType
     @type transaction_type: Integer
     @param tunnel_endpoint: The DOVE Switch on which the Endpoint is hosted
                             Maybe(None) - Then dove_gateway must be valid
     @type tunnel_endpoint: The Tunnel Endpoint
     @param vMAC: The Virtual MAC Address
     @type vMAC: ByteArray/String
     @param vIP: The IP Address of the Endpoint
     @type vIP: IPAddressLocation
     @param version: The version to start with
     @type version: integer
     '''
     if DpsCollection.Endpoints_Count >= DpsCollection.Endpoints_Count_Max:
         raise MemoryError('Out of Memory')
     self.domain = domain
     self.dvg = dvg
     self.vnid = vnid
     self.client_type = client_type
     self.vMac = vMac
     self.tunnel_endpoint = tunnel_endpoint
     self.vIP_set = {}
     self.vIP_set_show = {}
     if vIP is not None:
         self.vIP_set[vIP.ip_value] = vIP
         self.vIP_set_show[vIP.ip_value] = vIP
     #self.version = self.version_start
     self.version = version
     self.valid = True
     self.in_migration = False
     #############################################################
     #TODO:To be finished
     #Add to the appropriate DPS Client List
     #log.info('__init__: Adding to TunnelEndpoint\r')
     TunnelEndpoint.endpoint_add(tunnel_endpoint, self, transaction_type)
     #log.info('__init__: Added to TunnelEndpoint\r')
     #Add to the appropriate Domain Lists
     Domain.endpoint_add(domain, self)
     #log.info('__init__: Added to Domain\r')
     #Add to the appropriate DVG/VNID Lists
     DVG.endpoint_add(dvg, self)
     #log.info('__init__: Added to DVG\r')
     #self.show(None)
     DpsCollection.Endpoints_Count += 1
Пример #6
0
 def ip_add(self, dvg, fregister, client_type, inet_type, ip_value, transaction_type):
     '''
     This adds a tunnel IP address
     @param dvg: The DVG on which this registration occurred
     @type dvg: DVG
     @param fregister: Whether this is an explicit tunnel register
     @param fregister: Boolean
     @param client_type: The Type of Client: should be in DpsClientType.types
     @type client_type: Integer 
     @param inet_type: AF_INET or AF_INET6
     @type inet_type: Integer
     @param ip_value: The IP address value
     @type ip_value: Integer or String
     @param transaction_type: The Type of Transaction: should be in DpsTransactionType
     @type transaction_type: Integer
     '''
     while True:
         try:
             client_type_value = DpsClientType.types[client_type]
         except Exception:
             break
         self.DVG_Hash[client_type][dvg.unique_id] = dvg
         #Add to Tunnels List even though it may have come through other DVGs as well
         if inet_type == socket.AF_INET:
             if not self.ip_listv4.search(ip_value):
                 self.ip_listv4.add(inet_type, ip_value)
         elif inet_type == socket.AF_INET6:
             if not self.ip_listv4.search(ip_value):
                 self.ip_listv6.add(inet_type, ip_value)
         #log.info('ip_add: Adding to DPS Client %s', ip_value)
         #Add DVG to self.
         #Add IP to DPS Client
         DPSClient.tunnel_endpoint_add_IP(self.dps_client, self, inet_type, ip_value)
         #Add IP to this DVGs
         DVG.tunnel_endpoint_add_IP(dvg, fregister, self, client_type, inet_type, ip_value, transaction_type)
         try:
             vnid_hash_ip = self.VNID_Hash_IP[client_type][dvg.unique_id]
         except Exception:
             self.VNID_Hash_IP[client_type][dvg.unique_id] = {}
             vnid_hash_ip = self.VNID_Hash_IP[client_type][dvg.unique_id]
         vnid_hash_ip[ip_value] = True
         #Add DVGs to IP hash
         try:
             ip_hash_vnid = self.IP_Hash_VNID[client_type][ip_value]
         except Exception:
             self.IP_Hash_VNID[client_type][ip_value] = {}
             ip_hash_vnid = self.IP_Hash_VNID[client_type][ip_value]
         ip_hash_vnid[dvg.unique_id] = True 
         #Add IP to Domain
         #log.info('ip_add: Adding to domain %s', self.domain.unique_id)
         Domain.tunnel_endpoint_add_IP(self.domain, self, inet_type, ip_value)
         break
     return
Пример #7
0
 def vIP_add(self, vIP):
     '''
     Add a virtual IP address
     @param vIP: The IP Address of the Endpoint
     @type vIP: IPAddressLocation
     '''
     if vIP is not None:
         self.vIP_set[vIP.ip_value] = vIP
         Domain.endpoint_vIP_add(self.domain, self, vIP)
         DVG.endpoint_vIP_add(self.dvg, self, vIP)
         if len(self.vIP_set) < DpsCollection.Endpoints_vIP_Max:
             self.vIP_set_show[vIP.ip_value] = vIP
Пример #8
0
 def vIP_del(self, vIP):
     '''
     Delete a virtual IP address
     @param vIP: The IP Address of the Endpoint
     @type vIP: IPAddressLocation
     '''
     if vIP is not None:
         try:
             del self.vIP_set[vIP.ip_value]
             Domain.endpoint_vIP_del(self.domain, vIP)
             DVG.endpoint_vIP_del(self.dvg, vIP)
             del self.vIP_set_show[vIP.ip_value]
         except Exception:
             pass
Пример #9
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)
Пример #10
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)
Пример #11
0
 def delete(self):
     """
     Destructor: Remove itself from collection
     """
     if not self.valid:
         return
     self.valid = False
     if self.src_dvg == self.dst_dvg:
         # Restore to default allow policy and send update to VNID
         self.update(0, 67108864, struct.pack(Policy.fmt_action_struct_hdr, 0, 0, Policy.action_forward))
         if self.domain.active:
             DpsCollection.policy_update_queue.put((self.src_dvg, self.traffic_type))
     else:
         # Remove self from Domain, SRC and DST VNID/DVG
         DVG.policy_del_dst(self.dst_dvg, self.src_dvg.unique_id, self.traffic_type)
         DVG.policy_del_src(self.src_dvg, self.dst_dvg.unique_id, self.traffic_type)
         Domain.policy_del(self.domain, self)
Пример #12
0
 def delete(self):
     '''
     Destructor: Remove itself from collection
     '''
     if not self.valid:
         return
     self.valid = False
     if self.src_dvg == self.dst_dvg:
         #Restore to default allow policy and send update to VNID
         self.update(0, 67108864, struct.pack(Policy.fmt_action_struct_hdr,
                                              0, 0, Policy.action_forward))
         if self.domain.active:
             DpsCollection.policy_update_queue.put((self.src_dvg, self.traffic_type))
     else:
         #Remove self from Domain, SRC and DST VNID/DVG
         DVG.policy_del_dst(self.dst_dvg, self.src_dvg.unique_id, self.traffic_type)
         DVG.policy_del_src(self.src_dvg, self.dst_dvg.unique_id, self.traffic_type)
         Domain.policy_del(self.domain, self)
Пример #13
0
 def delete(self):
     '''
     Destructor:
     '''
     if not self.valid:
         return
     self.valid = False
     #Remove from Conflict Detection List
     self.domain.ConflictDetection.endpoint_delete(self)
     #Remove from DPS Client List
     TunnelEndpoint.endpoint_del(self.tunnel_endpoint, self)
     #Remove from Domain Collection
     Domain.endpoint_del(self.domain, self)
     #Remove from VNID/DVG collection
     DVG.endpoint_del(self.dvg, self)
     #Remove vIPs
     self.vIP_set.clear()
     self.vIP_set_show.clear()
     DpsCollection.Endpoints_Count -= 1
     return
Пример #14
0
 def delete_if_empty(self):
     '''
     This routine checks if a DPS Client no longer hosts any Endpoint.
     If it doesn't, it unlinks itself from all the domain
     '''
     if len(self.Endpoint_Hash_MAC) != 0:
         return
     if not self.valid:
         return
     self.valid = False
     #Remove self from all DVGs
     for client_type in DpsClientType.types.keys():
         for dvg in self.DVG_Hash[client_type].values():
             DVG.tunnel_endpoint_delete(dvg, self, client_type)
     #Clear the VNID/DVG Hash
     self.DVG_Hash.clear()
     #Remove from DPS Client Collection
     DPSClient.tunnel_endpoint_delete(self.dps_client, self)
     #Remove from Domain Collection
     Domain.tunnel_endpoint_delete(self.domain, self)
     #Clear IPs
     self.ip_listv4.clear()
     self.ip_listv6.clear()
     return
Пример #15
0
 def delete_if_empty(self):
     '''
     This routine checks if a DPS Client no longer hosts any Endpoint.
     If it doesn't, it unlinks itself from all the domain
     '''
     if len(self.Endpoint_Hash_MAC) != 0:
         return
     if not self.valid:
         return
     self.valid = False
     #Remove self from all DVGs
     for client_type in DpsClientType.types.keys():
         for dvg in self.DVG_Hash[client_type].values():
             DVG.tunnel_endpoint_delete(dvg, self, client_type)
     #Clear the VNID/DVG Hash
     self.DVG_Hash.clear()
     #Remove from DPS Client Collection
     DPSClient.tunnel_endpoint_delete(self.dps_client, self)
     #Remove from Domain Collection
     Domain.tunnel_endpoint_delete(self.domain, self)
     #Clear IPs
     self.ip_listv4.clear()
     self.ip_listv6.clear()
     return
Пример #16
0
 def vmotion(self, dvg, vnid, client_type, tunnel_endpoint, transaction_type):
     '''
     This routine handles the scenario where the Endpoint has vmotioned
     (without being explicitly told by the migration source).
     This routine will unlink the Endpoint from the existing DpsClient
     and remove the vIPs
     @param dvg: The DVG Object
     @type dvg: DVG
     @param vnid: The VNID (Maybe different from dvg.unique_id for Domain/DVG 0)
     @type vnid: Integer
     @param client_type: The Type of Client: should be in DpsClientType.types
     @type client_type: Integer 
     @param tunnel_endpoint: The New Tunnel Endpoint on which the endpoint exists
     @type tunnel_endpoint: TunnelEndpoint
     @param transaction_type: The Type of Transaction: should be in DpsTransactionType
     @type transaction_type: Integer
     '''
     #######################################################################
     #Remove from old values
     #######################################################################
     if self.tunnel_endpoint is not None:
         TunnelEndpoint.endpoint_del(self.tunnel_endpoint, self)
         self.tunnel_endpoint = None
     if self.dvg is not None:
         DVG.endpoint_del(self.dvg, self)
         if self.dvg != dvg:
             #Change in VNIDs. Clear all IPs
             DVG.endpoint_del(self.dvg, self)
             self.vIP_delete_all()
             self.vIP_set_show.clear()
     #######################################################################
     #Add to new values
     #######################################################################
     self.dvg = dvg
     self.vnid = vnid
     DVG.endpoint_add(dvg, self)
     self.tunnel_endpoint = tunnel_endpoint
     self.client_type = client_type
     self.in_migration = False
     TunnelEndpoint.endpoint_add(self.tunnel_endpoint, self, transaction_type)
     return
Пример #17
0
 def ip_delete(self, dvg, client_type, inet_type, ip_value):
     '''
     This deletes a tunnel IP address from a DVG and client type
     @param dvg: The DVG on which this registration occurred
     @type dvg: DVG
     @param client_type: The Type of Client: should be in DpsClientType.types
     @type client_type: Integer 
     @param inet_type: AF_INET or AF_INET6
     @type inet_type: Integer
     @param ip_value: The IP address value
     @type ip_value: Integer or String
     '''
     fdeleteVNID = False
     fdeleteIP = False
     while True:
         try:
             client_type_value = DpsClientType.types[client_type]
         except Exception:
             break
         try:
             vnid_hash_ip = self.VNID_Hash_IP[client_type][dvg.unique_id]
             del vnid_hash_ip[ip_value]
             if len(vnid_hash_ip) == 0:
                 del self.VNID_Hash_IP[client_type][dvg.unique_id]
                 fdeleteVNID = True
         except Exception:
             pass
         try:
             ip_hash_vnid = self.IP_Hash_VNID[client_type][ip_value]
             del ip_hash_vnid[dvg.unique_id]
             if len(ip_hash_vnid) == 0:
                 del self.IP_Hash_VNID[client_type][ip_value]
                 fdeleteIP = True
         except Exception:
             pass
         if fdeleteVNID:
             #Remove Tunnel from DVG
             DVG.tunnel_endpoint_delete(dvg, self, client_type)
             try:
                 del self.DVG_Hash[client_type][dvg.unique_id]
                 if len(self.DVG_Hash[client_type]) == 0:
                     #print 'Delete all Endpoints with client_type %s\r'%client_type_value
                     self.delete_client_type(client_type)
             except Exception:
                 pass
         if not fdeleteIP:
             break
         if fdeleteIP:
             #Remove only the IP from the DVG
             DVG.tunnel_endpoint_delete_IP(dvg, client_type, inet_type,
                                           ip_value)
         #Check if IP is present in any client type
         ip_present = False
         for ctype in self.IP_Hash_VNID.keys():
             try:
                 ip_hash_vnid = self.IP_Hash_VNID[ctype][ip_value]
                 ip_present = True
                 break
             except Exception:
                 continue
         if ip_present:
             break
         #Actually delete the IP from Domain and DPS Clients since no DVGs have it
         if inet_type == socket.AF_INET:
             self.ip_listv4.remove(inet_type, ip_value)
         elif inet_type == socket.AF_INET6:
             self.ip_listv6.remove(inet_type, ip_value)
         #Remove IP to DPS Client
         DPSClient.tunnel_endpoint_delete_IP(self.dps_client, inet_type,
                                             ip_value)
         #Remove IP from Domain
         Domain.tunnel_endpoint_delete_IP(self.domain, inet_type, ip_value)
         #Delete Self if not IP Addresses are present
         if self.ip_listv4.count() == 0 and self.ip_listv6.count() == 0:
             self.delete()
         break
     return
Пример #18
0
 def ip_delete(self, dvg, client_type, inet_type, ip_value):
     '''
     This deletes a tunnel IP address from a DVG and client type
     @param dvg: The DVG on which this registration occurred
     @type dvg: DVG
     @param client_type: The Type of Client: should be in DpsClientType.types
     @type client_type: Integer 
     @param inet_type: AF_INET or AF_INET6
     @type inet_type: Integer
     @param ip_value: The IP address value
     @type ip_value: Integer or String
     '''
     fdeleteVNID = False
     fdeleteIP = False
     while True:
         try:
             client_type_value = DpsClientType.types[client_type]
         except Exception:
             break
         try:
             vnid_hash_ip = self.VNID_Hash_IP[client_type][dvg.unique_id]
             del vnid_hash_ip[ip_value]
             if len(vnid_hash_ip) == 0:
                 del self.VNID_Hash_IP[client_type][dvg.unique_id]
                 fdeleteVNID = True
         except Exception:
             pass
         try:
             ip_hash_vnid = self.IP_Hash_VNID[client_type][ip_value]
             del ip_hash_vnid[dvg.unique_id]
             if len(ip_hash_vnid) == 0:
                 del self.IP_Hash_VNID[client_type][ip_value]
                 fdeleteIP = True
         except Exception:
             pass
         if fdeleteVNID:
             #Remove Tunnel from DVG
             DVG.tunnel_endpoint_delete(dvg, self, client_type)
             try:
                 del self.DVG_Hash[client_type][dvg.unique_id]
                 if len(self.DVG_Hash[client_type]) == 0:
                     #print 'Delete all Endpoints with client_type %s\r'%client_type_value
                     self.delete_client_type(client_type)
             except Exception:
                 pass
         if not fdeleteIP:
             break
         if fdeleteIP:
             #Remove only the IP from the DVG
             DVG.tunnel_endpoint_delete_IP(dvg, client_type, inet_type, ip_value)
         #Check if IP is present in any client type
         ip_present = False
         for ctype in self.IP_Hash_VNID.keys():
             try:
                 ip_hash_vnid = self.IP_Hash_VNID[ctype][ip_value]
                 ip_present = True
                 break
             except Exception:
                 continue
         if ip_present:
             break
         #Actually delete the IP from Domain and DPS Clients since no DVGs have it
         if inet_type == socket.AF_INET:
             self.ip_listv4.remove(inet_type, ip_value)
         elif inet_type == socket.AF_INET6:
             self.ip_listv6.remove(inet_type, ip_value)
         #Remove IP to DPS Client
         DPSClient.tunnel_endpoint_delete_IP(self.dps_client, inet_type, ip_value)
         #Remove IP from Domain
         Domain.tunnel_endpoint_delete_IP(self.domain, inet_type, ip_value)
         #Delete Self if not IP Addresses are present
         if self.ip_listv4.count() == 0 and self.ip_listv6.count() == 0:
             self.delete()
         break
     return