From 4540821caa31dc9ed0bedf521cd36975ddafebfa Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 14 Aug 2012 11:46:42 -0400 Subject: doc: move datasource documentation to doc/sources Each datasource had a bit of doc with it, and those were just landing in doc/. I've moved them to doc/sources now. --- doc/altcloud/README | 65 ------------- doc/configdrive/README | 118 ---------------------- doc/kernel-cmdline.txt | 48 --------- doc/nocloud/README | 55 ----------- doc/ovf/README | 83 ---------------- doc/ovf/example/ovf-env.xml | 46 --------- doc/ovf/example/ubuntu-server.ovf | 130 ------------------------- doc/ovf/make-iso | 156 ------------------------------ doc/ovf/ovf-env.xml.tmpl | 28 ------ doc/ovf/ovfdemo.pem | 27 ------ doc/ovf/user-data | 7 -- doc/sources/altcloud/README | 65 +++++++++++++ doc/sources/configdrive/README | 118 ++++++++++++++++++++++ doc/sources/kernel-cmdline.txt | 48 +++++++++ doc/sources/nocloud/README | 55 +++++++++++ doc/sources/ovf/README | 83 ++++++++++++++++ doc/sources/ovf/example/ovf-env.xml | 46 +++++++++ doc/sources/ovf/example/ubuntu-server.ovf | 130 +++++++++++++++++++++++++ doc/sources/ovf/make-iso | 156 ++++++++++++++++++++++++++++++ doc/sources/ovf/ovf-env.xml.tmpl | 28 ++++++ doc/sources/ovf/ovfdemo.pem | 27 ++++++ doc/sources/ovf/user-data | 7 ++ 22 files changed, 763 insertions(+), 763 deletions(-) delete mode 100644 doc/altcloud/README delete mode 100644 doc/configdrive/README delete mode 100644 doc/kernel-cmdline.txt delete mode 100644 doc/nocloud/README delete mode 100644 doc/ovf/README delete mode 100644 doc/ovf/example/ovf-env.xml delete mode 100644 doc/ovf/example/ubuntu-server.ovf delete mode 100755 doc/ovf/make-iso delete mode 100644 doc/ovf/ovf-env.xml.tmpl delete mode 100644 doc/ovf/ovfdemo.pem delete mode 100644 doc/ovf/user-data create mode 100644 doc/sources/altcloud/README create mode 100644 doc/sources/configdrive/README create mode 100644 doc/sources/kernel-cmdline.txt create mode 100644 doc/sources/nocloud/README create mode 100644 doc/sources/ovf/README create mode 100644 doc/sources/ovf/example/ovf-env.xml create mode 100644 doc/sources/ovf/example/ubuntu-server.ovf create mode 100755 doc/sources/ovf/make-iso create mode 100644 doc/sources/ovf/ovf-env.xml.tmpl create mode 100644 doc/sources/ovf/ovfdemo.pem create mode 100644 doc/sources/ovf/user-data (limited to 'doc') diff --git a/doc/altcloud/README b/doc/altcloud/README deleted file mode 100644 index 87d7949a..00000000 --- a/doc/altcloud/README +++ /dev/null @@ -1,65 +0,0 @@ -Data souce AltCloud will be used to pick up user data on -RHEVm and vSphere. - -RHEVm: -====== -For REHVm v3.0 the userdata is injected into the VM using floppy -injection via the RHEVm dashboard "Custom Properties". The format -of the Custom Properties entry must be: -"floppyinject=user-data.txt:" - -e.g.: To pass a simple bash script - -% cat simple_script.bash -#!/bin/bash -echo "Hello Joe!" >> /tmp/JJV_Joe_out.txt - -% base64 < simple_script.bash -IyEvYmluL2Jhc2gKZWNobyAiSGVsbG8gSm9lISIgPj4gL3RtcC9KSlZfSm9lX291dC50eHQK - -To pass this example script to cloud-init running in a RHEVm v3.0 VM -set the "Custom Properties" when creating the RHEMv v3.0 VM to: -floppyinject=user-data.txt:IyEvYmluL2Jhc2gKZWNobyAiSGVsbG8gSm9lISIgPj4gL3RtcC9KSlZfSm9lX291dC50eHQK - -NOTE: The prefix with file name must be: "floppyinject=user-data.txt:" - -It is also possible to launch a RHEVm v3.0 VM and pass optional user -data to it using the Delta Cloud. -For more inforation on Delta Cloud see: http://deltacloud.apache.org - -vSphere: -======== -For VMWare's vSphere the userdata is injected into the VM an ISO -via the cdrom. This can be done using the vSphere dashboard -by connecting an ISO image to the CD/DVD drive. - -To pass this example script to cloud-init running in a vSphere VM -set the CD/DVD drive when creating the vSphere VM to point to an -ISO on the data store. - -The ISO must contain the user data: - -For example, to pass the same simple_script.bash to vSphere: - -Create the ISO: -=============== -% mkdir my-iso - -NOTE: The file name on the ISO must be: "user-data.txt" -% cp simple_scirpt.bash my-iso/user-data.txt - -% genisoimage -o user-data.iso -r my-iso - -Verify the ISO: -=============== -% sudo mkdir /media/vsphere_iso -% sudo mount -o loop JoeV_CI_02.iso /media/vsphere_iso -% cat /media/vsphere_iso/user-data.txt -% sudo umount /media/vsphere_iso - -Then, launch the vSphere VM the ISO user-data.iso attached as a CDrom. - -It is also possible to launch a vSphere VM and pass optional user -data to it using the Delta Cloud. - -For more inforation on Delta Cloud see: http://deltacloud.apache.org diff --git a/doc/configdrive/README b/doc/configdrive/README deleted file mode 100644 index ed9033c9..00000000 --- a/doc/configdrive/README +++ /dev/null @@ -1,118 +0,0 @@ -The 'ConfigDrive' DataSource supports the OpenStack configdrive disk. -See doc/source/api_ext/ext_config_drive.rst in the nova source code for -more information on config drive. - -The following criteria are required to be identified by -DataSourceConfigDrive as a config drive: - * must be formated with vfat filesystem - * must be a un-partitioned block device (/dev/vdb, not /dev/vdb1) - * must contain one of the following files: - * etc/network/interfaces - * root/.ssh/authorized_keys - * meta.js - -By default, cloud-init does not consider this source to be a full-fledged -datasource. Instead, the default behavior is to assume it is really only -present to provide networking information. Cloud-init will copy off the -network information, apply it to the system, and then continue on. The -"full" datasource would then be found in the EC2 metadata service. - -== Content of config-drive == - * etc/network/interfaces - This file is laid down by nova in order to pass static networking - information to the guest. Cloud-init will copy it off of the config-drive - and into /etc/network/interfaces as soon as it can, and then attempt to - bring up all network interfaces. - - * root/.ssh/authorized_keys - This file is laid down by nova, and contains the keys that were - provided to it on instance creation (nova-boot --key ....) - - Cloud-init will copy those keys and put them into the configured user - ('ubuntu') .ssh/authorized_keys. - - * meta.js - meta.js is populated on the config-drive in response to the user passing - "meta flags" (nova boot --meta key=value ...). It is expected to be json - formated. - -== Configuration == -Cloud-init's behavior can be modified by keys found in the meta.js file in -the following ways: - * dsmode: - values: local, net, pass - default: pass - - This is what indicates if configdrive is a final data source or not. - By default it is 'pass', meaning this datasource should not be read. - Set it to 'local' or 'net' to stop cloud-init from continuing on to - search for other data sources after network config. - - The difference between 'local' and 'net' is that local will not require - networking to be up before user-data actions (or boothooks) are run. - - * instance-id: - default: iid-dsconfigdrive - This is utilized as the metadata's instance-id. It should generally - be unique, as it is what is used to determine "is this a new instance". - - * public-keys: - default: None - if present, these keys will be used as the public keys for the - instance. This value overrides the content in authorized_keys. - Note: it is likely preferable to provide keys via user-data - - * user-data: - default: None - This provides cloud-init user-data. See other documentation for what - all can be present here. - -== Example == -Here is an example using the nova client (python-novaclien) - -Assuming the following variables set up: - * img_id : set to the nova image id (uuid from image-list) - * flav_id : set to numeric flavor_id (nova flavor-list) - * keyname : set to name of key for this instance (nova keypair-list) - -$ cat my-user-data -#!/bin/sh -echo ==== USER_DATA FROM EC2 MD ==== | tee /ud.log - -$ ud_value=$(sed 's,EC2 MD,META KEY,') - -## Now, 'ud_value' has same content of my-user-data file, but -## with the string "USER_DATA FROM META KEY" - -## launch an instance with dsmode=pass -## This will really not use the configdrive for anything as the mode -## for the datasource is 'pass', meaning it will still expect some -## other data source (DataSourceEc2). - -$ nova boot --image=$img_id --config-drive=1 --flavor=$flav_id \ - --key_name=$keyname \ - --user_data=my-user-data \ - "--meta=instance-id=iid-001 \ - "--meta=user-data=${ud_keyval}" \ - "--meta=dsmode=pass" cfgdrive-dsmode-pass - -$ euca-get-console-output i-0000001 | grep USER_DATA -echo ==== USER_DATA FROM EC2 MD ==== | tee /ud.log - -## Now, launch an instance with dsmode=local -## This time, the only metadata and userdata available to cloud-init -## are on the config-drive -$ nova boot --image=$img_id --config-drive=1 --flavor=$flav_id \ - --key_name=$keyname \ - --user_data=my-user-data \ - "--meta=instance-id=iid-001 \ - "--meta=user-data=${ud_keyval}" \ - "--meta=dsmode=local" cfgdrive-dsmode-local - -$ euca-get-console-output i-0000002 | grep USER_DATA -echo ==== USER_DATA FROM META KEY ==== | tee /ud.log - --- -[1] https://github.com/openstack/nova/blob/master/doc/source/api_ext/ext_config_drive.rst for more if - - diff --git a/doc/kernel-cmdline.txt b/doc/kernel-cmdline.txt deleted file mode 100644 index 0b77a9af..00000000 --- a/doc/kernel-cmdline.txt +++ /dev/null @@ -1,48 +0,0 @@ -In order to allow an ephemeral, or otherwise pristine image to -receive some configuration, cloud-init will read a url directed by -the kernel command line and proceed as if its data had previously existed. - -This allows for configuring a meta-data service, or some other data. - -Note, that usage of the kernel command line is somewhat of a last resort, -as it requires knowing in advance the correct command line or modifying -the boot loader to append data. - -For example, when 'cloud-init start' runs, it will check to -see if if one of 'cloud-config-url' or 'url' appear in key/value fashion -in the kernel command line as in: - root=/dev/sda ro url=http://foo.bar.zee/abcde - -Cloud-init will then read the contents of the given url. -If the content starts with '#cloud-config', it will store -that data to the local filesystem in a static filename -'/etc/cloud/cloud.cfg.d/91_kernel_cmdline_url.cfg', and consider it as -part of the config from that point forward. - -If that file exists already, it will not be overwritten, and the url parameters -completely ignored. - -Then, when the DataSource runs, it will find that config already available. - -So, in able to configure the MAAS DataSource by controlling the kernel -command line from outside the image, you can append: - url=http://your.url.here/abcdefg -or - cloud-config-url=http://your.url.here/abcdefg - -Then, have the following content at that url: - #cloud-config - datasource: - MAAS: - metadata_url: http://mass-host.localdomain/source - consumer_key: Xh234sdkljf - token_key: kjfhgb3n - token_secret: 24uysdfx1w4 - -Notes: - * Because 'url=' is so very generic, in order to avoid false positives, - cloud-init requires the content to start with '#cloud-config' in order - for it to be considered. - * The url= is un-authed http GET, and contains credentials - It could be set up to be randomly generated and also check source - address in order to be more secure diff --git a/doc/nocloud/README b/doc/nocloud/README deleted file mode 100644 index c94b206a..00000000 --- a/doc/nocloud/README +++ /dev/null @@ -1,55 +0,0 @@ -The data source 'NoCloud' and 'NoCloudNet' allow the user to provide user-data -and meta-data to the instance without running a network service (or even without -having a network at all) - -You can provide meta-data and user-data to a local vm boot via files on a vfat -or iso9660 filesystem. These user-data and meta-data files are expected to be -in the format described in doc/example/seed/README . Basically, user-data is -simply user-data and meta-data is a yaml formated file representing what you'd -find in the EC2 metadata service. - -Given a disk 12.04 cloud image in 'disk.img', you can create a sufficient disk -by following the example below. - -## create user-data and meta-data files that will be used -## to modify image on first boot -$ { echo instance-id: iid-local01; echo local-hostname: cloudimg; } > meta-data - -$ printf "#cloud-config\npassword: passw0rd\nchpasswd: { expire: False }\nssh_pwauth: True\n" > user-data - -## create a disk to attach with some user-data and meta-data -$ genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data - -## alternatively, create a vfat filesystem with same files -## $ truncate --size 2M seed.img -## $ mkfs.vfat -n cidata seed.img -## $ mcopy -oi seed.img user-data meta-data :: - -## create a new qcow image to boot, backed by your original image -$ qemu-img create -f qcow2 -b disk.img boot-disk.img - -## boot the image and login as 'ubuntu' with password 'passw0rd' -## note, passw0rd was set as password through the user-data above, -## there is no password set on these images. -$ kvm -m 256 \ - -net nic -net user,hostfwd=tcp::2222-:22 \ - -drive file=boot-disk.img,if=virtio \ - -drive file=seed.iso,if=virtio - -Note, that the instance-id provided ('iid-local01' above) is what is used to -determine if this is "first boot". So if you are making updates to user-data -you will also have to change that, or start the disk fresh. - - -Also, you can inject an /etc/network/interfaces file by providing the content -for that file in the 'network-interfaces' field of metadata. Example metadata: - instance-id: iid-abcdefg - network-interfaces: | - iface eth0 inet static - address 192.168.1.10 - network 192.168.1.0 - netmask 255.255.255.0 - broadcast 192.168.1.255 - gateway 192.168.1.254 - hostname: myhost - diff --git a/doc/ovf/README b/doc/ovf/README deleted file mode 100644 index e3ef12e0..00000000 --- a/doc/ovf/README +++ /dev/null @@ -1,83 +0,0 @@ -This directory contains documentation and a demo of the OVF -functionality that is present in cloud-init. - -The example/ directory contains the following files: - example/ovf-env.xml - This is an example ovf environment file - to make an iso that qualifies for the ISO transport, do: - mkdir my-iso - cp environment.xml my-iso/ovf-env.xml - genisoimage -o transport.iso -r my-iso - Then, boot with that ISO attached as a CDrom -- example/ubuntu-server.ovf - Example generated by virtualbox "export" of a simple VM. - It contains a functional ProductSection also. Given answers - to each of the Properties there, a suitable OVF environment file - (ovf-env.xml) could be created. - -== Demo == -In order to easily demonstrate this functionality, simple demo is -contained here. To boot a local virtual machine in either kvm or virtual -box, follow the steps below. - -- download a suitable Ubuntu image - Visit http://cloud-images.ubuntu.com/releases and download a disk image - of Natty, Oneiric or a newer release. - - $ burl="http://cloud-images.ubuntu.com/releases/" - $ disk="ubuntu-11.10-server-cloudimg-i386-disk1" - $ wget "$burl/11.10/release/$disk.img" -O "$disk.img" - -- If you're going to use virtual box, you will need to convert the image - from qcow2 format into a virtual-box friendly VHD format. - $ qemu-img convert -O vdi "$disk.img" "ubuntu.vdi" - -- If you're using kvm, you should create a qcow delta image to store - the changes so you keep the original pristine. - $ qemu-img create -f qcow2 -b "$disk.img" "ubuntu.qcow2" - - Optionally, you could decompress the image, which will make it boot faster - but will take up more local disk space. - $ qemu-img convert -O qcow2 "$disk.img" "$disk.qcow2" - $ qemu-img create -f qcow2 -b "$disk.qcow2" ubuntu.qcow2 - -- Create an ISO file that will provide user-data to the image. - This will put the contents of 'user-data' into an ovf-env.xml file - and create an ISO file that can then be attached at boot to provide - the user data to cloud-init. - - $ ./make-iso ovf-env.xml.tmpl user-data --output ovftransport.iso - -- Boot your virtual machine - The cloud-images boot with kernel and boot progress to ttyS0. - You can change that at the grub prompt if you'd like by editing the - kernel entry. Otherwise, to see progress you'll need to switch - to the serial console. In kvm graphic mode, you do that by clicking - in the window and then pressing pressing 'ctrl-alt-3'. For information - on how to do that in virtualbox or kvm curses, see the relevant - documentation. - - KVM: - $ kvm -drive file=ubuntu.qcow2,if=virtio -cdrom ovftransport.iso \ - -m 256 -net nic -net user,hostfwd=tcp::2222-:22 - - VirtualBox: - - Launch the GUI and create a new vm with $disk.vdi and ovftransport.iso - attached. - - If you use 'NAT' networking, then forward a port (2222) to the - guests' port 22 to be able to ssh. - - Upon successful boot you will be able to log in as the 'ubuntu' user - with the password 'passw0rd' (which was set in the 'user-data' file). - - You will also be able to ssh to the instance with the provided: - $ chmod 600 ovfdemo.pem - $ ssh -i ovfdemo.pem -p 2222 ubuntu@localhost - -- Notes: - * The 'instance-id' that is set in the ovf-env.xml image needs to - be unique. If you want to run the first-boot code of cloud-init - again you will either have to remove /var/lib/cloud ('rm -Rf' is fine) - or create a new cdrom with a different instance-id. To do the - ladder, simply add the '--instance-id=' flag to the 'make-iso' - command above and start your vm with the new ISO attached. diff --git a/doc/ovf/example/ovf-env.xml b/doc/ovf/example/ovf-env.xml deleted file mode 100644 index 13e8f104..00000000 --- a/doc/ovf/example/ovf-env.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - ESX Server - 3.0.1 - VMware, Inc. - en_US - - - - - - - - - - - - - - - - - - diff --git a/doc/ovf/example/ubuntu-server.ovf b/doc/ovf/example/ubuntu-server.ovf deleted file mode 100644 index 846483a1..00000000 --- a/doc/ovf/example/ubuntu-server.ovf +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - Virtual disk information - - - - The list of logical networks - - The bridged network - - - - A virtual machine - Ubuntu - - 11.04 (Natty Narwhal) Server - - - Cloud-Init customization - 11.04 (Natty Narwhal) Server - - - Specifies the instance id. This is required and used to determine if the machine should take "first boot" actions - - - Specifies the hostname for the appliance - - - - This field is optional, but indicates that the instance should 'seed' user-data and meta-data from the given url. If set to 'http://tinyurl.com/sm-' is given, meta-data will be pulled from http://tinyurl.com/sm-meta-data and user-data from http://tinyurl.com/sm-user-data. Leave this empty if you do not want to seed from a url. - - - - This field is optional, but indicates that the instance should populate the default user's 'authorized_keys' with this value - - - - In order to fit into a xml attribute, this value is base64 encoded . It will be decoded, and then processed normally as user-data. - - - - - If set, the default user's password will be set to this value to allow password based login. The password will be good for only a single login. If set to the string 'RANDOM' then a random password will be generated, and written to the console. - - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - Ubuntu 11.04 (Natty Narwhal) Server - vmx-07 qemu-pc qemu-pc-0.13 virtualbox-2.2 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 1 - 3 - 1 - - - byte * 2^20 - Memory Size - 256MB of memory - 2 - 4 - 256 - - - 0 - USB Controller - usb - 3 - 23 - - - 0 - SCSI Controller - scsiController0 - 4 - lsilogic - 6 - - - 1 - IDE Controller - ideController1 - 5 - 5 - - - 0 - false - cdrom1 - 6 - 5 - 15 - - - 0 - disk1 - ovf:/disk/vmdisk1 - 7 - 4 - 17 - - - 2 - true - bridged - ethernet adapter on "bridged" - ethernet0 - 8 - E1000 - 10 - - - - For more information, see http://ubuntu.com - This is Ubuntu Server. - - - diff --git a/doc/ovf/make-iso b/doc/ovf/make-iso deleted file mode 100755 index 91d0e2e5..00000000 --- a/doc/ovf/make-iso +++ /dev/null @@ -1,156 +0,0 @@ -#!/bin/bash - -VERBOSITY=0 -PROPERTIES=( instance-id hostname user-data seedfrom ) -DEFAULTS=( "i-ovfdemo00" "ovfdemo.localdomain" "" "" ) - -DEF_OUTPUT="ovftransport.iso" -TEMP_D="" - -error() { echo "$@" 1>&2; } -fail() { [ $# -eq 0 ] || error "$@"; exit 1; } - -# propvalue(name, value) -propvalue() { - local prop="" val="$2" i=0 - for prop in "${PROPERTIES[@]}"; do - if [ "$prop" = "$1" ]; then - [ $# -eq 1 ] || DEFAULTS[$i]="$2" - _RET=${DEFAULTS[$i]} - return - fi - i=$(($i+1)) - done - return -} - -Usage() { - cat <&2; [ $# -eq 0 ] || error "$@"; exit 1; } -cleanup() { - [ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}" -} - -debug() { - local level=${1}; shift; - [ "${level}" -ge "${VERBOSITY}" ] && return - error "${@}" -} - -short_opts="ho:v" -long_opts="help,output:,verbose" -for i in "${PROPERTIES[@]}"; do - long_opts="$long_opts,$i:" -done -getopt_out=$(getopt --name "${0##*/}" \ - --options "${short_opts}" --long "${long_opts}" -- "$@") && - eval set -- "${getopt_out}" || - bad_Usage - -## <> -output="${DEF_OUTPUT}" -user_data="" - -while [ $# -ne 0 ]; do - cur=${1}; next=${2}; - case "$cur" in - -h|--help) Usage ; exit 0;; - -o|--output) output=${2}; shift;; - -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));; - --) shift; break;; - --*) - for i in "${PROPERTIES[@]}" _none_; do - [ "${cur#--}" == "$i" ] || continue - [ "$i" != "user-data" ] || - next=$(echo "$next" | base64 --wrap=0) || - fail "failed to base64 encode userdata" - propvalue "$i" "$next" - break - done - [ "$i" = "_none_" ] && bad_Usage "confused by $cur" - ;; - esac - shift; -done - -[ $# -eq 1 -o $# -eq 2 ] || - bad_Usage "wrong number of arguments" - -env_tmpl="$1" -ud_file="$2" - -[ -f "$env_tmpl" ] || bad_Usage "$env_tmpl: not a file" -[ -z "$ud_file" -o -f "$ud_file" ] || - bad_Usage "$ud_file: not a file" - -TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") || - fail "failed to make tempdir" -trap cleanup EXIT - -mkdir "$TEMP_D/iso" && iso_d="$TEMP_D/iso" || - fail "failed to make a tempdir?" -ovf_env="$TEMP_D/iso/ovf-env.xml" - -if [ -n "$ud_file" ]; then - user_data=$(base64 --wrap=0 "$ud_file") || - fail "failed to base64 encode $ud_file. Do you have base64 installed?" - propvalue user-data "$user_data" -fi - -changes=( ) -for i in "${PROPERTIES[@]}"; do - changes[${#changes[@]}]="-e" - propvalue "$i" - changes[${#changes[@]}]="s|@@$i@@|$_RET|g" -done - -sed "${changes[@]}" "$env_tmpl" > "$ovf_env" || - fail "failed to replace string in $env_tmpl" - -if [ "${#changes[@]}" -ne 0 ]; then - cmp "$ovf_env" "$env_tmpl" >/dev/null && - fail "nothing replaced in $ovf_env. template is identical to output" -fi - -debug 1 "creating iso with: genisoimage -o tmp.iso -r iso" -( cd "$TEMP_D" && - genisoimage -V OVF-TRANSPORT -o tmp.iso -r iso 2>/dev/null ) || - fail "failed to create iso. do you have genisoimage?" - -if [ "$output" = "-" ]; then - cat "$TEMP_D/tmp.iso" -else - cp "$TEMP_D/tmp.iso" "$output" || - fail "failed to write to $output" -fi - -error "wrote iso to $output" -exit 0 -# vi: ts=4 noexpandtab diff --git a/doc/ovf/ovf-env.xml.tmpl b/doc/ovf/ovf-env.xml.tmpl deleted file mode 100644 index 8e255d43..00000000 --- a/doc/ovf/ovf-env.xml.tmpl +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - ESX Server - 3.0.1 - VMware, Inc. - en_US - - - - - - - - - - - diff --git a/doc/ovf/ovfdemo.pem b/doc/ovf/ovfdemo.pem deleted file mode 100644 index 5bc629c8..00000000 --- a/doc/ovf/ovfdemo.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEA1Zq/11Rky/uHdbKJewmEtDABGoSjIFyjoY04T5dFYUNwi0B6 -Km7b85Ylqmi/1KmR4Zvi++dj10XnusoWr/Zruv85hHilMZ9GozL2RD6jU/CaI+rB -QkKSaR/CdmEHBbRimq6T2E9chMhJY0jNzeexJSKVR3QeLdbRZ64H7QGTHp7Ulodu -vS9VwAWcpYbGgcM541fboFAiJOLICM1UPH4x5WDkTq/6yeElSmeiE2lHtESHhyMJ -OSDB3YZ5hw1+4bY3sR+0vZ3VQWzpn1Lwg1X3AZA8yf+ZsmMZHhTFeCglsd8jlLHk -Wudh5mJBkCuwPvRQk1gE5gSnTGti0TUqLIrNRwIDAQABAoIBAGZMrdIXxgp3VWHF -9tfpMBgH4Y9stJ98HpXxh2V+4ih53v2iDKAj5c1cPH/HmQ/lgktVmDjikct43El2 -HbV6RBATyd0q1prUWEUy1ATNJvW9hmTrOlFchrg4EK8XOwC9angAYig3oeyp65PU -O1SAwTMyw+GruARmHHYWQA9/MJF5yexrjBw00w7hnCsqjezU5YIYsXwgcz0Zw+Ix -fDJcZFXF9X3Al7H3ZILW3PpfhcVl7WzkL47TIX4oB/ab2kltaTE90SZMXKVcLvTI -6To2xJAnMUyasRfcGmvE8m0SqWqp66POAUDF2I8qu78inKH2u0rNtLQjyx5btF5K -A39bPnkCgYEA8Joba3QFrbd0zPTP/DawRtTXzdIQcNjj4XEefxBN3Cw7MlCsfgDc -xiAR703zqQ/IDkF00XrU5w7rmDga3Pv66JRzFDwvRVtGb6QV+lg7Ypd/6NI1G5AS -0Qzneer2JytEpHoTqGH/vWcXzJRH2BfaPK/vEF4qhAXBqouz2DXn3EUCgYEA40ZU -eDc4MmHOSuqoggSEDJ5NITgPbdkwOta0BmnBZ36M5vgqN8EfAZISKocLNlERDrRG -MpBlQCulq3rpU7WYkx8hGE21f1YBo+vKkffI56ptO2lAp5iLflkSOypdiVN6OELW -5SzkViohDnxKc6eshVycnNoxh6MqE6ugWSd6ahsCgYEA6t0kQwIgwPDCfYfEt2kT -LjF675lNHzs5R8pKgLKDrpcmufjySJXC7UxE9ZrcbX3QRcozpIEI7vwrko3B+1Gm -Hf87TtdpNYTh/vznz1btsVI+NCFuYheDprm4A9UOsDGWchAQvF/dayAFpVhhwVmX -WYJMFWg2jGWqJTb2Oep1CRkCgYEAqzdkk1wmPe5o1w+I+sokIM1xFcGB/iNMrkbp -QJuTVECGLcpvI6mdjjVY8ijiTX0s+ILfD2CwpnM7T8A83w9DbjJZYFHKla9ZdQBB -j024UK6Xs9ZLGvdUv06i6We1J6t3u8K+2c/EBRWf6aXBAPgkhCOM6K2H+sL1A/Sb -zA5trlkCgYArqJCk999mXQuMjNv6UTwzB0iYDjAFNgJdFmPMXlogD51r0HlGeCgD -OEyup4FdIvX1ZYOCkKyieSngmPmY/P4lZBgQbM23FMp+oUkA+FlVW+WNVoXagUrh -abatKtbZ+WZHHmgSoC8sAo5KnxM9O0R6fWlpoIhJTVoihkZYdmnpMg== ------END RSA PRIVATE KEY----- diff --git a/doc/ovf/user-data b/doc/ovf/user-data deleted file mode 100644 index bfac51fd..00000000 --- a/doc/ovf/user-data +++ /dev/null @@ -1,7 +0,0 @@ -#cloud-config -password: passw0rd -chpasswd: { expire: False } -ssh_pwauth: True - -ssh_authorized_keys: - - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVmr/XVGTL+4d1sol7CYS0MAEahKMgXKOhjThPl0VhQ3CLQHoqbtvzliWqaL/UqZHhm+L752PXRee6yhav9mu6/zmEeKUxn0ajMvZEPqNT8Joj6sFCQpJpH8J2YQcFtGKarpPYT1yEyEljSM3N57ElIpVHdB4t1tFnrgftAZMentSWh269L1XABZylhsaBwznjV9ugUCIk4sgIzVQ8fjHlYOROr/rJ4SVKZ6ITaUe0RIeHIwk5IMHdhnmHDX7htjexH7S9ndVBbOmfUvCDVfcBkDzJ/5myYxkeFMV4KCWx3yOUseRa52HmYkGQK7A+9FCTWATmBKdMa2LRNSosis1H ubuntu@ovfdemo diff --git a/doc/sources/altcloud/README b/doc/sources/altcloud/README new file mode 100644 index 00000000..87d7949a --- /dev/null +++ b/doc/sources/altcloud/README @@ -0,0 +1,65 @@ +Data souce AltCloud will be used to pick up user data on +RHEVm and vSphere. + +RHEVm: +====== +For REHVm v3.0 the userdata is injected into the VM using floppy +injection via the RHEVm dashboard "Custom Properties". The format +of the Custom Properties entry must be: +"floppyinject=user-data.txt:" + +e.g.: To pass a simple bash script + +% cat simple_script.bash +#!/bin/bash +echo "Hello Joe!" >> /tmp/JJV_Joe_out.txt + +% base64 < simple_script.bash +IyEvYmluL2Jhc2gKZWNobyAiSGVsbG8gSm9lISIgPj4gL3RtcC9KSlZfSm9lX291dC50eHQK + +To pass this example script to cloud-init running in a RHEVm v3.0 VM +set the "Custom Properties" when creating the RHEMv v3.0 VM to: +floppyinject=user-data.txt:IyEvYmluL2Jhc2gKZWNobyAiSGVsbG8gSm9lISIgPj4gL3RtcC9KSlZfSm9lX291dC50eHQK + +NOTE: The prefix with file name must be: "floppyinject=user-data.txt:" + +It is also possible to launch a RHEVm v3.0 VM and pass optional user +data to it using the Delta Cloud. +For more inforation on Delta Cloud see: http://deltacloud.apache.org + +vSphere: +======== +For VMWare's vSphere the userdata is injected into the VM an ISO +via the cdrom. This can be done using the vSphere dashboard +by connecting an ISO image to the CD/DVD drive. + +To pass this example script to cloud-init running in a vSphere VM +set the CD/DVD drive when creating the vSphere VM to point to an +ISO on the data store. + +The ISO must contain the user data: + +For example, to pass the same simple_script.bash to vSphere: + +Create the ISO: +=============== +% mkdir my-iso + +NOTE: The file name on the ISO must be: "user-data.txt" +% cp simple_scirpt.bash my-iso/user-data.txt + +% genisoimage -o user-data.iso -r my-iso + +Verify the ISO: +=============== +% sudo mkdir /media/vsphere_iso +% sudo mount -o loop JoeV_CI_02.iso /media/vsphere_iso +% cat /media/vsphere_iso/user-data.txt +% sudo umount /media/vsphere_iso + +Then, launch the vSphere VM the ISO user-data.iso attached as a CDrom. + +It is also possible to launch a vSphere VM and pass optional user +data to it using the Delta Cloud. + +For more inforation on Delta Cloud see: http://deltacloud.apache.org diff --git a/doc/sources/configdrive/README b/doc/sources/configdrive/README new file mode 100644 index 00000000..ed9033c9 --- /dev/null +++ b/doc/sources/configdrive/README @@ -0,0 +1,118 @@ +The 'ConfigDrive' DataSource supports the OpenStack configdrive disk. +See doc/source/api_ext/ext_config_drive.rst in the nova source code for +more information on config drive. + +The following criteria are required to be identified by +DataSourceConfigDrive as a config drive: + * must be formated with vfat filesystem + * must be a un-partitioned block device (/dev/vdb, not /dev/vdb1) + * must contain one of the following files: + * etc/network/interfaces + * root/.ssh/authorized_keys + * meta.js + +By default, cloud-init does not consider this source to be a full-fledged +datasource. Instead, the default behavior is to assume it is really only +present to provide networking information. Cloud-init will copy off the +network information, apply it to the system, and then continue on. The +"full" datasource would then be found in the EC2 metadata service. + +== Content of config-drive == + * etc/network/interfaces + This file is laid down by nova in order to pass static networking + information to the guest. Cloud-init will copy it off of the config-drive + and into /etc/network/interfaces as soon as it can, and then attempt to + bring up all network interfaces. + + * root/.ssh/authorized_keys + This file is laid down by nova, and contains the keys that were + provided to it on instance creation (nova-boot --key ....) + + Cloud-init will copy those keys and put them into the configured user + ('ubuntu') .ssh/authorized_keys. + + * meta.js + meta.js is populated on the config-drive in response to the user passing + "meta flags" (nova boot --meta key=value ...). It is expected to be json + formated. + +== Configuration == +Cloud-init's behavior can be modified by keys found in the meta.js file in +the following ways: + * dsmode: + values: local, net, pass + default: pass + + This is what indicates if configdrive is a final data source or not. + By default it is 'pass', meaning this datasource should not be read. + Set it to 'local' or 'net' to stop cloud-init from continuing on to + search for other data sources after network config. + + The difference between 'local' and 'net' is that local will not require + networking to be up before user-data actions (or boothooks) are run. + + * instance-id: + default: iid-dsconfigdrive + This is utilized as the metadata's instance-id. It should generally + be unique, as it is what is used to determine "is this a new instance". + + * public-keys: + default: None + if present, these keys will be used as the public keys for the + instance. This value overrides the content in authorized_keys. + Note: it is likely preferable to provide keys via user-data + + * user-data: + default: None + This provides cloud-init user-data. See other documentation for what + all can be present here. + +== Example == +Here is an example using the nova client (python-novaclien) + +Assuming the following variables set up: + * img_id : set to the nova image id (uuid from image-list) + * flav_id : set to numeric flavor_id (nova flavor-list) + * keyname : set to name of key for this instance (nova keypair-list) + +$ cat my-user-data +#!/bin/sh +echo ==== USER_DATA FROM EC2 MD ==== | tee /ud.log + +$ ud_value=$(sed 's,EC2 MD,META KEY,') + +## Now, 'ud_value' has same content of my-user-data file, but +## with the string "USER_DATA FROM META KEY" + +## launch an instance with dsmode=pass +## This will really not use the configdrive for anything as the mode +## for the datasource is 'pass', meaning it will still expect some +## other data source (DataSourceEc2). + +$ nova boot --image=$img_id --config-drive=1 --flavor=$flav_id \ + --key_name=$keyname \ + --user_data=my-user-data \ + "--meta=instance-id=iid-001 \ + "--meta=user-data=${ud_keyval}" \ + "--meta=dsmode=pass" cfgdrive-dsmode-pass + +$ euca-get-console-output i-0000001 | grep USER_DATA +echo ==== USER_DATA FROM EC2 MD ==== | tee /ud.log + +## Now, launch an instance with dsmode=local +## This time, the only metadata and userdata available to cloud-init +## are on the config-drive +$ nova boot --image=$img_id --config-drive=1 --flavor=$flav_id \ + --key_name=$keyname \ + --user_data=my-user-data \ + "--meta=instance-id=iid-001 \ + "--meta=user-data=${ud_keyval}" \ + "--meta=dsmode=local" cfgdrive-dsmode-local + +$ euca-get-console-output i-0000002 | grep USER_DATA +echo ==== USER_DATA FROM META KEY ==== | tee /ud.log + +-- +[1] https://github.com/openstack/nova/blob/master/doc/source/api_ext/ext_config_drive.rst for more if + + diff --git a/doc/sources/kernel-cmdline.txt b/doc/sources/kernel-cmdline.txt new file mode 100644 index 00000000..0b77a9af --- /dev/null +++ b/doc/sources/kernel-cmdline.txt @@ -0,0 +1,48 @@ +In order to allow an ephemeral, or otherwise pristine image to +receive some configuration, cloud-init will read a url directed by +the kernel command line and proceed as if its data had previously existed. + +This allows for configuring a meta-data service, or some other data. + +Note, that usage of the kernel command line is somewhat of a last resort, +as it requires knowing in advance the correct command line or modifying +the boot loader to append data. + +For example, when 'cloud-init start' runs, it will check to +see if if one of 'cloud-config-url' or 'url' appear in key/value fashion +in the kernel command line as in: + root=/dev/sda ro url=http://foo.bar.zee/abcde + +Cloud-init will then read the contents of the given url. +If the content starts with '#cloud-config', it will store +that data to the local filesystem in a static filename +'/etc/cloud/cloud.cfg.d/91_kernel_cmdline_url.cfg', and consider it as +part of the config from that point forward. + +If that file exists already, it will not be overwritten, and the url parameters +completely ignored. + +Then, when the DataSource runs, it will find that config already available. + +So, in able to configure the MAAS DataSource by controlling the kernel +command line from outside the image, you can append: + url=http://your.url.here/abcdefg +or + cloud-config-url=http://your.url.here/abcdefg + +Then, have the following content at that url: + #cloud-config + datasource: + MAAS: + metadata_url: http://mass-host.localdomain/source + consumer_key: Xh234sdkljf + token_key: kjfhgb3n + token_secret: 24uysdfx1w4 + +Notes: + * Because 'url=' is so very generic, in order to avoid false positives, + cloud-init requires the content to start with '#cloud-config' in order + for it to be considered. + * The url= is un-authed http GET, and contains credentials + It could be set up to be randomly generated and also check source + address in order to be more secure diff --git a/doc/sources/nocloud/README b/doc/sources/nocloud/README new file mode 100644 index 00000000..c94b206a --- /dev/null +++ b/doc/sources/nocloud/README @@ -0,0 +1,55 @@ +The data source 'NoCloud' and 'NoCloudNet' allow the user to provide user-data +and meta-data to the instance without running a network service (or even without +having a network at all) + +You can provide meta-data and user-data to a local vm boot via files on a vfat +or iso9660 filesystem. These user-data and meta-data files are expected to be +in the format described in doc/example/seed/README . Basically, user-data is +simply user-data and meta-data is a yaml formated file representing what you'd +find in the EC2 metadata service. + +Given a disk 12.04 cloud image in 'disk.img', you can create a sufficient disk +by following the example below. + +## create user-data and meta-data files that will be used +## to modify image on first boot +$ { echo instance-id: iid-local01; echo local-hostname: cloudimg; } > meta-data + +$ printf "#cloud-config\npassword: passw0rd\nchpasswd: { expire: False }\nssh_pwauth: True\n" > user-data + +## create a disk to attach with some user-data and meta-data +$ genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data + +## alternatively, create a vfat filesystem with same files +## $ truncate --size 2M seed.img +## $ mkfs.vfat -n cidata seed.img +## $ mcopy -oi seed.img user-data meta-data :: + +## create a new qcow image to boot, backed by your original image +$ qemu-img create -f qcow2 -b disk.img boot-disk.img + +## boot the image and login as 'ubuntu' with password 'passw0rd' +## note, passw0rd was set as password through the user-data above, +## there is no password set on these images. +$ kvm -m 256 \ + -net nic -net user,hostfwd=tcp::2222-:22 \ + -drive file=boot-disk.img,if=virtio \ + -drive file=seed.iso,if=virtio + +Note, that the instance-id provided ('iid-local01' above) is what is used to +determine if this is "first boot". So if you are making updates to user-data +you will also have to change that, or start the disk fresh. + + +Also, you can inject an /etc/network/interfaces file by providing the content +for that file in the 'network-interfaces' field of metadata. Example metadata: + instance-id: iid-abcdefg + network-interfaces: | + iface eth0 inet static + address 192.168.1.10 + network 192.168.1.0 + netmask 255.255.255.0 + broadcast 192.168.1.255 + gateway 192.168.1.254 + hostname: myhost + diff --git a/doc/sources/ovf/README b/doc/sources/ovf/README new file mode 100644 index 00000000..e3ef12e0 --- /dev/null +++ b/doc/sources/ovf/README @@ -0,0 +1,83 @@ +This directory contains documentation and a demo of the OVF +functionality that is present in cloud-init. + +The example/ directory contains the following files: + example/ovf-env.xml + This is an example ovf environment file + to make an iso that qualifies for the ISO transport, do: + mkdir my-iso + cp environment.xml my-iso/ovf-env.xml + genisoimage -o transport.iso -r my-iso + Then, boot with that ISO attached as a CDrom +- example/ubuntu-server.ovf + Example generated by virtualbox "export" of a simple VM. + It contains a functional ProductSection also. Given answers + to each of the Properties there, a suitable OVF environment file + (ovf-env.xml) could be created. + +== Demo == +In order to easily demonstrate this functionality, simple demo is +contained here. To boot a local virtual machine in either kvm or virtual +box, follow the steps below. + +- download a suitable Ubuntu image + Visit http://cloud-images.ubuntu.com/releases and download a disk image + of Natty, Oneiric or a newer release. + + $ burl="http://cloud-images.ubuntu.com/releases/" + $ disk="ubuntu-11.10-server-cloudimg-i386-disk1" + $ wget "$burl/11.10/release/$disk.img" -O "$disk.img" + +- If you're going to use virtual box, you will need to convert the image + from qcow2 format into a virtual-box friendly VHD format. + $ qemu-img convert -O vdi "$disk.img" "ubuntu.vdi" + +- If you're using kvm, you should create a qcow delta image to store + the changes so you keep the original pristine. + $ qemu-img create -f qcow2 -b "$disk.img" "ubuntu.qcow2" + + Optionally, you could decompress the image, which will make it boot faster + but will take up more local disk space. + $ qemu-img convert -O qcow2 "$disk.img" "$disk.qcow2" + $ qemu-img create -f qcow2 -b "$disk.qcow2" ubuntu.qcow2 + +- Create an ISO file that will provide user-data to the image. + This will put the contents of 'user-data' into an ovf-env.xml file + and create an ISO file that can then be attached at boot to provide + the user data to cloud-init. + + $ ./make-iso ovf-env.xml.tmpl user-data --output ovftransport.iso + +- Boot your virtual machine + The cloud-images boot with kernel and boot progress to ttyS0. + You can change that at the grub prompt if you'd like by editing the + kernel entry. Otherwise, to see progress you'll need to switch + to the serial console. In kvm graphic mode, you do that by clicking + in the window and then pressing pressing 'ctrl-alt-3'. For information + on how to do that in virtualbox or kvm curses, see the relevant + documentation. + + KVM: + $ kvm -drive file=ubuntu.qcow2,if=virtio -cdrom ovftransport.iso \ + -m 256 -net nic -net user,hostfwd=tcp::2222-:22 + + VirtualBox: + - Launch the GUI and create a new vm with $disk.vdi and ovftransport.iso + attached. + - If you use 'NAT' networking, then forward a port (2222) to the + guests' port 22 to be able to ssh. + + Upon successful boot you will be able to log in as the 'ubuntu' user + with the password 'passw0rd' (which was set in the 'user-data' file). + + You will also be able to ssh to the instance with the provided: + $ chmod 600 ovfdemo.pem + $ ssh -i ovfdemo.pem -p 2222 ubuntu@localhost + +- Notes: + * The 'instance-id' that is set in the ovf-env.xml image needs to + be unique. If you want to run the first-boot code of cloud-init + again you will either have to remove /var/lib/cloud ('rm -Rf' is fine) + or create a new cdrom with a different instance-id. To do the + ladder, simply add the '--instance-id=' flag to the 'make-iso' + command above and start your vm with the new ISO attached. diff --git a/doc/sources/ovf/example/ovf-env.xml b/doc/sources/ovf/example/ovf-env.xml new file mode 100644 index 00000000..13e8f104 --- /dev/null +++ b/doc/sources/ovf/example/ovf-env.xml @@ -0,0 +1,46 @@ + + + + + + + + ESX Server + 3.0.1 + VMware, Inc. + en_US + + + + + + + + + + + + + + + + + + diff --git a/doc/sources/ovf/example/ubuntu-server.ovf b/doc/sources/ovf/example/ubuntu-server.ovf new file mode 100644 index 00000000..846483a1 --- /dev/null +++ b/doc/sources/ovf/example/ubuntu-server.ovf @@ -0,0 +1,130 @@ + + + + + + + Virtual disk information + + + + The list of logical networks + + The bridged network + + + + A virtual machine + Ubuntu + + 11.04 (Natty Narwhal) Server + + + Cloud-Init customization + 11.04 (Natty Narwhal) Server + + + Specifies the instance id. This is required and used to determine if the machine should take "first boot" actions + + + Specifies the hostname for the appliance + + + + This field is optional, but indicates that the instance should 'seed' user-data and meta-data from the given url. If set to 'http://tinyurl.com/sm-' is given, meta-data will be pulled from http://tinyurl.com/sm-meta-data and user-data from http://tinyurl.com/sm-user-data. Leave this empty if you do not want to seed from a url. + + + + This field is optional, but indicates that the instance should populate the default user's 'authorized_keys' with this value + + + + In order to fit into a xml attribute, this value is base64 encoded . It will be decoded, and then processed normally as user-data. + + + + + If set, the default user's password will be set to this value to allow password based login. The password will be good for only a single login. If set to the string 'RANDOM' then a random password will be generated, and written to the console. + + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + Ubuntu 11.04 (Natty Narwhal) Server + vmx-07 qemu-pc qemu-pc-0.13 virtualbox-2.2 + + + hertz * 10^6 + Number of Virtual CPUs + 1 virtual CPU(s) + 1 + 3 + 1 + + + byte * 2^20 + Memory Size + 256MB of memory + 2 + 4 + 256 + + + 0 + USB Controller + usb + 3 + 23 + + + 0 + SCSI Controller + scsiController0 + 4 + lsilogic + 6 + + + 1 + IDE Controller + ideController1 + 5 + 5 + + + 0 + false + cdrom1 + 6 + 5 + 15 + + + 0 + disk1 + ovf:/disk/vmdisk1 + 7 + 4 + 17 + + + 2 + true + bridged + ethernet adapter on "bridged" + ethernet0 + 8 + E1000 + 10 + + + + For more information, see http://ubuntu.com + This is Ubuntu Server. + + + diff --git a/doc/sources/ovf/make-iso b/doc/sources/ovf/make-iso new file mode 100755 index 00000000..91d0e2e5 --- /dev/null +++ b/doc/sources/ovf/make-iso @@ -0,0 +1,156 @@ +#!/bin/bash + +VERBOSITY=0 +PROPERTIES=( instance-id hostname user-data seedfrom ) +DEFAULTS=( "i-ovfdemo00" "ovfdemo.localdomain" "" "" ) + +DEF_OUTPUT="ovftransport.iso" +TEMP_D="" + +error() { echo "$@" 1>&2; } +fail() { [ $# -eq 0 ] || error "$@"; exit 1; } + +# propvalue(name, value) +propvalue() { + local prop="" val="$2" i=0 + for prop in "${PROPERTIES[@]}"; do + if [ "$prop" = "$1" ]; then + [ $# -eq 1 ] || DEFAULTS[$i]="$2" + _RET=${DEFAULTS[$i]} + return + fi + i=$(($i+1)) + done + return +} + +Usage() { + cat <&2; [ $# -eq 0 ] || error "$@"; exit 1; } +cleanup() { + [ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}" +} + +debug() { + local level=${1}; shift; + [ "${level}" -ge "${VERBOSITY}" ] && return + error "${@}" +} + +short_opts="ho:v" +long_opts="help,output:,verbose" +for i in "${PROPERTIES[@]}"; do + long_opts="$long_opts,$i:" +done +getopt_out=$(getopt --name "${0##*/}" \ + --options "${short_opts}" --long "${long_opts}" -- "$@") && + eval set -- "${getopt_out}" || + bad_Usage + +## <> +output="${DEF_OUTPUT}" +user_data="" + +while [ $# -ne 0 ]; do + cur=${1}; next=${2}; + case "$cur" in + -h|--help) Usage ; exit 0;; + -o|--output) output=${2}; shift;; + -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));; + --) shift; break;; + --*) + for i in "${PROPERTIES[@]}" _none_; do + [ "${cur#--}" == "$i" ] || continue + [ "$i" != "user-data" ] || + next=$(echo "$next" | base64 --wrap=0) || + fail "failed to base64 encode userdata" + propvalue "$i" "$next" + break + done + [ "$i" = "_none_" ] && bad_Usage "confused by $cur" + ;; + esac + shift; +done + +[ $# -eq 1 -o $# -eq 2 ] || + bad_Usage "wrong number of arguments" + +env_tmpl="$1" +ud_file="$2" + +[ -f "$env_tmpl" ] || bad_Usage "$env_tmpl: not a file" +[ -z "$ud_file" -o -f "$ud_file" ] || + bad_Usage "$ud_file: not a file" + +TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") || + fail "failed to make tempdir" +trap cleanup EXIT + +mkdir "$TEMP_D/iso" && iso_d="$TEMP_D/iso" || + fail "failed to make a tempdir?" +ovf_env="$TEMP_D/iso/ovf-env.xml" + +if [ -n "$ud_file" ]; then + user_data=$(base64 --wrap=0 "$ud_file") || + fail "failed to base64 encode $ud_file. Do you have base64 installed?" + propvalue user-data "$user_data" +fi + +changes=( ) +for i in "${PROPERTIES[@]}"; do + changes[${#changes[@]}]="-e" + propvalue "$i" + changes[${#changes[@]}]="s|@@$i@@|$_RET|g" +done + +sed "${changes[@]}" "$env_tmpl" > "$ovf_env" || + fail "failed to replace string in $env_tmpl" + +if [ "${#changes[@]}" -ne 0 ]; then + cmp "$ovf_env" "$env_tmpl" >/dev/null && + fail "nothing replaced in $ovf_env. template is identical to output" +fi + +debug 1 "creating iso with: genisoimage -o tmp.iso -r iso" +( cd "$TEMP_D" && + genisoimage -V OVF-TRANSPORT -o tmp.iso -r iso 2>/dev/null ) || + fail "failed to create iso. do you have genisoimage?" + +if [ "$output" = "-" ]; then + cat "$TEMP_D/tmp.iso" +else + cp "$TEMP_D/tmp.iso" "$output" || + fail "failed to write to $output" +fi + +error "wrote iso to $output" +exit 0 +# vi: ts=4 noexpandtab diff --git a/doc/sources/ovf/ovf-env.xml.tmpl b/doc/sources/ovf/ovf-env.xml.tmpl new file mode 100644 index 00000000..8e255d43 --- /dev/null +++ b/doc/sources/ovf/ovf-env.xml.tmpl @@ -0,0 +1,28 @@ + + + + + + + + ESX Server + 3.0.1 + VMware, Inc. + en_US + + + + + + + + + + + diff --git a/doc/sources/ovf/ovfdemo.pem b/doc/sources/ovf/ovfdemo.pem new file mode 100644 index 00000000..5bc629c8 --- /dev/null +++ b/doc/sources/ovf/ovfdemo.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA1Zq/11Rky/uHdbKJewmEtDABGoSjIFyjoY04T5dFYUNwi0B6 +Km7b85Ylqmi/1KmR4Zvi++dj10XnusoWr/Zruv85hHilMZ9GozL2RD6jU/CaI+rB +QkKSaR/CdmEHBbRimq6T2E9chMhJY0jNzeexJSKVR3QeLdbRZ64H7QGTHp7Ulodu +vS9VwAWcpYbGgcM541fboFAiJOLICM1UPH4x5WDkTq/6yeElSmeiE2lHtESHhyMJ +OSDB3YZ5hw1+4bY3sR+0vZ3VQWzpn1Lwg1X3AZA8yf+ZsmMZHhTFeCglsd8jlLHk +Wudh5mJBkCuwPvRQk1gE5gSnTGti0TUqLIrNRwIDAQABAoIBAGZMrdIXxgp3VWHF +9tfpMBgH4Y9stJ98HpXxh2V+4ih53v2iDKAj5c1cPH/HmQ/lgktVmDjikct43El2 +HbV6RBATyd0q1prUWEUy1ATNJvW9hmTrOlFchrg4EK8XOwC9angAYig3oeyp65PU +O1SAwTMyw+GruARmHHYWQA9/MJF5yexrjBw00w7hnCsqjezU5YIYsXwgcz0Zw+Ix +fDJcZFXF9X3Al7H3ZILW3PpfhcVl7WzkL47TIX4oB/ab2kltaTE90SZMXKVcLvTI +6To2xJAnMUyasRfcGmvE8m0SqWqp66POAUDF2I8qu78inKH2u0rNtLQjyx5btF5K +A39bPnkCgYEA8Joba3QFrbd0zPTP/DawRtTXzdIQcNjj4XEefxBN3Cw7MlCsfgDc +xiAR703zqQ/IDkF00XrU5w7rmDga3Pv66JRzFDwvRVtGb6QV+lg7Ypd/6NI1G5AS +0Qzneer2JytEpHoTqGH/vWcXzJRH2BfaPK/vEF4qhAXBqouz2DXn3EUCgYEA40ZU +eDc4MmHOSuqoggSEDJ5NITgPbdkwOta0BmnBZ36M5vgqN8EfAZISKocLNlERDrRG +MpBlQCulq3rpU7WYkx8hGE21f1YBo+vKkffI56ptO2lAp5iLflkSOypdiVN6OELW +5SzkViohDnxKc6eshVycnNoxh6MqE6ugWSd6ahsCgYEA6t0kQwIgwPDCfYfEt2kT +LjF675lNHzs5R8pKgLKDrpcmufjySJXC7UxE9ZrcbX3QRcozpIEI7vwrko3B+1Gm +Hf87TtdpNYTh/vznz1btsVI+NCFuYheDprm4A9UOsDGWchAQvF/dayAFpVhhwVmX +WYJMFWg2jGWqJTb2Oep1CRkCgYEAqzdkk1wmPe5o1w+I+sokIM1xFcGB/iNMrkbp +QJuTVECGLcpvI6mdjjVY8ijiTX0s+ILfD2CwpnM7T8A83w9DbjJZYFHKla9ZdQBB +j024UK6Xs9ZLGvdUv06i6We1J6t3u8K+2c/EBRWf6aXBAPgkhCOM6K2H+sL1A/Sb +zA5trlkCgYArqJCk999mXQuMjNv6UTwzB0iYDjAFNgJdFmPMXlogD51r0HlGeCgD +OEyup4FdIvX1ZYOCkKyieSngmPmY/P4lZBgQbM23FMp+oUkA+FlVW+WNVoXagUrh +abatKtbZ+WZHHmgSoC8sAo5KnxM9O0R6fWlpoIhJTVoihkZYdmnpMg== +-----END RSA PRIVATE KEY----- diff --git a/doc/sources/ovf/user-data b/doc/sources/ovf/user-data new file mode 100644 index 00000000..bfac51fd --- /dev/null +++ b/doc/sources/ovf/user-data @@ -0,0 +1,7 @@ +#cloud-config +password: passw0rd +chpasswd: { expire: False } +ssh_pwauth: True + +ssh_authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVmr/XVGTL+4d1sol7CYS0MAEahKMgXKOhjThPl0VhQ3CLQHoqbtvzliWqaL/UqZHhm+L752PXRee6yhav9mu6/zmEeKUxn0ajMvZEPqNT8Joj6sFCQpJpH8J2YQcFtGKarpPYT1yEyEljSM3N57ElIpVHdB4t1tFnrgftAZMentSWh269L1XABZylhsaBwznjV9ugUCIk4sgIzVQ8fjHlYOROr/rJ4SVKZ6ITaUe0RIeHIwk5IMHdhnmHDX7htjexH7S9ndVBbOmfUvCDVfcBkDzJ/5myYxkeFMV4KCWx3yOUseRa52HmYkGQK7A+9FCTWATmBKdMa2LRNSosis1H ubuntu@ovfdemo -- cgit v1.2.3