def _get_stub_node_full_data(self, node):
		'''
		doc
		'''

		n = self.topology[node.router_id]
		result = DTNode(router_id=node.router_id, datapath_id=n.datapath_id, status=node.status, net_type=n.net_type, 
						top_type=n.top_type)
        
		interfaces = {}
		for i in node.interfaces.itervalues():
			inter = self.topology[node.router_id].interfaces[i.ip_address]
            
			#Actually Links has not many information than lsdb information
			links = {}
            
			for l in i.links.itervalues():
				print l.to_node_int
				link = DTLink(status=l.status, from_node_int=l.from_node_int, to_node_int=l.to_node_int, weight=l.weight)
				links[link.to_node_int.ip_address] = link

			
			res = DTInterface(ip_address=i.ip_address, mac_address=inter.mac_address, ovs_port=inter.ovs_port, links=links, 
									i_type=inter.type)
			interfaces[i.ip_address] = res
            
		result.interfaces = interfaces

		return result
    def _get_stub_node_full_data(self, node):
        '''
		doc
		'''

        n = self.topology[node.router_id]
        result = DTNode(router_id=node.router_id,
                        datapath_id=n.datapath_id,
                        status=node.status,
                        net_type=n.net_type,
                        top_type=n.top_type)

        interfaces = {}
        for i in node.interfaces.itervalues():
            inter = self.topology[node.router_id].interfaces[i.ip_address]

            #Actually Links has not many information than lsdb information
            links = {}

            for l in i.links.itervalues():
                print l.to_node_int
                link = DTLink(status=l.status,
                              from_node_int=l.from_node_int,
                              to_node_int=l.to_node_int,
                              weight=l.weight)
                links[link.to_node_int.ip_address] = link

            res = DTInterface(ip_address=i.ip_address,
                              mac_address=inter.mac_address,
                              ovs_port=inter.ovs_port,
                              links=links,
                              i_type=inter.type)
            interfaces[i.ip_address] = res

        result.interfaces = interfaces

        return result
    def _get_ws_node_full_data(self, node):
        '''
		Connect via web service to SNMP agent app to get 
		specific node extra data
		'''

        url = URI_APP_SNMP + node.router_id
        result = None

        try:
            json_data = requests.get(url)
            data = json.loads(json_data.text)

            if data is not None:
                datapath_id = str(int(data["dpid"], 16))
                ports = data['puertos']
                port = None
                ip_address = None
                mac_address = None
                ovs_port = None
                result = DTNode(router_id=node.router_id,
                                datapath_id=datapath_id,
                                status=1,
                                net_type=0,
                                top_type=0)

                interfaces = {}
                for port in ports:

                    ip_address = port['ip']
                    mac_address = port['mac']
                    ovs_port = port['numeroOVS']
                    name = port['nombreInterfaz']

                    if (node.interfaces.has_key(ip_address)):
                        inter = node.interfaces[ip_address]

                        #Actually Links has not many information than lsdb information
                        links = {}

                        for l in inter.links.itervalues():

                            link = DTLink(status=l.status,
                                          from_node_int=l.from_node_int,
                                          to_node_int=l.to_node_int,
                                          weight=l.weight)
                            links[link.to_node_int.ip_address] = link

                        res = DTInterface(ip_address=ip_address,
                                          mac_address=mac_address,
                                          ovs_port=ovs_port,
                                          links=links,
                                          i_type=0,
                                          name=name,
                                          status=1)

                        interfaces[ip_address] = res

                    else:
                        # La interfaz no existe en la LSDB puede ser una interfaz externa asi que la agrega como interfaz down
                        # La crea solamente si tiene direccion IP, puerto ovs y direccion mac
                        if ip_address != None and mac_address != None and ovs_port != None:
                            links = {}

                            res = DTInterface(ip_address=ip_address,
                                              mac_address=mac_address,
                                              ovs_port=ovs_port,
                                              links=links,
                                              i_type=0,
                                              name=name,
                                              status=0)
                            interfaces[ip_address] = res

                result.interfaces = interfaces

        except ValueError:
            print "ERROR" + str(ValueError)

        except requests.exceptions.ConnectionError:
            print "Connection error: Could not connect to snmp agent"

        return result
	def _get_ws_node_full_data(self, node):
		'''
		Connect via web service to SNMP agent app to get 
		specific node extra data
		'''

		url = URI_APP_SNMP + node.router_id
		result = None

		try:
			json_data = requests.get(url)
			data = json.loads(json_data.text)

			if data is not None:
				datapath_id = str(int(data["dpid"], 16))
				ports = data['puertos']
				port = None
				ip_address = None
				mac_address =  None
				ovs_port = None
				result = DTNode(router_id=node.router_id, datapath_id=datapath_id, status=1, net_type=0, 
								top_type=0)
	            
				interfaces = {}
				for port in ports:
	            
					ip_address = port['ip']
					mac_address = port['mac']
					ovs_port = port['numeroOVS']
					name = port['nombreInterfaz']

					if(node.interfaces.has_key(ip_address)):
						inter = node.interfaces[ip_address]
		                
						#Actually Links has not many information than lsdb information
						links = {}

						for l in inter.links.itervalues():
							
							link = DTLink(status=l.status, from_node_int=l.from_node_int, to_node_int=l.to_node_int, weight=l.weight)
							links[link.to_node_int.ip_address] = link

						res = DTInterface(ip_address=ip_address, mac_address=mac_address, ovs_port=ovs_port, links=links, 
											i_type=0, name=name, status=1)
				
						interfaces[ip_address] = res
					
					else:
						# La interfaz no existe en la LSDB puede ser una interfaz externa asi que la agrega como interfaz down
						# La crea solamente si tiene direccion IP, puerto ovs y direccion mac
						if ip_address != None and mac_address != None and ovs_port != None:
							links = {}
						
							res = DTInterface(ip_address=ip_address, mac_address=mac_address, ovs_port=ovs_port, links=links, 
											i_type=0, name=name, status=0)
							interfaces[ip_address] = res
	                
				result.interfaces = interfaces

		except ValueError:
			print "ERROR" + str(ValueError)

		except requests.exceptions.ConnectionError:
			print "Connection error: Could not connect to snmp agent"  

		return result
Beispiel #5
0
    def initialize_management_app(self):
        #Carga en la variable de topologia de la aplicacion de gestion toda la informacion extra de la
        # topologia
        nodes = {}
        n = DTNode(router_id='192.168.1.10', datapath_id='10', net_type=0, top_type=1)
        interfaces = {}
        interfaces['192.168.1.10']=DTInterface(ip_address='192.168.1.10', mac_address='mac', ovs_port=0, i_type=1)
        n.interfaces =  interfaces
        nodes['192.168.1.10'] = n
      

        n = DTNode(router_id='192.168.1.11', datapath_id='11', net_type=1, top_type=1)
        interfaces = {}
        interfaces['192.168.1.11']=DTInterface(ip_address='192.168.1.11', mac_address='mac', ovs_port=0, i_type=1)
        interfaces['10.10.1.1']=DTInterface(ip_address='10.10.1.1', mac_address='mac', ovs_port=1, i_type=0)
        interfaces['10.10.5.1']=DTInterface(ip_address='10.10.5.1', mac_address='mac', ovs_port=2, i_type=0)
        interfaces['10.10.4.1']=DTInterface(ip_address='10.10.4.1', mac_address='mac', ovs_port=3, i_type=0)
        n.interfaces =  interfaces
        nodes['192.168.1.11'] = n
        
        n = DTNode(router_id='192.168.1.12', datapath_id='12', net_type=1, top_type=1)
        interfaces = {}
        interfaces['192.168.1.12']=DTInterface(ip_address='192.168.1.12', mac_address='mac', ovs_port=0, i_type=1)
        interfaces['10.10.1.2']=DTInterface(ip_address='10.10.1.2', mac_address='mac', ovs_port=1, i_type=0)
        interfaces['10.10.6.2']=DTInterface(ip_address='10.10.6.2', mac_address='mac', ovs_port=2, i_type=0)
        interfaces['10.10.3.1']=DTInterface(ip_address='10.10.3.1', mac_address='mac', ovs_port=3, i_type=0)
        n.interfaces =  interfaces
        nodes['192.168.1.12'] = n
        
        n = DTNode(router_id='192.168.1.13', datapath_id='13', net_type=1, top_type=1)
        interfaces = {}
        interfaces['192.168.1.13']=DTInterface(ip_address='192.168.1.13', mac_address='mac', ovs_port=0, i_type=1)
        interfaces['10.10.4.2']=DTInterface(ip_address='10.10.4.2', mac_address='mac', ovs_port=3, i_type=0)
        interfaces['10.10.2.1']=DTInterface(ip_address='10.10.2.1', mac_address='mac', ovs_port=1, i_type=0)
        interfaces['10.10.6.1']=DTInterface(ip_address='10.10.6.1', mac_address='mac', ovs_port=2, i_type=0)
        n.interfaces =  interfaces
        nodes['192.168.1.13'] = n
                
        n = DTNode(router_id='192.168.1.14', datapath_id='14', net_type=1, top_type=1)
        interfaces = {}
        interfaces['192.168.1.14']=DTInterface(ip_address='192.168.1.14', mac_address='mac', ovs_port=0, i_type=1)
        interfaces['10.10.3.2']=DTInterface(ip_address='10.10.3.2', mac_address='mac', ovs_port=3, i_type=0)
        interfaces['10.10.2.2']=DTInterface(ip_address='10.10.2.2', mac_address='mac', ovs_port=1, i_type=0)
        interfaces['10.10.5.2']=DTInterface(ip_address='10.10.5.2', mac_address='mac', ovs_port=2, i_type=0)
        n.interfaces =  interfaces
        nodes['192.168.1.14'] = n

        self.management_app.topology = nodes