openstack-barbican-api: cleanup unused files
[pti/rtp.git] / meta-stx / recipes-devtools / python / python-barbican_git.bb
1 #
2 ## Copyright (C) 2019 Wind River Systems, Inc.
3 #
4 #  Licensed under the Apache License, Version 2.0 (the "License");
5 #  you may not use this file except in compliance with the License.
6 #  You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #  Unless required by applicable law or agreed to in writing, software
11 #  distributed under the License is distributed on an "AS IS" BASIS,
12 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #  See the License for the specific language governing permissions and
14 #  limitations under the License.
15
16 DESCRIPTION = "Barbican is a ReST API designed for the secure storage, provisioning and management of secrets."
17 HOMEPAGE = "https://wiki.openstack.org/wiki/Barbican"
18 SECTION = "devel/python"
19 LICENSE = "Apache-2.0"
20 LIC_FILES_CHKSUM = "file://LICENSE;md5=fc8be9e7dffe97390d1216b01fd0be01"
21
22 PR = "r0"
23 SRCNAME = "barbican"
24 BARBICAN_MAX_PACKET_SIZE ?= "65535"
25
26 SRC_URI = " \
27         git://github.com/openstack/barbican.git;branch=${BRANCH} \
28         file://${BPN}/barbican-fix-path-to-find-configuration-files.patch \
29         file://${BPN}/openstack-barbican-api.service \
30         file://${BPN}/openstack-barbican-worker.service \
31         file://${BPN}/openstack-barbican-keystone-listener.service \
32         file://${BPN}/gunicorn-config.py \
33         "
34
35 SRCREV = "4c0ddda941289fba8e5ec4341b5d02d155d46162"
36 BRANCH = "stable/stein"
37 PV = "8.0.0+git${SRCPV}"
38 S = "${WORKDIR}/git"
39
40 inherit update-rc.d setuptools identity hosts useradd default_configs monitor systemd
41
42 SYSTEMD_SERVICE_${SRCNAME} = " \
43         openstack-barbican-api.service \
44         openstack-barbican-worker.service \
45         openstack-barbican-keystone-listener.service \
46         "
47
48 SYSTEMD_AUTO_ENABLE_${SRCNAME} = "disable"
49
50 SERVICECREATE_PACKAGES = "${SRCNAME}-setup"
51 KEYSTONE_HOST="${CONTROLLER_IP}"
52
53 # USERCREATE_PARAM and SERVICECREATE_PARAM contain the list of parameters to be set.
54 # If the flag for a parameter in the list is not set here, the default value will be given to that parameter.
55 # Parameters not in the list will be set to empty.
56
57 USERCREATE_PARAM_${SRCNAME}-setup = "name pass tenant role email"
58 SERVICECREATE_PARAM_${SRCNAME}-setup = "name type description region publicurl adminurl internalurl"
59 python () {
60     flags = {'type':'keystore',\
61              'description':'Barbican Key Management Service',\
62              'publicurl':"'http://${KEYSTONE_HOST}:9311/v1'",\
63              'adminurl':"'http://${KEYSTONE_HOST}:9312/v1'",\
64              'internalurl':"'http://${KEYSTONE_HOST}:9313/v1'"}
65     d.setVarFlags("SERVICECREATE_PARAM_%s-setup" % d.getVar('SRCNAME',True), flags)
66 }
67 SERVICECREATE_PACKAGES[vardeps] += "KEYSTONE_HOST"
68
69 do_install_append() {
70     TEMPLATE_CONF_DIR=${S}${sysconfdir}/${SRCNAME}
71     BARBICAN_CONF_DIR=${D}${sysconfdir}/${SRCNAME}
72
73     install -d ${BARBICAN_CONF_DIR}
74     cp -r ${TEMPLATE_CONF_DIR}/* ${BARBICAN_CONF_DIR}
75
76     install -d ${D}${localstatedir}/lib/barbican
77
78     # Install the systemd service files
79     install -d ${D}${systemd_system_unitdir}/
80     install -m 644 ${WORKDIR}/${BPN}/*.service ${D}${systemd_system_unitdir}
81
82     # python-gunicorn and gunicorn-config.py are required by openstack-barbican-api.service
83     install -m 644 ${WORKDIR}/${PN}/gunicorn-config.py ${BARBICAN_CONF_DIR}
84
85     # Modify barbican-api-paste.ini for gunicorn
86     echo '[server:main]' >> ${BARBICAN_CONF_DIR}/barbican-api-paste.ini
87     echo 'use = egg:gunicorn#main' >> ${BARBICAN_CONF_DIR}/barbican-api-paste.ini
88
89     sed -e "s:%BARBICAN_CONF_DIR%:${sysconfdir}/${SRCNAME}:g" \
90         -i ${D}/${PYTHON_SITEPACKAGES_DIR}/${SRCNAME}/tests/api/test_resources_policy.py
91
92     install -m 0755 -d ${D}/${sysconfdir}/tmpfiles.d
93     echo "d ${localstatedir}/log/barbican 0750 barbican barbican -" >> ${D}/${sysconfdir}/tmpfiles.d/barbican.conf
94 }
95
96 USERADD_PACKAGES = "${PN}"
97 GROUPADD_PARAM_${PN} = "--system barbican"
98 USERADD_PARAM_${PN}  = "--system --home /var/lib/barbican -g barbican \
99                         --no-create-home --shell /bin/false barbican"
100
101 PACKAGES += "${SRCNAME} \
102              ${SRCNAME}-setup "
103
104 FILES_${PN} = "${libdir}/* \
105 "
106 FILES_${SRCNAME} = "${sysconfdir}/${SRCNAME}/* \
107                     ${sysconfdir}/init.d/barbican-api \
108                     ${bindir} \
109                     ${bindir}/* \
110                     ${localstatedir}/* \
111                     ${systemd_system_unitdir} \
112                     ${sysconfdir}/tmpfiles.d/barbican.conf \
113 "
114
115 ALLOW_EMPTY_${SRCNAME}-setup = "1"
116 pkg_postinst_${SRCNAME}-setup () {
117     if [ -z "$D" ]; then
118         chown -R barbican:barbican ${sysconfdir}/${SRCNAME}
119         chown -R barbican:barbican ${localstatedir}/lib/barbican
120     fi
121 }
122
123 DEPENDS += " \
124         python-pip \
125         python-pbr-native \
126         "
127
128 RDEPENDS_${SRCNAME} = "${PN} \
129                        ${SRCNAME}-setup \
130                        uwsgi \
131                        python-falcon \
132                        python-oslo.messaging"
133
134 RDEPENDS_${PN} += " \
135         python-pip \
136         python-pbr \
137         python-alembic \
138         python-babel \
139         python-eventlet \
140         python-falcon \
141         python-iso8601 \
142         python-jsonschema \
143         python-kombu \
144         python-netaddr \
145         python-pastedeploy \
146         python-paste \
147         python-pycrypto \
148         python-keystoneclient \
149         python-sqlalchemy \
150         python-stevedore \
151         python-webob \
152         python-wsgiref \
153         python-barbicanclient \
154         python-gunicorn \
155         python-castellan \
156         python-ldap3 \
157         "
158
159 INITSCRIPT_PACKAGES = "${SRCNAME}"
160 INITSCRIPT_NAME_${SRCNAME} = "barbican-api"
161 INITSCRIPT_PARAMS_${SRCNAME} = "${OS_DEFAULT_INITSCRIPT_PARAMS}"
162
163 MONITOR_SERVICE_PACKAGES = "${SRCNAME}"
164 MONITOR_SERVICE_${SRCNAME} = "barbican"
165
166
167 FILES_${PN}_append = " ${datadir}/"