This commit is contained in:
49
hack/boxes-flatcar.sh
Executable file
49
hack/boxes-flatcar.sh
Executable file
@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
export VAGRANT_VAGRANTFILE=${VAGRANT_VAGRANTFILE:-/tmp/Vagrantfile.builder-flatcar}
|
||||
|
||||
fetch_vagrantfile() {
|
||||
curl -sSL -o ${VAGRANT_VAGRANTFILE} \
|
||||
https://raw.githubusercontent.com/flatcar/flatcar-packer-qemu/builder-ignition/Vagrantfile.builder-flatcar
|
||||
}
|
||||
|
||||
list_boxes() {
|
||||
vagrant box list \
|
||||
| grep -E '^flatcar-(alpha|beta|stable|edge)-[0-9.]+' \
|
||||
| sed 's/flatcar-\(alpha\|beta\|stable\|edge\)-\([0-9.]\+\).*/\1 \2/'
|
||||
}
|
||||
|
||||
fetch_vagrantfile
|
||||
|
||||
list_boxes | while read -r channel release; do
|
||||
export FLATCAR_CHANNEL="$channel"
|
||||
export FLATCAR_VERSION="$release"
|
||||
|
||||
echo "##############################################"
|
||||
echo "Image:"
|
||||
virsh vol-info --pool default "flatcar-${channel}-${release}_vagrant_box_image_0.img"
|
||||
echo "Env:"
|
||||
echo " export FLATCAR_CHANNEL='$channel'"
|
||||
echo " export FLATCAR_VERSION='$release'"
|
||||
echo " export VAGRANT_VAGRANTFILE='$VAGRANT_VAGRANTFILE'"
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
vagrant status | grep -v 'Run `vagrant up`'
|
||||
|
||||
[ "$1" = "cleanup" ] && {
|
||||
echo "#### Cleaning up vagrant VM"
|
||||
|
||||
img_name="flatcar-${channel}-${release}_vagrant_box_image_0.img"
|
||||
box_name="packer_flatcar-${channel}-${release}_libvirt.box"
|
||||
vagrant_name="flatcar-$channel-$release"
|
||||
|
||||
vagrant halt
|
||||
vagrant destroy -f
|
||||
vagrant box remove "$vagrant_name"
|
||||
virsh vol-delete --pool=default "$img_name"
|
||||
|
||||
rm -f "$box_name"
|
||||
}
|
||||
done
|
136
hack/convert-cloudstack-image.sh
Executable file
136
hack/convert-cloudstack-image.sh
Executable file
@ -0,0 +1,136 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2022 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
function xen_server_export() {
|
||||
echo "Creating XenServer Export for $1"
|
||||
qemu-img convert -f qcow2 -O raw "$1" "$1".raw
|
||||
vhd-util convert -s 0 -t 1 -i "$1".raw -o "$1".vhd
|
||||
faketime '2010-01-01' vhd-util convert -s 1 -t 2 -i "$1".vhd -o "$1-xen.vhd"
|
||||
rm -f *.bak
|
||||
echo "Created .vhd file, now zipping"
|
||||
bzip2 "$1-xen.vhd"
|
||||
chmod +r "$1-xen.vhd.bz2"
|
||||
echo "$1 exported for XenServer: $1-xen.vhd.bz2"
|
||||
}
|
||||
|
||||
function vmware_export() {
|
||||
echo "Creating VMware Export for $1"
|
||||
qemu-img convert -f qcow2 -O vmdk -o adapter_type=lsilogic,subformat=streamOptimized,compat6 "$1" "$1-vmware.vmdk"
|
||||
CDIR=$PWD
|
||||
chmod 666 $1-vmware.vmdk
|
||||
stage_vmx $1-vmware $1-vmware.vmdk
|
||||
ovftool $1-vmware.vmx $1-vmware.ova
|
||||
rm -f $1-vmware*.vmx $1-vmware*.vmdk
|
||||
cd $CDIR
|
||||
chmod +r "$1-vmware.ova"
|
||||
echo "$1 exported for VMware: $1-vmware.ova"
|
||||
}
|
||||
|
||||
function stage_vmx() {
|
||||
cat << VMXFILE > "${1}.vmx"
|
||||
.encoding = "UTF-8"
|
||||
displayname = "${1}"
|
||||
annotation = "${1}"
|
||||
guestos = "otherlinux-64"
|
||||
virtualHW.version = "11"
|
||||
config.version = "8"
|
||||
numvcpus = "2"
|
||||
cpuid.coresPerSocket = "2"
|
||||
memsize = "2048"
|
||||
pciBridge0.present = "TRUE"
|
||||
pciBridge4.present = "TRUE"
|
||||
pciBridge4.virtualDev = "pcieRootPort"
|
||||
pciBridge4.functions = "8"
|
||||
pciBridge5.present = "TRUE"
|
||||
pciBridge5.virtualDev = "pcieRootPort"
|
||||
pciBridge5.functions = "8"
|
||||
pciBridge6.present = "TRUE"
|
||||
pciBridge6.virtualDev = "pcieRootPort"
|
||||
pciBridge6.functions = "8"
|
||||
pciBridge7.present = "TRUE"
|
||||
pciBridge7.virtualDev = "pcieRootPort"
|
||||
pciBridge7.functions = "8"
|
||||
vmci0.present = "TRUE"
|
||||
floppy0.present = "FALSE"
|
||||
ide0:0.clientDevice = "FALSE"
|
||||
ide0:0.present = "TRUE"
|
||||
ide0:0.deviceType = "atapi-cdrom"
|
||||
ide0:0.autodetect = "TRUE"
|
||||
ide0:0.startConnected = "FALSE"
|
||||
mks.enable3d = "false"
|
||||
svga.autodetect = "false"
|
||||
svga.vramSize = "134217728"
|
||||
scsi0:0.present = "TRUE"
|
||||
scsi0:0.deviceType = "disk"
|
||||
scsi0:0.fileName = "$2"
|
||||
scsi0:0.mode = "persistent"
|
||||
scsi0:0.writeThrough = "false"
|
||||
scsi0.virtualDev = "lsilogic"
|
||||
scsi0.present = "TRUE"
|
||||
vmci0.unrestricted = "false"
|
||||
vcpu.hotadd = "false"
|
||||
vcpu.hotremove = "false"
|
||||
firmware = "bios"
|
||||
mem.hotadd = "false"
|
||||
VMXFILE
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "Converts a qcow2 image to any of the following formats"
|
||||
echo " - x : XenServer [vhd]"
|
||||
echo " - v : VMware [ova]"
|
||||
echo "Usage: $0 QCOW2_IMAGE FORMAT" 1>&2
|
||||
}
|
||||
|
||||
if [ "$1" = "-h" ]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
|
||||
FILE=$1
|
||||
if [ -z $FILE ]; then
|
||||
usage
|
||||
echo "File not specified. Exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FORMAT=$2
|
||||
if [ -z $FILE ]; then
|
||||
usage
|
||||
echo "Format not specified. Exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f $FILE ]; then
|
||||
echo "File '$FILE' not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $FORMAT in
|
||||
v)
|
||||
vmware_export $FILE
|
||||
;;
|
||||
x)
|
||||
xen_server_export $FILE
|
||||
;;
|
||||
all)
|
||||
vmware_export $FILE
|
||||
xen_server_export $FILE
|
||||
;;
|
||||
*)
|
||||
echo "Unknown format. Supported options are [x, v]"
|
||||
exit 1
|
||||
esac
|
45
hack/ensure-ansible-windows.sh
Executable file
45
hack/ensure-ansible-windows.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2020 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
source hack/utils.sh
|
||||
|
||||
_version="0.4.2"
|
||||
|
||||
if [[ ${HOSTOS} == "darwin" ]]; then
|
||||
echo "IMPORTANT: Winrm connection plugin for Ansible on MacOS causes connection issues."
|
||||
echo "See https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html#what-is-winrm for more details."
|
||||
echo "To fix the issue provide the enviroment variable 'no_proxy=*'"
|
||||
echo "Example call to build Windows images on MacOS: 'no_proxy=* make build-<target>'"
|
||||
fi
|
||||
|
||||
# Change directories to the parent directory of the one in which this
|
||||
# script is located.
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
# Disable pip's version check and root user warning
|
||||
export PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_ROOT_USER_ACTION=ignore
|
||||
|
||||
if pip3 show pywinrm >/dev/null 2>&1; then exit 0; fi
|
||||
|
||||
ensure_py3
|
||||
pip3 install --user "pywinrm==${_version}"
|
||||
if ! pip3 show pywinrm ; then exit 1; fi
|
45
hack/ensure-ansible.sh
Executable file
45
hack/ensure-ansible.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2020 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
source hack/utils.sh
|
||||
|
||||
_version="2.11.5"
|
||||
|
||||
# Change directories to the parent directory of the one in which this
|
||||
# script is located.
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
# Disable pip's version check and root user warning
|
||||
export PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_ROOT_USER_ACTION=ignore
|
||||
|
||||
if ! command -v ansible >/dev/null 2>&1; then
|
||||
ensure_py3
|
||||
pip3 install --user "ansible-core==${_version}"
|
||||
ensure_py3_bin ansible
|
||||
ensure_py3_bin ansible-playbook
|
||||
fi
|
||||
|
||||
ansible-galaxy collection install \
|
||||
community.general \
|
||||
ansible.posix \
|
||||
'ansible.windows:>=1.7.0' \
|
||||
community.windows
|
37
hack/ensure-azure-cli.sh
Executable file
37
hack/ensure-azure-cli.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2020 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
source hack/utils.sh
|
||||
|
||||
# Change directories to the parent directory of the one in which this
|
||||
# script is located.
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
if command -v az >/dev/null 2>&1; then exit 0; fi
|
||||
|
||||
# Disable pip's version check and root user warning
|
||||
export PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_ROOT_USER_ACTION=ignore
|
||||
|
||||
ensure_py3
|
||||
pip install -U pip setuptools
|
||||
pip3 install --user azure-cli
|
||||
ensure_py3_bin az azure-cli
|
30
hack/ensure-boskosctl.sh
Executable file
30
hack/ensure-boskosctl.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2021 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
if [[ -z "$(command -v boskosctl)" ]]; then
|
||||
echo "installing boskosctl"
|
||||
GO111MODULE=on go get sigs.k8s.io/boskos/cmd/boskosctl@master
|
||||
echo "'boskosctl' has been installed to $GOPATH/bin, make sure this directory is in your \$PATH"
|
||||
fi
|
||||
|
||||
echo "testing boskosctl"
|
||||
boskosctl --help
|
43
hack/ensure-ct.sh
Executable file
43
hack/ensure-ct.sh
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2022 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
_version="v0.9.3"
|
||||
|
||||
# Change directories to the parent directory of the one in which this
|
||||
# script is located.
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
source hack/utils.sh
|
||||
|
||||
if command -v ct >/dev/null 2>&1; then exit 0; fi
|
||||
|
||||
mkdir -p .local/bin && cd .local/bin
|
||||
|
||||
if [[ ${HOSTOS} == "linux" ]]; then
|
||||
_binfile="ct-${_version}-x86_64-unknown-linux-gnu"
|
||||
elif [[ ${HOSTOS} == "darwin" ]]; then
|
||||
_binfile="ct-${_version}-x86_64-apple-darwin"
|
||||
fi
|
||||
_bin_url="https://github.com/flatcar/container-linux-config-transpiler/releases/download/${_version}/${_binfile}"
|
||||
curl -SsL "${_bin_url}" -o ct
|
||||
chmod 0755 ct
|
||||
echo "'ct' has been installed to $(pwd), make sure this directory is in your \$PATH"
|
59
hack/ensure-go.sh
Executable file
59
hack/ensure-go.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2021 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
# Ensure the go tool exists and is a viable version.
|
||||
verify_go_version() {
|
||||
if [[ -z "$(command -v go)" ]]; then
|
||||
if [[ "${INSTALL_GO:-"true"}" == "true" ]]; then
|
||||
curl -sSL https://golang.org/dl/go${GO_VERSION:-"1.16.3"}.linux-amd64.tar.gz | tar -C /usr/local -xzf -
|
||||
export PATH=/usr/local/go/bin:$PATH
|
||||
export PATH=$(go env GOPATH)/bin:$PATH
|
||||
else
|
||||
cat <<EOF
|
||||
Can't find 'go' in PATH, please fix and retry.
|
||||
See http://golang.org/doc/install for installation instructions.
|
||||
EOF
|
||||
return 2
|
||||
fi
|
||||
fi
|
||||
|
||||
local go_version
|
||||
IFS=" " read -ra go_version <<< "$(go version)"
|
||||
local minimum_go_version
|
||||
minimum_go_version=1.16.0
|
||||
if [[ "${minimum_go_version}" != $(echo -e "${minimum_go_version}\n${go_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) && "${go_version[2]}" != "devel" ]]; then
|
||||
cat <<EOF
|
||||
Detected go version: ${go_version[*]}.
|
||||
Kubernetes requires ${minimum_go_version} or greater.
|
||||
Please install ${minimum_go_version} or later.
|
||||
EOF
|
||||
return 2
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Checking if go is available"
|
||||
verify_go_version
|
||||
|
||||
go version
|
||||
|
||||
# Explicitly opt into go modules, even though we're inside a GOPATH directory
|
||||
export GO111MODULE=on
|
73
hack/ensure-goss.sh
Executable file
73
hack/ensure-goss.sh
Executable file
@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
source hack/utils.sh
|
||||
|
||||
# SHA are for amd64 arch.
|
||||
_version="3.1.4"
|
||||
darwin_sha256="ddb663a3e4208639d90b89ebdb69dc240ec16d6b01877ccbf968f76a58a89f99"
|
||||
linux_sha256="9084877c2eea7e41fae60aaa6cdf7a7dde4e5de5e3d1f693ec8e812419ac54e9"
|
||||
_bin_url="https://github.com/YaleUniversity/packer-provisioner-goss/releases/download/v${_version}/packer-provisioner-goss-v${_version}-${HOSTOS}-${HOSTARCH}.tar.gz"
|
||||
_tarfile="${HOME}/.packer.d/plugins/packer-provisioner-goss.tar.gz"
|
||||
_binfile="${HOME}/.packer.d/plugins/packer-provisioner-goss"
|
||||
|
||||
# Get a shasum for right OS's binary
|
||||
case "${HOSTOS}" in
|
||||
linux)
|
||||
_sha256="${linux_sha256}"
|
||||
;;
|
||||
darwin)
|
||||
_sha256="${darwin_sha256}"
|
||||
;;
|
||||
*)
|
||||
echo "unsupported HOSTOS=${HOSTOS}" 1>&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check if current binary is latest
|
||||
if [ -f "${_binfile}" ]; then
|
||||
current_shasum=$(get_shasum "${_binfile}")
|
||||
if [ "$current_shasum" != "$_sha256" ]; then
|
||||
echo "Wrong version of binary present."
|
||||
else
|
||||
echo "Right version of binary present"
|
||||
# Check if binary is executable.
|
||||
# If not, delete it and proceed. If it is executable, exit 0
|
||||
{ [ -x "${_binfile}" ] && exit 0; } || rm -f "${_binfile}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# download binary, verify shasum, make it executable and clean up trash files.
|
||||
_bin_dir="$(dirname "${_tarfile}")"
|
||||
mkdir -p "${_bin_dir}" && cd "${_bin_dir}"
|
||||
curl -SsL "${_bin_url}" -o "${_tarfile}"
|
||||
tar -C "${_bin_dir}" -xzf "${_tarfile}"
|
||||
rm "${_tarfile}"
|
||||
printf "%s *${_binfile}" "${_sha256}" >"${_binfile}.sha256"
|
||||
if ! checksum_sha256 "${_binfile}.sha256"; then
|
||||
_exit_code="${?}"
|
||||
rm -f "${_binfile}.sha256"
|
||||
exit "${_exit_code}"
|
||||
fi
|
||||
rm -f "${_binfile}.sha256"
|
||||
chmod 0755 "${_binfile}"
|
43
hack/ensure-jq.sh
Executable file
43
hack/ensure-jq.sh
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2020 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
_version="1.6" # earlier versions don't follow the same OS/ARCH patterns
|
||||
|
||||
# Change directories to the parent directory of the one in which this
|
||||
# script is located.
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
source hack/utils.sh
|
||||
|
||||
if command -v jq >/dev/null 2>&1; then exit 0; fi
|
||||
|
||||
mkdir -p .local/bin && cd .local/bin
|
||||
|
||||
if [[ ${HOSTOS} == "linux" ]]; then
|
||||
_binfile="jq-linux64"
|
||||
elif [[ ${HOSTOS} == "darwin" ]]; then
|
||||
_binfile="jq-osx-amd64"
|
||||
fi
|
||||
_bin_url="https://github.com/stedolan/jq/releases/download/jq-${_version}/${_binfile}"
|
||||
curl -SsL "${_bin_url}" -o jq
|
||||
chmod 0755 jq
|
||||
echo "'jq' has been installed to $(pwd), make sure this directory is in your \$PATH"
|
32
hack/ensure-ovftool.sh
Executable file
32
hack/ensure-ovftool.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2021 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
[[ -z ${IB_OVFTOOL:-} ]] && exit 0
|
||||
|
||||
source hack/utils.sh
|
||||
|
||||
if command -v ovftool >/dev/null 2>&1; then exit 0; fi
|
||||
|
||||
echo "ovftool must be present to build OVAs. If already installed" >&2
|
||||
echo "make sure to add it to the PATH env var. If not installed, please" >&2
|
||||
echo "install latest from https://code.vmware.com/tool/ovf." >&2
|
||||
exit 1
|
54
hack/ensure-packer.sh
Executable file
54
hack/ensure-packer.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
_version="1.8.5"
|
||||
|
||||
# Change directories to the parent directory of the one in which this
|
||||
# script is located.
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
source hack/utils.sh
|
||||
|
||||
if command -v packer >/dev/null 2>&1; then exit 0; fi
|
||||
|
||||
mkdir -p .local/bin && cd .local/bin
|
||||
|
||||
SED="sed"
|
||||
if command -v gsed >/dev/null; then
|
||||
SED="gsed"
|
||||
fi
|
||||
if ! (${SED} --version 2>&1 | grep -q GNU); then
|
||||
echo "!!! GNU sed is required. If on OS X, use 'brew install gnu-sed'." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
_chkfile="packer_${_version}_SHA256SUMS"
|
||||
_chk_url="https://releases.hashicorp.com/packer/${_version}/${_chkfile}"
|
||||
_zipfile="packer_${_version}_${HOSTOS}_${HOSTARCH}.zip"
|
||||
_zip_url="https://releases.hashicorp.com/packer/${_version}/${_zipfile}"
|
||||
curl -SsLO "${_chk_url}"
|
||||
curl -SsLO "${_zip_url}"
|
||||
${SED} -i -n "/${HOSTOS}_${HOSTARCH}/p" "${_chkfile}"
|
||||
checksum_sha256 "${_chkfile}"
|
||||
unzip -o "${_zipfile}"
|
||||
rm -f "${_chkfile}" "${_zipfile}"
|
||||
echo "'packer' has been installed to $(pwd), make sure this directory is in your \$PATH"
|
52
hack/ensure-powervs.sh
Executable file
52
hack/ensure-powervs.sh
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2022 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
source hack/utils.sh
|
||||
|
||||
SED="sed"
|
||||
if command -v gsed >/dev/null; then
|
||||
SED="gsed"
|
||||
fi
|
||||
if ! (${SED} --version 2>&1 | grep -q GNU); then
|
||||
echo "!!! GNU sed is required. If on OS X, use 'brew install gnu-sed'." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
_version="0.1.6"
|
||||
_chkfile="packer-plugin-powervs_v${_version}_SHA256SUMS"
|
||||
_chk_url="https://github.com/ppc64le-cloud/packer-plugin-powervs/releases/download/v${_version}/${_chkfile}"
|
||||
_bin_url="https://github.com/ppc64le-cloud/packer-plugin-powervs/releases/download/v${_version}/packer-plugin-powervs_v${_version}_x5.0_${HOSTOS}_${HOSTARCH}.zip"
|
||||
_zipfile="${HOME}/.packer.d/plugins/packer-plugin-powervs_v${_version}_x5.0_${HOSTOS}_${HOSTARCH}.zip"
|
||||
_binfile="${HOME}/.packer.d/plugins/packer-plugin-powervs_v${_version}_x5.0_${HOSTOS}_${HOSTARCH}"
|
||||
_powervs_bin="${HOME}/.packer.d/plugins/packer-plugin-powervs"
|
||||
|
||||
_bin_dir="$(dirname "${_zipfile}")"
|
||||
mkdir -p "${_bin_dir}" && cd "${_bin_dir}"
|
||||
curl -SsLO "${_chk_url}"
|
||||
curl -SsLO "${_bin_url}"
|
||||
${SED} -i -n "/${HOSTOS}_${HOSTARCH}/p" "${_chkfile}"
|
||||
checksum_sha256 "${_chkfile}"
|
||||
rm -f "${_chkfile}"
|
||||
unzip -o "${_zipfile}"
|
||||
rm "${_zipfile}"
|
||||
chmod 0755 "${_binfile}"
|
||||
mv "${_binfile}" "${_powervs_bin}"
|
33
hack/ensure-vhdutil.sh
Executable file
33
hack/ensure-vhdutil.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2022 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
if ! command -v faketime >/dev/null 2>&1; then
|
||||
echo "faketime must be present to convert to vhd" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v vhd-util >/dev/null 2>&1; then
|
||||
wget http://packages.shapeblue.com.s3-eu-west-1.amazonaws.com/systemvmtemplate/vhd-util
|
||||
chmod +x vhd-util
|
||||
wget http://packages.shapeblue.com.s3-eu-west-1.amazonaws.com/systemvmtemplate/libvhd.so.1.0
|
||||
echo "'vhd-util' and 'libvhd.so.1.0' has been installed to $(pwd), make sure this directory is in your \$PATH"
|
||||
fi
|
161
hack/generate-goss-specs.py
Executable file
161
hack/generate-goss-specs.py
Executable file
@ -0,0 +1,161 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright 2021 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import argparse
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
root_path = os.path.abspath(os.path.join(sys.argv[0], '..', '..'))
|
||||
|
||||
# Define what OS's are supported on which providers
|
||||
builds = {'amazon': ['amazon linux', 'centos', 'flatcar', 'ubuntu', 'windows'],
|
||||
'azure': ['centos', 'ubuntu', 'windows'],
|
||||
'ova': ['centos', 'photon', 'rhel', 'ubuntu', 'windows'],
|
||||
'oci':['ubuntu', 'oracle linux']}
|
||||
|
||||
def generate_goss(provider, system, versions, runtime, dryrun=False, save=False):
|
||||
cmd = ['goss', '-g', 'packer/goss/goss.yaml', '--vars', 'packer/goss/goss-vars.yaml']
|
||||
vars = {'OS': system, 'PROVIDER': provider,
|
||||
'OS_VERSION': versions['os'],
|
||||
'containerd_version': versions['containerd'],
|
||||
'docker_ee_version': versions['docker'],
|
||||
'distribution_version': versions['os'],
|
||||
'kubernetes_version': versions['k8s'],
|
||||
'kubernetes_deb_version': versions['k8s_deb'],
|
||||
'kubernetes_rpm_version': versions['k8s_rpm'],
|
||||
'kubernetes_source_type': 'pkg',
|
||||
'kubernetes_cni_version': versions['cni'],
|
||||
'kubernetes_cni_deb_version': versions['cni_deb'],
|
||||
'kubernetes_cni_rpm_version': versions['cni_rpm'],
|
||||
'kubernetes_cni_source_type': 'pkg',
|
||||
'runtime': runtime,
|
||||
'pause_image': versions['pause']}
|
||||
|
||||
if system == "windows" and versions.get('ssh_url') is not None:
|
||||
vars['ssh_source_url'] = versions['ssh_url']
|
||||
|
||||
# Build command
|
||||
cmd.extend(['--vars-inline', json.dumps(vars), 'render'])
|
||||
print('\nGenerating os: %s, provider: %s, runtime: %s' % (system, provider, runtime))
|
||||
print(cmd)
|
||||
|
||||
# Run command with output going to file
|
||||
if not dryrun:
|
||||
if save:
|
||||
out_dir = os.path.join(root_path, 'packer', 'goss')
|
||||
out_filename = '%s-%s-%s-goss-spec.yaml' % (provider,
|
||||
system.replace(' ', '-'), versions['k8s'])
|
||||
out_filename = os.path.join(out_dir, out_filename)
|
||||
with open(out_filename, 'w') as f:
|
||||
subprocess.run(cmd, cwd=root_path, stdout=f, check=True)
|
||||
else:
|
||||
subprocess.run(cmd, cwd=root_path, check=True)
|
||||
|
||||
|
||||
def read_json_file(filename):
|
||||
j = None
|
||||
with open(filename, 'r') as f:
|
||||
j = json.load(f)
|
||||
return j
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Generates GOSS specs. By default, generates all '
|
||||
'possible specs to stdout.',
|
||||
usage='%(prog)s [-h] [--provider {amazon,azure,ova}] '
|
||||
'[--os {al2,centos,flatcar,photon,rhel,ubuntu,windows}]')
|
||||
parser.add_argument('--provider',
|
||||
choices=['amazon', 'azure', 'ova','oci'],
|
||||
action='append',
|
||||
default=None,
|
||||
help='One provider. Can be used multiple times')
|
||||
parser.add_argument('--os',
|
||||
choices=['al2', 'centos', 'flatcar', 'photon', 'rhel', 'ubuntu', 'windows'],
|
||||
action='append',
|
||||
default=None,
|
||||
help='One OS. Can be used multiple times')
|
||||
parser.add_argument('--dry-run',
|
||||
action='store_true',
|
||||
help='Do not run GOSS, just print GOSS commands')
|
||||
parser.add_argument('--write',
|
||||
action='store_true',
|
||||
help='Write GOSS specs to file')
|
||||
args = parser.parse_args()
|
||||
|
||||
versions = {}
|
||||
# Load JSON files with Version info
|
||||
cni = read_json_file(os.path.join(root_path, 'packer', 'config', 'cni.json'))
|
||||
versions['cni'] = cni['kubernetes_cni_semver'].lstrip('v')
|
||||
versions['cni_deb'] = cni['kubernetes_cni_deb_version']
|
||||
versions['cni_rpm'] = cni['kubernetes_cni_rpm_version'].split('-')[0]
|
||||
|
||||
k8s = read_json_file(os.path.join(root_path, 'packer', 'config', 'kubernetes.json'))
|
||||
versions['k8s'] = k8s['kubernetes_semver'].lstrip('v')
|
||||
versions['k8s_deb'] = k8s['kubernetes_deb_version']
|
||||
versions['k8s_rpm'] = k8s['kubernetes_rpm_version'].split('-')[0]
|
||||
|
||||
containerd = read_json_file(os.path.join(root_path, 'packer', 'config', 'containerd.json'))
|
||||
versions['containerd'] = containerd['containerd_version']
|
||||
|
||||
docker = read_json_file(os.path.join(root_path, 'packer', 'config', 'windows', 'docker.json'))
|
||||
versions['docker'] = docker['docker_ee_version']
|
||||
|
||||
wincommon = read_json_file(os.path.join(root_path, 'packer', 'config', 'windows', 'common.json'))
|
||||
versions['ssh_url'] = wincommon['ssh_source_url']
|
||||
|
||||
common = read_json_file(os.path.join(root_path, 'packer', 'config', 'common.json'))
|
||||
versions['pause'] = common['pause_image']
|
||||
|
||||
providers = builds.keys()
|
||||
if args.provider is not None:
|
||||
providers = args.provider
|
||||
|
||||
# Generate a unique list of all possible OS's if a choice wasn't made
|
||||
oss = args.os
|
||||
if args.os is None:
|
||||
oss = []
|
||||
for x in list(builds.values()):
|
||||
for o in x:
|
||||
oss.append(o)
|
||||
oss = list(set(oss))
|
||||
oss = [sub.replace('al2', 'amazon linux') for sub in oss]
|
||||
# Generate spec for each valid permutation
|
||||
for provider, system in itertools.product(providers, oss):
|
||||
if system in builds[provider]:
|
||||
if system == 'windows':
|
||||
runtimes = ["docker-ee","containerd"]
|
||||
os_versions = ["2019", "2004"]
|
||||
elif system == 'rhel':
|
||||
runtimes = ["containerd"]
|
||||
os_versions = ["7", "8"]
|
||||
elif system == 'photon':
|
||||
runtimes = ["containerd"]
|
||||
os_versions = ["3", "4"]
|
||||
else:
|
||||
runtimes = ["containerd"]
|
||||
os_versions = [""]
|
||||
for runtime in runtimes:
|
||||
for version in os_versions:
|
||||
versions["os"] = version
|
||||
generate_goss(provider, system, versions, runtime, args.dry_run, args.write)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
145
hack/image-build-flatcar.sh
Executable file
145
hack/image-build-flatcar.sh
Executable file
@ -0,0 +1,145 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
export VAGRANT_VAGRANTFILE=${VAGRANT_VAGRANTFILE:-/tmp/Vagrantfile.builder-flatcar}
|
||||
export VAGRANT_SSH_PRIVATE_KEY=${VAGRANT_SSH_PRIVATE_KEY:-/tmp/vagrant-insecure-key}
|
||||
export VAGRANT_SSH_PUBLIC_KEY=${VAGRANT_SSH_PUBLIC_KEY:-/tmp/vagrant-insecure-key.pub}
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [<channel>] [<version>]"
|
||||
echo " <channel> is one of: edge alpha beta stable (defaults to"
|
||||
echo " stable)"
|
||||
echo " <version> release version to use (defaults to the latest"
|
||||
echo " release available for <channel>)"
|
||||
}
|
||||
# --
|
||||
|
||||
check_for_release() {
|
||||
channel="$1"
|
||||
release="$2"
|
||||
curl -L -s \
|
||||
"https://www.flatcar.org/releases-json/releases-$channel.json" \
|
||||
| jq -r 'to_entries[] | "\(.key)"' \
|
||||
| grep -q "$release"
|
||||
}
|
||||
# --
|
||||
|
||||
fetch_vagrant_ssh_keys() {
|
||||
curl -sSL -o ${VAGRANT_SSH_PRIVATE_KEY} \
|
||||
https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant
|
||||
curl -sSL -o ${VAGRANT_SSH_PUBLIC_KEY} \
|
||||
https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub
|
||||
}
|
||||
# --
|
||||
|
||||
fetch_vagrantfile() {
|
||||
curl -sSL -o ${VAGRANT_VAGRANTFILE} \
|
||||
https://raw.githubusercontent.com/flatcar/flatcar-packer-qemu/builder-ignition/Vagrantfile.builder-flatcar
|
||||
}
|
||||
# --
|
||||
|
||||
run_vagrant() {
|
||||
echo "#### Fetching a test Vagrantfile remotely."
|
||||
|
||||
fetch_vagrantfile
|
||||
|
||||
echo "#### Importing $channel box to vagrant and setting up kubeadm."
|
||||
|
||||
vagrant_name="flatcar-${channel}-${release}"
|
||||
img_name="flatcar-${channel}-${release}_vagrant_box_image_0.img"
|
||||
box_name="packer_flatcar_libvirt.box"
|
||||
|
||||
export VAGRANT_VAGRANTFILE="${VAGRANT_VAGRANTFILE:-hack/Vagrantfile.flatcar}"
|
||||
export VAGRANT_DEFAULT_PROVIDER="libvirt"
|
||||
|
||||
echo "#### Cleaning up previous vagrant VMs"
|
||||
vagrant halt || true
|
||||
vagrant destroy -f || true
|
||||
vagrant box remove "$vagrant_name" || true
|
||||
virsh vol-delete --pool=default "$img_name" || true
|
||||
|
||||
echo "#### creating and starting VM."
|
||||
vagrant box add --name="$vagrant_name" "./$box_name"
|
||||
vagrant up
|
||||
vagrant ssh -c 'sudo systemctl stop locksmithd'
|
||||
vagrant ssh -c 'sudo systemctl restart containerd'
|
||||
|
||||
echo "#### Setting up kubeadm"
|
||||
# shellcheck disable=SC1004
|
||||
vagrant ssh -c 'sudo kubeadm init --ignore-preflight-errors=NumCPU \
|
||||
--config=/etc/kubeadm.yml'
|
||||
# shellcheck disable=SC2016
|
||||
vagrant ssh -c 'mkdir -p $HOME/.kube
|
||||
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
|
||||
sudo chown $(id -u):$(id -g) $HOME/.kube/config'
|
||||
echo
|
||||
vagrant ssh -c 'kubectl cluster-info'
|
||||
echo
|
||||
|
||||
echo "------------------------------------------------------------------"
|
||||
echo "All done."
|
||||
echo "You can access kubectl via 'vagrant ssh -c 'kubectl <command>'"
|
||||
echo "e.g."
|
||||
echo " vagrant ssh -c 'kubectl get pods --all-namespaces'"
|
||||
echo
|
||||
echo " Please run:"
|
||||
echo " export FLATCAR_CHANNEL='$channel'"
|
||||
echo " export FLATCAR_VERSION='$release'"
|
||||
echo " export VAGRANT_VAGRANTFILE='$VAGRANT_VAGRANTFILE'"
|
||||
echo "before using vagrant commands."
|
||||
}
|
||||
|
||||
CAPI_PROVIDER=${CAPI_PROVIDER:-qemu}
|
||||
|
||||
channel="$1"
|
||||
case $channel in
|
||||
edge);;
|
||||
alpha);;
|
||||
beta);;
|
||||
stable);;
|
||||
"") channel="stable";;
|
||||
*) echo "Unknown channel '$channel'."
|
||||
usage
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
release="$2"
|
||||
if [ -n "$release" ] ; then
|
||||
check_for_release "$channel" "$release" || {
|
||||
echo "Unknown release '$release' for channel '$channel'."
|
||||
usage
|
||||
exit 1; }
|
||||
else
|
||||
release="$(\
|
||||
"$(dirname "$0")"/image-grok-latest-flatcar-version.sh "$channel")"
|
||||
fi
|
||||
|
||||
|
||||
echo "#### Building for channel $channel, release $release."
|
||||
|
||||
# set packer /vagrant env vars
|
||||
FLATCAR_CHANNEL="$channel"
|
||||
FLATCAR_VERSION="$release"
|
||||
export FLATCAR_CHANNEL FLATCAR_VERSION
|
||||
|
||||
rm -rf ./output/flatcar-"${channel}-${release}"-kube-*
|
||||
|
||||
if [[ ${CAPI_PROVIDER} = "qemu" ]]; then
|
||||
FLATCAR_MAKE_OPTS+="FLATCAR_CHANNEL=$channel FLATCAR_VERSION=$release "
|
||||
FLATCAR_MAKE_OPTS+="SSH_PRIVATE_KEY_FILE=${VAGRANT_SSH_PRIVATE_KEY} "
|
||||
FLATCAR_MAKE_OPTS+="SSH_PUBLIC_KEY_FILE=${VAGRANT_SSH_PUBLIC_KEY} "
|
||||
|
||||
fetch_vagrant_ssh_keys
|
||||
make ${FLATCAR_MAKE_OPTS} build-qemu-flatcar
|
||||
run_vagrant
|
||||
elif [[ ${CAPI_PROVIDER} = "aws" ]] || [[ ${CAPI_PROVIDER} = "ami" ]]; then
|
||||
make ${FLATCAR_MAKE_OPTS} build-ami-flatcar
|
||||
else
|
||||
echo "Unknown CAPI_PROVIDER=${CAPI_PROVIDER}. exit."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# vim:set sts=4 sw=4 et:
|
272
hack/image-build-ova.py
Executable file
272
hack/image-build-ova.py
Executable file
@ -0,0 +1,272 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
################################################################################
|
||||
# usage: image-build-ova.py [FLAGS] ARGS
|
||||
# This program builds an OVA file from a VMDK and manifest file generated as a
|
||||
# result of a Packer build.
|
||||
################################################################################
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from string import Template
|
||||
import tarfile
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Builds an OVA using the artifacts from a Packer build")
|
||||
parser.add_argument('--stream_vmdk',
|
||||
dest='stream_vmdk',
|
||||
action='store_true',
|
||||
help='Compress vmdk file')
|
||||
parser.add_argument('--vmx',
|
||||
dest='vmx_version',
|
||||
default='15',
|
||||
help='The virtual hardware version')
|
||||
parser.add_argument('--eula_file',
|
||||
nargs='?',
|
||||
metavar='EULA',
|
||||
default='./ovf_eula.txt',
|
||||
help='Text file containing EULA')
|
||||
parser.add_argument('--ovf_template',
|
||||
nargs='?',
|
||||
metavar='OVF_TEMPLATE',
|
||||
default='./ovf_template.xml',
|
||||
help='XML template to build OVF')
|
||||
parser.add_argument('--vmdk_file',
|
||||
nargs='?',
|
||||
metavar='FILE',
|
||||
default=None,
|
||||
help='Use FILE as VMDK instead of reading from manifest. '
|
||||
'Must be in BUILD_DIR')
|
||||
parser.add_argument(dest='build_dir',
|
||||
nargs='?',
|
||||
metavar='BUILD_DIR',
|
||||
default='.',
|
||||
help='The Packer build directory')
|
||||
args = parser.parse_args()
|
||||
|
||||
# Read in the EULA
|
||||
eula = ""
|
||||
with io.open(args.eula_file, 'r', encoding='utf-8') as f:
|
||||
eula = f.read()
|
||||
|
||||
# Read in the OVF template
|
||||
ovf_template = ""
|
||||
with io.open(args.ovf_template, 'r', encoding='utf-8') as f:
|
||||
ovf_template = f.read()
|
||||
|
||||
# Change the working directory if one is specified.
|
||||
os.chdir(args.build_dir)
|
||||
print("image-build-ova: cd %s" % args.build_dir)
|
||||
|
||||
# Load the packer manifest JSON
|
||||
data = None
|
||||
with open('packer-manifest.json', 'r') as f:
|
||||
data = json.load(f)
|
||||
|
||||
# Get the first build.
|
||||
build = data['builds'][0]
|
||||
build_data = build['custom_data']
|
||||
|
||||
print("image-build-ova: loaded %s-kube-%s" % (build_data['build_name'],
|
||||
build_data['kubernetes_semver']))
|
||||
|
||||
if args.vmdk_file is None:
|
||||
# Get a list of the VMDK files from the packer manifest.
|
||||
vmdk_files = get_vmdk_files(build['files'])
|
||||
else:
|
||||
vmdk_files = [{"name": args.vmdk_file, "size": os.path.getsize(args.vmdk_file)}]
|
||||
|
||||
# Create stream-optimized versions of the VMDK files.
|
||||
if args.stream_vmdk is True:
|
||||
stream_optimize_vmdk_files(vmdk_files)
|
||||
else:
|
||||
for f in vmdk_files:
|
||||
f['stream_name'] = f['name']
|
||||
f['stream_size'] = os.path.getsize(f['name'])
|
||||
|
||||
# TODO(akutz) Support multiple VMDK files in the OVF/OVA
|
||||
vmdk = vmdk_files[0]
|
||||
|
||||
OS_id_map = {"vmware-photon-64": {"id": "36", "version": "", "type": "vmwarePhoton64Guest"},
|
||||
"centos7-64": {"id": "107", "version": "7", "type": "centos7-64"},
|
||||
"centos8-64": {"id": "107", "version": "8", "type": "centos8-64"},
|
||||
"rhel7-64": {"id": "80", "version": "7", "type": "rhel7_64guest"},
|
||||
"rhel8-64": {"id": "80", "version": "8", "type": "rhel8_64guest"},
|
||||
"ubuntu-64": {"id": "94", "version": "", "type": "ubuntu64Guest"},
|
||||
"flatcar-64": {"id": "100", "version": "", "type": "linux-64"},
|
||||
"Windows2019Server-64": {"id": "112", "version": "", "type": "windows9srv-64"},
|
||||
"Windows2004Server-64": {"id": "112", "version": "", "type": "windows9srv-64"}}
|
||||
|
||||
# Create the OVF file.
|
||||
data = {
|
||||
'BUILD_DATE': build_data['build_date'],
|
||||
'ARTIFACT_ID': build['artifact_id'],
|
||||
'BUILD_TIMESTAMP': build_data['build_timestamp'],
|
||||
'EULA': eula,
|
||||
'OS_NAME': build_data['os_name'],
|
||||
'OS_ID': OS_id_map[build_data['guest_os_type']]['id'],
|
||||
'OS_TYPE': OS_id_map[build_data['guest_os_type']]['type'],
|
||||
'OS_VERSION': OS_id_map[build_data['guest_os_type']]['version'],
|
||||
'IB_VERSION': build_data['ib_version'],
|
||||
'DISK_NAME': vmdk['stream_name'],
|
||||
'DISK_SIZE': build_data['disk_size'],
|
||||
'POPULATED_DISK_SIZE': vmdk['size'],
|
||||
'STREAM_DISK_SIZE': vmdk['stream_size'],
|
||||
'VMX_VERSION': args.vmx_version,
|
||||
'DISTRO_NAME': build_data['distro_name'],
|
||||
'DISTRO_VERSION': build_data['distro_version'],
|
||||
'DISTRO_ARCH': build_data['distro_arch'],
|
||||
'NESTEDHV': "false",
|
||||
'FIRMWARE': build_data['firmware']
|
||||
}
|
||||
|
||||
capv_url = "https://github.com/kubernetes-sigs/cluster-api-provider-vsphere"
|
||||
|
||||
data['CNI_VERSION'] = build_data['kubernetes_cni_semver']
|
||||
data['CONTAINERD_VERSION'] = build_data['containerd_version']
|
||||
data['KUBERNETES_SEMVER'] = build_data['kubernetes_semver']
|
||||
data['KUBERNETES_SOURCE_TYPE'] = build_data['kubernetes_source_type']
|
||||
data['PRODUCT'] = "%s and Kubernetes %s" % (
|
||||
build_data['os_name'], build_data['kubernetes_semver'])
|
||||
data['ANNOTATION'] = "Cluster API vSphere image - %s - %s" % (data['PRODUCT'], capv_url)
|
||||
data['WAKEONLANENABLED'] = "false"
|
||||
data['TYPED_VERSION'] = build_data['kubernetes_typed_version']
|
||||
|
||||
data['PROPERTIES'] = Template('''
|
||||
<Property ovf:userConfigurable="false" ovf:value="${DISTRO_NAME}" ovf:type="string" ovf:key="DISTRO_NAME"/>
|
||||
<Property ovf:userConfigurable="false" ovf:value="${DISTRO_VERSION}" ovf:type="string" ovf:key="DISTRO_VERSION"/>
|
||||
<Property ovf:userConfigurable="false" ovf:value="${DISTRO_ARCH}" ovf:type="string" ovf:key="DISTRO_ARCH"/>
|
||||
<Property ovf:userConfigurable="false" ovf:value="${CNI_VERSION}" ovf:type="string" ovf:key="CNI_VERSION"/>
|
||||
<Property ovf:userConfigurable="false" ovf:value="${CONTAINERD_VERSION}" ovf:type="string" ovf:key="CONTAINERD_VERSION"/>
|
||||
<Property ovf:userConfigurable="false" ovf:value="${KUBERNETES_SEMVER}" ovf:type="string" ovf:key="KUBERNETES_SEMVER"/>
|
||||
<Property ovf:userConfigurable="false" ovf:value="${KUBERNETES_SOURCE_TYPE}" ovf:type="string" ovf:key="KUBERNETES_SOURCE_TYPE"/>\n''').substitute(data)
|
||||
|
||||
# Check if OVF_CUSTOM_PROPERTIES environment Variable is set.
|
||||
# If so, load the json file & add the properties to the OVF
|
||||
|
||||
if os.environ.get("OVF_CUSTOM_PROPERTIES"):
|
||||
with open(os.environ.get("OVF_CUSTOM_PROPERTIES"), 'r') as f:
|
||||
custom_properties = json.loads(f.read())
|
||||
if custom_properties:
|
||||
for k, v in custom_properties.items():
|
||||
data['PROPERTIES'] = data['PROPERTIES'] + \
|
||||
f''' <Property ovf:userConfigurable="false" ovf:value="{v}" ovf:type="string" ovf:key="{k}"/>\n'''
|
||||
|
||||
if "windows" in OS_id_map[build_data['guest_os_type']]['type']:
|
||||
if build_data['disable_hypervisor'] != "true":
|
||||
data['NESTEDHV'] = "true"
|
||||
|
||||
ovf = "%s-%s.ovf" % (build_data['build_name'], data['TYPED_VERSION'])
|
||||
mf = "%s-%s.mf" % (build_data['build_name'], data['TYPED_VERSION'])
|
||||
ova = "%s-%s.ova" % (build_data['build_name'], data['TYPED_VERSION'])
|
||||
|
||||
# Create OVF
|
||||
create_ovf(ovf, data, ovf_template)
|
||||
|
||||
if os.environ.get("IB_OVFTOOL"):
|
||||
# Create the OVA.
|
||||
create_ova(ova, ovf, ovftool_args=os.environ.get("IB_OVFTOOL_ARGS", ""))
|
||||
|
||||
else:
|
||||
# Create the OVA manifest.
|
||||
create_ova_manifest(mf, [ovf, vmdk['stream_name']])
|
||||
|
||||
# Create the OVA
|
||||
create_ova(ova, ovf, ova_files=[mf, vmdk['stream_name']])
|
||||
|
||||
|
||||
def sha256(path):
|
||||
m = hashlib.sha256()
|
||||
with open(path, 'rb') as f:
|
||||
while True:
|
||||
data = f.read(65536)
|
||||
if not data:
|
||||
break
|
||||
m.update(data)
|
||||
return m.hexdigest()
|
||||
|
||||
|
||||
def create_ova(ova_path, ovf_path, ovftool_args=None, ova_files=None):
|
||||
if ova_files is None:
|
||||
cmd = f"ovftool {ovftool_args} {ovf_path} {ova_path}"
|
||||
|
||||
print("image-build-ova: creating OVA from %s using ovftool" %
|
||||
ovf_path)
|
||||
subprocess.run(cmd.split(), check=True)
|
||||
else:
|
||||
infile_paths = [ovf_path]
|
||||
infile_paths.extend(ova_files)
|
||||
print("image-build-ova: creating OVA using tar")
|
||||
with open(ova_path, 'wb') as f:
|
||||
with tarfile.open(fileobj=f, mode='w|') as tar:
|
||||
for infile_path in infile_paths:
|
||||
tar.add(infile_path)
|
||||
|
||||
chksum_path = "%s.sha256" % ova_path
|
||||
print("image-build-ova: create ova checksum %s" % chksum_path)
|
||||
with open(chksum_path, 'w') as f:
|
||||
f.write(sha256(ova_path))
|
||||
|
||||
|
||||
def create_ovf(path, data, ovf_template):
|
||||
print("image-build-ova: create ovf %s" % path)
|
||||
with io.open(path, 'w', encoding='utf-8') as f:
|
||||
f.write(Template(ovf_template).substitute(data))
|
||||
|
||||
|
||||
def create_ova_manifest(path, infile_paths):
|
||||
print("image-build-ova: create ova manifest %s" % path)
|
||||
with open(path, 'w') as f:
|
||||
for i in infile_paths:
|
||||
f.write('SHA256(%s)= %s\n' % (i, sha256(i)))
|
||||
|
||||
|
||||
def get_vmdk_files(inlist):
|
||||
outlist = []
|
||||
for f in inlist:
|
||||
if f['name'].endswith('.vmdk'):
|
||||
outlist.append(f)
|
||||
return outlist
|
||||
|
||||
|
||||
def stream_optimize_vmdk_files(inlist):
|
||||
for f in inlist:
|
||||
infile = f['name']
|
||||
outfile = infile.replace('.vmdk', '.ova.vmdk', 1)
|
||||
if os.path.isfile(outfile):
|
||||
os.remove(outfile)
|
||||
args = [
|
||||
'vmware-vdiskmanager',
|
||||
'-r', infile,
|
||||
'-t', '5',
|
||||
outfile
|
||||
]
|
||||
print("image-build-ova: stream optimize %s --> %s (1-2 minutes)" %
|
||||
(infile, outfile))
|
||||
subprocess.check_call(args)
|
||||
f['stream_name'] = outfile
|
||||
f['stream_size'] = os.path.getsize(outfile)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
68
hack/image-govc-cloudinit.sh
Executable file
68
hack/image-govc-cloudinit.sh
Executable file
@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
################################################################################
|
||||
# usage: image-govc-cloudinit.sh VM
|
||||
# This program updates a remote VM with the cloud-init data to ready it for
|
||||
# testing. This program requires a configured govc.
|
||||
################################################################################
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
if [ "${#}" -lt "1" ]; then
|
||||
echo "usage: ${0} VM" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v govc >/dev/null 2>&1; then
|
||||
echo "govc binary must be in \$PATH" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export GOVC_VM="${1-}"
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
# If the VM has a "new" snapshot then revert to it and delete all other
|
||||
# snapshots.
|
||||
snapshots="$(govc snapshot.tree 2>/dev/null)" || true
|
||||
if [[ ${snapshots} = *new* ]]; then
|
||||
echo "image-govc-cloudinit: reverting to snapshot 'new'"
|
||||
govc snapshot.revert new
|
||||
for s in ${snapshots}; do
|
||||
if [ "${s}" != "new" ] && [ "${s}" != "." ] ; then
|
||||
echo "image-govc-cloudinit: removing snapshot '${s}'"
|
||||
govc snapshot.remove "${s}"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "image-govc-cloudinit: creating snapshot 'new'"
|
||||
govc snapshot.create new
|
||||
fi
|
||||
|
||||
echo "image-govc-cloudinit: initializing cloud-init data"
|
||||
govc vm.change \
|
||||
-e "guestinfo.userdata.encoding=base64" \
|
||||
-e "guestinfo.metadata.encoding=base64" \
|
||||
-e "guestinfo.userdata='$(base64 -w0 <cloudinit/user-data)'" \
|
||||
-e "guestinfo.metadata='$(base64 -w0 <cloudinit/meta-data)'"
|
||||
|
||||
echo "image-govc-cloudinit: creating snapshot 'cloudinit'"
|
||||
govc snapshot.create cloudinit
|
12
hack/image-grok-latest-flatcar-version.sh
Executable file
12
hack/image-grok-latest-flatcar-version.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash -ue
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
channel="$1"
|
||||
|
||||
curl -L -s \
|
||||
"https://www.flatcar.org/releases-json/releases-$channel.json" \
|
||||
| jq -r 'to_entries[] | "\(.key)"' \
|
||||
| grep -v "current" \
|
||||
| sort --version-sort \
|
||||
| tail -n1
|
192
hack/image-new-kube.py
Executable file
192
hack/image-new-kube.py
Executable file
@ -0,0 +1,192 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import re
|
||||
import requests
|
||||
import sys
|
||||
import tarfile
|
||||
from io import BytesIO
|
||||
|
||||
KUBE_SRC = "https://dl.k8s.io"
|
||||
|
||||
KUBE_RESOLVED_SEM = "kubernetes_semver"
|
||||
KUBE_RESOLVED_SRC = "kubernetes_http_source"
|
||||
KUBE_RESOLVED_VER = "kubernetes_version"
|
||||
|
||||
# KubeVersionResolver is used for resolving Kubernetes version strings to the
|
||||
# actual version and URL or package string that may be used to deploy
|
||||
# Kubernetes.
|
||||
|
||||
|
||||
class KubeVersionResolver(object):
|
||||
|
||||
# Resolve accepts a Kubernetes version string and returns a dictionary with
|
||||
# information that can be used to deploy the provided version.
|
||||
def Resolve(self, version):
|
||||
if version == '':
|
||||
raise Exception('version is required')
|
||||
|
||||
result = {
|
||||
KUBE_RESOLVED_SEM: version,
|
||||
KUBE_RESOLVED_SRC: 'pkg',
|
||||
KUBE_RESOLVED_VER: version,
|
||||
}
|
||||
|
||||
# When version is 'latest' then the returned dictionary points
|
||||
# to the latest package for Kubernetes.
|
||||
if version == 'latest':
|
||||
return result
|
||||
# Otherwise check to see if the provided version matches a
|
||||
# managed package format. Technically the else clause could be
|
||||
# descoped one level, but by placing the logic in the scope of
|
||||
# the else clause, the scope of 'match' is isolated from the
|
||||
# rest of this function.
|
||||
else:
|
||||
match = re.match(r'^(\d+\.\d+.\d+)\-\d+$', version)
|
||||
if match:
|
||||
version = match.groups(1)[0]
|
||||
result[KUBE_RESOLVED_SEM] = f'v{version}'
|
||||
return result
|
||||
|
||||
url = ''
|
||||
if re.match(r'(?i)^https?:', version):
|
||||
url = version
|
||||
elif re.match(r'^v?\d+(?:\.\d+){0,3}(?:[.+-].+)?$', version):
|
||||
if not version.startswith('v'):
|
||||
version = f'v{version}'
|
||||
url = f'{KUBE_SRC}/release/{version}'
|
||||
elif re.match(r'^(ci|release)/.+$', version):
|
||||
url = self.__resolve_build_url(version)
|
||||
else:
|
||||
raise Exception(f'Invalid Kubernetes version: {version}')
|
||||
result[KUBE_RESOLVED_SRC] = url
|
||||
|
||||
version = self.__read_version_from_kube_tarball(url)
|
||||
result[KUBE_RESOLVED_SEM] = version
|
||||
result[KUBE_RESOLVED_VER] = version
|
||||
|
||||
return result
|
||||
|
||||
def __resolve_build_url(self, buildID):
|
||||
url = f'{KUBE_SRC}/{buildID}'
|
||||
|
||||
# If the URL doesn't end with '.txt' then see if the URL is already valid.
|
||||
if not url.endswith('.txt'):
|
||||
# If there is a kubernetes tarball available at the root of the URL
|
||||
# then it is already a valid URL.
|
||||
try:
|
||||
r = requests.head(url, allow_redirects=True)
|
||||
if r.status_code >= 200 and r.status_code <= 299:
|
||||
return url
|
||||
except:
|
||||
pass
|
||||
# The URL wasn't valid, so add '.txt' to the end and let's see if the
|
||||
# URL points to a valid build.
|
||||
url = f'{url}.txt'
|
||||
|
||||
# Do an HTTP GET on the txt file to get the actual Kubernetes version.
|
||||
version = requests.get(url).text
|
||||
version = version.strip()
|
||||
|
||||
if buildID.startswith('ci/'):
|
||||
version = f'ci/{version}'
|
||||
url = f'{KUBE_SRC}/{version}'
|
||||
|
||||
return url
|
||||
|
||||
def __read_version_from_kube_tarball(self, url):
|
||||
url = f'{url}/kubernetes.tar.gz'
|
||||
r = requests.get(url)
|
||||
if not r.status_code == 200:
|
||||
raise Exception(f'HTTP GET {url} failed: {r.status_code}')
|
||||
b = BytesIO(r.content)
|
||||
t = tarfile.open(fileobj=b, mode='r')
|
||||
v = t.extractfile('kubernetes/version')
|
||||
return v.read().strip().decode('utf-8')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
import textwrap
|
||||
parser = argparse.ArgumentParser(
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description='Generates new Kubernetes image config',
|
||||
epilog=textwrap.dedent(r'''
|
||||
THE VERSION STRING
|
||||
====================================================================
|
||||
The version string not only determines what version of Kubernetes
|
||||
will be installed, but also *how* Kubernetes is installed.
|
||||
|
||||
PLACEHOLDERS
|
||||
====================================================================
|
||||
The following placeholders are used in the examples below:
|
||||
|
||||
BASE_URI https://dl.k8s.io
|
||||
K8S_TGZ kubernetes.tar.gz
|
||||
|
||||
PACKAGE MANAGER INSTALLATION
|
||||
====================================================================
|
||||
If the version string matches the pattern "^\d+\.\d+.\d+\-\d+$",
|
||||
ex. 1.14.0-0, then Kubernetes is installed using the system's
|
||||
package manager, such as yum or apt.
|
||||
|
||||
MANUAL INSTALLATION
|
||||
====================================================================
|
||||
If the string does not match the above pattern then the following
|
||||
logic is used to resolve the string VALUE to a valid Kubernetes
|
||||
version along with the URLs for the Kubernetes artifiacts required
|
||||
for installation:
|
||||
|
||||
1. If the VALUE begins with "http:" or "https:" then the value is
|
||||
treated as a URL and the Kubernetes version is obtained by reading
|
||||
the "kuberentes/version" file from the URL "VALUE/K8S_TGZ".
|
||||
|
||||
2. If the VALUE matches a semantic version then the value is
|
||||
treated as a release build and "BASE_URI/release/SEMVER"
|
||||
is processed like the URL in step one.
|
||||
|
||||
3. If the VALUE begins with "ci/" then:
|
||||
|
||||
a. If VALUE does not end with ".txt" then a HEAD request is used
|
||||
to check the existence of "BASE_URI/VALUE/K8S_TGZ":
|
||||
|
||||
i. If the HEAD request is successful then the URL is processed
|
||||
like the one in step one.
|
||||
ii. If the HEAD request fails then ".txt" is added to the end
|
||||
of the URL and is processed by step 3b.
|
||||
|
||||
b. If VALUE *does* end with ".txt" then a GET request is used to
|
||||
read "BASE_URI/VALUE" in order to get the dereferenced
|
||||
version string. Then "BASE_URI/ci/DEREF" is processed
|
||||
like the URL in step one.
|
||||
|
||||
4. If the VALUE begins with "release/" then the VALUE is processed
|
||||
like step three, without the "ci/" prefix
|
||||
|
||||
The resolved URL is used to install Kuberentes from the set of
|
||||
pre-built container images and binaries.
|
||||
'''))
|
||||
parser.add_argument('version',
|
||||
nargs=1,
|
||||
help='A Kubernetes version string')
|
||||
|
||||
args = parser.parse_args()
|
||||
resolver = KubeVersionResolver()
|
||||
result = resolver.Resolve(args.version[0])
|
||||
|
||||
data = json.dumps(result, indent=2)
|
||||
print(data)
|
80
hack/image-post-create-config.sh
Executable file
80
hack/image-post-create-config.sh
Executable file
@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
################################################################################
|
||||
# usage: image-post-create-config.sh BUILD_DIR
|
||||
# This program runs after a new image is created and:
|
||||
# 1. Creates a snapshot of the image named "new"
|
||||
# 2. Modifies the image to use 2 vCPU
|
||||
# 3. Creates a snapshot of the image named "2cpu"
|
||||
# 4. Attaches the ISO build/images/cloudinit/cidata.iso
|
||||
################################################################################
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
if [ "${#}" -ne "1" ]; then
|
||||
echo "usage: ${0} BUILD_DIR" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VM_RUN="${VM_RUN:-$(command -v vmrun 2>/dev/null)}"
|
||||
if [ ! -e "${VM_RUN}" ] || [ ! -x "${VM_RUN}" ]; then
|
||||
echo "vmrun must be in \$PATH or specified by \$VM_RUN" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
VM_RUN_DIR="$(dirname "${VM_RUN}")"
|
||||
export PATH="${VM_RUN_DIR}:${PATH}"
|
||||
|
||||
# Get the path of the VMX file.
|
||||
VMX_FILE=$(/bin/ls "${1-}"/*.vmx)
|
||||
|
||||
create_snapshot() {
|
||||
snapshots="$(vmrun listSnapshots "${VMX_FILE}" 2>/dev/null)"
|
||||
if [[ ${snapshots} = *${1-}* ]]; then
|
||||
echo "image-post-create-config: skip snapshot '${1-}'; already exists"
|
||||
else
|
||||
echo "image-post-create-config: create snapshot '${1-}'"
|
||||
vmrun snapshot "${VMX_FILE}" "${1-}"
|
||||
fi
|
||||
}
|
||||
|
||||
create_snapshot new
|
||||
|
||||
if grep -q 'numvcpus = "2"' "${VMX_FILE}"; then
|
||||
echo "image-post-create-config: skipping cpu update; already 2"
|
||||
else
|
||||
echo "image-post-create-config: update cpu count to 2"
|
||||
sed -i.bak -e 's/numvcpus = "1"/numvcpus = "2"/' -e 's/cpuid.corespersocket = "1"/cpuid.corespersocket = "2"/' "${VMX_FILE}"
|
||||
create_snapshot 2cpu
|
||||
fi
|
||||
|
||||
if grep -q 'guestinfo.userdata' "${VMX_FILE}"; then
|
||||
echo "image-post-create-config: skipping cloud-init data; already exists"
|
||||
else
|
||||
echo "image-post-create-config: insert cloud-init data"
|
||||
CIDATA_DIR="$(dirname "${BASH_SOURCE[0]}")/../cloudinit"
|
||||
cat <<EOF >>"${VMX_FILE}"
|
||||
guestinfo.userdata = "$({ base64 -w0 || base64; } 2>/dev/null <"${CIDATA_DIR}/user-data")"
|
||||
guestinfo.userdata.encoding = "base64"
|
||||
guestinfo.metadata = "$({ base64 -w0 || base64; } 2>/dev/null <"${CIDATA_DIR}/meta-data")"
|
||||
guestinfo.metadata.encoding = "base64"
|
||||
EOF
|
||||
create_snapshot cloudinit
|
||||
fi
|
61
hack/image-ssh.sh
Executable file
61
hack/image-ssh.sh
Executable file
@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
################################################################################
|
||||
# usage: image-ssh.sh BUILD_DIR [SSH_USER]
|
||||
# This program uses SSH to connect to an image running locally in VMware
|
||||
# Workstation or VMware Fusion.
|
||||
################################################################################
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
[[ -n ${DEBUG:-} ]] && set -o xtrace
|
||||
|
||||
if [ "${#}" -lt "1" ]; then
|
||||
echo "usage: ${0} BUILD_DIR [SSH_USER]" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VM_RUN="${VM_RUN:-$(command -v vmrun 2>/dev/null)}"
|
||||
if [ ! -e "${VM_RUN}" ] || [ ! -x "${VM_RUN}" ]; then
|
||||
echo "vmrun must be in \$PATH or specified by \$VM_RUN" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
VM_RUN_DIR="$(dirname "${VM_RUN}")"
|
||||
export PATH="${VM_RUN_DIR}:${PATH}"
|
||||
|
||||
# Get the path of the VMX file.
|
||||
VMX_FILE=$(/bin/ls "${1-}"/*.vmx)
|
||||
|
||||
# Get the SSH user.
|
||||
SSH_USER="${SSH_USER:-${2-}}"
|
||||
if [ -z "${SSH_USER}" ]; then
|
||||
SSH_USER=builder
|
||||
fi
|
||||
if [ -z "${SSH_USER}" ]; then
|
||||
echo "SSH_USER is required" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the VM's IP address.
|
||||
IP_ADDR="$(vmrun getGuestIPAddress "${VMX_FILE}")"
|
||||
|
||||
# SSH into the VM with the provided user.
|
||||
SSH_KEY="$(dirname "${BASH_SOURCE[0]}")/../cloudinit/id_rsa.capi"
|
||||
echo "image-ssh: ssh -i ${SSH_KEY} ${SSH_USER}@${IP_ADDR}"
|
||||
exec ssh -o UserKnownHostsFile=/dev/null -i "${SSH_KEY}" "${SSH_USER}"@"${IP_ADDR}"
|
137
hack/image-upload.py
Executable file
137
hack/image-upload.py
Executable file
@ -0,0 +1,137 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
################################################################################
|
||||
# usage: image-upload.py [FLAGS] ARGS
|
||||
# This program uploads an OVA created from a Packer build
|
||||
################################################################################
|
||||
|
||||
import argparse
|
||||
import atexit
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import requests
|
||||
import subprocess
|
||||
import string
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Uploads an OVA created from a Packer build")
|
||||
parser.add_argument(dest='build_dir',
|
||||
nargs='?',
|
||||
metavar='BUILD_DIR',
|
||||
default='.',
|
||||
help='The Packer build directory')
|
||||
parser.add_argument('--key-file',
|
||||
dest='key_file',
|
||||
required=True,
|
||||
nargs='?',
|
||||
metavar='KEY_FILE',
|
||||
help='The GCS key file')
|
||||
args = parser.parse_args()
|
||||
|
||||
# Get the absolute path to the GCS key file.
|
||||
key_file = os.path.abspath(args.key_file)
|
||||
|
||||
# Change the working directory if one is specified.
|
||||
os.chdir(args.build_dir)
|
||||
print("image-upload-ova: cd %s" % args.build_dir)
|
||||
|
||||
# Load the packer manifest JSON
|
||||
data = None
|
||||
with open('packer-manifest.json', 'r') as f:
|
||||
data = json.load(f)
|
||||
|
||||
# Get the first build.
|
||||
build = data['builds'][0]
|
||||
build_data = build['custom_data']
|
||||
|
||||
version = build_data['kubernetes_semver']
|
||||
build_name = "%s-kube-%s" % (build_data['build_name'], version)
|
||||
print("image-upload-ova: loaded %s" % build_name)
|
||||
|
||||
# Get the OVA and its checksum.
|
||||
ova = "%s.ova" % build_name
|
||||
ova_sum = "%s.sha256" % ova
|
||||
|
||||
# Determine whether or not this is a release or CI image.
|
||||
upload_dir = 'ci'
|
||||
if re.match(r'^v?\d+\.\d+\.\d+(-\d+)?$', version):
|
||||
upload_dir = 'release'
|
||||
|
||||
# Get the path to the GCS OVA and its checksum.
|
||||
gcs_ova = "gs://capv-images/%s/%s/%s" % (
|
||||
upload_dir, version, ova)
|
||||
gcs_ova_sum = "%s.sha256" % gcs_ova
|
||||
|
||||
# Get the URL of the OVA and its checksum.
|
||||
url_ova = string.replace(gcs_ova, "gs://", "http://storage.googleapis.com/")
|
||||
url_ova_sum = "%s.sha256" % url_ova
|
||||
|
||||
# Compare the remote checksum with the local checksum.
|
||||
lcl_ova_sum_val = get_local_checksum(ova_sum)
|
||||
print("image-upload-ova: local sha256 %s" % lcl_ova_sum_val)
|
||||
rem_ova_sum_val = get_remote_checksum(url_ova_sum)
|
||||
print("image-upload-ova: remote sha256 %s" % rem_ova_sum_val)
|
||||
if lcl_ova_sum_val == rem_ova_sum_val:
|
||||
print("image-upload-ova: skipping upload")
|
||||
print("image-upload-ova: download from %s" % url_ova)
|
||||
return
|
||||
|
||||
# Activate the GCS service account.
|
||||
activate_service_account(key_file)
|
||||
atexit.register(deactivate_service_account)
|
||||
|
||||
# Upload the OVA and its checksum.
|
||||
print("image-upload-ova: upload %s" % gcs_ova)
|
||||
subprocess.check_call(['gsutil', 'cp', ova, gcs_ova])
|
||||
print("image-upload-ova: upload %s" % gcs_ova_sum)
|
||||
subprocess.check_call(['gsutil', 'cp', ova_sum, gcs_ova_sum])
|
||||
|
||||
print("image-upload-ova: download from %s" % url_ova)
|
||||
|
||||
|
||||
def activate_service_account(path):
|
||||
args = [
|
||||
"gcloud", "auth",
|
||||
"activate-service-account",
|
||||
"--key-file", path,
|
||||
]
|
||||
subprocess.check_call(args)
|
||||
|
||||
|
||||
def deactivate_service_account():
|
||||
subprocess.call(["gcloud", "auth", "revoke"])
|
||||
|
||||
|
||||
def get_remote_checksum(url):
|
||||
r = requests.get(url)
|
||||
if r.status_code >= 200 and r.status_code <= 299:
|
||||
return r.text.strip()
|
||||
return None
|
||||
|
||||
|
||||
def get_local_checksum(path):
|
||||
with open(path, 'r') as f:
|
||||
return f.readline().strip()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
273
hack/ovf_eula.txt
Normal file
273
hack/ovf_eula.txt
Normal file
@ -0,0 +1,273 @@
|
||||
VMWARE END USER LICENSE AGREEMENT
|
||||
|
||||
|
||||
|
||||
PLEASE NOTE THAT THE TERMS OF THIS END USER LICENSE AGREEMENT SHALL GOVERN YOUR USE OF THE SOFTWARE, REGARDLESS OF ANY TERMS THAT MAY APPEAR DURING THE INSTALLATION OF THE SOFTWARE.
|
||||
|
||||
IMPORTANT-READ CAREFULLY: BY DOWNLOADING, INSTALLING, OR USING THE SOFTWARE, YOU (THE INDIVIDUAL OR LEGAL ENTITY) AGREE TO BE BOUND BY THE TERMS OF THIS END USER LICENSE AGREEMENT ("EULA"). IF YOU DO NOT AGREE TO THE TERMS OF THIS EULA, YOU MUST NOT DOWNLOAD, INSTALL, OR USE THE SOFTWARE, AND YOU MUST DELETE OR RETURN THE UNUSED SOFTWARE TO THE VENDOR FROM WHICH YOU ACQUIRED IT WITHIN THIRTY (30) DAYS AND REQUEST A REFUND OF THE LICENSE FEE, IF ANY, THAT YOU PAID FOR THE SOFTWARE.
|
||||
|
||||
EVALUATION LICENSE. If You are licensing the Software for evaluation purposes, Your use of the Software is only permitted in a non-production environment and for the period limited by the License Key. Notwithstanding any other provision in this EULA, an Evaluation License of the Software is provided "AS-IS" without indemnification, support or warranty of any kind, expressed or implied.
|
||||
|
||||
|
||||
|
||||
1. DEFINITIONS.
|
||||
|
||||
|
||||
|
||||
1.1. "Affiliate" means, with respect to a party at a given time, an entity that then is directly or indirectly controlled by, is under common control with, or controls that party, and here "control" means an ownership, voting or similar interest representing fifty percent (50%) or more of the total interests then outstanding of that entity.
|
||||
|
||||
|
||||
|
||||
1.2. "Documentation" means that documentation that is generally provided to You by VMware with the Software, as revised by VMware from time to time, and which may include end user manuals, operation instructions, installation guides, release notes, and on-line help files regarding the use of the Software.
|
||||
|
||||
|
||||
|
||||
1.3. "Guest Operating Systems" means instances of third-party operating systems licensed by You, installed in a Virtual Machine and run using the Software.
|
||||
|
||||
|
||||
|
||||
1.4. "Intellectual Property Rights" means all worldwide intellectual property rights, including without limitation, copyrights, trademarks, service marks, trade secrets, know how, inventions, patents, patent applications, moral rights and all other proprietary rights, whether registered or unregistered.
|
||||
|
||||
|
||||
|
||||
1.5. "License" means a license granted under Section 2.1 (General License Grant).
|
||||
|
||||
|
||||
|
||||
1.6. "License Key" means a serial number that enables You to activate and use the Software.
|
||||
|
||||
|
||||
|
||||
1.7. "License Term" means the duration of a License as specified in the Order.
|
||||
|
||||
|
||||
|
||||
1.8. "License Type" means the type of License applicable to the Software, as more fully described in the Order.
|
||||
|
||||
|
||||
|
||||
1.9. "Open Source Software" or "OSS" means software components embedded in the Software and provided under separate license terms, which can be found either in the open_source_licenses.txt file (or similar file) provided within the Software or at www.vmware.com/download/open_source.html.
|
||||
|
||||
|
||||
|
||||
1.10. "Order" means a purchase order, enterprise license agreement, or other ordering document issued by You to VMware or a VMware authorized reseller that references and incorporates this EULA and is accepted by VMware as set forth in Section 4 (Order).
|
||||
|
||||
|
||||
|
||||
1.11. "Product Guide" means the current version of the VMware Product Guide at the time of Your Order, copies of which are found at www.vmware.com/download/eula.
|
||||
|
||||
|
||||
|
||||
1.12. "Support Services Terms" means VMware's then-current support policies, copies of which are posted at www.vmware.com/support/policies.
|
||||
|
||||
|
||||
|
||||
1.13. "Software" means the VMware Tools and the VMware computer programs listed on VMware's commercial price list to which You acquire a license under an Order, together with any software code relating to the foregoing that is provided to You pursuant to a support and subscription service contract and that is not subject to a separate license agreement.
|
||||
|
||||
|
||||
|
||||
1.14. "Territory" means the country or countries in which You have been invoiced; provided, however, that if You have been invoiced within any of the European Economic Area member states, You may deploy the corresponding Software throughout the European Economic Area.
|
||||
|
||||
|
||||
|
||||
1.15. "Third Party Agent" means a third party delivering information technology services to You pursuant to a written contract with You.
|
||||
|
||||
|
||||
|
||||
1.16. "Virtual Machine" means a software container that can run its own operating system and execute applications like a physical machine.
|
||||
|
||||
|
||||
|
||||
1.17. "VMware" means VMware, Inc., a Delaware corporation, if You are purchasing Licenses or services for use in the United States and VMware International Unlimited Company , a company organized and existing under the laws of Ireland, for all other purchases.
|
||||
|
||||
|
||||
|
||||
1.18. "VMware Tools" means the suite of utilities and drivers, Licensed by VMware under the "VMware Tools" name, that can be installed in a Guest Operating System to enhance the performance and functionality of a Guest Operating System when running in a Virtual Machine.
|
||||
|
||||
|
||||
|
||||
2. LICENSE GRANT.
|
||||
|
||||
|
||||
|
||||
2.1. General License Grant. VMware grants to You a non-exclusive, non-transferable (except as set forth in Section 12.1 (Transfers; Assignment)) license to use the Software and the Documentation during the period of the license and within the Territory, solely for Your internal business operations, and subject to the provisions of the Product Guide. Unless otherwise indicated in the Order, licenses granted to You will be perpetual, will be for use of object code only, and will commence on either delivery of the physical media or the date You are notified of availability for electronic download.
|
||||
|
||||
|
||||
|
||||
2.2. Third Party Agents. Under the License granted to You in Section 2.1 (General License Grant) above, You may permit Your Third Party Agents to access, use and/or operate the Software on Your behalf for the sole purpose of delivering services to You, provided that You will be fully responsible for Your Third Party Agents' compliance with terms and conditions of this EULA and any breach of this EULA by a Third Party Agent shall be deemed to be a breach by You.
|
||||
|
||||
|
||||
|
||||
2.3. Copying Permitted. You may copy the Software and Documentation as necessary to install and run the quantity of copies licensed, but otherwise for archival purposes only.
|
||||
|
||||
|
||||
|
||||
2.4. Benchmarking. You may use the Software to conduct internal performance testing and benchmarking studies. You may only publish or otherwise distribute the results of such studies to third parties as follows: (a) if with respect to VMware's Workstation or Fusion products, only if You provide a copy of Your study to benchmark@vmware.com prior to distribution; (b) if with respect to any other Software, only if VMware has reviewed and approved of the methodology, assumptions and other parameters of the study (please contact VMware at benchmark@vmware.com to request such review and approval) prior to such publication and distribution.
|
||||
|
||||
|
||||
|
||||
2.5. VMware Tools. You may distribute the VMware Tools to third parties solely when installed in a Guest Operating System within a Virtual Machine. You are liable for compliance by those third parties with the terms and conditions of this EULA.
|
||||
|
||||
|
||||
|
||||
2.6. Open Source Software. Notwithstanding anything herein to the contrary, Open Source Software is licensed to You under such OSS's own applicable license terms, which can be found in the open_source_licenses.txt file, the Documentation or as applicable, the corresponding source files for the Software available at www.vmware.com/download/open_source.html. These OSS license terms are consistent with the license granted in Section 2 (License Grant), and may contain additional rights benefiting You. The OSS license terms shall take precedence over this EULA to the extent that this EULA imposes greater restrictions on You than the applicable OSS license terms. To the extent the license for any Open Source Software requires VMware to make available to You the corresponding source code and/or modifications (the "Source Files"), You may obtain a copy of the applicable Source Files from VMware's website at www.vmware.com/download/open_source.html or by sending a written request, with Your name and address to: VMware, Inc., 3401 Hillview Avenue, Palo Alto, CA 94304, United States of America. All requests should clearly specify: Open Source Files Request, Attention: General Counsel. This offer to obtain a copy of the Source Files is valid for three years from the date You acquired this Software.
|
||||
|
||||
|
||||
|
||||
3. RESTRICTIONS; OWNERSHIP.
|
||||
|
||||
|
||||
|
||||
3.1. License Restrictions. Without VMware's prior written consent, You must not, and must not allow any third party to: (a) use Software in an application services provider, service bureau, or similar capacity for third parties, except that You may use the Software to deliver hosted services to Your Affiliates; (b) disclose to any third party the results of any benchmarking testing or comparative or competitive analyses of VMware's Software done by or on behalf of You, except as specified in Section 2.4 (Benchmarking); (c) make available Software in any form to anyone other than Your employees or contractors reasonably acceptable to VMware and require access to use Software on behalf of You in a matter permitted by this EULA, except as specified in Section 2.2 (Third Party Agents); (d) transfer or sublicense Software or Documentation to an Affiliate or any third party, except as expressly permitted in Section 12.1 (Transfers; Assignment); (e) use Software in conflict with the terms and restrictions of the Software's licensing model and other requirements specified in Product Guide and/or VMware quote; (f) except to the extent permitted by applicable mandatory law, modify, translate, enhance, or create derivative works from the Software, or reverse engineer, decompile, or otherwise attempt to derive source code from the Software, except as specified in Section 3.2 (Decompilation); (g) remove any copyright or other proprietary notices on or in any copies of Software; or (h) violate or circumvent any technological restrictions within the Software or specified in this EULA, such as via software or services.
|
||||
|
||||
|
||||
|
||||
3.2. Decompilation. Notwithstanding the foregoing, decompiling the Software is permitted to the extent the laws of the Territory give You the express right to do so to obtain information necessary to render the Software interoperable with other software; provided, however, You must first request such information from VMware, provide all reasonably requested information to allow VMware to assess Your claim, and VMware may, in its discretion, either provide such interoperability information to You, impose reasonable conditions, including a reasonable fee, on such use of the Software, or offer to provide alternatives to ensure that VMware's proprietary rights in the Software are protected and to reduce any adverse impact on VMware's proprietary rights.
|
||||
|
||||
|
||||
|
||||
3.3. Ownership. The Software and Documentation, all copies and portions thereof, and all improvements, enhancements, modifications and derivative works thereof, and all Intellectual Property Rights therein, are and shall remain the sole and exclusive property of VMware and its licensors. Your rights to use the Software and Documentation shall be limited to those expressly granted in this EULA and any applicable Order. No other rights with respect to the Software or any related Intellectual Property Rights are implied. You are not authorized to use (and shall not permit any third party to use) the Software, Documentation or any portion thereof except as expressly authorized by this EULA or the applicable Order. VMware reserves all rights not expressly granted to You. VMware does not transfer any ownership rights in any Software.
|
||||
|
||||
|
||||
|
||||
3.4. Guest Operating Systems. Certain Software allows Guest Operating Systems and application programs to run on a computer system. You acknowledge that You are responsible for obtaining and complying with any licenses necessary to operate any such third-party software.
|
||||
|
||||
|
||||
|
||||
4. ORDER. Your Order is subject to this EULA. No Orders are binding on VMware until accepted by VMware. Orders for Software are deemed to be accepted upon VMware's delivery of the Software included in such Order. Orders issued to VMware do not have to be signed to be valid and enforceable.
|
||||
|
||||
|
||||
|
||||
5. RECORDS AND AUDIT. During the License Term for Software and for two (2) years after its expiration or termination, You will maintain accurate records of Your use of the Software sufficient to show compliance with the terms of this EULA. During this period, VMware will have the right to audit Your use of the Software to confirm compliance with the terms of this EULA. That audit is subject to reasonable notice by VMware and will not unreasonably interfere with Your business activities. VMware may conduct no more than one (1) audit in any twelve (12) month period, and only during normal business hours. You will reasonably cooperate with VMware and any third party auditor and will, without prejudice to other rights of VMware, address any non-compliance identified by the audit by promptly paying additional fees. You will promptly reimburse VMware for all reasonable costs of the audit if the audit reveals either underpayment of more than five (5%) percent of the Software fees payable by You for the period audited, or that You have materially failed to maintain accurate records of Software use.
|
||||
|
||||
|
||||
|
||||
6. SUPPORT AND SUBSCRIPTION SERVICES. Except as expressly specified in the Product Guide, VMware does not provide any support or subscription services for the Software under this EULA. You have no rights to any updates, upgrades or extensions or enhancements to the Software developed by VMware unless you separately purchase VMware support or subscription services. These support or subscription services are subject to the Support Services Terms.
|
||||
|
||||
|
||||
|
||||
7. WARRANTIES.
|
||||
|
||||
|
||||
|
||||
7.1. Software Warranty, Duration and Remedy. VMware warrants to You that the Software will, for a period of ninety (90) days following notice of availability for electronic download or delivery ("Warranty Period"), substantially conform to the applicable Documentation, provided that the Software: (a) has been properly installed and used at all times in accordance with the applicable Documentation; and (b) has not been modified or added to by persons other than VMware or its authorized representative. VMware will, at its own expense and as its sole obligation and Your exclusive remedy for any breach of this warranty, either replace that Software or correct any reproducible error in that Software reported to VMware by You in writing during the Warranty Period. If VMware determines that it is unable to correct the error or replace the Software, VMware will refund to You the amount paid by You for that Software, in which case the License for that Software will terminate.
|
||||
|
||||
|
||||
|
||||
7.2. Software Disclaimer of Warranty. OTHER THAN THE WARRANTY ABOVE, AND TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, VMWARE AND ITS SUPPLIERS MAKE NO OTHER EXPRESS WARRANTIES UNDER THIS EULA, AND DISCLAIM ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT, AND ANY WARRANTY ARISING BY STATUTE, OPERATION OF LAW, COURSE OF DEALING OR PERFORMANCE, OR USAGE OF TRADE. VMWARE AND ITS LICENSORS DO NOT WARRANT THAT THE SOFTWARE WILL OPERATE UNINTERRUPTED OR THAT IT WILL BE FREE FROM DEFECTS OR THAT IT WILL MEET YOUR REQUIREMENTS.
|
||||
|
||||
|
||||
|
||||
8. INTELLECTUAL PROPERTY INDEMNIFICATION.
|
||||
|
||||
|
||||
|
||||
8.1. Defense and Indemnification. Subject to the remainder of this Section 8 (Intellectual Property Indemnification), VMware shall defend You against any third party claim that the Software infringes any patent, trademark or copyright of such third party, or misappropriates a trade secret (but only to the extent that the misappropriation is not a result of Your actions) under the laws of: (a) the United States and Canada; (b) the European Economic Area; (c) Australia; (d) New Zealand; (e) Japan; or (f) the People's Republic of China, to the extent that such countries are part of the Territory for the License ("Infringement Claim") and indemnify You from the resulting costs and damages finally awarded against You to such third party by a court of competent jurisdiction or agreed to in settlement. The foregoing obligations are applicable only if You: (i) promptly notify VMware in writing of the Infringement Claim; (ii) allow VMware sole control over the defense for the claim, any settlement negotiations and any related action challenging the validity of the allegedly infringed patent, trademark, or copyright; and (iii) reasonably cooperate in response to VMware requests for assistance. You may not settle or compromise any Infringement Claim without the prior written consent of VMware.
|
||||
|
||||
|
||||
|
||||
8.2. Remedies. If the alleged infringing Software become, or in VMware's opinion be likely to become, the subject of an Infringement Claim, VMware will, at VMware's option and expense, do one of the following: (a) procure the rights necessary for You to make continued use of the affected Software; (b) replace or modify the affected Software to make it non-infringing; or (c) terminate the License to the affected Software and discontinue the related support services, and, upon Your certified deletion of the affected Software, refund: (i) the fees paid by You for the License to the affected Software, less straight-line depreciation over a three (3) year useful life beginning on the date such Software was delivered; and (ii) any pre-paid service fee attributable to related support services to be delivered after the date such service is stopped. Nothing in this Section 8.2 (Remedies) shall limit VMware's obligation under Section 8.1 (Defense and Indemnification) to defend and indemnify You, provided that You replace the allegedly infringing Software upon VMware's making alternate Software available to You and/or You discontinue using the allegedly infringing Software upon receiving VMware's notice terminating the affected License.
|
||||
|
||||
|
||||
|
||||
8.3. Exclusions. Notwithstanding the foregoing, VMware will have no obligation under this Section 8 (Intellectual Property Indemnification) or otherwise with respect to any claim based on: (a) a combination of Software with non-VMware products (other than non-VMware products that are listed on the Order and used in an unmodified form); (b) use for a purpose or in a manner for which the Software was not designed; (c) use of any older version of the Software when use of a newer VMware version would have avoided the infringement; (d) any modification to the Software made without VMware's express written approval; (e) any claim that relates to open source software or freeware technology or any derivatives or other adaptations thereof that is not embedded by VMware into Software listed on VMware's commercial price list; or (f) any Software provided on a no charge, beta or evaluation basis. THIS SECTION 8 (INTELLECTUAL PROPERTY INDEMNIFICATION) STATES YOUR SOLE AND EXCLUSIVE REMEDY AND VMWARE'S ENTIRE LIABILITY FOR ANY INFRINGEMENT CLAIMS OR ACTIONS.
|
||||
|
||||
|
||||
|
||||
9. LIMITATION OF LIABILITY.
|
||||
|
||||
|
||||
|
||||
9.1. Limitation of Liability. TO THE MAXIMUM EXTENT MANDATED BY LAW, IN NO EVENT WILL VMWARE AND ITS LICENSORS BE LIABLE FOR ANY LOST PROFITS OR BUSINESS OPPORTUNITIES, LOSS OF USE, LOSS OF REVENUE, LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOSS OF DATA, OR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES UNDER ANY THEORY OF LIABILITY, WHETHER BASED IN CONTRACT, TORT, NEGLIGENCE, PRODUCT LIABILITY, OR OTHERWISE. BECAUSE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE PRECEDING LIMITATION MAY NOT APPLY TO YOU. VMWARE'S AND ITS LICENSORS' LIABILITY UNDER THIS EULA WILL NOT, IN ANY EVENT, REGARDLESS OF WHETHER THE CLAIM IS BASED IN CONTRACT, TORT, STRICT LIABILITY, OR OTHERWISE, EXCEED THE GREATER OF THE LICENSE FEES YOU PAID FOR THE SOFTWARE GIVING RISE TO THE CLAIM OR $5000. THE FOREGOING LIMITATIONS SHALL APPLY REGARDLESS OF WHETHER VMWARE OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF WHETHER ANY REMEDY FAILS OF ITS ESSENTIAL PURPOSE.
|
||||
|
||||
|
||||
|
||||
9.2. Further Limitations. VMware's licensors shall have no liability of any kind under this EULA and VMware's liability with respect to any third party software embedded in the Software shall be subject to Section 9.1 (Limitation of Liability). You may not bring a claim under this EULA more than eighteen (18) months after the cause of action arises.
|
||||
|
||||
|
||||
|
||||
10. TERMINATION.
|
||||
|
||||
|
||||
|
||||
10.1. EULA Term. The term of this EULA begins on the notice of availability for electronic download or delivery of the Software and continues until this EULA is terminated in accordance with this Section 10.
|
||||
|
||||
|
||||
|
||||
10.2. Termination for Breach. VMware may terminate this EULA effective immediately upon written notice to You if: (a) You fail to pay any portion of the fees under an applicable Order within ten (10) days after receiving written notice from VMware that payment is past due; or (b) You breach any other provision of this EULA and fail to cure within thirty (30) days after receipt of VMware's written notice thereof.
|
||||
|
||||
|
||||
|
||||
10.3. Termination for Insolvency. VMware may terminate this EULA effective immediately upon written notice to You if You: (a) terminate or suspend your business; (b) become insolvent, admit in writing Your inability to pay Your debts as they mature, make an assignment for the benefit of creditors; or become subject to control of a trustee, receiver or similar authority; or (c) become subject to any bankruptcy or insolvency proceeding.
|
||||
|
||||
|
||||
|
||||
10.4. Effect of Termination. Upon VMware's termination of this EULA: (a) all Licensed rights to all Software granted to You under this EULA will immediately cease; and (b) You must cease all use of all Software, and return or certify destruction of all Software and License Keys (including copies) to VMware, and return, or if requested by VMware, destroy, any related VMware Confidential Information in Your possession or control and certify in writing to VMware that You have fully complied with these requirements. Any provision will survive any termination or expiration if by its nature and context it is intended to survive, including Sections 1 (Definitions), 2.6 (Open Source Software), 3 (Restrictions; Ownership), 5 (Records and Audit), 7.2 (Software Disclaimer of Warranty), 9 (Limitation of Liability), 10 (Termination), 11 (Confidential Information) and 12 (General).
|
||||
|
||||
|
||||
|
||||
11. CONFIDENTIAL INFORMATION.
|
||||
|
||||
|
||||
|
||||
11.1. Definition. "Confidential Information" means information or materials provided by one party ("Discloser") to the other party ("Recipient") which are in tangible form and labelled "confidential" or the like, or, information which a reasonable person knew or should have known to be confidential. The following information shall be considered Confidential Information whether or not marked or identified as such: (a) License Keys; (b) information regarding VMware's pricing, product roadmaps or strategic marketing plans; and (c) non-public materials relating to the Software.
|
||||
|
||||
|
||||
|
||||
11.2. Protection. Recipient may use Confidential Information of Discloser; (a) to exercise its rights and perform its obligations under this EULA; or (b) in connection with the parties' ongoing business relationship. Recipient will not use any Confidential Information of Discloser for any purpose not expressly permitted by this EULA, and will disclose the Confidential Information of Discloser only to the employees or contractors of Recipient who have a need to know such Confidential Information for purposes of this EULA and who are under a duty of confidentiality no less restrictive than Recipient's duty hereunder. Recipient will protect Confidential Information from unauthorized use, access, or disclosure in the same manner as Recipient protects its own confidential or proprietary information of a similar nature but with no less than reasonable care.
|
||||
|
||||
|
||||
|
||||
11.3. Exceptions. Recipient's obligations under Section 11.2 (Protection) with respect to any Confidential Information will terminate if Recipient can show by written records that such information: (a) was already known to Recipient at the time of disclosure by Discloser; (b) was disclosed to Recipient by a third party who had the right to make such disclosure without any confidentiality restrictions; (c) is, or through no fault of Recipient has become, generally available to the public; or (d) was independently developed by Recipient without access to, or use of, Discloser's Information. In addition, Recipient will be allowed to disclose Confidential Information to the extent that such disclosure is required by law or by the order of a court of similar judicial or administrative body, provided that Recipient notifies Discloser of such required disclosure promptly and in writing and cooperates with Discloser, at Discloser's request and expense, in any lawful action to contest or limit the scope of such required disclosure.
|
||||
|
||||
|
||||
|
||||
11.4. Data Privacy. You agree that VMware may process technical and related information about Your use of the Software which may include internet protocol address, hardware identification, operating system, application software, peripheral hardware, and non-personally identifiable Software usage statistics to facilitate the provisioning of updates, support, invoicing or online services and may transfer such information to other companies in the VMware worldwide group of companies from time to time. To the extent that this information constitutes personal data, VMware shall be the controller of such personal data. To the extent that it acts as a controller, each party shall comply at all times with its obligations under applicable data protection legislation.
|
||||
|
||||
|
||||
|
||||
12. GENERAL.
|
||||
|
||||
|
||||
|
||||
12.1. Transfers; Assignment. Except to the extent transfer may not legally be restricted or as permitted by VMware's transfer and assignment policies, in all cases following the process set forth at www.vmware.com/support/policies/licensingpolicies.html, You will not assign this EULA, any Order, or any right or obligation herein or delegate any performance without VMware's prior written consent, which consent will not be unreasonably withheld. Any other attempted assignment or transfer by You will be void. VMware may use its Affiliates or other sufficiently qualified subcontractors to provide services to You, provided that VMware remains responsible to You for the performance of the services.
|
||||
|
||||
|
||||
|
||||
12.2. Notices. Any notice delivered by VMware to You under this EULA will be delivered via mail, email or fax.
|
||||
|
||||
|
||||
|
||||
12.3. Waiver. Failure to enforce a provision of this EULA will not constitute a waiver.
|
||||
|
||||
|
||||
|
||||
12.4. Severability. If any part of this EULA is held unenforceable, the validity of all remaining parts will not be affected.
|
||||
|
||||
|
||||
|
||||
12.5. Compliance with Laws; Export Control; Government Regulations. Each party shall comply with all laws applicable to the actions contemplated by this EULA. You acknowledge that the Software is of United States origin, is provided subject to the U.S. Export Administration Regulations, may be subject to the export control laws of the applicable territory, and that diversion contrary to applicable export control laws is prohibited. You represent that (1) you are not, and are not acting on behalf of, (a) any person who is a citizen, national, or resident of, or who is controlled by the government of any country to which the United States has prohibited export transactions; or (b) any person or entity listed on the U.S. Treasury Department list of Specially Designated Nationals and Blocked Persons, or the U.S. Commerce Department Denied Persons List or Entity List; and (2) you will not permit the Software to be used for, any purposes prohibited by law, including, any prohibited development, design, manufacture or production of missiles or nuclear, chemical or biological weapons. The Software and accompanying documentation are deemed to be "commercial computer software" and "commercial computer software documentation", respectively, pursuant to DFARS Section 227.7202 and FAR Section 12.212(b), as applicable. Any use, modification, reproduction, release, performing, displaying or disclosing of the Software and documentation by or for the U.S. Government shall be governed solely by the terms and conditions of this EULA.
|
||||
|
||||
|
||||
|
||||
12.6. Construction. The headings of sections of this EULA are for convenience and are not to be used in interpreting this EULA. As used in this EULA, the word ‘including' means "including but not limited to".
|
||||
|
||||
|
||||
|
||||
12.7. Governing Law. This EULA is governed by the laws of the State of California, United States of America (excluding its conflict of law rules), and the federal laws of the United States. To the extent permitted by law, the state and federal courts located in Santa Clara County, California will be the exclusive jurisdiction for disputes arising out of or in connection with this EULA. The U.N. Convention on Contracts for the International Sale of Goods does not apply.
|
||||
|
||||
|
||||
|
||||
12.8. Third Party Rights. Other than as expressly set out in this EULA, this EULA does not create any rights for any person who is not a party to it, and no person who is not a party to this EULA may enforce any of its terms or rely on any exclusion or limitation contained in it.
|
||||
|
||||
|
||||
|
||||
12.9. Order of Precedence. In the event of conflict or inconsistency among the Product Guide, this EULA and the Order, the following order of precedence shall apply unless otherwise set forth in an enterprise license agreement: (a) the Product Guide, (b) this EULA and (c) the Order. With respect to any inconsistency between this EULA and an Order, the terms of this EULA shall supersede and control over any conflicting or additional terms and conditions of any purchase order, acknowledgement or confirmation or other document issued by You.
|
||||
|
||||
|
||||
|
||||
12.10. Entire Agreement. This EULA, including accepted Orders and any amendments hereto, and the Product Guide contain the entire agreement of the parties with respect to the subject matter of this EULA and supersede all previous or contemporaneous communications, representations, proposals, commitments, understandings and agreements, whether written or oral, between the parties regarding the subject matter hereof. This EULA may be amended only in writing signed by authorized representatives of both parties.
|
||||
|
||||
|
||||
|
||||
12.11. Contact Information. Please direct legal notices or other correspondence to VMware, Inc., 3401 Hillview Avenue, Palo Alto, California 94304, United States of America, Attention: Legal Department.
|
170
hack/ovf_template.xml
Normal file
170
hack/ovf_template.xml
Normal file
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Envelope xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<References>
|
||||
<File ovf:id="file1" ovf:href="${DISK_NAME}" ovf:size="${STREAM_DISK_SIZE}"/>
|
||||
</References>
|
||||
<DiskSection>
|
||||
<Info>Virtual disk information</Info>
|
||||
<Disk ovf:capacity="${DISK_SIZE}" ovf:capacityAllocationUnits="byte * 2^20" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="${POPULATED_DISK_SIZE}"/>
|
||||
</DiskSection>
|
||||
<NetworkSection>
|
||||
<Info>The list of logical networks</Info>
|
||||
<Network ovf:name="nic0">
|
||||
<Description>Please select a network</Description>
|
||||
</Network>
|
||||
</NetworkSection>
|
||||
<VirtualSystem ovf:id="${ARTIFACT_ID}">
|
||||
<Info>A virtual machine</Info>
|
||||
<Name>${ARTIFACT_ID}</Name>
|
||||
<AnnotationSection>
|
||||
<Info>A human-readable annotation</Info>
|
||||
<Annotation>${ANNOTATION}</Annotation>
|
||||
</AnnotationSection>
|
||||
<OperatingSystemSection ovf:id="${OS_ID}" ovf:version="${OS_VERSION}" vmw:osType="${OS_TYPE}">
|
||||
<Info>The operating system installed</Info>
|
||||
</OperatingSystemSection>
|
||||
<VirtualHardwareSection>
|
||||
<Info>Virtual hardware requirements</Info>
|
||||
<System>
|
||||
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
|
||||
<vssd:InstanceID>0</vssd:InstanceID>
|
||||
<vssd:VirtualSystemIdentifier>${ARTIFACT_ID}</vssd:VirtualSystemIdentifier>
|
||||
<vssd:VirtualSystemType>vmx-${VMX_VERSION}</vssd:VirtualSystemType>
|
||||
</System>
|
||||
<Item>
|
||||
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
|
||||
<rasd:Description>Number of Virtual CPUs</rasd:Description>
|
||||
<rasd:ElementName>2 virtual CPU(s)</rasd:ElementName>
|
||||
<rasd:InstanceID>1</rasd:InstanceID>
|
||||
<rasd:ResourceType>3</rasd:ResourceType>
|
||||
<rasd:VirtualQuantity>2</rasd:VirtualQuantity>
|
||||
<vmw:CoresPerSocket ovf:required="false">2</vmw:CoresPerSocket>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
|
||||
<rasd:Description>Memory Size</rasd:Description>
|
||||
<rasd:ElementName>2048MB of memory</rasd:ElementName>
|
||||
<rasd:InstanceID>2</rasd:InstanceID>
|
||||
<rasd:ResourceType>4</rasd:ResourceType>
|
||||
<rasd:VirtualQuantity>2048</rasd:VirtualQuantity>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:Address>0</rasd:Address>
|
||||
<rasd:Description>SCSI Controller</rasd:Description>
|
||||
<rasd:ElementName>SCSI controller 0</rasd:ElementName>
|
||||
<rasd:InstanceID>3</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>VirtualSCSI</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>6</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="160"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:Address>1</rasd:Address>
|
||||
<rasd:Description>IDE Controller</rasd:Description>
|
||||
<rasd:ElementName>IDE 1</rasd:ElementName>
|
||||
<rasd:InstanceID>4</rasd:InstanceID>
|
||||
<rasd:ResourceType>5</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:Address>0</rasd:Address>
|
||||
<rasd:Description>IDE Controller</rasd:Description>
|
||||
<rasd:ElementName>IDE 0</rasd:ElementName>
|
||||
<rasd:InstanceID>5</rasd:InstanceID>
|
||||
<rasd:ResourceType>5</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:ElementName>Video card</rasd:ElementName>
|
||||
<rasd:InstanceID>6</rasd:InstanceID>
|
||||
<rasd:ResourceType>24</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="useAutoDetect" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="videoRamSizeInKB" vmw:value="4096"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="enable3DSupport" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="use3dRenderer" vmw:value="automatic"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="graphicsMemorySizeInKB" vmw:value="262144"/>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:ElementName>VMCI device</rasd:ElementName>
|
||||
<rasd:InstanceID>7</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>1</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="32"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="allowUnrestrictedCommunication" vmw:value="false"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||
<rasd:ElementName>Hard disk 1</rasd:ElementName>
|
||||
<rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
|
||||
<rasd:InstanceID>8</rasd:InstanceID>
|
||||
<rasd:Parent>3</rasd:Parent>
|
||||
<rasd:ResourceType>17</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="backing.writeThrough" vmw:value="false"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AddressOnParent>7</rasd:AddressOnParent>
|
||||
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
|
||||
<rasd:Connection>nic0</rasd:Connection>
|
||||
<rasd:Description>VmxNet3 ethernet adapter</rasd:Description>
|
||||
<rasd:ElementName>Network adapter 1</rasd:ElementName>
|
||||
<rasd:InstanceID>9</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>VmxNet3</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>10</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="192"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="wakeOnLanEnabled" vmw:value="${WAKEONLANENABLED}"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="connectable.allowGuestControl" vmw:value="true"/>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:ElementName>CD/DVD drive 1</rasd:ElementName>
|
||||
<rasd:InstanceID>10</rasd:InstanceID>
|
||||
<rasd:Parent>5</rasd:Parent>
|
||||
<rasd:ResourceSubType>vmware.cdrom.remotepassthrough</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>15</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="backing.exclusive" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="connectable.allowGuestControl" vmw:value="false"/>
|
||||
</Item>
|
||||
<vmw:Config ovf:required="false" vmw:key="cpuHotAddEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="cpuHotRemoveEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="memoryHotAddEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="${FIRMWARE}"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.syncTimeWithHost" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.afterPowerOn" vmw:value="true"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.afterResume" vmw:value="true"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.beforeGuestShutdown" vmw:value="true"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="tools.beforeGuestStandby" vmw:value="true"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.powerOffType" vmw:value="soft"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.resetType" vmw:value="soft"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.suspendType" vmw:value="hard"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="nestedHVEnabled" vmw:value="${NESTEDHV}"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="virtualICH7MPresent" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="virtualSMCPresent" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="flags.vvtdEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="flags.vbsEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="bootOptions.efiSecureBootEnabled" vmw:value="false"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.standbyAction" vmw:value="checkpoint"/>
|
||||
</VirtualHardwareSection>
|
||||
<vmw:BootOrderSection vmw:instanceId="8" vmw:type="disk">
|
||||
<Info>Virtual hardware device boot order</Info>
|
||||
</vmw:BootOrderSection>
|
||||
<EulaSection>
|
||||
<Info>An end-user license agreement</Info>
|
||||
<License>
|
||||
${EULA}
|
||||
</License>
|
||||
</EulaSection>
|
||||
<ProductSection>
|
||||
<Info>Information about the installed software</Info>
|
||||
<Product>${PRODUCT}</Product>
|
||||
<Vendor>VMware Inc.</Vendor>
|
||||
<Version>${TYPED_VERSION}</Version>
|
||||
<FullVersion>${TYPED_VERSION}</FullVersion>
|
||||
<VendorUrl>https://vmware.com</VendorUrl>
|
||||
<Category>Cluster API Provider (CAPI)</Category>
|
||||
<Property ovf:userConfigurable="false" ovf:value="${BUILD_TIMESTAMP}" ovf:type="string" ovf:key="BUILD_TIMESTAMP"/>
|
||||
<Property ovf:userConfigurable="false" ovf:value="${BUILD_DATE}" ovf:type="string" ovf:key="BUILD_DATE"/>
|
||||
<Property ovf:userConfigurable="false" ovf:value="${IB_VERSION}" ovf:type="string" ovf:key="IMAGE_BUILDER_VERSION"/>
|
||||
${PROPERTIES}
|
||||
</ProductSection>
|
||||
</VirtualSystem>
|
||||
</Envelope>
|
95
hack/utils.sh
Executable file
95
hack/utils.sh
Executable file
@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2020 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
case "${OSTYPE}" in
|
||||
linux*)
|
||||
HOSTOS=linux
|
||||
;;
|
||||
darwin*)
|
||||
HOSTOS=darwin
|
||||
;;
|
||||
*)
|
||||
echo "unsupported HOSTOS=${OSTYPE}" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
_hostarch=$(uname -m)
|
||||
case "${_hostarch}" in
|
||||
*64*)
|
||||
HOSTARCH=amd64
|
||||
;;
|
||||
*386*)
|
||||
HOSTARCH=386
|
||||
;;
|
||||
*686*)
|
||||
HOSTARCH=386
|
||||
;;
|
||||
*)
|
||||
echo "unsupported HOSTARCH=${_hostarch}" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
checksum_sha256() {
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 -c "${1}"
|
||||
elif command -v sha256sum >/dev/null 2>&1; then
|
||||
sha256sum -c "${1}"
|
||||
else
|
||||
echo "missing shasum tool" 1>&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_shasum() {
|
||||
local present_shasum=''
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
present_shasum=$(shasum -a 256 "${1}"| awk -F' ' '{print $1}')
|
||||
elif command -v sha256sum >/dev/null 2>&1; then
|
||||
present_shasum=$(sha256sum "${1}" | awk -F' ' '{print $1}')
|
||||
else
|
||||
echo "missing shasum tool" 1>&2
|
||||
return 1
|
||||
fi
|
||||
echo "$present_shasum"
|
||||
}
|
||||
|
||||
ensure_py3_bin() {
|
||||
# If given executable is not available, the user Python bin dir is not in path
|
||||
# This function assumes the executable to be checked was installed with
|
||||
# pip3 install --user ...
|
||||
if ! command -v "${1}" >/dev/null 2>&1; then
|
||||
echo "User's Python3 binary directory must be in \$PATH" 1>&2
|
||||
echo "Location of package is:" 1>&2
|
||||
pip3 show --disable-pip-version-check ${2:-$1} | grep "Location"
|
||||
echo "\$PATH is currently: $PATH" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_py3() {
|
||||
if ! command -v python3 >/dev/null 2>&1; then
|
||||
echo "python3 binary must be in \$PATH" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
if ! command -v pip3 >/dev/null 2>&1; then
|
||||
curl -SsL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
|
||||
python3 get-pip.py --user
|
||||
rm -f get-pip.py
|
||||
ensure_py3_bin pip3
|
||||
fi
|
||||
}
|
80
hack/windows-ova-unattend.py
Executable file
80
hack/windows-ova-unattend.py
Executable file
@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright 2021 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
import os
|
||||
import argparse
|
||||
import json
|
||||
|
||||
def set_xmlstring(root, location, key, value):
|
||||
setting = root.find(location)
|
||||
setting.find(key).text = value
|
||||
return setting
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Updates select variables in autounattend.xml")
|
||||
parser.add_argument(dest='build_dir',
|
||||
nargs='?',
|
||||
metavar='BUILD_DIR',
|
||||
default='.',
|
||||
help='The Packer build directory')
|
||||
parser.add_argument('--var-file',
|
||||
dest='var_file',
|
||||
nargs='?',
|
||||
metavar='VARIABLES_FILE',
|
||||
required=False,
|
||||
default='./packer_cache/unattend.json',
|
||||
help='The file that containers the unattend variables')
|
||||
parser.add_argument('--unattend-file',
|
||||
dest='unattend_file',
|
||||
required=False,
|
||||
nargs='?',
|
||||
metavar='UNATTEND_FILE',
|
||||
help='The Unattend file')
|
||||
args = parser.parse_args()
|
||||
|
||||
print("windows-ova-unattend: cd %s" % args.build_dir)
|
||||
|
||||
# Load the packer manifest JSON
|
||||
data = None
|
||||
with open(args.var_file, 'r') as f:
|
||||
data = json.load(f)
|
||||
|
||||
modified=0
|
||||
os.chdir(args.build_dir)
|
||||
unattend=ET.parse(args.unattend_file)
|
||||
ET.register_namespace('', "urn:schemas-microsoft-com:unattend")
|
||||
ET.register_namespace('wcm', "http://schemas.microsoft.com/WMIConfig/2002/State")
|
||||
ET.register_namespace('xsi', "http://www.w3.org/2001/XMLSchema-instance")
|
||||
|
||||
root = unattend.getroot()
|
||||
|
||||
if data["unattend_timezone"] != "":
|
||||
modified=1
|
||||
setting = set_xmlstring(root, ".//*[@pass='oobeSystem']/*[@name='Microsoft-Windows-Shell-Setup']",'{urn:schemas-microsoft-com:unattend}TimeZone', data["unattend_timezone"])
|
||||
print("windows-ova-unattend: Setting Timezone to %s" % data["unattend_timezone"])
|
||||
|
||||
if modified == 1:
|
||||
print("windows-ova-unattend: Updating %s ..." % args.unattend_file)
|
||||
unattend.write(args.unattend_file)
|
||||
|
||||
if modified == 0:
|
||||
print("windows-ova-unattend: skipping...")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user