Return-Path: X-Original-To: apmail-cloudstack-issues-archive@www.apache.org Delivered-To: apmail-cloudstack-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D7B03C53E for ; Fri, 19 Jul 2013 15:16:56 +0000 (UTC) Received: (qmail 98994 invoked by uid 500); 19 Jul 2013 15:16:56 -0000 Delivered-To: apmail-cloudstack-issues-archive@cloudstack.apache.org Received: (qmail 98912 invoked by uid 500); 19 Jul 2013 15:16:56 -0000 Mailing-List: contact issues-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list issues@cloudstack.apache.org Received: (qmail 98895 invoked by uid 500); 19 Jul 2013 15:16:56 -0000 Delivered-To: apmail-incubator-cloudstack-issues@incubator.apache.org Received: (qmail 98885 invoked by uid 99); 19 Jul 2013 15:16:56 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jul 2013 15:16:56 +0000 Date: Fri, 19 Jul 2013 15:16:56 +0000 (UTC) From: "ilya musayev (JIRA)" To: cloudstack-issues@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CLOUDSTACK-2053) [BUG] userdata.sh on router VM fixes for if else logic and missing meta-data MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CLOUDSTACK-2053?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13713758#comment-13713758 ] ilya musayev commented on CLOUDSTACK-2053: ------------------------------------------ Applied to 4.1, 4.2 and master. Closing this issue. > [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 > Labels: ROUTERVM > Fix For: 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