You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add tools for loading manifest data from inventory tools (#64)
* added initial loading script
* add inventory tools integration to manifest loading script
* add cron job to periodically run manifest loading script
* added TODO
* refactor: migrate to new Docker setup with separate dev and prod configurations
* chore: add 'env' to .dockerignore to exclude environment files
* chore: add issuer-key.pem to .gitignore to exclude sensitive key files
* refactor: update Makefile to support environment-specific Docker Compose configurations
* docs: update README to clarify environment configurations and Make commands
* remove not needed token
* Make script executable
* Update README.md
remove duplicate word
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Move the dockerfile edits to dev, so I can test them first
* fix: update cron job command to use manage.py shell for loading manifest
* Added TODO
* fix: update cron job command to redirect output and set permissions
* fix: update docker-compose to set environment variables and start cron service
* feat: add support for force-recreate in docker-compose for dev environment
* fix: use settings.INVENTORY_TOOLS directly in load_manifest.py for cloning repository
* feat: update inventory tools settings to include repository and version management
* feat: update inventory tools configuration in settings and docker-compose for clarity
* feat: add username and token settings for inventory tools authentication in load_manifest.py
* feat: update inventory tools settings to remove username and streamline token usage
* chore: update .gitignore to include data directory
* feat: refactor subprocess handling in load_manifest.py for improved logging
* Added instructions for setting up keys for INVENTORY_TOOLS
* feat: add SSH directory validation and logging in load_manifest.py
* updated readme
* feat: add INV_TOOLS_SSH_DIR environment variable for SSH directory configuration
* feat: configure SSH directory in docker-compose for inventory tools
* feat: add INV_TOOLS_SSH_TOOLS environment variable for SSH tools directory
* feat: update docker-compose to configure SSH tools and directory paths
* feat: validate INV_TOOLS_SSH_TOOLS setting in load_manifest.py
* feat: update Dockerfile to install rsync and configure safe directory for git
* refactor: remove unused import of shutil in load_manifest.py
* update TODOs
* refactor: remove INV_TOOLS_SSH_DIR setting and only use INV_TOOLS_SSH_TOOLS
* feat: configure safe directory for git in load_manifest.py
* change SSH directory path in load_manifest.py
* feat: add INV_TOOLS_SSH_TOOLS_PW to environment configuration
* docs: add INV_TOOLS_SSH_TOOLS_PW passphrase requirement to README
* feat: add INV_TOOLS_SSH_CONFIG and INV_TOOLS_SSH_TOOLS_PW to base settings
* feat: enhance SSH configuration setup in load_manifest.py
* feat: update SSH tools and configuration paths in docker-compose.yaml
* feat: add shell option to run_subprocess and update ssh-agent setup
* docs: update README with TODOs for INVENTORY_TOOLS environment variables and SSH setup instructions
* feat: change directory to repo after executing git commands in load_manifest.py
* refactor: clean up TODO comments in load_manifest.py
* added TODO
* refactor: changed the script to implement django's custom commands
* refactor: remove unused Inventory Tools keys from base settings
* feat: change working directory to REPO_DIR before scraping nodes and loading manifests
* Added TODO
* fix: update cron job to run autoloadmanifest every 30 minutes
* added update create modem data handling in loadmanifest command
* feat: enhance manifest loading by syncing node, modem, computes, and sensors
* feat: add custom hardware option and improve hardware retrieval in sync process
* feat: add comprehensive tests for loadmanifest command functionality
* Made _sync_computes() easily extendable without changing core logic
* fix: change custom hardware naming
* Added compute and sensor mappers for easy extensions
* refactor: abstract compute and sensor alias resolution with mappers
* fix: skip processing for unreachable devices in loadmanifest command
* refactor: update hardware resolution to use SensorHardware model and get_or_create
* added TODO
* add tests for handling reachable and unreachable devices
* add notes for adding compute and sensor mappers
* add k8s source in sensor mappers
* feat: add node resource handling to load manifest command and tests
* fix: update get_repo method to require token options when repo is url
* uncomment line
* fix: update inventory tools repository path and adjust comments for clarity
* fix: update inventory tools repository path in docker-compose configuration
* using vsns from inventory tools. added --no-scrape flag. check if node id exists before updating models.
* updated hardware mapper to determined rpi 4gb vs 8gb from device model and resources.
* added migration
* included memory in test data
* updated manifest data in tests to include model and memory
---------
Co-authored-by: FranciscoLozCoding <francisco.lozano33@outlook.com>
Co-authored-by: Francisco Lozano <77420455+FranciscoLozCoding@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: README.md
+53-9Lines changed: 53 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,18 +14,43 @@ There are two development / deployment configurations both in `env` folder:
14
14
* dev: intended for fast, local dev on host machine. debug flags are enabled.
15
15
* prod: intended for testing in docker compose prior to deploying to production cluster. debug flags are disabled and more security settings are enabled.
16
16
17
-
For both environments, you will have to set up the keys in `env/<environment>/.env` so that the `downloads` app can work.
17
+
Optionally, for either of these environments you can configure...
18
+
* user login via Globus OIDC
19
+
* http redirect to files captured by nodes (`downloads` app)
20
+
* Automatic updates of node manifests (`INVENTORY_TOOLS`)
18
21
19
-
- S3_ACCESS_KEY: This is the access key for your S3 storage
20
-
- S3_SECRET_KEY: This is the secret key for your S3 storage
21
-
- PELICAN_KEY_PATH: This is the path to the .pem file for Pelican in the docker container
22
-
- PELICAN_KEY_ID: The id for the jwt public key used for Pelican found in `jwks.json` (https://sagecontinuum.org/.well-known/openid-configuration)
22
+
Optionally, you can configure user login via Globus OIDC for either of these environments.
23
23
24
-
>NOTE: If you are not working on the `downloads` app this can be ignored.
24
+
### Keys
25
+
For both environments, you will have to set up these keys in `env/<environment>/.env` so that the `downloads` app can work.
25
26
26
-
Optionally, you can configure user login via Globus OIDC for either of these environments.
27
+
-`S3_ACCESS_KEY`: This is the access key for your S3 storage
28
+
-`S3_SECRET_KEY`: This is the secret key for your S3 storage
29
+
-`PELICAN_KEY_PATH`: This is the path to the .pem file for Pelican in the docker container
30
+
-`PELICAN_KEY_ID`: The id for the jwt public key used for Pelican found in `jwks.json` (https://sagecontinuum.org/.well-known/openid-configuration)
31
+
32
+
> NOTE: If you are not working on the `downloads` app this can be ignored.
33
+
34
+
You will also have to set up these keys in `env/<environment>/.env` so that `INVENTORY_TOOLS` can work. `INVENTORY_TOOLS` is used to update the manifest automatically.
35
+
36
+
- INV_TOOLS_TOKEN: This is a github token with clone/pull access to our [inventory tools repo](https://github.com/waggle-sensor/waggle-inventory-tools)
37
+
- INV_TOOLS_SSH_TOOLS_PW: This is the passphrase for our ecdsa-sage-waggle SSH IdentityFile
38
+
39
+
>NOTE: If you are not working on `INVENTORY_TOOLS` this can be ignored.
40
+
41
+
### Environment Variables
42
+
43
+
>TODO: add instructions for INVENTORY_TOOLS env variables and how to set them up
44
+
45
+
### Volumes
46
+
47
+
>TODO: Add instructions in setting up waggle_inv_tools for ssh access to nodes within the django container
48
+
49
+
>TODO: Add a make command to set up INVENTORY_TOOLS ssh and ssh tools volume. aka clone repos and set up ssh config
27
50
28
-
### Local development using dev configuration
51
+
>NOTE: If you are not working on `INVENTORY_TOOLS` this can be ignored.
52
+
53
+
## Local development using dev configuration
29
54
30
55
_I highly recommend creating a virtual env when working on the app. I typically use:_
31
56
@@ -79,6 +104,25 @@ To implement the model edits to the server run:
79
104
make migrate
80
105
```
81
106
107
+
### Local development Inventory Tools
108
+
109
+
>TODO: add docs on running inventory tools locally
Automatically Load manifest data using data scraped from nodes into the database. This builds off of
11
+
the loadmanifest command but sets up SSH and scraping tools for nodes.
12
+
"""
13
+
env=Env()
14
+
15
+
defhandle(self, *args, **options):
16
+
"""
17
+
Handle the command execution.
18
+
"""
19
+
# Check if required options are set
20
+
ifnotself.check_required_options(options):
21
+
return
22
+
self.set_constants(options)
23
+
24
+
# Check if SSH directories exist
25
+
ifnotself.check_ssh_dirs():
26
+
return
27
+
28
+
self.log("Starting manifest loading process...")
29
+
os.chdir(self.WORKDIR)
30
+
31
+
# Set up SSH and clone the repo
32
+
self.set_ssh()
33
+
self.get_repo(options)
34
+
35
+
# Get the list of VSNs to scrape/load
36
+
vsns=self.get_vsns(options)
37
+
self.scrape_nodes(vsns)
38
+
self.load_manifests(vsns)
39
+
40
+
self.log("Manifest loading process completed.")
41
+
42
+
defadd_arguments(self, parser):
43
+
"""
44
+
Add command line arguments for the command.
45
+
"""
46
+
parser.add_argument("--repo", type=str, default=self.env("INV_TOOLS_REPO", str, None), help="Inventory Tools Repository URL or local path")
47
+
parser.add_argument("--token", type=str, default=self.env("INV_TOOLS_TOKEN", str, None), help="Github Token with access to INV_TOOLS_REPO URL")
48
+
parser.add_argument("--repo_ver", type=str, default=self.env("INV_TOOLS_VERSION", str, None), help="Branch, tag, or commit SHA of INV_TOOLS_REPO URL to use")
49
+
parser.add_argument("--ssh-tools", type=str, default=self.env("INV_TOOLS_SSH_TOOLS", str, None), help="Directory holding SSH tools used for SSHing into nodes")
parser.add_argument("--ssh-pw", type=str, default=self.env("INV_TOOLS_SSH_TOOLS_PW", str, None), help="Password for SSH IdentityFile")
52
+
parser.add_argument("--vsns", nargs="+", type=str, default=None, help="Optional list of VSNs to scrape/load. If not provided, all from DB will be used.")
0 commit comments