summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/opnfv-apex-common.spec2
-rwxr-xr-xci/deploy.sh143
-rwxr-xr-xlib/virtual-setup-functions.sh151
3 files changed, 154 insertions, 142 deletions
diff --git a/build/opnfv-apex-common.spec b/build/opnfv-apex-common.spec
index d6599c89..87f7e244 100644
--- a/build/opnfv-apex-common.spec
+++ b/build/opnfv-apex-common.spec
@@ -54,6 +54,7 @@ mkdir -p %{buildroot}%{_var}/opt/opnfv/lib/python/apex
install lib/common-functions.sh %{buildroot}%{_var}/opt/opnfv/lib/
install lib/configure-deps-functions.sh %{buildroot}%{_var}/opt/opnfv/lib/
install lib/parse-functions.sh %{buildroot}%{_var}/opt/opnfv/lib/
+install lib/virtual-setup-functions.sh %{buildroot}%{_var}/opt/opnfv/lib/
install lib/utility-functions.sh %{buildroot}%{_var}/opt/opnfv/lib/
install lib/python/apex_python_utils.py %{buildroot}%{_var}/opt/opnfv/lib/python/
mkdir -p %{buildroot}%{python3_sitelib}/apex/
@@ -88,6 +89,7 @@ install config/inventory/pod_example_settings.yaml %{buildroot}%{_docdir}/opnfv/
%{_var}/opt/opnfv/lib/common-functions.sh
%{_var}/opt/opnfv/lib/configure-deps-functions.sh
%{_var}/opt/opnfv/lib/parse-functions.sh
+%{_var}/opt/opnfv/lib/virtual-setup-functions.sh
%{_var}/opt/opnfv/lib/utility-functions.sh
%{_var}/opt/opnfv/lib/python/
%{python3_sitelib}/apex/
diff --git a/ci/deploy.sh b/ci/deploy.sh
index d996b92a..6256039c 100755
--- a/ci/deploy.sh
+++ b/ci/deploy.sh
@@ -60,6 +60,7 @@ lib_files=(
$LIB/common-functions.sh
$LIB/configure-deps-functions.sh
$LIB/parse-functions.sh
+$LIB/virtual-setup-functions.sh
$LIB/utility-functions.sh
$LIB/installer/onos/onos_gw_mac_update.sh
)
@@ -206,148 +207,6 @@ function setup_undercloud_vm {
ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "restorecon -r /home/stack"
}
-##Create virtual nodes in virsh
-##params: vcpus, ramsize
-function setup_virtual_baremetal {
- local vcpus ramsize
- if [ -z "$1" ]; then
- vcpus=4
- ramsize=8192
- elif [ -z "$2" ]; then
- vcpus=$1
- ramsize=8192
- else
- vcpus=$1
- ramsize=$(($2*1024))
- fi
- #start by generating the opening json for instackenv.json
- cat > $CONFIG/instackenv-virt.json << EOF
-{
- "nodes": [
-EOF
-
- # next create the virtual machines and add their definitions to the file
- if [ "$ha_enabled" == "False" ]; then
- # 1 controller + computes
- # zero based so just pass compute count
- vm_index=$VM_COMPUTES
- else
- # 3 controller + computes
- # zero based so add 2 to compute count
- vm_index=$((2+$VM_COMPUTES))
- fi
-
- for i in $(seq 0 $vm_index); do
- if ! virsh list --all | grep baremetal${i} > /dev/null; then
- define_vm baremetal${i} network 41 'admin_network' $vcpus $ramsize
- for n in private_network public_network storage_network api_network; do
- if [[ $enabled_network_list =~ $n ]]; then
- echo -n "$n "
- virsh attach-interface --domain baremetal${i} --type network --source $n --model virtio --config
- fi
- done
- else
- echo "Found Baremetal ${i} VM, using existing VM"
- fi
- #virsh vol-list default | grep baremetal${i} 2>&1> /dev/null || virsh vol-create-as default baremetal${i}.qcow2 41G --format qcow2
- mac=$(virsh domiflist baremetal${i} | grep admin_network | awk '{ print $5 }')
-
- if [ "$VM_COMPUTES" -gt 0 ]; then
- capability="profile:compute"
- VM_COMPUTES=$((VM_COMPUTES - 1))
- else
- capability="profile:control"
- fi
-
- cat >> $CONFIG/instackenv-virt.json << EOF
- {
- "pm_addr": "192.168.122.1",
- "pm_user": "root",
- "pm_password": "INSERT_STACK_USER_PRIV_KEY",
- "pm_type": "pxe_ssh",
- "mac": [
- "$mac"
- ],
- "cpu": "$vcpus",
- "memory": "$ramsize",
- "disk": "41",
- "arch": "x86_64",
- "capabilities": "$capability"
- },
-EOF
- done
-
- #truncate the last line to remove the comma behind the bracket
- tail -n 1 $CONFIG/instackenv-virt.json | wc -c | xargs -I {} truncate $CONFIG/instackenv-virt.json -s -{}
-
- #finally reclose the bracket and close the instackenv.json file
- cat >> $CONFIG/instackenv-virt.json << EOF
- }
- ],
- "arch": "x86_64",
- "host-ip": "192.168.122.1",
- "power_manager": "nova.virt.baremetal.virtual_power_driver.VirtualPowerManager",
- "seed-ip": "",
- "ssh-key": "INSERT_STACK_USER_PRIV_KEY",
- "ssh-user": "root"
-}
-EOF
- #Overwrite the tripleo-inclubator domain.xml with our own, keeping a backup.
- if [ ! -f /usr/share/tripleo/templates/domain.xml.bak ]; then
- /usr/bin/mv -f /usr/share/tripleo/templates/domain.xml /usr/share/tripleo/templates/domain.xml.bak
- fi
-
- /usr/bin/cp -f $LIB/installer/domain.xml /usr/share/tripleo/templates/domain.xml
-}
-
-##Create virtual nodes in virsh
-##params: name - String: libvirt name for VM
-## bootdev - String: boot device for the VM
-## disksize - Number: size of the disk in GB
-## ovs_bridges: - List: list of ovs bridges
-## vcpus - Number of VCPUs to use (defaults to 4)
-## ramsize - Size of RAM for VM in MB (defaults to 8192)
-function define_vm () {
- local vcpus ramsize
-
- if [ -z "$5" ]; then
- vcpus=4
- ramsize=8388608
- elif [ -z "$6" ]; then
- vcpus=$5
- ramsize=8388608
- else
- vcpus=$5
- ramsize=$(($6*1024))
- fi
-
- # Create the libvirt storage volume
- if virsh vol-list default | grep ${1}.qcow2 2>&1> /dev/null; then
- volume_path=$(virsh vol-path --pool default ${1}.qcow2 || echo "/var/lib/libvirt/images/${1}.qcow2")
- echo "Volume ${1} exists. Deleting Existing Volume $volume_path"
- virsh vol-dumpxml ${1}.qcow2 --pool default > /dev/null || echo '' #ok for this to fail
- touch $volume_path
- virsh vol-delete ${1}.qcow2 --pool default
- fi
- virsh vol-create-as default ${1}.qcow2 ${3}G --format qcow2
- volume_path=$(virsh vol-path --pool default ${1}.qcow2)
- if [ ! -f $volume_path ]; then
- echo "$volume_path Not created successfully... Aborting"
- exit 1
- fi
-
- # create the VM
- /usr/libexec/openstack-tripleo/configure-vm --name $1 \
- --bootdev $2 \
- --image "$volume_path" \
- --diskbus sata \
- --arch x86_64 \
- --cpus $vcpus \
- --memory $ramsize \
- --libvirt-nic-driver virtio \
- --baremetal-interface $4
-}
-
##Copy over the glance images and instackenv json file
##params: none
function configure_undercloud {
diff --git a/lib/virtual-setup-functions.sh b/lib/virtual-setup-functions.sh
new file mode 100755
index 00000000..e7410da7
--- /dev/null
+++ b/lib/virtual-setup-functions.sh
@@ -0,0 +1,151 @@
+#!/usr/bin/env bash
+##############################################################################
+# Copyright (c) 2015 Tim Rozet (Red Hat), Dan Radez (Red Hat) and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+##Create virtual nodes in virsh
+##params: vcpus, ramsize
+function setup_virtual_baremetal {
+ local vcpus ramsize
+ if [ -z "$1" ]; then
+ vcpus=4
+ ramsize=8192
+ elif [ -z "$2" ]; then
+ vcpus=$1
+ ramsize=8192
+ else
+ vcpus=$1
+ ramsize=$(($2*1024))
+ fi
+ #start by generating the opening json for instackenv.json
+ cat > $CONFIG/instackenv-virt.json << EOF
+{
+ "nodes": [
+EOF
+
+ # next create the virtual machines and add their definitions to the file
+ if [ "$ha_enabled" == "False" ]; then
+ # 1 controller + computes
+ # zero based so just pass compute count
+ vm_index=$VM_COMPUTES
+ else
+ # 3 controller + computes
+ # zero based so add 2 to compute count
+ vm_index=$((2+$VM_COMPUTES))
+ fi
+
+ for i in $(seq 0 $vm_index); do
+ if ! virsh list --all | grep baremetal${i} > /dev/null; then
+ define_vm baremetal${i} network 41 'admin_network' $vcpus $ramsize
+ for n in private_network public_network storage_network api_network; do
+ if [[ $enabled_network_list =~ $n ]]; then
+ echo -n "$n "
+ virsh attach-interface --domain baremetal${i} --type network --source $n --model virtio --config
+ fi
+ done
+ else
+ echo "Found Baremetal ${i} VM, using existing VM"
+ fi
+ #virsh vol-list default | grep baremetal${i} 2>&1> /dev/null || virsh vol-create-as default baremetal${i}.qcow2 41G --format qcow2
+ mac=$(virsh domiflist baremetal${i} | grep admin_network | awk '{ print $5 }')
+
+ if [ "$VM_COMPUTES" -gt 0 ]; then
+ capability="profile:compute"
+ VM_COMPUTES=$((VM_COMPUTES - 1))
+ else
+ capability="profile:control"
+ fi
+
+ cat >> $CONFIG/instackenv-virt.json << EOF
+ {
+ "pm_addr": "192.168.122.1",
+ "pm_user": "root",
+ "pm_password": "INSERT_STACK_USER_PRIV_KEY",
+ "pm_type": "pxe_ssh",
+ "mac": [
+ "$mac"
+ ],
+ "cpu": "$vcpus",
+ "memory": "$ramsize",
+ "disk": "41",
+ "arch": "x86_64",
+ "capabilities": "$capability"
+ },
+EOF
+ done
+
+ #truncate the last line to remove the comma behind the bracket
+ tail -n 1 $CONFIG/instackenv-virt.json | wc -c | xargs -I {} truncate $CONFIG/instackenv-virt.json -s -{}
+
+ #finally reclose the bracket and close the instackenv.json file
+ cat >> $CONFIG/instackenv-virt.json << EOF
+ }
+ ],
+ "arch": "x86_64",
+ "host-ip": "192.168.122.1",
+ "power_manager": "nova.virt.baremetal.virtual_power_driver.VirtualPowerManager",
+ "seed-ip": "",
+ "ssh-key": "INSERT_STACK_USER_PRIV_KEY",
+ "ssh-user": "root"
+}
+EOF
+ #Overwrite the tripleo-inclubator domain.xml with our own, keeping a backup.
+ if [ ! -f /usr/share/tripleo/templates/domain.xml.bak ]; then
+ /usr/bin/mv -f /usr/share/tripleo/templates/domain.xml /usr/share/tripleo/templates/domain.xml.bak
+ fi
+
+ /usr/bin/cp -f $LIB/installer/domain.xml /usr/share/tripleo/templates/domain.xml
+}
+
+##Create virtual nodes in virsh
+##params: name - String: libvirt name for VM
+## bootdev - String: boot device for the VM
+## disksize - Number: size of the disk in GB
+## ovs_bridges: - List: list of ovs bridges
+## vcpus - Number of VCPUs to use (defaults to 4)
+## ramsize - Size of RAM for VM in MB (defaults to 8192)
+function define_vm () {
+ local vcpus ramsize
+
+ if [ -z "$5" ]; then
+ vcpus=4
+ ramsize=8388608
+ elif [ -z "$6" ]; then
+ vcpus=$5
+ ramsize=8388608
+ else
+ vcpus=$5
+ ramsize=$(($6*1024))
+ fi
+
+ # Create the libvirt storage volume
+ if virsh vol-list default | grep ${1}.qcow2 2>&1> /dev/null; then
+ volume_path=$(virsh vol-path --pool default ${1}.qcow2 || echo "/var/lib/libvirt/images/${1}.qcow2")
+ echo "Volume ${1} exists. Deleting Existing Volume $volume_path"
+ virsh vol-dumpxml ${1}.qcow2 --pool default > /dev/null || echo '' #ok for this to fail
+ touch $volume_path
+ virsh vol-delete ${1}.qcow2 --pool default
+ fi
+ virsh vol-create-as default ${1}.qcow2 ${3}G --format qcow2
+ volume_path=$(virsh vol-path --pool default ${1}.qcow2)
+ if [ ! -f $volume_path ]; then
+ echo "$volume_path Not created successfully... Aborting"
+ exit 1
+ fi
+
+ # create the VM
+ /usr/libexec/openstack-tripleo/configure-vm --name $1 \
+ --bootdev $2 \
+ --image "$volume_path" \
+ --diskbus sata \
+ --arch x86_64 \
+ --cpus $vcpus \
+ --memory $ramsize \
+ --libvirt-nic-driver virtio \
+ --baremetal-interface $4
+}