Update collect to take input with specified format#130
Conversation
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
e59ee6e to
92bdb3b
Compare
Signed-off-by: David Allen <davidallendj@gmail.com>
synackd
left a comment
There was a problem hiding this comment.
Testing with real BMCs.
Scanning:
$ ./magellan scan --subnet 172.16.0.0/24 -l info -i -F json --insecure
{"level":"warn","error":"RegisterFlagCompletionFunc: flag 'format' does not exist","time":"2026-05-14T13:45:41-06:00","message":"failed to register completion function"}
[
{
"host": "https://172.16.0.105",
"port": 443,
"protocol": "tcp",
"state": true,
"timestamp": "2026-05-14T13:45:41.948173759-06:00",
"service_type": "Redfish"
},
{
"host": "https://172.16.0.104",
"port": 443,
"protocol": "tcp",
"state": true,
"timestamp": "2026-05-14T13:45:41.947999177-06:00",
"service_type": "Redfish"
},
{
"host": "https://172.16.0.102",
"port": 443,
"protocol": "tcp",
"state": true,
"timestamp": "2026-05-14T13:45:41.947644981-06:00",
"service_type": "Redfish"
},
{
"host": "https://172.16.0.101",
"port": 443,
"protocol": "tcp",
"state": true,
"timestamp": "2026-05-14T13:45:41.947476248-06:00",
"service_type": "Redfish"
},
{
"host": "https://172.16.0.103",
"port": 443,
"protocol": "tcp",
"state": true,
"timestamp": "2026-05-14T13:45:41.947691662-06:00",
"service_type": "Redfish"
},
{
"host": "https://172.16.0.199",
"port": 443,
"protocol": "tcp",
"state": true,
"timestamp": "2026-05-14T13:45:41.948031377-06:00",
"service_type": "Redfish"
},
{
"host": "https://172.16.0.198",
"port": 443,
"protocol": "tcp",
"state": true,
"timestamp": "2026-05-14T13:45:41.947765703-06:00",
"service_type": "Redfish"
}
]
Scanning piping to collect:
$ ./magellan scan --subnet 172.16.0.0/24 -l info -i -F json --insecure | ./magellan collect -f json --show-output -i
{"level":"warn","error":"RegisterFlagCompletionFunc: flag 'format' does not exist","time":"2026-05-14T13:46:07-06:00","message":"failed to register completion function"}
{"level":"warn","error":"RegisterFlagCompletionFunc: flag 'format' does not exist","time":"2026-05-14T13:46:07-06:00","message":"failed to register completion function"}
{"level":"error","error":"no file found","time":"2026-05-14T13:46:07-06:00","caller":"/opt/shared/magellan/cmd/collect.go:61","message":"failed to get scanned results from cache"}
{"level":"error","error":"no assets found","time":"2026-05-14T13:46:07-06:00","caller":"/opt/shared/magellan/cmd/collect.go:178","message":"failed to collect data"}
null
| @@ -9,16 +9,20 @@ import ( | |||
| "github.com/OpenCHAMI/magellan/internal/cache/sqlite" | |||
| "github.com/OpenCHAMI/magellan/internal/format" | |||
| magellan "github.com/OpenCHAMI/magellan/pkg" | |||
There was a problem hiding this comment.
If we haven't added linting to Magellan yet, we definitely should. Internal imports should go after other package imports. I suspect this needs to be done in other files as well, so it can be addressed in a subsequent PR.
I think this may be happening because the This is where the check happens: And here is where the flag default is set: I can run it by setting ./magellan scan --subnet 172.16.0.0/24 -l info -i -F json | ./magellan collect -f json --show-output -i --cache "" -l debug |
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
cbe75b6 to
7b1e8d4
Compare
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
|
@synackd It should be working now. I had to add some missing logic back to This is the command I'm using to test currently: ./magellan scan --subnet 172.16.0.0/24 -l info -i -F json | ./magellan collect -f json --show-output -i --cache "" -l debug |
|
That command line worked for me. What if we added a check to see that stdin was open and, if so, used that instead of a cache unless explicitly told to do so? |
collect take input with specified formatcollect take input with specified format
collect take input with specified formatcollect to take input with specified format
@davidallendj Just wanted to check in again with this to see if this was something we wanted to add in this PR. |
Yes, I think we should. I just haven't gotten back around to add it. If you already have it implemented though, feel free to push to this branch and we can get this merged. |
|
Understood. I didn't attempt it in order to avoid possibly duplicating your work. All yours. 🙂 |
Pull Request Template
Thank you for your contribution! Please ensure the following before submitting:
Checklist
make test(or equivalent) locally and all tests passgit commit -s) with my real name and email<filename>.licensesidecarLICENSES/directoryDescription
This PR changes the
collectcommand to take JSON or YAML as input from thescancommand. This allows for the entire discovery process to be completed as a single command without hitting the file system.Examples:
Fixes #128
Type of Change
For more info, see Contributing Guidelines.