80f3fdf773ec59f8d70268ed043f7b17c93c885a
[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
93 USERADD_PACKAGES = "${PN}"
94 GROUPADD_PARAM_${PN} = "--system barbican"
95 USERADD_PARAM_${PN}  = "--system --home /var/lib/barbican -g barbican \
96                         --no-create-home --shell /bin/false barbican"
97
98 PACKAGES += "${SRCNAME} \
99              ${SRCNAME}-setup "
100
101 FILES_${PN} = "${libdir}/* \
102 "
103 FILES_${SRCNAME} = "${sysconfdir}/${SRCNAME}/* \
104                     ${sysconfdir}/init.d/barbican-api \
105                     ${bindir} \
106                     ${bindir}/* \
107                     ${localstatedir}/* \
108                     ${systemd_system_unitdir} \
109 "
110
111 ALLOW_EMPTY_${SRCNAME}-setup = "1"
112 pkg_postinst_${SRCNAME}-setup () {
113     if [ -z "$D" ]; then
114         chown -R barbican:barbican ${sysconfdir}/${SRCNAME}
115         chown -R barbican:barbican ${localstatedir}/lib/barbican
116     fi
117 }
118
119 DEPENDS += " \
120         python-pip \
121         python-pbr-native \
122         "
123 # Stx config files
124 DEPENDS += " \
125         openstack-barbican-api \
126         "
127
128
129 RDEPENDS_${SRCNAME} = "${PN} \
130                        ${SRCNAME}-setup \
131                        uwsgi \
132                        python-falcon \
133                        python-oslo.messaging"
134
135 RDEPENDS_${PN} += " \
136         python-pip \
137         python-pbr \
138         python-alembic \
139         python-babel \
140         python-eventlet \
141         python-falcon \
142         python-iso8601 \
143         python-jsonschema \
144         python-kombu \
145         python-netaddr \
146         python-pastedeploy \
147         python-paste \
148         python-pycrypto \
149         python-pysqlite \
150         python-keystoneclient \
151         python-sqlalchemy \
152         python-stevedore \
153         python-webob \
154         python-wsgiref \
155         python-barbicanclient \
156         python-gunicorn \
157         python-castellan \
158         python-ldap3 \
159         "
160
161 INITSCRIPT_PACKAGES = "${SRCNAME}"
162 INITSCRIPT_NAME_${SRCNAME} = "barbican-api"
163 INITSCRIPT_PARAMS_${SRCNAME} = "${OS_DEFAULT_INITSCRIPT_PARAMS}"
164
165 MONITOR_SERVICE_PACKAGES = "${SRCNAME}"
166 MONITOR_SERVICE_${SRCNAME} = "barbican"
167
168
169 FILES_${PN}_append = " ${datadir}/"