diff options
author | Vu Tran <vu.tran@windriver.com> | 2014-04-09 19:59:09 -0400 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2014-04-11 14:15:28 -0400 |
commit | 322d51de8417142c6ffbf024b198b26069a53f46 (patch) | |
tree | 7dc20eedcd969ecff64b57061a5263387fe1b424 /meta-openstack/recipes-devtools/python/python-swift_git.bb | |
parent | c173214e9c25409944144c9b4bd9892949a834ba (diff) | |
download | meta-cloud-services-322d51de8417142c6ffbf024b198b26069a53f46.tar.gz |
swift: add setup package
Introduce swift setup package. At boot time, this
package setups a simple swift cluster including:
* 3 zones
* each zone has 1 storage device which are based
on loopback devices which the backing files size
is controlled by variable SWIFT_BACKING_FILE_SIZE
The script /etc/swift/swift_setup.sh is also provided to ease
the task of setting up a complicated Swift cluster. It reads a
cluster config file, which describes what storage devices are
included in what rings, and constructs the cluster.
For details of how to use swift_setup.sh and the format
of Swift cluster config file please refer to the
script's help:
$ swift_setup.sh
Signed-off-by: Vu Tran <vu.tran@windriver.com>
Diffstat (limited to 'meta-openstack/recipes-devtools/python/python-swift_git.bb')
-rw-r--r-- | meta-openstack/recipes-devtools/python/python-swift_git.bb | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-swift_git.bb b/meta-openstack/recipes-devtools/python/python-swift_git.bb index 6ab147d..680dbc3 100644 --- a/meta-openstack/recipes-devtools/python/python-swift_git.bb +++ b/meta-openstack/recipes-devtools/python/python-swift_git.bb | |||
@@ -11,18 +11,29 @@ SRC_URI = "git://github.com/openstack/${SRCNAME}.git;branch=stable/havana \ | |||
11 | file://proxy-server.conf \ | 11 | file://proxy-server.conf \ |
12 | file://dispersion.conf \ | 12 | file://dispersion.conf \ |
13 | file://test.conf \ | 13 | file://test.conf \ |
14 | file://swift.init \ | ||
15 | file://swift_setup.sh \ | ||
16 | file://cluster.conf \ | ||
14 | " | 17 | " |
15 | 18 | ||
16 | SRCREV="2f3526c559fe53ce904b735a81dee6de46127176" | 19 | SRCREV="2f3526c559fe53ce904b735a81dee6de46127176" |
17 | PV="2013.2.2+git${SRCPV}" | 20 | PV="2013.2.2+git${SRCPV}" |
18 | S = "${WORKDIR}/git" | 21 | S = "${WORKDIR}/git" |
19 | 22 | ||
20 | inherit setuptools python-dir hosts identity | 23 | inherit setuptools python-dir update-rc.d hosts identity |
24 | |||
25 | # The size of the backing file (in Gigabytes) of loopback devices | ||
26 | # which are used for setting up Swift storage devices. The value | ||
27 | # of "0G" is for disabling loopback devices and using local | ||
28 | # filesystem as Swift storage device. In this case, the local | ||
29 | # filesystem of must support xattrs. e.g ext4 | ||
30 | SWIFT_BACKING_FILE_SIZE ?= "2G" | ||
21 | 31 | ||
22 | do_install_append() { | 32 | do_install_append() { |
23 | SWIFT_CONF_DIR=${D}${sysconfdir}/swift | 33 | SWIFT_CONF_DIR=${D}${sysconfdir}/swift |
24 | 34 | ||
25 | install -d ${SWIFT_CONF_DIR} | 35 | install -d ${SWIFT_CONF_DIR} |
36 | install -d ${D}${sysconfdir}/init.d/ | ||
26 | 37 | ||
27 | install -m 600 ${S}/etc/swift.conf-sample ${SWIFT_CONF_DIR}/swift.conf | 38 | install -m 600 ${S}/etc/swift.conf-sample ${SWIFT_CONF_DIR}/swift.conf |
28 | install -m 600 ${WORKDIR}/proxy-server.conf ${SWIFT_CONF_DIR}/proxy-server.conf | 39 | install -m 600 ${WORKDIR}/proxy-server.conf ${SWIFT_CONF_DIR}/proxy-server.conf |
@@ -31,6 +42,9 @@ do_install_append() { | |||
31 | install -m 600 ${S}/etc/object-server.conf-sample ${SWIFT_CONF_DIR}/object-server.conf | 42 | install -m 600 ${S}/etc/object-server.conf-sample ${SWIFT_CONF_DIR}/object-server.conf |
32 | install -m 600 ${WORKDIR}/dispersion.conf ${SWIFT_CONF_DIR}/dispersion.conf | 43 | install -m 600 ${WORKDIR}/dispersion.conf ${SWIFT_CONF_DIR}/dispersion.conf |
33 | install -m 600 ${WORKDIR}/test.conf ${SWIFT_CONF_DIR}/test.conf | 44 | install -m 600 ${WORKDIR}/test.conf ${SWIFT_CONF_DIR}/test.conf |
45 | install -m 755 ${WORKDIR}/swift.init ${D}${sysconfdir}/init.d/swift | ||
46 | install -m 700 ${WORKDIR}/swift_setup.sh ${SWIFT_CONF_DIR}/swift_setup.sh | ||
47 | install -m 600 ${WORKDIR}/cluster.conf ${SWIFT_CONF_DIR}/cluster.conf | ||
34 | 48 | ||
35 | sed 's/^# bind_port =.*/bind_port = 6002/' -i ${SWIFT_CONF_DIR}/account-server.conf | 49 | sed 's/^# bind_port =.*/bind_port = 6002/' -i ${SWIFT_CONF_DIR}/account-server.conf |
36 | sed 's/^# user =.*/user = root/' -i ${SWIFT_CONF_DIR}/account-server.conf | 50 | sed 's/^# user =.*/user = root/' -i ${SWIFT_CONF_DIR}/account-server.conf |
@@ -71,7 +85,32 @@ do_install_append() { | |||
71 | grep -rl '^from test' ${D}/${PYTHON_SITEPACKAGES_DIR}/${SRCNAME}/test | xargs sed 's/^from test/from swift\.test/g' -i | 85 | grep -rl '^from test' ${D}/${PYTHON_SITEPACKAGES_DIR}/${SRCNAME}/test | xargs sed 's/^from test/from swift\.test/g' -i |
72 | } | 86 | } |
73 | 87 | ||
74 | PACKAGES += "${SRCNAME}-tests ${SRCNAME}" | 88 | pkg_postinst_${SRCNAME}-setup () { |
89 | if [ "x$D" != "x" ]; then | ||
90 | exit 1 | ||
91 | fi | ||
92 | |||
93 | CLUSTER_CONF=/etc/swift/cluster.conf | ||
94 | SWIFT_SETUP='/bin/bash /etc/swift/swift_setup.sh' | ||
95 | |||
96 | for i in `seq 1 3`; do | ||
97 | BACKING_FILE=/etc/swift/swift_backing_$i | ||
98 | if [ "x${SWIFT_BACKING_FILE_SIZE}" != "x0G" ]; then | ||
99 | truncate -s ${SWIFT_BACKING_FILE_SIZE} $BACKING_FILE | ||
100 | sed "s:%SWIFT_BACKING_FILE_${i}%:$BACKING_FILE:g" -i $CLUSTER_CONF | ||
101 | else | ||
102 | sed "s:%SWIFT_BACKING_FILE_${i}%::g" -i $CLUSTER_CONF | ||
103 | fi | ||
104 | done | ||
105 | |||
106 | $SWIFT_SETUP createrings | ||
107 | $SWIFT_SETUP formatdevs | ||
108 | $SWIFT_SETUP mountdevs | ||
109 | $SWIFT_SETUP -i "${CONTROLLER_IP}" adddevs | ||
110 | $SWIFT_SETUP unmountdevs | ||
111 | } | ||
112 | |||
113 | PACKAGES += "${SRCNAME}-tests ${SRCNAME} ${SRCNAME}-setup" | ||
75 | 114 | ||
76 | FILES_${PN} = "${libdir}/*\ | 115 | FILES_${PN} = "${libdir}/*\ |
77 | " | 116 | " |
@@ -79,6 +118,11 @@ FILES_${PN} = "${libdir}/*\ | |||
79 | FILES_${SRCNAME}-tests = "${sysconfdir}/${SRCNAME}/test.conf \ | 118 | FILES_${SRCNAME}-tests = "${sysconfdir}/${SRCNAME}/test.conf \ |
80 | " | 119 | " |
81 | 120 | ||
121 | FILES_${SRCNAME}-setup = "${sysconfdir}/init.d/swift \ | ||
122 | ${sysconfdir}/${SRCNAME}/swift_setup.sh \ | ||
123 | ${sysconfdir}/${SRCNAME}/cluster.conf \ | ||
124 | " | ||
125 | |||
82 | FILES_${SRCNAME} = "${bindir}/* \ | 126 | FILES_${SRCNAME} = "${bindir}/* \ |
83 | ${sysconfdir}/${SRCNAME}/* \ | 127 | ${sysconfdir}/${SRCNAME}/* \ |
84 | " | 128 | " |
@@ -101,3 +145,10 @@ RDEPENDS_${PN} += " \ | |||
101 | " | 145 | " |
102 | 146 | ||
103 | RDEPENDS_${SRCNAME} = "${PN}" | 147 | RDEPENDS_${SRCNAME} = "${PN}" |
148 | |||
149 | RDEPENDS_${SRCNAME} = "${PN}" | ||
150 | RDEPENDS_${SRCNAME}-setup = "${SRCNAME}" | ||
151 | |||
152 | INITSCRIPT_PACKAGES = "${SRCNAME}-setup" | ||
153 | INITSCRIPT_NAME_${SRCNAME}-setup = "swift" | ||
154 | INITSCRIPT_PARAMS_${SRCNAME}-setup = "defaults" | ||