Skip to content

Commit

Permalink
Add Vagrant files and scripts for HW installation (#150)
Browse files Browse the repository at this point in the history
* Add vagrantfile

* Change setup.sh file permission

* Fix setup.sh

* Add sudo command in setup.sh

* Fix vagrantfile

* create directory for each VM

* Change vagrant file name and add run.sh file

* Change vagrantfile name

* Update run_vms.sh file to run each sh

* Add vcmd shell script

* Change vcmd sh permission

* Add shell command for each Vagrantfile startup script

* bugfix - fix ric Vagrantfile ID

* Add true in inline command in Vagrantfile

* Update Vagrantfiles and infra

* Add vagrant halt and destroy scripts
  • Loading branch information
woojoong88 authored Mar 9, 2022
1 parent db4cb5c commit b7203ea
Show file tree
Hide file tree
Showing 19 changed files with 259 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mk/epc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ EPC_PHONY := omec 5gc
omec: $(M)/omec
5gc: $(M)/5gc

$(M)/omec: | version $(M)/helm-ready $(M)/fabric
$(M)/omec: | version $(M)/helm-ready $(M)/fabric-core
kubectl get namespace $(RIAB_NAMESPACE) 2> /dev/null || kubectl create namespace $(RIAB_NAMESPACE)
helm repo update
helm dep up $(AETHERCHARTDIR)/omec/omec-control-plane
Expand All @@ -29,7 +29,7 @@ $(M)/omec: | version $(M)/helm-ready $(M)/fabric
kubectl wait pod -n $(RIAB_NAMESPACE) --for=condition=Ready -l release=omec-user-plane --timeout=300s
touch $@

$(M)/5gc: | version $(M)/helm-ready $(M)/fabric
$(M)/5gc: | version $(M)/helm-ready $(M)/fabric-core
kubectl get namespace $(RIAB_NAMESPACE) 2> /dev/null || kubectl create namespace $(RIAB_NAMESPACE)
helm repo update
helm dep up $(AETHERCHARTDIR)/omec/5g-control-plane
Expand Down
17 changes: 17 additions & 0 deletions mk/infra.mk
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@ $(M)/fabric-cu-du: | $(M)/setup /opt/cni/bin/simpleovs /opt/cni/bin/static
sudo ip link set $(E2_F1_DU_INTERFACE) up
touch $@

$(M)/fabric-core: | $(M)/setup /opt/cni/bin/simpleovs /opt/cni/bin/static
sudo apt install -y openvswitch-switch
sudo ovs-vsctl --may-exist add-br br-enb-net
sudo ovs-vsctl --may-exist add-port br-enb-net enb -- set Interface enb type=internal
sudo ip addr add $(OMEC_ENB_NET_IP) dev enb || true
sudo ip link set enb up
sudo ethtool --offload enb tx off
sudo ip route replace $(ACCESS_SUBNET) via $(shell echo $(ENB_GATEWAY) | awk -F '/' '{print $$1}') dev enb
cp $(RESOURCEDIR)/router-template.yaml $(RESOURCEDIR)/router.yaml
sed -i -e "s#CORE_GATEWAY#$(CORE_GATEWAY)#" $(RESOURCEDIR)/router.yaml
sed -i -e "s#ENB_GATEWAY#$(ENB_GATEWAY)#" $(RESOURCEDIR)/router.yaml
sed -i -e "s#ACCESS_GATEWAY#$(ACCESS_GATEWAY)#" $(RESOURCEDIR)/router.yaml
kubectl apply -f $(RESOURCEDIR)/router.yaml
kubectl wait pod -n default --for=condition=Ready -l app=router --timeout=300s
kubectl -n default exec router ip route add $(UE_IP_POOL)/$(UE_IP_MASK) via $(shell echo $(UPF_CORE_NET_IP) | awk -F '/' '{print $$1}') || true
touch $@

$(M)/atomix: | $(M)/k8s-ready
helm repo update
ifeq ($(VER), v1.0.0)
Expand Down
10 changes: 10 additions & 0 deletions vagrant/destroy_omec_vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

echo Run OMEC node
pushd omec
sudo vagrant destroy
popd
10 changes: 10 additions & 0 deletions vagrant/destroy_ran_vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

echo Run RAN node
pushd ran
sudo vagrant destroy
popd
10 changes: 10 additions & 0 deletions vagrant/destroy_ric_vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

echo Run RIC node
pushd ric
sudo vagrant destroy
popd
11 changes: 11 additions & 0 deletions vagrant/destroy_vms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

./destroy_ran_vm.sh

./destroy_ric_vm.sh

./destroy_omec_vm.sh
10 changes: 10 additions & 0 deletions vagrant/halt_omec_vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

echo Run OMEC node
pushd omec
sudo vagrant halt
popd
10 changes: 10 additions & 0 deletions vagrant/halt_ran_vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

echo Run RAN node
pushd ran
sudo vagrant halt
popd
10 changes: 10 additions & 0 deletions vagrant/halt_ric_vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

echo Run RIC node
pushd ric
sudo vagrant halt
popd
11 changes: 11 additions & 0 deletions vagrant/halt_vms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

./halt_ran_vm.sh

./halt_ric_vm.sh

./halt_omec_vm.sh
28 changes: 28 additions & 0 deletions vagrant/omec/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0

Vagrant.configure(2) do |config|
config.vm.define "omec" do |omec|
omec.vm.box = "generic/ubuntu1804"
omec.vm.disk :disk, size: "30GB", primary: true
omec.vm.hostname = "omec"
omec.vm.network :public_network, :dev => "br0", :ovs => true, :mode => "bridge", :type => "bridge"
omec.vm.provider "libvirt" do |v|
v.cpus = 4
v.memory = 8192
end

omec.vm.provision "shell", inline: <<-SHELL
sudo apt update -y
sudo apt install -y software-properties-common python3-pip jq httpie ipvsadm ethtool
sudo bash -c 'echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf'
SHELL

omec.vm.provision "shell", run: 'always', inline: <<-SHELL
sudo ifconfig eth1 192.168.10.21/24 up || true
route add -net 192.168.11.0/24 dev eth1 || true
route add -net 192.168.13.0/24 dev eth1 || true
SHELL
end
end
28 changes: 28 additions & 0 deletions vagrant/ran/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0

Vagrant.configure(2) do |config|
config.vm.define "ran" do |ran|
ran.vm.box = "generic/ubuntu1804"
ran.vm.disk :disk, size: "30GB", primary: true
ran.vm.hostname = "ran"
ran.vm.network :public_network, :dev => "br0", :ovs => true, :mode => "bridge", :type => "bridge"
ran.vm.provider "libvirt" do |v|
v.cpus = 4
v.memory = 8192
end

ran.vm.provision "shell", inline: <<-SHELL
sudo apt update -y
sudo apt install -y software-properties-common python3-pip jq httpie ipvsadm ethtool
sudo bash -c 'echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf'
SHELL

ran.vm.provision "shell", run: 'always', inline: <<-SHELL
sudo ifconfig eth1 192.168.13.21/24 up || true
sudo route add -net 192.168.10.0/24 dev eth1 || true
sudo route add -net 192.168.11.0/24 dev eth1 || true
SHELL
end
end
28 changes: 28 additions & 0 deletions vagrant/ric/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0

Vagrant.configure(2) do |config|
config.vm.define "ric" do |ric|
ric.vm.box = "generic/ubuntu1804"
ric.vm.disk :disk, size: "30GB", primary: true
ric.vm.hostname = "ric"
ric.vm.network :public_network, :dev => "br0", :ovs => true, :mode => "bridge", :type => "bridge"
ric.vm.provider "libvirt" do |v|
v.cpus = 4
v.memory = 8192
end

ric.vm.provision "shell", inline: <<-SHELL
sudo apt update -y
sudo apt install -y software-properties-common python3-pip jq httpie ipvsadm ethtool
sudo bash -c 'echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf'
SHELL

ric.vm.provision "shell", run: 'always', inline: <<-SHELL
sudo ifconfig eth1 192.168.10.22/24 up || true
route add -net 192.168.11.0/24 dev eth1 || true
route add -net 192.168.13.0/24 dev eth1 || true
SHELL
end
end
10 changes: 10 additions & 0 deletions vagrant/run_omec_vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

echo Run OMEC node
pushd omec
sudo vagrant up
popd
10 changes: 10 additions & 0 deletions vagrant/run_ran_vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

echo Run RAN node
pushd ran
sudo vagrant up
popd
10 changes: 10 additions & 0 deletions vagrant/run_ric_vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

echo Run RIC node
pushd ric
sudo vagrant up
popd
11 changes: 11 additions & 0 deletions vagrant/run_vms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

./run_ran_vm.sh

./run_ric_vm.sh

./run_omec_vm.sh
24 changes: 24 additions & 0 deletions vagrant/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

echo Install VM hypervisor and OpenVSwitch
sudo apt update
sudo apt install qemu libvirt-daemon-system libvirt-clients libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev ruby-libvirt ebtables dnsmasq-base qemu-kvm libvirt-bin bridge-utils virt-manager openvswitch-switch -y

echo Install Vagrant
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install vagrant -y

echo Add Vagrant plugins
vagrant plugin install vagrant-libvirt
vagrant plugin install vagrant-mutate

echo Add OVS
sudo ovs-vsctl --may-exist add-br br0
sudo ovs-vsctl show

./run_vms.sh
9 changes: 9 additions & 0 deletions vagrant/vcmd_ric.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# Copyright 2022-present Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0

pushd $1
sudo vagrant $2
popd

0 comments on commit b7203ea

Please sign in to comment.