CORD-714
initial set of roles/playbooks
bug fixes
fix docker-compose logging, pull xos-base image
dynamically add docker instances to ansible inventory after onboarding
Bootstrap the onboarding synchronizer
more defaults, reload vars after adding docker inventory
move TOSCA templates to cord-profilea, random password on admin
fixes for docker compose, paths in xos.yaml in jinja
don't try to mangle XOS _config files (yet)
create xos-test image
make xos-test use locally build xosproject/xos
add docker-compose v2 format networking
fix docker-compose template
path fixes, move ssh keys
service names/paths aren't so simple
added api-tests, teardown roles
scan the onboarded docker-compose file for ansible inventory
add various tests used by test-standalone profile
fixes for API tests
save test output to /tmp/<testname>.out, bugfixes
autogenerate openstack keystone admin password, fix tests
remove nonfunctional UI tests
change location of cord_profile, use inventory to specify profile
fix YAML escaping of backslashes in regex
bugfixes after path change, add teardown playbook
backout setting of cord_dir with ansible_user_dir which differs depending on context
gradle build fixes, renaming
fix yml/yaml naming issue
null xos_images default
added rcord/mcord frontend variants, exampleservice onboarding
add missing role, help text in cord-bootstrap.sh
bugfix
create/run deployment.yaml by default
allow teardown to handle partially built pods, bugfix to deployment.yaml generation
add defaults, fix path for exampleservice
revert yaml naming to ease testing, rename mocks
debugging
exampleservice onboarding, mounting volume in XOS container
bugfix
add volume mounts when creating xos_ui, don't double add to ansible inventory
post-onboard TOSCA cnfig
typo fixes, order of loading TOSCA
config bits for cord-pod, some var renaming
update documentation, rename to rcord
doc fixes
support for building just before XOS install, docs
fix tests, refactor how compute nodes are configed, split vtn service config from adding a node
remove build process from deploy repo
inclusion/merge of PKI support
typo
bugfixes and change to use cord instead of opencord for install dir
fix pki support
fix ssh key paths
update xos ui/bs ports, fix onboarding on vagrant
have compute enlist script use same config file as other playbooks
fix ports, add MaaS version of compute node enable script
fix port and nodes.yaml loading
generate API SSL cert for all profiles
remove cord-app-build which is vestigial
remove config dir
default xos_ui_port in xos-ready role
use xostosca from service-profie/cord-pod-ansible to handle POST form-encode
fix nodes.yaml, variable name in xostosca, and include openstack properly
copy cert chain to build into XOS container
increase onboarding timeouts, don't restart docker
fix ONOS app versions and network settings
fix management_hosts network optional include
fix management/fabric settings
avoid modifying service#ONOS_CORD when adding nodes
split out compute node and vtn config, put delay between
fix template generation and fail on file not found
rename vars to profile_manifests, fix redis include
whitespace fix
increase timeout
reenable platform-check
parameterize node_key path, set defaults and fix platform-check
workaround for onboarding sync, minor fixes
pause in middle of VTN bug workaround
reload openstack config as well
disable platform-check role as a test
fixed head-diag role
reapply VTN config during compute node enable
Create exampleservice instance during test

Change-Id: I87e171bcfa429e65e1075a1ee4c97de1e90a7dd5
diff --git a/scripts/bootstrap_ansible.sh b/scripts/bootstrap_ansible.sh
deleted file mode 100755
index 5dce4b2..0000000
--- a/scripts/bootstrap_ansible.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2012 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set -e
-
-echo "Installing Ansible..."
-apt-get install -y software-properties-common
-apt-add-repository ppa:ansible/ansible
-apt-get update
-apt-get install -y ansible
-cp /platform-install/ansible.cfg /etc/ansible/ansible.cfg
-
diff --git a/scripts/cord-bootstrap.sh b/scripts/cord-bootstrap.sh
new file mode 100644
index 0000000..760c304
--- /dev/null
+++ b/scripts/cord-bootstrap.sh
@@ -0,0 +1,128 @@
+#!/usr/bin/env bash
+# cord-bootstrap.sh
+# Bootstraps environment and downloads CORD repos
+
+set -e
+set -x
+
+CORDDIR=~/cord
+
+function bootstrap() {
+
+  if [ ! -x "/usr/bin/ansible" ]
+  then
+    echo "Installing Ansible..."
+    sudo apt-get update
+    sudo apt-get install -y software-properties-common
+    sudo apt-add-repository -y ppa:ansible/ansible
+    sudo apt-get update
+    sudo apt-get install -y ansible python-netaddr
+  fi
+
+  if [ ! -x "/usr/local/bin/repo" ]
+  then
+    echo "Installing repo..."
+    REPO_SHA256SUM="e147f0392686c40cfd7d5e6f332c6ee74c4eab4d24e2694b3b0a0c037bf51dc5"
+    curl -o /tmp/repo https://storage.googleapis.com/git-repo-downloads/repo
+    echo "$REPO_SHA256SUM  /tmp/repo" | sha256sum -c -
+    sudo mv /tmp/repo /usr/local/bin/repo
+    sudo chmod a+x /usr/local/bin/repo
+  fi
+
+  if [ ! -d "$CORDDIR" ]
+  then
+    echo "Downloading CORD/XOS..."
+
+    if [ ! -e "~/.gitconfig" ]
+    then
+      echo "No ~/.gitconfig, setting testing defaults"
+      git config --global user.name 'Test User'
+      git config --global user.email 'test@null.com'
+      git config --global color.ui false
+    fi
+
+    mkdir $CORDDIR && cd $CORDDIR
+    repo init -u https://gerrit.opencord.org/manifest -b master -g build,onos,orchestration
+    repo sync
+
+    # check out gerrit branches using repo
+    for gerrit_branch in ${GERRIT_BRANCHES[@]}; do
+      echo "checking out opencord gerrit branch: $gerrit_branch"
+      repo download ${gerrit_branch/:/ }
+    done
+  fi
+
+  if [ ! -x "/usr/bin/docker" ]
+  then
+    echo "Installing Devel Tools..."
+    cd ${CORDDIR}/build/platform-install
+    ansible-playbook -i inventory/localhost devel-tools-playbook.yml
+  fi
+
+  set +x
+  echo "*******************************************************************************"
+  echo "*  IMPORTANT: Logout and login so your account is added to the docker group!  *"
+  echo "*   Then 'cd ${CORDDIR}/build/platform-install' and start your CORD profile.  *"
+  echo "*        Need help?  Check out the wiki at: https://wiki.opencord.org/        *"
+  echo "*******************************************************************************"
+
+}
+
+function cleanup() {
+  if [ ! -x "/usr/bin/ansible" ]
+  then
+    echo "Ansible not installed, can't cleanup. Is this the initial run?"
+  else
+    echo "Cleaning up - destroying docker containers..."
+    cd ${CORDDIR}/build/platform-install
+    ansible-playbook -i inventory/localhost teardown-playbook.yaml
+  fi
+}
+
+function cord_profile() {
+  echo "Running a profile is broken due to docker group membership issue"
+}
+
+# options that may be set by getopt
+GERRIT_BRANCHES=
+CLEANUP=0
+CORD_PROFILE=""
+
+while getopts "b:hcp:" opt; do
+  case ${opt} in
+    b ) GERRIT_BRANCHES+=("$OPTARG")
+      ;;
+    c ) CLEANUP=1
+      ;;
+    h ) echo "Usage:"
+      echo "    $0                prep system to run a CORD profile"
+      echo "    $0 -b <project:changeset/revision>  checkout a changesets from gerrit. Can"
+      echo "                      be used multiple times."
+      echo "    $0 -c             cleanup from previous test"
+      echo "    $0 -p <profile>   prep then start running the specified profile"
+      echo "    $0 -h             display this help message"
+      exit 0
+      ;;
+    p ) CORD_PROFILE=$OPTARG
+      ;;
+    \? ) echo "Invalid option: -$OPTARG"
+      exit 1
+      ;;
+  esac
+done
+
+# "main" function
+if [[ $CLEANUP -eq 1 ]]
+then
+  cleanup
+fi
+
+bootstrap
+
+if [[ $CORD_PROFILE -ne "" ]]
+then
+  set -x
+  cord_profile
+fi
+
+exit 0