72224ff9c8d28aa8636c7f723ea983813f640482
[snf-image] / docs / interface.rst
1 Interface
2 =========
3
4 Ganeti OS Interface
5 ^^^^^^^^^^^^^^^^^^^
6
7 *snf-image* requires ganeti-os-interface v20 to operate and it introduces the
8 following OS Parameters:
9
10  * **img_format** (required if *config_url* is missing): the image format type
11    (:ref:`details <image-format>`)
12  * **img_id** (required if *config_url* is missing): the URI used to identify
13    the image (:ref:`details <image-id>`)
14  * **img_passwd** (required if *config_url* is missing): the password to be
15    injected to the image
16  * **img_properties** (optional): additional image properties used to customize
17    the image (:ref:`details <image-properties>`)
18  * **img_personality** (optional): files to be injected into the image
19    filesystem (:ref:`details <image-personality>`)
20  * **config_url** (optional): the url to download configuration data from
21
22 .. _image-format:
23
24 Image Format (img_format)
25 ^^^^^^^^^^^^^^^^^^^^^^^^^
26
27 snf-image supports 3 different types of image formats:
28
29  * **diskdump** (recommended): a raw dump of a disk
30  * **extdump**: a raw dump of an ext{2,3,4} file system
31  * **ntfsdump**: a raw dump of an NTFS file system
32
33 These are also the only valid values for the **img_format** OS parameter.
34 The **diskdump** type is the newest and recommended type. Thus, all sample
35 images we provide are of this type. For more details about the internals of
36 image formats please see the :ref:`corresponding advanced section
37 <image-format-advanced>`.
38
39 .. _image-id:
40
41 Image ID (img_id)
42 ^^^^^^^^^^^^^^^^^
43
44 The **img_id** OS parameter points to the actual Image that we want to deploy.
45 It is a URI and its prefix denotes the type of :ref:`backend <storage-backends>`
46 to be used. If no prefix is used, it defaults to the local backend:
47
48  * **Local backend**:
49    To select it, the prefix should be ``file://``, followed by the name of the
50    image. All local images are expected to be found under a predefined image
51    directory (``/var/lib/snf-image`` by default). The name of the actual file
52    should be ``<img_id>.<img_format>``.
53
54   | For example, if we want to deploy the image file:
55   | ``/var/lib/snf-image/slackware.diskdump``
56   | We need to assign:
57   | ``img_format=diskdump`` and ``img_id=file://slackware``
58
59  * **Network backend**:
60    If the **imd_id** starts with ``http:``, ``https:``, ``ftp:`` or ``ftps:``,
61    snf-image will treat the **img_id** as a remote URL and will try to fetch the
62    image using `cURL <http://curl.haxx.se/>`_.
63
64   | For example, if we want to deploy an image from an http location:
65   | ``img_id=http://www.synnefo.org/path/to/image/slackware-image``
66
67  * **Pithos backend**:
68    If the **img_id** is prefixed with ``pithos://`` or ``pithosmap://`` the
69    image is considered to reside on a Pithos deployment. For ``pithosmap://``
70    images, the user needs to have set a valid value for the
71    ``PITHOS_DATA`` variable in snf-image's configuration file
72    (``/etc/default/snf-image`` by default). For ``pithos://`` images, in
73    addition to ``PITHOS_DATA``, the user needs to have set a valid value for the
74    ``PITHOS_DB`` variable, too.
75
76   | For example, if we want to deploy using a full Pithos URI:
77   | ``img_id=pithos://<user-uuid>/<container>/<slackware-image>``
78   | or if we already know the map:
79   | ``img_id=pithosmap://<slackware-image-map-name>``
80
81  * **Null backend**:
82    To select the Null backend and skip the fetching and extraction step, we set
83    ``img_id=null``.
84
85 .. _image-properties:
86
87 Image Properties (img_properties)
88 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
89
90 *snf-image* may use a number of properties to properly configure the image.
91 Those image properties are passed to snf-image by Ganeti through the
92 *img_poroperties* OS parameter (see Ganeti OS Interface). The name of all image
93 properties is case-insensitive. For the diskdump format some properties are
94 mandatory. For {ext,ntfs}dump formats all image properties are optional.
95
96 We can group image properties in two categories:
97
98 1. Generic properties (*OSFAMILY*, *ROOT_PARTITION*, *USERS*)
99 2. Configuration tasks to run (*EXCLUDE_ALL_TASKS*, *EXCLUDE_TASK_<task_name>*)
100    (see here for :ref:`valid configuration tasks <image-configuration-tasks>`)
101
102 A list of all properties follows:
103
104 Mandatory properties (for diskdump only)
105 ++++++++++++++++++++++++++++++++++++++++
106
107  * **OSFAMILY={linux,windows}**
108    This specifies whether the image is a Linux or a Windows Image.
109    {ext,ntfs}dump formats are self descriptive regarding this property.
110  * **ROOT_PARTITION=n**
111    This specifies the partition number of the root partition. As mentioned
112    earlier, for now, only primary partitions are supported. This property is
113    trivial for {ext,ntfs}dump formats (they only host one partition).
114
115 Optional properties
116 +++++++++++++++++++
117
118  * **USERS="username1 username2...."**
119    This is a space-separated list of users, whose password will be reset by
120    *snf-image*. The use of this property is optional, but highly recommended.
121    For now, if this property is missing, the users are chosen according to a
122    set of rules, but those rules may change or even be dropped in the future.
123    The rules we currently use are listed below:
124
125      * For Windows images, the *Administrator*'s password is reset.
126      * For Linux and FreeBSD images, the *root* password is reset.
127
128  * **EXCLUDE_ALL_TASKS=yes**
129    If this property is defined with a value other than null, then during the
130    deployment, the image will not be configured at all. This is really handy
131    because it gives the ability to deploy images hosting operating systems
132    whose configuration is not supported by snf-image.
133
134  * **EXCLUDE_TASK_<task_name>=yes**
135    This family of properties gives the ability to exclude individual
136    configuration tasks from running. Hence, if the property
137    *EXCLUDE_TASK_DeleteSSHKeys* with a value other than null is passed to
138    *snf-image*, the aforementioned configuration step will not be executed, and
139    the SSH Keys found in the image will not be removed during the deployment.
140    Task exclusion provides great flexibility, but it needs to be used with
141    great care. Tasks depend on each other and although those dependencies are
142    well documented, automatic task dependency resolution isn't yet supported in
143    *snf-image*. If you exclude task A but not task B which depends on A, you
144    will probably end up with an unsuccessful deployment because B will fail and
145    exit in an abnormal way. You can read more about configuration tasks here.
146
147 img_properties OS parameter
148 +++++++++++++++++++++++++++
149
150 Image properties are passed to snf_image through the img_properties OS
151 parameter as a simple json string like the one below:
152
153 | {
154 |     "PROPERTY1": "VALUE1",
155 |     "PROPERTY2": "VALUE2",
156 |     "PROPERTY3": "VALUE3",
157 |     ...
158 |     ...
159 |     ...
160 |     "PROPERTYn": "VALUEn"
161 | }
162
163
164 A real life example for creating a new Ganeti instance and passing image
165 properties to snf-image looks like this:
166
167 .. code-block:: console
168
169    ``gnt-instance add -O img_properties='{"OSFAMILY":"linux"\,"ROOT_PARTITION":"2"\,"USERS":"root guest"}',img_format=diskdump,img_id=...``
170
171 .. _image-personality:
172
173 Image Personality (img_personality)
174 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
175
176 This parameter is an extension of the Server Personality notation proposed by
177 the OpenStack Compute API v1.1 and defines a list of files to be injected into
178 the image file system.
179
180 Format
181 ++++++
182
183 The format of this parameter is a JSON array of objects. Each object in the
184 array supports the following keys:
185
186  * **path**: The absolute path of the file (string)
187  * **contents**: The content of the file encoded as a base64 string (string)
188  * **owner**: The user ownership of the file (string)
189  * **group**: The group ownership of the file (string)
190  * **mode**: The permission mode of the file (number)
191
192 The first two (path, contents) are mandatory. The others (owner, group, mode)
193 are optional and their default value is root, root and 0440 respectively.
194
195 Example
196 +++++++
197
198 The JSON string below defines two files (*/tmp/test1*, */tmp/test2*) whose
199 content is ``test1\n`` and ``test2\n``, they are both owned by *root:root* and
200 their permissions are ``-rw-r--r--`` [#]_
201
202 | [
203 |     {
204 |         "path": "/tmp/test1",
205 |         "contents": "dGVzdDENCg==",
206 |         "owner": "root",
207 |         "group": "root",
208 |         "mode": 0644
209 |     },
210 |     {
211 |         "path": "/tmp/test2",
212 |         "contents": "dGVzdDINCg==",
213 |         "owner": "root",
214 |         "group": "root",
215 |         "mode": 420
216 |     }
217 | ]
218
219 .. [#] The first mode is in octal representation and the second in decimal.