Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import OS Parameters patch from GRNET #16

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ overlaysdir=${sysconfdir}/ganeti/instance-image/overlays
toolsdir=$(OS_DIR)/$(osname)/tools

dist_os_SCRIPTS = ${srcdir}/create ${srcdir}/import ${srcdir}/export \
${srcdir}/rename
${srcdir}/rename ${srcdir}/verify
dist_os_DATA = ${srcdir}/ganeti_api_version
dist_config_DATA = ${srcdir}/variants.list
dist_config_DATA = ${srcdir}/variants.list ${srcdir}/parameters.list
os_DATA = common.sh
tools_SCRIPTS = tools/ganeti-image tools/make-image tools/make-dump \
tools/make-qemu-img tools/mount-disks tools/umount-disks
Expand Down Expand Up @@ -71,6 +71,7 @@ install-exec-local:
@mkdir_p@ "$(DESTDIR)$(localstatedir)/cache/ganeti-instance-image"
touch "$(DESTDIR)$(variantsdir)/default.conf"
ln -fs $(DESTDIR)$(configdir)/variants.list $(DESTDIR)$(OS_DIR)/$(osname)/variants.list
ln -fs $(DESTDIR)$(configdir)/parameters.list $(DESTDIR)$(OS_DIR)/$(osname)/parameters.list

distclean-local:
rm -rf build-stamp debian/files debian/*.log debian/ganeti-instance-image/ \
Expand Down
15 changes: 15 additions & 0 deletions common.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ get_api10_arguments() {
old_name=$OLD_INSTANCE_NAME
}

get_api20_parameters() {
if [ -z "$OSP_IMG_ID" -o -z "$OSP_IMG_FORMAT" ]; then
log_error "Missing OS API Parameter:"
log_error "(OSP_IMG_ID or OSP_IMG_FORMAT)"
exit 1
fi
IMG_ID=$OSP_IMG_ID
IMG_FORMAT=$OSP_IMG_FORMAT
IMG_SSH_KEY_URL=$OSP_IMG_SSH_KEY_URL
}

get_os_type() {
target=$1
if [ -z "${target}" ] ; then
Expand Down Expand Up @@ -471,6 +482,10 @@ if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then
get_api5_arguments $GETOPT_RESULT
elif [ "$OS_API_VERSION" = "10" -o "$OS_API_VERSION" = "15" ]; then
get_api10_arguments
elif [ "$OS_API_VERSION" = "20" ]; then
get_api10_arguments
get_api20_parameters
IMAGE_NAME=$IMG_ID
else
log_error "Unknown OS API VERSION $OS_API_VERSION"
exit 1
Expand Down
3 changes: 2 additions & 1 deletion create
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ if [ "$CDINSTALL" = "no" ] ; then
BLOCKDEV=$blockdev
ROOT_DEV=$root_dev
BOOT_DEV=$boot_dev
export TARGET SUITE BLOCKDEV ROOT_DEV BOOT_DEV IMAGE_TYPE
IMG_SSH_KEY_URL="$IMG_SSH_KEY_URL"
export TARGET SUITE BLOCKDEV ROOT_DEV BOOT_DEV IMAGE_TYPE IMG_SSH_KEY_URL
$RUN_PARTS $CUSTOMIZE_DIR
fi
fi
Expand Down
1 change: 1 addition & 0 deletions debian/links
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
etc/ganeti/instance-image/variants.list usr/share/ganeti/os/image/variants.list
etc/ganeti/instance-image/parameters.list usr/share/ganeti/os/image/parameters.list
23 changes: 23 additions & 0 deletions example/hooks/root_ssh_key
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

#
# Copyright (C) 2011 Greek Research and Technology Network
#

set -e

. common.sh

debug set -x

trap cleanup EXIT

if [ -n "${IMG_SSH_KEY_URL}" ]; then
mkdir -p ${TARGET}/root/.ssh
wget -q -O "${TARGET}/root/.ssh/authorized_keys" "${IMG_SSH_KEY_URL}"
echo "Succesfully injected ssh key"
fi

trap - EXIT
exit 0

6 changes: 4 additions & 2 deletions ganeti-instance-image.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ URL: http://code.osuosl.org/projects/ganeti-image
Source0: http://ftp.osuosl.org/pub/osl/ganeti-instance-image/%{name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires: qemu-img, dump, tar, kpartx
Requires: qemu-img, dump, tar, kpartx, ganeti
Requires: qemu-img, dump, tar, kpartx, curl, ganeti
BuildArch: noarch

%description
Expand Down Expand Up @@ -46,8 +46,9 @@ rm -rf $RPM_BUILD_ROOT/%{_datadir}/doc/%{name}
# The install scripts create a symlink using the fully qualified path
# that includes the build root path.
pushd $RPM_BUILD_ROOT%{_datadir}/ganeti/os/%{instancename}
rm -f variants.list
rm -f variants.list parameters.list
ln -s ../../../../..%{_sysconfdir}/ganeti/instance-%{instancename}/variants.list variants.list
ln -s ../../../../..%{_sysconfdir}/ganeti/instance-%{instancename}/parameters.list parameters.list
popd


Expand All @@ -60,6 +61,7 @@ rm -rf $RPM_BUILD_ROOT
%doc COPYING README.markdown NEWS example/hooks/*
%config(noreplace) %{_sysconfdir}/ganeti/instance-%{instancename}/variants/default.conf
%config(noreplace) %{_sysconfdir}/ganeti/instance-%{instancename}/variants.list
%config(noreplace) %{_sysconfdir}/ganeti/instance-%{instancename}/parameters.list
%config(noreplace) %{_sysconfdir}/ganeti/instance-%{instancename}/hooks/*
%{_datadir}/ganeti/os/%{instancename}/*

Expand Down
1 change: 1 addition & 0 deletions ganeti_api_version
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
5
10
15
20
3 changes: 3 additions & 0 deletions parameters.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
img_id The id of the image to be installed (the id will be the image's file name prefix)
img_format The format of the image to be installed
img_ssh_key_url The root ssh key to be injected into the image
8 changes: 8 additions & 0 deletions verify
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if [ "$OSP_IMG_FORMAT" != "tarball" ] && [ "OSP_IMG_FORMAT" != "qemu" ] && [ "OSP_IMG_FORMAT" != "dump" ]; then
echo "Wrong image format. Supported formats are: qemu, tarball, dump." 1>&2
exit 1
fi

exit 0