On 2013年12月31日 03:49, Aline Manera wrote:
On 12/30/2013 12:17 AM, lvroyce@linux.vnet.ibm.com wrote:
From: Royce Lv <lvroyce@linux.vnet.ibm.com>

v3>v4, fix inconsistency between doc and json schema
v1>v3, fix racing problem, fix style.

Add parameters to GET request so that we will query storage server as:
    /storageservers?type=netfs

Royce Lv (5):
  Support params for GET method
  Add testcase for GET param
  Storage server: Update API.md
  storage server: update controller.py
  storage server: Update model and mockmodel

 docs/API.md              | 13 +++++++++++++
 src/kimchi/API.json      | 11 +++++++++++
 src/kimchi/controller.py | 26 ++++++++++++++++++++++++--
 src/kimchi/mockmodel.py  | 13 +++++++++++++
 src/kimchi/model.py      | 14 +++++++++++++-
 src/kimchi/root.py       |  1 +
 tests/test_rest.py       | 37 +++++++++++++++++++++++++++++++++++++
 7 files changed, 112 insertions(+), 3 deletions(-)


Let me explain what I expect with this patch set:

GET /storageservers will return all storage servers
Example:

[
{'host': 'localhost',
 'target_type': 'netfs',
 'sources': ['/srv', '/mnt/isos'],
}

{'host': '123.234.123.12',
 'target_type': 'iscsi',
 'sources': ['
iqn.2013-06.com.example:iscsi-pool'],
}
]
Aline, as posted inn my RFC patch: [project-kimchi][RFC]Storage backend targets probe
I explained, this is to give users a ref when he wants to fill the "host" blank of storagepool creation.

GET /storageservers only returns *servers* we uses as source as storagepool, *targets* will not be covered here.
We can return non query parameter results here, but I haven't figured out a usecase for this one.
Normally we only create storagepool of a given kind.


GET /storageservers?target_type=<server-type> will return only the storage servers with type <server-type>
Example: GET /storageservers?target_type=netfs

[
{'host': 'localhost',
 'target_type': 'netfs',
 'sources': ['/srv', '/mnt/isos'],
}
]

GET /storageservers/<id> will return data related to this specific server
Example: GET /storageservers/localhost

{'host': 'localhost',
 'target_type': 'netfs',
 'sources': ['/srv', '/mnt/isos'],
}

Because a host can serve as multiple server(iscsi, gluster, nfs) at same time. So I choose to make user query a specific kind by:
    GET /storageservers/localhost?target_type=netfs
or
    GET /storageservers/localhost?target_type=iscsi
like this.


This functionality is covered by [project-kimchi][PATCHv1 0/3] Storage targets support patchset.

The 'sources' for netfs, for example, will be the parsed output from "showmount -e <host>" command.

So when the user want to create NFS pool with a new server (never used before)

POST /storageservers/new-nfs-server

{'host': 'new-nfs-server',
 'target_type': 'netfs',
 'sources': ['/srv', '/mnt'],
}

Then the user know which paths are available to create the NFS pool
I don't quite agree... 'POST' to storage server means you want to create a storage server.

When he wants to create a new NFS pool:

1. If he knows his server, he fills it, if not he take a look at used NFS server by:
    GET /storageservers?target_type=netfs
{'localhost', '9.1.1.2', 'a-nfs-server.com'}
    Then he choose '9.1.1.2' as host

2. Now he manually fills path or query the exposed path by:
    GET /storageservers/9.1.1.2?target_type=netfs
{'type':'nfs',
 'targets': ['/a-path', '/b-path'],
}
    He decides to use 'a-path'

3. Then it comes to real storagepool creation by sending request:
    POST /storagepools
    {'host': '9.1.1.2', 'path': '/a-path', 'name': 'a-pool'}

Does that make sense for you?