| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,118 @@ |
| 0 |
+# lib/n-vol |
|
| 1 |
+# Install and start Nova volume service |
|
| 2 |
+ |
|
| 3 |
+# Dependencies: |
|
| 4 |
+# - functions |
|
| 5 |
+# - KEYSTONE_AUTH_* must be defined |
|
| 6 |
+# SERVICE_{TENANT_NAME|PASSWORD} must be defined
|
|
| 7 |
+ |
|
| 8 |
+# stack.sh |
|
| 9 |
+# --------- |
|
| 10 |
+# install_nvol |
|
| 11 |
+# configure_nvol |
|
| 12 |
+# init_nvol |
|
| 13 |
+# start_nvol |
|
| 14 |
+# stop_nvol |
|
| 15 |
+# cleanup_nvol |
|
| 16 |
+ |
|
| 17 |
+# Print the commands being run so that we can see the command that triggers |
|
| 18 |
+# an error. It is also useful for following along as the install occurs. |
|
| 19 |
+set -o xtrace |
|
| 20 |
+ |
|
| 21 |
+ |
|
| 22 |
+# Defaults |
|
| 23 |
+# -------- |
|
| 24 |
+ |
|
| 25 |
+# Name of the LVM volume group to use/create for iscsi volumes |
|
| 26 |
+VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes}
|
|
| 27 |
+VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-}
|
|
| 28 |
+ |
|
| 29 |
+ |
|
| 30 |
+# cleanup_nvol() - Remove residual data files, anything left over from previous |
|
| 31 |
+# runs that a clean run would need to clean up |
|
| 32 |
+function cleanup_nvol() {
|
|
| 33 |
+ # kill instances (nova) |
|
| 34 |
+ # delete image files (glance) |
|
| 35 |
+ # This function intentionally left blank |
|
| 36 |
+ : |
|
| 37 |
+} |
|
| 38 |
+ |
|
| 39 |
+# configure_nvol() - Set config files, create data dirs, etc |
|
| 40 |
+function configure_nvol() {
|
|
| 41 |
+ # sudo python setup.py deploy |
|
| 42 |
+ # iniset $XXX_CONF ... |
|
| 43 |
+ # This function intentionally left blank |
|
| 44 |
+ : |
|
| 45 |
+} |
|
| 46 |
+ |
|
| 47 |
+# init_nvol() - Initialize databases, etc. |
|
| 48 |
+function init_nvol() {
|
|
| 49 |
+ # Configure a default volume group called '`stack-volumes`' for the volume |
|
| 50 |
+ # service if it does not yet exist. If you don't wish to use a file backed |
|
| 51 |
+ # volume group, create your own volume group called ``stack-volumes`` before |
|
| 52 |
+ # invoking ``stack.sh``. |
|
| 53 |
+ # |
|
| 54 |
+ # By default, the backing file is 5G in size, and is stored in ``/opt/stack/data``. |
|
| 55 |
+ |
|
| 56 |
+ if ! sudo vgs $VOLUME_GROUP; then |
|
| 57 |
+ VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-$DATA_DIR/${VOLUME_GROUP}-backing-file}
|
|
| 58 |
+ # Only create if the file doesn't already exists |
|
| 59 |
+ [[ -f $VOLUME_BACKING_FILE ]] || truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE |
|
| 60 |
+ DEV=`sudo losetup -f --show $VOLUME_BACKING_FILE` |
|
| 61 |
+ # Only create if the loopback device doesn't contain $VOLUME_GROUP |
|
| 62 |
+ if ! sudo vgs $VOLUME_GROUP; then sudo vgcreate $VOLUME_GROUP $DEV; fi |
|
| 63 |
+ fi |
|
| 64 |
+ |
|
| 65 |
+ mkdir -p $NOVA_DIR/volumes |
|
| 66 |
+ |
|
| 67 |
+ if sudo vgs $VOLUME_GROUP; then |
|
| 68 |
+ if [[ "$os_PACKAGE" = "rpm" ]]; then |
|
| 69 |
+ # RPM doesn't start the service |
|
| 70 |
+ start_service tgtd |
|
| 71 |
+ fi |
|
| 72 |
+ |
|
| 73 |
+ # Remove nova iscsi targets |
|
| 74 |
+ sudo tgtadm --op show --mode target | grep $VOLUME_NAME_PREFIX | grep Target | cut -f3 -d ' ' | sudo xargs -n1 tgt-admin --delete || true |
|
| 75 |
+ # Clean out existing volumes |
|
| 76 |
+ for lv in `sudo lvs --noheadings -o lv_name $VOLUME_GROUP`; do |
|
| 77 |
+ # ``VOLUME_NAME_PREFIX`` prefixes the LVs we want |
|
| 78 |
+ if [[ "${lv#$VOLUME_NAME_PREFIX}" != "$lv" ]]; then
|
|
| 79 |
+ sudo lvremove -f $VOLUME_GROUP/$lv |
|
| 80 |
+ fi |
|
| 81 |
+ done |
|
| 82 |
+ fi |
|
| 83 |
+} |
|
| 84 |
+ |
|
| 85 |
+# install_nvol() - Collect source and prepare |
|
| 86 |
+function install_nvol() {
|
|
| 87 |
+ # git clone xxx |
|
| 88 |
+ # Install is handled when installing Nova |
|
| 89 |
+ : |
|
| 90 |
+} |
|
| 91 |
+ |
|
| 92 |
+# start_nvol() - Start running processes, including screen |
|
| 93 |
+function start_nvol() {
|
|
| 94 |
+ # Setup the tgt configuration file |
|
| 95 |
+ if [[ ! -f /etc/tgt/conf.d/nova.conf ]]; then |
|
| 96 |
+ sudo mkdir -p /etc/tgt/conf.d |
|
| 97 |
+ echo "include $NOVA_DIR/volumes/*" | sudo tee /etc/tgt/conf.d/nova.conf |
|
| 98 |
+ fi |
|
| 99 |
+ |
|
| 100 |
+ if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 101 |
+ # tgt in oneiric doesn't restart properly if tgtd isn't running |
|
| 102 |
+ # do it in two steps |
|
| 103 |
+ sudo stop tgt || true |
|
| 104 |
+ sudo start tgt |
|
| 105 |
+ else |
|
| 106 |
+ restart_service tgtd |
|
| 107 |
+ fi |
|
| 108 |
+ |
|
| 109 |
+ screen_it n-vol "cd $NOVA_DIR && $NOVA_DIR/bin/nova-volume" |
|
| 110 |
+} |
|
| 111 |
+ |
|
| 112 |
+# stop_nvol() - Stop running processes (non-screen) |
|
| 113 |
+function stop_nvol() {
|
|
| 114 |
+ # FIXME(dtroyer): stop only the n-vol screen window? |
|
| 115 |
+ |
|
| 116 |
+ stop_service tgt |
|
| 117 |
+} |
| ... | ... |
@@ -267,6 +267,7 @@ sudo chown `whoami` $DATA_DIR |
| 267 | 267 |
|
| 268 | 268 |
# Get project function libraries |
| 269 | 269 |
source $TOP_DIR/lib/cinder |
| 270 |
+source $TOP_DIR/lib/n-vol |
|
| 270 | 271 |
source $TOP_DIR/lib/ceilometer |
| 271 | 272 |
source $TOP_DIR/lib/heat |
| 272 | 273 |
|
| ... | ... |
@@ -1743,57 +1744,7 @@ fi |
| 1743 | 1743 |
if is_service_enabled cinder; then |
| 1744 | 1744 |
init_cinder |
| 1745 | 1745 |
elif is_service_enabled n-vol; then |
| 1746 |
- # Configure a default volume group called '`stack-volumes`' for the volume |
|
| 1747 |
- # service if it does not yet exist. If you don't wish to use a file backed |
|
| 1748 |
- # volume group, create your own volume group called ``stack-volumes`` before |
|
| 1749 |
- # invoking ``stack.sh``. |
|
| 1750 |
- # |
|
| 1751 |
- # By default, the backing file is 5G in size, and is stored in ``/opt/stack/data``. |
|
| 1752 |
- |
|
| 1753 |
- if ! sudo vgs $VOLUME_GROUP; then |
|
| 1754 |
- VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-$DATA_DIR/${VOLUME_GROUP}-backing-file}
|
|
| 1755 |
- # Only create if the file doesn't already exists |
|
| 1756 |
- [[ -f $VOLUME_BACKING_FILE ]] || truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE |
|
| 1757 |
- DEV=`sudo losetup -f --show $VOLUME_BACKING_FILE` |
|
| 1758 |
- # Only create if the loopback device doesn't contain $VOLUME_GROUP |
|
| 1759 |
- if ! sudo vgs $VOLUME_GROUP; then sudo vgcreate $VOLUME_GROUP $DEV; fi |
|
| 1760 |
- fi |
|
| 1761 |
- |
|
| 1762 |
- if sudo vgs $VOLUME_GROUP; then |
|
| 1763 |
- if [[ "$os_PACKAGE" = "rpm" ]]; then |
|
| 1764 |
- # RPM doesn't start the service |
|
| 1765 |
- start_service tgtd |
|
| 1766 |
- fi |
|
| 1767 |
- |
|
| 1768 |
- # Setup tgtd configuration files |
|
| 1769 |
- mkdir -p $NOVA_DIR/volumes |
|
| 1770 |
- |
|
| 1771 |
- # Remove nova iscsi targets |
|
| 1772 |
- sudo tgtadm --op show --mode target | grep $VOLUME_NAME_PREFIX | grep Target | cut -f3 -d ' ' | sudo xargs -n1 tgt-admin --delete || true |
|
| 1773 |
- # Clean out existing volumes |
|
| 1774 |
- for lv in `sudo lvs --noheadings -o lv_name $VOLUME_GROUP`; do |
|
| 1775 |
- # ``VOLUME_NAME_PREFIX`` prefixes the LVs we want |
|
| 1776 |
- if [[ "${lv#$VOLUME_NAME_PREFIX}" != "$lv" ]]; then
|
|
| 1777 |
- sudo lvremove -f $VOLUME_GROUP/$lv |
|
| 1778 |
- fi |
|
| 1779 |
- done |
|
| 1780 |
- fi |
|
| 1781 |
- |
|
| 1782 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 1783 |
- |
|
| 1784 |
- # Setup the tgt configuration file |
|
| 1785 |
- if [[ ! -f /etc/tgt/conf.d/nova.conf ]]; then |
|
| 1786 |
- sudo mkdir -p /etc/tgt/conf.d |
|
| 1787 |
- echo "include $NOVA_DIR/volumes/*" | sudo tee /etc/tgt/conf.d/nova.conf |
|
| 1788 |
- fi |
|
| 1789 |
- |
|
| 1790 |
- # tgt in oneiric doesn't restart properly if tgtd isn't running |
|
| 1791 |
- # do it in two steps |
|
| 1792 |
- sudo stop tgt || true |
|
| 1793 |
- sudo start tgt |
|
| 1794 |
- else |
|
| 1795 |
- restart_service tgtd |
|
| 1796 |
- fi |
|
| 1746 |
+ init_nvol |
|
| 1797 | 1747 |
fi |
| 1798 | 1748 |
|
| 1799 | 1749 |
# Support entry points installation of console scripts |
| ... | ... |
@@ -2169,12 +2120,14 @@ fi |
| 2169 | 2169 |
# ``screen_it`` checks ``is_service_enabled``, it is not needed here |
| 2170 | 2170 |
screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_BIN_DIR/nova-compute" |
| 2171 | 2171 |
screen_it n-crt "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cert" |
| 2172 |
-screen_it n-vol "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-volume" |
|
| 2173 | 2172 |
screen_it n-net "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-network" |
| 2174 | 2173 |
screen_it n-sch "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-scheduler" |
| 2175 | 2174 |
screen_it n-novnc "cd $NOVNC_DIR && ./utils/nova-novncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF --web ." |
| 2176 | 2175 |
screen_it n-xvnc "cd $NOVA_DIR && ./bin/nova-xvpvncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF" |
| 2177 | 2176 |
screen_it n-cauth "cd $NOVA_DIR && ./bin/nova-consoleauth" |
| 2177 |
+if is_service_enabled n-vol; then |
|
| 2178 |
+ start_nvol |
|
| 2179 |
+fi |
|
| 2178 | 2180 |
if is_service_enabled cinder; then |
| 2179 | 2181 |
start_cinder |
| 2180 | 2182 |
fi |