|
9 | 9 | }: |
10 | 10 | with lib; |
11 | 11 | let |
12 | | - # adminEnv = { |
13 | | - # OS_USERNAME = "admin"; |
14 | | - # OS_PASSWORD = "admin"; |
15 | | - # OS_PROJECT_NAME = "admin"; |
16 | | - # OS_USER_DOMAIN_NAME = "Default"; |
17 | | - # OS_PROJECT_DOMAIN_NAME = "Default"; |
18 | | - # OS_AUTH_URL = "http://controller:5000/v3"; |
19 | | - # OS_IDENTITY_API_VERSION = "3"; |
20 | | - # }; |
21 | 12 | cfg = config.cinder-storage-node; |
22 | 13 |
|
23 | 14 | cinder_env = pkgs.python3.buildEnv.override { |
|
32 | 23 | paths = [ |
33 | 24 | cinder_env |
34 | 25 | pkgs.qemu |
| 26 | + pkgs.tgt |
35 | 27 | ]; |
36 | 28 | }; |
37 | 29 |
|
|
45 | 37 | [DEFAULT] |
46 | 38 | transport_url = rabbit://openstack:openstack@controller |
47 | 39 | auth_strategy = keystone |
48 | | - my_ip = controller |
| 40 | + my_ip = 10.0.0.20 |
49 | 41 | enabled_backends = lvm |
50 | 42 | volumes_dir = /var/lib/cinder/volumes |
51 | 43 | state_path = /var/lib/cinder |
52 | 44 | rootwrap_config = ${rootwrapConf} |
53 | 45 | glance_api_servers = http://controller:9292 |
54 | 46 | verify_glance_signatures = disabled |
| 47 | + log_dir = /var/log/cinder |
| 48 | + iscsi_ip_address = $my_ip |
| 49 | + iscsi_port = 3260 |
| 50 | + iscsi_target_prefix = iqn.2010-10.org.openstack: |
55 | 51 |
|
56 | 52 | [database] |
57 | 53 | connection = mysql+pymysql://cinder:cinder@controller/cinder |
|
76 | 72 | volume_backend_name = lvm |
77 | 73 | lvm_type = default |
78 | 74 | target_protocol = iscsi |
| 75 | + target_helper = tgtadm |
| 76 | + iscsi_ip_address = $my_ip |
| 77 | + iscsi_port = 3260 |
| 78 | + iscsi_target_prefix = iqn.2010-10.org.openstack: |
| 79 | + ''; |
| 80 | + |
| 81 | + cinderTgtConf = pkgs.writeText "cinder.conf" '' |
| 82 | + include /var/lib/cinder/volumes/* |
79 | 83 | ''; |
80 | 84 | in |
81 | 85 | { |
|
140 | 144 | mode = "0755"; |
141 | 145 | }; |
142 | 146 | }; |
| 147 | + "/etc/cinder/cinder.conf" = { |
| 148 | + L = { |
| 149 | + argument = "${cinderConf}"; |
| 150 | + }; |
| 151 | + }; |
| 152 | + "/etc/tgt/conf.d/cinder.conf" = { |
| 153 | + L = { |
| 154 | + argument = "${cinderTgtConf}"; |
| 155 | + }; |
| 156 | + }; |
| 157 | + "/etc/tgt/targets.conf" = { |
| 158 | + L = { |
| 159 | + argument = "${pkgs.tgt}/etc/tgt/targets.conf"; |
| 160 | + }; |
| 161 | + }; |
143 | 162 | }; |
144 | 163 | }; |
145 | 164 |
|
146 | | - systemd.services.cinder-volume-group = { |
| 165 | + # start iSCSI target daemon |
| 166 | + # we expose LVM block storage as iSCSI to compute hosts |
| 167 | + systemd.services.tgtd = { |
| 168 | + enable = true; |
| 169 | + description = "iSCSI target framework daemon"; |
| 170 | + wantedBy = [ "multi-user.target" ]; |
| 171 | + after = [ |
| 172 | + "network.target" |
| 173 | + "cinder-volume-group-setup.service" |
| 174 | + ]; |
| 175 | + path = [ |
| 176 | + pkgs.coreutils |
| 177 | + pkgs.tgt |
| 178 | + ]; |
| 179 | + environment.TGTD_CONFIG = "/etc/tgt/targets.conf"; |
| 180 | + serviceConfig = { |
| 181 | + ExecStart = "${pkgs.tgt}/bin/tgtd -f"; |
| 182 | + ExecStartPost = [ |
| 183 | + "${pkgs.coreutils}/bin/sleep 5" |
| 184 | + "${pkgs.tgt}/bin/tgtadm --op update --mode sys --name State -v offline" |
| 185 | + "${pkgs.tgt}/bin/tgtadm --op update --mode sys --name State -v ready" |
| 186 | + "${pkgs.tgt}/bin/tgt-admin -e -c $TGTD_CONFIG" |
| 187 | + ]; |
| 188 | + |
| 189 | + ExecReload = "${pkgs.tgt}/bin/tgt-admin --update ALL -f -c $TGTD_CONFIG"; |
| 190 | + |
| 191 | + ExecStop = [ |
| 192 | + "${pkgs.tgt}/bin/tgtadm --op update --mode sys --name State -v offline" |
| 193 | + "${pkgs.tgt}/bin/tgt-admin --offline ALL" |
| 194 | + "${pkgs.tgt}/bin/tgt-admin --update ALL -c /dev/null -f" |
| 195 | + "${pkgs.tgt}/bin/tgtadm --op delete --mode system" |
| 196 | + ]; |
| 197 | + }; |
| 198 | + }; |
| 199 | + |
| 200 | + systemd.services.cinder-volume-group-setup = { |
147 | 201 | description = "OpenStack Cinder volume group setup"; |
148 | 202 | wantedBy = [ "multi-user.target" ]; |
149 | 203 | path = [ |
|
155 | 209 | ExecStart = pkgs.writeShellScript "cinder-volume-group.sh" '' |
156 | 210 | set -euxo pipefail |
157 | 211 |
|
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 |
| 212 | + # create a new LVM volume group on second disk |
| 213 | + pvcreate /dev/vdb |
| 214 | + vgcreate cinder-volumes /dev/vdb |
166 | 215 | ''; |
167 | 216 | }; |
168 | 217 | }; |
|
173 | 222 | # Update: still does not work -.- |
174 | 223 | environment.systemPackages = [ |
175 | 224 | pkgs.qemu |
| 225 | + pkgs.tgt |
176 | 226 | ]; |
177 | 227 |
|
178 | 228 | systemd.services.cinder-volume = { |
179 | 229 | description = "OpenStack Cinder Volume"; |
180 | 230 | after = [ |
181 | | - "cinder-volume-group.service" |
| 231 | + "cinder-volume-group-setup.service" |
182 | 232 | ]; |
183 | 233 | path = with pkgs; [ |
184 | 234 | cinder_env |
|
0 commit comments