<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hello Pedro,<br><br>Indeed, my problem was that the init.sh script has not been at all executed. I've spent the last day trying to trace down the problem, which was rather weird, since the exact same configuration (as presented in the example in the documentation you provided, too) worked on another one of my images, and the init.sh script was properly called. I didn't manage to find the cause, however, I did manage to solve my problem with a simple workaround applicable in my case, which was to set the following script as an init script on my respective image: <br><br># OpenNebula Network Contextualization<br><span style="font-family: courier,monaco,monospace,sans-serif;">MAC=`ifconfig eth0|grep HWaddr|awk '{print $5}'`</span><br style="font-family: courier,monaco,monospace,sans-serif;"><br style="font-family: courier,monaco,monospace,sans-serif;"><span
 style="font-family: courier,monaco,monospace,sans-serif;">for i in `echo $MAC|cut -d: -f3-|tr : ' '`; do</span><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;">    [ -n "$IP" ] && IP=$IP.</span><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;">    let c=0x$i</span><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;">    IP=${IP}$c</span><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;">done</span><br style="font-family: courier,monaco,monospace,sans-serif;"><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;">GATEWAY=`echo $IP|cut
 -d. -f1-3`.1</span><br style="font-family: courier,monaco,monospace,sans-serif;"><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;">ifconfig eth0 $IP netmask 255.255.0.0</span><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;">route add default gw $GATEWAY</span><br style="font-family: courier,monaco,monospace,sans-serif;"><br style="font-weight: bold; font-family: courier,monaco,monospace,sans-serif;"><span style="font-weight: bold; font-family: courier,monaco,monospace,sans-serif;">hostname "SLAVE${IP:9:12}"</span><br><br>This last line sets the hostname at the first boot to <SLAVE+the_digits_after_the_last_dot_in_the_VM's_IP_address>, and that was just what I needed.<br><br>Thank you for taking the time to answer.<br><br>Cheers,<br>Lehel.<br><br><br>--- On <b>Wed, 4/18/12, Pedro Vitti
 <i><pedrovitti@gmail.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Pedro Vitti <pedrovitti@gmail.com><br>Subject: Re: [one-users] Trouble setting VM's hostname<br>To: "biro lehel" <lehel.biro@yahoo.com><br>Cc: users@lists.opennebula.org<br>Date: Wednesday, April 18, 2012, 12:57 AM<br><br><div id="yiv1188372856">Hello,<br><br>Are you sure that your init script is running at VM startup? <br>If so, be sure to 'source' the file context.sh that contains $HOSTNAME definition, before running your script.<br><br>If you are using hdc as your device where the contextualization image will be available, you can use something like this at startup:<br>
<br><span style="color:rgb(0,0,0);">#!/bin/sh -e</span><br style="color:rgb(0,0,0);"><span style="color:rgb(0,0,0);"> </span><span style="color:rgb(0,0,0);"><br>mount -t iso9660 /dev/sdc /mnt</span><br style="color:rgb(0,0,0);">
<span style="color:rgb(0,0,0);"> </span><br style="color:rgb(0,0,0);"><span style="color:rgb(0,0,0);">if [ -f /mnt/context.sh ]; then</span><br style="color:rgb(0,0,0);"><span style="color:rgb(0,0,0);">  . /mnt/init.sh</span><br style="color:rgb(0,0,0);">
<span style="color:rgb(0,0,0);">fi</span><br style="color:rgb(0,0,0);"><span style="color:rgb(0,0,0);"> </span><br style="color:rgb(0,0,0);"><span style="color:rgb(0,0,0);">umount /mnt</span><br style="color:rgb(0,0,0);"><span style="color:rgb(0,0,0);"></span><span style="color:rgb(0,0,0);">exit 0<br>
<br></span>Take a look at last section (EXAMPLE) here: <a rel="nofollow" target="_blank" href="http://opennebula.org/documentation:archives:rel3.2:cong">http://opennebula.org/documentation:archives:rel3.2:cong</a><br>For opensuse init script, read this: <a rel="nofollow" target="_blank" href="http://www.novell.com/coolsolutions/feature/15380.html">http://www.novell.com/coolsolutions/feature/15380.html</a><br>
<div class="yiv1188372856gmail_quote"><br>Regars,<br>Pedro Vitti<br><br>On Tue, Apr 17, 2012 at 5:56 AM, biro lehel <span dir="ltr"><<a rel="nofollow" ymailto="mailto:lehel.biro@yahoo.com" target="_blank" href="/mc/compose?to=lehel.biro@yahoo.com">lehel.biro@yahoo.com</a>></span> wrote:<br><blockquote class="yiv1188372856gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font:inherit;" valign="top">Hello again,<br><br>I currently have an init script which I copy to the newly instantiated VM using the template's contextualization (FILES=.../init.sh). This script contains (among others) the following section:<br>
<br><span style="font-family:courier, monaco, monospace, sans-serif;">if [ -n "$HOSTNAME" ]; then</span><br style="font-family:courier, monaco, monospace, sans-serif;"><span style="font-family:courier, monaco, monospace, sans-serif;">    hostname $HOSTNAME</span><br>
<br>HOSTNAME is also a contextualized parameter, as I set HOSTNAME=MyHostName also in the contextualization section of my VM's template.<br>I would expect this to set my hostname as MyHostName on the instantiated VM. However, the hostname remains the same (meaning it still remains the same hostname as it is in my image that the respective template uses).<br>
<br>I'm using
 openSUSE 11.4 and OpenNebula 3.2.0.<br><br>What are the other ways to try to set the hostname in my VM's? Since more VM's will use the same image, I cannot simply set it in my image. Is anything need to be done regarding the hostname in the respective image?<br>
<br>Thanks, <br>Lehel.<br><br></td></tr></tbody></table><br>_______________________________________________<br>
Users mailing list<br>
<a rel="nofollow" ymailto="mailto:Users@lists.opennebula.org" target="_blank" href="/mc/compose?to=Users@lists.opennebula.org">Users@lists.opennebula.org</a><br>
<a rel="nofollow" target="_blank" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
<br></blockquote></div><br>
</div></blockquote></td></tr></table>