# Foreman Snapshot

A plugin to create images from Hostgroups

| Supported Compute Resources | | ————————— | | Openstack | | Libvirt |

Setup

Add this plugin to the Gemfile, and restart Rails.

Usage

The plugin has no UI as yet, so send an API request to /api/v2/hostgroups/:id/snapshot. Replace :id with the hostgroup id as normal. See the sections below for examples for each compute resource.

The request will block until complete (unless using Dynflow & ForemanTasks, see below). This can take nearly 10 minutes for something like Libvirt, so be patient.

Openstack

Send an API request like this:

{
  "host": {
    "compute_resource_id": 7,
    "compute_attributes": {
      "flavor_ref": 1,
      "network": "public",
      "image_ref": "9c9d4946-3e33-4f6e-92f0-f3527ef42862"
    }
  }
}

Libvirt

For Libvirt you will need fog >= 1.21 for clone_volume support. Then send an API request like this:

{
  "host": {
    "compute_resource_id": 3,
    "compute_profile_id": 1,
    "compute_attributes": {
      "image_id": "",
      "image_ref": ""
    }
  }
}

Unsetting the image id/ref is important, otherwise the VM may boot with a backing volume instead of doing a fresh PXE install. You could specify compute_attributes explicitly instead of using a compute profile.

Optional: Set up Foreman Tasks

This plugin can use Dynflow & ForemanTasks to offload the slow process of building, configuring, and snapshotting the image.

To use this, first configure Foreman-Tasks and then continue with the normal opertion.

The API call should immediately return a Tasks id, and you should be able to view it in /foreman_tasks/tasks.

TODO

Copyright

Copyright © 2014 Red Hat

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 3 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, see www.gnu.org/licenses/.