Revision c744425f lib/rapi/client.py
b/lib/rapi/client.py | ||
---|---|---|
71 | 71 |
# Internal constants |
72 | 72 |
_REQ_DATA_VERSION_FIELD = "__version__" |
73 | 73 |
_INST_CREATE_REQV1 = "instance-create-reqv1" |
74 |
_INST_REINSTALL_REQV1 = "instance-reinstall-reqv1" |
|
74 | 75 |
_INST_NIC_PARAMS = frozenset(["mac", "ip", "mode", "link", "bridge"]) |
75 | 76 |
_INST_CREATE_V0_DISK_PARAMS = frozenset(["size"]) |
76 | 77 |
_INST_CREATE_V0_PARAMS = frozenset([ |
... | ... | |
858 | 859 |
("/%s/instances/%s/startup" % |
859 | 860 |
(GANETI_RAPI_VERSION, instance)), query, None) |
860 | 861 |
|
861 |
def ReinstallInstance(self, instance, os=None, no_startup=False): |
|
862 |
def ReinstallInstance(self, instance, os=None, no_startup=False, |
|
863 |
osparams=None): |
|
862 | 864 |
"""Reinstalls an instance. |
863 | 865 |
|
864 | 866 |
@type instance: str |
... | ... | |
870 | 872 |
@param no_startup: Whether to start the instance automatically |
871 | 873 |
|
872 | 874 |
""" |
875 |
if _INST_REINSTALL_REQV1 in self.GetFeatures(): |
|
876 |
body = { |
|
877 |
"start": not no_startup, |
|
878 |
} |
|
879 |
if os is not None: |
|
880 |
body["os"] = os |
|
881 |
if osparams is not None: |
|
882 |
body["osparams"] = osparams |
|
883 |
return self._SendRequest(HTTP_POST, |
|
884 |
("/%s/instances/%s/reinstall" % |
|
885 |
(GANETI_RAPI_VERSION, instance)), None, body) |
|
886 |
|
|
887 |
# Use old request format |
|
888 |
if osparams: |
|
889 |
raise GanetiApiError("Server does not support specifying OS parameters" |
|
890 |
" for instance reinstallation") |
|
891 |
|
|
873 | 892 |
query = [] |
874 | 893 |
if os: |
875 | 894 |
query.append(("os", os)) |
Also available in: Unified diff