Skip to content

Commit 61a414f

Browse files
committed
Inject permium stuff into systemvm.iso when managment server start
1 parent fa96dee commit 61a414f

5 files changed

Lines changed: 83 additions & 0 deletions

File tree

cloud.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ fi
596596
%{_sysconfdir}/%{name}/management/components-premium.xml
597597
%{_datadir}/%{name}/setup/create-database-premium.sql
598598
%{_datadir}/%{name}/setup/create-schema-premium.sql
599+
%{_libdir}/%{name}/agent/vms/premium-systemvm.zip
599600

600601
%files usage
601602
%defattr(0644,root,root,0775)

debian/cloud-premium.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/usr/share/cloud/setup/create-database-premium.sql
77
/usr/share/cloud/setup/create-schema-premium.sql
88
/usr/lib/cloud/agent/premium-scripts/*
9+
/usr/lib/cloud/agent/vms/premium-systemvm.zip
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
# Copies premium stuff to systemvm.iso
3+
4+
#set -x
5+
6+
TMP=${HOME}/tmp
7+
MOUNTPATH=/mnt/cloud/systemvm
8+
TMPDIR=${TMP}/cloud/systemvm
9+
ISOPATH=`dirname $0`/../../../vms/systemvm.iso
10+
STUFFPATH=`dirname $0`/../../../vms/premium-systemvm.zip
11+
12+
13+
14+
clean_up() {
15+
sudo umount $MOUNTPATH
16+
rm -rf $TMPDIR
17+
}
18+
19+
inject_into_iso() {
20+
local isofile=${ISOPATH}
21+
local backup=${isofile}.bak
22+
local tmpiso=${TMP}/$1
23+
[ ! -f $isofile ] && echo "$(basename $0): Could not find systemvm iso patch file $isofile" && return 1
24+
sudo mount -o loop $isofile $MOUNTPATH
25+
[ $? -ne 0 ] && echo "$(basename $0): Failed to mount original iso $isofile" && clean_up && return 1
26+
sudo cp -b $isofile $backup
27+
[ $? -ne 0 ] && echo "$(basename $0): Failed to backup original iso $isofile" && clean_up && return 1
28+
rm -rf $TMPDIR
29+
mkdir -p $TMPDIR
30+
[ ! -d $TMPDIR ] && echo "$(basename $0): Could not find/create temporary dir $TMPDIR" && clean_up && return 1
31+
sudo cp -fr $MOUNTPATH/* $TMPDIR/
32+
[ $? -ne 0 ] && echo "$(basename $0): Failed to copy from original iso $isofile" && clean_up && return 1
33+
sudo cp -f $STUFFPATH $TMPDIR/systemvm.zip
34+
[ $? -ne 0 ] && echo "$(basename $0): Failed to copy sutff $STUFFPATH from to new iso " && clean_up && return 1
35+
mkisofs -quiet -r -o $tmpiso $TMPDIR
36+
[ $? -ne 0 ] && echo "$(basename $0): Failed to create new iso $tmpiso from $TMPDIR" && clean_up && return 1
37+
sudo umount $MOUNTPATH
38+
[ $? -ne 0 ] && echo "$(basename $0): Failed to unmount old iso from $MOUNTPATH" && return 1
39+
sudo cp -f $tmpiso $isofile
40+
[ $? -ne 0 ] && echo "$(basename $0): Failed to overwrite old iso $isofile with $tmpiso" && return 1
41+
rm -rf $TMPDIR
42+
return $?
43+
}
44+
45+
sudo mkdir -p $MOUNTPATH
46+
47+
[ ! -f $STUFFPATH ] && echo "$(basename $0): Could not find $STUFFPATH" && exit 3
48+
command -v mkisofs > /dev/null || (echo "$(basename $0): mkisofs not found, please install or ensure PATH is accurate" ; exit 4)
49+
50+
inject_into_iso systemvm.iso
51+
52+
[ $? -ne 0 ] && exit 5
53+
54+
exit 0

server/src/com/cloud/server/ConfigurationServerImpl.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,29 @@ public ConfigurationServerImpl() {
123123
_ipAddressDao = locator.getDao(IPAddressDao.class);
124124
}
125125

126+
private void updatePremiumStuff() {
127+
if (!_configDao.isPremium()) {
128+
return;
129+
}
130+
131+
String injectScript = "scripts/vm/systemvm/inject_premium_stuff.sh";
132+
String scriptPath = Script.findScript("", injectScript);
133+
if (scriptPath == null) {
134+
throw new CloudRuntimeException("Unable to find key inject script "
135+
+ injectScript);
136+
}
137+
138+
final Script command = new Script(scriptPath, s_logger);
139+
final String result = command.execute();
140+
if (result != null) {
141+
s_logger.warn("Failed to inject premium stuff into systemvm iso "
142+
+ result);
143+
throw new CloudRuntimeException(
144+
"Failed to inject premium stuff into systemvm iso "
145+
+ result);
146+
}
147+
}
148+
126149
@Override @DB
127150
public void persistDefaultValues() throws InvalidParameterValueException, InternalErrorException {
128151

@@ -243,6 +266,8 @@ public void persistDefaultValues() throws InvalidParameterValueException, Intern
243266
}
244267
}
245268

269+
updatePremiumStuff();
270+
246271
// store the public and private keys in the database
247272
updateKeyPairs();
248273

wscript_build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ def build_systemvm_patch ():
158158
bld.install_files ("${AGENTLIBDIR}/vms", "%s/systemvm.zip" % distdir)
159159
# ISO creation
160160
bld.install_as("${AGENTLIBDIR}/vms/systemvm.iso", "%s/systemvm.iso" % distdir)
161+
if buildpremium:
162+
bld.install_as("${AGENTLIBDIR}/vms/premium-systemvm.zip", "%s/premium-systemvm.zip" % distdir)
161163

162164
def build_systemvm_iso ():
163165
if buildpremium:

0 commit comments

Comments
 (0)