Bulk update to deployment
[dcaegen2/deployments.git] / cm-container / scripts / get-type-files.sh
1 #!/bin/bash
2 # ============LICENSE_START=======================================================
3 # org.onap.dcae
4 # ================================================================================
5 # Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
6 # ================================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END=========================================================
19
20 # Pull type files from repos
21 # Set up the CM import resolver
22 # $1 is the DCAE repo URL
23 # $2 is the CCSDK repo URL
24 #
25 set -x
26 DEST=/opt/manager/resources/onapspec
27 EXTRA_RULES=/opt/manager/extra-resolver-rules
28
29 DCAETYPEFILES=\
30 "\
31 /dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml \
32 /relationshipplugin/1.0.0/relationshipplugin_types.yaml \
33 /k8splugin/1.4.5/k8splugin_types.yaml \
34 /k8splugin/1.4.12/k8splugin_types.yaml \
35
36 "
37
38 CCSDKTYPEFILES=\
39 "\
40 /type_files/pgaas/1.1.0/pgaas_types.yaml \
41 /type_files/sshkeyshare/sshkey_types.yaml \
42 /type_files/helm/4.0.0/helm-type.yaml \
43 /type_files/dmaap/dmaap.yaml \
44 "
45
46 mkdir ${DEST}
47
48 for typefile in ${DCAETYPEFILES}
49 do
50         mkdir -p ${DEST}/$(dirname ${typefile})
51         curl -Ss $1/${typefile} >> ${DEST}/${typefile}
52 done
53
54 for typefile in ${CCSDKTYPEFILES}
55 do
56         mkdir -p ${DEST}/$(dirname ${typefile})
57         curl -Ss $2/${typefile} >> ${DEST}/${typefile}
58 done
59
60 chown cfyuser:cfyuser ${DEST}
61
62 # Add our local type file store to CM import resolver configuration
63 TYPE_RULE0="{\"$1\": \"file://${DEST}\"}"
64 TYPE_RULE1="{\"$2\": \"file://${DEST}\"}"
65 # This sed re is 'brittle' but we can be sure the config.yaml file
66 # won't change as long as we do not change the source Docker image for CM
67 sed -i -e "s#      rules:#      rules:\n      - ${TYPE_RULE0}#" /etc/cloudify/config.yaml
68 sed -i -e "s#      rules:#      rules:\n      - ${TYPE_RULE1}#" /etc/cloudify/config.yaml
69
70 chown cfyuser:cfyuser /etc/cloudify/config.yaml
71
72 # Changing /etc/cloudify/config.yaml is no longer sufficient
73 # Need to provide the additional rules in a file that can be
74 # used at deployment time to update the resolver rules
75 echo "- ${TYPE_RULE0}" > ${EXTRA_RULES}
76 echo "- ${TYPE_RULE1}" >> ${EXTRA_RULES}