mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 14:41:31 +02:00
Merge branch 'master' of ssh://github.com/coreos/scripts
This commit is contained in:
commit
f871c34186
@ -24,11 +24,6 @@ if [[ ! -e "${FLAGS_disk_vmdk}" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "${FLAGS_output_ovf}" ]]; then
|
||||
echo "No ovf file path provided." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DISK_NAME=$(basename "${FLAGS_disk_vmdk}")
|
||||
DISK_UUID=$(uuidgen)
|
||||
DISK_SIZE_BYTES=$(qemu-img info -f vmdk "${FLAGS_disk_vmdk}" \
|
||||
@ -72,7 +67,8 @@ end
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat >"${FLAGS_output_ovf}" <<EOF
|
||||
if [[ -n "${FLAGS_output_ovf}" ]]; then
|
||||
cat >"${FLAGS_output_ovf}" <<EOF
|
||||
<?xml version="1.0"?>
|
||||
<Envelope ovf:version="1.0" xml:lang="en-US" xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vbox="http://www.virtualbox.org/ovf/machine">
|
||||
<References>
|
||||
@ -293,3 +289,4 @@ cat >"${FLAGS_output_ovf}" <<EOF
|
||||
</VirtualSystem>
|
||||
</Envelope>
|
||||
EOF
|
||||
fi
|
||||
|
@ -11,6 +11,7 @@ VALID_IMG_TYPES=(
|
||||
qemu
|
||||
rackspace
|
||||
vagrant
|
||||
vagrant_vmware_fusion
|
||||
virtualbox
|
||||
vmware
|
||||
xen
|
||||
@ -66,6 +67,11 @@ IMG_vagrant_DISK_FORMAT=vmdk
|
||||
IMG_vagrant_CONF_FORMAT=vagrant
|
||||
IMG_vagrant_OEM_PACKAGE=oem-vagrant
|
||||
|
||||
## vagrant_vmware
|
||||
IMG_vagrant_vmware_fusion_DISK_FORMAT=vmdk
|
||||
IMG_vagrant_vmware_fusion_CONF_FORMAT=vagrant_vmware_fusion
|
||||
IMG_vagrant_vmware_fusion_OEM_PACKAGE=oem-vagrant
|
||||
|
||||
## vmware
|
||||
IMG_vmware_DISK_FORMAT=vmdk
|
||||
IMG_vmware_CONF_FORMAT=vmx
|
||||
@ -340,7 +346,7 @@ sound.virtualDev = "es1371"
|
||||
displayName = "CoreOS"
|
||||
guestOS = "otherlinux"
|
||||
ethernet0.addressType = "generated"
|
||||
floppy0.present = "FALSE""
|
||||
floppy0.present = "FALSE"
|
||||
EOF
|
||||
VM_GENERATED_FILES+=( "${vmx_path}" )
|
||||
}
|
||||
@ -434,7 +440,11 @@ _write_vagrant_conf() {
|
||||
--output_ovf "$ovf" \
|
||||
--output_vagrant "$vfile"
|
||||
|
||||
tar -czf "${box}" -C "${VM_TMP_DIR}" "box.ovf" "Vagrantfile" "${dst_name}"
|
||||
cat > "${VM_TMP_DIR}"/metadata.json <<EOF
|
||||
{"provider": "virtualbox"}
|
||||
EOF
|
||||
|
||||
tar -czf "${box}" -C "${VM_TMP_DIR}" "box.ovf" "Vagrantfile" "${dst_name}" "metadata.json"
|
||||
|
||||
cat > "${VM_README}" <<EOF
|
||||
Vagrant >= 1.2.3 is required. Use something like the following to get started:
|
||||
@ -451,6 +461,50 @@ EOF
|
||||
VM_GENERATED_FILES=( "${box}" "${VM_README}" )
|
||||
}
|
||||
|
||||
_write_vagrant_vmware_fusion_conf() {
|
||||
local vm_mem="${1:-$(_get_vm_opt MEM)}"
|
||||
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")"
|
||||
local vmx_file=$(basename "${vmx_path}")
|
||||
local vfile="${VM_TMP_DIR}/Vagrantfile"
|
||||
local box="${dst_dir}/$(_src_to_dst_name "${src_name}" ".box")"
|
||||
|
||||
# Move the disk image to tmp, it won't be a final output file
|
||||
mv "${VM_DST_IMG}" "${VM_TMP_DIR}/${dst_name}"
|
||||
|
||||
_write_vmx_conf ${vm_mem}
|
||||
"${BUILD_LIBRARY_DIR}/virtualbox_ovf.sh" \
|
||||
--vm_name "$VM_NAME" \
|
||||
--disk_vmdk "${VM_TMP_DIR}/${dst_name}" \
|
||||
--memory_size "$vm_mem" \
|
||||
--output_vagrant "$vfile"
|
||||
|
||||
cat > "${VM_TMP_DIR}"/metadata.json <<EOF
|
||||
{"provider": "vmware_fusion"}
|
||||
EOF
|
||||
|
||||
mv "${vmx_path}" "${VM_TMP_DIR}/"
|
||||
|
||||
tar -czf "${box}" -C "${VM_TMP_DIR}" "Vagrantfile" "${dst_name}" \
|
||||
"${vmx_file}" "metadata.json"
|
||||
|
||||
cat > "${VM_README}" <<EOF
|
||||
Vagrant master (unreleased) currently has full CoreOS support. In the meantime, you may encounter an error about networking that can be ignored
|
||||
vagrant box add coreos path/to/$(basename "${box}")
|
||||
vagrant init coreos
|
||||
vagrant up
|
||||
vagrant ssh
|
||||
|
||||
You will get a warning about "No guest additions were detected...",
|
||||
this is expected and should be ignored. SSH should work just dandy.
|
||||
EOF
|
||||
|
||||
# Replace list, not append, since we packaged up the disk image.
|
||||
VM_GENERATED_FILES=( "${box}" "${VM_README}" )
|
||||
}
|
||||
|
||||
vm_cleanup() {
|
||||
info "Cleaning up temporary files"
|
||||
rm -rf "${VM_TMP_DIR}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user