Skip to content

Conversation

@amd-pdebski
Copy link
Contributor

JSON API - ioctl handling, json requests handling, structuring and marshaling json responses, RESTful API early prototype

@CAS-Linux-Jenkins
Copy link

Can one of the admins verify this patch?

@rafalste
Copy link
Contributor

ok to test

@robertbaldyga
Copy link
Member

add to whitelist

…rshaling json responses, RESTful API early prototype

Signed-off-by: Piotr Debski <[email protected]>
@amd-pdebski amd-pdebski changed the title JSON API - ioctl handling, json requests handling, structuring and ma… JSON API - STAGE I Sep 2, 2021
@amd-pdebski amd-pdebski changed the title JSON API - STAGE I JSON API - stage I Sep 2, 2021
/** Reads Request structure from file "request.json" */

func (req *Request) Read_req() {
data, err := ioutil.ReadFile("request.json")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd prefer to read input json from stdin instead of forcing user to create file containing the request.


func (req *Request) Write_req() {
file, err := json.MarshalIndent(req, "", " ")
_ = ioutil.WriteFile("request.json", file, 0644)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. We'd prefer to print output to stdout. It's much easier to integrate with other tools.

Comment on lines 15 to 50
type Request struct {
Request_list_caches bool `json:"request list_caches"`
Request_get_stats bool `json:"request statistics"`
Get_stats_info Stats_request_info `json:"statistics request info"`
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to have common request header (it may consist of a single field like "command", which would contain name of the command) and the rest of the request structure would be different for each command. Otherwise we will end up with request structure containing all the input for all variants of all commands.

That would require preparsing request json as a Header struct which may look like this:

type Header struct {
    Command string `json:"command"`
}

That would allow us to determine the command type, and then we would be able to parse the request as a specific command.

@arutk
Copy link
Contributor

arutk commented Oct 4, 2021

Please squash commits to hide review history (e.g. remove "Review fixes" commit" from the log)

@arutk
Copy link
Contributor

arutk commented Oct 5, 2021

General comment: I would suggest to make json application output to entirely conform to json syntax. Especially error information might be included in the json output itself.

Comment on lines 6 to 7
"core_id": 0,
"io_class": 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make sense to make "core_id" and "io_class" parameters optional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem addressed trough increase granulation and making current parameters obligatory (different commands for each statistics level)

@Deixx
Copy link
Contributor

Deixx commented Oct 29, 2021

retest this please

@@ -0,0 +1,165 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update license tag to SPDX-License-Identifier: BSD-3-Clause

json_get_stats_core(*params)
}

if command == "opencas.ioclass.stats.get" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be opencas.cache.ioclass.stats.get.

json_get_stats_cache(*params)
}

if command == "opencas.core.stats.get" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be opencas.cache.core.stats.get.

json_get_cache_info(*params)
}

if command == "opencas.core.info.get" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opencas.cache.core.info.get

json_get_core_info(*params)
}

if command == "opencas.ioclass.info.get" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opencas.cache.ioclass.info.get

@Open-CAS Open-CAS deleted a comment from pep8speaks Nov 9, 2021
@pep8speaks
Copy link

pep8speaks commented Dec 23, 2021

Hello @pdebski21! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 18:59: E128 continuation line under-indented for visual indent
Line 21:45: E128 continuation line under-indented for visual indent

Line 48:53: E128 continuation line under-indented for visual indent
Line 54:61: E128 continuation line under-indented for visual indent

Comment last updated at 2022-01-04 09:28:29 UTC

KanagiAomori and others added 2 commits January 4, 2022 10:25
Signed-off-by: Piotr Debski <[email protected]>
Signed-off-by: Piotr Debski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants