Skip to content

Commit f24082d

Browse files
committed
xxxx: create separate storage node
Signed-off-by: Paul Kroeher <paul.kroeher@cyberus-technology.de>
1 parent cd921cb commit f24082d

6 files changed

Lines changed: 129 additions & 23 deletions

File tree

modules/compute/nova.nix

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,7 @@ in
184184
user = "nova";
185185
};
186186
};
187-
"/etc/systemd/system/tgtd.service" = {
188-
"C+" = {
189-
user = "root";
190-
group = "root";
191-
mode = "0600";
192-
argument = "${pkgs.tgt}/etc/systemd/system/tgtd.service";
193-
};
194-
};
187+
# we don't need tgt on a compute node -> only iscsi-client (openiscsi)
195188
};
196189
};
197190

@@ -200,7 +193,7 @@ in
200193
name = "iqn.iscsi.${config.networking.hostName}";
201194
};
202195

203-
environment.systemPackages = [ pkgs.tgt ];
196+
environment.systemPackages = [ pkgs.openiscsi ];
204197

205198
systemd.services.nova-compute = {
206199
description = "OpenStack Nova Scheduler Daemon";
@@ -217,7 +210,7 @@ in
217210
qemu
218211
util-linux
219212
lvm2
220-
tgt
213+
openiscsi
221214
]
222215
++ cfg.extraPkgs;
223216
environment.PYTHONPATH = "${nova_env}/${pkgs.python3.sitePackages}";

modules/controller/openstack-controller.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ in
3333
(import ./nova.nix { inherit nova; })
3434
(import ./neutron.nix { inherit neutron; })
3535
(import ./horizon.nix { inherit horizon; })
36-
(import ./cinder.nix { inherit cinder; })
37-
(import ../storage/cinder-storage-node.nix { inherit cinder; })
36+
(import ./cinder.nix { inherit cinder; }) # only cinder management component
37+
# deploy real storage backend into a separate storageNode
38+
# (import ../storage/cinder-storage-node.nix { inherit cinder; })
3839
];
3940

4041
config = {

modules/default.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@
1414

1515
computeModule = import ./compute/compute.nix { inherit (openstackPkgs) neutron nova; };
1616

17+
storageModule = import ./storage/cinder-storage-node.nix { inherit (openstackPkgs) cinder; };
18+
1719
testModules = import ./testing { };
1820
}

modules/storage/cinder-storage-node.nix

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let
4545
[DEFAULT]
4646
transport_url = rabbit://openstack:openstack@controller
4747
auth_strategy = keystone
48-
my_ip = controller
48+
my_ip = 10.0.0.20
4949
enabled_backends = lvm
5050
volumes_dir = /var/lib/cinder/volumes
5151
state_path = /var/lib/cinder
@@ -76,6 +76,11 @@ let
7676
volume_backend_name = lvm
7777
lvm_type = default
7878
target_protocol = iscsi
79+
target_helper = tgtadm
80+
'';
81+
82+
cinderTgtConf = pkgs.writeText "cinder.conf" ''
83+
include /var/lib/cinder/volumes/*
7984
'';
8085
in
8186
{
@@ -140,10 +145,60 @@ in
140145
mode = "0755";
141146
};
142147
};
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+
];
143198
};
144199
};
145200

146-
systemd.services.cinder-volume-group = {
201+
systemd.services.cinder-volume-group-setup = {
147202
description = "OpenStack Cinder volume group setup";
148203
wantedBy = [ "multi-user.target" ];
149204
path = [
@@ -155,14 +210,9 @@ in
155210
ExecStart = pkgs.writeShellScript "cinder-volume-group.sh" ''
156211
set -euxo pipefail
157212
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
166216
'';
167217
};
168218
};
@@ -173,12 +223,13 @@ in
173223
# Update: still does not work -.-
174224
environment.systemPackages = [
175225
pkgs.qemu
226+
pkgs.tgt
176227
];
177228

178229
systemd.services.cinder-volume = {
179230
description = "OpenStack Cinder Volume";
180231
after = [
181-
"cinder-volume-group.service"
232+
"cinder-volume-group-setup.service"
182233
];
183234
path = with pkgs; [
184235
cinder_env

modules/testing/default.nix

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,54 @@ in
188188
};
189189

190190
};
191+
192+
testStorage =
193+
{ ... }:
194+
{
195+
196+
imports = [ common ];
197+
198+
virtualisation = {
199+
memorySize = 4096;
200+
cores = 4;
201+
diskSize = 4096;
202+
# add separate disk as LVM backend
203+
emptyDiskImages = [
204+
16384
205+
];
206+
interfaces = {
207+
eth1 = {
208+
vlan = 1;
209+
};
210+
eth2 = {
211+
vlan = 2;
212+
};
213+
};
214+
};
215+
216+
systemd.network = {
217+
enable = true;
218+
wait-online.enable = false;
219+
220+
networks = {
221+
eth1 = {
222+
matchConfig.Name = [ "eth1" ];
223+
networkConfig = {
224+
Address = "10.0.0.20/24";
225+
Gateway = "10.0.0.1";
226+
DNS = "8.8.8.8";
227+
};
228+
};
229+
230+
eth2 = {
231+
matchConfig.Name = [ "eth2" ];
232+
networkConfig = {
233+
DHCP = "no";
234+
LinkLocalAddressing = "no";
235+
KeepConfiguration = "yes";
236+
};
237+
};
238+
};
239+
};
240+
};
191241
}

tests/openstack-default-setup.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ pkgs.nixosTest {
2323
];
2424
};
2525

26+
nodes.storageVM =
27+
{ ... }:
28+
{
29+
imports = [
30+
nixosModules.storageModule
31+
nixosModules.testModules.testStorage
32+
];
33+
};
34+
2635
testScript =
2736
{ ... }:
2837
''

0 commit comments

Comments
 (0)