[Kimchi-devel] [PATCH][Kimchi 3/5] Update REST API
Ramon Medeiros
ramonn at linux.vnet.ibm.com
Wed Jun 8 21:06:44 UTC 2016
Isn't more simple to use the if on the iteration like this:
# iterate over new bootorder and build tag
for device in params["order"]:
if device not in ["hd", "cdrom", "fd", "network"]:
raise InvalidParameter("KCHVM0053E")
?
"KCHVM0053E": _("Boot order must be a list. Devices accepted: hd,
cdrom, fd or network."),
On 06/08/2016 04:44 PM, Rodrigo Trujillo wrote:
> Hi Ramon,
> yes, it is possible to use ENUM (with a little trick )... please,
> analyze and try this schema:
>
> ********************************************************************
> "boot": {
> "description": "Boot order and bootmenu configuration",
> "type": "object",
> "error": "KCHVM0052E",
> "properties": {
> "order": {
> "description": "Boot order",
> "type": "array",
> "error": "KCHVM0053E",
> "items": [
> {"type": "string",
> "enum": ["hd", "cdrom", "network", "fd"]
> },
> {"type": "string",
> "enum": ["hd", "cdrom", "network", "fd"]
> },
> {"type": "string",
> "enum": ["hd", "cdrom", "network", "fd"]
> },
> {"type": "string",
> "enum": ["hd", "cdrom", "network", "fd"]
> }
> ],
> "minItems": 1,
> "additionalItems": false,
> "uniqueItems": true
> }
> },
> "additionalProperties": false,
> "required": ["order"]
> }
>
> ********************************************************************
>
> In my tests out of Kimchi it worked , but it accepts "boot" empty
> ("minProperties: 1" did not work).
> So you have to treat this in the code.
>
> Let me know.
>
> Rodrigo Trujillo
>
>
> On 06/08/2016 02:46 PM, Ramon Medeiros wrote:
>>
>>
>> On 06/07/2016 10:02 AM, Rodrigo Trujillo wrote:
>>>
>>>
>>> On 06/06/2016 06:13 PM, Ramon Medeiros wrote:
>>>> Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
>>>> ---
>>>> API.json | 12 ++++++++++++
>>>> i18n.py | 2 ++
>>>> 2 files changed, 14 insertions(+)
>>>>
>>>> diff --git a/API.json b/API.json
>>>> index 8d4f725..d0e6831 100644
>>>> --- a/API.json
>>>> +++ b/API.json
>>>> @@ -294,6 +294,18 @@
>>>> "minLength": 1,
>>>> "error": "KCHVM0011E"
>>>> },
>>>> + "boot": {
>>>> + "description": "Boot order and bootmenu
>>>> configuration",
>>>> + "type": "object",
>>>> + "error": "KCHVM0052E",
>>>> + "properties": {
>>>> + "order": {
>>>> + "description": "Boot order",
>>>> + "type": "array",
>>>> + "error": "KCHVM0053E"
>>> Here you can use ENUM and restrict the options accepted. See the
>>> graphics schema a
>> I can't use enum, it returns error all time because this patch is to
>> add the boot order, not the first device.
>>
>> Enum seems to be usable to fixed options, like at VNC. I was not able
>> to use in this case
>>> nd:
>>> http://spacetelescope.github.io/understanding-json-schema/reference/array.html
>>>
>>>
>>>> + }
>>>> + }
>>>> + },
>>>> "users": {
>>>> "description": "Array of users who have
>>>> permission to the VM",
>>>> "type": "array",
>>>> diff --git a/i18n.py b/i18n.py
>>>> index 2d8390f..ec060ae 100644
>>>> --- a/i18n.py
>>>> +++ b/i18n.py
>>>> @@ -103,6 +103,8 @@ messages = {
>>>> "KCHVM0049E": _("Cannot power off %(name)s. Virtual machine
>>>> is shut off."),
>>>> "KCHVM0050E": _("Cannot shutdown %(name)s. Virtual machine is
>>>> shut off."),
>>>> "KCHVM0051E": _("Cannot reset %(name)s. Virtual machine is
>>>> already shut off."),
>>>> + "KCHVM0052E": _("Boot configuration must have order list"),
>>>> + "KCHVM0053E": _("Boot order must be a list of the devices"),
>>> I think the messages must be clearer. Like:
>>> "Boot configuration must receive a list of devices in the boot order"
>>> "Boot order must be a list of devices among ['network', 'hd', ...]"
>>>
>>>>
>>>> "KCHVM0055E": _("Migrate to localhost %(host)s is not
>>>> allowed."),
>>>> "KCHVM0056E": _("To migrate a virtual machine to the remote
>>>> host %(host)s the user %(user)s must have password-less login to
>>>> the remote host."),
>>>
>>> _______________________________________________
>>> Kimchi-devel mailing list
>>> Kimchi-devel at ovirt.org
>>> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>>>
>>
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>
--
Ramon Nunes Medeiros
Kimchi Developer
Linux Technology Center Brazil
IBM Systems & Technology Group
Phone : +55 19 2132 7878
ramonn at br.ibm.com
More information about the Kimchi-devel
mailing list