COMAC-8 initial version of comac-in-a-box makefile
This makefile installs OMEC and OAI eNB and UE in a single node.
It does not require any special hardwares.
Run "make" -> "make run-test" for test.
CORD platform support will be added later.
Change-Id: I9f27219522c85dcd95c50a23a9bab5f32f7484b1
diff --git a/comac-in-a-box/Makefile b/comac-in-a-box/Makefile
new file mode 100644
index 0000000..7eca5ee
--- /dev/null
+++ b/comac-in-a-box/Makefile
@@ -0,0 +1,189 @@
+SHELL := /bin/bash
+BUILD ?= /tmp/build
+M ?= $(BUILD)/milestones
+MAKEDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+SCRIPTDIR := $(MAKEDIR)../scripts
+RESOURCEDIR := $(MAKEDIR)/resources
+WORKSPACE ?= $(HOME)
+VENV ?= $(BUILD)/venv/ciab
+CIABVALUES ?= $(MAKEDIR)/comac-in-a-box-values.yaml
+
+KUBESPRAY_VERSION ?= release-2.10
+DOCKER_VERSION ?= 18.06
+K8S_VERSION ?= v1.14.3
+HELM_VERSION ?= v2.13.1
+
+# used to start logging/monitoring and other infrastructure charts
+INFRA_CHARTS ?=
+INFRA_PREREQS = $(foreach chart,$(INFRA_CHARTS),$(M)/$(chart))
+
+KAFKA_CHART_VERSION ?= 0.13.3
+KAFKA_POD := "pod/cord-kafka-0"
+
+ETCD_OPERATOR_VERSION ?= 0.8.3
+
+HELM_GLOBAL_ARGS ?=
+HELM_NEM_ARGS ?= $(HELM_GLOBAL_ARGS)
+HELM_ONOS_ARGS ?= $(HELM_GLOBAL_ARGS)
+
+cpu_family := $(shell lscpu | grep 'CPU family:' | awk '{print $$3}')
+cpu_model := $(shell lscpu | grep 'Model:' | awk '{print $$2}')
+os_vendor := $(shell lsb_release -i -s)
+os_distro := $(shell lsb_release -c -s)
+
+# TODO: include CORD platform
+ciab: $(M)/system_check $(M)/omec $(M)/oaisim
+
+.PHONY: ciab run-test reset-test clean
+
+$(M):
+ mkdir -p $(M)
+
+$(M)/system_check: | $(M)
+ @if [[ $(cpu_family) -eq 6 ]]; then \
+ if [[ $(cpu_model) -lt 60 ]]; then \
+ echo "FATAL: haswell CPU or newer is required."; \
+ exit 1; \
+ fi \
+ else \
+ echo "FATAL: unsupported CPU family."; \
+ exit 1; \
+ fi
+ @if [[ $(os_vendor) =~ (Ubuntu) ]]; then \
+ if [[ ! $(os_distro) =~ (xenial) ]]; then \
+ echo "WARN: $(os_vendor) $(os_distro) has not been tested."; \
+ fi \
+ else \
+ echo "FAIL: unsupported OS."; \
+ exit 1; \
+ fi
+ touch $@
+
+$(M)/setup: | $(M)
+ sudo $(SCRIPTDIR)/cloudlab-disksetup.sh
+ sudo apt update; sudo apt install -y software-properties-common python-pip jq httpie ipvsadm
+ touch $@
+
+$(BUILD)/kubespray: | $(M)/setup
+ mkdir -p $(BUILD)
+ cd $(BUILD); git clone https://github.com/kubernetes-incubator/kubespray.git -b $(KUBESPRAY_VERSION)
+
+$(VENV)/bin/activate: | $(M)/setup
+ sudo pip install virtualenv
+ virtualenv $(VENV) --no-site-packages
+
+$(M)/kubespray-requirements: $(BUILD)/kubespray | $(VENV)/bin/activate
+ source "$(VENV)/bin/activate" && \
+ pip install -r $(BUILD)/kubespray/requirements.txt
+ touch $@
+
+$(M)/k8s-ready: | $(M)/setup $(BUILD)/kubespray $(VENV)/bin/activate $(M)/kubespray-requirements
+ source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
+ ansible-playbook -b -i inventory/local/hosts.ini \
+ -e "{'override_system_hostname' : False, 'disable_swap' : True}" \
+ -e "{'docker_version' : $(DOCKER_VERSION)}" \
+ -e "{'docker_iptables_enabled' : True}" \
+ -e "{'kube_version' : $(K8S_VERSION)}" \
+ -e "{'kube_network_plugin_multus' : True}" \
+ -e "{'kube_proxy_mode': iptables}" \
+ -e "{'kube_pods_subnet' : 192.168.0.0/17, 'kube_service_addresses' : 192.168.128.0/17}" \
+ -e "{'kube_apiserver_node_port_range' : 2000-36767}" \
+ -e "{'kubeadm_enabled': True}" \
+ -e "{'kube_feature_gates' : [SCTPSupport=True]}" \
+ -e "{'kubelet_custom_flags' : [--allowed-unsafe-sysctls=net.*]}" \
+ -e "{'dns_min_replicas' : 1}" \
+ -e "{'helm_enabled' : True, 'helm_version' : $(HELM_VERSION)}" \
+ cluster.yml
+ mkdir -p $(HOME)/.kube
+ sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
+ sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
+ kubectl wait pod -n kube-system --for=condition=Ready --all
+ touch $@
+
+$(M)/helm-ready: | $(M)/k8s-ready
+ helm init --wait --client-only
+ helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
+ helm repo add cord https://charts.opencord.org
+ touch $@
+
+$(WORKSPACE)/cord/helm-charts: | $(M)/setup
+ mkdir -p $(WORKSPACE)/cord
+ cd $(WORKSPACE)/cord; git clone https://gerrit.opencord.org/helm-charts
+
+# TODO: need to connect ONOS
+$(M)/ovs-setup: | $(M)/setup
+ sudo apt install -y openvswitch-switch
+ sudo ovs-vsctl --may-exist add-br br-s1u-net
+ sudo ovs-vsctl --may-exist add-port br-s1u-net s1u-enb -- set Interface s1u-enb type=internal
+ sudo ip link set s1u-enb address 0a:00:00:00:00:01
+ sudo ip addr add 119.0.0.253/24 dev s1u-enb || true
+ sudo ip link set s1u-enb up
+ touch $@
+
+/opt/cni/bin/simpleovs: | $(M)/k8s-ready
+ sudo cp $(RESOURCEDIR)/simpleovs /opt/cni/bin/
+
+$(M)/omec: | $(M)/ovs-setup $(M)/helm-ready $(WORKSPACE)/cord/helm-charts /opt/cni/bin/simpleovs
+ cd $(WORKSPACE)/cord/helm-charts/mcord-release; \
+ helm upgrade --install $(HELM_GLOBAL_ARGS) mcord-services mcord-services -f $(CIABVALUES)
+ $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh default
+ touch $@
+
+# UE images includes kernel module, ue_ip.ko
+# which should be built in the exactly same kernel version of the host machine
+$(BUILD)/openairinterface: | $(M)/setup
+ mkdir -p $(BUILD)
+ cd $(BUILD); git clone https://github.com/opencord/openairinterface.git
+
+$(M)/ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
+ cd $(BUILD)/openairinterface; \
+ sudo docker build . --target lte-uesoftmodem \
+ --build-arg build_base=omecproject/oai-base:1.0.0 \
+ --file Dockerfile.ue \
+ --tag omecproject/lte-uesoftmodem:1.0.0
+ touch $@
+
+$(M)/oaisim: | $(M)/omec $(M)/ue-image
+ sudo ip addr add 127.0.0.2/8 dev lo || true
+ $(eval mme_iface=$(shell ip -4 route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }'))
+ cd $(WORKSPACE)/cord/helm-charts; \
+ helm upgrade --install $(HELM_GLOBAL_ARGS) oaisim oaisim -f $(CIABVALUES) \
+ --set conf.enb.networks.s1_mme.interface=$(mme_iface)
+ $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh default
+ @timeout 60s bash -c \
+ "until ip addr show oip1 | grep -q inet; \
+ do \
+ echo 'Waiting for UE 1 gets IP address'; \
+ sleep 3; \
+ done"
+ touch $@
+
+$(M)/router: | /opt/cni/bin/simpleovs $(M)/ovs-setup
+ kubectl apply -f $(RESOURCEDIR)/quagga.yaml
+ kubectl wait pod --for=condition=Ready -l app=quagga
+ $(eval spgwu_ip=$(shell kubectl get pod -ojson spgwu-0 2>/dev/null | \
+ jq -r '.metadata.annotations["k8s.v1.cni.cncf.io/networks-status"]' | \
+ jq -r '.[] | select(.name=="sgi-net") | .ips[0]'))
+ kubectl exec router ip route add 16.0.0.0/8 via $(spgwu_ip)
+ touch $@
+
+run-test: | $(M)/router
+ ping -I oip1 13.1.1.254 -c 5
+
+reset-test:
+ -kubectl delete po router
+ -helm delete --purge oaisim mcord-services
+ cd $(M); rm -f router oaisim omec
+
+clean: reset-test
+ helm delete --purge $(shell helm ls -q) || true
+ sudo ovs-vsctl del-br br-s1u-net || true
+ sudo ovs-vsctl del-br br-sgi-net || true
+ sudo apt remove --purge openvswitch-switch -y
+ source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
+ ansible-playbook -b -i inventory/local/hosts.ini reset.yml
+ @if [ -d /usr/local/etc/emulab ]; then \
+ mount | grep /mnt/extra/kubelet/pods | cut -d" " -f3 | sudo xargs umount; \
+ sudo rm -rf /mnt/extra/kubelet; \
+ fi
+ rm -rf $(M)
diff --git a/comac-in-a-box/comac-in-a-box-values.yaml b/comac-in-a-box/comac-in-a-box-values.yaml
new file mode 100644
index 0000000..df30271
--- /dev/null
+++ b/comac-in-a-box/comac-in-a-box-values.yaml
@@ -0,0 +1,77 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# 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.
+
+---
+# etcd-cluster
+etcdNodePort: 32379
+clusterSize: 1
+
+# mcord-services values
+hssdb:
+ cpu: 1
+hss:
+ cpu: 0.5
+spgwc:
+ image: omecproject/ngic-cp:0.1.0-debug
+ cpu: 0.5
+spgwu:
+ images:
+ tags:
+ spgwu: omecproject/ngic-dp:0.1.0-debug
+ resources:
+ cpu: 1
+ conf:
+ dp:
+ devices: "--no-pci --vdev eth_af_packet0,iface=s1u-net --vdev eth_af_packet1,iface=sgi-net"
+mme:
+ type: openmme
+ resources:
+ cpu: 0.5
+network:
+ sriov:
+ enabled: false
+ s1u:
+ cni_plugin: simpleovs
+ ipam: host-local
+ static_arp:
+ - ip: 119.0.0.253
+ mac: 0a:00:00:00:00:01
+ sgi:
+ cni_plugin: simpleovs
+ ipam: host-local
+ static_arp:
+ - ip: 13.1.1.254
+ mac: 0e:00:00:00:00:01
+
+# oaisim values
+conf:
+ plmn:
+ name: "COMAC Test Network"
+ short_name: "COMAC"
+ mcc: "208"
+ mnc: "01"
+ enb:
+ mme:
+ address: 127.0.0.1
+ networks:
+ s1u:
+ interface: s1u-enb
+ ue:
+ # 1 UE is supported for now
+ name: ue
+ sim:
+ msin: "4567891201"
+ api_key: "465b5ce8b199b49faa5f0a2ee238a6bc"
+ opc: "d4416644f6154936193433dd20a0ace0"
+ msisdn: "1122334456"
diff --git a/comac-in-a-box/resources/quagga.yaml b/comac-in-a-box/resources/quagga.yaml
new file mode 100644
index 0000000..63f87f5
--- /dev/null
+++ b/comac-in-a-box/resources/quagga.yaml
@@ -0,0 +1,43 @@
+#!/bin/bash -x
+#
+# Copyright 2019-present Open Networking Foundation
+#
+# 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.
+---
+apiVersion: v1
+kind: Pod
+metadata:
+ name: router
+ labels:
+ app: quagga
+ annotations:
+ k8s.v1.cni.cncf.io/networks: '[
+ { "name": "sgi-net", "interface": "sgi-rtr", "interfaceRequest": "sgi-rtr" }
+ ]'
+spec:
+ containers:
+ - name: quagga
+ command: ["/bin/bash", "-c"]
+ args:
+ - >
+ ip addr flush sgi-rtr;
+ ip link set sgi-rtr address 0e:00:00:00:00:01;
+ ip addr add 13.1.1.254/24 dev sgi-rtr;
+ trap : TERM INT; sleep infinity & wait
+ image: opencord/quagga
+ securityContext:
+ capabilities:
+ add:
+ - NET_ADMIN
+ ports:
+ - containerPort: 2601
diff --git a/comac-in-a-box/resources/simpleovs b/comac-in-a-box/resources/simpleovs
new file mode 100755
index 0000000..f43b8a1
--- /dev/null
+++ b/comac-in-a-box/resources/simpleovs
@@ -0,0 +1,77 @@
+#!/bin/bash -x
+#
+# Copyright 2019-present Open Networking Foundation
+#
+# 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 pipefail
+set -o nounset
+
+exec 3>&1
+exec &>>/var/log/simple-ovs-cni.log
+
+PATH="$CNI_PATH:$(dirname "${BASH_SOURCE[0]}"):$PATH"
+CNI_CONF=$(cat /dev/stdin)
+
+get_bridge() {
+ echo "br-$(echo $CNI_CONF | jq -r '.name')"
+}
+
+ipam() {
+ local plugin=$(echo $CNI_CONF | jq -r '.ipam.type')
+ local res=$(echo $"$CNI_CONF" | "$plugin" | jq -c '.')
+ echo $res
+}
+
+add_br_and_port() {
+ mkdir -p /var/run/netns/
+ ln -sfT $CNI_NETNS /var/run/netns/$CNI_CONTAINERID
+
+ local bridge=$(get_bridge)
+ local ip=$1
+
+ ovs-vsctl --may-exist add-br $bridge
+ ovs-vsctl add-port $bridge $CNI_IFNAME -- set Interface $CNI_IFNAME type=internal
+
+ ip link set $CNI_IFNAME netns $CNI_CONTAINERID
+ ip netns exec $CNI_CONTAINERID ip addr add $ip dev $CNI_IFNAME
+ ip netns exec $CNI_CONTAINERID ip link set $CNI_IFNAME up
+}
+
+delete_br_and_port() {
+ local bridge="br-$(echo $CNI_CONF | jq -r '.name')"
+ ovs-vsctl del-port $CNI_IFNAME
+ if [ -z "$(ovs-vsctl list-ports $bridge)" ]; then
+ ovs-vsctl del-br $bridge
+ fi
+}
+
+case $CNI_COMMAND in
+ADD)
+ res=$(ipam)
+ ip=$(echo $res | jq -r '.ip4.ip')
+ add_br_and_port $ip
+ echo '{"cniVersion":"0.2.0"}' | jq -c --arg ip $ip '.ip4.ip = $ip' >&3
+ ;;
+DEL)
+ set +o errexit
+ ipam
+ delete_br_and_port
+ set -o errexit
+ ;;
+*)
+ echo "CNI_COMMAND=[ADD|DEL] only supported"
+ exit 1
+ ;;
+esac
diff --git a/openstack-helm/openstack-helm-dev-setup.sh b/openstack-helm/openstack-helm-dev-setup.sh
index cb383bf..fdb66b5 100755
--- a/openstack-helm/openstack-helm-dev-setup.sh
+++ b/openstack-helm/openstack-helm-dev-setup.sh
@@ -37,7 +37,7 @@
if [ -d /usr/local/etc/emulab ]
then
sudo delgroup docker || true
- "$DIR"/cloudlab-disk-setup.sh
+ "$DIR"/../scripts/cloudlab-disksetup.sh
fi
if [ ! -e ~/openstack-helm-infra ]
diff --git a/openstack-helm/cloudlab-disk-setup.sh b/scripts/cloudlab-disksetup.sh
similarity index 100%
rename from openstack-helm/cloudlab-disk-setup.sh
rename to scripts/cloudlab-disksetup.sh
diff --git a/scripts/omec-nodesetup.sh b/scripts/omec-nodesetup.sh
new file mode 100755
index 0000000..e84bbb4
--- /dev/null
+++ b/scripts/omec-nodesetup.sh
@@ -0,0 +1,168 @@
+#!/bin/bash
+
+# Copyright 2019-present Open Networking Foundation
+#
+# 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.
+
+SRIOV_PF=${1:?"Specify SR-IOV interface name as argv[1]"}
+NR_HUGEPAGE=32
+
+if [ "$(id -u)" != "0" ]; then
+ echo "FAIL: You should run this as root."
+ echo "HINT: sudo $0 $SRIOV_PF"
+ exit 1
+fi
+
+grub_updated=0
+function update_grub_cmdline {
+ local param=$1
+ IFS='=' read -r key value <<< "$param"
+ if ! grep -q "$key"= /etc/default/grub; then
+ sed -i "s/^GRUB_CMDLINE_LINUX=\"/&${param} /" /etc/default/grub
+ else
+ sed -i "s/\\(${key}=\\)\\w*/\\1${value}/g" /etc/default/grub
+ fi
+ echo " Added \"${param}\" is to kernel parameters"
+ grub_updated=1
+}
+
+function check_vf {
+ local pfpci
+ local num_vfs
+
+ pfpci=$(readlink /sys/devices/pci*/*/*/net/"$SRIOV_PF"/device | awk '{print substr($1,10)}')
+ num_vfs=$(cat /sys/class/net/"$SRIOV_PF"/device/sriov_numvfs)
+ if [ "$num_vfs" = "0" ]; then
+ echo "FAIL: SR-IOV VFs are not created"
+ return 1
+ fi
+
+ local vfpci
+ local driver
+ for ((idx = 0; idx < num_vfs; idx++)); do
+ local vfn="virtfn$idx"
+ # shellcheck disable=SC2012
+ vfpci=$(ls -l /sys/devices/pci*/*/"$pfpci" | awk -v vfn=$vfn 'vfn==$9 {print substr($11,4)}')
+ driver=$(lspci -vvv -s "$vfpci" | grep "Kernel driver in use" | awk '{print $5}')
+ if [ "$driver" != "vfio-pci" ]; then
+ echo "FAIL: SR-IOV VF $idx does not exist or bind to vfio-pci"
+ return 1
+ fi
+ done
+ return 0
+}
+
+# Check hardware virtualization is enabled
+# --------------------------
+virt=$(grep -E -m1 -w '^flags[[:blank:]]*:' /proc/cpuinfo | grep -E -wo '(vmx|svm)') || true
+if [ -z "$virt" ]; then
+ echo "FATAL: Your CPU does not support hardware virtualization."
+ exit 1
+fi
+
+msr="/dev/cpu/0/msr"
+if [ ! -r "$msr" ]; then
+ modprobe msr
+fi
+
+disabled=0
+if [ "$virt" = "vmx" ]; then
+ BIT=$(rdmsr --bitfield 0:0 0x3a 2>/dev/null || true)
+ if [ "$BIT" = "1" ]; then
+ BIT=$(rdmsr --bitfield 2:2 0x3a 2>/dev/null || true)
+ if [ "$BIT" = "0" ]; then
+ disabled=1
+ fi
+ fi
+elif [ "$virt" = "svm" ]; then
+ BIT=$(rdmsr --bitfield 4:4 0xc0010114 2>/dev/null || true)
+ if [ "$BIT" = "1" ]; then
+ disabled=1
+ fi
+else
+ echo "FATAL: Unknown virtualization extension: $virt."
+ exit 1
+fi
+
+if [ "$disabled" -eq 1 ]; then
+ echo "FAIL: $virt is disabled by BIOS"
+ echo "HINT: Enter your BIOS setup and enable Virtualization Technology (VT),"
+ echo " and then hard poweroff/poweron your system"
+else
+ echo " OK: $virt is enabled"
+fi
+
+# Ensure IOMMU is enabled
+# --------------------------
+if ! compgen -G "/sys/class/iommu/*/devices" > /dev/null; then
+ disabled=1
+ echo "FAIL: IOMMU is disabled"
+ update_grub_cmdline "intel_iommu=on"
+else
+ echo " OK: IOMMU is enabled"
+fi
+
+# Ensure hugepage is enabled
+# --------------------------
+hugepage=$(grep -i HugePages_Total /proc/meminfo | awk '{print $2}') || true
+if [ "$hugepage" -eq "0" ]; then
+ disabled=1
+ echo "FAIL: Hugepage is disabled"
+
+ update_grub_cmdline "hugepages=$NR_HUGEPAGE"
+ update_grub_cmdline "default_hugepagesz=1G"
+ if ! grep -q "^vm.nr_hugepages" /etc/sysctl.conf; then
+ echo "vm.nr_hugepages=$NR_HUGEPAGE" >> /etc/sysctl.conf
+ fi
+else
+ echo " OK: Hugepage is enabled"
+fi
+
+# Ensure SR-IOV is enabled
+# --------------------------
+if ! lsmod | grep -q vfio-pci; then
+ echo 'vfio-pci' | tee /etc/modules-load.d/sriov.conf 1> /dev/null
+ systemctl restart systemd-modules-load.service
+fi
+
+if ! check_vf; then
+ cp "$(cd "$(dirname "$0")" && pwd)/sriov.sh" /usr/bin/sriov.sh
+ tee "/etc/systemd/system/sriov.service" > /dev/null << EOF
+[Unit]
+Description=Create VFs on $SRIOV_PF
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/sriov.sh -b $SRIOV_PF
+
+[Install]
+WantedBy=default.target
+EOF
+ systemctl daemon-reload
+ systemctl enable --now sriov.service &> /dev/null
+ echo " Configured VFs on $SRIOV_PF"
+fi
+
+if check_vf; then
+ echo " OK: SR-IOV is enabled on $SRIOV_PF"
+else
+ disabled=1
+fi
+
+if [ "$grub_updated" -eq 1 ]; then
+ update-grub &> /dev/null
+ echo "HINT: Grub was updated, reboot for changes to take effect"
+ exit 1
+fi
+
+exit $disabled
diff --git a/scripts/sriov.sh b/scripts/sriov.sh
new file mode 100755
index 0000000..a478541
--- /dev/null
+++ b/scripts/sriov.sh
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+# Copyright (c) 2019 Intel Corporation
+#
+# 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.
+
+# copied from https://github.com/clearlinux/cloud-native-setup/blob/master/clr-k8s-examples/9-multi-network/systemd/sriov.sh
+
+set -o errexit
+set -o pipefail
+set -o nounset
+set -x
+
+OPTIND=1
+bind="false"
+
+while getopts ":b" opt; do
+ case ${opt} in
+ b)
+ bind="true"
+ ;;
+ \?)
+ echo "Usage: sriov.sh [-b] ens785f0 ens785f1 ..."
+ echo "-b Bind to vfio-pci"
+ exit
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+setup_pf() {
+ local pf=$1
+ local num_vfs
+
+ echo "Resetting PF $pf"
+ echo 0 | tee /sys/class/net/"$pf"/device/sriov_numvfs
+ num_vfs=$(cat /sys/class/net/"$pf"/device/sriov_totalvfs)
+ echo "Enabling $num_vfs VFs for $pf"
+ echo "$num_vfs" | tee /sys/class/net/"$pf"/device/sriov_numvfs
+ ip link set "$pf" up
+ sleep 1
+}
+
+vfio_bind() {
+ local pf=$1
+ local pfpci
+ local num_vfs
+
+ pfpci=$(readlink /sys/devices/pci*/*/*/net/"$pf"/device | awk '{print substr($1,10)}')
+ num_vfs=$(cat /sys/class/net/"$pf"/device/sriov_numvfs)
+
+ local vfpci
+ local mac
+ for ((idx = 0; idx < num_vfs; idx++)); do
+ #Some drivers does not support state change of VF
+ #ip link set dev $pf vf $idx state enable
+
+ local vfn="virtfn$idx"
+ # shellcheck disable=SC2012
+ vfpci=$(ls -l /sys/devices/pci*/*/"$pfpci" | awk -v vfn=$vfn 'vfn==$9 {print substr($11,4)}')
+ # Capture and set MAC of the VF before unbinding from linux, for later use in CNI
+ mac=$(cat /sys/bus/pci*/*/"$vfpci"/net/*/address)
+ ip link set dev "$pf" vf $idx mac "$mac"
+ # Bind VF to vfio-pci
+ echo "$vfpci" >/sys/bus/pci*/*/"$vfpci"/driver/unbind
+ echo "vfio-pci" >/sys/devices/pci*/*/"$vfpci"/driver_override
+ echo "$vfpci" >/sys/bus/pci/drivers/vfio-pci/bind
+ done
+}
+
+for pf in "$@"; do
+ setup_pf "$pf"
+ if [ $bind ]; then vfio_bind "$pf"; fi
+done
diff --git a/seba-in-a-box/Makefile b/seba-in-a-box/Makefile
index 8965f3d..df46c07 100644
--- a/seba-in-a-box/Makefile
+++ b/seba-in-a-box/Makefile
@@ -84,7 +84,7 @@
sudo apt update
sudo apt install -y httpie jq software-properties-common
sudo swapoff -a
- if [ -d /usr/local/etc/emulab ]; then $(MAKEDIR)/../openstack-helm/cloudlab-disk-setup.sh; fi
+ if [ -d /usr/local/etc/emulab ]; then $(MAKEDIR)/../scripts/cloudlab-disksetup.sh; fi
touch $@
/usr/bin/docker: | $(M)/setup