daemon: refactored node.nodedir to node.directory
This commit is contained in:
parent
a2148c6923
commit
be0e0175a2
8 changed files with 27 additions and 27 deletions
|
@ -271,7 +271,7 @@ def get_node_proto(session: Session, node: NodeBase) -> core_pb2.Node:
|
|||
node_dir = None
|
||||
config_services = []
|
||||
if isinstance(node, CoreNodeBase):
|
||||
node_dir = str(node.nodedir)
|
||||
node_dir = str(node.directory)
|
||||
config_services = [x for x in node.config_services]
|
||||
channel = None
|
||||
if isinstance(node, CoreNode):
|
||||
|
|
|
@ -590,8 +590,8 @@ class EmaneManager(ModelManager):
|
|||
if eventservicenetidx >= 0 and eventgroup != otagroup:
|
||||
node.node_net_client.create_route(eventgroup, eventdev)
|
||||
# start emane
|
||||
log_file = node.nodedir / f"{node.name}-emane.log"
|
||||
platform_xml = node.nodedir / f"{node.name}-platform.xml"
|
||||
log_file = node.directory / f"{node.name}-emane.log"
|
||||
platform_xml = node.directory / f"{node.name}-platform.xml"
|
||||
args = f"{emanecmd} -f {log_file} {platform_xml}"
|
||||
node.cmd(args)
|
||||
logging.info("node(%s) emane daemon running: %s", node.name, args)
|
||||
|
|
|
@ -223,7 +223,7 @@ class CoreNodeBase(NodeBase):
|
|||
"""
|
||||
super().__init__(session, _id, name, server)
|
||||
self.config_services: Dict[str, "ConfigService"] = {}
|
||||
self.nodedir: Optional[Path] = None
|
||||
self.directory: Optional[Path] = None
|
||||
self.tmpnodedir: bool = False
|
||||
|
||||
@abc.abstractmethod
|
||||
|
@ -314,10 +314,10 @@ class CoreNodeBase(NodeBase):
|
|||
"""
|
||||
if is_dir:
|
||||
directory = str(path).strip("/").replace("/", ".")
|
||||
return self.nodedir / directory
|
||||
return self.directory / directory
|
||||
else:
|
||||
directory = str(path.parent).strip("/").replace("/", ".")
|
||||
return self.nodedir / directory / path.name
|
||||
return self.directory / directory / path.name
|
||||
|
||||
def add_config_service(self, service_class: "ConfigServiceType") -> None:
|
||||
"""
|
||||
|
@ -362,9 +362,9 @@ class CoreNodeBase(NodeBase):
|
|||
|
||||
:return: nothing
|
||||
"""
|
||||
if self.nodedir is None:
|
||||
self.nodedir = self.session.directory / f"{self.name}.conf"
|
||||
self.host_cmd(f"mkdir -p {self.nodedir}")
|
||||
if self.directory is None:
|
||||
self.directory = self.session.directory / f"{self.name}.conf"
|
||||
self.host_cmd(f"mkdir -p {self.directory}")
|
||||
self.tmpnodedir = True
|
||||
else:
|
||||
self.tmpnodedir = False
|
||||
|
@ -379,7 +379,7 @@ class CoreNodeBase(NodeBase):
|
|||
if preserve:
|
||||
return
|
||||
if self.tmpnodedir:
|
||||
self.host_cmd(f"rm -rf {self.nodedir}")
|
||||
self.host_cmd(f"rm -rf {self.directory}")
|
||||
|
||||
def add_iface(self, iface: CoreInterface, iface_id: int) -> None:
|
||||
"""
|
||||
|
@ -475,7 +475,7 @@ class CoreNode(CoreNodeBase):
|
|||
session: "Session",
|
||||
_id: int = None,
|
||||
name: str = None,
|
||||
nodedir: Path = None,
|
||||
directory: Path = None,
|
||||
server: "DistributedServer" = None,
|
||||
) -> None:
|
||||
"""
|
||||
|
@ -484,12 +484,12 @@ class CoreNode(CoreNodeBase):
|
|||
:param session: core session instance
|
||||
:param _id: object id
|
||||
:param name: object name
|
||||
:param nodedir: node directory
|
||||
:param directory: node directory
|
||||
:param server: remote server node
|
||||
will run on, default is None for localhost
|
||||
"""
|
||||
super().__init__(session, _id, name, server)
|
||||
self.nodedir: Optional[Path] = nodedir
|
||||
self.directory: Optional[Path] = directory
|
||||
self.ctrlchnlname: Path = self.session.directory / self.name
|
||||
self.client: Optional[VnodeClient] = None
|
||||
self.pid: Optional[int] = None
|
||||
|
@ -539,8 +539,8 @@ class CoreNode(CoreNodeBase):
|
|||
f"{VNODED} -v -c {self.ctrlchnlname} -l {self.ctrlchnlname}.log "
|
||||
f"-p {self.ctrlchnlname}.pid"
|
||||
)
|
||||
if self.nodedir:
|
||||
vnoded += f" -C {self.nodedir}"
|
||||
if self.directory:
|
||||
vnoded += f" -C {self.directory}"
|
||||
env = self.session.get_environment(state=False)
|
||||
env["NODE_NUMBER"] = str(self.id)
|
||||
env["NODE_NAME"] = str(self.name)
|
||||
|
|
|
@ -76,7 +76,7 @@ class DockerNode(CoreNode):
|
|||
session: "Session",
|
||||
_id: int = None,
|
||||
name: str = None,
|
||||
nodedir: str = None,
|
||||
directory: str = None,
|
||||
server: DistributedServer = None,
|
||||
image: str = None,
|
||||
) -> None:
|
||||
|
@ -86,7 +86,7 @@ class DockerNode(CoreNode):
|
|||
:param session: core session instance
|
||||
:param _id: object id
|
||||
:param name: object name
|
||||
:param nodedir: node directory
|
||||
:param directory: node directory
|
||||
:param server: remote server node
|
||||
will run on, default is None for localhost
|
||||
:param image: image to start container with
|
||||
|
@ -94,7 +94,7 @@ class DockerNode(CoreNode):
|
|||
if image is None:
|
||||
image = "ubuntu"
|
||||
self.image: str = image
|
||||
super().__init__(session, _id, name, nodedir, server)
|
||||
super().__init__(session, _id, name, directory, server)
|
||||
|
||||
def create_node_net_client(self, use_ovs: bool) -> LinuxNetClient:
|
||||
"""
|
||||
|
|
|
@ -72,7 +72,7 @@ class LxcNode(CoreNode):
|
|||
session: "Session",
|
||||
_id: int = None,
|
||||
name: str = None,
|
||||
nodedir: str = None,
|
||||
directory: str = None,
|
||||
server: DistributedServer = None,
|
||||
image: str = None,
|
||||
) -> None:
|
||||
|
@ -82,7 +82,7 @@ class LxcNode(CoreNode):
|
|||
:param session: core session instance
|
||||
:param _id: object id
|
||||
:param name: object name
|
||||
:param nodedir: node directory
|
||||
:param directory: node directory
|
||||
:param server: remote server node
|
||||
will run on, default is None for localhost
|
||||
:param image: image to start container with
|
||||
|
@ -90,7 +90,7 @@ class LxcNode(CoreNode):
|
|||
if image is None:
|
||||
image = "ubuntu"
|
||||
self.image: str = image
|
||||
super().__init__(session, _id, name, nodedir, server)
|
||||
super().__init__(session, _id, name, directory, server)
|
||||
|
||||
def alive(self) -> bool:
|
||||
"""
|
||||
|
|
|
@ -26,13 +26,13 @@ class PhysicalNode(CoreNodeBase):
|
|||
session: "Session",
|
||||
_id: int = None,
|
||||
name: str = None,
|
||||
nodedir: Path = None,
|
||||
directory: Path = None,
|
||||
server: DistributedServer = None,
|
||||
) -> None:
|
||||
super().__init__(session, _id, name, server)
|
||||
if not self.server:
|
||||
raise CoreError("physical nodes must be assigned to a remote server")
|
||||
self.nodedir: Optional[Path] = nodedir
|
||||
self.directory: Optional[Path] = directory
|
||||
self.lock: threading.RLock = threading.RLock()
|
||||
self._mounts: List[Tuple[Path, Path]] = []
|
||||
|
||||
|
@ -193,13 +193,13 @@ class PhysicalNode(CoreNodeBase):
|
|||
def mount(self, src_path: Path, target_path: Path) -> None:
|
||||
logging.debug("node(%s) mounting: %s at %s", self.name, src_path, target_path)
|
||||
self.cmd(f"mkdir -p {target_path}")
|
||||
self.host_cmd(f"{MOUNT} --bind {src_path} {target_path}", cwd=self.nodedir)
|
||||
self.host_cmd(f"{MOUNT} --bind {src_path} {target_path}", cwd=self.directory)
|
||||
self._mounts.append((src_path, target_path))
|
||||
|
||||
def umount(self, target_path: Path) -> None:
|
||||
logging.info("unmounting '%s'", target_path)
|
||||
try:
|
||||
self.host_cmd(f"{UMOUNT} -l {target_path}", cwd=self.nodedir)
|
||||
self.host_cmd(f"{UMOUNT} -l {target_path}", cwd=self.directory)
|
||||
except CoreCommandError:
|
||||
logging.exception("unmounting failed for %s", target_path)
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ def create_node_file(
|
|||
:return:
|
||||
"""
|
||||
if isinstance(node, CoreNode):
|
||||
file_path = node.nodedir / file_name
|
||||
file_path = node.directory / file_name
|
||||
else:
|
||||
file_path = node.session.directory / file_name
|
||||
create_file(xml_element, doc_name, file_path, node.server)
|
||||
|
|
|
@ -443,7 +443,7 @@ class TestGui:
|
|||
if not request.config.getoption("mock"):
|
||||
directory = str(file_path.parent)
|
||||
created_directory = directory[1:].replace("/", ".")
|
||||
create_path = node.nodedir / created_directory / file_path.name
|
||||
create_path = node.directory / created_directory / file_path.name
|
||||
assert create_path.exists()
|
||||
|
||||
def test_exec_node_tty(self, coretlv: CoreHandler):
|
||||
|
|
Loading…
Reference in a new issue