renamed session.session_id to session.id
This commit is contained in:
parent
6672fd0f7a
commit
73bc56e4c3
11 changed files with 89 additions and 90 deletions
|
@ -389,7 +389,7 @@ class CoreBroker(object):
|
|||
sid = self.session_id_master
|
||||
if sid is None:
|
||||
# this is the master session
|
||||
sid = self.session.session_id
|
||||
sid = self.session.id
|
||||
|
||||
key = (sid << 16) ^ hash(n1num) ^ (hash(n2num) << 8)
|
||||
return key & 0xFFFFFFFF
|
||||
|
@ -697,7 +697,7 @@ class CoreBroker(object):
|
|||
tlvdata += coreapi.CoreConfigTlv.pack(ConfigTlvs.DATA_TYPES.value, (ConfigDataTypes.STRING.value,))
|
||||
tlvdata += coreapi.CoreConfigTlv.pack(ConfigTlvs.VALUES.value,
|
||||
"%s:%s:%s" % (server.name, server.host, server.port))
|
||||
tlvdata += coreapi.CoreConfigTlv.pack(ConfigTlvs.SESSION.value, "%s" % self.session.session_id)
|
||||
tlvdata += coreapi.CoreConfigTlv.pack(ConfigTlvs.SESSION.value, "%s" % self.session.id)
|
||||
msg = coreapi.CoreConfMessage.pack(0, tlvdata)
|
||||
server.sock.send(msg)
|
||||
|
||||
|
@ -973,7 +973,7 @@ class CoreBroker(object):
|
|||
filename = os.path.join(self.session.session_dir, "servers")
|
||||
master = self.session_id_master
|
||||
if master is None:
|
||||
master = self.session.session_id
|
||||
master = self.session.id
|
||||
try:
|
||||
with open(filename, "w") as f:
|
||||
f.write("master=%s\n" % master)
|
||||
|
|
|
@ -57,7 +57,6 @@ class CoreHandler(SocketServer.BaseRequestHandler):
|
|||
:param request: request object
|
||||
:param str client_address: client address
|
||||
:param CoreServer server: core server instance
|
||||
:return:
|
||||
"""
|
||||
self.done = False
|
||||
self.message_handlers = {
|
||||
|
@ -140,7 +139,7 @@ class CoreHandler(SocketServer.BaseRequestHandler):
|
|||
self.session.broker.session_clients.remove(self)
|
||||
if not self.session.broker.session_clients and not self.session.is_active():
|
||||
logging.info("no session clients left and not active, initiating shutdown")
|
||||
self.coreemu.delete_session(self.session.session_id)
|
||||
self.coreemu.delete_session(self.session.id)
|
||||
|
||||
return SocketServer.BaseRequestHandler.finish(self)
|
||||
|
||||
|
@ -160,9 +159,9 @@ class CoreHandler(SocketServer.BaseRequestHandler):
|
|||
num_sessions = 0
|
||||
|
||||
with self._sessions_lock:
|
||||
for session_id, session in self.coreemu.sessions.iteritems():
|
||||
for _id, session in self.coreemu.sessions.iteritems():
|
||||
num_sessions += 1
|
||||
id_list.append(str(session_id))
|
||||
id_list.append(str(_id))
|
||||
|
||||
name = session.name
|
||||
if not name:
|
||||
|
@ -372,7 +371,7 @@ class CoreHandler(SocketServer.BaseRequestHandler):
|
|||
|
||||
:return: register message data
|
||||
"""
|
||||
logging.info("GUI has connected to session %d at %s", self.session.session_id, time.ctime())
|
||||
logging.info("GUI has connected to session %d at %s", self.session.id, time.ctime())
|
||||
|
||||
tlv_data = ""
|
||||
tlv_data += coreapi.CoreRegisterTlv.pack(RegisterTlvs.EXECUTE_SERVER.value, "core-daemon")
|
||||
|
@ -538,7 +537,7 @@ class CoreHandler(SocketServer.BaseRequestHandler):
|
|||
# TODO: add shutdown handler for session
|
||||
self.session = self.coreemu.create_session(port, master=False)
|
||||
# self.session.shutdown_handlers.append(self.session_shutdown)
|
||||
logging.debug("created new session for client: %s", self.session.session_id)
|
||||
logging.debug("created new session for client: %s", self.session.id)
|
||||
|
||||
# TODO: hack to associate this handler with this sessions broker for broadcasting
|
||||
# TODO: broker needs to be pulled out of session to the server/handler level
|
||||
|
@ -592,7 +591,7 @@ class CoreHandler(SocketServer.BaseRequestHandler):
|
|||
:return:
|
||||
"""
|
||||
exception_data = ExceptionData(
|
||||
session=str(self.session.session_id),
|
||||
session=str(self.session.id),
|
||||
node=node,
|
||||
date=time.ctime(),
|
||||
level=level.value,
|
||||
|
@ -850,7 +849,7 @@ class CoreHandler(SocketServer.BaseRequestHandler):
|
|||
try:
|
||||
session.open_xml(file_name, start=True)
|
||||
except:
|
||||
self.coreemu.delete_session(session.session_id)
|
||||
self.coreemu.delete_session(session.id)
|
||||
raise
|
||||
else:
|
||||
thread = threading.Thread(
|
||||
|
@ -908,7 +907,7 @@ class CoreHandler(SocketServer.BaseRequestHandler):
|
|||
# find the session containing this client and set the session to master
|
||||
for session in self.coreemu.sessions.itervalues():
|
||||
if self in session.broker.session_clients:
|
||||
logging.debug("setting session to master: %s", session.session_id)
|
||||
logging.debug("setting session to master: %s", session.id)
|
||||
session.master = True
|
||||
break
|
||||
|
||||
|
@ -1591,7 +1590,7 @@ class CoreHandler(SocketServer.BaseRequestHandler):
|
|||
logging.warn("session %s not found", session_id)
|
||||
continue
|
||||
|
||||
logging.info("request to modify to session: %s", session.session_id)
|
||||
logging.info("request to modify to session: %s", session.id)
|
||||
if names is not None:
|
||||
session.name = names[index]
|
||||
|
||||
|
@ -1624,7 +1623,7 @@ class CoreHandler(SocketServer.BaseRequestHandler):
|
|||
self.remove_session_handlers()
|
||||
self.session.broker.session_clients.remove(self)
|
||||
if not self.session.broker.session_clients and not self.session.is_active():
|
||||
self.coreemu.delete_session(self.session.session_id)
|
||||
self.coreemu.delete_session(self.session.id)
|
||||
|
||||
# set session to join
|
||||
self.session = session
|
||||
|
@ -1727,7 +1726,7 @@ class CoreHandler(SocketServer.BaseRequestHandler):
|
|||
type=ConfigFlags.UPDATE.value,
|
||||
data_types=data_types,
|
||||
data_values=values,
|
||||
session=str(self.session.session_id),
|
||||
session=str(self.session.id),
|
||||
opaque=opaque
|
||||
)
|
||||
self.session.broadcast_config(config_data)
|
||||
|
|
|
@ -118,8 +118,8 @@ class IdGen(object):
|
|||
|
||||
|
||||
class EmuSession(Session):
|
||||
def __init__(self, session_id, config=None, mkdir=True):
|
||||
super(EmuSession, self).__init__(session_id, config, mkdir)
|
||||
def __init__(self, _id, config=None, mkdir=True):
|
||||
super(EmuSession, self).__init__(_id, config, mkdir)
|
||||
|
||||
# object management
|
||||
self.node_id_gen = IdGen()
|
||||
|
@ -620,7 +620,7 @@ class EmuSession(Session):
|
|||
|
||||
:return: nothing
|
||||
"""
|
||||
logging.info("session(%s) shutting down", self.session_id)
|
||||
logging.info("session(%s) shutting down", self.id)
|
||||
self.set_state(EventTypes.DATACOLLECT_STATE, send_event=True)
|
||||
self.set_state(EventTypes.SHUTDOWN_STATE, send_event=True)
|
||||
super(EmuSession, self).shutdown()
|
||||
|
@ -647,7 +647,7 @@ class EmuSession(Session):
|
|||
:return: True if active, False otherwise
|
||||
"""
|
||||
result = self.state in {EventTypes.RUNTIME_STATE.value, EventTypes.DATACOLLECT_STATE.value}
|
||||
logging.info("session(%s) checking if active: %s", self.session_id, result)
|
||||
logging.info("session(%s) checking if active: %s", self.id, result)
|
||||
return result
|
||||
|
||||
def open_xml(self, file_name, start=False):
|
||||
|
|
|
@ -153,7 +153,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
session.set_state(EventTypes.DEFINITION_STATE)
|
||||
session.location.setrefgeo(47.57917, -122.13232, 2.0)
|
||||
session.location.refscale = 150000.0
|
||||
return core_pb2.CreateSessionResponse(id=session.session_id, state=session.state)
|
||||
return core_pb2.CreateSessionResponse(id=session.id, state=session.state)
|
||||
|
||||
def DeleteSession(self, request, context):
|
||||
logging.debug("delete session: %s", request)
|
||||
|
@ -344,7 +344,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
name=event.name,
|
||||
data=event.data,
|
||||
time=event_time,
|
||||
session=session.session_id
|
||||
session=session.id
|
||||
)
|
||||
yield session_event
|
||||
except Empty:
|
||||
|
@ -881,8 +881,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
try:
|
||||
session.open_xml(temp_path, start=True)
|
||||
return core_pb2.OpenXmlResponse(session=session.session_id, result=True)
|
||||
return core_pb2.OpenXmlResponse(session=session.id, result=True)
|
||||
except IOError:
|
||||
logging.exception("error opening session file")
|
||||
self.coreemu.delete_session(session.session_id)
|
||||
self.coreemu.delete_session(session.id)
|
||||
context.abort(grpc.StatusCode.INVALID_ARGUMENT, "invalid xml file")
|
||||
|
|
|
@ -319,7 +319,7 @@ def expand_corepath(pathname, session=None, node=None):
|
|||
"""
|
||||
if session is not None:
|
||||
pathname = pathname.replace("~", "/home/%s" % session.user)
|
||||
pathname = pathname.replace("%SESSION%", str(session.session_id))
|
||||
pathname = pathname.replace("%SESSION%", str(session.id))
|
||||
pathname = pathname.replace("%SESSION_DIR%", session.session_dir)
|
||||
pathname = pathname.replace("%SESSION_USER%", session.user)
|
||||
|
||||
|
|
|
@ -648,7 +648,7 @@ class OvsGreTapBridge(OvsNet):
|
|||
OvsNet.__init__(self, session=session, objid=objid, name=name, policy=policy, start=False)
|
||||
self.grekey = key
|
||||
if self.grekey is None:
|
||||
self.grekey = self.session.session_id ^ self.objid
|
||||
self.grekey = self.session.id ^ self.objid
|
||||
|
||||
self.localnum = None
|
||||
self.remotenum = None
|
||||
|
|
|
@ -589,7 +589,7 @@ class GreTapBridge(LxBrNet):
|
|||
LxBrNet.__init__(self, session=session, objid=objid, name=name, policy=policy, start=False)
|
||||
self.grekey = key
|
||||
if self.grekey is None:
|
||||
self.grekey = self.session.session_id ^ self.objid
|
||||
self.grekey = self.session.id ^ self.objid
|
||||
self.localnum = None
|
||||
self.remotenum = None
|
||||
self.remoteip = remoteip
|
||||
|
|
|
@ -46,18 +46,18 @@ class Session(object):
|
|||
CORE session manager.
|
||||
"""
|
||||
|
||||
def __init__(self, session_id, config=None, mkdir=True):
|
||||
def __init__(self, _id, config=None, mkdir=True):
|
||||
"""
|
||||
Create a Session instance.
|
||||
|
||||
:param int session_id: session id
|
||||
:param int _id: session id
|
||||
:param dict config: session configuration
|
||||
:param bool mkdir: flag to determine if a directory should be made
|
||||
"""
|
||||
self.session_id = session_id
|
||||
self.id = _id
|
||||
|
||||
# define and create session directory when desired
|
||||
self.session_dir = os.path.join(tempfile.gettempdir(), "pycore.%s" % self.session_id)
|
||||
self.session_dir = os.path.join(tempfile.gettempdir(), "pycore.%s" % self.id)
|
||||
if mkdir:
|
||||
os.mkdir(self.session_dir)
|
||||
|
||||
|
@ -207,12 +207,12 @@ class Session(object):
|
|||
state_name = state.name
|
||||
|
||||
if self.state == state_value:
|
||||
logging.info("session(%s) is already in state: %s, skipping change", self.session_id, state_name)
|
||||
logging.info("session(%s) is already in state: %s, skipping change", self.id, state_name)
|
||||
return
|
||||
|
||||
self.state = state_value
|
||||
self._state_time = time.time()
|
||||
logging.info("changing session(%s) to state %s", self.session_id, state_name)
|
||||
logging.info("changing session(%s) to state %s", self.id, state_name)
|
||||
|
||||
self.write_state(state_value)
|
||||
self.run_hooks(state_value)
|
||||
|
@ -397,7 +397,7 @@ class Session(object):
|
|||
:return:
|
||||
"""
|
||||
env = os.environ.copy()
|
||||
env["SESSION"] = "%s" % self.session_id
|
||||
env["SESSION"] = "%s" % self.id
|
||||
env["SESSION_SHORT"] = "%s" % self.short_session_id()
|
||||
env["SESSION_DIR"] = "%s" % self.session_dir
|
||||
env["SESSION_NAME"] = "%s" % self.name
|
||||
|
@ -562,7 +562,7 @@ class Session(object):
|
|||
"""
|
||||
Log information about the session in its current state.
|
||||
"""
|
||||
logging.info("session id=%s name=%s state=%s", self.session_id, self.name, self.state)
|
||||
logging.info("session id=%s name=%s state=%s", self.id, self.name, self.state)
|
||||
logging.info("file=%s thumbnail=%s node_count=%s/%s",
|
||||
self.file_name, self.thumbnail, self.get_node_count(), len(self.objects))
|
||||
|
||||
|
@ -579,7 +579,7 @@ class Session(object):
|
|||
|
||||
exception_data = ExceptionData(
|
||||
node=object_id,
|
||||
session=str(self.session_id),
|
||||
session=str(self.id),
|
||||
level=level,
|
||||
source=source,
|
||||
date=time.ctime(),
|
||||
|
@ -649,8 +649,8 @@ class Session(object):
|
|||
# this is called from instantiate() after receiving an event message
|
||||
# for the instantiation state, and from the broker when distributed
|
||||
# nodes have been started
|
||||
logging.info("session(%s) checking if not in runtime state, current state: %s", self.session_id,
|
||||
coreapi.state_name(self.state))
|
||||
logging.info("session(%s) checking if not in runtime state, current state: %s", self.id,
|
||||
coreapi.state_name(self.state))
|
||||
if self.state == EventTypes.RUNTIME_STATE.value:
|
||||
logging.info("valid runtime state found, returning")
|
||||
return
|
||||
|
@ -696,7 +696,7 @@ class Session(object):
|
|||
and links remain.
|
||||
"""
|
||||
node_count = self.get_node_count()
|
||||
logging.info("session(%s) checking shutdown: %s nodes remaining", self.session_id, node_count)
|
||||
logging.info("session(%s) checking shutdown: %s nodes remaining", self.id, node_count)
|
||||
|
||||
shutdown = False
|
||||
if node_count == 0:
|
||||
|
@ -710,7 +710,7 @@ class Session(object):
|
|||
Return a shorter version of the session ID, appropriate for
|
||||
interface names, where length may be limited.
|
||||
"""
|
||||
ssid = (self.session_id >> 8) ^ (self.session_id & ((1 << 8) - 1))
|
||||
ssid = (self.id >> 8) ^ (self.id & ((1 << 8) - 1))
|
||||
return "%x" % ssid
|
||||
|
||||
def boot_nodes(self):
|
||||
|
@ -963,7 +963,7 @@ class Session(object):
|
|||
logging.exception("error retrieving control net object")
|
||||
return
|
||||
|
||||
header = "CORE session %s host entries" % self.session_id
|
||||
header = "CORE session %s host entries" % self.id
|
||||
if remove:
|
||||
logging.info("Removing /etc/hosts file entries.")
|
||||
utils.file_demunge("/etc/hosts", header)
|
||||
|
|
|
@ -194,7 +194,7 @@ class CoreServerTest(object):
|
|||
|
||||
# set services for host nodes
|
||||
message = CoreConfMessage.create(0, [
|
||||
(ConfigTlvs.SESSION, str(self.session.session_id)),
|
||||
(ConfigTlvs.SESSION, str(self.session.id)),
|
||||
(ConfigTlvs.OBJECT, "services"),
|
||||
(ConfigTlvs.TYPE, 0),
|
||||
(ConfigTlvs.DATA_TYPES, (10, 10, 10)),
|
||||
|
|
|
@ -32,7 +32,7 @@ class TestGrpc:
|
|||
assert session.state == response.state
|
||||
if session_id is not None:
|
||||
assert response.id == session_id
|
||||
assert session.session_id == session_id
|
||||
assert session.id == session_id
|
||||
|
||||
@pytest.mark.parametrize("session_id, expected", [
|
||||
(None, True),
|
||||
|
@ -43,7 +43,7 @@ class TestGrpc:
|
|||
client = CoreGrpcClient()
|
||||
session = grpc_server.coreemu.create_session()
|
||||
if session_id is None:
|
||||
session_id = session.session_id
|
||||
session_id = session.id
|
||||
|
||||
# then
|
||||
with client.context_connect():
|
||||
|
@ -62,7 +62,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_session(session.session_id)
|
||||
response = client.get_session(session.id)
|
||||
|
||||
# then
|
||||
assert response.session.state == core_pb2.STATE_DEFINITION
|
||||
|
@ -81,7 +81,7 @@ class TestGrpc:
|
|||
# then
|
||||
found_session = None
|
||||
for current_session in response.sessions:
|
||||
if current_session.id == session.session_id:
|
||||
if current_session.id == session.id:
|
||||
found_session = current_session
|
||||
break
|
||||
assert len(response.sessions) == 1
|
||||
|
@ -94,7 +94,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_session_options(session.session_id)
|
||||
response = client.get_session_options(session.id)
|
||||
|
||||
# then
|
||||
assert len(response.groups) > 0
|
||||
|
@ -106,7 +106,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_session_location(session.session_id)
|
||||
response = client.get_session_location(session.id)
|
||||
|
||||
# then
|
||||
assert response.scale == 1.0
|
||||
|
@ -128,7 +128,7 @@ class TestGrpc:
|
|||
lat_lon_alt = (1, 1, 1)
|
||||
with client.context_connect():
|
||||
response = client.set_session_location(
|
||||
session.session_id,
|
||||
session.id,
|
||||
x=xyz[0], y=xyz[1], z=xyz[2],
|
||||
lat=lat_lon_alt[0], lon=lat_lon_alt[1], alt=lat_lon_alt[2],
|
||||
scale=scale
|
||||
|
@ -149,7 +149,7 @@ class TestGrpc:
|
|||
option = "enablerj45"
|
||||
value = "1"
|
||||
with client.context_connect():
|
||||
response = client.set_session_options(session.session_id, {option: value})
|
||||
response = client.set_session_options(session.id, {option: value})
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -164,7 +164,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_session_state(session.session_id, core_pb2.STATE_DEFINITION)
|
||||
response = client.set_session_state(session.id, core_pb2.STATE_DEFINITION)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -178,7 +178,7 @@ class TestGrpc:
|
|||
# then
|
||||
with client.context_connect():
|
||||
node = core_pb2.Node()
|
||||
response = client.add_node(session.session_id, node)
|
||||
response = client.add_node(session.id, node)
|
||||
|
||||
# then
|
||||
assert response.id is not None
|
||||
|
@ -192,7 +192,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_node(session.session_id, node.objid)
|
||||
response = client.get_node(session.id, node.objid)
|
||||
|
||||
# then
|
||||
assert response.node.id == node.objid
|
||||
|
@ -211,7 +211,7 @@ class TestGrpc:
|
|||
x, y = 10, 10
|
||||
with client.context_connect():
|
||||
position = core_pb2.Position(x=x, y=y)
|
||||
response = client.edit_node(session.session_id, node_id, position)
|
||||
response = client.edit_node(session.id, node_id, position)
|
||||
|
||||
# then
|
||||
assert response.result is expected
|
||||
|
@ -231,7 +231,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.delete_node(session.session_id, node_id)
|
||||
response = client.delete_node(session.id, node_id)
|
||||
|
||||
# then
|
||||
assert response.result is expected
|
||||
|
@ -249,7 +249,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_hooks(session.session_id)
|
||||
response = client.get_hooks(session.id)
|
||||
|
||||
# then
|
||||
assert len(response.hooks) == 1
|
||||
|
@ -267,7 +267,7 @@ class TestGrpc:
|
|||
file_name = "test"
|
||||
file_data = "echo hello"
|
||||
with client.context_connect():
|
||||
response = client.add_hook(session.session_id, core_pb2.STATE_RUNTIME, file_name, file_data)
|
||||
response = client.add_hook(session.id, core_pb2.STATE_RUNTIME, file_name, file_data)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -280,7 +280,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
client.save_xml(session.session_id, str(tmp))
|
||||
client.save_xml(session.id, str(tmp))
|
||||
|
||||
# then
|
||||
assert tmp.exists()
|
||||
|
@ -311,7 +311,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_node_links(session.session_id, switch.objid)
|
||||
response = client.get_node_links(session.id, switch.objid)
|
||||
|
||||
# then
|
||||
assert len(response.links) == 1
|
||||
|
@ -328,7 +328,7 @@ class TestGrpc:
|
|||
# then
|
||||
with pytest.raises(grpc.RpcError):
|
||||
with client.context_connect():
|
||||
client.get_node_links(session.session_id, 3)
|
||||
client.get_node_links(session.id, 3)
|
||||
|
||||
def test_add_link(self, grpc_server, interface_helper):
|
||||
# given
|
||||
|
@ -341,7 +341,7 @@ class TestGrpc:
|
|||
# then
|
||||
interface = interface_helper.create_interface(node.objid, 0)
|
||||
with client.context_connect():
|
||||
response = client.add_link(session.session_id, node.objid, switch.objid, interface)
|
||||
response = client.add_link(session.id, node.objid, switch.objid, interface)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -357,7 +357,7 @@ class TestGrpc:
|
|||
interface = interface_helper.create_interface(node.objid, 0)
|
||||
with pytest.raises(grpc.RpcError):
|
||||
with client.context_connect():
|
||||
client.add_link(session.session_id, 1, 3, interface)
|
||||
client.add_link(session.id, 1, 3, interface)
|
||||
|
||||
def test_edit_link(self, grpc_server, ip_prefixes):
|
||||
# given
|
||||
|
@ -373,7 +373,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.edit_link(session.session_id, node.objid, switch.objid, options)
|
||||
response = client.edit_link(session.id, node.objid, switch.objid, options)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -400,7 +400,7 @@ class TestGrpc:
|
|||
# then
|
||||
with client.context_connect():
|
||||
response = client.delete_link(
|
||||
session.session_id, node_one.objid, node_two.objid, interface_one.id, interface_two.id)
|
||||
session.id, node_one.objid, node_two.objid, interface_one.id, interface_two.id)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -414,7 +414,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_wlan_config(session.session_id, wlan.objid)
|
||||
response = client.get_wlan_config(session.id, wlan.objid)
|
||||
|
||||
# then
|
||||
assert len(response.groups) > 0
|
||||
|
@ -429,7 +429,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_wlan_config(session.session_id, wlan.objid, {range_key: range_value})
|
||||
response = client.set_wlan_config(session.id, wlan.objid, {range_key: range_value})
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -443,7 +443,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_emane_config(session.session_id)
|
||||
response = client.get_emane_config(session.id)
|
||||
|
||||
# then
|
||||
assert len(response.groups) > 0
|
||||
|
@ -457,7 +457,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_emane_config(session.session_id, {config_key: config_value})
|
||||
response = client.set_emane_config(session.id, {config_key: config_value})
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -479,7 +479,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_emane_model_configs(session.session_id)
|
||||
response = client.get_emane_model_configs(session.id)
|
||||
|
||||
# then
|
||||
assert len(response.configs) == 1
|
||||
|
@ -499,7 +499,7 @@ class TestGrpc:
|
|||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_emane_model_config(
|
||||
session.session_id, emane_network.objid, EmaneIeee80211abgModel.name, {config_key: config_value})
|
||||
session.id, emane_network.objid, EmaneIeee80211abgModel.name, {config_key: config_value})
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -518,7 +518,7 @@ class TestGrpc:
|
|||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_emane_model_config(
|
||||
session.session_id, emane_network.objid, EmaneIeee80211abgModel.name)
|
||||
session.id, emane_network.objid, EmaneIeee80211abgModel.name)
|
||||
|
||||
# then
|
||||
assert len(response.groups) > 0
|
||||
|
@ -530,7 +530,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_emane_models(session.session_id)
|
||||
response = client.get_emane_models(session.id)
|
||||
|
||||
# then
|
||||
assert len(response.models) > 0
|
||||
|
@ -544,7 +544,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_mobility_configs(session.session_id)
|
||||
response = client.get_mobility_configs(session.id)
|
||||
|
||||
# then
|
||||
assert len(response.configs) > 0
|
||||
|
@ -559,7 +559,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_mobility_config(session.session_id, wlan.objid)
|
||||
response = client.get_mobility_config(session.id, wlan.objid)
|
||||
|
||||
# then
|
||||
assert len(response.groups) > 0
|
||||
|
@ -574,7 +574,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_mobility_config(session.session_id, wlan.objid, {config_key: config_value})
|
||||
response = client.set_mobility_config(session.id, wlan.objid, {config_key: config_value})
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -591,7 +591,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.mobility_action(session.session_id, wlan.objid, core_pb2.MOBILITY_STOP)
|
||||
response = client.mobility_action(session.id, wlan.objid, core_pb2.MOBILITY_STOP)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -614,7 +614,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_service_defaults(session.session_id)
|
||||
response = client.get_service_defaults(session.id)
|
||||
|
||||
# then
|
||||
assert len(response.defaults) > 0
|
||||
|
@ -628,7 +628,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_service_defaults(session.session_id, {node_type: services})
|
||||
response = client.set_service_defaults(session.id, {node_type: services})
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -642,7 +642,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_node_service(session.session_id, node.objid, "IPForward")
|
||||
response = client.get_node_service(session.id, node.objid, "IPForward")
|
||||
|
||||
# then
|
||||
assert len(response.service.configs) > 0
|
||||
|
@ -655,7 +655,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_node_service_file(session.session_id, node.objid, "IPForward", "ipforward.sh")
|
||||
response = client.get_node_service_file(session.id, node.objid, "IPForward", "ipforward.sh")
|
||||
|
||||
# then
|
||||
assert response.data is not None
|
||||
|
@ -670,7 +670,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_node_service(session.session_id, node.objid, service_name, (), validate, ())
|
||||
response = client.set_node_service(session.id, node.objid, service_name, (), validate, ())
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -688,7 +688,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_node_service_file(session.session_id, node.objid, service_name, file_name, file_data)
|
||||
response = client.set_node_service_file(session.id, node.objid, service_name, file_name, file_data)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -704,7 +704,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.service_action(session.session_id, node.objid, service_name, core_pb2.SERVICE_STOP)
|
||||
response = client.service_action(session.id, node.objid, service_name, core_pb2.SERVICE_STOP)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -722,7 +722,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
client.node_events(session.session_id, handle_event)
|
||||
client.node_events(session.id, handle_event)
|
||||
time.sleep(0.1)
|
||||
session.broadcast_node(node_data)
|
||||
|
||||
|
@ -745,7 +745,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
client.link_events(session.session_id, handle_event)
|
||||
client.link_events(session.id, handle_event)
|
||||
time.sleep(0.1)
|
||||
session.broadcast_link(link_data)
|
||||
|
||||
|
@ -763,7 +763,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
client.session_events(session.session_id, handle_event)
|
||||
client.session_events(session.id, handle_event)
|
||||
time.sleep(0.1)
|
||||
event = EventData(event_type=EventTypes.RUNTIME_STATE.value, time="%s" % time.time())
|
||||
session.broadcast_event(event)
|
||||
|
@ -782,7 +782,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
client.config_events(session.session_id, handle_event)
|
||||
client.config_events(session.id, handle_event)
|
||||
time.sleep(0.1)
|
||||
session_config = session.options.get_configs()
|
||||
config_data = ConfigShim.config_data(0, None, ConfigFlags.UPDATE.value, session.options, session_config)
|
||||
|
@ -802,7 +802,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
client.exception_events(session.session_id, handle_event)
|
||||
client.exception_events(session.id, handle_event)
|
||||
time.sleep(0.1)
|
||||
session.exception(ExceptionLevels.FATAL, "test", None, "exception message")
|
||||
|
||||
|
@ -821,7 +821,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
client.file_events(session.session_id, handle_event)
|
||||
client.file_events(session.id, handle_event)
|
||||
time.sleep(0.1)
|
||||
file_data = session.services.get_service_file(node, "IPForward", "ipforward.sh")
|
||||
session.broadcast_file(file_data)
|
||||
|
|
|
@ -360,11 +360,11 @@ class Ns3Session(Session):
|
|||
A Session that starts an ns-3 simulation thread.
|
||||
"""
|
||||
|
||||
def __init__(self, session_id, persistent=False, duration=600):
|
||||
def __init__(self, _id, persistent=False, duration=600):
|
||||
self.duration = duration
|
||||
self.nodes = ns.network.NodeContainer()
|
||||
self.mobhelper = ns.mobility.MobilityHelper()
|
||||
Session.__init__(self, session_id)
|
||||
Session.__init__(self, _id)
|
||||
|
||||
def run(self, vis=False):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue