Merge branch 'develop' into pydocupdates

This commit is contained in:
Huy Pham 2019-09-13 11:07:43 -07:00
commit 813ddc10c6
11 changed files with 56 additions and 51 deletions

36
daemon/Pipfile.lock generated
View file

@ -16,15 +16,24 @@
"default": {
"configparser": {
"hashes": [
"sha256:296a9c0d0607f689f2a262d4ca3fa2b22146ac0acb07fd281125c86dee3bcf50",
"sha256:5e4c0d9de6ffc76f625eda1f5e28cec0700aed7cdacfe5070964df002ac02fec"
"sha256:254c1d9c79f60c45dfde850850883d5aaa7f19a23f13561243a050d5a7c3fe4c",
"sha256:c7d282687a5308319bf3d2e7706e575c635b0a470342641c93bea0ea3b5331df"
],
"version": "==4.0.1"
"version": "==4.0.2"
},
"core": {
"editable": true,
"path": "."
},
"enum34": {
"hashes": [
"sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850",
"sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a",
"sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79",
"sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1"
],
"version": "==1.1.6"
},
"future": {
"hashes": [
"sha256:67045236dcfd6816dc439556d009594abf643e5eb48992e36beac09c2ca659b8"
@ -95,27 +104,6 @@
],
"version": "==4.4.1"
},
"protobuf": {
"hashes": [
"sha256:00a1b0b352dc7c809749526d1688a64b62ea400c5b05416f93cfb1b11a036295",
"sha256:01acbca2d2c8c3f7f235f1842440adbe01bbc379fa1cbdd80753801432b3fae9",
"sha256:0a795bca65987b62d6b8a2d934aa317fd1a4d06a6dd4df36312f5b0ade44a8d9",
"sha256:0ec035114213b6d6e7713987a759d762dd94e9f82284515b3b7331f34bfaec7f",
"sha256:31b18e1434b4907cb0113e7a372cd4d92c047ce7ba0fa7ea66a404d6388ed2c1",
"sha256:32a3abf79b0bef073c70656e86d5bd68a28a1fbb138429912c4fc07b9d426b07",
"sha256:55f85b7808766e5e3f526818f5e2aeb5ba2edcc45bcccede46a3ccc19b569cb0",
"sha256:64ab9bc971989cbdd648c102a96253fdf0202b0c38f15bd34759a8707bdd5f64",
"sha256:64cf847e843a465b6c1ba90fb6c7f7844d54dbe9eb731e86a60981d03f5b2e6e",
"sha256:917c8662b585470e8fd42f052661fc66d59fccaae450a60044307dcbf82a3335",
"sha256:afed9003d7f2be2c3df20f64220c30faec441073731511728a2cb4cab4cd46a6",
"sha256:bf8e05d638b585d1752c5a84247134a0350d3a8b73d3632489a014a9f6f1e758",
"sha256:d831b047bd69becaf64019a47179eb22118a50dd008340655266a906c69c6417",
"sha256:de2760583ed28749ff885789c1cbc6c9c06d6de92fc825740ab99deb2f25ea4d",
"sha256:eabc4cf1bc19689af8022ba52fd668564a8d96e0d08f3b4732d26a64255216a4",
"sha256:fcff6086c86fb1628d94ea455c7b9de898afc50378042927a59df8065a79a549"
],
"version": "==3.9.1"
},
"six": {
"hashes": [
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",

View file

@ -262,7 +262,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
"""
try:
return session.get_node(node_id)
except KeyError:
except CoreError:
context.abort(
grpc.StatusCode.NOT_FOUND, "node {} not found".format(node_id)
)

View file

@ -489,12 +489,10 @@ class CoreBroker(object):
:param int node_id: node id of network to add tunnel to
:return: list of gre taps
:rtype: list
:raises core.CoreError: when node to add net tunnel to does not exist
"""
try:
net = self.session.get_node(node_id)
logging.info("adding net tunnel for: id(%s) %s", node_id, net)
except KeyError:
raise KeyError("network node %s not found" % node_id)
net = self.session.get_node(node_id)
logging.info("adding net tunnel for: id(%s) %s", node_id, net)
# add other nets here that do not require tunnels
if nodeutils.is_node(net, NodeTypes.EMANE_NET):

View file

@ -14,7 +14,7 @@ from builtins import range
from itertools import repeat
from queue import Empty, Queue
from core import utils
from core import CoreError, utils
from core.api.tlv import coreapi, dataconversion, structutils
from core.config import ConfigShim
from core.emulator.data import ConfigData, EventData, ExceptionData, FileData
@ -913,7 +913,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
utils.mute_detach(command)
else:
node.cmd(command, wait=False)
except KeyError:
except CoreError:
logging.exception("error getting object: %s", node_num)
# XXX wait and queue this message to try again later
# XXX maybe this should be done differently
@ -1420,7 +1420,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
node = self.session.get_node(node_id)
if object_name == BasicRangeModel.name:
node.updatemodel(parsed_config)
except KeyError:
except CoreError:
logging.error(
"skipping mobility configuration for unknown node: %s", node_id
)
@ -1581,6 +1581,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
:param core.api.tlv.coreapi.CoreEventMessage message: event message to handle
:return: reply messages
:raises core.CoreError: when event type <= SHUTDOWN_STATE and not a known node id
"""
event_data = EventData(
node=message.get_tlv(EventTlvs.NODE.value),
@ -1599,10 +1600,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
logging.debug("handling event %s at %s", event_type.name, time.ctime())
if event_type.value <= EventTypes.SHUTDOWN_STATE.value:
if node_id is not None:
try:
node = self.session.get_node(node_id)
except KeyError:
raise KeyError("Event message for unknown node %d" % node_id)
node = self.session.get_node(node_id)
# configure mobility models for WLAN added during runtime
if event_type == EventTypes.INSTANTIATION_STATE and nodeutils.is_node(
@ -1706,7 +1704,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
try:
node = self.session.get_node(node_id)
except KeyError:
except CoreError:
logging.warning(
"ignoring event for service '%s', unknown node '%s'", name, node_id
)

View file

@ -7,7 +7,7 @@ import logging
import os
import threading
from core import CoreCommandError, constants, utils
from core import CoreCommandError, CoreError, constants, utils
from core.api.tlv import coreapi, dataconversion
from core.config import ConfigGroup, ConfigShim, Configuration, ModelManager
from core.emane import emanemanifest
@ -950,7 +950,7 @@ class EmaneManager(ModelManager):
# generate a node message for this location update
try:
node = self.session.get_node(n)
except KeyError:
except CoreError:
logging.exception(
"location event NEM %s has no corresponding node %s" % (nemid, n)
)

View file

@ -4,6 +4,7 @@ Defines Emane Models used within CORE.
import logging
import os
from core import CoreError
from core.config import ConfigGroup, Configuration
from core.emane import emanemanifest
from core.emulator.enumerations import ConfigDataTypes
@ -142,7 +143,7 @@ class EmaneModel(WirelessModel):
try:
wlan = self.session.get_node(self.id)
wlan.setnempositions(moved_netifs)
except KeyError:
except CoreError:
logging.exception("error during update")
def linkconfig(

View file

@ -1663,7 +1663,7 @@ class Session(object):
return None
return control_net
except KeyError:
except CoreError:
if remove:
return None
@ -1807,7 +1807,7 @@ class Session(object):
try:
control_net = self.get_control_net(net_index)
except KeyError:
except CoreError:
logging.exception("error retrieving control net node")
return

View file

@ -11,7 +11,7 @@ import time
from builtins import int
from functools import total_ordering
from core import utils
from core import CoreError, utils
from core.config import ConfigGroup, ConfigurableOptions, Configuration, ModelManager
from core.emulator.data import EventData, LinkData
from core.emulator.enumerations import (
@ -79,7 +79,7 @@ class MobilityManager(ModelManager):
try:
node = self.session.get_node(node_id)
except KeyError:
except CoreError:
logging.warning(
"skipping mobility configuration for unknown node: %s", node_id
)
@ -112,7 +112,7 @@ class MobilityManager(ModelManager):
try:
node = self.session.get_node(node_id)
except KeyError:
except CoreError:
logging.exception(
"Ignoring event for model '%s', unknown node '%s'", name, node_id
)
@ -203,7 +203,7 @@ class MobilityManager(ModelManager):
for node_id in self.nodes():
try:
node = self.session.get_node(node_id)
except KeyError:
except CoreError:
continue
if node.model:
node.model.update(moved, moved_netifs)

View file

@ -7,7 +7,7 @@ import socket
from future.moves.urllib.parse import urlparse
from core import constants
from core import CoreError, constants
from core.emulator.enumerations import (
EventTypes,
LinkTlvs,
@ -438,7 +438,7 @@ class Sdt(object):
try:
node = self.session.get_node(nodenum)
except KeyError:
except CoreError:
node = None
if node:
self.updatenode(
@ -508,7 +508,7 @@ class Sdt(object):
else:
try:
n = self.session.get_node(nodenum)
except KeyError:
except CoreError:
return False
if nodeutils.is_node(n, (NodeTypes.WIRELESS_LAN, NodeTypes.EMANE)):
return True

View file

@ -51,7 +51,7 @@ class TestEmane:
session.emane.set_model_config(
emane_network.id,
EmaneTdmaModel.name,
{"schedule": os.path.join(_DIR, "../examples/tdma/schedule.xml")},
{"schedule": os.path.join(_DIR, "../../examples/tdma/schedule.xml")},
)
# create nodes

View file

@ -42,6 +42,14 @@ python3 -m pipenv install --dev
export PYTHON=$(python3 -m pipenv --py)
```
### Setup pre-commit
Install pre-commit hooks to help automate running tool checks against code.
```shell
python3 -m pipenv run pre-commit install
```
### Build CORE
```shell
@ -69,6 +77,18 @@ cd $REPO/netns
sudo make install
```
### Adding EMANE to Pipenv
EMANE bindings are not available through pip, you will need to build and install from source.
[Build EMANE](https://github.com/adjacentlink/emane/wiki/Build#general-build-instructions)
```shell
# after building emane above
# ./autogen.sh && ./configure --prefix=/usr && make
python3 -m pipenv install --skip-lock $EMANEREPO/src/python
```
### Running CORE
This will run the core-daemon server using the configuration files within the repo.