pax_global_header00006660000000000000000000000064127232560230014514gustar00rootroot0000000000000052 comment=1c34101fe6c125ae7cc4cac843854e259b57aabb ganeti-instance-debootstrap-0.16/000077500000000000000000000000001272325602300170375ustar00rootroot00000000000000ganeti-instance-debootstrap-0.16/.gitignore000066400000000000000000000004001272325602300210210ustar00rootroot00000000000000# gitignore rules # autotools results /Makefile /Makefile.in /aclocal.m4 /autom4te.cache /autotools /config.log /config.status /configure /test-suite.log /test/*.log /test/*.trs # built scripts /common.sh # archives /ganeti-instance-debootstrap-*.tar.gz ganeti-instance-debootstrap-0.16/COPYING000066400000000000000000000431221272325602300200740ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ganeti-instance-debootstrap-0.16/Makefile.am000066400000000000000000000024351272325602300210770ustar00rootroot00000000000000osname=$(subst ganeti-instance-,,$(PACKAGE)) osdir=$(OS_DIR)/$(osname) variantsdir=$(DESTDIR)$(sysconfdir)/ganeti/instance-debootstrap/variants defaultsdir=$(DESTDIR)$(sysconfdir)/default dist_os_SCRIPTS = create import export rename verify dist_os_DATA = ganeti_api_version variants.list parameters.list os_DATA = common.sh dist_doc_DATA = COPYING NEWS README exampledir = $(docdir)/examples exampleconfdir = $(exampledir)/confdata dist_exampleconf_DATA = \ examples/hooks/confdata/defaultpasswords \ examples/hooks/confdata/timezone dist_example_DATA = \ examples/hooks/defaultpasswords \ examples/hooks/grub \ examples/hooks/hosts \ examples/hooks/interfaces \ examples/hooks/ssh-keys \ examples/hooks/timezone EXTRA_DIST = \ common.sh.in \ defaults \ $(TESTS) do_subst = sed \ -e 's,[@]sysconfdir[@],$(sysconfdir),g' \ -e 's,[@]localstatedir[@],$(localstatedir),g' common.sh: common.sh.in Makefile $(do_subst) < $< > $@ TESTS = \ test/install-export-import install-exec-local: @mkdir_p@ $(variantsdir) touch $(variantsdir)/default.conf @mkdir_p@ $(defaultsdir) $(INSTALL_DATA) $(top_srcdir)/defaults \ $(defaultsdir)/ganeti-instance-debootstrap uninstall-local: rm -f $(variantsdir)/default.conf rm -f $(defaultsdir)/ganeti-instance-debootstrap CLEANFILES = common.sh ganeti-instance-debootstrap-0.16/NEWS000066400000000000000000000172051272325602300175430ustar00rootroot00000000000000Version 0.16 ------------ Again a small bugfix release: - ensure the same filesystem is used consistently throughout the code (issue 1175); previously only the create script was paying attention to `OSP_FILESYSTEM` - fix compatibility with sfdisk version 2.26 and later (Ubuntu bug LP#1577346) - improve checks for required programs at configure time - change default distribution to Jessie and increase minimum accepted disk size from 256MiB to 512MiB - add a small test suite to allow for easier integration testing with distributions Version 0.15 ------------ Small bugfix release: - improved compatibility with newer `losetup` versions (issue 690) - make kpartx run in sync mode, so that partitions are present by the time we want to access them - wait for udev to finish scanning (loopback) devices before attempting to delete them - fix parsing of UUIDs that contain "-1" as sub-string Version 0.14 ------------ The root password is now automatically cleared, so that it is possible to immediately log into a newly created instance. A hardcoded reference to ext3 is removed. The documentation is improved, correctly specifying that the default debian version installed is now wheezy, and with the addition of examples on how to run hooks while creating a new instance. Version 0.13 ------------ The Debian version installed by default is now Wheezy. The filesystem type for the root partition of instances is now configurable through the new OS parameter ``filesystem``. It defaults to 'ext4'. Improve documentation with regard to instance variants. Bugfixes: - Report an error if it's exporting an instance fails because of the wrong filesystem type. Version 0.12 ------------ A few small bugfixes: - the defaults file is now installed automatically; even though all settings are commented out, this allows for easier configuration - require and check for a minimum device size; this makes error messages much clearer, compared to tar's out of disk space errors (fixes issue 164) - it is now possible to override the "components" argument to debootstrap, to be able to install more packages (e.g. from contrib, or from universe) (fixes issue 254) - all existing hooks are now distributed in the archive and also installed via `make install' (fixes issue 283) - the console activation for xen-pvm hypervisor has been corrected; before it was working only for kvm (fixes issue 284) Version 0.11 ------------ The partition alignment offset is now configurable (using the PARTITION_ALIGNMENT configuration setting, in sectors) and the distribution names and packages in the defaults file have been updated. Furthermore, the grub example hook has been improved a bit: - automatically uses the defined proxy, so that package installation uses the same method as the main install - debconf frontend set to non-interactive, to prevent an debconf question loop However, there still seem to be issues related to this hook (recent grub versions fail to run correctly "grub-install" or "update-grub" and complain about device mappings); help is welcome. Version 0.10 ------------ This add supports for ext4 file-systems and changes the default distribution from Lenny to Squeeze. Additionally, new hooks were added: - setting the password for the root user - setting the timezone - setting SSH keys for a given user Version 0.9 ----------- Changed the default CUSTOMIZE_DIR (under $sysconfdir, usually /etc) from ganeti/instance-debootstrap.d to ganeti/instance-debootstrap/hooks, to match better with the directory used for the variants file. Now customization of the instance-debootstrap is done either in the defaults file or under ganeti/instance-debootstrap. Fix serial console access for kvm instances (bind to ttyS0 rather than console). Please note that with this change if you toggle the serial console hypervisor parameter in Ganeti, but don't create the getty entry in /etc/inittab or /etc/event.d/ you won't have serial access. Before it used to work, but the serial console was slightly broken (no ctrl+c for example). Also start shipping the examples in the tar archive, to ease packaging. Version 0.8 ----------- Added support for OS API 15 (with OS variants) that is supported by Ganeti 2.1. blktype is now supported as an alternative to vol_id; this is needed for newer Debian-based operating systems. Added an example grub script, that can be used for automatically installing grub inside new instances. Version 0.7 ----------- Fix Ganeti 1.2 compatibility (0.6 was broken) and force the scripts to be executed under /bin/bash (rather than /bin/sh). This fixes compatibility with distributions where /bin/sh is not bash. Support 'msdos' partition style, in which the instance disk gets a partition table, and one big partition, rather than creating the filesytem directly on the block device. This requires kpartx to be installed, and is the default when installing under Ganeti 2.0. Added the possibility to customize the installation without having to patch the os directly, by executing the scripts in CUSTOMIZE_DIR and giving them a chance to change the instance filesystem. As an example a script that sets the first nic to request a dhcp address is provided. Version 0.6 ----------- Support for Ganeti 2.0 (os api 10) The instance's fstab is now generated with volumes' UUIDs rather than paths. This makes it more resilient to changes and use under different hypervisors/drivers. Init is configured to listen on /dev/console rather than /dev/tty1 Version 0.5 ----------- Most of the settings of the script have been moved to a configuration file. Depending on the ./configure options, the location of this file might be /etc/default/ganeti-instance-debootstrap or /usr/local/etc/default/ganeti-instance-debootstrap. The cache generation and cleaning variables can be modified as follows: - to enable generating the cache, modify the config file and set GENERATE_CACHE to "yes" - to disable cleaning the cache, set CLEAN_CACHE to ""; or alternatively, you can customize with this variable the number of days after which to clear the cache Note that the cache file is no longer stored in the same directory as the OS definition files, but (again depending on ./configure options) usually under /var/cache/ganeti-instance-debootstrap. There are many other customizable settings added in this version, for example the actual OS to be installed (no longer always installing Debian Etch), whether to use a proxy or not, etc. See the README and the 'defaults' files. Version 0.4 ----------- This version fixes the problem of interface renaming at instance import time, by removing the saved udev hotplug rules (if any). Version 0.3 ----------- The OS will cache the image of the first instance it installs using the name "cache-$arch.tar" (where $arch is what dpkg --print-architecture returns) on a node-by-node basis. This cache will be then used on the future installs, speeding them greatly (even with a fast mirror). Feel free to remove the cache at any time, or to copy it to all nodes. The cache will be kept for two weeks, after which the first install will recreate the cache (in order not to use old packages). If you don't care about package age, remove the user write permission (chmod u-w) from the cache and ganeti will continue to use the same file without refreshing it. If you don't have enough space and don't want cache creation, just touch the file 'no_cache' - this will prevent the creation, but the script will continue to use a cache if it exists (but it will remove an existing one after two weeks). Also note that if the image file is there, the script does not need network access at all. .. vim: set textwidth=72 : .. Local Variables: .. mode: rst .. fill-column: 72 .. End: ganeti-instance-debootstrap-0.16/README000066400000000000000000000214251272325602300177230ustar00rootroot00000000000000ganeti-instance-debootstrap =========================== This is a guest OS definition for Ganeti (http://code.google.com/p/ganeti). It will install a minimal version of Debian or Ubuntu via debootstrap (thus it requires network access). This only works if you have a Debian-based node or you have debootstrap installed by hand on another distribution. Installation ------------ In order to install this package from source, you need to determine what options ganeti itself has been configured with. If ganeti was built directly from source, then the only place it looks for OS definitions is ``/srv/ganeti/os``, and you need to install the OS under it:: ./configure --prefix=/usr --localstatedir=/var \ --sysconfdir=/etc \ --with-os-dir=/srv/ganeti/os make && make install If ganeti was installed from a package, its default OS path should already include /usr/share/ganeti/os, so you can just run:: ./configure -prefix=/usr --localstatedir=/var \ --sysconfdir=/etc make && make install Note that you need to repeat this procedure on all nodes of the cluster. The actual path that ganeti has been installed with can be determined by looking for a file named _autoconf.py under a ganeti directory in the python modules tree (e.g. ``/usr/lib/python2.4/site-packages/ganeti/_autoconf.py``). In this file, a variable named OS_SEARCH_PATH will list all the directories in which ganeti will look for OS definitions. Configuration of instance creation ---------------------------------- Note: the minimum disk size accepted is 256MB, as ``debootstrap`` requires disk space both for downloading the packages and installing them. The kind of instance created can be customized via a settings file. This file is not installed by default, as the instance creation will work without it. The creation scripts will look for it in ``$sysconfdir/default/ganeti-instance-debootstrap``, so if you have run configure with the parameter ``--sysconfdir=/etc``, the final filename will be ``/etc/default/ganeti-instance-debootstrap``. The following settings will be examined in this file (see also the file named 'defaults' in the source distribution for more details): - PROXY: http proxy to use for non-cached installs - MIRROR: the mirror to use if not the default one - ARCH: either i386 or amd64, otherwise your current architecture will be used - SUITE: the actual OS to be installed; the current default is Debian *wheezy*, and you can choose any of the OSes supported deboostrap (on Debian, look into /usr/share/deboostrap/scripts) - EXTRAPKGS: most OSes will need some extra packages installed to make them work nicely under Xen; the example file containts a few suggestions - COMPONENTS: if defined, overrides the default debootstrap components ("main"); this can be helpful e.g. by using "main,contrib,nonfree" for Debian, or "main,universe" for Ubuntu - CUSTOMIZE_DIR: a directory containing customization script for the instance. (by default $sysconfdir/ganeti/instance-debootstrap/hooks) See "Customization of the instance" below. - GENERATE_CACHE: if 'yes' (the default), the installation process will save and reuse a cache file to speed reinstalls (located under $localstatedir/cache/ganeti-instance-debootstrap) - CLEAN_CACHE: if empty, the cached files will never be cleaned and thus the installation will definitely need to be updated after install; otherwise, the value of this variable will be taken as the number of days after which to remove the cache file; the default is 14 (two weeks) - PARTITION_STYLE: if 'none' the device will be formatted directly, if 'msdos' a partition table will be installed on it. You need to have kpartx installed to use the 'msdos' option. The default is 'msdos' from Ganeti 2.0 onwards, but still 'none' if installing under Ganeti 1.2 Note that the settings file is important on the node that the instance is installed on, not the cluster master. This is indeed not a very good model of using this OS but currently the OS interface in ganeti is limiting. Creating OS variants -------------------- Every Ganeti OS supports variants, so it's possible to define custom OS variants with instance-debootstrap as well. First, an additional variant has to be defined in ``$osdir/debootstrap/variants.list`` (with ``$osdir`` being ``/usr/share/ganeti/os`` by default). Secondly, you can configure this instance variant in ``$sysconfdir/ganeti/instance-debootstrap/variants/$variant.conf``, overriding the settings mentioned in the previous section. To use the newly created instance variant, specify it in ``gnt-instance`` like this:: gnt-instance add -o debootstrap+precise ... Example +++++++ To create a Ubuntu 12.04 (precise) instance variant, add the following to ``$osdir/debootstrap/variants.list``:: precise Now create the file ``$sysconfdir/ganeti/instance-debootstrap/variants/precise.conf`` with the following content:: MIRROR="http://archive.ubuntu.com/ubuntu/" SUITE="precise" COMPONENTS="main,universe" ARCH="amd64" You can create Ubuntu 12.04 instances as follows:: gnt-instance add -t plain -o debootstrap+precise --disk 0:size=10000m -n node1.example.com instance1.example.com For this to work, make sure that you have the appropriate debootstrap script for precise (or just create a symlink called ``precise`` to ``gutsy`` in ``/usr/share/debootstrap/scripts``). Instance creation parameters ---------------------------- Some aspects of the created instance can be conrolled via parameters at instance creation time with the ``-O`` parameter of ``gnt-instance``. The supported parameters are: - filesystem: the filesystem type to use for the root partition. This has to be a filesystem type supported by ``mke2fs``. The default is 'ext4'. Customization of the instance ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If run-parts is in the os create script, and the CUSTOMIZE_DIR (by default $sysconfdir/ganeti/instance-debootstrap/hooks, /etc/ganeti/instance-debootstrap/hooks if you configured the os with --sysconfdir=/etc) directory exists any executable whose name matches the run-parts execution rules (quoting run-parts(8): the names must consist entirely of upper and lower case letters, digits, underscores, and hyphens) is executed to allow further personalization of the installation. The following environment variables are passed, in addition to the ones ganeti passes to the OS scripts: TARGET: directory in which the filesystem is mounted SUITE: suite installed by debootstrap (eg: wheezy) ARCH: target architecture PARTITION_STYLE: style of the disk partitioning (see above) EXTRA_PKGS: extra packages installed by debootstrap BLOCKDEV: ganeti block device FSYSDEV: device in which the filesystem resides (the one mounted in TARGET) The scripts in CUSTOMIZE_DIR can exit with an error code to signal an error in the instance creation, should they fail. The scripts in CUSTOMIZE_DIR should not start any long-term processes or daemons using this directory, otherwise the installation will fail because it won't be able to umount the filesystem from the directory, and hand the instance back to Ganeti. Example +++++++ The root password can be automatically set when the instance is created. In order to do this, the ``examples/hooks/defaultpasswords`` file has to be copied to ``$sysconfdir/ganeti/instance-debootstrap/hooks/``, and its data file ``examples/hooks/confdata/defaultpasswords`` has to be copied to ``$sysconfdir/ganeti/instance-debootstrap/hooks/confdata/`` and modified accordingly to one's own need. The file syntax is such that each line represent a user, with the format:: username:password After copying the two files, just running the instance creation as usual will automatically cause their execution. Caching ~~~~~~~ As described above, the install process uses a cache file in order to speed up repeated installs. If you only rarely do installs, this will not matter to you, but if you want to install 10 instances in a row, the difference will be visible. The default settings are to generate a cache, and to clean it up after two weeks. Note that the cache will use one file per architecture per suite, so if you install multiple suites there might be a non-trivial amount of space used in the cache directory. It is safe to remove manually the files. It is also possible, if done with care, to modify and regenerate the cache file (which is simply a tar archive) in order to preseed your installs with site-specific customizations. Instance notes -------------- The instance is a minimal install: - it has no password for root; simply login at the console - it has no network interfaces defined (besides lo); add your own definitions to /etc/network/interfaces - after configuring the network, it is recommended to run ``apt-get update`` so that signatures for the release files are picked up .. vim: set textwidth=72 : .. Local Variables: .. mode: rst .. fill-column: 72 .. End: ganeti-instance-debootstrap-0.16/autogen.sh000077500000000000000000000004561272325602300210450ustar00rootroot00000000000000#!/bin/sh if test ! -f configure.ac ; then echo "You must execute this script from the top level directory." exit 1 fi set -e rm -rf config.cache autom4te.cache mkdir -p autotools ${ACLOCAL:-aclocal} -I autotools ${AUTOCONF:-autoconf} ${AUTOMAKE:-automake} --add-missing rm -rf autom4te.cache ganeti-instance-debootstrap-0.16/common.sh.in000066400000000000000000000145241272325602300212760ustar00rootroot00000000000000# # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. CLEANUP=( ) log_error() { echo "$@" >&2 } get_api5_arguments() { GETOPT_RESULT=$* # Note the quotes around `$TEMP': they are essential! eval set -- "$GETOPT_RESULT" while true; do case "$1" in -i|-n) instance=$2; shift 2;; -o) old_name=$2; shift 2;; -b) blockdev=$2; shift 2;; -s) swapdev=$2; shift 2;; --) shift; break;; *) log_error "Internal error!" >&2; exit 1;; esac done if [ -z "$instance" -o -z "$blockdev" ]; then log_error "Missing OS API Argument (-i, -n, or -b)" exit 1 fi if [ "$SCRIPT_NAME" != "export" -a -z "$swapdev" ]; then log_error "Missing OS API Argument -s (swapdev)" exit 1 fi if [ "$SCRIPT_NAME" = "rename" -a -z "$old_name" ]; then log_error "Missing OS API Argument -o (old_name)" exit 1 fi } get_api10_arguments() { if [ -z "$INSTANCE_NAME" -o -z "$HYPERVISOR" -o -z "$DISK_COUNT" ]; then log_error "Missing OS API Variable:" log_error "(INSTANCE_NAME HYPERVISOR or DISK_COUNT)" exit 1 fi instance=$INSTANCE_NAME if [ $DISK_COUNT -lt 1 -o -z "$DISK_0_PATH" ]; then log_error "At least one disk is needed" exit 1 fi if [ "$SCRIPT_NAME" = "export" ]; then if [ -z "$EXPORT_DEVICE" ]; then log_error "Missing OS API Variable EXPORT_DEVICE" fi blockdev=$EXPORT_DEVICE elif [ "$SCRIPT_NAME" = "import" ]; then if [ -z "$IMPORT_DEVICE" ]; then log_error "Missing OS API Variable IMPORT_DEVICE" fi blockdev=$IMPORT_DEVICE else blockdev=$DISK_0_PATH fi if [ "$SCRIPT_NAME" = "rename" -a -z "$OLD_INSTANCE_NAME" ]; then log_error "Missing OS API Variable OLD_INSTANCE_NAME" fi old_name=$OLD_INSTANCE_NAME } format_disk0() { # Create one big partition, and make it bootable. local ARGS # Some versions of sfdisk need manual specification of head/sectors # for devices such as drbd which don't report geometry. if sfdisk --help | grep -q -e '--cylinders'; then ARGS="-H 64 -S 32 -u S --Linux" fi sfdisk $ARGS --quiet "$1" < /dev/null filesystem_dev="/dev/mapper/$filesystem_dev_base" if [ ! -b "$filesystem_dev" ]; then log_error "Can't find kpartx mapped partition: $filesystem_dev" exit 1 fi echo "$filesystem_dev" } unmap_disk0() { kpartx -d -p- $1 } cleanup() { if [ ${#CLEANUP[*]} -gt 0 ]; then LAST_ELEMENT=$((${#CLEANUP[*]}-1)) REVERSE_INDEXES=$(seq ${LAST_ELEMENT} -1 0) for i in $REVERSE_INDEXES; do ${CLEANUP[$i]} done fi } trap cleanup EXIT DEFAULT_FILE="@sysconfdir@/default/ganeti-instance-debootstrap" if [ -f "$DEFAULT_FILE" ]; then . "$DEFAULT_FILE" fi # note: we don't set a default mirror since debian and ubuntu have # different defaults, and it's better to use the default # only if the user want to specify a mirror in the defaults file we # will use it, this declaration is to make sure the variable is set : ${MIRROR:=""} : ${PROXY:=""} : ${SUITE:="jessie"} : ${ARCH:=""} : ${EXTRA_PKGS:=""} : ${COMPONENTS:=""} : ${CUSTOMIZE_DIR:="@sysconfdir@/ganeti/instance-debootstrap/hooks"} : ${VARIANTS_DIR:="@sysconfdir@/ganeti/instance-debootstrap/variants"} : ${GENERATE_CACHE:="yes"} : ${CLEAN_CACHE:="14"} # number of days to keep a cache file : ${PARTITION_ALIGNMENT:=2048} # sectors to align partition (1Mib default) if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then DEFAULT_PARTITION_STYLE="none" else DEFAULT_PARTITION_STYLE="msdos" fi : ${PARTITION_STYLE:=$DEFAULT_PARTITION_STYLE} # disk partition style : ${OSP_FILESYSTEM:="ext4"} CACHE_DIR="@localstatedir@/cache/ganeti-instance-debootstrap" SCRIPT_NAME=$(basename $0) if [ -f /sbin/blkid -a -x /sbin/blkid ]; then VOL_ID="/sbin/blkid -o value -s UUID" VOL_TYPE="/sbin/blkid -o value -s TYPE" else for dir in /lib/udev /sbin; do if [ -f $dir/vol_id -a -x $dir/vol_id ]; then VOL_ID="$dir/vol_id -u" VOL_TYPE="$dir/vol_id -t" fi done fi if [ -z "$VOL_ID" ]; then log_error "vol_id or blkid not found, please install udev or util-linux" exit 1 fi if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then OS_API_VERSION=5 GETOPT_RESULT=`getopt -o o:n:i:b:s: -n '$0' -- "$@"` if [ $? != 0 ] ; then log_error "Terminating..."; exit 1 ; fi get_api5_arguments $GETOPT_RESULT elif [ "$OS_API_VERSION" = "10" -o "$OS_API_VERSION" = "15" -o \ "$OS_API_VERSION" = "20" ]; then get_api10_arguments else log_error "Unknown OS API VERSION $OS_API_VERSION" exit 1 fi if [ -n "$OS_VARIANT" ]; then if [ ! -d "$VARIANTS_DIR" ]; then log_error "OS Variants directory $VARIANTS_DIR doesn't exist" exit 1 fi VARIANT_CONFIG="$VARIANTS_DIR/$OS_VARIANT.conf" if [ -f "$VARIANT_CONFIG" ]; then . "$VARIANT_CONFIG" else if grep -qxF "$OS_VARIANT" variants.list; then log_error "ERROR: instance-debootstrap configuration error" log_error " Published variant $OS_VARIANT is missing its config file" log_error " Please create $VARIANT_CONFIG or unpublish the variant" log_error " (by removing $OS_VARIANT from variants.list)" else log_error "Unofficial variant $OS_VARIANT is unsupported" log_error "Most probably this is a user error, forcing a wrong name" log_error "To support this variant please create file $VARIANT_CONFIG" fi exit 1 fi fi ganeti-instance-debootstrap-0.16/configure.ac000066400000000000000000000027451272325602300213350ustar00rootroot00000000000000AC_PREREQ(2.59) AC_INIT(ganeti-instance-debootstrap, 0.16, ganeti@googlegroups.com) AC_CONFIG_AUX_DIR(autotools) AC_CONFIG_SRCDIR(configure) AM_INIT_AUTOMAKE([1.11 foreign tar-ustar -Wall -Wno-portability]) # --with-os-dir=... AC_ARG_WITH([os-dir], [AS_HELP_STRING([--with-os-dir=DIR], [top-level OS directory under which to install] [ (default is $datadir/ganeti/os)] )], [os_dir="$withval"], [os_dir="$datadir/ganeti/os"]) AC_SUBST(OS_DIR, $os_dir) # Check common programs AC_PROG_INSTALL AC_PROG_LN_S # Check for the required programs ROOT_PATH=[$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin]dnl [$PATH_SEPARATOR/usr/local/sbin] AC_ARG_VAR(KPARTX, [kpartx path]) AC_PATH_PROG(KPARTX, [kpartx], [], [$ROOT_PATH]) if test -z "$KPARTX" then AC_MSG_ERROR([kpartx command not found]) fi AC_ARG_VAR(LOSETUP, [losetup path]) AC_PATH_PROG(LOSETUP, [losetup], [], [$ROOT_PATH]) if test -z "$LOSETUP" then AC_MSG_ERROR([losetup command not found]) fi AC_ARG_VAR(DEBOOTSTRAP, [debootstrap path]) AC_PATH_PROG(DEBOOTSTRAP, [debootstrap], [], [$ROOT_PATH]) if test -z "$DEBOOTSTRAP" then AC_MSG_ERROR([debootstrap command not found]) fi AC_ARG_VAR(DUMP, [dump path]) AC_PATH_PROG(DUMP, [dump], [], [$ROOT_PATH]) if test -z "$DUMP" then AC_MSG_ERROR([dump command not found]) fi AC_ARG_VAR(RESTORE, [restore path]) AC_PATH_PROG(RESTORE, [restore], [], [$ROOT_PATH]) if test -z "$RESTORE" then AC_MSG_ERROR([restore command not found]) fi AC_CONFIG_FILES([ Makefile ]) AC_OUTPUT ganeti-instance-debootstrap-0.16/create000077500000000000000000000127171272325602300202400ustar00rootroot00000000000000#!/bin/bash # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. set -e # minimum device size is 512 MB, but we use 511 to account for # potential rounding declare -ri MIN_DEV_SIZE=$((511*1048576)) . common.sh if [ "$GENERATE_CACHE" = "yes" -a ! -d "$CACHE_DIR" ]; then mkdir -p "$CACHE_DIR" fi DPKG_ARCH=${ARCH:-`dpkg --print-architecture`} CACHE_FILE="$CACHE_DIR/cache-${SUITE}-${DPKG_ARCH}.tar" # If the target device is not a real block device we'll first losetup it. # This is needed for file disks. if [ ! -b $blockdev ]; then ORIGINAL_BLOCKDEV=$blockdev blockdev=$(losetup --show -f $blockdev) CLEANUP+=("losetup -d $blockdev") CLEANUP+=("udevadm settle") fi DEVICE_SIZE=$(blockdev --getsize64 $blockdev) if [ "$DEVICE_SIZE" -lt $MIN_DEV_SIZE ]; then echo "Device size is too small ($((DEVICE_SIZE/1048576)) MB)" 1>&2 echo "Required size is at least 256MB" 1>&2 exit 1 fi if [ "$PARTITION_STYLE" = "none" ]; then filesystem_dev=$blockdev elif [ "$PARTITION_STYLE" = "msdos" ]; then # Create one big partition, and make it bootable format_disk0 $blockdev filesystem_dev=$(map_disk0 $blockdev) CLEANUP+=("unmap_disk0 $blockdev") else echo "Unknown partition style $PARTITION_STYLE" 1>&2 exit 1 fi mke2fs -Fjqt $OSP_FILESYSTEM $filesystem_dev root_uuid=$($VOL_ID $filesystem_dev ) if [ -n "$swapdev" ]; then mkswap $swapdev swap_uuid=$($VOL_ID $swapdev || true ) fi TMPDIR=`mktemp -d` || exit 1 CLEANUP+=("rmdir $TMPDIR") mount $filesystem_dev $TMPDIR CLEANUP+=("umount $TMPDIR") # remove the cache file if it's old (> 2 weeks) and writable by the owner (the # default due to the standard umask) if [ "$CLEAN_CACHE" -a -d "$CACHE_DIR" ]; then find "$CACHE_DIR" -name 'cache-*.tar' -type f \ -daystart -mtime "+${CLEAN_CACHE}" -print0 | \ xargs -r0 rm -f fi if [ -f "$CACHE_FILE" ]; then tar xf "$CACHE_FILE" -C $TMPDIR else if [ "$PROXY" ]; then export http_proxy="$PROXY" export https_proxy="$PROXY" fi # INCLUDE will be empty if EXTRA_PKGS is null/empty, otherwise we # build the full parameter format from it INCLUDE=${EXTRA_PKGS:+"--include=$EXTRA_PKGS"} COMP=${COMPONENTS:+"--components=$COMPONENTS"} debootstrap \ --arch "$DPKG_ARCH" \ $INCLUDE \ $COMP \ "$SUITE" $TMPDIR $MIRROR # remove the downloaded debs, as they are no longer needed find "$TMPDIR/var/cache/apt/archives" -type f -name '*.deb' -print0 | \ xargs -r0 rm -f # remove the persistent-net rules, otherwise it will remember the node's # interfaces as eth0, eth1, ... rm -f "$TMPDIR/etc/udev/rules.d/z25_persistent-net.rules" if [ "$GENERATE_CACHE" = "yes" ]; then TMP_CACHE=`mktemp "${CACHE_FILE}.XXXXXX"` tar cf "$TMP_CACHE" -C $TMPDIR . mv -f "$TMP_CACHE" "$CACHE_FILE" fi fi # reset the root password chroot $TMPDIR passwd -d root cp -p /etc/hosts $TMPDIR/etc/hosts cp -p /etc/resolv.conf $TMPDIR/etc/resolv.conf echo $instance > $TMPDIR/etc/hostname echo $instance > $TMPDIR/etc/mailname cat > $TMPDIR/etc/fstab < UUID=$root_uuid / $OSP_FILESYSTEM defaults 0 1 proc /proc proc defaults 0 0 EOF [ -n "$swapdev" -a -n "$swap_uuid" ] && cat >> $TMPDIR/etc/fstab < $TMPDIR/etc/network/interfaces <> $TMPDIR/etc/inittab elif [ -e $TMPDIR/etc/init ]; then # ubuntu (eg. karmic) cat > $TMPDIR/etc/init/${SERIAL_PORT}.conf < $TMPDIR/etc/event.d/${SERIAL_PORT}.conf <" >&2 exit 1 fi echo "Using Git repository $URL" TMPDIR=$(mktemp -d -t gntrelease.XXXXXXXXXX) cd $TMPDIR echo "Cloning the repository under $TMPDIR ..." git clone -q "$URL" dist cd dist git checkout $TAG ./autogen.sh ./configure VERSION=$(sed -n -e '/^PACKAGE_VERSION =/ s/^PACKAGE_VERSION = // p' Makefile) make distcheck fakeroot make dist tar tzvf ganeti-instance-debootstrap-$VERSION.tar.gz echo echo 'MD5:' md5sum ganeti-instance-debootstrap-$VERSION.tar.gz echo echo 'SHA1:' sha1sum ganeti-instance-debootstrap-$VERSION.tar.gz echo echo "The archive is at $PWD/ganeti-instance-debootstrap-$VERSION.tar.gz" echo "Please copy it and remove the temporary directory when done." ganeti-instance-debootstrap-0.16/devel/upload000077500000000000000000000026551272325602300213600ustar00rootroot00000000000000#!/bin/bash # Copyright (C) 2006, 2007 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # This is a test script to ease development and testing on test clusters. # It should not be used to update production environments. # Usage: upload node-{1,2,3} set -e hosts= while [ "$#" -gt 0 ]; do opt="$1" case "$opt" in -h|--help) echo "Usage: $0 hosts..." exit 0 ;; -*) echo "Unknown option: $opt" >&2 exit 1 ;; *) hosts="$hosts $opt" ;; esac shift done set ${hosts} TXD=`mktemp -d` trap 'rm -rf $TXD' EXIT # install the os as a real tree make install DESTDIR="$TXD" echo --- ( cd "$TXD" && find; ) echo --- for host; do echo Uploading code to ${host}... rsync -v -rlDc ${TXD}/* root@${host}:/ & done wait ganeti-instance-debootstrap-0.16/examples/000077500000000000000000000000001272325602300206555ustar00rootroot00000000000000ganeti-instance-debootstrap-0.16/examples/hooks/000077500000000000000000000000001272325602300220005ustar00rootroot00000000000000ganeti-instance-debootstrap-0.16/examples/hooks/confdata/000077500000000000000000000000001272325602300235575ustar00rootroot00000000000000ganeti-instance-debootstrap-0.16/examples/hooks/confdata/defaultpasswords000066400000000000000000000000141272325602300270670ustar00rootroot00000000000000root:s3cr3t ganeti-instance-debootstrap-0.16/examples/hooks/confdata/timezone000066400000000000000000000000201272325602300253240ustar00rootroot00000000000000Europe/Brussels ganeti-instance-debootstrap-0.16/examples/hooks/defaultpasswords000077500000000000000000000004551272325602300253240ustar00rootroot00000000000000#!/bin/sh # # This is an example script that sets the root pasword to a given # default. # Note: depending on your version of passwd, chpasswd can use the -e # flag to handle en encrypted password. you probably want to use that. cat $(dirname $0)/confdata/defaultpasswords | chroot $TARGET chpasswd ganeti-instance-debootstrap-0.16/examples/hooks/grub000077500000000000000000000023041272325602300226640ustar00rootroot00000000000000#!/bin/bash # # This is an example script that install and configure grub after installation. # To use it put it in your CUSTOMIZE_DIR and make it executable. # # Do not include grub in EXTRA_PKGS of # $sysconfdir/default/ganeti-instance-debootstrap because it will # cause error of debootstrap. set -e . common.sh CLEANUP=( ) trap cleanup EXIT if [ -z "$TARGET" -o ! -d "$TARGET" ]; then echo "Missing target directory" exit 1 fi # install grub export LANG=C if [ "$PROXY" ]; then export http_proxy="$PROXY" export https_proxy="$PROXY" fi export DEBIAN_FRONTEND=noninteractive chroot "$TARGET" apt-get -y --force-yes install grub grub-common # make /dev/sda mknod $TARGET/dev/sda b $(stat -L -c "0x%t 0x%T" $BLOCKDEV) CLEANUP+=("rm -f $TARGET/dev/sda") # make /dev/sda1 mknod $TARGET/dev/sda1 b $(stat -L -c "0x%t 0x%T" $FSYSDEV) CLEANUP+=("rm -f $TARGET/dev/sda1") # create grub directory mkdir -p "$TARGET/boot/grub" # create device.map cat > "$TARGET/boot/grub/device.map" <> $TARGET/etc/host ganeti-instance-debootstrap-0.16/examples/hooks/interfaces000077500000000000000000000027521272325602300240570ustar00rootroot00000000000000#!/bin/bash # Copyright (C) 2009 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # This is an example script that configures you /etc/network/interfaces after # installation. By default its sets up the system to use dhcp. To use it just # put it in your CUSTOMIZE_DIR and make it executable. if [ -z "$TARGET" -o ! -d "$TARGET" ]; then echo "Missing target directory" exit 1 fi if [ ! -d "$TARGET/etc/network" ]; then echo "Missing target network directory" exit 1 fi if [ -z "$NIC_COUNT" ]; then echo "Missing NIC COUNT" exit 1 fi if [ "$NIC_COUNT" -gt 0 ]; then cat > $TARGET/etc/network/interfaces <&2 exit 1 fi # execute cleanups cleanup trap - EXIT exit 0 ganeti-instance-debootstrap-0.16/ganeti_api_version000066400000000000000000000000131272325602300226210ustar00rootroot0000000000000020 15 10 5 ganeti-instance-debootstrap-0.16/import000077500000000000000000000046221272325602300203030ustar00rootroot00000000000000#!/bin/bash # Copyright (C) 2007, 2008, 2009 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. set -e . common.sh # If the target device is not a real block device we'll first losetup it. # This is needed for file disks. if [ ! -b $blockdev ]; then ORIGINAL_BLOCKDEV=$blockdev blockdev=$(losetup --show -f $blockdev) CLEANUP+=("losetup -d $blockdev") fi if [ "$PARTITION_STYLE" = "none" ]; then filesystem_dev=$blockdev elif [ "$PARTITION_STYLE" = "msdos" ]; then # Create one big partition, and make it bootable format_disk0 $blockdev filesystem_dev=$(map_disk0 $blockdev) CLEANUP+=("unmap_disk0 $blockdev") else echo "Unknown partition style $PARTITION_STYLE" exit 1 fi mke2fs -Fjqt $OSP_FILESYSTEM $filesystem_dev root_uuid=$($VOL_ID $filesystem_dev ) if [ -n "$swapdev" ]; then mkswap $swapdev swap_uuid=$($VOL_ID $swapdev || true ) fi TMPDIR=`mktemp -d` || exit 1 CLEANUP+=("rmdir $TMPDIR") mount $filesystem_dev $TMPDIR CLEANUP+=("umount $TMPDIR") ( cd $TMPDIR; restore -r -y -f - ) rm -f $TMPDIR/etc/udev/rules.d/z*_persistent-net.rules # Fix /etc/fstab with the new volumes' UUIDs if [ -e $TMPDIR/etc/fstab ]; then ROOT_LINE="UUID=$root_uuid / $OSP_FILESYSTEM defaults 0 1" if [ -n "$swapdev" -a -n "$swap_uuid" ]; then SWAP_LINE="UUID=$swap_uuid swap swap defaults 0 0" cat $TMPDIR/etc/fstab | \ sed -re "s#^(/dev/sda|UUID=[a-f0-9-]+)\s+/\s+.*\$#$ROOT_LINE#" \ -e "s#^(/dev/sdb|UUID=[a-f0-9-]+)\s+swap\s+.*\$#$SWAP_LINE#" \ > $TMPDIR/etc/fstab.new else cat $TMPDIR/etc/fstab | \ sed -re "s#^(/dev/sda|UUID=[a-f0-9-]+)\s+/\s+.*\$#$ROOT_LINE#" \ > $TMPDIR/etc/fstab.new fi mv $TMPDIR/etc/fstab.new $TMPDIR/etc/fstab fi # execute cleanups cleanup trap - EXIT exit 0 ganeti-instance-debootstrap-0.16/parameters.list000066400000000000000000000002171272325602300220770ustar00rootroot00000000000000filesystem The filesystem type to use for the root partition. This has to be a filesystem type supported by ``mke2fs``. The default is 'ext4'. ganeti-instance-debootstrap-0.16/rename000077500000000000000000000037321272325602300202410ustar00rootroot00000000000000#!/bin/bash # Copyright (C) 2007, 2008, 2009 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. set -e . common.sh TMPDIR=`mktemp -d` || exit 1 CLEANUP+=("rmdir $TMPDIR") # If the target device is not a real block device we'll first losetup it. # This is needed for file disks. if [ ! -b $blockdev ]; then ORIGINAL_BLOCKDEV=$blockdev blockdev=$(losetup --show -f $blockdev) CLEANUP+=("losetup -d $blockdev") fi if [ "$PARTITION_STYLE" = "none" ]; then filesystem_dev=$blockdev elif [ "$PARTITION_STYLE" = "msdos" ]; then filesystem_dev=$(map_disk0 $blockdev) CLEANUP+=("unmap_disk0 $blockdev") else echo "Unknown partition style $PARTITION_STYLE" exit 1 fi mount $filesystem_dev $TMPDIR CLEANUP+=("umount $TMPDIR") HNAME="$TMPDIR/etc/hostname" MNAME="$TMPDIR/etc/mailname" # for hostname, we raise and error if the old hostname is not what we # expect OLD_HNAME="`cat $HNAME`" if [ "$OLD_HNAME" = "$old_name" ]; then echo $instance > $HNAME else log_error "Cannot rename from $old_name to $instance:" log_error "Instance has a different hostname ($OLD_HNAME)" exit 1 fi # for mailname, we rename only if it has the old name, otherwise we # ignore it (and assumme that it's a customized name) if [ "`cat $MNAME`" = "$old_name" ]; then echo $instance > $MNAME fi # execute cleanups cleanup trap - EXIT exit 0 ganeti-instance-debootstrap-0.16/test/000077500000000000000000000000001272325602300200165ustar00rootroot00000000000000ganeti-instance-debootstrap-0.16/test/install-export-import000077500000000000000000000027561272325602300242530ustar00rootroot00000000000000#!/bin/bash set -eu if [ $(id -u) != 0 ]; then echo "Testing requires root due to losetup/kpartx usage" 2>&1 exit 77 fi TEMPDIR=$(mktemp -d) trap 'rm -rf "$TEMPDIR"' EXIT DISK0="$TEMPDIR/disk0" dd if=/dev/zero of="$DISK0" bs=1024k count=512 DUMP="$TEMPDIR/dump" # check that we can actually run losetup, otherwise we might be under # fakeroot, for example; include sbin* dirs in PATH to ensure we don't # fail due to command not found. PATH=$PATH:/sbin:/usr/sbin LOOP=$(losetup --show -f "$DISK0") || \ { echo "losetup doesn't work, skipping test" 2>&1 ; exit 77; } losetup -d "$LOOP" echo "Installing instance..." GENERATE_CACHE=no \ CLEAN_CACHE="" \ OS_API_VERSION=10 \ INSTANCE_NAME=foo.example.com \ HYPERVISOR=dont-care \ DISK_COUNT=1 \ DISK_0_PATH="$DISK0" \ $srcdir/create echo "Exporting instance..." OS_API_VERSION=10 \ INSTANCE_NAME=foo.example.com \ HYPERVISOR=dont-care \ DISK_COUNT=1 \ DISK_0_PATH="$DISK0" \ EXPORT_DISK_PATH="$DISK0" \ EXPORT_DEVICE="$DISK0" \ EXPORT_INDEX=0 \ $srcdir/export > "$DUMP" echo "Importing instance..." # first wipe the disk. dd if=/dev/zero of="$DISK0" bs=1024k count=512 OS_API_VERSION=10 \ INSTANCE_NAME=foo.example.com \ HYPERVISOR=dont-care \ DISK_COUNT=1 \ DISK_0_PATH="$DISK0" \ IMPORT_DISK_PATH="$DISK0" \ IMPORT_DEVICE="$DISK0" \ IMPORT_INDEX=0 \ $srcdir/import < "$DUMP" # Do a listing of the directory (to see the size of the dump, a proxy # for the needed install space). ls -l -h "$TEMPDIR" ganeti-instance-debootstrap-0.16/variants.list000066400000000000000000000000101272325602300215520ustar00rootroot00000000000000default ganeti-instance-debootstrap-0.16/verify000077500000000000000000000016641272325602300203000ustar00rootroot00000000000000#!/bin/bash # Copyright (C) 2007, 2008, 2009 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. set -e case $OSP_FILESYSTEM in ""|"ext2"|"ext3"|"ext4") ;; *) echo "Invalid value '$OSP_FILESYSTEM' for the filesystem parameter" 1>&2 exit 1 ;; esac exit 0