|
45 | 45 | [DEFAULT] |
46 | 46 | transport_url = rabbit://openstack:openstack@controller |
47 | 47 | auth_strategy = keystone |
48 | | - my_ip = controller |
| 48 | + my_ip = 10.0.0.20 |
49 | 49 | enabled_backends = lvm |
50 | 50 | volumes_dir = /var/lib/cinder/volumes |
51 | 51 | state_path = /var/lib/cinder |
|
76 | 76 | volume_backend_name = lvm |
77 | 77 | lvm_type = default |
78 | 78 | target_protocol = iscsi |
| 79 | + target_helper = tgtadm |
| 80 | + ''; |
| 81 | + |
| 82 | + cinderTgtConf = pkgs.writeText "cinder.conf" '' |
| 83 | + include /var/lib/cinder/volumes/* |
79 | 84 | ''; |
80 | 85 | in |
81 | 86 | { |
|
140 | 145 | mode = "0755"; |
141 | 146 | }; |
142 | 147 | }; |
| 148 | + "/etc/cinder/cinder.conf" = { |
| 149 | + L = { |
| 150 | + argument = "${cinderConf}"; |
| 151 | + }; |
| 152 | + }; |
| 153 | + "/etc/tgt/conf.d/cinder.conf" = { |
| 154 | + L = { |
| 155 | + argument = "${cinderTgtConf}"; |
| 156 | + }; |
| 157 | + }; |
| 158 | + "/etc/tgt/targets.conf" = { |
| 159 | + L = { |
| 160 | + argument = "${pkgs.tgt}/etc/tgt/targets.conf"; |
| 161 | + }; |
| 162 | + }; |
| 163 | + }; |
| 164 | + }; |
| 165 | + |
| 166 | + # start iSCSI target daemon |
| 167 | + # we expose LVM block storage as iSCSI to compute hosts |
| 168 | + systemd.services.tgtd = { |
| 169 | + enable = true; |
| 170 | + description = "iSCSI target framework daemon"; |
| 171 | + wantedBy = [ "multi-user.target" ]; |
| 172 | + after = [ |
| 173 | + "network.target" |
| 174 | + "cinder-volume-group-setup.service" |
| 175 | + ]; |
| 176 | + path = [ |
| 177 | + pkgs.coreutils |
| 178 | + pkgs.tgt |
| 179 | + ]; |
| 180 | + environment.TGTD_CONFIG = "/etc/tgt/targets.conf"; |
| 181 | + serviceConfig = { |
| 182 | + ExecStart = "${pkgs.tgt}/bin/tgtd"; |
| 183 | + ExecStartPost = [ |
| 184 | + "${pkgs.coreutils}/bin/sleep 5" |
| 185 | + "${pkgs.tgt}/bin/tgtadm --op update --mode sys --name State -v offline" |
| 186 | + "${pkgs.tgt}/bin/tgtadm --op update --mode sys --name State -v ready" |
| 187 | + "${pkgs.tgt}/bin/tgt-admin -e -c $TGTD_CONFIG" |
| 188 | + ]; |
| 189 | + |
| 190 | + ExecReload = "${pkgs.tgt}/bin/tgt-admin --update ALL -f -c $TGTD_CONFIG"; |
| 191 | + |
| 192 | + ExecStop = [ |
| 193 | + "${pkgs.tgt}/bin/tgtadm --op update --mode sys --name State -v offline" |
| 194 | + "${pkgs.tgt}/bin/tgt-admin --offline ALL" |
| 195 | + "${pkgs.tgt}/bin/tgt-admin --update ALL -c /dev/null -f" |
| 196 | + "${pkgs.tgt}/bin/tgtadm --op delete --mode system" |
| 197 | + ]; |
143 | 198 | }; |
144 | 199 | }; |
145 | 200 |
|
146 | | - systemd.services.cinder-volume-group = { |
| 201 | + systemd.services.cinder-volume-group-setup = { |
147 | 202 | description = "OpenStack Cinder volume group setup"; |
148 | 203 | wantedBy = [ "multi-user.target" ]; |
149 | 204 | path = [ |
|
155 | 210 | ExecStart = pkgs.writeShellScript "cinder-volume-group.sh" '' |
156 | 211 | set -euxo pipefail |
157 | 212 |
|
158 | | - # Setup some lvm volume group required by cinder |
159 | | - dd if=/dev/zero of=/tmp/cinder-volumes bs=1G count=2 |
160 | | -
|
161 | | - losetup /dev/loop0 /tmp/cinder-volumes |
162 | | -
|
163 | | - # Create physical volume and volume group |
164 | | - pvcreate /dev/loop0 |
165 | | - vgcreate cinder-volumes /dev/loop0 |
| 213 | + # create a new LVM volume group on second disk |
| 214 | + pvcreate /dev/vdb |
| 215 | + vgcreate cinder-volumes /dev/vdb |
166 | 216 | ''; |
167 | 217 | }; |
168 | 218 | }; |
|
173 | 223 | # Update: still does not work -.- |
174 | 224 | environment.systemPackages = [ |
175 | 225 | pkgs.qemu |
| 226 | + pkgs.tgt |
176 | 227 | ]; |
177 | 228 |
|
178 | 229 | systemd.services.cinder-volume = { |
179 | 230 | description = "OpenStack Cinder Volume"; |
180 | 231 | after = [ |
181 | | - "cinder-volume-group.service" |
| 232 | + "cinder-volume-group-setup.service" |
182 | 233 | ]; |
183 | 234 | path = with pkgs; [ |
184 | 235 | cinder_env |
|
0 commit comments