Exemplo n.º 1
0
 def show_details_client_type(self, client_type):
     '''
     Display the details of a Tunnel given a client_type
     '''
     try:
         vnid_hash = self.DVG_Hash[client_type]
         vnid_hash_ip = self.VNID_Hash_IP[client_type]
         ip_hash_vnid = self.IP_Hash_VNID[client_type]
         client_type_string = DpsClientType.types[client_type]
         print 'Tunnel Type %s\r' % client_type_string
         print 'VNIDS %s\r' % vnid_hash.keys()
         for vnid, vnid_ips in vnid_hash_ip.items():
             ip_list = IPAddressList(socket.AF_INET)
             for vnid_ip in vnid_ips:
                 try:
                     ip_list.add(socket.AF_INET, vnid_ip)
                 except Exception:
                     pass
             print 'VNID %s, PIPv4s %s\r' % (vnid, ip_list.toString())
         for ip, ip_vnids in ip_hash_vnid.items():
             try:
                 ip_packed = struct.pack(IPAddressList.fmts[socket.AF_INET],
                                         ip)
                 ip_string = socket.inet_ntop(socket.AF_INET, ip_packed)
             except Exception:
                 pass
             print 'PIPv4 %s, VNIDs %s\r' % (ip_string, ip_vnids.keys())
     except Exception:
         pass
     return
Exemplo n.º 2
0
 def __init__(self, fregister, domain, dvg, client_type, transaction_type,
              dps_client, pip_tuple_list):
     '''
     Constructor:
     This routine assumes that the 1st IP address in the tuple uniquely
     identifies a DOVE Switch/VLAN Gateway within the Domain.
     @param fregister: Whether this is an explicit tunnel register
     @param fregister: Boolean
     @param domain: The Domain object
     @type domain: Domain
     @param dvg: The DVG/VNID object
     @type dvg: DVG
     @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 Domain.transaction_types
     @type transaction_type: Integer
     @param dps_client: The DPS Client associated with this Tunnel
     @type dps_client: DPSClient
     @type dps_client_port: Integer
     @param pip_tuple_array: A list of tuples of Physical IP Addresses, each 
                             tuple is of the form (inet_type, ip_value).
                             The inet_type = socket type i.e. AF_INET or AF_INET6
                             The ip_value = IPv4 in integer or IPv6 in string
     @type pip_tuple_array: List of tuples
     '''
     if len(pip_tuple_list) == 0:
         raise Exception('No IP Address Provided: Invalid DOVE Switch')
     try:
         client_string = DpsClientType.types[client_type]
     except Exception:
         raise Exception('Not a supported Tunnel Type')
     self.domain = domain
     #DPS Client Location i.e. the UDP Port and Location
     self.dps_client = dps_client
     #############################################################
     #Based on Object Model Chapter 5.3: DOVE Switch
     #############################################################
     #TODO: SQL Table of Policies: Requirement 1.3
     #Hash List of all Endpoints hashed by MAC: Requirement 1.4
     self.Endpoint_Hash_MAC = {}
     #A dictionary indexed by VNID IDs, the value is the number
     #of Endpoints on that DOVE Switch in a particular VNID/DVG
     self.DVG_Hash = {}
     inet_type = pip_tuple_list[0][0]
     ip_value = pip_tuple_list[0][1]
     #ip_location = IPAddressLocation(inet_type, ip_value, 0)
     #print 'Tunnel %s created DVG_Hash\r'%ip_location.show_ip()
     for ctype in DpsClientType.types.keys():
         self.DVG_Hash[ctype] = {}
     #Key IP_value: Value VNID
     self.IP_Hash_VNID = {}
     #print 'Tunnel %s created IP_Hash_VNID\r'%ip_location.show_ip()
     for ctype in DpsClientType.types.keys():
         self.IP_Hash_VNID[ctype] = {}
     #Key VNID: Value Hash of IPs
     self.VNID_Hash_IP = {}
     for ctype in DpsClientType.types.keys():
         self.VNID_Hash_IP[ctype] = {}
     #print 'Tunnel %s created VNID_Hash_IP\r'%ip_location.show_ip()
     #List of Physical IP Addresses
     self.ip_listv4 = IPAddressList(socket.AF_INET)
     self.ip_listv6 = IPAddressList(socket.AF_INET6)
     for i in range(len(pip_tuple_list)):
         inet_type = pip_tuple_list[i][0]
         ip_value = pip_tuple_list[i][1]
         self.ip_add(dvg, fregister, client_type, inet_type, ip_value,
                     transaction_type)
     #############################################################
     #To be finished
     #############################################################
     #dcs_object.__init__(self, self.primary_ip().show())
     self.version = 0
     self.valid = True
     DPSClientHost.Host_Add(domain, dps_client.location.inet_type,
                            dps_client.location.ip_value,
                            dps_client.location.port, client_type)
Exemplo n.º 3
0
    def __init__(self, domain_id, active):
        '''
        Constructor:
        @param domain_id: The Domain ID
        @type domain_id: Integer
        @param active: Whether the Domain is active
        @type active: Boolean
        '''
        if domain_id < 0 or domain_id > 16777215:
            raise Exception('Domain ID %s not valid' % (domain_id))
        self.IP_Subnet_List = IPSubnetList()
        self.active = active
        self.replication_factor = 1
        self.mass_transfer = None
        #Set of nodes to forward updates after Mass Transfer is complete
        #and waiting for all other nodes to see this new DPS Node
        #as part of the domain.
        self.mass_transfer_forward_nodes = {}
        #Create Timer for the Domain Object
        #Create the Replication Dictionary
        #The Replication dictionary
        self.replication_query_id_server = {}
        self.replication_query_id_client = {}
        #Based on Object Model Chapter 5.1: Domain Object
        #Collection of DVGs hashed by DVG id.
        #TODO: Add to Domain Object in Domain Object Model
        self.DVG_Hash = {}
        #############################################################
        #Endpoint Object Tables (Requirement 1.1 and 1.2)
        #############################################################
        #Endpoint Object Hash Table (IP Address)
        #Separating IPv4 and IPv6 into different Hashes since one
        #will be hashed by integer, the other string
        self.Endpoint_Hash_IPv4 = {}
        self.Endpoint_Hash_IPv6 = {}
        #Endpoint Object Hash Table (MAC Address)
        self.Endpoint_Hash_MAC = {}
        #############################################################
        #Policy Object Hash Table (Requirement 1.2)
        #The first index is for unicast policy, the second for multicast
        #############################################################
        self.Policy_Hash_DVG = [{}, {}]
        #############################################################
        #DPS Client Hash Tables (Requirement 1.5)
        #############################################################
        #This is to store the DPS Client IPs Address (Different from
        #the DOVE Switch/Gateway IP address)
        self.DPSClients_Hash_IPv4 = {}
        self.DPSClients_Hash_IPv6 = {}
        #This is to store the Tunnel Endpoint IP Address
        self.Tunnel_Endpoints_Hash_IPv4 = {}
        self.Tunnel_Endpoints_Hash_IPv6 = {}
        #List of Implicit Gateway IP Address for this Domain
        self.ImplicitGatewayIPListv4 = IPAddressList(socket.AF_INET)
        self.ImplicitGatewayIPListv6 = IPAddressList(socket.AF_INET6)
        #Multicast Object
        self.Multicast = Multicast(self, domain_id)
        #Address Resolution
        self.AddressResolution = AddressResolution(domain_id)
        self.ConflictDetection = ConflictDetection(domain_id)
        #############################################################
        #Add the domain into DPS Collection Hash Table
        #############################################################
        DpsCollection.Domain_Hash[domain_id] = self
        #DpsCollection.VNID_Hash[domain_id] = domain_id
        #############################################################
        #Statistics
        #############################################################
        self.Stats_Array = []
        curr_time = time.time()
        self.Stats_Array.append([curr_time, 0, 0, 0])

        self.Endpoint_Update_Count = 0
        self.Endpoint_Update_Count_Delta = 0
        self.Endpoint_Lookup_Count = 0
        self.Endpoint_Lookup_Count_Delta = 0
        self.Policy_Lookup_Count = 0
        self.Policy_Lookup_Count_Delta = 0
        self.Multicast_Lookup_Count = 0
        self.Internal_Gateway_Lookup_Count = 0
        #############################################################
        #To be finished
        #############################################################
        # Initialize the common part
        dcs_object.__init__(self, domain_id)