Statistics
| Branch: | Tag: | Revision:

root / doc / design-ovf-support.rst @ 6499c5b8

History | View | Annotate | Download (16.5 kB)

1
==============================================================
2
Ganeti Instance Import/Export using Open Virtualization Format
3
==============================================================
4

    
5
Background
6
==========
7

    
8
Open Virtualization Format is an open standard for packaging
9
information regarding virtual machines. It is used, among other, by
10
VMWare, VirtualBox and XenServer. OVF allows users to migrate between
11
virtualization software without the need of reconfiguring hardware,
12
network or operating system.
13

    
14
Currently, exporting instance in Ganeti results with a configuration
15
file that is readable only for Ganeti. It disallows the users to
16
change the platform they use without loosing all the machine's
17
configuration.  Import function in Ganeti is also currently limited to
18
the previously prepared instances.
19

    
20
Implementation of OVF support allows users to migrate to Ganeti from
21
other platforms, thus potentially increasing the usage. It also
22
enables virtual machine end-users to create their own machines
23
(e.g. in VirtualBox or SUSE Studio) and then add them to Ganeti
24
cluster, thus providing better personalization.
25

    
26
Overview
27
========
28

    
29
Open Virtualization Format description
30
--------------------------------------
31

    
32
According to the DMTF document introducing the standard: "The Open
33
Virtualization Format (OVF) Specification describes an open, secure,
34
portable, efficient and extensible format for the packaging and
35
distribution of software to be run in virtual machines."  OVF supports
36
both single and multiple- configurations of VMs in one package, is
37
host- and virtualization platform-independent and optimized for
38
distribution (e.g. by allowing usage of public key infrastructure and
39
providing tools for management of basic software licensing).
40

    
41
There are no limitations regarding hard drive images used, as long as
42
the description is provided. Any hardware described in a proper
43
i.e. CIM - Common Information Model) format is accepted, although
44
there is no guarantee that every virtualization software will support
45
all types of hardware.
46

    
47
OVF package should contain one file with ``.ovf`` extension, which is an
48
XML file specifying the following (per virtual machine):
49

    
50
- virtual disks
51
- network description
52
- list of virtual hardware
53
- operating system, if any
54

    
55
Each of the elements in ``.ovf`` file may, if desired, contain a
56
human-readable description to every piece of information given.
57

    
58
Additionally, the package may have some disk image files and other
59
additional resources (e.g. ISO images).
60

    
61
Supported disk formats
62
----------------------
63

    
64
Although OVF is claimed to support 'any disk format', what we are
65
interested in is which of the formats are supported by VM managers
66
that currently use OVF.
67

    
68
- VMWare: ``.vmdk`` (which comes in at least 3 different flavours:
69
  ``sparse``, ``compressed`` and ``streamOptimized``)
70
- VirtualBox: ``.vdi`` (VirtualBox's format), ``.vmdk``, ``.vhd``
71
  (Microsoft and XenServer); export disk format is always ``.vmdk``
72
- XenServer: ``.vmdk``, ``.vhd``; export disk format is always
73
  ``.vhd``
74
- Red Hat Enterprise Virtualization: ``.raw`` (raw disk format),
75
  ``.cow`` (qemu's ``QCOW2``)
76
- other: AbiCloud, OpenNode Cloud, SUSE Studio, Morfeo Claudia,
77
  OpenStack
78

    
79
In our implementation of the OVF we plan to allow a choice between
80
raw, cow and vmdk disk formats for export. We will not limit the import
81
formats in any way, but the used format has to be supported by qemu-img.
82
The justification is the following:
83

    
84
- Raw format is supported as it is the main format of disk images used
85
  in Ganeti, thus it is effortless to provide support for this format
86
- Cow is used in Qemu
87
- Vmdk is most commonly supported in virtualization software, it also
88
  has the advantage of producing relatively small disk images, which
89
  is extremely important advantage when moving instances.
90

    
91
The conversion between RAW and the other formats will be done using
92
qemu-img, which transforms, among other, raw disk images to monolithic
93
sparse vmdk images.
94

    
95
Import and export - the closer look
96
===================================
97

    
98
This section contains an overview of how different parts of
99
Ganeti's export info are included in ``.ovf`` configuration file.
100
It also explains how import is designed to work with incomplete
101
information.
102

    
103
Ganeti's backup format vs OVF
104
-----------------------------
105
.. highlight:: xml
106

    
107
The basic structure of Ganeti ``.ovf`` file is the following::
108

    
109
    <Envelope>
110
        <References></References>
111
        <DiskSection></DiskSection>
112
        <NetworkSection></NetworkSection>
113
        <VirtualSystem>
114
            <Name></Name>
115
            <OperatingSystemSection></OperatingSystemSection>
116
            <VirtualHardwareSection><VirtualHardwareSection>
117
        </VirtualSystem>
118
        <gnt:GanetiSection>
119
            <gnt:VersionId/>
120
            <gnt:AutoBalance/>
121
            <gnt:Tags></gnt:Tags>
122
            <gnt:DiskTemplate</gnt:DiskTemplate>
123
            <gnt:OperatingSystem>
124
                <gnt:Name/>
125
                <gnt:Parameters>
126
                </gnt:Parameters>
127
            </gnt:OperatingSystem>
128
            <gnt:Hypervisor>
129
                <gnt:Name/>
130
                <gnt:Parameters>
131
                </gnt:Parameters>
132
            </gnt:Hypervisor>
133
            <gnt:Network>
134
            <gnt:Mode/>
135
            <gnt:MACAddress/>
136
            <gnt:Link/>
137
            <gnt:IPAddress/>
138
            </gnt:Network>
139
        </gnt:GanetiSection>
140
    </Envelope>
141

    
142
.. note ::
143
    Tags with ``gnt:`` prefix are Ganeti-specific and are not a part of
144
    OVF standard.
145

    
146
.. highlight:: text
147

    
148
Whereas Ganeti's export info is of the following form, ``=>`` showing
149
where will the data be in OVF format::
150

    
151
  [instance]
152
      disk0_dump = filename     => File in References
153
      disk0_ivname = name       => generated automatically
154
      disk0_size = size_in_mb   => calculated after conversion to RAW
155
      disk_count = number       => generated automatically
156
      disk_template = disk_type => gnt:DiskTemplate
157
      hypervisor = hyp-name     => gnt:Name in gnt:Hypervisor
158
      name = inst-name          => Name in VirtualSystem
159
      nic0_ip = ip              => gnt:IPAddress in gnt:Network
160
      nic0_link = link          => gnt:Link in gnt:Network
161
      nic0_mac = mac            => gnt:MACAddress in gnt:Network or
162
                                   Item in VirtualHardwareSection
163
      nic0_mode = mode          => gnt:Mode in gnt:Network
164
      nic_count = number        => generated automatically
165
      tags                      => gnt:Tags
166

    
167
  [backend]
168
      auto_balanced             => gnt:AutoBalance
169
      memory = mem_in_mb        => Item in VirtualHardwareSection
170
      vcpus = number            => Item in VirtualHardwareSection
171

    
172
  [export]
173
      compression		=> ignored
174
      os                        => gnt:Name in gnt:OperatingSystem
175
      source                    => ignored
176
      timestamp                 => ignored
177
      version                   => gnt:VersionId or
178
                                   constants.EXPORT_VERSION
179

    
180
  [os]                          => gnt:Parameters in gnt:OperatingSystem
181

    
182
  [hypervisor]                  => gnt:Parameters in gnt:Hypervisor
183

    
184
In case of multiple networks/disks used by an instance, they will
185
all be saved in appropriate sections as specified above for the first
186
network/disk.
187

    
188
Import from other virtualization software
189
-----------------------------------------
190
In case of importing to Ganeti OVF package generated in other software,
191
e.g. VirtualBox, some fields required for Ganeti to properly handle
192
import may be missing. Most often it will happen that such OVF package
193
will lack the ``gnt:GanetiSection``.
194

    
195
If this happens you can specify all the missing parameters in
196
the command line. Please refer to `Command Line`_ section.
197

    
198
In the `user's manual <TODO: link to manual>`_ we provide examples of
199
options when converting from VirtualBox, VMWare and OpenSuseStudio.
200

    
201
Export to other virtualization software
202
---------------------------------------
203
When exporting to other virtualization software, you may notice that
204
there is a section ``gnt:GanetiSection``, containing Ganeti-specific
205
information. This may on **rare** cases cause trouble in importing your
206
instance. If that is the case please do one of the two:
207

    
208
1. Export from Ganeti to OVF with ``--external`` option - this will
209
cause to skip the non-standard information.
210

    
211
2. Manually remove the gnt:GanetiSection from the ``.ovf`` file. You
212
will also have to recompute sha1 sum (``sha1sum`` command) of the .ovf
213
file and update your ``.mf`` file with new value.
214

    
215
.. note::
216
    Manual change option is only recommended when you have exported your
217
    instance with ``-format`` option other that ``raw`` or selected
218
    ``--compress``. It saves you the time of converting or compressing
219
    the disk image.
220

    
221
Planned limitations
222
===================
223

    
224
The limitations regarding import of the OVF instances generated
225
outside Ganeti will be (in general) the same, as limitations for
226
Ganeti itself.  The desired behavior in case of encountering
227
unsupported element will be to ignore this element's tag without
228
interruption of the import process.
229

    
230
Package
231
-------
232

    
233
There are no limitations regarding support for multiple files in
234
package or packing the OVF package into one OVA (Open Virtual
235
Appliance) file. As for certificates and licenses in the package,
236
their support will be under discussion after completion of the basic
237
features implementation.
238

    
239
Multiple Virtual Systems
240
------------------------
241

    
242
At first only singular instances (i.e. VirtualSystem, not
243
VirtualSystemCollection) will be supported. In the future multi-tiered
244
appliances containing whole nodes (or even clusters) are considered an
245
option.
246

    
247
Disks
248
-----
249

    
250
As mentioned, Ganeti will allow exporting only ``raw``, ``cow`` and
251
``vmdk`` formats.  As for import, we will support all that
252
``qemu-img`` can convert to raw format. At this point this means
253
``raw``, ``cow``, ``qcow``, ``qcow2``, ``vmdk`` and ``cloop``.  We do
254
not plan for now to support ``vdi`` or ``vhd``.
255

    
256
We plan to support compression both for import and export - in tar.gz
257
format. There is also a possibility to provide virtual disk in chunks
258
of equal size. The latter will not be implemented in the first version,
259
but we do plan to support it eventually.
260

    
261
The ``ovf:format`` tag is not used in our case. Instead we use
262
``qemu-img info``, which provides enough information for our purposes
263
and is better standardized.
264

    
265
Please note, that due to security reasons we require the disk image to
266
be in the same directory as the ``.ovf`` description file.
267

    
268
In order to completely ignore disk-related information in resulting
269
config file, please use ``--disk-template=diskless`` option.
270

    
271
Network
272
-------
273

    
274
Ganeti provides support for routed and bridged mode for the networks.
275
Since the standard OVF format does not contain any information regarding
276
used network type, we add our own source of such information in
277
``gnt:GanetiSection``. In case this additional information is not
278
present, we perform a simple check - if network name specified in
279
``NetworkSection`` contains words ``bridged`` or ``routed``, we consider
280
this to be the network type. Otherwise option ``auto`` is chosen, in
281
which case the clusters' default value for that field will be used when
282
importing. This provides a safe fallback in case of NAT networks usage,
283
which are commonly used e.g. in VirtualBox.
284

    
285
Hardware
286
--------
287

    
288
The supported hardware is limited to virtual CPUs, RAM memory, disks and
289
networks. In particular, no USB support is currently provided, as Ganeti
290
does not support them.
291

    
292
Operating Systems
293
-----------------
294

    
295
Support for different operating systems depends solely on their
296
accessibility for Ganeti instances. List of installed OSes can be
297
checked using ``gnt-os list`` command.
298

    
299
Other
300
-----
301

    
302
The instance name (``gnt:VirtualSystem\gnt:Name``) has to be resolvable
303
in order for successful import using ``gnt-backup import``.
304

    
305
_`Command Line`
306
===============
307

    
308
The basic usage of the ovf tool is one of the following::
309

    
310
    ovfconverter import filename
311
    ovfconverter export filename
312

    
313
This will result in a conversion based solely on the content of provided
314
file. In case some information required to make the conversion is
315
missing, an error will occur.
316

    
317
If output directory should be different than the standard Ganeti export
318
directory (usually ``/srv/ganeti/export``), option ``--output-dir``
319
can be used.
320

    
321
If name of resulting entity should be different than the one read from
322
the file, use ``--name`` option.
323

    
324
Import options
325
--------------
326

    
327
Import options that ``ovfconverter`` supports include options for
328
backend, disks, hypervisor, networks and operating system. If an option
329
is given, it overrides the values provided in the OVF file.
330

    
331
Backend
332
^^^^^^^
333
``--backend=option=value`` can be used to set auto balance, number of
334
vcpus and amount of RAM memory.
335

    
336
Please note that when you do not provide full set of options, the
337
omitted ones will be set to cluster defaults (``auto``).
338

    
339
Disks
340
^^^^^
341
``--disk-template=diskless`` causes the converter to ignore all other
342
disk option - both from .ovf file and the command line.
343

    
344
``--disk=number:size=value`` causes to create disks instead of
345
converting them from OVF package; numbers should start with ``0`` and be
346
consecutive.
347

    
348
Hypervisor
349
^^^^^^^^^^
350
``-H hypervisor_name`` and ``-H hypervisor_name:option=value``
351
provide options for hypervisor.
352

    
353
Network
354
^^^^^^^
355
``--no-nics`` option causes converter to ignore any network information
356
provided.
357

    
358
``--network=number:option=value`` sets network information according to
359
provided data, ignoring the OVF package configuration.
360

    
361
Operating System
362
^^^^^^^^^^^^^^^^
363
``--os-type=type`` sets os type accordingly, this option is **required**
364
when importing from OVF instance not created from Ganeti config file.
365

    
366
``--os-parameters`` provides options for chosen operating system.
367

    
368
Tags
369
^^^^
370
``--tags=tag1,tag2,tag3`` is a means of providing tags specific for the
371
instance.
372

    
373
After the conversion is completed, you may use ``gnt-backup import`` to
374
import the instance into Ganeti.
375

    
376
Example::
377

    
378
	ovfconverter file.ovf --disk-template=diskless \
379
                        --os-type=lenny-image \
380
                        --backend=vcpus=1,memory=512,auto_balance \
381
                        -H:xen-pvm \
382
                        --net=0:mode=bridged,link=xen-br0 \
383
                        --name=xen.i1 \
384
                        -v
385
	[output]
386
	gnt-backup import xen.i1
387
	[output]
388
	gnt-instance list
389

    
390
Export options
391
--------------
392
Export options include choice of disk formats to convert the disk image
393
(``--format``; default=``raw`` with no conversion) and compression of
394
the disk into tar.gz format (``--compress``).
395
User has also the choice of allowing to skip the Ganeti-specific part of
396
the OVF document (``--external``).
397

    
398
By default, exported OVF package will not be contained in the OVA
399
package, but this may be changed by adding ``--ova`` option.
400

    
401
[TODO: examples of usage]
402

    
403
Please note that in order to create an OVF package, it is first
404
required that you export your VM using ``gnt-backup export``.
405

    
406
[TODO: complete example of export]
407

    
408
Implementation details
409
======================
410

    
411
Disk conversion
412
---------------
413

    
414
Disk conversion for both import and export is done using external tool
415
called qemu-tools. The same tool is used to determine the type of disks.
416

    
417

    
418
Import
419
------
420

    
421
Import functionality is implemented using two classes - OVFReader and
422
OVFImporter.
423

    
424
OVFReader class is used to read the contents of the ``.ovf`` file. Every
425
action that requires ``.ovf`` file access is done through that class.
426
It also performs validation of manifest, if one is present.
427

    
428
The result of reading some part of file is typically a dictionary or a
429
string, containing options which correspond to the ones in
430
``config.ini`` file. Only in case of disks, the resulting value is
431
different - it is then a list of disk names. The reason for that is the
432
need for conversion.
433

    
434
OVFImporter class performs all the command-line-like tasks, such as
435
unpacking OVA package, removing temporary directory, converting disk
436
file to raw format or saving the configuration file on disk.
437
It also contains a set of functions that read the options provided in
438
the command line.
439

    
440

    
441
Typical workflow for the import is very simple:
442

    
443
- read the ``.ovf`` file info memory
444
- verify manifest
445
- parse each element of the configuration file: name, disk template,
446
  hypervisor, operating system, backend parameters, network and disks
447

    
448
    - check if option for the element can be read from command line
449
      options
450

    
451
		- if yes: parse options from command line
452

    
453
		- otherwise: read the appropriate portion of ``.ovf`` file
454

    
455
- save gathered information in ``config.ini`` file
456

    
457
ToDo
458
====
459

    
460
This lists functionalities for import that are not yet implemented, but
461
should be before the initial release:
462

    
463
- Support for compressed disks
464

    
465

    
466
.. vim: set textwidth=72 :
467
.. Local Variables:
468
.. mode: rst
469
.. fill-column: 72
470
.. End: