[Kimchi-devel] [PATCH v3 2/4] CDROM Management: Update controller and API.json for guest storages
Royce Lv
lvroyce at linux.vnet.ibm.com
Wed Feb 12 04:03:06 UTC 2014
On 2014年02月12日 10:38, Daniel Barboza wrote:
> From: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
>
> 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>
>
> API.json: adding virtio device pattern
>
> Signed-off-by: Daniel Henrique Barboza <danielhb 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 f025661..8ea9de7 100644
> --- a/src/kimchi/API.json
> +++ b/src/kimchi/API.json
> @@ -296,6 +296,39 @@
> },
> "additionalProperties": false
> },
> + "storages_create": {
> + "type": "object",
> + "properties": {
> + "dev": {
> + "description": "The storage device name",
> + "type": "string",
> + "pattern": "^hd[b-z]|vd[a-z]$"
> + },
> + "type": {
> + "description": "The storage type",
> + "type": "string",
> + "pattern": "^cdrom|disk$",
As I mentioned, shall we consider to exclude cdrom from this?
> + "required": true
> + },
> + "path": {
> + "description": "Path of iso image file or disk mount point",
> + "type": "string",
> + "pattern": "^((/)|(http)[s]?:|[t]?(ftp)[s]?:)+.*$",
> + "required": true
> + }
> + }
> + },
> + "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..953620f
> --- /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>
Author:)
> +#
> +# 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
More information about the Kimchi-devel
mailing list