Update show-datamodel-api spec

1. Update sample command for show-datamodel-api.
2. Modify REST API return value example.

Change-Id: I19593c3d4892e0e2c3d4e1cd08b47cf80167ebd8
This commit is contained in:
chenke 2019-08-20 17:21:03 +08:00
parent 26f3881d8f
commit 8bd1829204

View File

@ -14,10 +14,11 @@ https://blueprints.launchpad.net/watcher/+spec/show-datamodel-api
Problem description Problem description
=================== ===================
The datamodel is very important for Watcher to generate resource The data model is very important for Watcher to generate resource
optimization solutions. Currently, it can only be found by looking at optimization solutions. Currently, it can only be found by looking at
the log file, which is very inconvenient. Therefore, it is necessary the log file, which is very inconvenient. Therefore, it is necessary
to add an api to facilitate the user to quickly view the datamodel. to add an api to facilitate the user to quickly view the current datamodel
in memory.
Use Cases Use Cases
---------- ----------
@ -36,16 +37,18 @@ about the datamodel, then parses and returns.
The command line interface used in watcherclient could be like this: The command line interface used in watcherclient could be like this:
* watcher datamodel list [--audit <audit_id>] * openstack optimize datamodel list [--audit <audit_uuid>]
* [--type <type>] [--detail]
In watcherclient, we can add **"datamodel.py,datamodel_shell.py"** to send In watcherclient, we can add **"data_model.py,data_model_shell.py"** to send
datamodel list request and receive the result. datamodel list request and receive the result.
In watcher-api, we can add **"datamodel.py"** to recieve the In watcher-api, we can add **"data_model.py"** to recieve the
python-watcherclient's request and call watcher-decision-engine module. python-watcherclient's request and call watcher-decision-engine module.
In watcher-decision-engine, we can get datamodel data according to the In watcher-decision-engine, we can get datamodel data according to the
specified scope, then parses the datamodel and return to watcher-api. specified scope and the type, then parses the datamodel and return to
watcher-api.
Alternatives Alternatives
------------ ------------
@ -60,9 +63,9 @@ None
REST API impact REST API impact
--------------- ---------------
Add following **datamodel** REST: Add following **data model** REST:
* GET /v1/datamodels * GET /v1/data_model
* Normal http response code(200) * Normal http response code(200)
* Expected error http response code(400,401) * Expected error http response code(400,401)
@ -70,106 +73,71 @@ Add following **datamodel** REST:
* Request * Request
* **audit_uuid (Optional)**: UUID of an audit * **audit_uuid (Optional)**: UUID of an audit
* **type (Optional)**: Type of data model user want to list
* Response * Response
* **instance_uuid**: UUID of an instance * **server_uuid**: UUID of server
* **node_uuid**: UUID of an compute node * **server_name**: name of server
* **instance_state**: state of instance * **server_vcpus**: number of server vcpus
* **node_state**: state of compute node * **server_memory**: memory of server
* **server_disk**: disk of server
* GET /v1/datamodels/detail * **server_state**: state of server
* **node_uuid**: UUID of node
* Normal http response code(200) * **node_hostname**: name of node
* Expected error http response code(400,401) * **node_vcpus**: number of node vcpus
* **node_vcpu_ratio**: vcpu ratio of node
* Request
* **audit_uuid (Optional)**: UUID of an audit
* Response
* **instance_uuid**: UUID of an instance
* **instance_state**: state of instance
* **instance_name**: name of instance
* **instance_vcpus**: number of instance vcpus
* **instance_memory**: memory of instance
* **instance_disk**: disk of instance
* **instance_disk_capacity**: disk capacity of instance
* **node_uuid**: UUID of an compute node
* **node_state**: state of compute node
* **node_name**: name of node
* **node_vcpus**: number of compute node vcpus
* **node_memory**: memory of node * **node_memory**: memory of node
* **node_memory_ratio**: memory ratio of node
* **node_disk**: disk of node * **node_disk**: disk of node
* **node_disk_capacity**: disk capacity of node * **node_disk_ratio**: disk ratio of node
* **node_state**: state of node
* Example JSON representation of Datamodel * Example JSON representation of compute data model
:: ::
{ {
"compute": [ "context": [
{ {
"node_uuid": "90d7da5c-d432-4eba-89b4-743c9f1e6cfa", "server_uuid": "1bf91464-9b41-428d-a11e-af691e5563bb",
"node_name": "node_1", "server_name": "chenke-test1",
"node_vcpus": 48, "server_vcpus": "1",
"node_memory": "4096", "server_memory": "512",
"node_disk": "40", "server_disk": "1",
"node_disk_capacity": "60" "server_state": "active",
"servers": [ "node_uuid": "253e5dd0-9384-41ab-af13-4f2c2ce26112",
{ "node_hostname": "localhost.localdomain",
"instance_uuid": "9e7cbe91-b391-4394-a42c-68996a4fd555", "node_vcpus": "4",
"instance_state": "active", "node_vcpu_ratio": "16.0",
"instance_name": "vm_4", "node_memory": "16383",
"instance_vcpus": 16, "node_memory_ratio": "1.5",
"instance_memory": "2048", "node_disk": "37"
"instance_disk": "10", "node_disk_ratio": "1.0",
"instance_disk_capacity": "35", "node_state": "up",
}, },
{ {
"instance_uuid": "8e7cbe91-b391-4394-a42c-68996a4fd555", "server_uuid": "e2cb5f6f-fa1d-4ba2-be1e-0bf02fa86ba4",
"instance_state": "active", "server_name": "chenke-test2",
"instance_name": "vm_5", "server_vcpus": "1",
"instance_vcpus": 16, "server_memory": "512",
"instance_memory": "2048", "server_disk": "1",
"instance_disk": "10", "server_state": "active",
"instance_disk_capacity": "35", "node_uuid": "253e5dd0-9384-41ab-af13-4f2c2ce26112",
} "node_hostname": "localhost.localdomain",
] "node_vcpus": "4",
}, "node_vcpu_ratio": "16.0",
{ "node_memory": "16383",
"node_uuid": "78d7da5c-d432-4eba-89b4-743c9f1e6cfa", "node_memory_ratio": "1.5",
"node_name": "node_2", "node_disk": "37"
"node_vcpus": 96, "node_disk_ratio": "1.0",
"node_memory": "4096", "node_state": "up",
"node_disk": "60",
"node_disk_capacity": "60"
"servers": [
{
"instance_uuid": "6b7cbe91-b391-4394-a42c-68996a4fd55b",
"instance_state": "active",
"instance_name": "vm_1",
"instance_vcpus": 32,
"instance_memory": "2048",
"instance_disk": "10",
"instance_disk_capacity": "35",
},
{
"instance_uuid": "527cbe91-b391-4394-a42c-68996a4fd5e7",
"instance_state": "active",
"instance_name": "vm_2",
"instance_vcpus": 16,
"instance_memory": "2048",
"instance_disk": "10",
"instance_disk_capacity": "35",
}
]
} }
] ]
} }
Security impact Security impact
--------------- ---------------
@ -191,7 +159,7 @@ in python-watcherclient:
and add the **audit** parameter to filter the datamodel in the and add the **audit** parameter to filter the datamodel in the
specified scope: specified scope:
* watcher datamodel list [--audit <audit_id>] * watcher datamodel list [--audit <audit_uuid>]
Performance Impact Performance Impact
------------------ ------------------
@ -250,7 +218,7 @@ Documentation Impact
==================== ====================
* A documentation explaining how to use * A documentation explaining how to use
**watcher datamodel list [--audit <audit_id>]** **watcher datamodel list [--audit <audit_uuid>] [--type <type>] [--detail]**
* Update API Reference * Update API Reference
@ -266,4 +234,14 @@ None
History History
======= =======
None
.. list-table:: Revisions
:header-rows: 1
* - Release Name
- Description
* - Stein
- Introduced
* - Train
- Updated