Update documentation for using diskimage-builder

Recent change in nodepool to build images using
diskimage-builder involved adding new diskimages section
in the nodepool.yaml file, and added new commands like
dib-image-list, dib-image-delete, image-build and image-upload.

Change-Id: If36f3f6e39e382cb4c6398d3a063c979888a8642
This commit is contained in:
Yolanda Robla 2014-08-20 14:07:36 +02:00 committed by Yolanda Robla
parent f4dd764ddf
commit ad97fb91a2
4 changed files with 79 additions and 20 deletions

View File

@ -7,10 +7,13 @@ Nodepool reads its configuration from ``/etc/nodepool/nodepool.yaml``
by default. The configuration file follows the standard YAML syntax
with a number of sections defined with top level keys. For example, a
full configuration file may have the ``labels``, ``providers``, and
``targets`` sections::
``targets`` sections. If building images using diskimage-builder, the
``diskimages`` section is also required::
labels:
...
diskimages:
...
providers:
...
targets:
@ -152,6 +155,35 @@ A script specified by `ready-script` can be used to perform any last minute
changes to a node after it has been launched but before it is put in the READY
state to receive jobs. For more information, see :ref:`scripts`.
diskimages
----------
Lists the images that are going to be built using diskimage-builder.
Image keyword defined on labels section will be mapped to the
images listed on diskimages. If an entry matching the image is found
this will be built using diskimage-builder and the settings found
on this configuration. If no matching image is found, image
will be built using the provider snapshot approach::
diskimages:
- name: devstack-precise
elements:
- ubuntu
- vm
- puppet
- node-devstack
release: precise
qemu-img-options: compat=0.10
For diskimages, the `name` is required. The `elements` section
enumerates all the elements that will be included when building
the image, and will point to the `elements-dir` path referenced
in the same config file. `release` specifies the distro to be
used as a base image to build the image using diskimage-builder.
`qemu-img-options` allows to specify custom settings that qemu
will be using to build the final image. Settings there have to
be separated by commas, and must follow qemu syntax.
providers
---------
@ -219,7 +251,10 @@ For providers, the `name`, `username`, `password`, `auth-url`,
`name`, `base-image`, and `min-ram` keys are required. The `username`
and `private-key` values default to the values indicated. Nodepool
expects that user to exist after running the script indicated by
`setup`. See :ref:`scripts` for setup script details.
`setup`. `setup` will be used only when not building images
using diskimage-builder, in that case settings defined in
the ``diskimages`` section will be used instead. See :ref:`scripts`
for setup script details.
Both `boot-timeout` and `launch-timeout` keys are optional. The
`boot-timeout` key defaults to 60 seconds and `launch-timeout` key

View File

@ -33,14 +33,30 @@ The general options that apply to all subcommands are:
The following subcommands deal with nodepool images:
dib-image-list
^^^^^^^^^^^^^^
.. program-output:: nodepool dib-image-list --help
image-list
^^^^^^^^^^
.. program-output:: nodepool image-list --help
image-build
^^^^^^^^^^^
.. program-output:: nodepool image-build --help
image-update
^^^^^^^^^^^^
.. program-output:: nodepool image-update --help
image-upload
^^^^^^^^^^^^
.. program-output:: nodepool image-upload --help
dib-image-delete
^^^^^^^^^^^^^^^^
.. program-output:: nodepool dib-image-delete --help
image-delete
^^^^^^^^^^^^
.. program-output:: nodepool image-delete --help

View File

@ -25,7 +25,8 @@ Setup script
Each provider can specify a setup script with `setup`, and that script is
expected to exist in `script_dir`. If it is found, it will be run during image
creation. When the script is invoked, the instance hostname will be passed in
as the first parameter.
as the first parameter. This setup script will only be applied when building
images using provider snapshots, not using diskimage-builder.
Ready script

View File

@ -44,22 +44,27 @@ class NodePoolCmd(object):
cmd_list = subparsers.add_parser('list', help='list nodes')
cmd_list.set_defaults(func=self.list)
cmd_image_list = subparsers.add_parser('image-list',
help='list images')
cmd_image_list = subparsers.add_parser(
'image-list', help='list images from providers')
cmd_image_list.set_defaults(func=self.image_list)
cmd_dib_image_list = subparsers.add_parser('dib-image-list',
help='list dib images')
cmd_dib_image_list = subparsers.add_parser(
'dib-image-list',
help='list images built with diskimage-builder')
cmd_dib_image_list.set_defaults(func=self.dib_image_list)
cmd_image_update = subparsers.add_parser('image-update',
help='update image')
cmd_image_update.add_argument('provider', help='provider name')
cmd_image_update = subparsers.add_parser(
'image-update',
help='rebuild the image and upload to provider')
cmd_image_update.add_argument(
'provider',
help='provider name (`all` for uploading to all providers)')
cmd_image_update.add_argument('image', help='image name')
cmd_image_update.set_defaults(func=self.image_update)
cmd_image_build = subparsers.add_parser('image-build',
help='build image')
cmd_image_build = subparsers.add_parser(
'image-build',
help='build image using diskimage-builder')
cmd_image_build.add_argument('image', help='image name')
cmd_image_build.set_defaults(func=self.image_build)
@ -100,16 +105,18 @@ class NodePoolCmd(object):
cmd_dib_image_delete = subparsers.add_parser(
'dib-image-delete',
help='delete a dib image')
help='delete image built with diskimage-builder')
cmd_dib_image_delete.set_defaults(func=self.dib_image_delete)
cmd_dib_image_delete.add_argument('id', help='dib image id')
cmd_image_upload = subparsers.add_parser(
'image-upload',
help='upload an image')
help='upload an image to a provider ')
cmd_image_upload.set_defaults(func=self.image_upload)
cmd_image_upload.add_argument('provider', help='provider name',
nargs='?', default='all')
cmd_image_upload.add_argument(
'provider',
help='provider name (`all` for uploading to all providers)',
nargs='?', default='all')
cmd_image_upload.add_argument('image', help='image name')
self.args = parser.parse_args()
@ -227,13 +234,13 @@ class NodePoolCmd(object):
with self.pool.getDB().getSession() as session:
for provider in self.pool.config.providers.values():
if (self.args.provider and
provider.name != self.args.provider):
provider.name != self.args.provider):
continue
manager = self.pool.getProviderManager(provider)
for server in manager.listServers():
if not session.getNodeByExternalID(
provider.name, server['id']):
provider.name, server['id']):
t.add_row([provider.name, server['name'], server['id'],
server['public_v4']])
print t
@ -246,14 +253,14 @@ class NodePoolCmd(object):
with self.pool.getDB().getSession() as session:
for provider in self.pool.config.providers.values():
if (self.args.provider and
provider.name != self.args.provider):
provider.name != self.args.provider):
continue
manager = self.pool.getProviderManager(provider)
for image in manager.listImages():
if image['metadata'].get('image_type') == 'snapshot':
if not session.getSnapshotImageByExternalID(
provider.name, image['id']):
provider.name, image['id']):
t.add_row([provider.name, image['name'],
image['id']])
print t