From 86f779eb36059f19e59f5dd7e17ec028e9245154 Mon Sep 17 00:00:00 2001 From: trevortao Date: Mon, 22 Apr 2019 15:42:49 +0800 Subject: [PATCH] Add uninstall and test scripts for SEBA Add uninstall and function test scripts for SEBA on arm. Revised the install script to avoid the possible unnecessary failure. Revise install.sh to avoid long time waiting. Change-Id: Ia9f8d96b9e87d03d20b4e948efe169d73b1e56e5 Signed-off-by: trevortao Signed-off-by: trevor tao --- src/use_cases/seba_on_arm/install/README | 18 ++++++ src/use_cases/seba_on_arm/install/fabric.yaml | 78 ++++++++++++++++++++++++++ src/use_cases/seba_on_arm/install/install.sh | 30 +++------- src/use_cases/seba_on_arm/install/olt.yaml | 32 +++++++++++ src/use_cases/seba_on_arm/install/test.sh | 27 +++++++++ src/use_cases/seba_on_arm/install/uninstall.sh | 12 ++++ src/use_cases/seba_on_arm/install/util.sh | 22 ++++++++ 7 files changed, 198 insertions(+), 21 deletions(-) create mode 100644 src/use_cases/seba_on_arm/install/fabric.yaml create mode 100644 src/use_cases/seba_on_arm/install/olt.yaml create mode 100644 src/use_cases/seba_on_arm/install/test.sh create mode 100755 src/use_cases/seba_on_arm/install/uninstall.sh create mode 100644 src/use_cases/seba_on_arm/install/util.sh diff --git a/src/use_cases/seba_on_arm/install/README b/src/use_cases/seba_on_arm/install/README index e69de29..9a389a7 100644 --- a/src/use_cases/seba_on_arm/install/README +++ b/src/use_cases/seba_on_arm/install/README @@ -0,0 +1,18 @@ +SEBA on Arm Installation Guide + +1. To install: + sudo install.sh + +2. To uninstal: + sudo uninstall.sh + +3. A simple test for its function: + sudo test.sh + It may need to install the tool 'curl', for ubuntu 16.04/18.04 by: + apt-get -y install curl + +4. Use the XOS-GUI webui with your browser to check the config: + http://node_ip:30001 + For a known Kubernetes issues, you may need to add to the node you would like to access: + $sudo iptables -A FORWARD -j ACCEPT + if you can only access the GUI from the node where xos-gui pod runs. diff --git a/src/use_cases/seba_on_arm/install/fabric.yaml b/src/use_cases/seba_on_arm/install/fabric.yaml new file mode 100644 index 0000000..1e7f0d9 --- /dev/null +++ b/src/use_cases/seba_on_arm/install/fabric.yaml @@ -0,0 +1,78 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 +imports: + - custom_types/switch.yaml + - custom_types/switchport.yaml + - custom_types/portinterface.yaml + - custom_types/bngportmapping.yaml + - custom_types/attworkflowdriverwhitelistentry.yaml + - custom_types/attworkflowdriverservice.yaml + - custom_types/serviceinstanceattribute.yaml + - custom_types/onosapp.yaml + +description: Configures a full SEBA POD + +topology_template: + node_templates: + # Fabric configuration + switch#leaf_1: + type: tosca.nodes.Switch + properties: + driver: ofdpa3 + ipv4Loopback: 100.100.0.201 + ipv4NodeSid: 17 + isEdgeRouter: "True" + name: AGG_SWITCH + ofId: of:0000000000000001 + routerMac: 00:00:02:01:06:01 + + # Setup the OLT switch port + port#olt_port: + type: tosca.nodes.SwitchPort + properties: + portId: 1 + host_learning: false + requirements: + - switch: + node: switch#leaf_1 + relationship: tosca.relationships.BelongsToOne + + # Port connected to the BNG + port#bng_port: + type: tosca.nodes.SwitchPort + properties: + portId: 31 + requirements: + - switch: + node: switch#leaf_1 + relationship: tosca.relationships.BelongsToOne + + # Setup the fabric switch port where the external + # router is connected to + bngmapping: + type: tosca.nodes.BNGPortMapping + properties: + s_tag: any + switch_port: 31 + + # DHCP L2 Relay config + onos_app#dhcpl2relay: + type: tosca.nodes.ONOSApp + properties: + name: dhcpl2relay + must-exist: true + + dhcpl2relay-config-attr: + type: tosca.nodes.ServiceInstanceAttribute + properties: + name: /onos/v1/network/configuration/apps/org.opencord.dhcpl2relay + value: > + { + "dhcpl2relay" : { + "useOltUplinkForServerPktInOut" : false, + "dhcpServerConnectPoints" : [ "of:0000000000000001/31" ] + } + } + requirements: + - service_instance: + node: onos_app#dhcpl2relay + relationship: tosca.relationships.BelongsToOne diff --git a/src/use_cases/seba_on_arm/install/install.sh b/src/use_cases/seba_on_arm/install/install.sh index 1208325..daf2223 100755 --- a/src/use_cases/seba_on_arm/install/install.sh +++ b/src/use_cases/seba_on_arm/install/install.sh @@ -8,29 +8,13 @@ CORD_REPO=${CORD_REPO:-https://charts.opencord.org} CORD_PLATFORM_VERSION=${CORD_PLATFORM_VERSION:-6.1.0} SEBA_VERSION=${SEBA_VERSION:-1.0.0} ATT_WORKFLOW_VERSION=${ATT_WORKFLOW_VERSION:-1.0.2} +BBSIM_VERSION=${SEBA_VERSION:-1.0.0} CORD_CHART=${CORD_CHART:-${basepath}/../src_repo/seba_charts} # TODO(alav): Make each step re-entrant -function wait_for { - # Execute in a subshell to prevent local variable override during recursion - ( - local total_attempts=$1; shift - local cmdstr=$* - local sleep_time=2 - echo -e "\n[wait_for] Waiting for cmd to return success: ${cmdstr}" - # shellcheck disable=SC2034 - for attempt in $(seq "${total_attempts}"); do - echo "[wait_for] Attempt ${attempt}/${total_attempts%.*} for: ${cmdstr}" - # shellcheck disable=SC2015 - eval "${cmdstr}" && echo "[wait_for] OK: ${cmdstr}" && return 0 || true - sleep "${sleep_time}" - done - echo "[wait_for] ERROR: Failed after max attempts: ${cmdstr}" - return 1 - ) -} +source util.sh wait_for 10 'test $(kubectl get pods --all-namespaces | grep -ce "tiller.*Running") -eq 1' @@ -51,12 +35,16 @@ fi # Install the CORD platform helm install -n cord-platform ${CORD_CHART}/cord-platform --version="${CORD_PLATFORM_VERSION}" # Wait until 3 etcd CRDs are present in Kubernetes -wait_for 300 'test $(kubectl get crd | grep -ice etcd) -eq 3' +wait_for 300 'test $(kubectl get crd | grep -ice etcd) -eq 3' || true # Install the SEBA profile helm install -n seba --version "${SEBA_VERSION}" ${CORD_CHART}/seba -wait_for 1500 'test $(kubectl get pods | grep -vcE "(\s(.+)/\2.*Running|tosca-loader.*Completed)") -eq 1' +wait_for 500 'test $(kubectl get pods | grep -vcE "(\s(.+)/\2.*Running|tosca-loader.*Completed)") -eq 1' || true # Install the AT&T workflow helm install -n att-workflow --version "${ATT_WORKFLOW_VERSION}" ${CORD_CHART}/att-workflow -wait_for 300 'test $(kubectl get pods | grep -vcE "(\s(.+)/\2.*Running|tosca-loader.*Completed)") -eq 1' +wait_for 300 'test $(kubectl get pods | grep -vcE "(\s(.+)/\2.*Running|tosca-loader.*Completed)") -eq 1' || true + +# Install bbsim +export BBSIM_VERSION +#helm install -n bbsim --version ${BBSIM_VERSION} ${CORD_CHART}/bbsim diff --git a/src/use_cases/seba_on_arm/install/olt.yaml b/src/use_cases/seba_on_arm/install/olt.yaml new file mode 100644 index 0000000..df5b77f --- /dev/null +++ b/src/use_cases/seba_on_arm/install/olt.yaml @@ -0,0 +1,32 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 +imports: + - custom_types/oltdevice.yaml + - custom_types/onudevice.yaml + - custom_types/voltservice.yaml +description: Create an OLT Device in VOLTHA +topology_template: + node_templates: + + service#volt: + type: tosca.nodes.VOLTService + properties: + name: volt + must-exist: true + + olt_device: + type: tosca.nodes.OLTDevice + properties: + name: My OLT + device_type: openolt + host: {{bbsim_ip}} + port: 50060 + switch_datapath_id: of:0000000000000002 # the openflow switch to which the OLT is connected + switch_port: "1" # the port on the switch on which the OLT is connected + outer_tpid: "0x8100" + uplink: "65536" + nas_id: "NAS_ID" + serial_number: "{{bbsim_ip}}:50060" + requirements: + - volt_service: + node: service#volt + relationship: tosca.relationships.BelongsToOne diff --git a/src/use_cases/seba_on_arm/install/test.sh b/src/use_cases/seba_on_arm/install/test.sh new file mode 100644 index 0000000..3577d3f --- /dev/null +++ b/src/use_cases/seba_on_arm/install/test.sh @@ -0,0 +1,27 @@ +#!/bin/bash -ex +# shellcheck disable=SC2016 + +#Modified from https://github.com/cachengo/seba_charts/blob/master/scripts/mini_test.sh + +TOSCA_POD=`kubectl get pods | grep xos-tosca | cut -d " " -f1` +TOSCA_IP=`kubectl describe pod $TOSCA_POD | grep Node: | cut -d "/" -f2` +BBSIM_IP=`kubectl get services -n voltha | grep bbsim | tr -s ' ' | cut -d " " -f3` + + +# Create the first model +curl \ + -H "xos-username: admin@opencord.org" \ + -H "xos-password: letmein" \ + -X POST \ + --data-binary @fabric.yaml \ + http://$TOSCA_IP:30007/run + +# Create the second model +sed "s/{{bbsim_ip}}/$BBSIM_IP/g" olt.yaml > olt.yaml.tmp +curl \ + -H "xos-username: admin@opencord.org" \ + -H "xos-password: letmein" \ + -X POST \ + --data-binary @olt.yaml.tmp \ + http://$TOSCA_IP:30007/run +rm olt.yaml.tmp diff --git a/src/use_cases/seba_on_arm/install/uninstall.sh b/src/use_cases/seba_on_arm/install/uninstall.sh new file mode 100755 index 0000000..f3d6d01 --- /dev/null +++ b/src/use_cases/seba_on_arm/install/uninstall.sh @@ -0,0 +1,12 @@ +#!/bin/bash -ex +# shellcheck disable=SC2016 + +source util.sh + +helm del --purge att-workflow || true +wait_for 100 "test $(helm list 'att-platform' | wc -l) -eq 0" +helm del --purge seba || true +wait_for 100 "test $(helm list 'seba' | wc -l) -eq 0" +helm del --purge cord-platform || true +wait_for 100 "test $(helm list 'cord-platform' | wc -l) -eq 0" + diff --git a/src/use_cases/seba_on_arm/install/util.sh b/src/use_cases/seba_on_arm/install/util.sh new file mode 100644 index 0000000..ad80c6c --- /dev/null +++ b/src/use_cases/seba_on_arm/install/util.sh @@ -0,0 +1,22 @@ +#!/bin/bash -ex +# shellcheck disable=SC2016 + +function wait_for { + # Execute in a subshell to prevent local variable override during recursion + ( + local total_attempts=$1; shift + local cmdstr=$* + local sleep_time=2 + echo -e "\n[wait_for] Waiting for cmd to return success: ${cmdstr}" + # shellcheck disable=SC2034 + for attempt in $(seq "${total_attempts}"); do + echo "[wait_for] Attempt ${attempt}/${total_attempts%.*} for: ${cmdstr}" + # shellcheck disable=SC2015 + eval "${cmdstr}" && echo "[wait_for] OK: ${cmdstr}" && return 0 || true + sleep "${sleep_time}" + done + echo "[wait_for] ERROR: Failed after max attempts: ${cmdstr}" + return 1 + ) +} + -- 2.16.6