diff --git a/build_library/niftycloud_ovf.sh b/build_library/niftycloud_ovf.sh new file mode 100755 index 0000000000..3da1eec9bf --- /dev/null +++ b/build_library/niftycloud_ovf.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +SCRIPT_ROOT=$(readlink -f $(dirname "$0")/..) +. "${SCRIPT_ROOT}/common.sh" || exit 1 + +DEFINE_string vm_name "CoreOS" "Name for this VM" +DEFINE_string disk_vmdk "" "Disk image to reference, only basename is used." +DEFINE_integer memory_size 1024 "Memory size in MB" +DEFINE_string output_ovf "" "Path to write ofv file to, required." + +# Parse command line +FLAGS "$@" || exit 1 +eval set -- "${FLAGS_ARGV}" + +# Die on any errors. +switch_to_strict_mode + +if [[ ! -e "${FLAGS_disk_vmdk}" ]]; then + echo "No such disk image '${FLAGS_disk_vmdk}'" >&2 + exit 1 +fi + +DISK_NAME=$(basename "${FLAGS_disk_vmdk}") +DISK_UUID=$(uuidgen) +DISK_SIZE_BYTES=$(qemu-img info -f vmdk "${FLAGS_disk_vmdk}" \ + | gawk 'match($0, /^virtual size:.*\(([0-9]+) bytes\)/, a) {print a[1]}') +DISK_FILE_SIZE_BYTES=$(ls -l ${FLAGS_disk_vmdk} | awk '{print $5}') + +if [[ -z "${DISK_SIZE_BYTES}" ]]; then + echo "Unable to determine virtual size of ${FLAGS_disk_vmdk}" >&2 + exit 1 +fi + +# Date format as used in ovf +datez() { + date -u "+%Y-%m-%dT%H:%M:%SZ" +} + +if [[ -n "${FLAGS_output_ovf}" ]]; then + cat >"${FLAGS_output_ovf}" < + + + + + + List of the virtual disks used in the package + + + + Logical networks used in the package + + Logical network used by this appliance. + + + + A virtual machine + ${FLAGS_vm_name} + + The kind of installed guest operating system + + + Virtual hardware requirements for a virtual machine + + Virtual Hardware Family + 0 + ${FLAGS_vm_name} + vmx-08 + + + hertz * 10^6 + Number of virtual CPUs + 1 virtual CPU(s) + 1 + 3 + 1 + + + byte * 2^20 + Memory Size + ${FLAGS_memory_size} MB of memory + 2 + 4 + ${FLAGS_memory_size} + + + 0 + SCSI Controller + scsiController0 + 3 + VirtualSCSI + 6 + + + 0 + disk0 + ovf:/disk/vmdisk1 + 4 + 3 + 17 + + + 2 + true + bridged + VmxNet3 ethernet adapter on "bridged" + ethernet0 + 5 + VmxNet3 + 10 + + + + +EOF +fi diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 20f702c355..8c3730dccc 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -846,48 +846,23 @@ _write_niftycloud_conf() { local src_name=$(basename "$VM_SRC_IMG") local dst_name=$(basename "$VM_DST_IMG") local dst_dir=$(dirname "$VM_DST_IMG") - local vmx_path="${dst_dir}/$(_src_to_dst_name "${src_name}" ".vmx")" - cat >"${vmx_path}" < "${VM_README}" <