[one-users] problem running vm context image

Andrei Vakhnin Andrey.A.Vakhnin at nasa.gov
Thu Sep 13 14:59:47 PDT 2012


Hello

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.
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:
My disk image configured to run init.sh on boot:

[root at localhost ~]# cat /etc/rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
mount -t iso9660 /dev/sdb /mnt
if [-f /mnt/context.sh];
then
./mnt/init.sh
fi
umount /mnt


Here is my template:

NAME   = "master"
CPU    = 1
MEMORY = 1024

FEATURES=[ ACPI=yes ]

DISK = [
        IMAGE_ID = 18,
        driver = raw,
        readonly = no,
        target = sda,
        type = disk,
        bus = virtio ]

# swap, sdd
#DISK = [ TYPE     = swap,
#         SIZE     = 1024,
#         READONLY = "no" ]

#DISK = [ TYPE   = fs,
#         SIZE   = 4096,
#         FORMAT = ext3,
#         SAVE   = yes,
#         TARGET = sdc ]

GRAPHICS = [
        type = "vnc",
        keymap = "en-us",
        listen = "0.0.0.0"]

NIC = [
        network = "Small network",
        bridge = "br2",
        model = virtio ]

#NIC = [
#        network = "public",
#        bridge = "br0",
#        model = virtio ]

OS = [
        boot = hd,
        arch = x86_64 ]

RAW=[ TYPE=kvm ]


CONTEXT = [
  HOSTNAME   = "dev-$VMID",
  IP_PRIVATE = "NIC[IP,NETWORK=\"private\"]",
  DNS        = "$NETWORK[DNS, NAME=\"private\"]",
  username  = devuser,
  files     = "/var/lib/one/rhel/init.sh",
  TARGET    = sdb,
  IP_GEN     = "10.4.10.$VMID"

And init.sh script

#!/bin/bash
if [ -f /mnt/context.sh ]
then
  . /mnt/context.sh
fi


if [ -n "$HOSTNAME" ]; then
    echo $HOSTNAME > /etc/HOSTNAME
    hostname $HOSTNAME
fi

if [ -n "$IP_PUBLIC" ]; then
    ifconfig eth0 $IP_PUBLIC
fi

if [ -n "$NETMASK" ]; then
    ifconfig eth0 netmask $NETMASK
fi
if [ -n "$USERNAME" ]; then
    adduser -s /bin/bash -D $USERNAME
    if [ -f /mnt/context/$USER_PUBKEY ]; then
        mkdir -p /home/$USERNAME/.ssh/
        cat /mnt/context/$USER_PUBKEY >> /home/$USERNAME/.ssh/authorized_keys
        chown -R $USERNAME /home/$USERNAME/.ssh
        chmod -R 600 /home/$USERNAME/.ssh
    fi
fi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20120913/0020be88/attachment.htm>


More information about the Users mailing list