merged latest code from rodolfos merge from the latest github pull
This commit is contained in:
commit
613e550e8a
32 changed files with 267 additions and 276 deletions
|
@ -13,7 +13,5 @@ Pieces can be imported individually, for example
|
|||
from core.netns import vnode
|
||||
"""
|
||||
|
||||
__all__ = []
|
||||
|
||||
# Automatically import all add-ons listed in addons.__all__
|
||||
from addons import *
|
||||
|
|
|
@ -246,7 +246,9 @@ class EmaneManager(ConfigurableManager):
|
|||
# Adamson change: first check for iface config keyed by "node:ifc.name"
|
||||
# (so that nodes w/ multiple interfaces of same conftype can have
|
||||
# different configs for each separate interface)
|
||||
key = 1000 * ifc.node.objid + ifc.netindex
|
||||
key = 1000*ifc.node.objid
|
||||
if ifc.netindex is not None:
|
||||
key += ifc.netindex
|
||||
values = self.getconfig(key, conftype, None)[1]
|
||||
if not values:
|
||||
values = self.getconfig(ifc.node.objid, conftype, None)[1]
|
||||
|
|
|
@ -301,12 +301,6 @@ class LxBrNet(PyCoreNet):
|
|||
snoop = "/sys/devices/virtual/net/%s/bridge/multicast_snooping" % self.brname
|
||||
if os.path.exists(snoop):
|
||||
open(snoop, "w").write('0')
|
||||
|
||||
# turn on LLDP forwarding (disabled by default in linux)
|
||||
lldpfile = "/sys/class/net/%s/bridge/group_fwd_mask" % self.brname
|
||||
if os.path.exists(lldpfile):
|
||||
open(lldpfile, "w").write('0x4000')
|
||||
|
||||
except subprocess.CalledProcessError:
|
||||
logger.exception("Error setting bridge parameters")
|
||||
|
||||
|
|
|
@ -389,8 +389,12 @@ class SimpleLxcNode(PyCoreNode):
|
|||
:return: nothing
|
||||
"""
|
||||
if self.up:
|
||||
self.cmd([constants.IP_BIN, "addr", "add", str(addr),
|
||||
"dev", self.ifname(ifindex)])
|
||||
if ":" in str(addr): # check if addr is ipv6
|
||||
self.cmd([constants.IP_BIN, "addr", "add", str(addr),
|
||||
"dev", self.ifname(ifindex)])
|
||||
else:
|
||||
self.cmd([constants.IP_BIN, "addr", "add", str(addr), "broadcast", "+",
|
||||
"dev", self.ifname(ifindex)])
|
||||
self._netif[ifindex].addaddr(addr)
|
||||
|
||||
def deladdr(self, ifindex, addr):
|
||||
|
|
|
@ -106,6 +106,10 @@ class CoreServices(ConfigurableManager):
|
|||
from core.services import startup
|
||||
self.is_startup_service = startup.Startup.is_startup_service
|
||||
|
||||
@classmethod
|
||||
def add_service_path(cls, path):
|
||||
cls.service_path.add(path)
|
||||
|
||||
def importcustom(self, path):
|
||||
"""
|
||||
Import services from a myservices directory.
|
||||
|
@ -975,7 +979,7 @@ class CoreService(object):
|
|||
:return: nothing
|
||||
"""
|
||||
if key not in self.keys:
|
||||
raise ValueError
|
||||
raise ValueError('key `%s` not in `%s`' % (key, self.keys))
|
||||
# this handles data conversion to int, string, and tuples
|
||||
if value:
|
||||
if key == "startidx":
|
||||
|
|
|
@ -4,4 +4,17 @@ Services
|
|||
Services available to nodes can be put in this directory. Everything listed in
|
||||
__all__ is automatically loaded by the main core module.
|
||||
"""
|
||||
__all__ = ["quagga", "nrl", "xorp", "bird", "utility", "security", "ucarp", "dockersvc", "OvsService" , "ryuService" , 'startup' ]
|
||||
|
||||
__all__ = [
|
||||
"quagga",
|
||||
"nrl",
|
||||
"xorp",
|
||||
"bird",
|
||||
"utility",
|
||||
"security",
|
||||
"ucarp",
|
||||
"dockersvc",
|
||||
"OvsService",
|
||||
"RyuService",
|
||||
"startup"
|
||||
]
|
||||
|
|
|
@ -603,7 +603,7 @@ class MgenActor(NrlService):
|
|||
cfg = "#!/bin/sh\n"
|
||||
cfg += "# auto-generated by nrl.py:MgenActor.generateconfig()\n"
|
||||
comments = ""
|
||||
cmd = "python /usr/local/bin/mgenBasicActor.py -n %s -a 0.0.0.0 -p 5555" % (node.name)
|
||||
cmd = "mgenBasicActor.py -n %s -a 0.0.0.0" % node.name
|
||||
|
||||
servicenames = map(lambda x: x._name, services)
|
||||
netifs = filter(lambda x: not getattr(x, 'control', False), node.netifs())
|
||||
|
|
|
@ -12,16 +12,11 @@ from core.misc import nodeutils
|
|||
from core.service import CoreService
|
||||
from core.service import ServiceManager
|
||||
|
||||
QUAGGA_USER = "root"
|
||||
QUAGGA_GROUP = "root"
|
||||
if os.uname()[0] == "FreeBSD":
|
||||
QUAGGA_GROUP = "wheel"
|
||||
|
||||
|
||||
class Zebra(CoreService):
|
||||
_name = "zebra"
|
||||
_group = "Quagga"
|
||||
_depends = ("vtysh",)
|
||||
_dirs = ("/usr/local/etc/quagga", "/var/run/quagga")
|
||||
_configs = ("/usr/local/etc/quagga/Quagga.conf",
|
||||
"quaggaboot.sh", "/usr/local/etc/quagga/vtysh.conf")
|
||||
|
@ -53,16 +48,11 @@ class Zebra(CoreService):
|
|||
|
||||
@classmethod
|
||||
def generateQuaggaConf(cls, node, services):
|
||||
""" Returns configuration file text. Other services that depend on zebra
|
||||
will have generatequaggaifcconfig() and generatequaggaconfig()
|
||||
hooks that are invoked here.
|
||||
"""
|
||||
# Check whether the node is running OVS
|
||||
has_ovs = 0
|
||||
for s in services:
|
||||
if s._name == "OvsService":
|
||||
has_ovs =1
|
||||
|
||||
Returns configuration file text. Other services that depend on zebra
|
||||
will have generatequaggaifcconfig() and generatequaggaconfig()
|
||||
hooks that are invoked here.
|
||||
"""
|
||||
# we could verify here that filename == Quagga.conf
|
||||
cfg = ""
|
||||
for ifc in node.netifs():
|
||||
|
@ -72,7 +62,7 @@ class Zebra(CoreService):
|
|||
ifnumstr = re.findall(r"\d+", ifc.name)
|
||||
ifnum = ifnumstr[0]
|
||||
ifname = "rtr%s" % ifnum
|
||||
|
||||
|
||||
cfg += "interface %s\n" % ifname
|
||||
#cfg += "interface %s\n" % ifc.name
|
||||
# include control interfaces in addressing but not routing daemons
|
||||
|
@ -147,8 +137,6 @@ QUAGGA_CONF=%s
|
|||
QUAGGA_SBIN_SEARCH=%s
|
||||
QUAGGA_BIN_SEARCH=%s
|
||||
QUAGGA_STATE_DIR=%s
|
||||
QUAGGA_USER=%s
|
||||
QUAGGA_GROUP=%s
|
||||
|
||||
searchforprog()
|
||||
{
|
||||
|
@ -177,21 +165,6 @@ confcheck()
|
|||
fi
|
||||
}
|
||||
|
||||
waitforvtyfiles()
|
||||
{
|
||||
for f in "$@"; do
|
||||
count=1
|
||||
until [ -e $QUAGGA_STATE_DIR/$f ]; do
|
||||
if [ $count -eq 10 ]; then
|
||||
echo "ERROR: vty file not found: $QUAGGA_STATE_DIR/$f" >&2
|
||||
return 1
|
||||
fi
|
||||
sleep 0.1
|
||||
count=$(($count + 1))
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
bootdaemon()
|
||||
{
|
||||
QUAGGA_SBIN_DIR=$(searchforprog $1 $QUAGGA_SBIN_SEARCH)
|
||||
|
@ -203,54 +176,54 @@ bootdaemon()
|
|||
|
||||
flags=""
|
||||
|
||||
if [ "$1" != "zebra" ]; then
|
||||
waitforvtyfiles zebra.vty
|
||||
fi
|
||||
|
||||
if [ "$1" = "xpimd" ] && \\
|
||||
grep -E -q '^[[:space:]]*router[[:space:]]+pim6[[:space:]]*$' $QUAGGA_CONF; then
|
||||
flags="$flags -6"
|
||||
fi
|
||||
|
||||
$QUAGGA_SBIN_DIR/$1 $flags -u $QUAGGA_USER -g $QUAGGA_GROUP -d
|
||||
$QUAGGA_SBIN_DIR/$1 $flags -d
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "ERROR: Quagga's '$1' daemon failed to start!:"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
bootvtysh()
|
||||
bootquagga()
|
||||
{
|
||||
QUAGGA_BIN_DIR=$(searchforprog $1 $QUAGGA_BIN_SEARCH)
|
||||
QUAGGA_BIN_DIR=$(searchforprog 'vtysh' $QUAGGA_BIN_SEARCH)
|
||||
if [ "z$QUAGGA_BIN_DIR" = "z" ]; then
|
||||
echo "ERROR: Quagga's '$1' daemon not found in search path:"
|
||||
echo " $QUAGGA_SBIN_SEARCH"
|
||||
echo "ERROR: Quagga's 'vtysh' program not found in search path:"
|
||||
echo " $QUAGGA_BIN_SEARCH"
|
||||
return 1
|
||||
fi
|
||||
|
||||
vtyfiles="zebra.vty"
|
||||
# fix /var/run/quagga permissions
|
||||
id -u quagga 2>/dev/null >/dev/null
|
||||
if [ "$?" = "0" ]; then
|
||||
chown quagga $QUAGGA_STATE_DIR
|
||||
fi
|
||||
|
||||
bootdaemon "zebra"
|
||||
for r in rip ripng ospf6 ospf bgp babel; do
|
||||
if grep -q "^router \<${r}\>" $QUAGGA_CONF; then
|
||||
vtyfiles="$vtyfiles ${r}d.vty"
|
||||
bootdaemon "${r}d"
|
||||
fi
|
||||
done
|
||||
|
||||
if grep -E -q '^[[:space:]]*router[[:space:]]+pim6?[[:space:]]*$' $QUAGGA_CONF; then
|
||||
vtyfiles="$vtyfiles xpimd.vty"
|
||||
bootdaemon "xpimd"
|
||||
fi
|
||||
|
||||
# wait for Quagga daemon vty files to appear before invoking vtysh
|
||||
waitforvtyfiles $vtyfiles
|
||||
|
||||
$QUAGGA_BIN_DIR/vtysh -b
|
||||
}
|
||||
|
||||
confcheck
|
||||
if [ "x$1" = "x" ]; then
|
||||
echo "ERROR: missing the name of the Quagga daemon to boot"
|
||||
if [ "$1" != "zebra" ]; then
|
||||
echo "WARNING: '$1': all Quagga daemons are launched by the 'zebra' service!"
|
||||
exit 1
|
||||
elif [ "$1" = "vtysh" ]; then
|
||||
bootvtysh $1
|
||||
else
|
||||
bootdaemon $1
|
||||
fi
|
||||
""" % (cls._configs[0], quagga_sbin_search, quagga_bin_search, constants.QUAGGA_STATE_DIR, QUAGGA_USER, QUAGGA_GROUP)
|
||||
confcheck
|
||||
bootquagga
|
||||
""" % (cls._configs[0], quagga_sbin_search, quagga_bin_search, constants.QUAGGA_STATE_DIR)
|
||||
|
||||
|
||||
class QuaggaService(CoreService):
|
||||
|
@ -308,7 +281,7 @@ class QuaggaService(CoreService):
|
|||
return ""
|
||||
|
||||
@classmethod
|
||||
def generatequaggaconfig(cls, node, services):
|
||||
def generatequaggaconfig(cls, node):
|
||||
return ""
|
||||
|
||||
|
||||
|
@ -319,9 +292,9 @@ class Ospfv2(QuaggaService):
|
|||
unified Quagga.conf file.
|
||||
"""
|
||||
_name = "OSPFv2"
|
||||
_startup = ("sh quaggaboot.sh ospfd",)
|
||||
_shutdown = ("killall ospfd",)
|
||||
_validate = ("pidof ospfd",)
|
||||
_startup = ()
|
||||
_shutdown = ("killall ospfd", )
|
||||
_validate = ("pidof ospfd", )
|
||||
_ipv4_routing = True
|
||||
|
||||
@staticmethod
|
||||
|
@ -353,7 +326,7 @@ class Ospfv2(QuaggaService):
|
|||
return ""
|
||||
|
||||
@classmethod
|
||||
def generatequaggaconfig(cls, node, services):
|
||||
def generatequaggaconfig(cls, node):
|
||||
cfg = "router ospf\n"
|
||||
rtrid = cls.routerid(node)
|
||||
cfg += " router-id %s\n" % rtrid
|
||||
|
@ -394,9 +367,9 @@ class Ospfv3(QuaggaService):
|
|||
unified Quagga.conf file.
|
||||
"""
|
||||
_name = "OSPFv3"
|
||||
_startup = ("sh quaggaboot.sh ospf6d",)
|
||||
_shutdown = ("killall ospf6d",)
|
||||
_validate = ("pidof ospf6d",)
|
||||
_startup = ()
|
||||
_shutdown = ("killall ospf6d", )
|
||||
_validate = ("pidof ospf6d", )
|
||||
_ipv4_routing = True
|
||||
_ipv6_routing = True
|
||||
|
||||
|
@ -438,13 +411,7 @@ class Ospfv3(QuaggaService):
|
|||
return ""
|
||||
|
||||
@classmethod
|
||||
def generatequaggaconfig(cls, node, services):
|
||||
# Check whether the node is running OVS
|
||||
has_ovs = 0
|
||||
for s in services:
|
||||
if s._name == "OvsService":
|
||||
has_ovs =1
|
||||
|
||||
def generatequaggaconfig(cls, node):
|
||||
cfg = "router ospf6\n"
|
||||
rtrid = cls.routerid(node)
|
||||
cfg += " router-id %s\n" % rtrid
|
||||
|
@ -457,7 +424,7 @@ class Ospfv3(QuaggaService):
|
|||
ifnumstr = re.findall(r"\d+", ifc.name)
|
||||
ifnum = ifnumstr[0]
|
||||
ifname = "rtr%s" % ifnum
|
||||
|
||||
|
||||
cfg += " interface %s area 0.0.0.0\n" % ifc.name
|
||||
cfg += "!\n"
|
||||
return cfg
|
||||
|
@ -508,6 +475,7 @@ class Ospfv3mdr(Ospfv3):
|
|||
else:
|
||||
return cfg
|
||||
|
||||
|
||||
class Bgp(QuaggaService):
|
||||
"""
|
||||
The BGP service provides interdomain routing.
|
||||
|
@ -515,15 +483,15 @@ class Bgp(QuaggaService):
|
|||
having the same AS number.
|
||||
"""
|
||||
_name = "BGP"
|
||||
_startup = ("sh quaggaboot.sh bgpd",)
|
||||
_shutdown = ("killall bgpd",)
|
||||
_validate = ("pidof bgpd",)
|
||||
_startup = ()
|
||||
_shutdown = ("killall bgpd", )
|
||||
_validate = ("pidof bgpd", )
|
||||
_custom_needed = True
|
||||
_ipv4_routing = True
|
||||
_ipv6_routing = True
|
||||
|
||||
@classmethod
|
||||
def generatequaggaconfig(cls, node, services):
|
||||
def generatequaggaconfig(cls, node):
|
||||
cfg = "!\n! BGP configuration\n!\n"
|
||||
cfg += "! You should configure the AS number below,\n"
|
||||
cfg += "! along with this router's peers.\n!\n"
|
||||
|
@ -534,18 +502,19 @@ class Bgp(QuaggaService):
|
|||
cfg += "! neighbor 1.2.3.4 remote-as 555\n!\n"
|
||||
return cfg
|
||||
|
||||
|
||||
class Rip(QuaggaService):
|
||||
"""
|
||||
The RIP service provides IPv4 routing for wired networks.
|
||||
"""
|
||||
_name = "RIP"
|
||||
_startup = ("sh quaggaboot.sh ripd",)
|
||||
_shutdown = ("killall ripd",)
|
||||
_validate = ("pidof ripd",)
|
||||
_startup = ()
|
||||
_shutdown = ("killall ripd", )
|
||||
_validate = ("pidof ripd", )
|
||||
_ipv4_routing = True
|
||||
|
||||
@classmethod
|
||||
def generatequaggaconfig(cls, node, services):
|
||||
def generatequaggaconfig(cls, node):
|
||||
cfg = """\
|
||||
router rip
|
||||
redistribute static
|
||||
|
@ -556,18 +525,19 @@ router rip
|
|||
"""
|
||||
return cfg
|
||||
|
||||
|
||||
class Ripng(QuaggaService):
|
||||
"""
|
||||
The RIP NG service provides IPv6 routing for wired networks.
|
||||
"""
|
||||
_name = "RIPNG"
|
||||
_startup = ("sh quaggaboot.sh ripngd",)
|
||||
_shutdown = ("killall ripngd",)
|
||||
_validate = ("pidof ripngd",)
|
||||
_startup = ()
|
||||
_shutdown = ("killall ripngd", )
|
||||
_validate = ("pidof ripngd", )
|
||||
_ipv6_routing = True
|
||||
|
||||
@classmethod
|
||||
def generatequaggaconfig(cls, node, services):
|
||||
def generatequaggaconfig(cls, node):
|
||||
cfg = """\
|
||||
router ripng
|
||||
redistribute static
|
||||
|
@ -578,36 +548,24 @@ router ripng
|
|||
"""
|
||||
return cfg
|
||||
|
||||
|
||||
class Babel(QuaggaService):
|
||||
"""
|
||||
The Babel service provides a loop-avoiding distance-vector routing
|
||||
protocol for IPv6 and IPv4 with fast convergence properties.
|
||||
"""
|
||||
_name = "Babel"
|
||||
_startup = ("sh quaggaboot.sh babeld",)
|
||||
_shutdown = ("killall babeld",)
|
||||
_validate = ("pidof babeld",)
|
||||
_startup = ()
|
||||
_shutdown = ("killall babeld", )
|
||||
_validate = ("pidof babeld", )
|
||||
_ipv6_routing = True
|
||||
|
||||
@classmethod
|
||||
def generatequaggaconfig(cls, node, services):
|
||||
# Check whether the node is running OVS
|
||||
has_ovs = 0
|
||||
for s in services:
|
||||
if s._name == "OvsService":
|
||||
has_ovs =1
|
||||
|
||||
def generatequaggaconfig(cls, node):
|
||||
cfg = "router babel\n"
|
||||
for ifc in node.netifs():
|
||||
if hasattr(ifc, 'control') and ifc.control is True:
|
||||
if hasattr(ifc, "control") and ifc.control is True:
|
||||
continue
|
||||
if has_ovs == 0:
|
||||
ifname = ifc.name
|
||||
else:
|
||||
ifnumstr = re.findall(r"\d+", ifc.name)
|
||||
ifnum = ifnumstr[0]
|
||||
ifname = "rtr%s" % ifnum
|
||||
|
||||
cfg += " network %s\n" % ifc.name
|
||||
cfg += " redistribute static\n redistribute connected\n"
|
||||
return cfg
|
||||
|
@ -620,37 +578,23 @@ class Babel(QuaggaService):
|
|||
else:
|
||||
return " babel wired\n babel split-horizon\n"
|
||||
|
||||
|
||||
class Xpimd(QuaggaService):
|
||||
"""
|
||||
PIM multicast routing based on XORP.
|
||||
"""
|
||||
_name = 'Xpimd'
|
||||
_startup = ('sh quaggaboot.sh xpimd',)
|
||||
_shutdown = ('killall xpimd',)
|
||||
_validate = ('pidof xpimd',)
|
||||
_startup = ()
|
||||
_shutdown = ('killall xpimd', )
|
||||
_validate = ('pidof xpimd', )
|
||||
_ipv4_routing = True
|
||||
|
||||
@classmethod
|
||||
def generatequaggaconfig(cls, node, services):
|
||||
# Check whether the node is running OVS
|
||||
has_ovs = 0
|
||||
for s in services:
|
||||
if s._name == "OvsService":
|
||||
has_ovs =1
|
||||
if has_ovs == 0:
|
||||
ifname = 'eth0'
|
||||
else:
|
||||
ifname = 'rtr0'
|
||||
|
||||
def generatequaggaconfig(cls, node):
|
||||
ifname = 'eth0'
|
||||
for ifc in node.netifs():
|
||||
if ifc.name != 'lo':
|
||||
if has_ovs == 0:
|
||||
ifname = ifc.name
|
||||
else:
|
||||
ifnumstr = re.findall(r"\d+", ifc.name)
|
||||
ifnum = ifnumstr[0]
|
||||
ifname = "rtr%s" % ifnum
|
||||
|
||||
ifname = ifc.name
|
||||
break
|
||||
cfg = 'router mfea\n!\n'
|
||||
cfg += 'router igmp\n!\n'
|
||||
|
@ -665,20 +609,6 @@ class Xpimd(QuaggaService):
|
|||
def generatequaggaifcconfig(cls, node, ifc):
|
||||
return ' ip mfea\n ip igmp\n ip pim\n'
|
||||
|
||||
class Vtysh(CoreService):
|
||||
"""
|
||||
Simple service to run vtysh -b (boot) after all Quagga daemons have
|
||||
started.
|
||||
"""
|
||||
_name = "vtysh"
|
||||
_group = "Quagga"
|
||||
_startindex = 45
|
||||
_startup = ("sh quaggaboot.sh vtysh",)
|
||||
_shutdown = ()
|
||||
|
||||
@classmethod
|
||||
def generateconfig(cls, node, filename, services):
|
||||
return ""
|
||||
|
||||
def load_services():
|
||||
ServiceManager.add(Zebra)
|
||||
|
@ -690,4 +620,3 @@ def load_services():
|
|||
ServiceManager.add(Ripng)
|
||||
ServiceManager.add(Babel)
|
||||
ServiceManager.add(Xpimd)
|
||||
ServiceManager.add(Vtysh)
|
||||
|
|
|
@ -102,7 +102,6 @@ class XenNode(PyCoreNode):
|
|||
# 'sh quaggaboot.sh zebra',
|
||||
# 'sh quaggaboot.sh ospfd',
|
||||
# 'sh quaggaboot.sh ospf6d',
|
||||
'sh quaggaboot.sh vtysh',
|
||||
'killall zebra',
|
||||
'killall ospfd',
|
||||
'killall ospf6d',
|
||||
|
|
|
@ -851,12 +851,10 @@ class CoreDocumentParser1(object):
|
|||
def parse_default_services(self):
|
||||
# defaults from the CORE GUI
|
||||
self.default_services = {
|
||||
'router': ['zebra', 'OSPFv2', 'OSPFv3', 'vtysh', 'IPForward'],
|
||||
'router': ['zebra', 'OSPFv2', 'OSPFv3', 'IPForward'],
|
||||
'host': ['DefaultRoute', 'SSH'],
|
||||
'PC': ['DefaultRoute', ],
|
||||
'mdr': ['zebra', 'OSPFv3MDR', 'vtysh', 'IPForward'],
|
||||
# 'prouter': ['zebra', 'OSPFv2', 'OSPFv3', 'vtysh', 'IPForward'],
|
||||
# 'xen': ['zebra', 'OSPFv2', 'OSPFv3', 'vtysh', 'IPForward'],
|
||||
'mdr': ['zebra', 'OSPFv3MDR', 'IPForward'],
|
||||
}
|
||||
default_services = xmlutils.get_first_child_by_tag_name(self.scenario, 'CORE:defaultservices')
|
||||
if not default_services:
|
||||
|
|
|
@ -603,7 +603,7 @@ class DeviceElement(NamedXmlElement):
|
|||
device_type = DevType.HOST
|
||||
|
||||
if device_type is None:
|
||||
raise Exception
|
||||
raise ValueError("unknown device type: %s" % core_device_type)
|
||||
|
||||
NamedXmlElement.__init__(self, scen_plan, parent, device_type, device_object.name)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue