I should start off by saying that a lot of this code is in flux right now. As KK mentioned, I recently checked in some significant changes to authenticator that will hopefully make retrieving exactly the type of information Te-Yuan is looking for much more efficient by not requiring a call to the database and thus not requiring the asynchronous callback interface. That being said, only the back-end of these changes has been checked in, and the improved interface + documentation to go with it has yet to be completed. Thus in the meantime, bindings_storage is the correct way to retrieve this information.

All calls to bindings_storage take a callback as an argument because they require a query to the database. Assuming you're querying from python (the required callback prototypes for C++ can be inferred from bindings_storage.hh), there are two high-level types of queries: get_names_by_* and get_entities_by_name.

get_name_by_* (e.g. get_names_by_mac, get_names_by_ip etc) will retrieve all names associated with a given network identifier. The callback passed in will be called with a list of (name, name_type) tuples (e.g. [ ("host1", Name.HOST), ("user1", Name.USER) ]).

get_entities_by_name meanwhile will retrieve all network identifiers associated with a particular name. In particular, the callback passed in will be called with of a list of (dpid, port, ethernet addr, ip addr) tuples. The values returned however are in their integer format so you'll likely want to create datapathid/ethernetaddr/ipaddr objects out of them.

bindings_directory.py wraps some of the bindings_storage code for specific uses, but I'm not sure how easy the code is to follow as example uses. For example, get_interfaces_for_host(hostname) returns the information get_entities_by_name does but with a location name and also with the mac/ip addresses in their typed forms.

In regards to the specific query for the switch a host is connected to, you'll probably want to use get_entities_by_name("host1", Name.HOST, cb)

In general all of this code isn't nearly as clean/documented as we'd like it to be, but we're working on it and will hopefully be able to get it out there soon.

Natasha

On Feb 16, 2009, at 1:00 PM, kk yap wrote:

HI All,

Below is a question about location binding.  The new upgraded version
from Natasha looks very useful, and we would love some help in getting
to use it.

Thanks.

Regards
KK


---------- Forwarded message ----------
From: Te-Yuan Huang <[email protected]>
Date: 2009/2/16
Subject: Questions on Location Binding
To: [email protected]
Cc: kk yap <[email protected]>, Nikhil Handigol
<[email protected]>, Michael Chan <[email protected]>,
Masayoshi Kobayashi <[email protected]>


Hi all,

I am trying to use Bindings_Storage to retrieve information
about which datapath(switch) a host is connected to.

Questions:
1. Which function should I look into?
   I did found that "get_location_by_name" might be helpful,
   but I would like to confirm the functionality of it.
   Or would love to know where can I find documentations about
functions inside Bindings_Storage.

2. In order to use get_location_by_name, I need to supply a name for
host in string format.
   There is a get_name_by_ip() function, but there is no return value.
I guess the information is passed by reference through callback functions.
    But I have no clue about which function I should pass into the
get_name_by_ip() function.
    Is there any sample code that I can take a look at ?

Best,
Te-Yuan

_______________________________________________
nox-dev mailing list
[email protected]
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org


_______________________________________________
nox-dev mailing list
[email protected]
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org

Reply via email to