[ONOS-7346] ver.b

Change-Id: I330e0f197c2a3a213e5e9734b0175ad302b71dfc
diff --git a/jjb/OnosSystemTest/cho-clean-up.sh b/jjb/OnosSystemTest/cho-clean-up.sh
new file mode 100644
index 0000000..9d2a1d0
--- /dev/null
+++ b/jjb/OnosSystemTest/cho-clean-up.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+source ./clean-up.sh
+
+beforeClean
+
+cdTolog admin
+
+cleaning
+
+cd /var/lib/jenkins/workspace/OnosProdCHOpost
+
+echo "Checking if there are jenkins-logs older than ${DAYS_OLD} days...."
+for i in $(find . -mtime +${DAYS_OLD})
+do
+echo -e "logs older than $DAYS_OLD are: "
+echo $i
+rm -rf $i
+done
+
+afterClean
diff --git a/jjb/OnosSystemTest/clean-up.sh b/jjb/OnosSystemTest/clean-up.sh
new file mode 100644
index 0000000..bfcb47a
--- /dev/null
+++ b/jjb/OnosSystemTest/clean-up.sh
@@ -0,0 +1,24 @@
+function beforeClean{
+    echo -e "\n Before clean up disk usage: \n"
+    df -h
+}
+function cdTolog{
+    cd /home/$1/OnosSystemTest/TestON/logs
+}
+function cleaning{
+    if [ $? -eq 0 ]
+    then
+        echo "Checking if there are logs older than ${DAYS_OLD} days...."
+        for i in $(find . -mtime +${DAYS_OLD} -type d)
+        do
+        echo -e "DIRs older than $DAYS_OLD are: "
+        echo $i
+        rm -rf $i
+        done
+    fi
+}
+function afterClean{
+    echo -e "\n After clean up disk usage:\n"
+    df -h
+
+}
diff --git a/jjb/OnosSystemTest/onos-test-freestyle.yaml b/jjb/OnosSystemTest/onos-test-freestyle.yaml
new file mode 100644
index 0000000..6b061fc
--- /dev/null
+++ b/jjb/OnosSystemTest/onos-test-freestyle.yaml
@@ -0,0 +1,179 @@
+---
+# ONOS System Test Pipeline jobs
+
+# TODO: Change all the job names in Jenkins Pipeline script.
+
+- test-free-job-boiler-plate: &test-free-job-boiler-plate
+    name: test-free-job-boiler-plate
+
+    project-type: freestyle
+
+- init-station-plate: &init-station-plate
+    name: init-station-plate
+    station-type:
+      - 'VM'
+      - 'BM'
+
+- test-free-init-procedure-plate: &test-free-init-procedure-plate
+    name: test-free-init-procedure-plate
+    project: OnosSystemTest
+    stream: 'master'
+
+- inject-env-variable-plate: &inject-env-variable-plate
+    name: inject-env-variable-plate
+    wrappers:
+      - inject:
+         properties-file: '/var/jenkins/TestONOS.property'
+         script-content: |
+                          echo "ONOSBranch=$ONOSBranch" > /var/jenkins/TestONOS.property
+                          echo "TestONBranch=$TestONBranch" >> /var/jenkins/TestONOS.property
+                          echo "ONOSTag=$ONOSTag" >> /var/jenkins/TestONOS.property
+                          echo "WikiPrefix=$WikiPrefix" >> /var/jenkins/TestONOS.property
+         override-build-parameters: true
+
+# post_Job
+- job-template:
+    name: postjob-{station-type}
+
+    <<: *test-free-job-boiler-plate
+
+    properties:
+
+      - build-discarder:
+         num-to-keep: 1
+
+    parameters:
+
+      - lf-infra-parameters:
+         project: '{project}'
+         branch: '{stream}'
+         stream: '{stream}'
+         lftools-version: '{lftools-version}'
+
+    node: 'TestStation-{station-type}s'
+
+    publishers:
+
+#      - image-gallery:
+#         - gallery-type: archived-images-gallery
+#           title: 'Test result'
+#           includes: '*.jpg'
+
+      - archive:
+         artifacts: '*.jpg'
+
+# cleanup_stations - TDOO: need to add bash script.
+- job-template:
+    name: test-station-log-cleanup-VM
+
+    <<: *test-free-job-boiler-plate
+    <<: *inject-env-variable-plate
+    properties:
+
+      - build-discarder:
+         num-to-keep: 30
+
+    parameters:
+
+      - string:
+         name: 'DAYS_OLD'
+         default: '15'
+
+      - lf-infra-parameters:
+         project: '{project}'
+         branch: '{stream}'
+         stream: '{stream}'
+         lftools-version: '{lftools-version}'
+
+    node: 'TestStation-VMs'
+
+    triggers:
+      - timed: '01 08 1,15 * *'
+
+    builders:
+
+      - shell: !include-raw-escape: vm-bm-clean-up.sh
+
+- job-template:
+    name: test-station-log-cleanup-BM
+
+    <<: *test-free-job-boiler-plate
+    <<: *inject-env-variable-plate
+    properties:
+
+      - build-discarder:
+         num-to-keep: 30
+
+    parameters:
+
+      - string:
+         name: 'DAYS_OLD'
+         default: '30'
+
+      - lf-infra-parameters:
+         project: '{project}'
+         branch: '{stream}'
+         stream: '{stream}'
+         lftools-version: '{lftools-version}'
+
+    node: 'TestStation-BMs'
+
+    triggers:
+      - timed: '01 08 1 * *'
+
+    builders:
+
+      - shell: !include-raw-escape: vm-bm-clean-up.sh
+
+- job-template:
+    name: test-station-log-cleanup-CHO
+
+    <<: *test-free-job-boiler-plate
+    <<: *inject-env-variable-plate
+    properties:
+
+      - build-discarder:
+         num-to-keep: 15
+
+    parameters:
+
+      - string:
+         name: 'DAYS_OLD'
+         default: '15'
+
+      - lf-infra-parameters:
+         project: '{project}'
+         branch: '{stream}'
+         stream: '{stream}'
+         lftools-version: '{lftools-version}'
+
+    node: 'TestStation-CHOs'
+
+    triggers:
+      - timed: '@daily'
+
+    builders:
+
+      - shell: !include-raw-escape: cho-clean-up.sh
+
+#TODO LIST : DELTA -> perhaps change into pipeline?? , CHO_jobs, Check_style, Personal stations : necessary?
+
+- project:
+    name: post-result-jobs
+    project-name: post-result-jobs
+
+    <<: *test-free-init-procedure-plate
+    <<: *init-station-plate
+    jobs:
+      - 'postjob-{station-type}'
+
+- project:
+    name: cleanup-jobs
+    project-name: cleanup-jobs
+
+    <<: *test-free-init-procedure-plate
+    <<: *init-station-plate
+    jobs:
+      - 'test-station-log-cleanup-VM'
+      - 'test-station-log-cleanup-BM'
+      - 'test-station-log-cleanup-CHO'
diff --git a/jjb/OnosSystemTest/onos-test-pipeline.yaml b/jjb/OnosSystemTest/onos-test-pipeline.yaml
index f7b06a8..4542fe1 100644
--- a/jjb/OnosSystemTest/onos-test-pipeline.yaml
+++ b/jjb/OnosSystemTest/onos-test-pipeline.yaml
@@ -10,8 +10,8 @@
     SCPF: "SCPFcbench\nSCPFflowTp1g\nSCPFhostLat\nSCPFintentEventTp\nSCPFintentInstallWithdrawLat\nSCPFintentRerouteLat\nSCPFmastershipFailoverLat\nSCPFbatchFlowResp\nSCPFportLat\nSCPFscaleTopo\nSCPFscalingMaxIntents\nSCPFswitchLat\nSCPFflowTp1gWithFlowObj\nSCPFintentEventTpWithFlowObj\nSCPFintentRerouteLatWithFlowObj\nSCPFscalingMaxIntentsWithFlowObj\nSCPFintentInstallWithdrawLatWithFlowObj"
     USECASE: "FUNCbgpls\nFUNCvirNetNB\nPLATdockertest\nVPLSBasic\nVPLSfailsafe\nUSECASE_SdnipFunction\nUSECASE_SdnipFunctionCluster\nSRClusterRestart\nSRDynamic\nSRHighAvailability\nSRLinkFailure\nSROnosFailure\nSRSanity\nSRSwitchFailure"
 
-- job-boiler-plate: &job-boiler-plate
-    name: job-boiler-plate
+- test-pipe-job-boiler-plate: &test-pipe-job-boiler-plate
+    name: test-pipe-job-boiler-plate
 
     project-type: pipeline
 
@@ -22,8 +22,8 @@
       - build-discarder:
          num-to-keep: 20
 
-- init-procedure-plate: &init-procedure-plate
-    name: init-procedure-plate
+- test-pipe-init-procedure-plate: &test-pipe-init-procedure-plate
+    name: test-pipe-init-procedure-plate
     project: OnosSystemTest
     stream: 'master'
     jenkins-path: 'TestON/JenkinsFile'
@@ -48,7 +48,7 @@
     name: all-pipeline-trigger
 
     <<: *var-init-boiler-plate
-    <<: *job-boiler-plate
+    <<: *test-pipe-job-boiler-plate
 
     parameters:
 
@@ -121,7 +121,7 @@
 - job-template:
     name: '{type}-pipeline-{version}'
 
-    <<: *job-boiler-plate
+    <<: *test-pipe-job-boiler-plate
 
     parameters:
 
@@ -152,16 +152,10 @@
     name: 'manual-graph-generator-SCPF'
 
     <<: *var-init-boiler-plate
-    <<: *job-boiler-plate
+    <<: *test-pipe-job-boiler-plate
 
     parameters:
 
-      - lf-infra-parameters:
-         project: 'OnosSystemTest'
-         branch: 'master'
-         stream: 'master'
-         lftools-version: '<1.0.0'
-
       - choice:
          name: ONOSbranch
          choices:
@@ -199,7 +193,7 @@
     name: 'manual-graph-generator-trend'
 
     <<: *var-init-boiler-plate
-    <<: *job-boiler-plate
+    <<: *test-pipe-job-boiler-plate
 
     parameters:
 
@@ -232,7 +226,7 @@
 
       - string:
          name: Builds
-         deafult: 20
+         deafult: '20'
          description: 'Builds to show in the graph.'
 
       - lf-infra-parameters:
@@ -254,7 +248,7 @@
     name: all-pipeline-trigger
     project-name: all-pipeline-trigger
 
-    <<: *init-procedure-plate
+    <<: *test-pipe-init-procedure-plate
 
     # can we use this node or master ?
     build-node: 'ubuntu16.04-basebuild-8c-15g'
@@ -268,7 +262,7 @@
 
     project-name: '{type}-pipeline'
 
-    <<: *init-procedure-plate
+    <<: *test-pipe-init-procedure-plate
     <<: *job-version-plate
 
     jobs:
@@ -279,7 +273,7 @@
 
     project-name: 'graph-generator'
 
-    <<: *init-procedure-plate
+    <<: *test-pipe-init-procedure-plate
 
     jobs:
       - 'manual-graph-generator-SCPF'
diff --git a/jjb/OnosSystemTest/vm-bm-clean-up.sh b/jjb/OnosSystemTest/vm-bm-clean-up.sh
new file mode 100644
index 0000000..03497fc
--- /dev/null
+++ b/jjb/OnosSystemTest/vm-bm-clean-up.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+source ./clean-up.sh
+
+beforeClean
+
+cdTolog sdn
+
+cleaning
+
+afterClean