Skip to content

Commit dd61beb

Browse files
authored
Merge branch 'main' into 305-rest-api-error-handling
2 parents 2679935 + 3a1e57f commit dd61beb

File tree

16 files changed

+214
-181
lines changed

16 files changed

+214
-181
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ GRAFANA_CONTAINER_PORT=3000
4545
GRAFANA_HOST_PORT=grafana:${GRAFANA_CONTAINER_PORT}
4646
GRAFANA_PROXIES_PATH=localhost/grafana
4747
GRAFANA_DB_NAME=grafana_internal_db
48+
GRAFANA_PASS=grafana
4849

4950
REDIS_PORT=6379
5051
JS_AMP_PORT=3001
@@ -69,4 +70,3 @@ CTR_SOCKDIR=/var/tmp/nm
6970

7071
ADM_PATH=deps/dtnma-adms
7172

72-
GRAFANA_PASS=grafana

README.md

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
Copyright (c) 2023 The Johns Hopkins University Applied Physics
2+
Copyright (c) 2022-2026 The Johns Hopkins University Applied Physics
33
Laboratory LLC.
44
55
This file is part of the Asynchronous Network Management System (ANMS).
@@ -21,13 +21,42 @@ subcontract 1658085.
2121
-->
2222
# AMMOS ANMS
2323

24-
This is a detailed developer-focused documentation for the AMMOS Asynchronous Network Management System (ANMS).
24+
This is the quickstart documentation for the AMMOS Asynchronous Network Management System (ANMS).
2525

2626
### Copyright
2727

28-
Copyright (C) 2022-2025 The Johns Hopkins University Applied Physics Laboratory LLC.
28+
Copyright (C) 2022-2026 The Johns Hopkins University Applied Physics Laboratory LLC.
2929

30-
[[_TOC_]]
30+
# Start Here: Which Documentation Should You Use?
31+
32+
ANMS supports multiple types of users. The appropriate documentation depends on how you are interacting with the system.
33+
34+
**1. Are you installing ANMS from this source repository?**
35+
36+
If yes, then use this README for:
37+
* Quickstart instructions
38+
* Installation steps
39+
* Basic configuration
40+
* High-level overview
41+
42+
For detailed operational guidance after installation, refer to the ANMS User Guide, found here: www.nasa-ammos.github.io/anms-docs/.
43+
44+
**2. Are you an AMMOS user or operating an already-installed ANMS instance (not from source)?**
45+
46+
If yes, do not rely on this README for operational guidance. Refer to the ANMS Product Guide and ANMS User Guide for:
47+
* System usage
48+
* Operational workflows
49+
* Configuration details
50+
51+
**NOTE:** These guides apply to *all* users once ANMS is installed.
52+
53+
**3. Are you a developer contributing to ANMS or setting up a development environment?**
54+
55+
If yes, refer to both this README and the ANMS Wiki [Development Guide](https://github.com/NASA-AMMOS/anms/wiki/Development-Guide) for:
56+
* Local development environment configuration
57+
* Testing workflows
58+
* Contribution guidelines
59+
* Additional troubleshooting guidance
3160

3261
# Quick Start
3362

@@ -37,19 +66,20 @@ This section details prerequisites to installing the ANMS from source on a devel
3766

3867
### Software and OS Versions
3968

40-
The setup of ANMS and demos listed in this README have been tested on macOS 11.6.4 (Big Sur), RHEL 9 and Ubuntu 20.04.
41-
To run the ANMS tool, you must also install Docker Engine version 20.10.10 or newer or Podman 5.2.2+. You will also need either Docker Compose version 1.29.2+ or podman-compose. Docker and podman can generally be used interchangeably.
69+
The setup of ANMS and demos listed in this README have been tested on macOS 11.6.4 (Big Sur), RHEL 9 and Ubuntu 20.04.
70+
To run the ANMS tool, you must also install Docker Engine version 20.10.10 or newer or Podman 5.2.2+. You will also need either Docker Compose version 1.29.2+ or podman-compose. Docker and Podman can generally be used interchangeably.
4271

43-
The ANMS UI capability has been tested on Firefox version 96.0.1.
44-
There is no capability that should preclude operation on other modern browsers.
72+
**NOTE:** `docker-compose` can be used with `podman`, and `docker-compose` is generally recommended for improved reliability over `podman-compose`, with some platforms (e.g. Mac) failing to start up correctly with Podman. In all cases, recent versions of the installed compose tool are invoked with `podman compose` or `docker compose` as appropriate.
73+
74+
The ANMS UI should work on all modern browsers.
4575

4676
### Network Setup
4777

4878
If your computer is behind a network proxy, this may cause issues related to using self-signed certificates when pulling dependencies to build Docker images.
49-
Though ANMS can be run behind a proxy; building the ANMS Docker images from behind a network proxy may result in errors.
79+
Though ANMS can be run behind a proxy, building the ANMS Docker images from behind a network proxy may result in errors.
5080

51-
The first steps in each of the container image `Dockerfile` is to attempt to download an APLNIS root CA to validate the APLNIS HTTPS proxy.
52-
When building images outside of the APLNIS, this download will gracefully fail and the image will not be able to run within the APLNIS. The URL for this certificate can be changed for users requiring equivalent functionality on their own networks.
81+
The first steps in each of the container image `Dockerfile` is to attempt to download the appropriate root CA to validate your HTTPS proxy.
82+
When building images outside of the internal network, it is possible that this download will gracefully fail and the image will not be able to run within the internal network. The URL for this certificate can be changed for users requiring equivalent functionality on their own networks.
5383

5484
### Special Notes on Podman
5585

@@ -62,7 +92,8 @@ Note: If running on a system where **SELinux** is enabled, the system will not s
6292

6393
### Upgrading ANMS
6494

65-
If upgrading from an earlier version, a few steps are necessary to clear out earlier state.
95+
If upgrading from an earlier version, a few steps are necessary to clear out the earlier state. **NOTE:** please see the `UPGRADING.md` file in this repo for specific changes when one wishes to preserve data.
96+
6697
The following command sequence uses standard Docker commands to stop all containers and remove all "dangling" images, networks, and volumes.
6798

6899
:warning: The last command in this sequence removes volumes, **which include DB state**.
@@ -81,16 +112,16 @@ docker stop $(docker ps -q); docker rm $(docker ps --all -q); docker system prun
81112

82113
The quickstart script will configure, pull, and start the ANMS system for the first time. See comments in the script for additional details, including optional ENV variables to override default behavior.
83114

84-
NOTICE: By default, quick start will pull pre-built containers from the github registry (ghcr.io). To force a rebuild, run it as `FORCE_REBULD=y ./quickstart.sh`. See the script header for details.
115+
NOTICE: By default, quick start will pull pre-built containers from the github registry (ghcr.io). To force a rebuild, run it as `FORCE_REBUILD=y ./quickstart.sh`. See the script header for details.
85116

86-
To stop the system use `podman compose -f testenv-compose.yml -f docker-compose.yml down`.
117+
To stop the system, use `podman compose -f testenv-compose.yml -f docker-compose.yml down`.
87118

88-
To start the system in the future use `podman compose -f testenv-compose.yml up` and `podman compose up`.
119+
To start the system in the future, use `podman compose -f testenv-compose.yml up` and `podman compose up`.
89120

90121
## Manual Startup
91-
Choose the appropriate docker, podman or podman-compose commands in the directions below as appropriate for your system.
122+
Choose the appropriate docker, podman, or podman-compose commands in the directions below as appropriate for your system.
92123

93-
- Edit `.env` file as appropriately
124+
- Edit `.env` file as appropriate.
94125
- Select appropriate profile(s) as desired.
95126
- Core ANMS services are always started.
96127
- The 'full' profile starts up all UI and related services.
@@ -111,8 +142,8 @@ Choose the appropriate docker, podman or podman-compose commands in the directio
111142
- `docker compose -f docker-compose.yml build`
112143
- `podman compose -f docker-compose.yml build`
113144
- `podman-compose --podman-build-args='--format docker' -f docker-compose.yml build`
114-
- Note: The docker format argument here enables suppoort for HEALTHCHECK. If omitted, the system will run but will be unable to report the health of the system. This flag does not appear necessary when using the no-dash version of compose.
115-
- Build test environemnt images using one of the following:
145+
- Note: The docker format argument here enables support for HEALTHCHECK. If omitted, the system will run but will be unable to report the health of the system. This flag does not appear necessary when using the no-dash version of compose.
146+
- Build test environment images using one of the following:
116147
- `docker compose -f testenv-compose.yml build`
117148
- `podman compose -f testenv-compose.yml build`
118149
- `podman-compose --podman-build-args='--format docker' -f testenv-compose.yml build`
@@ -162,7 +193,7 @@ point. With ANMS running, go to `localhost:8080` and log in to the database with
162193

163194
### ADM and Agent Updates
164195

165-
Changes to ADMs are handled on the Manager by uploading a new version of the ADM via the Web UI.
196+
By default after building the system, ANMS starts with the ADMs defined in `deps/dtnma-adms` and ADMs added to `anms-core/extra_adms`. Changes to and adding new ADMs are handled on the Manager by uploading a new version of the ADM via the Web UI or the REST POST endpoint `http://localhost:5555/adms/`.
166197
The manager will then be able to use the new ADM.
167198

168199
Changes to a test Agent are more complicated, and require auto-generated C sources built into the ION source tree.

anms-core/anms/init_adms.py

Lines changed: 0 additions & 81 deletions
This file was deleted.

anms-core/anms/routes/ARIs/ari.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
# subcontract 1658085.
2323
#
2424
import asyncio
25-
from functools import cache
2625
from typing import List
2726

2827
from fastapi import Depends, APIRouter
@@ -36,7 +35,6 @@
3635
from anms.models.relational import get_async_session
3736
from anms.models.relational.actual_parameter import ActualParameter
3837
from anms.models.relational.ari import ARI
39-
from anms.models.relational.adms.data_model_view import DataModel
4038
from anms.models.relational.formal_parameter import FormalParameter
4139

4240

anms-core/anms/routes/adms/adm.py

Lines changed: 5 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -126,71 +126,11 @@ async def remove_adm(enumeration: int, namespace:str):
126126
logger.debug(f"ADM ENUM:{enumeration} in NAMESPACE {namespace} not a known ADM")
127127
raise HTTPException(status_code = status.HTTP_400_BAD_REQUEST, detail = f"ADM ENUM:{enumeration} in NAMESPACE {namespace} not a known ADM")
128128

129-
130-
131-
async def handle_adm(admset: ace.AdmSet, adm_file: ace.models.AdmModule, session, replace=True):
132-
''' Process a received and decoded ADM into the ANMS DB.
133-
134-
:param replace: If true and the ADM exists it will be checked and replaced.
135-
:return: A list of issues with the ADM, which is empty if successful.
136-
'''
137-
logger.info("Adm name: %s", adm_file.norm_name)
138-
data_model_view = await DataModel.get(adm_file.ns_model_enum,adm_file.ns_org_name )
139-
if data_model_view:
140-
if not replace:
141-
logger.info('Not replacing existing ADM name %s', adm_file.norm_name)
142-
return []
143-
data_rec = None
144-
async with get_async_session() as session:
145-
data_rec,_ = await AdmData.get(data_model_view.data_model_id,session)
146-
147-
if data_rec:
148-
# Compare old and new contents
149-
logger.info("Checking existing ADM name %s", adm_file.norm_name)
150-
old_adm = admset.load_from_data(io.BytesIO(data_rec.data), del_dupe=False)
151-
comp = AdmCompare(admset)
152-
if not comp.compare_adms(old_adm, adm_file):
153-
issues = comp.get_errors()
154-
else:
155-
issues = [f"Updating existing adm is not allowed yet"]
156-
return issues
157-
158-
logger.info("Inserting ADM name %s", adm_file.norm_name)
159-
160-
# Use CAmPython to generate sql
161-
out_path = "" # This is empty string since we don't need to write the generated sql to a file
162-
sql_dialect = 'pgsql'
163-
writer = create_sql.Writer(admset, adm_file, out_path, sql_dialect)
164-
string_buffer = io.StringIO()
165-
writer.write(string_buffer)
166-
167-
# execute generated Sql
168-
queries = string_buffer.getvalue()
169-
try:
170-
await session.execute(queries)
171-
await session.commit()
172-
except Exception as err:
173-
logger.error(f"{sql_dialect} execution error: {err.args}")
174-
logger.debug('%s', traceback.format_exc())
175-
raise
176-
177-
# Save the adm file of the new adm
178-
179-
180-
buf = io.StringIO()
181-
ace.adm_yang.Encoder().encode(adm_file, buf)
182-
ret_dm = await DataModel.get(adm_file.ns_model_enum, adm_file.ns_org_name, session)
183-
184-
# Write the encoded string data to the BytesIO object
185-
bytes_io = io.BytesIO()
186-
bytes_io.write(buf.getvalue().encode('utf-8'))
187-
# Reset the pointer to the beginning
188-
bytes_io.seek(0)
189-
data = {"enumeration":ret_dm.data_model_id, "data": bytes_io.getvalue()}
190-
await AdmData.add_data(data, session)
191-
192-
return []
193-
129+
@router.post("/load_default", status_code=status.HTTP_201_CREATED)
130+
async def load_default_adm():
131+
await TRANSMORGIFIER.load_default_adms()
132+
response = JSONResponse(status_code=status.HTTP_200_OK, content={"message": "Initilized default ADMs", "error_details": ""})
133+
return response
194134

195135
@router.post("/", status_code=status.HTTP_201_CREATED,
196136
responses={400: {"model": RequestError}, 405: {"model": UpdateAdmError}, 500: {"model": RequestError}})

0 commit comments

Comments
 (0)