summaryrefslogtreecommitdiffstats
path: root/heat/OpenECOMP/openecomp_rackspace.yaml
blob: fa25ac458d77f3081934bf9b3369b1403e39e66b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
heat_template_version: 2013-05-23

description: Heat template to deploy OpenECOMP components

parameters:

  # Generic parameters used across all OpenECOMP components
  public_net_id:
    type: string
    label: Public network name or ID
    description: Public network that enables remote connection to the compute instance

  key_name:
    type: string
    label: Key pair name
    description: Public/Private key pair name

  pub_key:
    type: string
    label: Public key
    description: Public key or SSL certificate to be installed on the compute instance

  nexus_repo:
    type: string
    label: Nexus Repository
    description: Complete URL for the Nexus repository.

  nexus_docker_repo:
    type: string
    label: Nexus Docker Images Repository
    description: Complete URL for the Nexus repository for docker images.

  nexus_username:
    type: string
    label: Nexus Repository Username
    description: Nexus Repository username

  nexus_password:
    type: string
    label: Nexus Repository Password
    description: Nexus Repository Password
    
  gitlab_username:
    type: string
    label: Gitlab Repository Username
    description: Gitlab Repository username

  gitlab_password:
    type: string
    label: Gitlab Repository Password
    description: Gitlab Repository Password

  dmaap_topic:
    type: string
    label: DmaaP Topic
    description: DmaaP Topic that MSO and A&AI listen to

  artifacts_version:
    type: string
    label: Artifacts Version
    description: Artifacts version of OpenECOMP components


  # Parameters for DCAE instantiation
  dcae_zone:
    type: string
    label: DCAE Zone
    description: DCAE Zone to use in VM names created by DCAE controller

  dcae_state:
    type: string
    label: DCAE State
    description: DCAE State to use in VM names created by DCAE controller

  openstack_tenant_id:
    type: string
    label: Rackspace tenant ID
    description: Rackspace tenant ID

  openstack_username:
    type: string
    label: Rackspace username
    description: Rackspace username

  openstack_api_key:
    type: string
    label: Rackspace API Key
    description: Rackspace API Key

  openstack_password:
    type: string
    label: Rackspace Password
    description: Rackspace Password

  nexus_repo_root:
    type: string
    label: Root URL of nexus repository
    description: Root URL of nexus repository
    
  nexus_url_snapshot:
    type: string
    label: Snapshot of Maven repository for DCAE deployment
    description: Snapshot of Maven repository

  openstack_region:
    type: string
    label: Rackspace Region
    description: Rackspace region where the DCAE controller will spin the VMs

  gitlab_branch:
    type: string
    label: Branch of the Gitlab repository
    description: Branch of the Gitlab repository
    

resources:
  random-str:
    type: OS::Heat::RandomString
    properties:
      length: 4

  # Public key used to access OpenECOMP components
  vm_key:
    type: OS::Nova::KeyPair
    properties:
      name: 
        str_replace:
          template: base_rand
          params:
            base: { get_param: key_name }
            rand: { get_resource: random-str }         
      public_key: { get_param: pub_key }
      save_private_key: false


  # OpenECOMP management private network
  oam_ecomp:
    type: OS::Neutron::Net
    properties:
      name: 
        str_replace:
          template: oam_ecomp_rand
          params:
            rand: { get_resource: random-str }

  oam_ecomp_subnet:
    type: OS::Neutron::Subnet
    properties:
      name: 
        str_replace:
          template: oam_ecomp_rand
          params:
            rand: { get_resource: random-str }
      network_id: { get_resource: oam_ecomp }
      cidr: 10.0.0.0/8
    value: { get_attr: [oam_ecomp, name] }


  # DNS Server instantiation
  dns_private_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: oam_ecomp }
      fixed_ips: [{"subnet": { get_resource: oam_ecomp_subnet }, "ip_address": 10.0.0.1}]

  dns_vm:
    type: OS::Nova::Server
    properties:
      image: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
      flavor: 4 GB General Purpose v1
      name: vm1-dns-server
      key_name: { get_resource: vm_key }
      networks:
        - network: { get_param: public_net_id }
        - port: { get_resource: dns_private_port }
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __nexus_repo__: { get_param: nexus_repo }
            __artifacts_version__: { get_param: artifacts_version }
          template: |
            #!/bin/bash

            # Download dependencies
            add-apt-repository -y ppa:openjdk-r/ppa
            apt-get update
            apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk bind9 bind9utils bind9-doc ntp ntpdate

            # Download script
            mkdir /etc/bind/zones

            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/db_simpledemo_openecomp_org -o /etc/bind/zones/db.simpledemo.openecomp.org
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/named.conf.options -o /etc/bind/named.conf.options
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/named.conf.local -o /etc/bind/named.conf.local

            # Configure Bind
            modprobe ip_gre
            sed -i "s/OPTIONS=.*/OPTIONS=\"-4 -u bind\"/g" /etc/default/bind9
            service bind9 restart


  # A&AI instantiation
  aai_private_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: oam_ecomp }
      fixed_ips: [{"subnet": { get_resource: oam_ecomp_subnet }, "ip_address": 10.0.1.1}]

  aai_volume:
    type: OS::Cinder::Volume
    properties:
      name: vol1-aai
      size: 50
      volume_type: SSD
      image: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)

  aai_vm:
    type: OS::Nova::Server
    depends_on: sdc_vm
    properties:
      flavor: 15 GB Compute v1
      name: vm1-aai
      key_name: { get_resource: vm_key }
      block_device_mapping:
        - volume_id: { get_resource: aai_volume }
          device_name: vda
      networks:
        - network: { get_param: public_net_id }
        - port: { get_resource: aai_private_port }
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __nexus_repo__: { get_param: nexus_repo }
            __nexus_docker_repo__: { get_param: nexus_docker_repo }
            __nexus_username__: { get_param: nexus_username }
            __nexus_password__: { get_param: nexus_password }
            __gitlab_username__: { get_param: gitlab_username }
            __gitlab_password__: { get_param: gitlab_password }
            __dmaap_topic__: { get_param: dmaap_topic }
            __artifacts_version__: { get_param: artifacts_version }
          template: |
            #!/bin/bash

            # DNS/GW IP address configuration
            echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
            resolvconf -u
            
            # Download dependencies
            add-apt-repository -y ppa:openjdk-r/ppa
            apt-get update
            apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk ntp ntpdate

            # Download scripts from Nexus
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/aai_vm_init.sh -o /opt/aai_vm_init.sh
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/aai_serv.sh -o /opt/aai_serv.sh
            chmod +x /opt/aai_vm_init.sh
            chmod +x /opt/aai_serv.sh
            mv /opt/aai_serv.sh /etc/init.d
            update-rc.d aai_serv.sh defaults

            # Download and install docker-engine and docker-compose
            apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
            echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
            apt-get update
            apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
            apt-get install -y docker-engine
            service docker start

            mkdir -p /opt/openecomp/aai/logs
            mkdir -p /opt/openecomp/aai/data
            mkdir /opt/docker
            curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
            chmod +x /opt/docker/docker-compose
            
            # Store credentials in files
            mkdir -p /opt/config
            echo "__nexus_docker_repo__" > /opt/config/nexus_docker_repo.txt
            echo "__nexus_username__" > /opt/config/nexus_username.txt
            echo "__nexus_password__" > /opt/config/nexus_password.txt
            echo "__dmaap_topic__" > /opt/config/dmaap_topic.txt
            echo "__gitlab_username__" > /opt/config/gitlab_username.txt
            echo "__gitlab_password__" > /opt/config/gitlab_password.txt
            echo "gerrit.openecomp.org" > /opt/config/gitlab_certname.txt
            
            # Execute docker instructions
            cd /opt
            ./aai_vm_init.sh


  # MSO instantiation
  mso_private_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: oam_ecomp }
      fixed_ips: [{"subnet": { get_resource: oam_ecomp_subnet }, "ip_address": 10.0.5.1}]

  mso_vm:
    type: OS::Nova::Server
    properties:
      image: Ubuntu 16.04 LTS (Xenial Xerus) (PVHVM)
      flavor: 4 GB General Purpose v1
      name: vm1-mso
      key_name: { get_resource: vm_key }
      networks:
        - network: { get_param: public_net_id }
        - port: { get_resource: mso_private_port }
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __nexus_repo__: { get_param: nexus_repo }
            __nexus_docker_repo__: { get_param: nexus_docker_repo }
            __nexus_username__: { get_param: nexus_username }
            __nexus_password__: { get_param: nexus_password }
            __gitlab_username__: { get_param: gitlab_username }
            __gitlab_password__: { get_param: gitlab_password }
            __openstack_username__: { get_param: openstack_username }
            __openstack_tenant_id__: { get_param: openstack_tenant_id }
            __openstack_api_key__: { get_param: openstack_api_key }
            __dmaap_topic__: { get_param: dmaap_topic }
            __artifacts_version__: { get_param: artifacts_version }
          template: |
            #!/bin/bash

            # DNS/GW IP address configuration
            echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
            resolvconf -u

            # Download dependencies
            add-apt-repository -y ppa:openjdk-r/ppa
            apt-get update
            apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk git ntp ntpdate

            # Download scripts from Nexus
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/mso_vm_init.sh -o /opt/mso_vm_init.sh
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/mso_serv.sh -o /opt/mso_serv.sh
            chmod +x /opt/mso_vm_init.sh
            chmod +x /opt/mso_serv.sh
            mv /opt/mso_serv.sh /etc/init.d
            update-rc.d mso_serv.sh defaults

            # Download and install docker-engine and docker-compose
            apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
            echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
            apt-get update
            apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
            apt-get install -y docker-engine
            service docker start

            mkdir /opt/docker
            curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
            chmod +x /opt/docker/docker-compose

            # Store credentials in files
            mkdir -p /opt/config
            echo "__nexus_docker_repo__" > /opt/config/nexus_docker_repo.txt
            echo "__nexus_username__" > /opt/config/nexus_username.txt
            echo "__nexus_password__" > /opt/config/nexus_password.txt
            echo "__gitlab_username__" > /opt/config/gitlab_username.txt
            echo "__gitlab_password__" > /opt/config/gitlab_password.txt
            echo "__openstack_username__" > /opt/config/openstack_username.txt
            echo "__openstack_tenant_id__" > /opt/config/tenant_id.txt
            echo "__dmaap_topic__" > /opt/config/dmaap_topic.txt
           

            # Run docker-compose to spin up containers
            cd /opt
            git clone https://__gitlab_username__:__gitlab_password__@gerrit.openecomp.org/r/a/mso/docker-config.git test_lab
            MSO_ENCRYPTION_KEY=$(cat /opt/test_lab/encryption.key)
            echo -n "__openstack_api_key__" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 256 -p > /opt/config/api_key.txt
            ./mso_vm_init.sh


  # Message Router instantiation
  mrouter_private_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: oam_ecomp }
      fixed_ips: [{"subnet": { get_resource: oam_ecomp_subnet }, "ip_address": 10.0.11.1}]

  mrouter_vm:
    type: OS::Nova::Server
    properties:
      image: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
      flavor: 15 GB I/O v1
      name: vm1-message-router
      key_name: { get_resource: vm_key }
      networks:
        - network: { get_param: public_net_id }
        - port: { get_resource: mrouter_private_port }
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __nexus_repo__: { get_param: nexus_repo }
            __nexus_docker_repo__: { get_param: nexus_docker_repo }
            __nexus_username__: { get_param: nexus_username }
            __nexus_password__: { get_param: nexus_password }
            __gitlab_username__: { get_param: gitlab_username }
            __gitlab_password__: { get_param: gitlab_password }
            __artifacts_version__: { get_param: artifacts_version }
          template: |
            #!/bin/bash

            # DNS/GW IP address configuration
            echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
            resolvconf -u

            # Download dependencies
            add-apt-repository -y ppa:openjdk-r/ppa
            apt-get update
            apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk ntp ntpdate
            
            # Download scripts from Nexus
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/mr_vm_init.sh -o /opt/mr_vm_init.sh
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/mr_serv.sh -o /opt/mr_serv.sh
            chmod +x /opt/mr_vm_init.sh
            chmod +x /opt/mr_serv.sh
            mv /opt/mr_serv.sh /etc/init.d
            update-rc.d mr_serv.sh defaults

            # Download and install docker-engine and docker-compose
            apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
            echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
            apt-get update
            apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
            apt-get install -y docker-engine
            service docker start

            mkdir /opt/docker
            curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
            chmod +x /opt/docker/docker-compose

            # Store credentials in files
            mkdir -p /opt/config
            echo "__nexus_docker_repo__" > /opt/config/nexus_docker_repo.txt
            echo "__nexus_username__" > /opt/config/nexus_username.txt
            echo "__nexus_password__" > /opt/config/nexus_password.txt
            echo "__gitlab_username__" > /opt/config/gitlab_username.txt
            echo "__gitlab_password__" > /opt/config/gitlab_password.txt

            # Run docker-compose to spin up containers
            cd /opt
            git clone https://__gitlab_username__:__gitlab_password__@gerrit.openecomp.org/r/a/dcae/demo/startup/message-router.git dcae-startup-vm-message-router
            ./mr_vm_init.sh


  # RobotE2E instantiation
  robot_private_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: oam_ecomp }
      fixed_ips: [{"subnet": { get_resource: oam_ecomp_subnet }, "ip_address": 10.0.10.1}]
 
  robot_vm:
    type: OS::Nova::Server
    properties:
      image: Ubuntu 16.04 LTS (Xenial Xerus) (PVHVM)
      flavor: 2 GB General Purpose v1
      name: vm1-robot
      key_name: { get_resource: vm_key }
      networks:
        - network: { get_param: public_net_id }
        - port: { get_resource: robot_private_port }
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __nexus_repo__: { get_param: nexus_repo }
            __nexus_docker_repo__: { get_param: nexus_docker_repo }
            __nexus_username__: { get_param: nexus_username }
            __nexus_password__: { get_param: nexus_password }
            __gitlab_username__: { get_param: gitlab_username }
            __gitlab_password__: { get_param: gitlab_password }
            __network_name__: { get_attr: [oam_ecomp, name] }
            __openstack_username__: { get_param: openstack_username }
            __openstack_api_key__: { get_param : openstack_api_key }
            __openstack_password__: { get_param: openstack_password }
            __artifacts_version__: { get_param: artifacts_version }
            __openstack_region__: { get_param: openstack_region }
          template: |
            #!/bin/bash

            # DNS/GW IP address configuration
            echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
            resolvconf -u
 
            # Download dependencies
            add-apt-repository -y ppa:openjdk-r/ppa
            apt-get update
            apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk ntp ntpdate
            echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic

            # Download scripts from Nexus
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/robot_vm_init.sh -o /opt/robot_vm_init.sh
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/robot_serv.sh -o /opt/robot_serv.sh
            chmod +x /opt/robot_vm_init.sh
            chmod +x /opt/robot_serv.sh
            mv /opt/robot_serv.sh /etc/init.d
            update-rc.d robot_serv.sh defaults
 
            # Download and install docker-engine and docker-compose
            apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
            echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
            apt-get update
            apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
            apt-get install -y docker-engine
            #sed -i 's|^ExecStart=/usr/bin/dockerd \s*-H \s*fd://\s*$|ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375|' /lib/systemd/system/docker.service
            service docker start
 
            mkdir /opt/docker
            curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
            chmod +x /opt/docker/docker-compose
 
            # Store credentials in files
            mkdir -p /opt/config
            echo "__nexus_docker_repo__" > /opt/config/nexus_docker_repo.txt
            echo "__nexus_repo__" > /opt/config/nexus_repo.txt
            echo "__nexus_username__" > /opt/config/nexus_username.txt
            echo "__nexus_password__" > /opt/config/nexus_password.txt
            echo "__gitlab_username__" > /opt/config/gitlab_username.txt
            echo "__gitlab_password__" > /opt/config/gitlab_password.txt
            echo "__network_name__" > /opt/config/network.txt
            echo "__openstack_username__" > /opt/config/openstack_username.txt
            echo "__openstack_password__" > /opt/config/openstack_password.txt
            echo "__openstack_api_key__" > /opt/config/openstack_api_key.txt
            echo "__openstack_region__" > /opt/config/region.txt
            echo "__artifacts_version__" > /opt/config/artifacts_version.txt

            # Execute RobotETE-specific instructions: create share folder to run as a docker volume
            mkdir -p /opt/eteshare/logs
            mkdir -p /opt/eteshare/config

            # Run docker-compose to spin up containers
            cd /opt
            git clone https://__gitlab_username__:__gitlab_password__@gerrit.openecomp.org/r/a/testsuite/properties.git testsuite/properties
            ./robot_vm_init.sh


  # VID instantiation
  vid_private_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: oam_ecomp }
      fixed_ips: [{"subnet": { get_resource: oam_ecomp_subnet }, "ip_address": 10.0.8.1}]

  vid_vm:
    type: OS::Nova::Server
    properties:
      image: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
      flavor: 2 GB General Purpose v1
      name: vm1-vid
      key_name: { get_resource: vm_key }
      networks:
        - network: { get_param: public_net_id }
        - port: { get_resource: vid_private_port }
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __nexus_repo__: { get_param: nexus_repo }
            __nexus_docker_repo__: { get_param: nexus_docker_repo }
            __nexus_username__: { get_param: nexus_username }
            __nexus_password__: { get_param: nexus_password }
            __gitlab_username__: { get_param: gitlab_username }
            __gitlab_password__: { get_param: gitlab_password }
            __artifacts_version__: { get_param: artifacts_version }
          template: |
            #!/bin/bash

            # DNS/GW IP address configuration
            echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
            resolvconf -u

            # Download dependencies
            add-apt-repository -y ppa:openjdk-r/ppa
            apt-get update
            apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk make git ntp ntpdate

            # Download scripts from Nexus
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/vid_vm_init.sh -o /opt/vid_vm_init.sh
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/vid_serv.sh -o /opt/vid_serv.sh
            chmod +x /opt/vid_vm_init.sh
            chmod +x /opt/vid_serv.sh
            mv /opt/vid_serv.sh /etc/init.d
            update-rc.d vid_serv.sh defaults

            # Download and install docker-engine and docker-compose
            apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
            echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
            apt-get update
            apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
            apt-get install -y docker-engine
            service docker start

            mkdir /opt/docker
            curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
            chmod +x /opt/docker/docker-compose

            # Store credentials in files
            mkdir -p /opt/config
            echo "__nexus_docker_repo__" > /opt/config/nexus_docker_repo.txt
            echo "__nexus_username__" > /opt/config/nexus_username.txt
            echo "__nexus_password__" > /opt/config/nexus_password.txt
            echo "__gitlab_username__" > /opt/config/gitlab_username.txt
            echo "__gitlab_password__" > /opt/config/gitlab_password.txt

            # Run script to spin up containers
            cd /opt
            git clone https://__gitlab_username__:__gitlab_password__@gerrit.openecomp.org/r/a/vid.git
            ./vid_vm_init.sh


  # SDN-C instantiation
  sdnc_private_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: oam_ecomp }
      fixed_ips: [{"subnet": { get_resource: oam_ecomp_subnet }, "ip_address": 10.0.7.1}]

  sdnc_vm:
    type: OS::Nova::Server
    properties:
      image: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
      flavor: 4 GB General Purpose v1
      name: vm1-sdnc
      key_name: { get_resource: vm_key }
      networks:
        - network: { get_param: public_net_id }
        - port: { get_resource: sdnc_private_port }
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __nexus_repo__: { get_param: nexus_repo }
            __nexus_docker_repo__: { get_param: nexus_docker_repo }
            __nexus_username__: { get_param: nexus_username }
            __nexus_password__: { get_param: nexus_password }
            __gitlab_username__: { get_param: gitlab_username }
            __gitlab_password__: { get_param: gitlab_password }
            __artifacts_version__: { get_param: artifacts_version }
          template: |
            #!/bin/bash

            # DNS/GW IP address configuration
            mkdir /opt/config
            echo "10.0.0.1" > /opt/config/dns_gw_ip.txt
            echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
            resolvconf -u

            # Download dependencies
            add-apt-repository -y ppa:openjdk-r/ppa
            apt-get update
            apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk ntp ntpdate

            # Download scripts from Nexus
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/sdnc_vm_init.sh -o /opt/sdnc_vm_init.sh
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/sdnc_serv.sh -o /opt/sdnc_serv.sh
            chmod +x /opt/sdnc_vm_init.sh
            chmod +x /opt/sdnc_serv.sh
            mv /opt/sdnc_serv.sh /etc/init.d
            update-rc.d sdnc_serv.sh defaults
            
            # Download and install docker-engine and docker-compose
            apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
            echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
            apt-get update
            apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
            apt-get install -y docker-engine
            service docker start

            mkdir /opt/docker
            curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
            chmod +x /opt/docker/docker-compose
            
            # Store credentials in files
            mkdir -p /opt/config
            echo "__nexus_docker_repo__" > /opt/config/nexus_docker_repo.txt
            echo "__nexus_username__" > /opt/config/nexus_username.txt
            echo "__nexus_password__" > /opt/config/nexus_password.txt
            echo "__gitlab_username__" > /opt/config/gitlab_username.txt
            echo "__gitlab_password__" > /opt/config/gitlab_password.txt

            # Run docker-compose to spin up containers
            cd /opt
            git clone https://__gitlab_username__:__gitlab_password__@gerrit.openecomp.org/r/a/sdnc/oam.git sdnc
            ./sdnc_vm_init.sh


  # SDC instantiation
  sdc_private_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: oam_ecomp }
      fixed_ips: [{"subnet": { get_resource: oam_ecomp_subnet }, "ip_address": 10.0.3.1}]

  sdc_volume_local:
    type: OS::Cinder::Volume
    properties:
      name: vol1-sdc-local
      size: 50
      volume_type: SSD
      image: Ubuntu 16.04 LTS (Xenial Xerus) (PVHVM)

  sdc_volume_data:
    type: OS::Cinder::Volume
    properties:
      name: vol1-sdc-data
      size: 100
      volume_type: SSD

  sdc_volume_attachment:
    type: OS::Cinder::VolumeAttachment
    properties:
      volume_id: { get_resource: sdc_volume_data }
      instance_uuid: { get_resource: sdc_vm }
      mountpoint: /dev/xvdb

  sdc_vm:
    type: OS::Nova::Server
    properties:
      flavor: 15 GB Compute v1
      name: vm1-sdc
      key_name: { get_resource: vm_key }
      block_device_mapping:
        - volume_id: { get_resource: sdc_volume_local }
          device_name: vda
      networks:
        - network: { get_param: public_net_id }
        - port: { get_resource: sdc_private_port }
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __nexus_repo__: { get_param: nexus_repo }
            __nexus_docker_repo__: { get_param: nexus_docker_repo }
            __nexus_username__: { get_param: nexus_username }
            __nexus_password__: { get_param: nexus_password }
            __gitlab_username__: { get_param: gitlab_username }
            __gitlab_password__: { get_param: gitlab_password }
            __env_name__: { get_param: dmaap_topic }
            __artifacts_version__: { get_param: artifacts_version }
          template: |
            #!/bin/bash
            
            # DNS/GW IP address configuration
            mkdir /opt/config
            echo "10.0.0.1" > /opt/config/dns_gw_ip.txt
            echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
            resolvconf -u
          
            # Download dependencies
            add-apt-repository -y ppa:openjdk-r/ppa
            apt-get update
            apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk ntp ntpdate
            
            # Download scripts from Nexus
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/asdc_vm_init.sh -o /opt/asdc_vm_init.sh
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/asdc_serv.sh -o /opt/asdc_serv.sh
            chmod +x /opt/asdc_vm_init.sh
            chmod +x /opt/asdc_serv.sh
            mv /opt/asdc_serv.sh /etc/init.d
            update-rc.d asdc_serv.sh defaults
            
            # Download and install docker-engine and docker-compose
            apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
            echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
            apt-get update
            apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
            apt-get install -y docker-engine
            service docker start
            mkdir /opt/docker
            curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
            chmod +x /opt/docker/docker-compose

            # Create partition and mount the external volume
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/asdc_ext_volume_partitions.txt -o /opt/asdc_ext_volume_partitions.txt
            sfdisk /dev/xvdb < /opt/asdc_ext_volume_partitions.txt
            mkfs -t ext4 /dev/xvdb1
            mkdir -p /data
            mount /dev/xvdb1 /data
            echo "/dev/xvdb1  /data           ext4    errors=remount-ro,noatime,barrier=0 0       1" >> /etc/fstab

            # Store credentials in files
            mkdir -p /opt/config
            echo "__nexus_docker_repo__" > /opt/config/nexus_docker_repo.txt
            echo "__nexus_username__" > /opt/config/nexus_username.txt
            echo "__nexus_password__" > /opt/config/nexus_password.txt
            echo "__gitlab_username__" > /opt/config/gitlab_username.txt
            echo "__gitlab_password__" > /opt/config/gitlab_password.txt
            echo "__env_name__" > /opt/config/env_name.txt
            echo "10.0.11.1" > /opt/config/mr_ip_addr.txt

            # Run SDC-specific instructions
            cd /opt
            mkdir -p /data/environments
            mkdir -p /data/scripts
            mkdir -p /data/logs/BE
            mkdir -p /data/logs/FE
            chmod 777 /data
            chmod 777 /data/logs/BE
            chmod 777 /data/logs/FE

            git clone https://__gitlab_username__:__gitlab_password__@gerrit.openecomp.org/r/a/sdc.git

            cat > /root/.bash_aliases << EOF
            alias dcls='/data/scripts/docker_clean.sh \$1'
            alias dlog='/data/scripts/docker_login.sh \$1'
            alias rund='/data/scripts/docker_run.sh'
            alias health='/data/scripts/docker_health.sh'
            EOF

            # Run docker-compose to spin up containers
            ./asdc_vm_init.sh
            

  # PORTAL instantiation
  portal_private_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: oam_ecomp }
      fixed_ips: [{"subnet": { get_resource: oam_ecomp_subnet }, "ip_address": 10.0.9.1}]

  portal_volume:
    type: OS::Cinder::Volume
    properties:
      name: vol1-portal
      size: 50
      volume_type: SSD
      image: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)

  portal_vm:
    type: OS::Nova::Server
    properties:
      flavor: 15 GB Memory v1
      name: vm1-portal
      key_name: { get_resource: vm_key }
      block_device_mapping:
        - volume_id: { get_resource: portal_volume }
          device_name: vda
      networks:
        - network: { get_param: public_net_id }
        - port: { get_resource: portal_private_port }
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __nexus_repo__: { get_param: nexus_repo }
            __nexus_docker_repo__: { get_param: nexus_docker_repo }
            __nexus_username__: { get_param: nexus_username }
            __nexus_password__: { get_param: nexus_password }
            __gitlab_username__: { get_param: gitlab_username }
            __gitlab_password__: { get_param: gitlab_password }
            __artifacts_version__: { get_param: artifacts_version }
          template: |
            #!/bin/bash
            
            # DNS/GW IP address configuration
            mkdir /opt/config
            echo "10.0.0.1" > /opt/config/dns_gw_ip.txt
            echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
            resolvconf -u
            
            # Download dependencies
            add-apt-repository -y ppa:openjdk-r/ppa
            apt-get update
            apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk unzip mysql-client-core-5.6 ntp ntpdate
            
            # Download scripts from Nexus
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/portal_vm_init.sh -o /opt/portal_vm_init.sh
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/portal_serv.sh -o /opt/portal_serv.sh
            chmod +x /opt/portal_vm_init.sh
            chmod +x /opt/portal_serv.sh
            mv /opt/portal_serv.sh /etc/init.d
            update-rc.d portal_serv.sh defaults
            
            # Download and install docker-engine and docker-compose
            apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
            echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
            apt-get update
            apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
            apt-get install -y docker-engine
            service docker start
            mkdir /opt/docker
            curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
            chmod +x /opt/docker/docker-compose

            # Store credentials in files
            mkdir -p /opt/config
            echo "__nexus_docker_repo__" > /opt/config/nexus_docker_repo.txt
            echo "__nexus_username__" > /opt/config/nexus_username.txt
            echo "__nexus_password__" > /opt/config/nexus_password.txt
            echo "__gitlab_username__" > /opt/config/gitlab_username.txt
            echo "__gitlab_password__" > /opt/config/gitlab_password.txt

            # Run Portal-specific instructions
            mkdir -p /PROJECT/OpenSource/UbuntuEP/logs
            cd /opt
            git clone https://__gitlab_username__:__gitlab_password__@gerrit.openecomp.org/r/a/portal.git

            # Run docker-compose to spin up containers
            ./portal_vm_init.sh


  # DCAE Controller instantiation
  dcae_c_private_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: oam_ecomp }
      fixed_ips: [{"subnet": { get_resource: oam_ecomp_subnet }, "ip_address": 10.0.4.1}]
  dcae_c_vm:
    type: OS::Nova::Server
    properties:
      image: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
      flavor: 8 GB General Purpose v1
      name: vm1-dcae-controller
      key_name: { get_resource: vm_key }
      networks:
        - network: { get_param: public_net_id }
        - port: { get_resource: dcae_c_private_port }
      user_data_format: RAW
      user_data: 
        str_replace:
          params:
            __nexus_repo__: { get_param: nexus_repo }
            __nexus_docker_repo__: { get_param: nexus_docker_repo }
            __nexus_username__: { get_param: nexus_username }
            __nexus_password__: { get_param: nexus_password }
            __nexus_url_snapshots__: { get_param: nexus_url_snapshot }
            __gitlab_username__: { get_param: gitlab_username }
            __gitlab_password__: { get_param: gitlab_password }
            __gitlab_branch__: { get_param: gitlab_branch }
            __dcae_zone__: { get_param: dcae_zone }
            __dcae_state__: { get_param: dcae_state }
            __artifacts_version__: { get_param: artifacts_version }
            __tenant_id__: { get_param: openstack_tenant_id }
            __openstack_private_network_name__: { get_attr: [oam_ecomp, name] }
            __openstack_user__: { get_param: openstack_username }
            __openstack_password__: { get_param: openstack_api_key }
            __key_name__: { get_param: key_name }
            __rand_str__: { get_resource: random-str }
            __pub_key__: { get_param: pub_key }
            __nexus_repo_root__: { get_param: nexus_repo_root }
            __openstack_region__: { get_param: openstack_region }
          template: |
            #!/bin/bash
            
            # DNS/GW IP address configuration
            echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
            resolvconf -u

            # Download dependencies
            add-apt-repository -y ppa:openjdk-r/ppa
            apt-get update
            apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk make git ntp ntpdate

            # Download scripts from Nexus
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/dcae_vm_init.sh -o /opt/dcae_vm_init.sh
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/dcae_serv.sh -o /opt/dcae_serv.sh
            chmod +x /opt/dcae_vm_init.sh
            chmod +x /opt/dcae_serv.sh
            mv /opt/dcae_serv.sh /etc/init.d
            update-rc.d dcae_serv.sh defaults

            # Download and install docker-engine and docker-compose
            apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
            echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
            apt-get update
            apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
            apt-get install -y docker-engine
            service docker start
            mkdir /opt/docker
            curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
            chmod +x /opt/docker/docker-compose
            
            # DCAE Controller specific deployment
            cd /opt
            git clone https://__gitlab_username__:__gitlab_password__@gerrit.openecomp.org/r/a/dcae/demo/startup/controller.git dcae-startup-vm-controller

            cd dcae-startup-vm-controller
            mkdir -p /opt/app/dcae-controller
            cat > /opt/app/dcae-controller/config.yaml << EOF_CONFIG
            ZONE: __dcae_zone__
            STATE: __dcae_state__
            DCAE-VERSION: __artifacts_version__
            HORIZON-URL: https://mycloud.rackspace.com/cloud/__tenant_id__
            KEYSTONE-URL: https://identity.api.rackspacecloud.com/v2.0
            OPENSTACK-TENANT-ID: __tenant_id__
            OPENSTACK-TENANT-NAME: OPEN-ECOMP
            OPENSTACK-REGION: __openstack_region__
            OPENSTACK-PRIVATE-NETWORK: __openstack_private_network_name__
            OPENSTACK-USER: __openstack_user__
            OPENSTACK-PASSWORD: __openstack_password__
            OPENSTACK-KEYNAME: __key_name_____rand_str___dcae
            OPENSTACK-PUBKEY: __pub_key__
            
            NEXUS-URL-ROOT: __nexus_repo_root__
            NEXUS-USER: __nexus_username__
            NEXUS-PASSWORD: __nexus_password__
            NEXUS-URL-SNAPSHOTS: __nexus_url_snapshots__
            NEXUS-RAWURL: __nexus_repo__
            
            DOCKER-REGISTRY: __nexus_docker_repo__

            GIT-MR-REPO: https://__gitlab_username__:__gitlab_password__@gerrit.openecomp.org/r/a/dcae/demo/startup/message-router.git
            EOF_CONFIG

            # Store credentials in files
            mkdir -p /opt/config
            echo "__nexus_docker_repo__" > /opt/config/nexus_docker_repo.txt
            echo "__nexus_username__" > /opt/config/nexus_username.txt
            echo "__nexus_password__" > /opt/config/nexus_password.txt
            echo "__gitlab_username__" > /opt/config/gitlab_username.txt
            echo "__gitlab_password__" > /opt/config/gitlab_password.txt
            echo "__gitlab_branch__" > /opt/config/gitlab_branch.txt

            cd /opt
            ./dcae_vm_init.sh


  # Policy engine instantiation
  policy_private_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: oam_ecomp }
      fixed_ips: [{"subnet": { get_resource: oam_ecomp_subnet }, "ip_address": 10.0.6.1}]

  policy_volume:
    type: OS::Cinder::Volume
    properties:
      name: vol1-policy
      size: 50
      volume_type: SSD
      image: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)

  policy_vm:
    type: OS::Nova::Server
    properties:
      flavor: 15 GB Compute v1
      name: vm1-policy
      key_name: { get_resource: vm_key }
      block_device_mapping:
        - volume_id: { get_resource: policy_volume }
          device_name: vda
      networks:
        - network: { get_param: public_net_id }
        - port: { get_resource: policy_private_port }
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __nexus_repo__: { get_param: nexus_repo }
            __nexus_docker_repo__: { get_param: nexus_docker_repo }
            __nexus_username__: { get_param: nexus_username }
            __nexus_password__: { get_param: nexus_password }
            __gitlab_username__: { get_param: gitlab_username }
            __gitlab_password__: { get_param: gitlab_password }
            __artifacts_version__: { get_param: artifacts_version }
          template: |
            #!/bin/bash
            
            # DNS/GW IP address configuration
            mkdir /opt/config
            echo "10.0.0.1" > /opt/config/dns_gw_ip.txt
            echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
            resolvconf -u

            # Download dependencies
            add-apt-repository -y ppa:openjdk-r/ppa
            apt-get update
            apt-get install -y apt-transport-https ca-certificates wget openjdk-8-jdk ntp ntpdate

            # Download scripts from Nexus
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/policy_vm_init.sh -o /opt/policy_vm_init.sh
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/policy_serv.sh -o /opt/policy_serv.sh
            chmod +x /opt/policy_vm_init.sh
            chmod +x /opt/policy_serv.sh
            mv /opt/policy_serv.sh /etc/init.d
            update-rc.d policy_serv.sh defaults

            # Download and install docker-engine and docker-compose
            apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
            echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
            apt-get update
            apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
            apt-get install -y docker-engine
            service docker start
            mkdir /opt/docker
            curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
            chmod +x /opt/docker/docker-compose

            # Store credentials in files
            mkdir -p /opt/config
            echo "__nexus_docker_repo__" > /opt/config/nexus_docker_repo.txt
            echo "__nexus_username__" > /opt/config/nexus_username.txt
            echo "__nexus_password__" > /opt/config/nexus_password.txt
            echo "__gitlab_username__" > /opt/config/gitlab_username.txt
            echo "__gitlab_password__" > /opt/config/gitlab_password.txt

            # Run docker-compose to spin up containers
            cd /opt
            git clone https://__gitlab_username__:__gitlab_password__@gerrit.openecomp.org/r/a/policy/docker.git policy

            ./policy_vm_init.sh


  # APP-C instantiation
  appc_private_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: oam_ecomp }
      fixed_ips: [{"subnet": { get_resource: oam_ecomp_subnet }, "ip_address": 10.0.2.1}]

  appc_vm:
    type: OS::Nova::Server
    properties:
      image: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
      flavor: 4 GB General Purpose v1
      name: vm1-appc
      key_name: { get_resource: vm_key }
      networks:
        - network: { get_param: public_net_id }
        - port: { get_resource: appc_private_port }
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __nexus_repo__: { get_param: nexus_repo }
            __nexus_docker_repo__: { get_param: nexus_docker_repo }
            __nexus_username__: { get_param: nexus_username }
            __nexus_password__: { get_param: nexus_password }
            __gitlab_username__: { get_param: gitlab_username }
            __gitlab_password__: { get_param: gitlab_password }
            __dmaap_topic__: { get_param: dmaap_topic }
            __artifacts_version__: { get_param: artifacts_version }
          template: |
            #!/bin/bash

            # DNS/GW IP address configuration
            mkdir /opt/config
            echo "10.0.0.1" > /opt/config/dns_gw_ip.txt
            echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
            resolvconf -u

            # Download dependencies
            add-apt-repository -y ppa:openjdk-r/ppa
            apt-get update
            apt-get install -y apt-transport-https ca-certificates wget openjdk-7-jdk ntp ntpdate

            # Download scripts from Nexus
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/appc_vm_init.sh -o /opt/appc_vm_init.sh
            curl -k __nexus_repo__/org.openecomp.demo/boot/__artifacts_version__/appc_serv.sh -o /opt/appc_serv.sh
            chmod +x /opt/appc_vm_init.sh
            chmod +x /opt/appc_serv.sh
            mv /opt/appc_serv.sh /etc/init.d
            update-rc.d appc_serv.sh defaults
            
            # Download and install docker-engine and docker-compose
            apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
            echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
            apt-get update
            apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
            apt-get install -y docker-engine
            service docker start

            mkdir /opt/docker
            curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
            chmod +x /opt/docker/docker-compose
            
            # Store credentials in files
            mkdir -p /opt/config
            echo "__nexus_docker_repo__" > /opt/config/nexus_docker_repo.txt
            echo "__nexus_username__" > /opt/config/nexus_username.txt
            echo "__nexus_password__" > /opt/config/nexus_password.txt
            echo "__gitlab_username__" > /opt/config/gitlab_username.txt
            echo "__gitlab_password__" > /opt/config/gitlab_password.txt
            echo "__dmaap_topic__" > /opt/config/dmaap_topic.txt

            # Run docker-compose to spin up containers
            cd /opt
            git clone https://__gitlab_username__:__gitlab_password__@gerrit.openecomp.org/r/a/appc/deployment.git appc
            ./appc_vm_init.sh