~james-page/ubuntu-openstack-ci/drop-tox-from-slave-config

« back to all changes in this revision

Viewing changes to job-parts/osci_mojo_common.sh

[1chb1n, r=admcleod] Update cleanup; use mojo from a venv; add ocata mapping

 - Use port-cleanup tool to delete neutron ext-ports left over from mojo runs. [Bug 1656306]
 - Update and re-enable undercloud instance reaping when error conditions are known. [Bug 1668778]
 - Block forever when destroy fails and cleanup fails, where human intervention is required anyway. [Bug 1668778]
 - Use mojo from a python virtualenv. [Bug 1666746]
 - Use python virtualenv for juju_status_health_check to work around paramiki/crypto IV CTR issues upstream. [Bug 1665598]

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
function f_mojo_broom() {
6
6
  if [[ -d "/srv/mojo/mojo-openstack-specs/" ]]; then
7
 
    echo " - Purging /srv/mojo/mojo-openstack-specs ..."
8
 
    rm -rfv /srv/mojo/mojo-openstack-specs/*
 
7
    echo " - Purging /srv/mojo/mojo-openstack-specs"
 
8
    rm -rf /srv/mojo/mojo-openstack-specs/*
 
9
    echo " - Purging $MOJO_ROOT"
 
10
    rm -rf ${MOJO_ROOT}
9
11
  fi
10
12
}
11
13
 
12
14
 
 
15
function f_mojo_create_venv() {
 
16
  cd $UOSCI_BOT_CONTROL_ROOT/tools/mojo-openstack
 
17
  deactivate ||:
 
18
  tox
 
19
  . .tox/mojo/bin/activate
 
20
  cd $WORKSPACE
 
21
}
 
22
 
 
23
 
13
24
function f_mojo_new_project() {
14
25
# Add mojo project.
15
26
  if [[ -n "$(ls $WORKSPACE -1 | egrep '.failed|.bad')" ]]; then
17
28
    touch $WORKSPACE/fyi-${test:0:4}.mojo-project-new.skipped
18
29
  else
19
30
    set -x
20
 
    mojo project-new --series ${MOJO_SERIES} \
21
 
        --container containerless ${MOJO_PROJ} 2>&1 | tee $WORKSPACE/mojo-project-new.txt
 
31
    mojo-project-new --series ${MOJO_SERIES} \
 
32
        --container containerless ${MOJO_PROJ} --mojo-root ${MOJO_ROOT} 2>&1 | tee $WORKSPACE/mojo-project-new.txt
22
33
    # Error trap
23
34
    if [[ "${PIPESTATUS[0]}" != "0" ]]; then
24
35
      echo " ! Failed to create new mojo project."
30
41
}
31
42
 
32
43
 
33
 
# No longer necessary, as we run mojo "containerless"
34
 
#function f_mojo_lxc_perms_workaround() {
35
 
# Workaround for bug https://bugs.launchpad.net/mojo/+bug/1346873
36
 
#  set -x
37
 
#  sudo chmod 755 /var/lib/lxc/${MOJO_PROJ}.${MOJO_SERIES} || true
38
 
#  sudo chmod 755 /var/lib/lxc || true
39
 
#  set +x
40
 
#}
41
 
 
42
 
 
43
44
function f_mojo_new_workspace() {
44
45
# Add mojo workspace.
45
46
  if [[ -n "$(ls $WORKSPACE -1 | egrep '.failed|.bad')" ]]; then
47
48
    touch $WORKSPACE/fyi-${test:0:4}.mojo-workspace-new.skipped
48
49
  else
49
50
    set -x
50
 
    mojo workspace-new --project ${MOJO_PROJ} --series ${MOJO_SERIES} \
51
 
        --stage ${MOJO_SPEC} ${MOJO_OPENSTACK_SPECS_REPO} ${MOJO_WORKSPACE_NAME} \
 
51
    mojo --mojo-root ${MOJO_ROOT} workspace-new --project ${MOJO_PROJ} --series ${MOJO_SERIES} \
 
52
        --stage ${MOJO_SPEC} ${MOJO_OPENSTACK_SPECS_REPO} ${MOJO_WKSP} \
52
53
        2>&1 | tee $WORKSPACE/mojo-workspace-new.txt
 
54
 
53
55
    # Error trap
54
56
    if [[ "${PIPESTATUS[0]}" != "0" ]]; then
55
57
      echo " ! Failed to create new mojo workspace."
71
73
    f_openstack_set_network_env_vars
72
74
    #f_amulet_set_network_env_vars
73
75
    set -x
74
 
    mojo run --project ${MOJO_PROJ} --series ${MOJO_SERIES} \
75
 
        --stage ${MOJO_SPEC} ${MOJO_OPENSTACK_SPECS_REPO} ${MOJO_WORKSPACE_NAME} \
 
76
    mojo --mojo-root ${MOJO_ROOT} run --project ${MOJO_PROJ} --series ${MOJO_SERIES} \
 
77
        --stage ${MOJO_SPEC} ${MOJO_OPENSTACK_SPECS_REPO} ${MOJO_WKSP} \
76
78
        2>&1 | tee $WORKSPACE/mojo-run.txt
 
79
 
77
80
    # Error trap
78
81
    if [[ "${PIPESTATUS[0]}" != "0" ]]; then
79
82
      echo " ! Mojo run manifest failed."
84
87
}
85
88
 
86
89
 
87
 
# DEPRECATED
88
 
#function f_lxc_destroy_all() {
89
 
# Destroy all lxc containser if any exist
90
 
#  lxc_ls="$(sudo lxc-ls -1)"
91
 
#  if [[ -z "$lxc_ls" ]]; then
92
 
#    echo "OK: no lxc containers to destroy."
93
 
#  else
94
 
#    echo " - Destroying all lxc containers:"
95
 
#    for container in "$(sudo lxc-ls -1)"; do
96
 
#      echo " -   ${container}"
97
 
#      sudo lxc-destroy --name ${container} --force || true
98
 
#      sudo lxc-destroy --name ${container} --force || true
99
 
#    done
100
 
#  fi
101
 
#}
102
 
 
103
 
 
104
90
function f_mojo_handle_env_vars() {
105
91
# Validate and process mojo runner environment variables.
106
92