module PxnxJruby class SessionDirectoryNotification require 'java' require 'jruby/core_ext' java_import org.slf4j.Logger java_import org.slf4j.LoggerFactory include Java::com.cisco.pxgrid.stub.identity.SessionDirectoryNotification java_signature 'void onChange(com.cisco.pxgrid.model.net.Session)' attr_accessor :session, :interface, :device_ip_address # TODO: Test this method. # TODO: Properly create calls to start integration with the IP received. def onChange(session) # Log this session id. @session = session @interface = session.getInterface device_interfaces = @interface.getIpIntfIDs device = device_interfaces[0] @device_ip_address = device.get_ip_address connect_manager = PxnxJruby::ConnectionManager.instance log = LoggerFactory.getLogger(SessionDirectoryNotification.become_java!) log.info("Found new IP #{@device_ip_address} connecting to the network, assessing.") connect_manager.new_connection(@device_ip_address) end end end