[novcp] Add deploy argument `-N` (experimental)
[fuel.git] / mcp / scripts / xdf_data.sh.j2
1 #!/bin/bash -e
2 # shellcheck disable=SC2034
3 ##############################################################################
4 # Copyright (c) 2018 Mirantis Inc., Enea AB and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 #
11 # Data derived from XDF (PDF/IDF/SDF/etc), used as input in deploy.sh
12 #
13
14 {%- set arch = conf[conf.MCP_JUMP_ARCH] -%}
15
16 {%- macro bash_arr(_l) -%}
17   ({%- for n in _l -%}'{{ n }}' {% endfor -%})
18 {%- endmacro -%}
19
20 {#- Pack list as `sep`-separated string, replacing spaces with '|' -#}
21 {%- macro pack(x = [], sep = ',') -%}
22   {{ x | join(sep) | replace(' ', '|') }}
23 {%- endmacro -%}
24
25 {#- Pack all vnode data as string -#}
26 {%- macro serialize_vnodes() -%}
27   {%- set V = conf.virtual -%}
28   {%- set arr = [] -%}
29   {%- for n in V.nodes -%}
30     {%- if n not in V -%}{%- do V.update({n: {}}) -%}{%- endif -%}
31     {%- do arr.append(pack([n, V[n].ram or arch.default.ram,
32                                V[n].vcpus or arch.default.vcpus])) -%}
33   {%- endfor -%}
34   '{{ pack(arr, '|') }}'
35 {%- endmacro -%}
36
37 {#- Pack apt_pkg data as string -#}
38 {%- macro serialize_apt_pkg() -%}
39   {%- set arr = [] -%}
40   {%- set sections = [arch.common] -%}
41   {%- if conf.MCP_VCP -%}
42     {%- do sections.append(arch.control) -%}
43   {%- endif -%}
44   {%- for c in sections -%}
45     {%- do arr.append(pack([pack(c.apt['keys']), pack(c.apt.repos),
46                             pack(c.pkg.install), pack(c.pkg.remove)], '^')) -%}
47   {%- endfor -%}
48   '{{ pack(arr, '^') }}'
49 {%- endmacro -%}
50
51 {%- set bridges = conf.idf.fuel.jumphost.bridges %}
52 # Determine bridge names based on IDF, where all bridges are now mandatory
53 OPNFV_BRIDGES=(
54   '{{ bridges.admin or "pxebr" }}'
55   '{{ bridges.mgmt or "mgmt" }}'
56   '{{ bridges.private or "internal" }}'
57   '{{ bridges.public or "public" }}'
58 )
59
60 export CLUSTER_DOMAIN={{ conf.cluster.domain }}
61 cluster_states={{ bash_arr(conf.cluster.states) }}
62 virtual_nodes={{ bash_arr(conf.virtual.nodes) }}
63 base_image={{ arch.base_image }}
64
65 # Serialize vnode data as '<name0>,<ram0>,<vcpu0>|<name1>,<ram1>,<vcpu1>[...]'
66 virtual_nodes_data={{ serialize_vnodes() }}
67
68 # Serialize repos, packages to (pre-)install/remove for:
69 # - foundation node VM base image (virtual: all VMs, baremetal: cfg01|mas01)
70 # - virtualized control plane VM base image (only when VCP is used)
71 virtual_repos_pkgs={{ serialize_apt_pkg() }}