##!/bin/bash
# Migrates the machine named $1 from the dev cluster.
# To be run on the prod cluster.

## The present version is NOT A REAL SCRIPT.
## Things may not even be tested.  Copy and paste.

## dump from dev db; save info well

#echo "\\a \\t \\\\ select * from machines where name = '$MACHINE';" \
# | psql -h xvm -U sipb-xen sipb_xen -q
## 581|fsck|256|price|price|2ab6638f-3f65-2b32-3fd3-c16b74a9b7fe|linux|f|1|price|test|f
## watch out for funny characters in description; better (non-)quoting needed
## also disks, nics

## remove from dev db; ideally atomic with dump

## shut down if up
#remctl remote control $MACHINE destroy

## copy disk image... copy, copy...
## for each disk:
lvname="d_${MACHINE}_${guest_device_name}"
lvcreate xenvg -n "$lvname" -L "${size}"M
ssh t-i dd if=/dev/xenvg/"$lvname" of=/dev/stdout bs=1M \
 | dd if=/dev/stdin of=/dev/xenvg/"$lvname" bs=1M

## add to dev db

## power on if desired
