[Kimchi-devel] [PATCH 2/5] cdrom: update controller

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Mon Jan 13 12:06:46 UTC 2014


On 01/06/2014 07:32 AM, lvroyce at linux.vnet.ibm.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> Update controller and API.json for cdrom.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
>   src/kimchi/API.json       | 16 ++++++++++++++++
>   src/kimchi/control/vms.py | 22 ++++++++++++++++++++++
>   2 files changed, 38 insertions(+)
>
> diff --git a/src/kimchi/API.json b/src/kimchi/API.json
> index 3a3c48f..feb0c82 100644
> --- a/src/kimchi/API.json
> +++ b/src/kimchi/API.json
> @@ -103,6 +103,22 @@
>                   }
>               }
>           },
> +        "cdroms_create": {
> +            "type": "object",
> +            "properties": {
> +                "name": {
> +                    "description": "The name of the new VM",
Should be "new VM cdrom" or "new CDROM"
> +                    "type": "string",
> +                    "pattern": "^hd[b-z]$",
I do not see reasons to restrict the name of the cdrom device.
Because, this name may not reflect the device name inside the host,
and user could set the name to "my-ubuntu-iso" for instance, for better
management.

> +                    "required": true
> +                },
> +               "path": {
> +                    "description": "Path of image file inserted to the CDROM",
> +                    "type": "string",
> +                    "pattern": "^((/)|(http)[s]?:|[t]?(ftp)[s]?:)+.*([.]iso)$"
> +                }
> +            }
> +        },
>           "networks_create": {
>               "type": "object",
>               "properties": {
> diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py
> index d722920..51a18c1 100644
> --- a/src/kimchi/control/vms.py
> +++ b/src/kimchi/control/vms.py
> @@ -37,6 +37,7 @@ class VM(Resource):
>           super(VM, self).__init__(model, ident)
>           self.update_params = ["name"]
>           self.screenshot = VMScreenShot(model, ident)
> +        self.cdroms = CDROMs(model, ident)
>           self.uri_fmt = '/vms/%s'
>           self.start = self.generate_action_handler('start')
>           self.stop = self.generate_action_handler('stop')
> @@ -63,3 +64,24 @@ class VMScreenShot(Resource):
>       def get(self):
>           self.lookup()
>           raise internal_redirect(self.info)
> +
> +
> +class CDROMs(Collection):
> +    def __init__(self, model, vm):
> +        super(CDROMs, self).__init__(model)
> +        self.resource = CDROM
> +        self.vm = vm
> +        self.resource_args = [self.vm, ]
> +        self.model_args = [self.vm, ]
> +
> +
> +class CDROM(Resource):
> +    def __init__(self, model, vm, ident):
> +        super(CDROM, self).__init__(model, ident)
> +        self.vm = vm
> +        self.model_args = [self.vm, self.ident]
> +        self.uri_fmt = '/vms/%s/cdroms/%s'
> +
> +    @property
> +    def data(self):
> +        return self.info




More information about the Kimchi-devel mailing list