On 01/02/2014 12:41 AM, Royce Lv wrote:
On 2013年12月31日 03:30, Aline Manera wrote:
> On 12/30/2013 12:17 AM, lvroyce(a)linux.vnet.ibm.com wrote:
>> From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
>>
>> Add storage server collection and resource to report
>> used storage server.
>>
>> Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
>> ---
>> src/kimchi/API.json | 11 +++++++++++
>> src/kimchi/controller.py | 17 +++++++++++++++++
>> src/kimchi/root.py | 1 +
>> 3 files changed, 29 insertions(+)
>>
>> diff --git a/src/kimchi/API.json b/src/kimchi/API.json
>> index 7b90826..29d8172 100644
>> --- a/src/kimchi/API.json
>> +++ b/src/kimchi/API.json
>> @@ -205,6 +205,17 @@
>> }
>> },
>> "additionalProperties": false
>> + },
>> + "storageservers_get_list": {
>> + "type": "object",
>> + "properties": {
>> + "target_type": {
>> + "description": "List storage servers of given type",
>> + "type": "string",
>> + "pattern": "^netfs$",
>> + "required": true
>> + }
>> + }
>> }
>> }
>> }
>> diff --git a/src/kimchi/controller.py b/src/kimchi/controller.py
>> index c99a811..bdd3cab 100644
>> --- a/src/kimchi/controller.py
>> +++ b/src/kimchi/controller.py
>> @@ -647,6 +647,23 @@ class DebugReport(Resource):
>> 'time': self.info['ctime']}
>>
>>
>> +class StorageServers(Collection):
>> + def __init__(self, model):
>> + super(StorageServers, self).__init__(model)
>> + self.resource = StorageServer
>> +
>> + def get(self):
>> + res_list = []
>> + params = parse_request()
>> + validate_params(params, self, 'get_list')
>> + get_list = getattr(self.model, model_fn(self, 'get_list'))
>> + res_list = get_list(*self.model_args, **params)
>> + return kimchi.template.render(get_class_name(self), res_list)
>> +
>> +
>> +class StorageServer(Resource):
>> + pass
>
> You also need to expose which values will be returned:
>
> @property
> def data(self):
> return self.info
paths only return in storageTarget resource, so this resource does not
have any data yet.
At least the ident should be exposed.
GET /storageservers should return a list of idents
>
>> +
>> class Config(Resource):
>> def __init__(self, model, id=None):
>> super(Config, self).__init__(model, id)
>> diff --git a/src/kimchi/root.py b/src/kimchi/root.py
>> index c43897c..0f80785 100644
>> --- a/src/kimchi/root.py
>> +++ b/src/kimchi/root.py
>> @@ -67,6 +67,7 @@ class Root(controller.Resource):
>> self.logout = controller.logout
>> self.debugreports = controller.DebugReports(model)
>> self.plugins = controller.Plugins(model)
>> + self.storageservers = controller.StorageServers(model)
>> self.api_schema = json.load(open(get_api_schema_file()))
>>
>> def get(self):
>