Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add onebootstrap

  • Loading branch information...
commit 76ecc252e4c30a36c8a1c441bfc0bd3dc0620318 1 parent 265a6da
@jmelis jmelis authored
View
19 README.md
@@ -97,3 +97,22 @@ Opens the VNC console of a running VM:
$ onevnc 9
+onebootstrap
+------------
+
+This command should be executed only with a fresh OpenNebula installation. It
+will create some resources:
+
+* __host__: localhost with KVM configuration
+* __vnet__: a few IPs in the 172.16.0.0/24 network connected to bridge `br0`
+* __datastore__: a file-system based user datastore
+* __image__: an Ubuntu image (users will have to execute first
+`bootstrap/image/download_ubuntu.sh`)
+* __template__: an Ubuntu template ready to be instantiated
+
+All of these resources can be customized by editing the files inside
+`bootstrap/`. Other resources can be added and they will also be created.
+
+The datastore where the images will be instantiated needs to have `DEFAULT =
+YES` inside the template. This is only necessary if more than one template is
+created.
View
7 bootstrap/datastore/ds1.datastore
@@ -0,0 +1,7 @@
+NAME = ds_user
+DS_MAD = fs
+TM_MAD = shared
+
+SAFE_DIRS = "/"
+
+DEFAULT = YES
View
3  bootstrap/host/localhost.host
@@ -0,0 +1,3 @@
+IM=im_kvm
+VMM=vmm_kvm
+NET=dummy
View
20 bootstrap/image/download_ubuntu.sh
@@ -0,0 +1,20 @@
+#!/bin/bash -e
+
+# This script downloads an ubuntu image for KVM and creates an image template
+# for it, which can be used later in the onebootstrap script.
+
+REALPATH=$(readlink -f $0)
+cd `dirname $REALPATH`
+
+ID=4fc76a938fb81d3517000001
+NAME="ubuntu-server-12.04"
+
+URL="https://marketplace.c12g.com/appliance/$ID/download"
+
+curl -sLk $URL | bunzip2 -c > $NAME.img
+
+cat <<EOF > $NAME.image
+NAME = "$NAME"
+PATH = $(pwd)/$NAME.img
+PUBLIC = YES
+EOF
View
18 bootstrap/template/ubuntu.template
@@ -0,0 +1,18 @@
+NAME = ubuntu
+
+CPU = 1
+VCPU = 1
+MEMORY = 512
+
+OS = [ arch = "x86_64" ]
+
+DISK = [
+ IMAGE = "ubuntu-server-12.04"
+]
+
+NIC = [ NETWORK = "net_172" ]
+
+GRAPHICS = [
+ TYPE = "vnc",
+ LISTEN = "0.0.0.0"
+]
View
12 bootstrap/vnet/net_127.vnet
@@ -0,0 +1,12 @@
+NAME = "net_172"
+TYPE = fixed
+BRIDGE = br0
+
+LEASES = [ IP = 172.16.0.200 ]
+LEASES = [ IP = 172.16.0.201 ]
+LEASES = [ IP = 172.16.0.202 ]
+LEASES = [ IP = 172.16.0.203 ]
+LEASES = [ IP = 172.16.0.204 ]
+LEASES = [ IP = 172.16.0.205 ]
+LEASES = [ IP = 172.16.0.206 ]
+LEASES = [ IP = 172.16.0.207 ]
View
42 onebootstrap
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+REALPATH=$(readlink -f $0)
+cd `dirname $REALPATH`
+
+for host in $(ls bootstrap/host/*.host 2>/dev/null); do
+ unset IM VMM NET
+ source $host
+
+ HOSTNAME=$(basename $host)
+ HOSTNAME=${HOSTNAME%%.host}
+
+ onehost create $HOSTNAME -i $IM -v $VMM -n $NET
+done
+
+for vnet in $(ls bootstrap/vnet/*.vnet 2>/dev/null); do
+ onevnet create $vnet
+done
+
+unset DEFAULT_DS
+for datastore in $(ls bootstrap/datastore/*.datastore 2>/dev/null); do
+ DS_ID=$(onedatastore create $datastore|awk '{print $2}')
+
+ # If it's the first registered datastore, mark it as default
+ [ -z "$DEFAULT_DS" ] && DEFAULT_DS=$DS_ID
+
+ # If it has DEFAULT inside the template mark it as default
+ if cat $datastore | grep -q DEFAULT; then
+ DEFAULT_DS=$DS_ID
+ fi
+done
+
+# If no datastore was created, used DS 1 as the default
+[ -z "DEFAULT_DS" ] && DEFAULT_DS=1
+
+for image in $(ls bootstrap/image/*.image 2>/dev/null); do
+ oneimage create $image -d $DEFAULT_DS
+done
+
+for template in $(ls bootstrap/template/*.template 2>/dev/null); do
+ onetemplate create $template
+done
Please sign in to comment.
Something went wrong with that request. Please try again.