add ccsdk-sli-northbound
[infra/cicd.git] / jjb / onap-offline / build_jobs / scripts / 1_build_stack_creation_2.sh
1 #!/bin/bash
2 # Create OpenStack heat template file
3
4 cat <<EOF > ${heat_template}
5 heat_template_version: 2013-05-23
6
7 description: Simple template to deploy a single compute instance
8
9 parameters:
10   instance_name:
11     type: string
12     label: Instance Name
13     description: Name of the instance to be used
14   key:
15     type: string
16     label: Key Name
17     description: Name of key-pair to be used for compute instance
18   image_name:
19     type: string
20     label: Image ID
21     description: Image to be used for compute instance
22   flavor_name:
23     type: string
24     label: Instance Type
25     description: Type of instance (flavor) to be used
26   public_net_id:
27     type: string
28     label: Netid
29     description: public NetId
30   public_net_subnet:
31     type: string
32     label: subnet
33     description: public subnet NetId
34   onap_sg:
35     type: string
36     default: default
37   volume_name:
38     type: string
39     default: onap_offline_build_volume
40   volume_size:
41     type: number
42     default: 400
43
44
45 resources:
46   VMwithvolume_0_private_port:
47     type: OS::Neutron::Port
48     properties:
49       network: { get_param: public_net_id }
50       fixed_ips: [{"subnet": { get_param: public_net_subnet }}]
51       security_groups:
52       - { get_param: onap_sg }
53
54
55   VMwithvolume_0:
56     type: OS::Nova::Server
57     properties:
58       name: { get_param: instance_name }
59       availability_zone: nova
60       key_name: { get_param: key }
61       image: { get_param: image_name }
62       flavor: { get_param: flavor_name }
63       networks:
64       - port: { get_resource: VMwithvolume_0_private_port }
65       user_data_format: RAW
66       user_data:
67         str_replace:
68           params:
69              __mount_dir__: "aa"
70           template: |
71             #!/bin/bash
72             set -e
73
74
75             while [ ! -e /dev/vdb ]; do echo Waiting for volume /dev/sdb to attach; sleep 1; done
76
77
78
79             echo "Partitions not formated, format it as ext4"
80             # yes /dev/disk/by-id/, partprobe and hdparm show it is there, but no it is is not ready
81             sleep 1
82             mkfs.ext4 /dev/vdb
83             file -sL /dev/disk/by-id/*
84
85             mkdir -pv /tmp
86             # mount on reboot
87             echo "/dev/vdb /tmp ext4 defaults,nofail 0 0" >> /etc/fstab
88             # mount now
89             mount /tmp
90
91   cinder_volume:
92     type: OS::Cinder::Volume
93     properties:
94       name: { get_param: volume_name }
95       size: { get_param: volume_size }
96
97   volume_attachment:
98     type: OS::Cinder::VolumeAttachment
99     properties:
100       volume_id: { get_resource: cinder_volume }
101       instance_uuid: { get_resource: VMwithvolume_0 }
102       mountpoint: /dev/vdb
103 EOF