<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello<div><br></div><div>I'm having problem deploying VMs using context. According to VM's log, the context block device gets generated but init.sh won't run. My goal is to configure VM with static IP address (no DHCP server) and hostname on the new VMs.</div><div><pre style="color: rgb(34, 34, 34); font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); position: static; z-index: auto; ">hu Sep 13 17:40:35 2012 [DiM][I]: New VM state is ACTIVE.
Thu Sep 13 17:40:35 2012 [LCM][I]: New VM state is PROLOG.
Thu Sep 13 17:41:45 2012 [TM][I]: clone: Cloning ../../1/a0163ea0265ead2c81030ae4680ec359 in hb13.cluster.net:/var/lib/one//datastores/0/50/disk.0
Thu Sep 13 17:41:45 2012 [TM][I]: ExitCode: 0
Thu Sep 13 17:41:46 2012 [TM][I]: context: Generating context block device at hb13.cluster.net:/var/lib/one//datastores/0/50/disk.1
Thu Sep 13 17:41:46 2012 [TM][I]: ExitCode: 0
Thu Sep 13 17:41:46 2012 [LCM][I]: New VM state is BOOT
Thu Sep 13 17:41:46 2012 [VMM][I]: Generating deployment file: /var/lib/one/50/deployment.0
Thu Sep 13 17:41:46 2012 [VMM][I]: ExitCode: 0
Thu Sep 13 17:41:46 2012 [VMM][I]: Successfully execute network driver operation: pre.
Thu Sep 13 17:41:46 2012 [VMM][I]: ExitCode: 0
Thu Sep 13 17:41:46 2012 [VMM][I]: Successfully execute virtualization driver operation: deploy.
Thu Sep 13 17:41:46 2012 [VMM][I]: ExitCode: 0
Thu Sep 13 17:41:46 2012 [VMM][I]: Successfully execute network driver operation: post.
Thu Sep 13 17:41:46 2012 [LCM][I]: New VM state is RUNNING
Thu Sep 13 17:51:47 2012 [VMM][I]: ExitCode: 0
Thu Sep 13 17:51:47 2012 [VMM][D]: Monitor Information:</pre><div>My disk image configured to run init.sh on boot:</div></div><div><br></div><div><div>[root@localhost ~]# cat /etc/rc.local </div><div>#!/bin/sh</div><div>#</div><div># This script will be executed *after* all the other init scripts.</div><div># You can put your own initialization stuff in here if you don't</div><div># want to do the full Sys V style init stuff.</div><div><br></div><div>touch /var/lock/subsys/local</div><div>mount -t iso9660 /dev/sdb /mnt</div><div>if [-f /mnt/context.sh];</div><div>then</div><div>./mnt/init.sh</div><div>fi</div><div>umount /mnt</div></div><div><br></div><div><br></div><div>Here is my template:</div><div><br></div><div><div>NAME = "master"</div><div>CPU = 1</div><div>MEMORY = 1024</div><div><br></div><div>FEATURES=[ ACPI=yes ]</div><div><br></div><div>DISK = [</div><div> IMAGE_ID = 18,</div><div> driver = raw,</div><div> readonly = no,</div><div> target = sda,</div><div> type = disk,</div><div> bus = virtio ]</div><div><br></div><div># swap, sdd</div><div>#DISK = [ TYPE = swap,</div><div># SIZE = 1024,</div><div># READONLY = "no" ]</div><div><br></div><div>#DISK = [ TYPE = fs,</div><div># SIZE = 4096,</div><div># FORMAT = ext3,</div><div># SAVE = yes,</div><div># TARGET = sdc ]</div><div><br></div><div>GRAPHICS = [</div><div> type = "vnc",</div><div> keymap = "en-us",</div><div> listen = "0.0.0.0"]</div><div><br></div><div>NIC = [</div><div> network = "Small network",</div><div> bridge = "br2",</div><div> model = virtio ]</div><div><br></div><div>#NIC = [</div><div># network = "public",</div><div># bridge = "br0",</div><div># model = virtio ]</div><div><br></div><div>OS = [</div><div> boot = hd,</div><div> arch = x86_64 ]</div><div><br></div><div>RAW=[ TYPE=kvm ]</div><div><br></div><div><br></div><div>CONTEXT = [</div><div> HOSTNAME = "dev-$VMID",</div><div> IP_PRIVATE = "NIC[IP,NETWORK=\"private\"]",</div><div> DNS = "$NETWORK[DNS, NAME=\"private\"]",</div><div> username = devuser,</div><div> files = "/var/lib/one/rhel/init.sh",</div><div> TARGET = sdb,</div><div> IP_GEN = "10.4.10.$VMID"</div></div><div><br></div><div>And init.sh script</div><div><br></div><div><div>#!/bin/bash</div><div>if [ -f /mnt/context.sh ]</div><div>then</div><div> . /mnt/context.sh</div><div>fi</div><div><br></div><div><br></div><div>if [ -n "$HOSTNAME" ]; then</div><div> echo $HOSTNAME > /etc/HOSTNAME</div><div> hostname $HOSTNAME</div><div>fi</div><div><br></div><div>if [ -n "$IP_PUBLIC" ]; then</div><div> ifconfig eth0 $IP_PUBLIC</div><div>fi</div><div><br></div><div>if [ -n "$NETMASK" ]; then</div><div> ifconfig eth0 netmask $NETMASK</div><div>fi</div><div>if [ -n "$USERNAME" ]; then</div><div> adduser -s /bin/bash -D $USERNAME</div><div> if [ -f /mnt/context/$USER_PUBKEY ]; then</div><div> mkdir -p /home/$USERNAME/.ssh/</div><div> cat /mnt/context/$USER_PUBKEY >> /home/$USERNAME/.ssh/authorized_keys</div><div> chown -R $USERNAME /home/$USERNAME/.ssh</div><div> chmod -R 600 /home/$USERNAME/.ssh</div><div> fi</div><div>fi</div></div><div><br></div></body></html>