File: setup-service

package info (click to toggle)
senlin 14.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,448 kB
  • sloc: python: 72,605; sh: 586; makefile: 199
file content (82 lines) | stat: -rwxr-xr-x 2,248 bytes parent folder | download
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
76
77
78
79
80
81
82
#!/bin/bash

if [[ -z $OS_AUTH_URL ]]; then
  echo "This script must have proper environment variables exported. "
  echo "Please check if you have sourced senlinrc file or openrc file if "
  echo "you are using devstack."
  exit -1
fi

if [ $OS_USERNAME != 'admin' ]; then
  echo "This script has to be executed as an 'admin' user. "
  echo "Please set environment variable OS_USERNAME to 'admin'."
  exit -1
fi

if [ $# -ne 2 ]; then
  echo "Usage: `basename $0` <HOST_IP> <SERVICE_PASSWORD>"
  exit -1
fi

PORT=8777
HOST=$1 # Put your host IP here
SVC_PASSWD=$2
OS_REGION_NAME=${OS_REGION_NAME:-RegionOne}
OS_IDENTITY_API_VERSION=${OS_IDENTITY_API_VERSION:-3}
SERVICE_PROJECT=${OS_SERVICE_PROJECT:-service}
SERVICE_ROLE=${OS_SERVICE_ROLE:-service}

SERVICE_ID=$(openstack service show senlin -f value -cid 2>/dev/null)
if [[ -z $SERVICE_ID ]]; then
  SERVICE_ID=$(openstack service create \
    --name senlin \
    --description 'Senlin Clustering Service V1' \
    -f value -cid \
    clustering)
fi

if [[ -z $SERVICE_ID ]]; then
  exit
fi

if [ "$OS_IDENTITY_API_VERSION" = "3" ]; then
    openstack endpoint create senlin admin "http://$HOST:$PORT" \
      --region $OS_REGION_NAME
    openstack endpoint create senlin public "http://$HOST:$PORT" \
      --region $OS_REGION_NAME
    openstack endpoint create senlin internal "http://$HOST:$PORT" \
      --region $OS_REGION_NAME
else
    openstack endpoint create \
      --adminurl "http://$HOST:$PORT" \
      --publicurl "http://$HOST:$PORT" \
      --internalurl "http://$HOST:$PORT" \
      --region $OS_REGION_NAME \
      senlin
fi

# Check service project name.
# Devstack uses 'service' while some distributions use 'services'
PROJECT_ID=$(openstack project show service -f value -cid 2>/dev/null)
if [[ -z $PROJECT_ID ]]; then
    SERVICE_PROJECT=services
    SERVICE_ROLE=services
    openstack role create $SERVICE_ROLE
fi

openstack user create \
    --password "$SVC_PASSWD" \
    --project $SERVICE_PROJECT \
    --email senlin@localhost \
    senlin

openstack role add \
    admin \
    --user senlin \
    --project $SERVICE_PROJECT

  # make sure 'senlin' has service role on 'demo' project
openstack role add \
    $SERVICE_ROLE \
    --user senlin \
    --project demo