You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cloudstack.apache.org by "ilya musayev (JIRA)" <ji...@apache.org> on 2013/04/16 21:45:15 UTC
[jira] [Created] (CLOUDSTACK-2053) [BUG] userdata.sh on router VM
fixes for if else logic and missing meta-data
ilya musayev created CLOUDSTACK-2053:
----------------------------------------
Summary: [BUG] userdata.sh on router VM fixes for if else logic and missing meta-data
Key: CLOUDSTACK-2053
URL: https://issues.apache.org/jira/browse/CLOUDSTACK-2053
Project: CloudStack
Issue Type: Bug
Security Level: Public (Anyone can view this level - this is the default.)
Components: Network Controller
Affects Versions: 4.0.0, 4.1.0, 4.2.0
Environment: VSphere 5.0 and ACS 4.1
Reporter: ilya musayev
Assignee: ilya musayev
Fix For: 4.1.0, 4.2.0
Logic in userdata.sh for bash if / else is not optimal and is based on exit codes VS using native "if grep" support. Current logic is causing multiple redundant entries in .htaccess files.
Moreover, we are missing the meta-data rewrite rule in .htaccess file for cloud-init/boto component to configure the vm.
Details:
Instead of doing:
grep -F `echo $entry` $htaccessFile
if [ $? -gt 0 ]; then
echo -e $entry >> $htaccessFile;
fi
result=$?
if [ $result -eq 0 ]; then
entry="Options -Indexes\\nOrder Deny,Allow\\nDeny from all\\nAllow from $vmIp"
htaccessFolder="/var/www/html/$folder/$vmIp"
htaccessFile=$htaccessFolder/.htaccess
mkdir -p $htaccessFolder
echo -e $entry > $htaccessFile
result=$?
fi
We should do:
if ! grep -Fq "$entry" $htaccessFile
then
echo -e $entry >> $htaccessFile;
result=$?
else
entry="Options -Indexes\\nOrder Deny,Allow\\nDeny from all\\nAllow from $vmIp"
htaccessFolder="/var/www/html/$folder/$vmIp"
htaccessFile=$htaccessFolder/.htaccess
mkdir -p $htaccessFolder
echo "echo -e $entry \> $htaccessFile"
echo -e $entry > $htaccessFile
result=$?
fi
I'm still keeping the "result=$?", because the logic is based on exit codes - in other places, however, it is unnecessary.
Also, we are missing Rewrite rule in .htaccess file:
RewriteRule ^meta-data/$ ../metadata/%{REMOTE_ADDR}/meta-data [L,NC,QSA]
RewriteRule ^meta-data/(.*)$ ../metadata/%{REMOTE_ADDR}/$1 [L,NC,QSA]
As boto is looking for meta-data under /var/www/html/latest, but cant find it and fails to proceed.
I will add a function to check if entry exists, and if not, append.
Overall, this fix will keep the .htaccess file much cleaner with only 1 entry per file and dir.
Regards
ilya
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira