2011-04-01 18:09:57 +00:00
|
|
|
# Module for Nova, a.k.a. OpenStack Compute.
|
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-04-01 18:09:57 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2011-04-01 18:09:57 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.virtualisation.nova;
|
|
|
|
|
|
|
|
nova = pkgs.nova;
|
|
|
|
|
2011-05-11 13:52:49 +00:00
|
|
|
novaConf = pkgs.writeText "nova.conf"
|
|
|
|
''
|
|
|
|
--nodaemon
|
|
|
|
--verbose
|
2011-06-20 14:27:06 +00:00
|
|
|
${cfg.extraConfig}
|
2011-05-11 13:52:49 +00:00
|
|
|
'';
|
|
|
|
|
2011-04-01 18:09:57 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2011-09-14 18:20:50 +00:00
|
|
|
virtualisation.nova.enableSingleNode =
|
2011-04-01 18:09:57 +00:00
|
|
|
mkOption {
|
|
|
|
default = false;
|
|
|
|
description =
|
|
|
|
''
|
|
|
|
This option enables Nova, also known as OpenStack Compute,
|
|
|
|
a cloud computing system, as a single-machine
|
|
|
|
installation. That is, all of Nova's components are
|
|
|
|
enabled on this machine, using SQLite as Nova's database.
|
|
|
|
This is useful for evaluating and experimenting with Nova.
|
|
|
|
However, for a real cloud computing environment, you'll
|
|
|
|
want to enable some of Nova's services on other machines,
|
|
|
|
and use a database such as MySQL.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2011-09-14 18:20:50 +00:00
|
|
|
virtualisation.nova.extraConfig =
|
2011-06-20 14:27:06 +00:00
|
|
|
mkOption {
|
2012-02-23 21:25:22 +00:00
|
|
|
default = "";
|
2011-06-20 14:27:06 +00:00
|
|
|
description =
|
|
|
|
''
|
|
|
|
Additional text appended to <filename>nova.conf</filename>,
|
|
|
|
the main Nova configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2011-04-01 18:09:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enableSingleNode {
|
|
|
|
|
2011-06-09 17:11:56 +00:00
|
|
|
environment.systemPackages = [ nova pkgs.euca2ools pkgs.novaclient ];
|
2011-04-01 18:09:57 +00:00
|
|
|
|
|
|
|
environment.etc =
|
2011-06-20 14:27:06 +00:00
|
|
|
[ { source = novaConf;
|
|
|
|
target = "nova/nova.conf";
|
2011-04-01 18:09:57 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
# Nova requires libvirtd and RabbitMQ.
|
|
|
|
virtualisation.libvirtd.enable = true;
|
|
|
|
services.rabbitmq.enable = true;
|
|
|
|
|
|
|
|
# `qemu-nbd' required the `nbd' kernel module.
|
|
|
|
boot.kernelModules = [ "nbd" ];
|
2011-04-07 09:59:11 +00:00
|
|
|
|
|
|
|
system.activationScripts.nova =
|
|
|
|
''
|
2011-04-07 12:47:20 +00:00
|
|
|
mkdir -m 755 -p /var/lib/nova
|
|
|
|
mkdir -m 755 -p /var/lib/nova/networks
|
|
|
|
mkdir -m 700 -p /var/lib/nova/instances
|
|
|
|
mkdir -m 700 -p /var/lib/nova/keys
|
2011-04-07 09:59:11 +00:00
|
|
|
|
|
|
|
# Allow the CA certificate generation script (called by
|
|
|
|
# nova-api) to work.
|
|
|
|
mkdir -m 700 -p /var/lib/nova/CA /var/lib/nova/CA/private
|
|
|
|
|
2011-09-14 18:20:50 +00:00
|
|
|
# Initialise the SQLite database.
|
2011-04-07 09:59:11 +00:00
|
|
|
${nova}/bin/nova-manage db sync
|
|
|
|
'';
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2011-04-01 18:09:57 +00:00
|
|
|
# `nova-api' receives and executes external client requests from
|
|
|
|
# tools such as euca2ools. It listens on port 8773 (XML) and 8774
|
|
|
|
# (JSON).
|
|
|
|
jobs.nova_api =
|
|
|
|
{ name = "nova-api";
|
|
|
|
|
|
|
|
description = "Nova API service";
|
|
|
|
|
|
|
|
startOn = "ip-up";
|
|
|
|
|
2011-04-07 12:47:20 +00:00
|
|
|
# `openssl' is required to generate the CA. `openssh' is
|
|
|
|
# required to generate key pairs.
|
2015-06-27 00:09:58 +00:00
|
|
|
path = [ pkgs.openssl config.programs.ssh.package pkgs.bash ];
|
2011-06-09 17:11:56 +00:00
|
|
|
|
|
|
|
respawn = false;
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2011-06-09 17:11:56 +00:00
|
|
|
exec = "${nova}/bin/nova-api --flagfile=${novaConf} --api_paste_config=${nova}/etc/nova/api-paste.ini";
|
2011-04-01 18:09:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# `nova-objectstore' is a simple image server. Useful if you're
|
|
|
|
# not running the OpenStack Imaging Service (Swift). It serves
|
|
|
|
# images placed in /var/lib/nova/images/.
|
|
|
|
jobs.nova_objectstore =
|
|
|
|
{ name = "nova-objectstore";
|
|
|
|
|
2013-11-09 19:06:01 +00:00
|
|
|
description = "Nova Simple Object Store Service";
|
2011-04-01 18:09:57 +00:00
|
|
|
|
|
|
|
startOn = "ip-up";
|
|
|
|
|
2011-04-07 12:47:20 +00:00
|
|
|
preStart =
|
|
|
|
''
|
|
|
|
mkdir -m 700 -p /var/lib/nova/images
|
|
|
|
'';
|
|
|
|
|
2011-05-11 13:52:49 +00:00
|
|
|
exec = "${nova}/bin/nova-objectstore --flagfile=${novaConf}";
|
2011-04-01 18:09:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# `nova-scheduler' schedules VM execution requests.
|
|
|
|
jobs.nova_scheduler =
|
|
|
|
{ name = "nova-scheduler";
|
|
|
|
|
2013-11-09 19:06:01 +00:00
|
|
|
description = "Nova Scheduler Service";
|
2011-04-01 18:09:57 +00:00
|
|
|
|
|
|
|
startOn = "ip-up";
|
|
|
|
|
2011-05-11 13:52:49 +00:00
|
|
|
exec = "${nova}/bin/nova-scheduler --flagfile=${novaConf}";
|
2011-04-01 18:09:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# `nova-compute' starts and manages virtual machines.
|
|
|
|
jobs.nova_compute =
|
|
|
|
{ name = "nova-compute";
|
|
|
|
|
2013-11-09 19:06:01 +00:00
|
|
|
description = "Nova Compute Service";
|
2011-04-01 18:09:57 +00:00
|
|
|
|
|
|
|
startOn = "ip-up";
|
|
|
|
|
|
|
|
path =
|
|
|
|
[ pkgs.sudo pkgs.vlan pkgs.nettools pkgs.iptables pkgs.qemu_kvm
|
2016-01-21 15:07:38 +00:00
|
|
|
pkgs.e2fsprogs pkgs.utillinux pkgs.multipath-tools pkgs.iproute
|
2015-02-20 20:43:09 +00:00
|
|
|
pkgs.bridge-utils
|
2011-04-01 18:09:57 +00:00
|
|
|
];
|
|
|
|
|
2011-05-11 13:52:49 +00:00
|
|
|
exec = "${nova}/bin/nova-compute --flagfile=${novaConf}";
|
2011-04-01 18:09:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# `nova-network' manages networks and allocates IP addresses.
|
|
|
|
jobs.nova_network =
|
|
|
|
{ name = "nova-network";
|
|
|
|
|
2013-11-09 19:06:01 +00:00
|
|
|
description = "Nova Network Service";
|
2011-04-01 18:09:57 +00:00
|
|
|
|
|
|
|
startOn = "ip-up";
|
|
|
|
|
|
|
|
path =
|
|
|
|
[ pkgs.sudo pkgs.vlan pkgs.dnsmasq pkgs.nettools pkgs.iptables
|
2015-02-20 20:43:09 +00:00
|
|
|
pkgs.iproute pkgs.bridge-utils pkgs.radvd
|
2011-04-01 18:09:57 +00:00
|
|
|
];
|
|
|
|
|
2011-05-11 13:52:49 +00:00
|
|
|
exec = "${nova}/bin/nova-network --flagfile=${novaConf}";
|
2011-04-01 18:09:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|