Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions .github/workflows/anms-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,8 @@ on:
- anms-core/**

jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip3 install deps/dtnma-ace
pip3 install deps/dtnma-camp
- name: Install
working-directory: anms-core
run: pip3 install -e '.[test]'
- name: Run test
working-directory: anms-core
run: PYTHONPATH=src python3 -m pytest --junit-xml=testresults.xml --cov=anms test

flake8:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -39,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.9"
- name: Install dependencies
run: |
pip3 install deps/dtnma-ace
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/aricodec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.9"
- name: Install dependencies
run: |
pip3 install deps/dtnma-ace
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ jobs:
sudo mkdir /run/anms
- name: Start
run: |
podman compose ${ANMS_COMPOSE_OPTS} up -d --force-recreate
podman compose ${TESTENV_COMPOSE_OPTS} up -d --force-recreate
sleep 5
podman compose ${TESTENV_COMPOSE_OPTS} up -d --force-recreate --wait
podman compose ${ANMS_COMPOSE_OPTS} up -d --force-recreate --wait
- name: Status
run: |
for BADSTATUS in stopped restarting; do
Expand Down Expand Up @@ -99,7 +98,9 @@ jobs:
echo "GITHUB_WORKSPACE=${{ github.workspace }}"
ls -al ${{ github.workspace }}
- name: Build Main
run: docker compose ${ANMS_COMPOSE_OPTS} build
run: |
docker compose ${ANMS_COMPOSE_OPTS} build builder-base builder-init builder-acelib
docker compose ${ANMS_COMPOSE_OPTS} build
- name: Build Agents
run: docker compose ${TESTENV_COMPOSE_OPTS} build
- name: Build Volume
Expand All @@ -108,9 +109,8 @@ jobs:
sudo mkdir /run/anms
- name: Start
run: |
docker compose ${ANMS_COMPOSE_OPTS} up -d --force-recreate
docker compose ${TESTENV_COMPOSE_OPTS} up -d --force-recreate
sleep 5
docker compose ${TESTENV_COMPOSE_OPTS} up -d --force-recreate --wait
docker compose ${ANMS_COMPOSE_OPTS} up -d --force-recreate --wait
- name: Status
run: |
for BADSTATUS in stopped restarting; do
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/transcoder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
flake8:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -17,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.9"
- name: Install flake8
working-directory: transcoder
run: pip3 install flake8
Expand Down
2 changes: 1 addition & 1 deletion anms-core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ COPY --chmod=755 docker-entrypoint.sh /usr/local/bin/
USER ${APP_USER}
CMD ["/usr/local/bin/docker-entrypoint.sh"]

HEALTHCHECK --interval=60s --timeout=60s --retries=20 \
HEALTHCHECK --start-period=10s --interval=60s --timeout=10s --retries=20 \
CMD ["curl", "-sq", "-o/dev/null", "http://localhost:5555/hello"]
57 changes: 34 additions & 23 deletions anms-core/anms/routes/ARIs/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,26 @@ async def report_ac(agent_id: str, correlator_nonce: int):
agent_id = agent_id.strip()
final_res = []
ari = None
dec = ace.ari_cbor.Decoder()
buf = io.StringIO()
# Load in adms
# get command that made the report as first entry
stmt = select(ExecutionSet).where(and_(ExecutionSet.agent_id == agent_id, ExecutionSet.correlator_nonce == correlator_nonce) )
async with get_async_session() as session:
result: Result = await session.scalars(stmt)
result = result.one_or_none()
exec_set_entry=["time"]

# there should only be one execution per agent per correlator_nonce
Comment thread
d-linko marked this conversation as resolved.
# in the event that two occur pull the latest one
result = result.all()
exec_set_dir = {}

if result:
result = result[-1]
exec_set = result.entries.hex()
# use ACE to handle report set decoding
in_text = '0x'+exec_set
try:
in_bytes = ace.cborutil.from_hexstr(in_text)
dec = ace.ari_cbor.Decoder()
ari = dec.decode(io.BytesIO(in_bytes))

except Exception as err:
Expand All @@ -125,26 +131,28 @@ async def report_ac(agent_id: str, correlator_nonce: int):
if type(ari.value) == ace.ari.ExecutionSet:
try:
enc = ace.ari_text.Encoder()
buf = io.StringIO()
# run through targets and their parameters to get all things parts translated
for targ in ari.value.targets:
if targ.params:
for param in targ.params:
enc.encode(param, buf)
buf = io.StringIO()
exec_set_entry=["time"]
enc.encode(targ, buf)
out_text_targ = buf.getvalue()
if targ is ace.LiteralARI and targ.type_id is ace.StructType.AC:
for part in targ.value:
buf = io.StringIO()
enc.encode(part, buf)
out_text = buf.getvalue()
ari_val = await transcoder.transcoder_put_await_str(out_text)
exec_set_entry.append(ari_val['data'])
exec_set_entry.append(out_text)
else:
enc.encode(targ, buf)
out_text = buf.getvalue()
ari_val = await transcoder.transcoder_put_await_str(out_text)
exec_set_entry.append(ari_val['data'])

exec_set_entry.append(out_text_targ)

exec_set_dir[out_text_targ] = [exec_set_entry]

except Exception as err:
logger.info(err)


final_res.append(exec_set_entry)
# final_res.append(exec_set_entry)
ari = None
stmt = select(Report).where(and_(Report.agent_id == agent_id, Report.correlator_nonce == correlator_nonce) )
async with get_async_session() as session:
Expand All @@ -157,7 +165,6 @@ async def report_ac(agent_id: str, correlator_nonce: int):
in_text = '0x'+rpt_set
try:
in_bytes = ace.cborutil.from_hexstr(in_text)
dec = ace.ari_cbor.Decoder()
ari = dec.decode(io.BytesIO(in_bytes))

except Exception as err:
Expand All @@ -173,13 +180,17 @@ async def report_ac(agent_id: str, correlator_nonce: int):
for item in rpt.items:
buf = io.StringIO()
enc.encode(item, buf)
out_text = buf.getvalue()
ari_val = await transcoder.transcoder_put_await_str(out_text)
addition.append(ari_val['data'])
out_text = buf.getvalue()
addition.append(out_text)
buf = io.StringIO()
enc.encode(rpt.source, buf)
out_text = buf.getvalue()

exec_set_dir[out_text].append(addition)
except Exception as err:
logger.error(err)

if addition not in final_res:
final_res.append(addition)
return final_res


return list(exec_set_dir.values())

2 changes: 1 addition & 1 deletion anms-core/anms/routes/transcoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def transcoder_put_cbor_await(cbor: str):

while True:
with get_session() as session:
curr_uri = TranscoderLog.query.filter_by(TranscoderLog.transcoder_log_id==transcoder_log_id).first()
curr_uri = TranscoderLog.query.filter(TranscoderLog.transcoder_log_id==transcoder_log_id).first()
if curr_uri.parsed_as != "pending":
if curr_uri.parsed_as == "ERROR":
curr_uri = "ARI://BADARI"
Expand Down
1 change: 0 additions & 1 deletion anms-core/integration_test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@
"integration_tests": "newman run integration_tests.json -r cli,json"
}
}
z
4 changes: 2 additions & 2 deletions anms-ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ENV PM2_HOME=${APP_WORK_DIR}/.pm2

# Install NodeJS Global Dependencies
RUN --mount=type=cache,target=/root/.cache/yarn \
yarn global add pm2 @vue/cli
yarn global --ignore-engines add pm2 @vue/cli

# Remaining commands as this user
USER ${APP_USER}:${APP_USER}
Expand Down Expand Up @@ -79,7 +79,7 @@ COPY --chown=${APP_USER}:${APP_USER} config.yaml process.yml config_ui_env.js da

CMD ["pm2-docker", "process.yml", "--env", "production"]

HEALTHCHECK --start-period=10s --interval=60s --timeout=60s --retries=20 \
HEALTHCHECK --start-period=10s --interval=60s --timeout=10s --retries=20 \
CMD ["pm2", "pid", "anms"]

EXPOSE 9030
2 changes: 1 addition & 1 deletion anms-ui/check_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ docker image build --tag anms-ui --target anms-ui ${SELFDIR}


docker run anms-ui bash -c "cd /opt/node_app/public && yarn audit --json || exit 0" > ${SELFDIR}/logs/${PUBLIC_LOG}
docker run anms-ui bash -c "cd /opt/node_app/server && npm audit --json || exit 0" > ${SELFDIR}/logs/${SERVER_LOG}
docker run anms-ui bash -c "cd /opt/node_app/server && yarn audit --json || exit 0" > ${SELFDIR}/logs/${SERVER_LOG}


8 changes: 5 additions & 3 deletions anms-ui/prep_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ mkdir -p "/home/${USER}/.cache/yarn"

for SUBNAME in server public
do
echo -e "\n\nUpdating in ${SUBNAME}...\n"
docker run \
-v "/etc/group:/etc/group:ro" \
-v "/etc/passwd:/etc/passwd:ro" \
-v "/etc/shadow:/etc/shadow:ro" \
-u ${UID}:${GID} \
-v "/home/${USER}/.cache/yarn:/home/${USER}/.cache/yarn" \
-v "${SELFDIR}/${SUBNAME}:/usr/src/app" \
yarn-base bash -c "cd /usr/src/app && yarn install"
-v "/home/${USER}/.cache/yarn:/home/${USER}/.cache/yarn:U" \
-v "${SELFDIR}/${SUBNAME}:/usr/src/app:U" \
yarn-base \
bash -c "cd /usr/src/app && yarn install"
done
36 changes: 21 additions & 15 deletions anms-ui/public/app/components/management/agents/reports.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@
:key="index"
:value="index">{{ rpt }}</b-form-select-option>
</b-form-select>
<b-table sticky-header
<div v-for="(_, index) in tableHeaders" :key="index">
<b-table sticky-header
hover
bordered
responsive
v-if="!loading && selected != -1"
id="report-table"
:fields="tableHeaders"
:items="tableItems"
>
</b-table>
id="report-table" :items="tableItems[index]" :fields="tableHeaders[index]"></b-table>
</div>
</div>
</template>

Expand Down Expand Up @@ -73,17 +71,25 @@ export default {
this.loading = false;
},
processReport(report) {
let holdHeader = report.shift();
this.tableHeaders = [];
for (let i = 0; i < holdHeader.length; i++) {
this.tableHeaders.push({"key":holdHeader[i]});
}
for (let item of report) {
let row = {};

for(const rpt of report){

let currTableItems = [];
let currTableHeaders = []
let holdHeader = rpt.shift();
for (let i = 0; i < holdHeader.length; i++) {
row[holdHeader[i]] = item[i];
currTableHeaders.push({"key":holdHeader[i]});
}
this.tableHeaders.push(currTableHeaders);

for (let item of rpt) {
let row = {};
for (let i = 0; i < holdHeader.length; i++) {
row[holdHeader[i]] = item[i];
}
currTableItems.push(row);
}
this.tableItems.push(row);
this.tableItems.push(currTableItems)
}
}
},
Expand Down
1 change: 0 additions & 1 deletion anms-ui/public/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "anms-ui",
"version": "0.1.1",
"dependencies": {
"@achrinza/node-ipc": "^10.1.11",
"@fortawesome/fontawesome-free": "^5.13.0",
"@fortawesome/fontawesome-svg-core": "^1.2.32",
"@fortawesome/free-solid-svg-icons": "^6.2.0",
Expand Down
Loading
Loading