aboutsummaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-devtools/python/python-nova/nova-init
blob: 5faa7d6f59cf725f8ec81da2127e39e7e0267fd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
#
# Basic nova setup based on:
# https://docs.openstack.org/nova/pike/install/controller-install-ubuntu.html
#
# Prerequisites: keystone must be available and bootstrapped
#

# Substitutions setup at do_intall()
DB_USER=%DB_USER%
NOVA_USER=%NOVA_USER%
NOVA_GROUP=%NOVA_GROUP%
CONTROLLER_IP=%CONTROLLER_IP%
ADMIN_USER=%ADMIN_USER%
ADMIN_PASSWORD=%ADMIN_PASSWORD%
ADMIN_ROLE=%ADMIN_ROLE%
SYSCONFDIR=%SYSCONFDIR%
PLACEMENT_USER=%PLACEMENT_USER%

#	sudo -u postgres createdb nova
#	sleep 2
#	nova-manage db sync

# Create the neutron DB and grant the necessary permissions
sudo -u postgres psql -c "CREATE DATABASE \"nova-api\"" 2> /dev/null
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE \"nova-api\" TO ${DB_USER}" 2> /dev/null

sudo -u postgres psql -c "CREATE DATABASE nova" 2> /dev/null
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE nova TO ${DB_USER}" 2> /dev/null

sudo -u postgres psql -c "CREATE DATABASE \"nova-cell0\"" 2> /dev/null
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE \"nova-cell0\" TO ${DB_USER}" 2> /dev/null

source ${SYSCONFDIR}/keystone/admin-openrc

openstack user create --domain default --password ${ADMIN_PASSWORD} ${NOVA_USER}

# Ensure the 'service' project exists
openstack project show service > /dev/null 2>&1
if [ $? -ne 0 ]; then
    openstack project create service --domain default
fi
openstack role add --project service --user ${NOVA_USER} ${ADMIN_ROLE}

# Create nova service and service endpoints
openstack service create --name nova --description "OpenStack Compute" compute
openstack endpoint create --region RegionOne compute public http://${CONTROLLER_IP}:8774
openstack endpoint create --region RegionOne compute internal http://${CONTROLLER_IP}:8774
openstack endpoint create --region RegionOne compute admin http://${CONTROLLER_IP}:8774

# Create placement service, role, and endpoints.
openstack user create --domain default --password ${ADMIN_PASSWORD} ${PLACEMENT_USER}
openstack role add --project service --user ${PLACEMENT_USER} ${ADMIN_ROLE}
openstack service create --name placement --description "Placement API" placement
openstack endpoint create --region RegionOne placement public http://${CONTROLLER_IP}:8778
openstack endpoint create --region RegionOne placement internal http://${CONTROLLER_IP}:8778
openstack endpoint create --region RegionOne placement admin http://${CONTROLLER_IP}:8778

sudo -u ${NOVA_USER} nova-manage api_db sync
sudo -u ${NOVA_USER} nova-manage cell_v2 map_cell0
sudo -u ${NOVA_USER} nova-manage cell_v2 create_cell --name=cell1 --verbose
sudo -u ${NOVA_USER} nova-manage db sync

# Enable and start the nova services
systemctl enable nova-api
systemctl enable nova-consoleauth
systemctl enable nova-scheduler
systemctl enable nova-conductor
systemctl enable nova-novncproxy

systemctl start nova-api
systemctl start nova-consoleauth
systemctl start nova-scheduler
systemctl start nova-conductor
systemctl start nova-novncproxy