Hi Sakib,

On 2015年05月26日 02:28, MD.Badruzzaman Shakib wrote:
> Hello everyone,
> 
> I want to get the port information from the link_add event. I couldn't find 
> any getter function for port number.
> for the code below-
> 
> @set_ev_cls(EventLinkAdd, MAIN_DISPATCHER)
> def _link_add_handler(self, ev):
>         link = ev.link
>         #print "type of links:", type(link)
>         print link
> 
> it prints-       
> Link: Port<dpid=4, port_no=5, LIVE> to Port<dpid=6, port_no=3, LIVE>
> 
> So now I am getting the source port_no by using
>         src_port = int(str(link)[27:28])

You can get the port number from EventLinkAdd/EventLinkDelete as follow.

    @set_ev_cls(EventLinkAdd, MAIN_DISPATCHER)
    def _link_add_handler(self, ev):
            link = ev.link
            self.logger.info('link.src.port_no = %d', link.src.port_no)
            # e.g.)
            # link.src.port_no = 2

FYI,
'ev.link' is an instance of 'class Link' in ryu/topology/switches.py.
 <https://github.com/osrg/ryu/blob/master/ryu/topology/switches.py#L135>
And 'ev.link.src/dst' is an instance of 'class Port'.
 <https://github.com/osrg/ryu/blob/master/ryu/topology/switches.py#L57>

Thanks,
Iwase

> 
> But I am interested to know is there any standard method to get the port 
> number from the link_add/ link_delete event?
> 
> Thanking you
> Sakib
> 

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to