From 3fd7f652447c18aa336d1fcd9717d473694805ff Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 30 Mar 2011 12:52:02 +0200 Subject: [PATCH] RAPI server: Drop support for instance creation format 0 Ganeti 2.1.3, released in June 2010, added support for a new, extensible instance creation request format, called version 1. This patch removes support for the old and undocumented version 0 format. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- NEWS | 3 +++ doc/rapi.rst | 4 +-- lib/rapi/rlib2.py | 62 ++--------------------------------------------- 3 files changed, 7 insertions(+), 62 deletions(-) diff --git a/NEWS b/NEWS index ef31fda6d..782faedaa 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,9 @@ Version 2.5.0 beta1 parameter no longer defaults to ``loop`` and must be specified - The deprecated "bridge" nic parameter is no longer supported. Use "link" instead. +- Support for the undocumented and deprecated RAPI instance creation + request format version 0 has been dropped. Use version 1, supported + since Ganeti 2.1.3 and :doc:`documented <rapi>`, instead. Version 2.4.0 diff --git a/doc/rapi.rst b/doc/rapi.rst index 37299733e..625da292c 100644 --- a/doc/rapi.rst +++ b/doc/rapi.rst @@ -568,8 +568,8 @@ Body parameters: ``__version__`` (int, required) Must be ``1`` (older Ganeti versions used a different format for - instance creation requests, version ``0``, but that format is not - documented and should no longer be used). + instance creation requests, version ``0``, but that format is no + longer supported) .. opcode_params:: OP_INSTANCE_CREATE diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py index f6dcd951d..e45057e47 100644 --- a/lib/rapi/rlib2.py +++ b/lib/rapi/rlib2.py @@ -751,65 +751,6 @@ class R_2_instances(baserlib.R_Generic): return baserlib.BuildUriList(instanceslist, "/2/instances/%s", uri_fields=("id", "uri")) - def _ParseVersion0CreateRequest(self): - """Parses an instance creation request version 0. - - Request data version 0 is deprecated and should not be used anymore. - - @rtype: L{opcodes.OpInstanceCreate} - @return: Instance creation opcode - - """ - # Do not modify anymore, request data version 0 is deprecated - beparams = baserlib.MakeParamsDict(self.request_body, - constants.BES_PARAMETERS) - hvparams = baserlib.MakeParamsDict(self.request_body, - constants.HVS_PARAMETERS) - fn = self.getBodyParameter - - # disk processing - disk_data = fn('disks') - if not isinstance(disk_data, list): - raise http.HttpBadRequest("The 'disks' parameter should be a list") - disks = [] - for idx, d in enumerate(disk_data): - if not isinstance(d, int): - raise http.HttpBadRequest("Disk %d specification wrong: should" - " be an integer" % idx) - disks.append({"size": d}) - - # nic processing (one nic only) - nics = [{"mac": fn("mac", constants.VALUE_AUTO)}] - if fn("ip", None) is not None: - nics[0]["ip"] = fn("ip") - if fn("mode", None) is not None: - nics[0]["mode"] = fn("mode") - if fn("link", None) is not None: - nics[0]["link"] = fn("link") - - # Do not modify anymore, request data version 0 is deprecated - return opcodes.OpInstanceCreate( - mode=constants.INSTANCE_CREATE, - instance_name=fn('name'), - disks=disks, - disk_template=fn('disk_template'), - os_type=fn('os'), - pnode=fn('pnode', None), - snode=fn('snode', None), - iallocator=fn('iallocator', None), - nics=nics, - start=fn('start', True), - ip_check=fn('ip_check', True), - name_check=fn('name_check', True), - wait_for_sync=True, - hypervisor=fn('hypervisor', None), - hvparams=hvparams, - beparams=beparams, - file_storage_dir=fn('file_storage_dir', None), - file_driver=fn('file_driver', constants.FD_LOOP), - dry_run=bool(self.dryRun()), - ) - def POST(self): """Create an instance. @@ -823,7 +764,8 @@ class R_2_instances(baserlib.R_Generic): data_version = self.getBodyParameter(_REQ_DATA_VERSION, 0) if data_version == 0: - op = self._ParseVersion0CreateRequest() + raise http.HttpBadRequest("Instance creation request version 0 is no" + " longer supported") elif data_version == 1: data = self.request_body.copy() # Remove "__version__" -- GitLab