[#521] Add netmap load command to policy playground #522

Merged
fyrchik merged 2 commits from ale64bit/frostfs-node:fix/521-pp-load into master 2023-07-19 11:34:10 +00:00
Member

Adds a load command to load an external netmap from a json file:

> load /home/godzilla/my/netmap.json

The structure is trivial:

{
	"nodeID": {
		"attributeName": "attributeValue",
		(...)
	},
	(...)
}

For example:

{
	"01": {
		"Color": "Red",
		"Shape": "Circle"
	},
	"02": {
		"Color": "Blue",
		"Location": "Saint Petersburg",
		"Shape": "Circle"
	}
}

This makes it easy to load custom netmaps and modify the existing one and adds support for attribute names containing space. Note that the load command discards any existing netmap info.

Signed-off-by: Alejandro Lopez a.lopez@yadro.com

Closes #521

Adds a `load` command to load an external netmap from a json file: ```sh > load /home/godzilla/my/netmap.json ``` The structure is trivial: ```json { "nodeID": { "attributeName": "attributeValue", (...) }, (...) } ``` For example: ```json { "01": { "Color": "Red", "Shape": "Circle" }, "02": { "Color": "Blue", "Location": "Saint Petersburg", "Shape": "Circle" } } ``` This makes it easy to load custom netmaps and modify the existing one and adds support for attribute names containing space. Note that the `load` command discards any existing netmap info. Signed-off-by: Alejandro Lopez <a.lopez@yadro.com> Closes #521
ale64bit requested review from d.zayakin 2023-07-14 08:16:58 +00:00
ale64bit requested review from storage-core-committers 2023-07-14 08:16:58 +00:00
ale64bit requested review from storage-core-developers 2023-07-14 08:16:59 +00:00
dstepanov-yadro approved these changes 2023-07-14 13:48:09 +00:00
fyrchik requested changes 2023-07-15 10:09:48 +00:00
@ -51,6 +52,7 @@ func (repl *policyPlaygroundREPL) handleAdd(args []string) error {
if len(args) == 0 {
return fmt.Errorf("too few arguments for command 'add': got %d, want >0", len(args))
}
Owner

unrelated to the commit

unrelated to the commit
Author
Member

done

done
fyrchik marked this conversation as resolved
@ -72,0 +83,4 @@
return fmt.Errorf("reading netmap file %q: %v", args[0], err)
}
if err := json.Unmarshal(b, &jsonNetmap); err != nil {
Owner

Why did you decide to stay on JSON? I mean it is good, but what about supporting YAML too?

Why did you decide to stay on JSON? I mean it is good, but what about supporting YAML too?
Author
Member

mmm, I guess I didn't think too much of it. JSON was simple enough for this particular use-case.

Maybe let's think about supporting YAML later, if someone actually asks for it.

mmm, I guess I didn't think too much of it. JSON was simple enough for this particular use-case. Maybe let's think about supporting YAML later, if someone actually asks for it.
fyrchik marked this conversation as resolved
@ -132,7 +168,10 @@ func (repl *policyPlaygroundREPL) run() error {
cmdHandlers := map[string]func([]string) error{
"ls": repl.handleLs,
"list": repl.handleLs,
Owner

Again, seems unrelated to the commit, could you move it to a separate commit?

Again, seems unrelated to the commit, could you move it to a separate commit?
Author
Member

done

done
fyrchik marked this conversation as resolved
ale64bit force-pushed fix/521-pp-load from 89bd54a339 to ef0bf5029c 2023-07-17 07:25:20 +00:00 Compare
ale64bit force-pushed fix/521-pp-load from ef0bf5029c to 79fae06d31 2023-07-19 07:07:55 +00:00 Compare
fyrchik merged commit 57e7fb5ccf into master 2023-07-19 11:34:10 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#522
No description provided.