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

Updated setup-sysvm-tmplt script, to run cmds without sudo #10263

Draft
wants to merge 2 commits into
base: 4.19
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

public class SystemVmTemplateRegistration {
private static final Logger LOGGER = Logger.getLogger(SystemVmTemplateRegistration.class);
private static final String UMOUNT_COMMAND = "sudo umount %s";
private static final String UMOUNT_COMMAND = "umount %s";
private static final String RELATIVE_TEMPLATE_PATH = "./engine/schema/dist/systemvm-templates/";
private static final String ABSOLUTE_TEMPLATE_PATH = "/usr/share/cloudstack-management/templates/systemvm/";
private static final String TEMPLATES_PATH = fetchTemplatesPath();
Expand Down Expand Up @@ -147,7 +147,7 @@
}

public static String getMountCommand(String nfsVersion, String device, String dir) {
String cmd = "sudo mount -t nfs";
String cmd = "mount -t nfs";

Check warning on line 150 in engine/schema/src/main/java/com/cloud/upgrade/SystemVmTemplateRegistration.java

View check run for this annotation

Codecov / codecov/patch

engine/schema/src/main/java/com/cloud/upgrade/SystemVmTemplateRegistration.java#L150

Added line #L150 was not covered by tests
if (StringUtils.isNotBlank(nfsVersion)) {
cmd = String.format("%s -o vers=%s", cmd, nfsVersion);
}
Expand Down
12 changes: 6 additions & 6 deletions scripts/storage/secondary/setup-sysvm-tmplt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fi
localfile=$uuid.$ext


sudo mkdir -p $destdir
mkdir -p $destdir
if [[ $? -ne 0 ]]; then
failed 2 "Failed to write to destdir $destdir -- is it mounted?\n"
fi
Expand All @@ -108,7 +108,7 @@ tmpfolder=/tmp/cloud/templates/
mkdir -p $tmpfolder
tmplfile=$tmpfolder/$localfile

sudo touch $tmplfile
touch $tmplfile
if [[ $? -ne 0 ]]; then
failed 2 "Failed to create temporary file in directory $tmpfolder -- is it read-only or full?\n"
fi
Expand All @@ -121,7 +121,7 @@ localcap=$(df -P $tmpfolder | awk '{print $4}' | tail -1 )


if [[ "$fflag" == "1" ]]; then
sudo cp $tmpltimg $tmplfile
cp $tmpltimg $tmplfile
if [[ $? -ne 0 ]]; then
failed 2 "Failed to create temporary file in directory $tmpfolder -- is it read-only or full?\n"
fi
Expand All @@ -138,7 +138,7 @@ tmpdestdir=$tmpfolder
if [ "$ext" == "ova" ]
then
tar xvf $tmpdestdir/$localfile -C $tmpdestdir &> /dev/null
sudo cp $tmpdestdir/*.vmdk $tmpdestdir/*.mf $tmpdestdir/*.ovf $destdir/
cp $tmpdestdir/*.vmdk $tmpdestdir/*.mf $tmpdestdir/*.ovf $destdir/
rm -rf $tmpdestdir/*.vmdk $tmpdestdir/*.mf $tmpdestdir/*.ovf $tmpdestdir/*.ova
else
rm -rf $tmpdestdir/*.tmp
Expand All @@ -154,7 +154,7 @@ else
fi

templateId=${destdir##*/}
sudo touch $destdir/template.properties
touch $destdir/template.properties
echo "$ext=true" >> $tmpdestdir/template.properties
echo "id=$templateId" >> $tmpdestdir/template.properties
echo "public=true" >> $tmpdestdir/template.properties
Expand All @@ -164,7 +164,7 @@ echo "$ext.virtualsize=$vrtmpltsize" >> $tmpdestdir/template.properties
echo "virtualsize=$vrtmpltsize" >> $tmpdestdir/template.properties
echo "$ext.size=$tmpltsize" >> $tmpdestdir/template.properties

sudo cp $tmpdestdir/template.properties $destdir/template.properties
cp $tmpdestdir/template.properties $destdir/template.properties
if [ -f "$tmpdestdir/template.properties" ]
then
rm -rf $tmpdestdir/template.properties
Expand Down
Loading