File: install-export-import

package info (click to toggle)
ganeti-instance-debootstrap 0.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 240 kB
  • sloc: sh: 488; makefile: 54
file content (67 lines) | stat: -rwxr-xr-x 1,518 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash

set -eu

if [ $(id -u) != 0 ]; then
  echo "Testing requires root due to losetup/kpartx usage" 2>&1
  exit 77
fi

TEMPDIR=$(mktemp -d)
trap 'rm -rf "$TEMPDIR"' EXIT

DISK0="$TEMPDIR/disk0"
dd if=/dev/zero of="$DISK0" bs=1024k count=512

DUMP="$TEMPDIR/dump"

# check that we can actually run losetup, otherwise we might be under
# fakeroot, for example; include sbin* dirs in PATH to ensure we don't
# fail due to command not found.
PATH=$PATH:/sbin:/usr/sbin
LOOP=$(losetup --show -f "$DISK0") || \
  { echo "losetup doesn't work, skipping test" 2>&1 ;
    exit 77;
  }
losetup -d "$LOOP"

echo "Installing instance..."
GENERATE_CACHE=no \
  CLEAN_CACHE="" \
  OS_API_VERSION=10 \
  INSTANCE_NAME=foo.example.com \
  HYPERVISOR=dont-care \
  DISK_COUNT=1 \
  DISK_0_PATH="$DISK0" \
  $srcdir/create

echo "Exporting instance..."

OS_API_VERSION=10 \
  INSTANCE_NAME=foo.example.com \
  HYPERVISOR=dont-care \
  DISK_COUNT=1 \
  DISK_0_PATH="$DISK0" \
  EXPORT_DISK_PATH="$DISK0" \
  EXPORT_DEVICE="$DISK0" \
  EXPORT_INDEX=0 \
  $srcdir/export > "$DUMP"

echo "Importing instance..."

# first wipe the disk.
dd if=/dev/zero of="$DISK0" bs=1024k count=512

OS_API_VERSION=10 \
  INSTANCE_NAME=foo.example.com \
  HYPERVISOR=dont-care \
  DISK_COUNT=1 \
  DISK_0_PATH="$DISK0" \
  IMPORT_DISK_PATH="$DISK0" \
  IMPORT_DEVICE="$DISK0" \
  IMPORT_INDEX=0 \
  $srcdir/import < "$DUMP"

# Do a listing of the directory (to see the size of the dump, a proxy
# for the needed install space).
ls -l -h "$TEMPDIR"