Add uninstall and test scripts for SEBA 76/576/12
authortrevortao <trevor.tao@arm.com>
Mon, 22 Apr 2019 07:42:49 +0000 (15:42 +0800)
committerCristina Pauna <cristina.pauna@enea.com>
Mon, 6 May 2019 08:17:43 +0000 (11:17 +0300)
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 <trevor.tao@arm.com>
Signed-off-by: trevor tao <trevor.tao@arm.com>
src/use_cases/seba_on_arm/install/README
src/use_cases/seba_on_arm/install/fabric.yaml [new file with mode: 0644]
src/use_cases/seba_on_arm/install/install.sh
src/use_cases/seba_on_arm/install/olt.yaml [new file with mode: 0644]
src/use_cases/seba_on_arm/install/test.sh [new file with mode: 0644]
src/use_cases/seba_on_arm/install/uninstall.sh [new file with mode: 0755]
src/use_cases/seba_on_arm/install/util.sh [new file with mode: 0644]

index e69de29..9a389a7 100644 (file)
@@ -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 (file)
index 0000000..1e7f0d9
--- /dev/null
@@ -0,0 +1,78 @@
+tosca_definitions_version: tosca_simple_yaml_1_0\r
+imports:\r
+  - custom_types/switch.yaml\r
+  - custom_types/switchport.yaml\r
+  - custom_types/portinterface.yaml\r
+  - custom_types/bngportmapping.yaml\r
+  - custom_types/attworkflowdriverwhitelistentry.yaml\r
+  - custom_types/attworkflowdriverservice.yaml\r
+  - custom_types/serviceinstanceattribute.yaml\r
+  - custom_types/onosapp.yaml\r
+\r
+description: Configures a full SEBA POD\r
+\r
+topology_template:\r
+  node_templates:\r
+    # Fabric configuration\r
+    switch#leaf_1:\r
+      type: tosca.nodes.Switch\r
+      properties:\r
+        driver: ofdpa3\r
+        ipv4Loopback: 100.100.0.201\r
+        ipv4NodeSid: 17\r
+        isEdgeRouter: "True"\r
+        name: AGG_SWITCH\r
+        ofId: of:0000000000000001\r
+        routerMac: 00:00:02:01:06:01\r
+\r
+    # Setup the OLT switch port\r
+    port#olt_port:\r
+      type: tosca.nodes.SwitchPort\r
+      properties:\r
+        portId: 1\r
+        host_learning: false\r
+      requirements:\r
+        - switch:\r
+            node: switch#leaf_1\r
+            relationship: tosca.relationships.BelongsToOne\r
+\r
+    # Port connected to the BNG\r
+    port#bng_port:\r
+      type: tosca.nodes.SwitchPort\r
+      properties:\r
+        portId: 31\r
+      requirements:\r
+        - switch:\r
+            node: switch#leaf_1\r
+            relationship: tosca.relationships.BelongsToOne\r
+\r
+    # Setup the fabric switch port where the external\r
+    # router is connected to\r
+    bngmapping:\r
+      type: tosca.nodes.BNGPortMapping\r
+      properties:\r
+        s_tag: any\r
+        switch_port: 31\r
+\r
+    # DHCP L2 Relay config\r
+    onos_app#dhcpl2relay:\r
+      type: tosca.nodes.ONOSApp\r
+      properties:\r
+        name: dhcpl2relay\r
+        must-exist: true\r
+\r
+    dhcpl2relay-config-attr:\r
+      type: tosca.nodes.ServiceInstanceAttribute\r
+      properties:\r
+        name: /onos/v1/network/configuration/apps/org.opencord.dhcpl2relay\r
+        value: >\r
+          {\r
+            "dhcpl2relay" : {\r
+              "useOltUplinkForServerPktInOut" : false,\r
+              "dhcpServerConnectPoints" : [ "of:0000000000000001/31" ]\r
+            }\r
+          }\r
+      requirements:\r
+        - service_instance:\r
+            node: onos_app#dhcpl2relay\r
+            relationship: tosca.relationships.BelongsToOne\r
index 1208325..daf2223 100755 (executable)
@@ -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 (file)
index 0000000..df5b77f
--- /dev/null
@@ -0,0 +1,32 @@
+tosca_definitions_version: tosca_simple_yaml_1_0\r
+imports:\r
+  - custom_types/oltdevice.yaml\r
+  - custom_types/onudevice.yaml\r
+  - custom_types/voltservice.yaml\r
+description: Create an OLT Device in VOLTHA\r
+topology_template:\r
+  node_templates:\r
+\r
+    service#volt:\r
+      type: tosca.nodes.VOLTService\r
+      properties:\r
+        name: volt\r
+        must-exist: true\r
+\r
+    olt_device:\r
+      type: tosca.nodes.OLTDevice\r
+      properties:\r
+        name: My OLT\r
+        device_type: openolt\r
+        host: {{bbsim_ip}}\r
+        port: 50060\r
+        switch_datapath_id: of:0000000000000002             # the openflow switch to which the OLT is connected\r
+        switch_port: "1"          # the port on the switch on which the OLT is connected\r
+        outer_tpid: "0x8100"\r
+        uplink: "65536"\r
+        nas_id: "NAS_ID"\r
+        serial_number: "{{bbsim_ip}}:50060"\r
+      requirements:\r
+        - volt_service:\r
+            node: service#volt\r
+            relationship: tosca.relationships.BelongsToOne\r
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 (file)
index 0000000..3577d3f
--- /dev/null
@@ -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 (executable)
index 0000000..f3d6d01
--- /dev/null
@@ -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 (file)
index 0000000..ad80c6c
--- /dev/null
@@ -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
+  )
+}
+