Modifying instances over rapi

40 views
Skip to first unread message

Unavailable Now

unread,
Jan 19, 2024, 4:55:55 AMJan 19
to gan...@googlegroups.com
Hi,

I am writing a small tool to similar to the CLI gnt-instance. The modify option is working perfectly with beparams/hvparams/os etc.. but not when adding/removing disks/nics.

According to the RAPI docs:
disks (defaults to [], must be (List of ((Length 3) and (Item 0 is (OneOf attach, detach, add, modify, remove), item 1 is (Integer or String [Device index, can be negative, e.g. -1 for last disk]), item 2 is (Dictionary with keys of NonEmptyString and values of (NonEmptyString or Integer) [Disk parameters]))) [Recommended]) or (List of ((Length 2) and (Item 0 is ((OneOf attach, detach, add, remove) or EqualOrGreaterThanZero), item 1 is (Dictionary with keys of NonEmptyString and values of (NonEmptyString or Integer) [Disk parameters]))) [Deprecated]))

I tried different types of disks payload with no success:
{'disks': ['add', 1, [{'size': '10G'}]]}
{'disks': ['add', 1, {'size': '10G'}]}
even with the deprecated type:
{'disks': ['add', {'size': '10G'}]}

I always get the same error depending on the payload:
ganeti-rapi pid=641664 ERROR OpCode OP_INSTANCE_SET_PARAMS, parameter disks, has invalid type <class 'list'>/value '['add', 1, [{'size': '10G'}]]' expecting type (List of ((Length 3) and (Item 0 is (OneOf detach, attach, modify, remove, add), item 1 is (Integer or String [Device index, can be negative, e.g. -1 for last disk]), item 2 is (Dictionary with keys of NonEmptyString and values of (NonEmptyString or Integer) [Disk parameters]))) [Recommended]) or (List of ((Length 2) and (Item 0 is ((OneOf attach, detach, add, remove) or EqualOrGreaterThanZero), item 1 is (Dictionary with keys of NonEmptyString and values of (NonEmptyString or Integer) [Disk parameters]))) [Deprecated])


It would be great if someone could direct me to how to create the payload for RAPI for:
gnt-instance modify --disks/--nicks add/remove


Thanks a lot

Unavailable Now

unread,
Jan 19, 2024, 7:21:12 AMJan 19
to ganeti
The RAPI documentation ist not correct, the disks payload should be a list of one tuple:

{'disks': [('add', 1, {'size': '10G'})]}
Or:
{'disks': [('add', {'size': '20G'})]}

Thanks a lot

Unavailable Now

unread,
Jan 19, 2024, 7:32:17 AMJan 19
to ganeti
Or I didn't understand it well. Probably (List of ((Length 3).........) means simply a list of tuple with three items [(a, b, c)]
Anyways Its resolved.
Thank you very much.

Reply all
Reply to author
Forward
0 new messages