Skip to content
This repository was archived by the owner on Jul 24, 2019. It is now read-only.

Commit 8bcc3bc

Browse files
authored
Merge pull request #77 from portdirect/heat
OpenStack Heat Initial Commit
2 parents 905ebbc + d8a07ee commit 8bcc3bc

35 files changed

Lines changed: 1664 additions & 9 deletions

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
.PHONY: ceph bootstrap mariadb keystone memcached rabbitmq common openstack neutron maas all clean
1+
.PHONY: ceph bootstrap mariadb keystone memcached rabbitmq common openstack neutron heat maas all clean
22

33
B64_DIRS := common/secrets
44
B64_EXCLUDE := $(wildcard common/secrets/*.b64)
55

6-
CHARTS := ceph mariadb rabbitmq GLANCE memcached keystone glance horizon neutron maas openstack
6+
CHARTS := ceph mariadb rabbitmq GLANCE memcached keystone glance horizon neutron heat maas openstack
77
COMMON_TPL := common/templates/_globals.tpl
88

9-
all: common ceph bootstrap mariadb rabbitmq memcached keystone glance horizon neutron maas openstack
9+
all: common ceph bootstrap mariadb rabbitmq memcached keystone glance horizon neutron heat maas openstack
1010

1111
common: build-common
1212

@@ -27,6 +27,8 @@ glance: build-glance
2727

2828
neutron: build-neutron
2929

30+
heat: build-heat
31+
3032
maas: build-maas
3133

3234
memcached: build-memcached
@@ -44,4 +46,3 @@ build-%:
4446
if [ -f $*/requirements.yaml ]; then helm dep up $*; fi
4547
helm lint $*
4648
helm package $*
47-

common/templates/_endpoints.tpl

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,51 @@
8787
{{- end -}}
8888
{{- end -}}
8989

90+
# this function returns the endpoint uri for a service, it takes an tuple
91+
# input in the form: service-name, endpoint-class, port-name. eg:
92+
# { tuple "heat" "public" "api" . | include "endpoint_addr_lookup" }
93+
# will return the appropriate URI. Once merged this should phase out the above.
94+
95+
{{- define "endpoint_addr_lookup" -}}
96+
{{- $name := index . 0 -}}
97+
{{- $endpoint := index . 1 -}}
98+
{{- $port := index . 2 -}}
99+
{{- $context := index . 3 -}}
100+
{{- $nameNorm := $name | replace "-" "_" }}
101+
{{- $endpointMap := index $context.Values.endpoints $nameNorm }}
102+
{{- $fqdn := $context.Release.Namespace -}}
103+
{{- if $context.Values.endpoints.fqdn -}}
104+
{{- $fqdn := $context.Values.endpoints.fqdn -}}
105+
{{- end -}}
106+
{{- with $endpointMap -}}
107+
{{- $endpointScheme := .scheme }}
108+
{{- $endpointHost := index .hosts $endpoint | default .hosts.default}}
109+
{{- $endpointPort := index .port $port }}
110+
{{- $endpointPath := .path }}
111+
{{- printf "%s://%s.%s:%1.f%s" $endpointScheme $endpointHost $fqdn $endpointPort $endpointPath | quote -}}
112+
{{- end -}}
113+
{{- end -}}
114+
115+
116+
#-------------------------------
117+
# endpoint type lookup
118+
#-------------------------------
119+
120+
# this function is used in endpoint management templates
121+
# it returns the service type for an openstack service eg:
122+
# { tuple heat . | include "ks_endpoint_type" }
123+
# will return "orchestration"
124+
125+
{{- define "endpoint_type_lookup" -}}
126+
{{- $name := index . 0 -}}
127+
{{- $context := index . 1 -}}
128+
{{- $nameNorm := $name | replace "-" "_" }}
129+
{{- $endpointMap := index $context.Values.endpoints $nameNorm }}
130+
{{- $endpointType := index $endpointMap "type" }}
131+
{{- $endpointType | quote -}}
132+
{{- end -}}
133+
90134
#-------------------------------
91135
# kolla helpers
92136
#-------------------------------
93137
{{ define "keystone_auth" }}{'auth_url':'{{ include "endpoint_keystone_internal" . }}', 'username':'{{ .Values.keystone.admin_user }}','password':'{{ .Values.keystone.admin_password }}','project_name':'{{ .Values.keystone.admin_project_name }}','domain_name':'default'}{{end}}
94-

common/templates/_funcs.tpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@
2121
{{- $wtf := $context.Template.Name | replace $last $name -}}
2222
{{- include $wtf $context | sha256sum | quote -}}
2323
{{- end -}}
24-
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{{- define "common_keystone_domain_user" }}
2+
#!/bin/bash
3+
4+
# Copyright 2017 Pete Birley
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
set -ex
19+
20+
# Manage domain
21+
SERVICE_OS_DOMAIN_ID=$(openstack domain create --or-show --enable -f value -c id \
22+
--description="Service Domain for ${SERVICE_OS_REGION_NAME}/${SERVICE_OS_DOMAIN_NAME}" \
23+
"${SERVICE_OS_DOMAIN_NAME}")
24+
25+
# Display domain
26+
openstack domain show "${SERVICE_OS_DOMAIN_ID}"
27+
28+
# Manage user
29+
SERVICE_OS_USERID=$(openstack user create --or-show --enable -f value -c id \
30+
--domain="${SERVICE_OS_DOMAIN_ID}" \
31+
--description "Service User for ${SERVICE_OS_REGION_NAME}/${SERVICE_OS_DOMAIN_NAME}" \
32+
--password="${SERVICE_OS_PASSWORD}" \
33+
"${SERVICE_OS_USERNAME}")
34+
35+
# Display user
36+
openstack user show "${SERVICE_OS_USERID}"
37+
38+
# Manage role
39+
SERVICE_OS_ROLE_ID=$(openstack role show -f value -c id \
40+
--domain="${SERVICE_OS_DOMAIN_ID}" \
41+
"${SERVICE_OS_ROLE}" || openstack role create -f value -c id \
42+
--domain="${SERVICE_OS_DOMAIN_ID}" \
43+
"${SERVICE_OS_ROLE}" )
44+
45+
# Manage user role assignment
46+
openstack role add \
47+
--domain="${SERVICE_OS_DOMAIN_ID}" \
48+
--user="${SERVICE_OS_USERID}" \
49+
--user-domain="${SERVICE_OS_DOMAIN_ID}" \
50+
"${SERVICE_OS_ROLE_ID}"
51+
52+
# Display user role assignment
53+
openstack role assignment list \
54+
--role="${SERVICE_OS_ROLE_ID}" \
55+
--user-domain="${SERVICE_OS_DOMAIN_ID}" \
56+
--user="${SERVICE_OS_USERID}"
57+
{{- end }}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{{- define "common_keystone_endpoints" }}
2+
#!/bin/bash
3+
4+
# Copyright 2017 Pete Birley
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
set -ex
19+
20+
# Get Service ID
21+
OS_SERVICE_ID=$( openstack service list -f csv --quote none | \
22+
grep ",${OS_SERVICE_NAME},${OS_SERVICE_TYPE}$" | \
23+
sed -e "s/,${OS_SERVICE_NAME},${OS_SERVICE_TYPE}//g" )
24+
25+
# Get Endpoint ID if it exists
26+
OS_ENDPOINT_ID=$( openstack endpoint list -f csv --quote none | \
27+
grep "^[a-z0-9]*,${OS_REGION_NAME},${OS_SERVICE_NAME},${OS_SERVICE_TYPE},True,${OS_SVC_ENDPOINT}," | \
28+
awk -F ',' '{ print $1 }' )
29+
30+
# Making sure only a single endpoint exists for a service within a region
31+
if [ "$(echo $OS_ENDPOINT_ID | wc -w)" -gt "1" ]; then
32+
echo "More than one endpoint found, cleaning up"
33+
for ENDPOINT_ID in $OS_ENDPOINT_ID; do
34+
openstack endpoint delete ${ENDPOINT_ID}
35+
done
36+
unset OS_ENDPOINT_ID
37+
fi
38+
39+
# Determine if Endpoint needs updated
40+
if [[ ${OS_ENDPOINT_ID} ]]; then
41+
OS_ENDPOINT_URL_CURRENT=$(openstack endpoint show ${OS_ENDPOINT_ID} --f value -c url)
42+
if [ "${OS_ENDPOINT_URL_CURRENT}" == "${OS_SERVICE_ENDPOINT}" ]; then
43+
echo "Endpoints Match: no action required"
44+
OS_ENDPOINT_UPDATE="False"
45+
else
46+
echo "Endpoints Dont Match: removing existing entries"
47+
openstack endpoint delete ${OS_ENDPOINT_ID}
48+
OS_ENDPOINT_UPDATE="True"
49+
fi
50+
else
51+
OS_ENDPOINT_UPDATE="True"
52+
fi
53+
54+
# Update Endpoint if required
55+
if [[ "${OS_ENDPOINT_UPDATE}" == "True" ]]; then
56+
OS_ENDPOINT_ID=$( openstack endpoint create -f value -c id \
57+
--region="${OS_REGION_NAME}" \
58+
"${OS_SERVICE_ID}" \
59+
${OS_SVC_ENDPOINT} \
60+
"${OS_SERVICE_ENDPOINT}" )
61+
fi
62+
63+
# Display the Endpoint
64+
openstack endpoint show ${OS_ENDPOINT_ID}
65+
{{- end }}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{- define "common_keystone_service" }}
2+
#!/bin/bash
3+
4+
# Copyright 2017 Pete Birley
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
set -ex
19+
20+
# Service boilerplate description
21+
OS_SERVICE_DESC="${OS_REGION_NAME}: ${OS_SERVICE_NAME} (${OS_SERVICE_TYPE}) service"
22+
23+
# Get Service ID if it exists
24+
unset OS_SERVICE_ID
25+
OS_SERVICE_ID=$( openstack service list -f csv --quote none | \
26+
grep ",${OS_SERVICE_NAME},${OS_SERVICE_TYPE}$" | \
27+
sed -e "s/,${OS_SERVICE_NAME},${OS_SERVICE_TYPE}//g" )
28+
29+
# If a Service ID was not found, then create the service
30+
if [[ -z ${OS_SERVICE_ID} ]]; then
31+
OS_SERVICE_ID=$(openstack service create -f value -c id \
32+
--name="${OS_SERVICE_NAME}" \
33+
--description "${OS_SERVICE_DESC}" \
34+
--enable \
35+
"${OS_SERVICE_TYPE}")
36+
fi
37+
{{- end }}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{{- define "common_keystone_user" }}
2+
#!/bin/bash
3+
4+
# Copyright 2017 Pete Birley
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
set -ex
19+
20+
# Manage user project
21+
USER_PROJECT_DESC="Service Project for ${SERVICE_OS_REGION_NAME}/${SERVICE_OS_PROJECT_DOMAIN_NAME}"
22+
USER_PROJECT_ID=$(openstack project create --or-show --enable -f value -c id \
23+
--domain="${SERVICE_OS_PROJECT_DOMAIN_NAME}" \
24+
--description="${USER_PROJECT_DESC}" \
25+
"${SERVICE_OS_PROJECT_NAME}");
26+
27+
# Display project
28+
openstack project show "${USER_PROJECT_ID}"
29+
30+
# Manage user
31+
USER_DESC="Service User for ${SERVICE_OS_REGION_NAME}/${SERVICE_OS_USER_DOMAIN_NAME}/${SERVICE_OS_SERVICE_NAME}"
32+
USER_ID=$(openstack user create --or-show --enable -f value -c id \
33+
--domain="${SERVICE_OS_USER_DOMAIN_NAME}" \
34+
--project-domain="${SERVICE_OS_PROJECT_DOMAIN_NAME}" \
35+
--project="${USER_PROJECT_ID}" \
36+
--description="${USER_DESC}" \
37+
--password="${SERVICE_OS_PASSWORD}" \
38+
"${SERVICE_OS_USERNAME}");
39+
40+
# Display user
41+
openstack user show "${USER_ID}"
42+
43+
# Manage user role
44+
USER_ROLE_ID=$(openstack role create --or-show -f value -c id \
45+
"${SERVICE_OS_ROLE}");
46+
47+
# Manage user role assignment
48+
openstack role add \
49+
--user="${USER_ID}" \
50+
--user-domain="${SERVICE_OS_USER_DOMAIN_NAME}" \
51+
--project-domain="${SERVICE_OS_PROJECT_DOMAIN_NAME}" \
52+
--project="${USER_PROJECT_ID}" \
53+
"${USER_ROLE_ID}"
54+
55+
# Display user role assignment
56+
openstack role assignment list \
57+
--role="${SERVICE_OS_ROLE}" \
58+
--user-domain="${SERVICE_OS_USER_DOMAIN_NAME}" \
59+
--user="${USER_ID}"
60+
{{- end }}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{{- define "env_ks_openrc_tpl" }}
2+
{{- $ksUserSecret := .ksUserSecret }}
3+
- name: OS_IDENTITY_API_VERSION
4+
value: "3"
5+
- name: OS_AUTH_URL
6+
valueFrom:
7+
secretKeyRef:
8+
name: {{ $ksUserSecret }}
9+
key: OS_AUTH_URL
10+
- name: OS_REGION_NAME
11+
valueFrom:
12+
secretKeyRef:
13+
name: {{ $ksUserSecret }}
14+
key: OS_REGION_NAME
15+
- name: OS_PROJECT_DOMAIN_NAME
16+
valueFrom:
17+
secretKeyRef:
18+
name: {{ $ksUserSecret }}
19+
key: OS_PROJECT_DOMAIN_NAME
20+
- name: OS_PROJECT_NAME
21+
valueFrom:
22+
secretKeyRef:
23+
name: {{ $ksUserSecret }}
24+
key: OS_PROJECT_NAME
25+
- name: OS_USER_DOMAIN_NAME
26+
valueFrom:
27+
secretKeyRef:
28+
name: {{ $ksUserSecret }}
29+
key: OS_USER_DOMAIN_NAME
30+
- name: OS_USERNAME
31+
valueFrom:
32+
secretKeyRef:
33+
name: {{ $ksUserSecret }}
34+
key: OS_USERNAME
35+
- name: OS_PASSWORD
36+
valueFrom:
37+
secretKeyRef:
38+
name: {{ $ksUserSecret }}
39+
key: OS_PASSWORD
40+
{{- end }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- define "env_ks_user_create_openrc_tpl" }}
2+
{{- $ksUserSecret := .ksUserSecret }}
3+
- name: SERVICE_OS_REGION_NAME
4+
valueFrom:
5+
secretKeyRef:
6+
name: {{ $ksUserSecret }}
7+
key: OS_REGION_NAME
8+
- name: SERVICE_OS_PROJECT_DOMAIN_NAME
9+
valueFrom:
10+
secretKeyRef:
11+
name: {{ $ksUserSecret }}
12+
key: OS_PROJECT_DOMAIN_NAME
13+
- name: SERVICE_OS_PROJECT_NAME
14+
valueFrom:
15+
secretKeyRef:
16+
name: {{ $ksUserSecret }}
17+
key: OS_PROJECT_NAME
18+
- name: SERVICE_OS_USER_DOMAIN_NAME
19+
valueFrom:
20+
secretKeyRef:
21+
name: {{ $ksUserSecret }}
22+
key: OS_USER_DOMAIN_NAME
23+
- name: SERVICE_OS_USERNAME
24+
valueFrom:
25+
secretKeyRef:
26+
name: {{ $ksUserSecret }}
27+
key: OS_USERNAME
28+
- name: SERVICE_OS_PASSWORD
29+
valueFrom:
30+
secretKeyRef:
31+
name: {{ $ksUserSecret }}
32+
key: OS_PASSWORD
33+
{{- end }}

0 commit comments

Comments
 (0)