Пример #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 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
Пример #3
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
Пример #4
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