install: updates to support building deb/rpm packages that contain python wheels and install core from a single file, updates to core to install scripts by way of python directly
This commit is contained in:
parent
cd6bb319ad
commit
fcf6f30302
54 changed files with 528 additions and 187 deletions
0
package/examples/grpc/__init__.py
Normal file
0
package/examples/grpc/__init__.py
Normal file
64
package/examples/grpc/distributed_switch.py
Normal file
64
package/examples/grpc/distributed_switch.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
import argparse
|
||||
import logging
|
||||
|
||||
from core.api.grpc import client
|
||||
from core.api.grpc.wrappers import NodeType, Position, Server
|
||||
|
||||
|
||||
def log_event(event):
|
||||
logging.info("event: %s", event)
|
||||
|
||||
|
||||
def main(args):
|
||||
# helper to create interfaces
|
||||
interface_helper = client.InterfaceHelper(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create grpc client and connect
|
||||
core = client.CoreGrpcClient()
|
||||
core.connect()
|
||||
|
||||
# create session
|
||||
session = core.create_session()
|
||||
|
||||
# add distributed server
|
||||
server = Server(name="core2", host=args.server)
|
||||
session.servers.append(server)
|
||||
|
||||
# handle events session may broadcast
|
||||
core.events(session.id, log_event)
|
||||
|
||||
# create switch node
|
||||
position = Position(x=150, y=100)
|
||||
switch = session.add_node(1, _type=NodeType.SWITCH, position=position)
|
||||
position = Position(x=100, y=50)
|
||||
node1 = session.add_node(2, position=position)
|
||||
position = Position(x=200, y=50)
|
||||
node2 = session.add_node(3, position=position, server=server.name)
|
||||
|
||||
# create links
|
||||
iface1 = interface_helper.create_iface(node1.id, 0)
|
||||
session.add_link(node1=node1, node2=switch, iface1=iface1)
|
||||
iface1 = interface_helper.create_iface(node2.id, 0)
|
||||
session.add_link(node1=node2, node2=switch, iface1=iface1)
|
||||
|
||||
# start session
|
||||
core.start_session(session)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
parser = argparse.ArgumentParser(description="Run distributed_switch example")
|
||||
parser.add_argument(
|
||||
"-a",
|
||||
"--address",
|
||||
required=True,
|
||||
help="local address that distributed servers will use for gre tunneling",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
"--server",
|
||||
required=True,
|
||||
help="distributed server to use for creating nodes",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
main(args)
|
38
package/examples/grpc/emane80211.py
Normal file
38
package/examples/grpc/emane80211.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
# required imports
|
||||
from core.api.grpc import client
|
||||
from core.api.grpc.wrappers import NodeType, Position
|
||||
from core.emane.models.ieee80211abg import EmaneIeee80211abgModel
|
||||
|
||||
# interface helper
|
||||
iface_helper = client.InterfaceHelper(ip4_prefix="10.0.0.0/24", ip6_prefix="2001::/64")
|
||||
|
||||
# create grpc client and connect
|
||||
core = client.CoreGrpcClient()
|
||||
core.connect()
|
||||
|
||||
# add session
|
||||
session = core.create_session()
|
||||
|
||||
# create nodes
|
||||
position = Position(x=200, y=200)
|
||||
emane = session.add_node(
|
||||
1, _type=NodeType.EMANE, position=position, emane=EmaneIeee80211abgModel.name
|
||||
)
|
||||
position = Position(x=100, y=100)
|
||||
node1 = session.add_node(2, model="mdr", position=position)
|
||||
position = Position(x=300, y=100)
|
||||
node2 = session.add_node(3, model="mdr", position=position)
|
||||
|
||||
# create links
|
||||
iface1 = iface_helper.create_iface(node1.id, 0)
|
||||
session.add_link(node1=node1, node2=emane, iface1=iface1)
|
||||
iface1 = iface_helper.create_iface(node2.id, 0)
|
||||
session.add_link(node1=node2, node2=emane, iface1=iface1)
|
||||
|
||||
# setup emane configurations using a dict mapping currently support values as strings
|
||||
emane.set_emane_model(
|
||||
EmaneIeee80211abgModel.name, {"eventservicettl": "2", "unicastrate": "3"}
|
||||
)
|
||||
|
||||
# start session
|
||||
core.start_session(session)
|
26
package/examples/grpc/peertopeer.py
Normal file
26
package/examples/grpc/peertopeer.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
from core.api.grpc import client
|
||||
from core.api.grpc.wrappers import Position
|
||||
|
||||
# interface helper
|
||||
iface_helper = client.InterfaceHelper(ip4_prefix="10.0.0.0/24", ip6_prefix="2001::/64")
|
||||
|
||||
# create grpc client and connect
|
||||
core = client.CoreGrpcClient()
|
||||
core.connect()
|
||||
|
||||
# add session
|
||||
session = core.create_session()
|
||||
|
||||
# create nodes
|
||||
position = Position(x=100, y=100)
|
||||
node1 = session.add_node(1, position=position)
|
||||
position = Position(x=300, y=100)
|
||||
node2 = session.add_node(2, position=position)
|
||||
|
||||
# create link
|
||||
iface1 = iface_helper.create_iface(node1.id, 0)
|
||||
iface2 = iface_helper.create_iface(node2.id, 0)
|
||||
session.add_link(node1=node1, node2=node2, iface1=iface1, iface2=iface2)
|
||||
|
||||
# start session
|
||||
core.start_session(session)
|
29
package/examples/grpc/switch.py
Normal file
29
package/examples/grpc/switch.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
from core.api.grpc import client
|
||||
from core.api.grpc.wrappers import NodeType, Position
|
||||
|
||||
# interface helper
|
||||
iface_helper = client.InterfaceHelper(ip4_prefix="10.0.0.0/24", ip6_prefix="2001::/64")
|
||||
|
||||
# create grpc client and connect
|
||||
core = client.CoreGrpcClient()
|
||||
core.connect()
|
||||
|
||||
# add session
|
||||
session = core.create_session()
|
||||
|
||||
# create nodes
|
||||
position = Position(x=200, y=200)
|
||||
switch = session.add_node(1, _type=NodeType.SWITCH, position=position)
|
||||
position = Position(x=100, y=100)
|
||||
node1 = session.add_node(2, position=position)
|
||||
position = Position(x=300, y=100)
|
||||
node2 = session.add_node(3, position=position)
|
||||
|
||||
# create links
|
||||
iface1 = iface_helper.create_iface(node1.id, 0)
|
||||
session.add_link(node1=node1, node2=switch, iface1=iface1)
|
||||
iface1 = iface_helper.create_iface(node2.id, 0)
|
||||
session.add_link(node1=node2, node2=switch, iface1=iface1)
|
||||
|
||||
# start session
|
||||
core.start_session(session)
|
29
package/examples/grpc/wireless.py
Normal file
29
package/examples/grpc/wireless.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
from core.api.grpc import client
|
||||
from core.api.grpc.wrappers import NodeType, Position
|
||||
|
||||
# interface helper
|
||||
iface_helper = client.InterfaceHelper(ip4_prefix="10.0.0.0/24", ip6_prefix="2001::/64")
|
||||
|
||||
# create grpc client and connect
|
||||
core = client.CoreGrpcClient()
|
||||
core.connect()
|
||||
|
||||
# add session
|
||||
session = core.create_session()
|
||||
|
||||
# create nodes
|
||||
position = Position(x=200, y=200)
|
||||
wlan = session.add_node(1, _type=NodeType.WIRELESS, position=position)
|
||||
position = Position(x=100, y=100)
|
||||
node1 = session.add_node(2, model="mdr", position=position)
|
||||
position = Position(x=300, y=100)
|
||||
node2 = session.add_node(3, model="mdr", position=position)
|
||||
|
||||
# create links
|
||||
iface1 = iface_helper.create_iface(node1.id, 0)
|
||||
session.add_link(node1=node1, node2=wlan, iface1=iface1)
|
||||
iface1 = iface_helper.create_iface(node2.id, 0)
|
||||
session.add_link(node1=node2, node2=wlan, iface1=iface1)
|
||||
|
||||
# start session
|
||||
core.start_session(session)
|
41
package/examples/grpc/wlan.py
Normal file
41
package/examples/grpc/wlan.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
from core.api.grpc import client
|
||||
from core.api.grpc.wrappers import NodeType, Position
|
||||
|
||||
# interface helper
|
||||
iface_helper = client.InterfaceHelper(ip4_prefix="10.0.0.0/24", ip6_prefix="2001::/64")
|
||||
|
||||
# create grpc client and connect
|
||||
core = client.CoreGrpcClient()
|
||||
core.connect()
|
||||
|
||||
# add session
|
||||
session = core.create_session()
|
||||
|
||||
# create nodes
|
||||
position = Position(x=200, y=200)
|
||||
wlan = session.add_node(1, _type=NodeType.WIRELESS_LAN, position=position)
|
||||
position = Position(x=100, y=100)
|
||||
node1 = session.add_node(2, model="mdr", position=position)
|
||||
position = Position(x=300, y=100)
|
||||
node2 = session.add_node(3, model="mdr", position=position)
|
||||
|
||||
# create links
|
||||
iface1 = iface_helper.create_iface(node1.id, 0)
|
||||
session.add_link(node1=node1, node2=wlan, iface1=iface1)
|
||||
iface1 = iface_helper.create_iface(node2.id, 0)
|
||||
session.add_link(node1=node2, node2=wlan, iface1=iface1)
|
||||
|
||||
# set wlan config using a dict mapping currently
|
||||
# support values as strings
|
||||
wlan.set_wlan(
|
||||
{
|
||||
"range": "280",
|
||||
"bandwidth": "55000000",
|
||||
"delay": "6000",
|
||||
"jitter": "5",
|
||||
"error": "5",
|
||||
}
|
||||
)
|
||||
|
||||
# start session
|
||||
core.start_session(session)
|
Loading…
Add table
Add a link
Reference in a new issue