From 386b57af7a09e4cdb2a40832f823397ee791d8d2 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 17 Sep 2007 10:52:33 +0000 Subject: [PATCH] Add support for rename operation in the OS API This patch adds support for renaming at OS level. Because of this, we need to bump up the version of the OS api from 4 to 5. The patch also documents the new script interface in the ganeti-os-interface(7) man page and adds a section on upgrading the OS definitions to the new version. Reviewed-by: imsnah --- lib/backend.py | 5 ++- lib/constants.py | 2 +- lib/objects.py | 3 +- man/ganeti-os-interface.sgml | 74 ++++++++++++++++++++++++++++++++---- 4 files changed, 73 insertions(+), 11 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index d71574060..65135b71c 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -812,6 +812,7 @@ def UploadFile(file_name, data, mode, uid, gid, atime, mtime): utils.RemoveFile(new_name) return True + def _ErrnoOrStr(err): """Format an EnvironmentError exception. @@ -871,6 +872,7 @@ def _OSOndiskVersion(name, os_dir=None): return api_version + def DiagnoseOS(top_dir=None): """Compute the validity for all OSes. @@ -922,7 +924,7 @@ def OSFromDisk(name, os_dir=None): % (api_version, constants.OS_API_VERSION)) # OS Scripts dictionary, we will populate it with the actual script names - os_scripts = {'create': '', 'export': '', 'import': ''} + os_scripts = {'create': '', 'export': '', 'import': '', 'rename': ''} for script in os_scripts: os_scripts[script] = os.path.sep.join([os_dir, script]) @@ -944,6 +946,7 @@ def OSFromDisk(name, os_dir=None): create_script=os_scripts['create'], export_script=os_scripts['export'], import_script=os_scripts['import'], + rename_script=os_scripts['rename'], api_version=api_version) diff --git a/lib/constants.py b/lib/constants.py index 246136aa4..6e327093b 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -27,7 +27,7 @@ from ganeti import _autoconf CONFIG_VERSION = 3 PROTOCOL_VERSION = 2 RELEASE_VERSION = _autoconf.PACKAGE_VERSION -OS_API_VERSION = 4 +OS_API_VERSION = 5 EXPORT_VERSION = 0 diff --git a/lib/objects.py b/lib/objects.py index de33eb8eb..0d409cc5c 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -400,7 +400,8 @@ class OS(ConfigObject): "api_version", "create_script", "export_script", - "import_script" + "import_script", + "rename_script", ] diff --git a/man/ganeti-os-interface.sgml b/man/ganeti-os-interface.sgml index f3f6717dd..6d3a56f0a 100644 --- a/man/ganeti-os-interface.sgml +++ b/man/ganeti-os-interface.sgml @@ -53,10 +53,10 @@ <title>REFERENCE</title> <para> - There are four required files: <filename>create</filename>, - <filename>import</filename>, <filename>export</filename> - (executables) and <filename>ganeti_api_version</filename> (text - file). + There are five required files: <filename>create</filename>, + <filename>import</filename>, <filename>export</filename>, + <filename>rename</filename> (executables) and + <filename>ganeti_api_version</filename> (text file). </para> <refsect2> @@ -81,7 +81,7 @@ denote the block devices which will be visible in the instance as <emphasis>sda</emphasis> and <emphasis>sdb</emphasis>. The <emphasis>sda</emphasis> block device should be used for the - root disk (and will be passed as the root device for linux + root disk (and will be passed as the root device for Linux kernels). The <emphasis>sdb</emphasis> device should be setup for swap usage.</para> @@ -131,14 +131,48 @@ </refsect2> + <refsect2> + <title>rename</title> + <cmdsynopsis> + <command>rename</command> + <arg choice="req">-o <replaceable>old_name</replaceable></arg> + <arg choice="req">-n <replaceable>new_name</replaceable></arg> + <arg choice="req">-b <replaceable>blockdev_sda</replaceable></arg> + <arg choice="req">-s <replaceable>blockdev_sdb</replaceable></arg> + </cmdsynopsis> + + <para> + This command is used in order to perform a rename at the + instance OS level, after the instance has been renamed in + Ganeti. The command should do whatever steps are required to + ensure that the instance is updated to use the new name, if + the operating system supports it. + </para> + + <para> + Note that it is acceptable for the rename script to do nothing + at all, however be warned that in this case, there will be a + desynchronization between what <computeroutput>gnt-instance + list</computeroutput> shows you and the actual hostname of the + instance. + </para> + + <para> + A very simple rename script should at least change the + hostname and IP address of the instance, leaving the + administrator to update the other services. + </screen> + </para> + </refsect2> + <refsect2> <title>ganeti_api_version</title> <para> The <filename>ganeti_api_version</filename> file is a plain text file containing the version of the guest OS api that this OS definition complies with. The version documented by this - man page is 4, so this file must contain 4 followed by a - newline. + man page is 5, so this file must contain the number 5 followed + by a newline. </para> </refsect2> @@ -154,12 +188,36 @@ </refsect2> + <refsect2> + <title>Upgrading from old versions</title> + <refsect3> + <title>Version 4 to 5</title> + <para> + The <filename>rename</filename> script has been added. If + you don't want to do any changes on the instances after a + rename, you can migrate the OS definition to version 5 by + creating the <filename>rename</filename> script simply as: + <screen> +#!/bin/sh + +exit 0 + </screen> + </para> + + <para>Note that the script must be executable.</para> + </refsect3> + </refsect2> + <!-- <refsect2> <title>Export/import format</title> - <para>It is up to the export and import scripts to define the format they use. It is only required for these two to work together. It is not recommended that </para> + <para> + It is up to the export and import scripts to define the format + they use. It is only required for these two to work + together. It is not recommended that + </para> </refsect2> --> -- GitLab