Hi Dave and Ethan.
I wanted to run by you the algorithm for getting the proper IP addresses
for the Derived Manifests project, to make sure I've got my bases covered.
For the benefit of others: the IP addresses will be part of the
environment set up by the Derived Manifests Module (DMM). The DMM will
then run a script which can call a utility (aimanifest) to make
system-specific customizations to a manifest before AI installs from it.
The design spec allows for only one IP address to be propagated in the
environment: SI_HOSTADDR. However, there could be a system with
multiple host adapters connected, and so there can be multiple
addresses. My algorithm addresses this and introduces numbered host
addresses and an environment variable that returns the number of host
addresses.
Here's the algorithm:
list of network interfaces = `ipadm show-if`
if list is empty:
putenv(SI_HOSTADDR_1, "")
putenv(SI_NUM_HOSTADDR, 0)
remove virtual interafaces from the list
remove interfaces not in the "OK" state from the list
if list is empty:
putenv(SI_HOSTADDR_1, "")
putenv(SI_NUM_HOSTADDR, 0)
if only one interface remains in the list:
putenv(SI_HOSTADDR_1, that interface)
putenv(SI_NUM_HOSTADDR, 1)
primary_interface = `netstrategy`
if (error) or (no primary_interface returned):
primary_interface =
the first one in the list of network interfaces that does broadcast
if primary_interface is still not determined:
primary_interface = the first one in the list of network interfaces
# An interface can have many addresses associated with it. For example,
it can # have an IPv4 and an IPv6 address.
addr_if_mapping = `ipadm show-addr`
Remove all lines with ":" in the output. (These are IPv6 entries.)
for item = each ramaining item in list of network interfaces:
matching_if_list = `filter lines of addr_if_mapping that match item`
if a.b.c.d entry exists in matching_if_list:
matching_addr = first a.b.c.d entry
else if a.b.c.d->e.f.g.h entry exists in matching_if_list:
matching_addr = a.b.c.d portion
putenv(SI_HOSTADDR_1, matching address of primary interface)
for all other (non-primary) interfaces:
putenv(SI_HOSTADDR_x, matching address of interface)
putenv(SI_NUM_HOSTADDR, number of interfaces set in environment)
Thanks,
Jack
_______________________________________________
caiman-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/caiman-discuss