• Michael Hanselmann's avatar
    LUInstanceSetParams: Convert to generic algorithm for NIC/disk changes · c0f1033f
    Michael Hanselmann authored
    Unfortunately this got a bit messier than I intended, but then again it
    cleans up a lot of messy code with heaps of local variables
    (“this_nic_override”) and LU attributes (“nic_pnew”, “nic_pinst”). Most
    of these variables were index by a number, or one of the
    constants.DDM_* constants.
    This patch moves the code for adding/modifying/removing a NIC/disk to
    dedicated, small functions. The previously added generic algorithm for
    applying changes to containers is then used to actually change the
    instance's network interfaces or disks based on the requested
    modifications. The LU now supports adding/removing disks/NICs in
    arbitrary positions.
    The compuation of all network interface changes has been moved to
    CheckPrereq, so that its result can be used for hooks. For this to work
    without side-effects, the NIC objects need to be copied (only done if
    there are actual changes).
    The command line utility still needs to be updated.
    Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
    Reviewed-by: default avatarIustin Pop <iustin@google.com>
cmdlib.py 537 KB