[Kimchi-devel] [PATCH 2/3] (WIP) CDROM Management: Update controller and API.json for guest storages

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Mon Feb 10 22:09:47 UTC 2014


On 02/10/2014 05:48 PM, Aline Manera wrote:
> On 02/10/2014 10:52 AM, Rodrigo Trujillo wrote:
>> This patch adds the control classes for guest storages
>>
>> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
>> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
>> ---
>>   src/kimchi/API.json               | 33 ++++++++++++++++++++++++++
>>   src/kimchi/control/vm/storages.py | 49 
>> +++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 82 insertions(+)
>>   create mode 100644 src/kimchi/control/vm/storages.py
>>
>> diff --git a/src/kimchi/API.json b/src/kimchi/API.json
>> index 842fb11..861c96e 100644
>> --- a/src/kimchi/API.json
>> +++ b/src/kimchi/API.json
>> @@ -290,6 +290,39 @@
>>               },
>>               "additionalProperties": false
>>            },
>> +        "storage_create": {
>> +            "type": "object",
>> +            "properties": {
>> +                "dev": {
>> +                    "description": "The storage device name",
>> +                    "type": "string",
>> +                    "pattern": "^hd[b-z]$",
>> +                    "required": true
>
> The dev can be optinal.
> We can choose one if user does not provide one
>
ack
>> +                },
>> +                "type": {
>> +                    "description": "The storage type",
>> +                    "type": "string",
>> +                    "pattern": "^[cdrom|disk]$",
>> +                    "required": true
>> +                },
>> +               "path": {
>> +                    "description": "Path of iso image file or disk 
>> mount point",
>> +                    "type": "string",
>> +                    "pattern": "^((/)|(http)[s]?:|[t]?(ftp)[s]?:)+.*$"
>
> The path is a required parameter.
ack
>
>> +                }
>> +            }
>> +        },
>> +        "storage_update": {
>> +            "type": "object",
>> +            "properties": {
>> +               "path": {
>> +                    "description": "Path of iso image file or disk 
>> mount point",
>> +                    "type": "string",
>> +                    "pattern": "^((/)|(http)[s]?:|[t]?(ftp)[s]?:)+.*$",
>> +                    "required": true
>> +                }
>> +            }
>> +        },
>>           "template_update": {
>>               "type": "object",
>>               "properties": {
>> diff --git a/src/kimchi/control/vm/storages.py 
>> b/src/kimchi/control/vm/storages.py
>> new file mode 100644
>> index 0000000..8878d6e
>> --- /dev/null
>> +++ b/src/kimchi/control/vm/storages.py
>> @@ -0,0 +1,49 @@
>> +#
>> +# Project Kimchi
>> +#
>> +# Copyright IBM, Corp. 2013
>> +#
>> +# Authors:
>> +#  ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>> +#
>> +# This library is free software; you can redistribute it and/or
>> +# modify it under the terms of the GNU Lesser General Public
>> +# License as published by the Free Software Foundation; either
>> +# version 2.1 of the License, or (at your option) any later version.
>> +#
>> +# This library is distributed in the hope that it will be useful,
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> +# Lesser General Public License for more details.
>> +#
>> +# You should have received a copy of the GNU Lesser General Public
>> +# License along with this library; if not, write to the Free Software
>> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
>> 02110-1301 USA
>> +
>> +from kimchi.control.base import Collection, Resource
>> +from kimchi.control.utils import UrlSubNode
>> +
>> +
>> + at UrlSubNode("storages")
>> +class Storages(Collection):
>> +    def __init__(self, model, vm):
>> +        super(Storages, self).__init__(model)
>> +        self.resource = Storage
>> +        self.vm = vm
>> +        self.resource_args = [self.vm, ]
>> +        self.model_args = [self.vm, ]
>> +
>> +
>> +class Storage(Resource):
>> +    def __init__(self, model, vm, ident):
>> +        super(Storage, self).__init__(model, ident)
>> +        self.vm = vm
>> +        self.ident = ident
>> +        self.info = {}
>> +        self.model_args = [self.vm, self.ident]
>> +        self.uri_fmt = '/vms/%s/storages/%s'
>> +        self.update_params = ['path']
>> +
>> +    @property
>> +    def data(self):
>> +       return self.info
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>




More information about the Kimchi-devel mailing list