setup-basic.sh 7.5 KB
Newer Older
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
#!/bin/sh

##
## Initialize some basic useful stuff.
##

set -x

DIRNAME=`dirname $0`

# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

# Grab our libs
. "$DIRNAME/setup-lib.sh"

if [ "$HOSTNAME" != "$CONTROLLER" ]; then
    exit 0;
fi

if [ -f $SETTINGS ]; then
    . $SETTINGS
fi

. $OURDIR/admin-openrc.sh

30
echo "*** Adding Images ..."
31

32 33 34 35 36 37
ARCH=`uname -m`
if [ "$ARCH" = "aarch64" ] ; then
    $DIRNAME/setup-basic-aarch64.sh
else
    $DIRNAME/setup-basic-x86_64.sh
fi
38

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
#
# Setup tunnel-based networks
#
if [ ${DATATUNNELS} -gt 0 ]; then
    i=0
    while [ $i -lt ${DATATUNNELS} ]; do
	LAN="tun${i}"
	#. $OURDIR/info.$LAN
	. $OURDIR/ipinfo.$LAN

	echo "*** Creating GRE data network $LAN and subnet $CIDR ..."

	neutron net-create ${LAN}-net --provider:network_type gre
	neutron subnet-create ${LAN}-net  --name ${LAN}-subnet "$CIDR"
	neutron router-create ${LAN}-router
	neutron router-interface-add ${LAN}-router ${LAN}-subnet
	neutron router-gateway-set ${LAN}-router ext-net

	i=`expr $i + 1`
    done
fi
60

61 62
for lan in ${DATAFLATLANS} ; do
    . $OURDIR/info.${lan}
63

64 65
    name="$lan"
    echo "*** Creating Flat data network ${lan} and subnet ..."
66

67 68 69
    nmdataip=`cat $OURDIR/data-hosts.${lan} | grep ${NETWORKMANAGER} | sed -n -e 's/^\([0-9]*.[0-9]*.[0-9]*.[0-9]*\).*$/\1/p'`
    allocation_pool=`cat $OURDIR/data-allocation-pool.${lan}`
    cidr=`cat $OURDIR/data-cidr.${lan}`
70 71
    # Make sure to set the right gateway IP (to our router)
    routeripaddr=`cat $OURDIR/router-ipaddr.$lan`
72

73
    neutron net-create ${name}-net --shared --provider:physical_network ${lan} --provider:network_type flat
74
    neutron subnet-create ${name}-net --name ${name}-subnet --allocation-pool ${allocation_pool} --gateway $routeripaddr $cidr
75

76 77
    subnetid=`neutron subnet-show ${name}-subnet | awk '/ id / {print $4}'`

78 79 80 81 82
    neutron router-create ${name}-router
    neutron router-interface-add ${name}-router ${name}-subnet
    #if [ $PUBLICCOUNT -ge 3 ] ; then
	neutron router-gateway-set ${name}-router ext-net
    #fi
83

84 85
    # Fix up the dhcp agent port IP addr.  We can't set this in the
    # creation command, so do a port update!
86 87 88
    ports=`neutron port-list | grep $subnetid | awk '{print $2}'`
    for port in $ports ; do
	owner=`neutron port-show $port | awk '/ device_owner / {print $4}'`
89 90 91 92
	#if [ "x$owner" = "xnetwork:router_interface" -a -f $OURDIR/router-ipaddr.$lan ]; then
	#    newipaddr=`cat $OURDIR/router-ipaddr.$lan`
	#    neutron port-update $port --fixed-ip subnet_id=$subnetid,ip_address=$newipaddr
	#fi
93 94 95 96 97
	if [ "x$owner" = "xnetwork:dhcp" -a -f $OURDIR/dhcp-agent-ipaddr.$lan ]; then
	    newipaddr=`cat $OURDIR/dhcp-agent-ipaddr.$lan`
	    neutron port-update $port --fixed-ip subnet_id=$subnetid,ip_address=$newipaddr
	fi
    done
98
done
99

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
for lan in ${DATAVLANS} ; do
    . $OURDIR/info.${lan}
    . $OURDIR/ipinfo.${lan}

    echo "*** Creating VLAN data network $lan and subnet $CIDR ..."

    neutron net-create ${lan}-net --shared --provider:physical_network ${DATAVLANDEV} --provider:network_type vlan
    # NB: for now don't specify an allocation_pool:
    #  --allocation-pool ${ALLOCATION_POOL}
    neutron subnet-create ${lan}-net --name ${lan}-subnet "$CIDR"

    neutron router-create ${lan}-router
    neutron router-interface-add ${lan}-router ${lan}-subnet
    #if [ $PUBLICCOUNT -ge 3 ] ; then
	neutron router-gateway-set ${lan}-router ext-net
    #fi
done
117

118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
#
# Setup VXLAN-based networks
#
if [ ${DATAVXLANS} -gt 0 ]; then
    i=0
    while [ $i -lt ${DATAVXLANS} ]; do
	LAN="vxlan${i}"
	#. $OURDIR/info.$LAN
	. $OURDIR/ipinfo.$LAN

	echo "*** Creating VXLAN data network $LAN and subnet $CIDR ..."

	neutron net-create ${LAN}-net --provider:network_type vxlan
	neutron subnet-create ${LAN}-net  --name ${LAN}-subnet "$CIDR"
	neutron router-create ${LAN}-router
	neutron router-interface-add ${LAN}-router ${LAN}-subnet
	neutron router-gateway-set ${LAN}-router ext-net

	i=`expr $i + 1`
    done
fi

140 141 142 143 144
if [ ${DEFAULT_SECGROUP_ENABLE_SSH_ICMP} -eq 1 ]; then
    nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
    nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
fi

145
if [ $GENIUSER -eq 1 ] ; then
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
    echo "*** Importing GENI user keys for admin user..."
    $DIRNAME/setup-user-info.py

    #
    # XXX: ugh, this is ugly, but now that we have two admin users, we have
    # to create keys for the admin user -- but we upload keys as the adminapi
    # user.  I can't find a way with the API to upload keys for another user
    # (seems very dumb, I must be missing something, but...)... so what we do
    # is add the keys once for the adminapi user, change the db manually to
    # make those keys be for the admin user, then add the same keys again (for
    # the adminapi user).  Then both admin users have the keys.
    #
    AAID=`keystone user-get ${ADMIN_API} | awk '/ id / {print $4}'`
    AID=`keystone user-get admin | awk '/ id / {print $4}'`
    echo "update key_pairs set user_id='$AID' where user_id='$AAID'" \
	| mysql -u root --password=${DB_ROOT_PASS} nova

    # Ok, do it again!
    echo "*** Importing GENI user keys, for ${ADMIN_API} user..."
165 166 167
    $DIRNAME/setup-user-info.py
fi

168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
if [ $QUOTASOFF -eq 1 ]; then
    nova quota-class-update --instances -1 default
    nova quota-class-update --cores -1 default
    nova quota-class-update --ram -1 default
    nova quota-class-update --floating-ips -1 default
    nova quota-class-update --fixed-ips -1 default
    nova quota-class-update --metadata-items -1 default
    nova quota-class-update --injected-files -1 default
    nova quota-class-update --injected-file-content-bytes -1 default
    nova quota-class-update --injected-file-path-bytes -1 default
    nova quota-class-update --key-pairs -1 default
    nova quota-class-update --security-groups -1 default
    nova quota-class-update --security-group-rules -1 default
    nova quota-class-update --server-groups -1 default
    nova quota-class-update --server-group-members -1 default

184 185 186 187 188 189 190 191 192 193 194 195 196
    neutron quota-update --network -1
    neutron quota-update --subnet -1
    neutron quota-update --port -1
    neutron quota-update --router -1
    neutron quota-update --floatingip -1
    neutron quota-update --security-group -1
    neutron quota-update --security-group-rule -1
    neutron quota-update --rbac-policy -1
    neutron quota-update --vip -1
    neutron quota-update --pool -1
    neutron quota-update --member -1
    neutron quota-update --health-monitor -1

197 198 199 200 201 202 203
    cinder quota-class-update --volumes -1 default
    cinder quota-class-update --snapshots -1 default
    cinder quota-class-update --gigabytes -1 default
    # Guess you can't set these via CLI?
    #cinder quota-class-update --backup-_gigabytes -1 default
    #cinder quota-class-update --backups -1 default
    #cinder quota-class-update --per-volume-gigabytes -1 default
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219

    openstack quota set --class --ram -1 admin
    openstack quota set --class --secgroup-rules -1 admin
    openstack quota set --class --instances -1 admin
    openstack quota set --class --key-pairs -1 admin
    openstack quota set --class --fixed-ips -1 admin
    openstack quota set --class --secgroups -1 admin
    openstack quota set --class --injected-file-size -1 admin
    openstack quota set --class --floating-ips -1 admin
    openstack quota set --class --injected-files -1 admin
    openstack quota set --class --cores -1 admin
    openstack quota set --class --injected-path-size -1 admin
    openstack quota set --class --gigabytes -1 admin
    openstack quota set --class --volumes -1 admin
    openstack quota set --class --snapshots -1 admin
    openstack quota set --class --volume-type -1 admin
220 221
fi

222
exit 0