Commit be9d4f39 authored by lavado's avatar lavado
Browse files

Merge branch 'hackfest9' into 'master'

Fix enodeb charm: run daemon

See merge request !13
parents ed1e5e44 aec484fa
Loading
Loading
Loading
Loading

charm-helpers @ 8a90d2cc

Original line number Diff line number Diff line
Subproject commit 8a90d2cc3aa0ba170756bdc87b4499903ac86fe5

charms.osm @ 623ba0d8

Original line number Diff line number Diff line
Subproject commit 623ba0d8e6d3ff7a01067a0e09f15fc98ef6bec5

operator @ a3918e1d

Original line number Diff line number Diff line
Subproject commit a3918e1db40edac88a5250c46d7ef3156e8853d3
+103 KiB

File added.

No diff preview for this file type.

+7 −2
Original line number Diff line number Diff line
@@ -28,7 +28,10 @@ import subprocess
import logging
import asyncio
import random

logger = logging.getLogger(__name__)


class EnodebCharm(CharmBase):
    state = StoredState()
    def __init__(self, *args):
@@ -93,7 +96,7 @@ class EnodebCharm(CharmBase):
            process = self._run_daemon(command, log_file)
            logger.debug("Register action: executed")
            event.set_results(
                {"status": "ok", "pid": process.pid, "log_file": log_file}
                {"status": "ok", "pid": process.pid, "log-file": log_file}
            )
        except subprocess.CalledProcessError as e:
            event.fail("Command error: {}".format(e.output))
@@ -114,9 +117,11 @@ class EnodebCharm(CharmBase):
            event.fail("Command error: {}".format(e.output))
        except Exception as e:
            event.fail(e)

    def _run_daemon(self, cmd, stdout_file):
        with open(stdout_file, "wb") as f:
            return subprocess.Popen(cmd, shell=True, stdout=f)

    def on_attach_ue_action(self, event):
        """Attach User Emulator to EnodeB."""
        try:
@@ -142,7 +147,7 @@ class EnodebCharm(CharmBase):
            process = self._run_daemon(command, log_file)
            logger.debug("Attach UE action: executed")
            event.set_results(
                {"status": "ok", "pid": process.pid, "log_file": log_file}
                {"status": "ok", "pid": process.pid, "log-file": log_file}
            )
        except subprocess.CalledProcessError as ex:
            event.fail(ex)
Loading