Browse Source

Merge "DevStack cleanups"

Zuul 2 months ago
parent
commit
d139b39fda
6 changed files with 147 additions and 49 deletions
  1. 16
    3
      .zuul.yaml
  2. 35
    0
      devstack/build.sh
  3. 83
    43
      devstack/lib/stx-fault
  4. 1
    1
      devstack/plugin.sh
  5. 8
    2
      devstack/settings
  6. 4
    0
      tox.ini

+ 16
- 3
.zuul.yaml View File

@@ -5,24 +5,37 @@
5 5
       - build-openstack-docs-pti
6 6
     check:
7 7
       jobs:
8
-        - stx-devstack-fault:
9
-            voting: false
10 8
         - build-openstack-api-ref
11 9
         - build-openstack-releasenotes
12 10
         - openstack-tox-linters
13 11
         - openstack-tox-pep8
12
+        - stx-fault-build
13
+        - stx-fault-devstack
14 14
     gate:
15 15
       jobs:
16 16
         - build-openstack-api-ref
17 17
         - build-openstack-releasenotes
18 18
         - openstack-tox-linters
19 19
         - openstack-tox-pep8
20
+        - stx-fault-devstack
20 21
     post:
21 22
       jobs:
22 23
         - publish-stx-api-ref
23 24
         - publish-stx-tox
24 25
         - publish-stx-releasenotes
25 26
 
27
+# Perform just a build
28
+- job:
29
+    name: stx-fault-build
30
+    parent: tox
31
+    description: Run build for fault
32
+    irrelevant-files:
33
+      - api-ref/*
34
+      - docs/*
35
+      - releasenotes/*
36
+    vars:
37
+      tox_envlist: build
38
+
26 39
 # This job is to begin testing a DevStack run here
27 40
 - job:
28 41
     name: stx-devstack-base
@@ -72,7 +85,7 @@
72 85
         FORCE: yes
73 86
 
74 87
 - job:
75
-    name: stx-devstack-fault
88
+    name: stx-fault-devstack
76 89
     parent: stx-devstack-base
77 90
     timeout: 7800
78 91
     required-projects:

+ 35
- 0
devstack/build.sh View File

@@ -0,0 +1,35 @@
1
+#!/bin/bash
2
+
3
+# devstack/build.sh
4
+# Run DevStack plugin builds
5
+
6
+set -o xtrace
7
+
8
+unset LANG
9
+unset LANGUAGE
10
+LC_ALL=en_US.utf8
11
+export LC_ALL
12
+
13
+# Keep track of the DevStack plugin directory
14
+PLUGIN_DIR=$(cd $(dirname "$0")/.. && pwd)
15
+PLUGIN_NAME=$(basename $PLUGIN_DIR)
16
+
17
+# Keep plugin happy
18
+declare -a GITDIR
19
+GITDIR[$PLUGIN_NAME]=$PLUGIN_DIR
20
+
21
+# Dummy function to keep plugin happy
22
+function get_python_exec_prefix {
23
+    echo ""
24
+}
25
+
26
+function is_service_enabled {
27
+    return 0
28
+}
29
+
30
+# Get the build functions
31
+source $PLUGIN_DIR/devstack/lib/stx-fault
32
+
33
+# Call builds
34
+build_fm_common
35
+build_fm_mgr

+ 83
- 43
devstack/lib/stx-fault View File

@@ -5,9 +5,6 @@
5 5
 
6 6
 # Dependencies:
7 7
 #
8
-# - ``functions`` file
9
-# - ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined
10
-
11 8
 # - The stx-update plugin must be enabled
12 9
 
13 10
 # ``stack.sh`` calls the entry points in this order:
@@ -26,13 +23,13 @@ set -o xtrace
26 23
 # Defaults
27 24
 # --------
28 25
 
29
-FAULT_DIR=${GITDIR[$STX_FAULT_NAME]}
30
-FAULT_CONF_DIR=/etc/fm
31
-FM_RESTAPI_CONF=$FAULT_CONF_DIR/fm.conf
32
-FM_RESTAPI_PASTE_INI=$FAULT_CONF_DIR/api-paste.ini
26
+STX_FAULT_DIR=${GITDIR[$STX_FAULT_NAME]}
27
+STX_FAULT_CONF_DIR=/etc/fm
28
+FM_RESTAPI_CONF=$STX_FAULT_CONF_DIR/fm.conf
29
+FM_RESTAPI_PASTE_INI=$STX_FAULT_CONF_DIR/api-paste.ini
33 30
 FM_RESTAPI_AUTH_CACHE_DIR=${FM_RESTAPI_AUTH_CACHE_DIR:-/var/cache/fault}
34 31
 
35
-FM_RESTAPI_DIR=${GITDIR[$STX_FAULT_NAME]}/fm-rest-api/fm
32
+FM_RESTAPI_DIR=$STX_FAULT_DIR/fm-rest-api/fm
36 33
 
37 34
 
38 35
 if is_service_enabled tls-proxy; then
@@ -49,6 +46,51 @@ PYTHON_SITE_DIR=$(python -c "from distutils.sysconfig import get_python_lib; pri
49 46
 # Functions
50 47
 # ---------
51 48
 
49
+function build_fm_common {
50
+    pushd $STX_FAULT_DIR/fm-common/sources
51
+
52
+    local major minor version x
53
+
54
+    if [[ -z $1 || -z $2 ]]; then
55
+        # get fm-common version
56
+        read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-common/PKG-INFO)
57
+        major=${version%%.*}
58
+        minor=${version##*.}
59
+    else
60
+        major=$1
61
+        minor=$2
62
+    fi
63
+
64
+    # build
65
+    make MAJOR=$major MINOR=$minor
66
+    python setup.py build
67
+
68
+    popd
69
+}
70
+
71
+function build_fm_mgr {
72
+    pushd $STX_FAULT_DIR/fm-mgr/sources
73
+
74
+    local x version
75
+
76
+    local major minor version x
77
+
78
+    if [[ -z $1 || -z $2 ]]; then
79
+        # get fm-mgr version
80
+        read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-mgr/PKG-INFO)
81
+        local major=${version%%.*}
82
+        local minor=${version##*.}
83
+    else
84
+        major=$1
85
+        minor=$2
86
+    fi
87
+
88
+    # build
89
+    make MAJOR=$major MINOR=$minor
90
+
91
+    popd
92
+}
93
+
52 94
 function cleanup_fault {
53 95
     stop_fault
54 96
 
@@ -67,14 +109,14 @@ function cleanup_fm_common {
67 109
     local x version
68 110
 
69 111
     # get fm-common version
70
-    read x version <<< $(grep '^Version: ' ${GITDIR[$STX_FAULT_NAME]}/fm-common/PKG-INFO)
112
+    read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-common/PKG-INFO)
71 113
     local major=${version%%.*}
72 114
     local minor=${version##*.}
73 115
     local prefix=${STX_BIN_DIR%/*}
74 116
 
75 117
     sudo rm /etc/ld.so.conf.d/stx-fault.conf
76 118
 
77
-    pushd ${GITDIR[$STX_FAULT_NAME]}/fm-common/sources
119
+    pushd $STX_FAULT_DIR/fm-common/sources
78 120
 
79 121
     sudo make \
80 122
         DEST_DIR=$prefix \
@@ -96,11 +138,11 @@ function cleanup_fm_mgr {
96 138
     local x version
97 139
 
98 140
     # get fm-mgr version
99
-    read x version <<< $(grep '^Version: ' ${GITDIR[$STX_FAULT_NAME]}/fm-mgr/PKG-INFO)
141
+    read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-mgr/PKG-INFO)
100 142
     local major=${version%%.*}
101 143
     local minor=${version##*.}
102 144
 
103
-    pushd ${GITDIR[$STX_FAULT_NAME]}/fm-mgr/sources
145
+    pushd $STX_FAULT_DIR/fm-mgr/sources
104 146
 
105 147
     sudo make \
106 148
         BIN_DIR=/bin \
@@ -120,13 +162,15 @@ function cleanup_fm_rest_api {
120 162
 function configure_fault {
121 163
     if is_service_enabled fm-rest-api; then
122 164
         configure_fm_rest_api
165
+        create_fault_user_group
166
+        create_fault_accounts
123 167
     fi
124 168
 }
125 169
 
126 170
 function configure_fm_rest_api {
127
-    sudo install -d -o $STACK_USER -m 755 $FAULT_CONF_DIR
171
+    sudo install -d -o $STACK_USER -m 755 $STX_FAULT_CONF_DIR
128 172
 
129
-    cp -p $FAULT_DIR/devstack/files/api-paste.ini $FM_RESTAPI_PASTE_INI
173
+    cp -p $STX_FAULT_DIR/devstack/files/api-paste.ini $FM_RESTAPI_PASTE_INI
130 174
 
131 175
     configure_auth_token_middleware $FM_RESTAPI_CONF fm $FM_RESTAPI_AUTH_CACHE_DIR
132 176
 
@@ -159,14 +203,12 @@ function configure_fm_rest_api {
159 203
 }
160 204
 
161 205
 function create_fault_accounts {
162
-    if [[ "$ENABLED_SERVICES" =~ "fm-rest-api" ]]; then
163
-        create_service_user "fm"
164
-        get_or_create_service "fm" "faultmanagement" "Fault Management Service"
165
-        get_or_create_endpoint \
166
-            "faultmanagement" \
167
-            "$REGION_NAME" \
168
-            "$FM_RESTAPI_SERVICE_PROTOCOL://$FM_RESTAPI_SERVICE_HOST:$FM_RESTAPI_SERVICE_PORT/v1"
169
-    fi
206
+    create_service_user "fm"
207
+    get_or_create_service "fm" "faultmanagement" "Fault Management Service"
208
+    get_or_create_endpoint \
209
+        "faultmanagement" \
210
+        "$REGION_NAME" \
211
+        "$FM_RESTAPI_SERVICE_PROTOCOL://$FM_RESTAPI_SERVICE_HOST:$FM_RESTAPI_SERVICE_PORT/v1"
170 212
 }
171 213
 
172 214
 function create_fault_cache_dir {
@@ -186,10 +228,9 @@ function init_fault {
186 228
 function install_fault {
187 229
     if is_service_enabled fm-common; then
188 230
         install_fm_common
189
-        install_fm_client
190 231
     fi
191
-    if is_service_enabled fm-api; then
192
-        install_fm_api
232
+    if is_service_enabled fm-client || is_service_enabled fm-common; then
233
+        install_fm_client
193 234
     fi
194 235
     if is_service_enabled fm-api; then
195 236
         install_fm_api
@@ -203,7 +244,7 @@ function install_fault {
203 244
 }
204 245
 
205 246
 function install_fm_api {
206
-    pushd ${GITDIR[$STX_FAULT_NAME]}/fm-api
247
+    pushd $STX_FAULT_DIR/fm-api
207 248
     sudo python setup.py install \
208 249
         --root=/ \
209 250
         --install-lib=$PYTHON_SITE_DIR \
@@ -214,7 +255,7 @@ function install_fm_api {
214 255
 }
215 256
 
216 257
 function install_fm_client {
217
-    pushd ${GITDIR[$STX_FAULT_NAME]}/python-fmclient/fmclient
258
+    pushd $STX_FAULT_DIR/python-fmclient/fmclient
218 259
     sudo python setup.py install \
219 260
         --root=/ \
220 261
         --install-lib=$PYTHON_SITE_DIR \
@@ -225,22 +266,21 @@ function install_fm_client {
225 266
 }
226 267
 
227 268
 function install_fm_common {
228
-    local x version
269
+    pushd $STX_FAULT_DIR/fm-common/sources
270
+
271
+    local major minor version x
229 272
 
230 273
     # get fm-common version
231
-    read x version <<< $(grep '^Version: ' ${GITDIR[$STX_FAULT_NAME]}/fm-common/PKG-INFO)
232
-    local major=${version%%.*}
233
-    local minor=${version##*.}
274
+    read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-common/PKG-INFO)
275
+    major=${version%%.*}
276
+    minor=${version##*.}
277
+
278
+    build_fm_common $major $minor
234 279
 
235 280
     # Set up the destinations
236 281
     # Making an assumption here about STX_BIN_DIR having ../include be valid
237 282
     local prefix=${STX_BIN_DIR%/*}
238 283
 
239
-    # build
240
-    pushd ${GITDIR[$STX_FAULT_NAME]}/fm-common/sources
241
-    make MAJOR=$major MINOR=$minor
242
-    sudo python setup.py build
243
-
244 284
     # install
245 285
     sudo make \
246 286
         DEST_DIR=$prefix \
@@ -273,16 +313,16 @@ function install_fm_common {
273 313
 }
274 314
 
275 315
 function install_fm_mgr {
276
-    local x version
316
+    pushd $STX_FAULT_DIR/fm-mgr/sources
317
+
318
+    local major minor version x
277 319
 
278 320
     # get fm-mgr version
279
-    read x version <<< $(grep '^Version: ' ${GITDIR[$STX_FAULT_NAME]}/fm-mgr/PKG-INFO)
280
-    local major=${version%%.*}
281
-    local minor=${version##*.}
321
+    read x version <<< $(grep '^Version: ' $STX_FAULT_DIR/fm-mgr/PKG-INFO)
322
+    major=${version%%.*}
323
+    minor=${version##*.}
282 324
 
283
-    # build
284
-    pushd ${GITDIR[$STX_FAULT_NAME]}/fm-mgr/sources
285
-    make MAJOR=$major MINOR=$minor
325
+    build_fm_mgr $major $minor
286 326
 
287 327
     # install
288 328
     sudo make \

+ 1
- 1
devstack/plugin.sh View File

@@ -3,7 +3,7 @@
3 3
 # devstack/plugin.sh
4 4
 # Triggers stx-fault specific functions to install and configure Fault Management
5 5
 
6
-echo_summary "fault devstack plugin.sh called: $1/$2"
6
+echo_summary "stx-fault devstack plugin.sh called: $1/$2"
7 7
 
8 8
 # check for service enabled
9 9
 if is_service_enabled stx-fault; then

+ 8
- 2
devstack/settings View File

@@ -1,6 +1,14 @@
1 1
 #!/bin/bash
2 2
 # Devstack settings
3 3
 
4
+# Services
5
+# stx-fault - Overall enable for this plugin
6
+# fm-client
7
+# fm-common
8
+# fm-api
9
+# fm-rest-api
10
+# fm-mgr
11
+
4 12
 # Defaults
5 13
 # --------
6 14
 
@@ -8,9 +16,7 @@ STX_FAULT_NAME=stx-fault
8 16
 
9 17
 ######### Plugin Specific ##########
10 18
 enable_service $STX_FAULT_NAME
11
-#define_plugin $STX_FAULT_NAME
12 19
 
13
-# Handle STX pre-reqs
14 20
 if is_service_enabled fm-rest-api; then
15 21
     enable_service tsconfig
16 22
 fi

+ 4
- 0
tox.ini View File

@@ -104,6 +104,10 @@ commands =
104 104
   sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html
105 105
 whitelist_externals = rm
106 106
 
107
+[testenv:build]
108
+deps =
109
+commands = {toxinidir}/devstack/build.sh
110
+
107 111
 [testenv:functional]
108 112
 basepython = python3
109 113
 whitelist_externals = cat

Loading…
Cancel
Save