Adaptation of PnP PNF simulator heat template
[integration.git] / test / mocks / pnfsimulator / deployment / PnP_PNF_sim_heat_template_Ubuntu_16_04.yml
1 description: Heat template that deploys PnP PNF simulator
2 heat_template_version: '2013-05-23'
3 outputs:
4   PNF_PnP_simualtor_private_ip:
5     description: IP address of PNF_PnP_simualtor in private network
6     value:
7       get_attr: [PNF_PnP_simualtor, first_address]
8   PNF_PnP_simualtor_public_ip:
9     description: Floating IP address of PNF_PnP_simualtor in public network
10     value:
11       get_attr: [PNF_PnP_simualtor_public, floating_ip_address]
12 parameters:
13   flavor_name:
14     description: Type of instance (flavor) to be used
15     label: Flavor
16     type: string
17   image_name:
18     description: Ubuntu 16.04 image to be used
19     label: Image name or ID
20     type: string
21   key_name:
22     description: Public/Private key pair name
23     label: Key pair name
24     type: string
25   private_net_id:
26     description: Private network id
27     label: Private network name or ID
28     type: string
29   private_subnet_id:
30     description: Private subnet id
31     label: Private subnetwork name or ID
32     type: string
33   public_net_id:
34     description: Public network that enables remote connection to VNF
35     label: Public network name or ID
36     type: string
37   security_group:
38     default: default
39     description: Security group to be used
40     label: Security Groups
41     type: string
42   proxy:
43     default: ''
44     description: Proxy
45     label: Proxy
46     type: string
47   correlation_id:
48     default: 'someId'
49     description: Correlation ID
50     label: Correlation ID
51     type: string
52   VES-HOST:
53     default: 'VES-HOST'
54     description: VES collector host ip
55     label: VES ip
56     type: string
57   VES-PORT:
58     default: 'VES-PORT'
59     description: VES collector host port
60     label: VES port
61     type: string
62 resources:
63   PNF_PnP_simualtor:
64     properties:
65       flavor:
66         get_param: flavor_name
67       image:
68         get_param: image_name
69       key_name:
70         get_param: key_name
71       networks:
72       - port:
73           get_resource: PNF_PnP_simualtor_port0
74       user_data:
75         str_replace:
76           params:
77             $proxy:
78               get_param: proxy
79             $VES-PORT:
80               get_param: VES-PORT
81             $VES-HOST:
82               get_param: VES-HOST
83             $correlation_id:
84               get_param: correlation_id
85           template: |
86             #!/bin/bash
87
88             set_versions () {
89                 DOCKER_VERSION=17.03
90                 DOCKER_COMPOSE_VERSION=1.22.0
91                 PROTOBUF_VERSION=3.6.1
92             }
93
94             enable_root_ssh () {
95                 sed -i 's/PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
96                 sed -i 's/PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
97                 service sshd restart
98                 echo -e "onap\nonap" | passwd root
99             }
100
101             update_os () {
102                 rm -rf /var/lib/apt/lists/*
103                 apt-get clean
104                 apt-get update
105             }
106
107             docker_install_and_configure () {
108                 curl "https://releases.rancher.com/install-docker/$DOCKER_VERSION.sh" | sh
109                 mkdir -p /etc/systemd/system/docker.service.d/
110                 cat > /etc/systemd/system/docker.service.d/docker.conf << EOF
111             [Service]
112             ExecStart=
113             ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry=nexus3.onap.org:10003
114             Environment="HTTP_PROXY=$proxy"
115             Environment="HTTPS_PROXY=$proxy"
116             EOF
117                 systemctl daemon-reload
118                 systemctl restart docker
119                 apt-mark hold docker-ce
120                 docker login -u docker -p docker nexus3.onap.org:10003
121             }
122
123             docker_compose_install () {
124                 curl -L "https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
125                 chmod +x /usr/local/bin/docker-compose
126             }
127
128             pnf_sim_file_checkout () {
129                 cd /root; git clone https://gerrit.onap.org/r/integration
130                 printf "{\n  \"simulatorParams\": {\n    \"vesServerUrl\": \"http://$VES-HOST:$VES-PORT/eventListener/v7\",\n    \"testDuration\": \"10\",\n    \"messageInterval\": \"1\"\n  },\n  \"commonEventHeaderParams\": {\n    \"eventName\": \"pnfRegistration_Nokia_5gDu\",\n    \"nfNamingCode\": \"gNB\",\n    \"nfcNamingCode\": \"oam\",\n    \"sourceName\": \"$correlation_id\",\n    \"sourceId\": \"val13\",\n    \"reportingEntityName\": \"NOK6061ZW3\"\n  },\n  \"pnfRegistrationParams\": {\n    \"serialNumber\": \"6061ZW3\",\n    \"vendorName\": \"Nokia\",\n    \"oamV4IpAddress\": \"val3\",\n    \"oamV6IpAddress\": \"val4\",\n    \"unitFamily\": \"BBU\",\n    \"modelNumber\": \"val6\",\n    \"softwareVersion\": \"val7\",\n    \"unitType\": \"val8\"\n  }\n}" > integration/test/mocks/pnfsimulator/config/config.json
131             }
132
133             start_simulator () {
134                docker login -u docker -p docker nexus3.onap.org:10003
135                cd ~/integration/test/mocks/pnfsimulator
136                ./simulator.sh start
137             }
138
139             set_versions
140             enable_root_ssh
141             update_os
142             docker_install_and_configure
143             docker_compose_install
144             pnf_sim_file_checkout
145             start_simulator
146
147     type: OS::Nova::Server
148   PNF_PnP_simualtor_port0:
149     properties:
150       fixed_ips:
151       - subnet_id:
152           get_param: private_subnet_id
153       network_id:
154         get_param: private_net_id
155       security_groups:
156       - get_param: security_group
157     type: OS::Neutron::Port
158   PNF_PnP_simualtor_public:
159     properties:
160       floating_network_id:
161         get_param: public_net_id
162       port_id:
163         get_resource: PNF_PnP_simualtor_port0
164     type: OS::Neutron::FloatingIP
165