Commit ab84eacf authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Merge branch 'master' into debian

parents 626270a6 3a4b6bbb
2013-09-23, v0.10.1
* Merge the ChangeLog files of snf-image and snf-image-helper
* Add version check in snf-image-update-helper
* Remove HELPER_URL from
2013-09-19, v0.10
* Move the snf-image-helper image from squeeze to wheezy
* Add documentations under /docs
* Fix a bug in the network back-end
2013-09-02, v0.9.3
* Add code to download and install a fixed snf-image-helper image. This is the default
behaviour for snf-image-update-helper.
......@@ -12,6 +22,7 @@
2013-04-23, v0.9
* Add support for FreeBSD images
* HELPER: Fix a few bugs in the helper monitoring system
2013-03-12, v0.8.1
* Fix a bug in
......@@ -24,9 +35,14 @@
* Increase the default HELPER_SIZE and TIMEOUT values
* Cleanup the code and remove settings no longer used
* Rename snf-image-host to snf-image
* HELPER: Add support for xen
* HELPER: Cleanup the helper code
2013-01-21, v0.7.6
* Make the size of the helper VM image configurable
* HELPER: Mount /proc and /dev before chrooting
* HELPER: Fix a bug in DeleteSSHKeys task where the code for checking for
non-default keys was never called.
2013-01-17, v0.7.5
* Cleanup defaults file and remove redundant variables
......@@ -34,15 +50,27 @@
passed with ./configure
2013-01-08, v0.7.4
* HELPER: Fix a bug in the code that determines which partition to resize
* HELPER: On linux images, mount all local partition during deployment. Not
just /.
2013-01-04, v0.7.3
* Fix multistrap.conf to work with
2013-01-04, v0.7.2
* Change snf-image-helper repository to
* HELPER: In windows images make sure the file C:\Window\panther\Unattend.xml
gets removed after sysprep runs
* HELPER: Support extended partitions with id 0x0f
* HELPER: Fix a bug in the error monitoring system
* HELPER: Fix a bug in AssignHostname for archlinux images
* HELPER: In AssignHostname check for the presence of /etc/hostname before
trying to determine the disto of a Linux image.
2012-12-07, v0.7.1
* Make pithcat work with pithosmap URLs
* HELPER: Fix a race condition where in some cases could lead to a kernel
panic for the helper VM.
2012-12-03, v0.7
* Abandon debootstrap in favor of multistrap. This way we can define
......@@ -56,8 +84,16 @@
local file system using the -p variable.
* Specify snf-image-helper as the init process when running the helper
* HELPER: Make snf-image-helper the init process of the system
* HELPER: Shutdown the helper image fast using the apropriate SysRq key
* HELPER: Use eatmydata to omit the syncs performed by resize2fs when
resizing a file system. You can supress this behaviour by defining
the DO_SYNC image property.
2012-11-20, v0.6.5
* HELPER: Fix a bug in AssignHostname configuration task where the script did
not search for the presence of the Unattend.xml file in the VM, in
a case-insensitive way
2012-11-15, v0.6.4
* Fix a bug in snf-image-update-helper introduced in v0.6.3
......@@ -65,11 +101,18 @@
2012-11-13, v0.6.3
* Fix a bug in snf-image-update-helper where the temporary image file
was not removed if an error occured.
* HELPER: Don't overwrite C:\Unattend.xml file in windows images, unless the
image property USE_DEFAULT_UNATTEND is defined.
* HELPER: Fix a bug in the error monitoring system
* HELPER: Correct some error messages
2012-10-12, v0.6.2
* Seperate the error messages that should be logged by the system from
those that should be propagated to the user through the monitoring
mechanism. Don't allow internal configuration options get revieled to
* HELPER: Remove the rule of updating the password for user `user' in Fedora
and Ubuntu when the USERS image property is missing.
* HELPER: Check if a user exists before updating its password.
the user.
2012-10-05, v0.6.1
......@@ -84,6 +127,9 @@
* Fix import and export scripts
* Add new config_url os parameter. This can be used by snf-image to
download a json file that contains the value for other os parameters
* HELPER: Make sure EnforcePersonality is the last task that runs before
UmountImage. Doing this ensures that user-enjected files never
get overwritten by any other configuration task.
2012-08-31, v0.5
* Add a new progress monitoring mechanism. With this new mechanism,
......@@ -94,10 +140,15 @@
* Add support for null image backend type. This backend type can be
used if we want snf-image to configure the VM disk without first
copying an image to it.
* HELPER: Add a new progress monitoring mechanish
* HELPER: Add support for arch linux
2012-06-29, v0.4.2
* HELPER: Make the name of image properties case-insensitive
2012-05-28, v0.4.1
* HELPER: Fix a bug in FixPartitionTable where in some cases the script
failed to create the logical swap partition.
2012-05-17, v0.4
* Remove progress-monitor-support flag. An external progress monitor
......@@ -110,6 +161,10 @@
performed. If a cache file is found, snf-update-helper will use this
list to determine if it is OK to use this cache file or not.
* Add mechanism for overwritting the helper's Unattend.xml file
* HELPER: Add support for creating SWAP partitions
* HELPER: Add support for GPT partition tables
* HELPER: Add support for resizing logical partitions
* HELPER: Add mechanism for overwritting Unattend.xml
2012-03-29, v0.3.6
* Make snf-image-update-helper ask whether to use the found deboostrap
......@@ -118,29 +173,43 @@
option is used and it's value does not point to a cache file.
2012-03-26, v0.3.5
* HELPER: Force Automatic Update in Windows images
2012-03-05, v0.3.4
* HELPER: Fix 2 bugs in Delete SSH Keys task, caused by the use of pipefail
bash option
2012-02-29, v0.3.3
* Fix a bug in pithcat where the restored image had incorrect
size. The trailing zeros in the image files where not restored.
* HELPER: Check if the images partition table is valid
2012-02-06, v0.3.2
* Make pithcat work with pithos v0.8.3
2012-01-26, v0.3.1
* HELPER: Fix a bug in the OS detection code
2011-01-12, v0.3
* Put all helpers run-time created files in a tmpfs jail
* Remove the ARCH field from the image name
* Support remote (network accessable) and pithos hosted images
* Remove custom images format (remote images is a supergroup)
* HELPER: Warn and in some cases fail if the instance is of an unknown
* HELPER: Force a resize when the filesystem is clean, even if resize2fs
* HELPER: Make sure OSFAMILY image property is specified
2011-11-18, v0.2
* Support diskdump format
* Support custom images format. Custom images are diskdump images
that can be accessed from a URL
* Add a new OS parameter (img_properties)
* HELPER: Add support for Image Properties
* HELPER: Add new FixPartitionTable task
* HELPER: Add new task that disables RDP connections during windows setup
* HELPER: Extend image personalization to support custom ownership and
permissions in the injected files
2011-10-20, v0.1.2
* Fix a debootstrap bug in snf-image-update-helper
......@@ -151,6 +220,8 @@
2011-10-17, v0.1.1
* Replace $(var) with ${var} in defaults file.
* Fix a dangerous-use-of-xargs bug in create.
* HELPER: Fix a bug in ChangePassword task
* HELPER: Add timestamps in output of the tasks
2011-10-04, v0.1
* Initial release
# Makefile for Sphinx documentation
# You can set these variables from the command line.
SPHINXBUILD = sphinx-build
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
-rm -rf $(BUILDDIR)/*
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
@echo "Build finished; now you can process the pickle files."
@echo "Build finished; now you can process the JSON files."
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/snf-image.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/snf-image.qhc"
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
"run these through (pdf)latex."
@echo "The overview file is in $(BUILDDIR)/changes."
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
Advanced Topics
Progress Monitoring Interface
*snf-image* has an embedded mechanism for transmitting progress messages during
an image deployment. A user may specify an external executable by overwriting
the *PROGRESS_MONITOR* variable under ``/etc/default/snf-image`` and
*snf-image* will redirect the progress messages to the standard input of this
program. In this section we will describe the format and the fields of the
progress messages.
The progress messages are json strings with standardized fields. All messages
have a **type** field whose value is a string and a **timestamp** field whose
value is a floating point number referring to a time encoded as the number of
seconds elapsed since the epoch. The rest of the field depend on the specific
This message type is used to display random progress information. It has an
extra *messages* field whose value is a list of strings. A valid ``image-info``
message looks like this:
``{"messages": ["Starting image copy..."], "type": "image-info", "timestamp": 1378914866.209169}``
This message type is used to display a fatal error that occurred during image
deployment. It may either have an extra *messages* field to display the error
message or an *stderr* field to display the last lines of the standard error
output stream of the OS creation script. Valid ``image-error`` messages look
like this:
``{"messages": ["Image customization failed."], "type": "image-error", "timestamp": 1379507045.924449}``
One of the tasks *snf-image* has to accomplish is to copy the image file into
the VM's hard disk before configuring it. Messages of type
``image-copy-progress`` are used to display the progress of this task. The extra
fields this message type has is *position*, *total* and *progress*. The
*position* field is used to display the number of bytes written to the hard
disk. The *total* field indicates the overall size (in bytes) of the image, and
finally the *progress* field indicates the percent of the accomplished work.
Messages of this type look like this:
``{"position": 335547996, "total": 474398720, "type": "image-copy-progress", "timestamp": 1378914869.312985, "progress": 70.73}``
This is a family of messages that are created when *snf-image-helper* runs.
Each message of this type has a *subtype* field.
Messages with *subtype* ``task-start`` indicate that *snf-image-helper*
started running a :ref:`configuration task <image-configuration-tasks>` on the
image. Messages of this type have an extra *task* field whose value is the
name of the task *snf-image-helper* started, and look like this:
``{"subtype": "task-start", "task": "FixPartitionTable", "type": "image-helper", "timestamp": 1379507040.456931}``
Messages with *subtype* ``task-stop`` are produced every time a configuration
task successfully exits. As with the ``task-start`` messages, the *task* field
is present:
``{"subtype": "task-end", "task": "FixPartitionTable", "type": "image-helper", "timestamp": 1379507041.357184}``
This messages are produced to display a warning. The actual warning message
itself is present in the *messages* field:
``{"subtype": "warning", "type": "image-helper", "messages": [" No swap partition defined"], "timestamp": 1379075807.71704}``
The last ``image-helper`` message that may occur is the ``error`` message. As
with the ``image-error`` messages, either a *messages* field that hosts the
actual error message or a *stderr* field that hosts the last 10 lines of the
standard error output stream of *snf-image-helper*. Valid *error* messages look
like this:
``{"subtype": "error", "type": "image-helper", "messages": ["The image contains a(n) msdos partition table. For FreeBSD images only GUID Partition Tables are supported."], "timestamp": 1379507910.799365}``
snf-image is split in two components: The main program running on the Ganeti
host with full root privilege (*snf-image* previously *snf-image-host*) and a
part running inside an unprivileged helper VM (*snf-image-helper*).
This part implements the Ganeti OS interface. It extracts the Image onto the
Ganeti-provided block device, using streaming block I/O (dd with oflag=direct),
then passes control to snf-image-helper running inside a helper VM. The helper
VM is created using KVM, runs as an unprivileged user, nobody by default.
There is no restriction on the distribution running inside the helper VM, as
long as it executes the snf-image-helper component automatically upon bootup.
The snf-image-update-helper script is provided with snf-image to automate the
creation of a helper VM image based on Debian Stable, using multistrap.
The snf-image-helper component is spawned inside a specific hardware
* The VM features a virtual floppy, containing an ext2 filesystem with all
parameters needed for image customization.
* The hard disk of the VM being deployed is accessible as the first virtio
hard disk.
* All kernel/console output is redirected to the first virtual serial console,
and eventually finds its way into the OS definition log files that Ganeti
* The helper VM is expected to output "SUCCESS" to its second serial port if
image customization was successful inside the VM.
* In any other case, execution of the helper VM or snf-image-helper has
* The helper VM is expected to shutdown automatically once it is done. Its
execution is time-limited; if it has not terminated after a number of
seconds, configurable via /etc/default/snf-image, it is sent a SIGTERM
and/or a SIGKILL.
KVM is currently a dependency for snf-image, meaning it is needed to spawn the
helper VM. There is no restriction on the hypervisor used for the actual Ganeti
instances. This is not a strict requirement; KVM could be replaced by qemu,
doing full CPU virtualization without any kernel support for spawning the
helper VM.
This part runs inside the helper VM and undertakes customization of the VM
being deployed using a number of hooks, or tasks. The tasks run in an
environment, specified by rules found in a virtual floppy, placed there by
*snf-image*. *snf-image-helper* uses runparts to run tasks found under
*/usr/lib/snf-image-helper/tasks* by default
Graphical Representation
The architecture is presented below:
.. image:: /images/arch.png
.. _image-configuration-tasks:
Image Configuration Tasks
Configuration tasks are scripts called by snf-image-helper to accomplish
various configuration steps on the newly created instance. See below for a
description of each one of them:
**FixPartitionTable**: Enlarges the last partition in the partition table of
the instance, to consume all the available space and optionally adds a swap
partition in the end.
**FilesystemResizeUnmounted**: Extends the file system of the last partition to
cover up the whole partition. This only works for ext{2,3,4} file systems. Any
other file system type is ignored and a warning is triggered. The task will
fail if *SNF_IMAGE_DEV* environmental variable is missing.
**MountImage**: Mounts the nth partition of *SNF_IMAGE_DEV*, which is specified
by *SNF_IMAGE_PROPERTY_ROOT_PARTITION* variable under the directory specified
by *SNF_IMAGE_TARGET*. The script will fail if any of those 3 variables has a
non-sane value.
**AddSwap**: Formats the swap partion added by *FixPartitionTable* task and
adds an appropriate swap entry in the system's ``/etc/fstab``. The script will
only run if *SNF_IMAGE_PROPERTY_SWAP* is present and will fail if
*SNF_IMAGE_TARGET* in not defined.
**DeleteSSHKeys**: For linux images, this script will clear out any ssh keys
found in the image and for debian, it will recreate them too. In order to find
the ssh keys, the script looks in default locations (/etc/ssh/ssh_*_key) and
also parses ``/etc/ssh/sshd_config`` file if present. The script will fail if
*SNF_IMAGE_TARGET* is not set.
**DisableRemoteDesktopConnections**: This script temporary disables RDP
connections in windows instances by changing the value *fDenyTSConnection*
registry key. RDP connections will be enabled back during the specialize pass
of the Windows setup. The task will fail if *SNF_IMAGE_TARGET* is not defined.
**InstallUnattend**: Installs the Unattend.xml files in windows images. This is
needed by windows in order to perform an unattended setup. The
*SNF_IMAGE_TARGET* variables needs to be present for this task to run.
**SELinuxAutorelabel**: Creates *.autorelabel* file in RedHat images. This is
needed if SELinux is enabled to enforce an automatic file system relabeling at
the next boot. The only enviromental variable required by this task is
**AssignHostname**: Assigns or changes the hostname in a Linux or Windows
image. The task will fail if the Linux distribution is not supported. For now,
we support Debian, Redhat, Slackware, SUSE and Gentoo derived distros. The
hostname is read from *SNF_IMAGE_HOSTNAME* variable. In addition to the latter,
*SNF_IMAGE_TARGET* is also required.
**ChangePassword**: Changes the password for a list of users. For Linux systems
this is accomplished by directly altering the image's ``/etc/shadow`` file. For
Windows systems a script is injected into the VM's hard disk. This script will
be executed during the specialize pass of the Windows setup. The list of users
whose passwords will changed is determined by the *SNF_IMAGE_PROPERTY_USERS*
variable (see :ref:`image-properties`). For this task to run *SNF_IMAGE_TARGET*
and *SNF_IMAGE_PASSWORD* variables need to be present.
**FilesystemResizeMounted**: Injects a script into a Windows image file system
that will enlarge the last file system to cover up the whole partition. The
script will run during the specialize pass of the Windows setup. If the
*SNF_IMAGE_TARGET* variable is missing, the task will fail.
**EnforcePersonality**: Injects the files specified by the
*SNF_IMAGE_PROPERTY_OSFAMILY* variable into the file system. If the variable is
missing a warning is produced. The only environmental variable required is
**UmountImage**: Umounts the file system previously mounted by MountImage. The
only environmental variable required is *SNF_IMAGE_TARGET*.
| | | Dependencies | Enviromental Variables [#]_ |
+ Name | +------------------+-------------------------+-------------------------+------------------------+
| |Pr.| Run-After | Run-Before | Required | Optional |
|FixPartitionTable |10 | |FilesystemResizeUnmounted|DEV | |
|FilesystemResizeUnmounted |20 |FixPartitionTable |MountImage |DEV | |
|MountImage |30 | |UmountImage |DEV | |
| | | | |TARGET | |
|AddSwap |40 |MountImage |EnforcePersonality |TARGET |PROPERTY_OSFAMILY |
| | | | | |PROPERTY_SWAP |
|DeleteSSHKeys |40 |MountImage |EnforcePersonality |TARGET |PROPERTY_OSFAMILY |
|DisableRemoteDesktopConnections|40 |EnforcePersonality|UmountImage |TARGET |PROPERTY_OSFAMILY |
|InstallUnattend |40 |MountImage |EnforcePersonality |TARGET |PROPERTY_OSFAMILY |
|SELinuxAutorelabel |40 |MountImage |EnforcePersonality |TARGET |PROPERTY_OSFAMILY |
|AssignHostname |50 |InstallUnattend |EnforcePersonality |TARGET | |
|ChangePassword |50 |InstallUnattend |EnforcePersonality |TARGET |PROPERTY_USERS |
|FilesystemResizeMounted |50 |InstallUnattend |EnforcePersonality |TARGET |PROPERTY_OSFAMILY |
|EnforcePersonality |60 |MountImage |UmountImage |TARGET |PERSONALITY |
|UmountImage |80 |MountImage | |TARGET | |
.. [#] all environmental variables are prefixed with *SNF_IMAGE_*
# -*- coding: utf-8 -*-
# snf-image documentation build configuration file, created by
# sphinx-quickstart on Fri Sep 13 16:50:13 2013.
# This file is execfile()d with the current directory set to its containing dir.
# Note that not all possible configuration values are present in this
# autogenerated file.
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'snf-image'
copyright = u'2011, 2012, 2013 GRNET S.A. All rights reserved'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
# The short X.Y version.
version = '0.10.1'
# The full version, including alpha/beta/rc tags.
release = '0.10.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
'collapsiblesidebar': 'true',
'footerbgcolor': '#55b577',
'footertextcolor': '#000000',
'sidebarbgcolor': '#ffffff',