aboutsummaryrefslogtreecommitdiffstats
path: root/heat/vIPsec/vIPsec/base_vipsec.yaml
blob: f59bdc18b61e24eefe59712b3ce157c5eebb1425 (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
##########################################################################
#
#==================LICENSE_START==========================================
#
# Copyright © Intel Corporation 2019
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#==================LICENSE_END============================================
#
##########################################################################

heat_template_version: 2013-05-23

description: Heat template that deploys vIPsec demo app for ONAP

##############
#            #
# PARAMETERS #
#            #
##############

parameters:
  basic_image_name:
    type: string
    label: Image name or ID
    description: Image to be used for IPsec compute instance
  ipsec_flavor_name:
    type: string
    label: IPsec Flavor
    description: Type of instance (flavor) to be used for IPsec VM
  sink_flavor_name:
    type: string
    label: Flavor
    description: Type of instance (flavor) to be used for vSink VM
  packetgen_flavor_name:
    type: string
    label: Flavor
    description: Type of instance (flavor) to be used for packet generator
  public_net_id:
    type: string
    label: Public network name or ID
    description: Public network that enables remote connection to VNF
  protected_clientA_private_net_id:
    type: string
    label: protected private network name or ID
    description: Private network that connects vPacketGenerator with vIPsec gateway A
  protected_clientB_private_net_id:
    type: string
    label: Protected private network name or ID
    description: Private network that connects vIPsec gateway B with vSink
  protected_clientA_provider_net_id:
    type: string
    label: Provider network name or ID for client A
    description: Private network that connects vPacketGenerator with vIPsec gateway A
  protected_clientB_provider_net_id:
    type: string
    label: Provider network name or ID for client B
    description: Private network that connects vIPsec gateway B with vSink
  ipsec_provider_net_id:
    type: string
    label: Provider network name or ID between IPsec gateways
    description: Private network that connects vIPsec gateway B with vIPsec gateway A
  onap_private_net_id:
    type: string
    label: ONAP management network name or ID
    description: Private network that connects ONAP components and the VNF
  onap_private_subnet_id:
    type: string
    label: ONAP management sub-network name or ID
    description: Private sub-network that connects ONAP components and the VNF
  ipsec_private_net_id:
    type: string
    label: IPsec private network name or ID
    description: Private network that connects the two IPsec VNFs
  protected_clientA_private_net_cidr:
    type: string
    label: Unprotected private network CIDR
    description: The CIDR of the protected private network for clientA
  protected_clientB_private_net_cidr:
    type: string
    label: Protected private network CIDR
    description: The CIDR of the protected private network for clientB
  onap_private_net_cidr:
    type: string
    label: ONAP private network CIDR
    description: The CIDR of the protected private network
  ipsec_private_net_cidr:
    type: string
    label: IPsec private network CIDR
    description: The CIDR of the protected IPsec private network
  vipsec_A_private_ip_0:
    type: string
    label: vIPsec private IP address towards the protected network A
    description: Private IP address that is assigned to the vIPsec gateway A to communicate with the vPacketGenerator
  vipsec_A_private_ip_1:
    type: string
    label: vIPsec private IP address towards the ONAP management network
    description: Private IP address that is assigned to the vIPsec A to communicate with ONAP components
  vipsec_A_private_ip_2:
    type: string
    label: vIPsec private IP address towards the IPsec external network
    description: Private IP address that is assigned to the vIPsec A to communicate with vIPsec B
  vipsec_B_private_ip_0:
    type: string
    label: vIPsec private IP address towards the protected network B
    description: Private IP address that is assigned to the vIPsec gateway B to communicate with the vSink
  vipsec_B_private_ip_1:
    type: string
    label: vIPsec private IP address towards the ONAP management network
    description: Private IP address that is assigned to the vIPsec B to communicate with ONAP components
  vipsec_B_private_ip_2:
    type: string
    label: vIPsec private IP address towards the IPsec external network
    description: Private IP address that is assigned to the vIPsec B to communicate with vIPsec A
  vpg_private_ip_0:
    type: string
    label: vPacketGenerator private IP address towards the protected network A
    description: Private IP address that is assigned to the vPacketGenerator to communicate with the vIPsec gateway A
  vpg_private_ip_1:
    type: string
    label: vPacketGenerator private IP address towards the ONAP management network
    description: Private IP address that is assigned to the vPacketGenerator to communicate with ONAP components
  vsn_private_ip_0:
    type: string
    label: vSink private IP address towards the protected network
    description: Private IP address that is assigned to the vSink to communicate with the vIPsec gateway B
  vsn_private_ip_1:
    type: string
    label: vSink private IP address towards the ONAP management network
    description: Private IP address that is assigned to the vSink to communicate with ONAP components
  vipsec_A_private_0_port_vnic_type:
    type: string
    description: vipsec port 0 vnic type (normal, direct)
    default: normal
  vipsec_private_1_port_vnic_type:
    type: string
    description: vipsec port 1 vnic type (normal, direct)
    default: normal
  vipsec_B_private_0_port_vnic_type:
    type: string
    description: vipsec port 0 vnic type (normal, direct)
    default: normal
  vipsec_private_2_port_vnic_type:
    type: string
    description: vipsec port 2 vnic type (normal, direct)
    default: normal
  vsn_private_0_port_vnic_type:
    type: string
    description: vsn port 0 vnic type (normal, direct)
    default: normal
  vsn_private_1_port_vnic_type:
    type: string
    description: vsn port 1 vnic type (normal, direct)
    default: normal
  vpg_private_0_port_vnic_type:
    type: string
    description: vpg port 0 vnic type (normal, direct)
    default: normal
  vpg_private_1_port_vnic_type:
    type: string
    description: vpg port 1 vnic type (normal, direct)
    default: normal
  vipsec_name_0:
    type: string
    label: vIPsec name
    description: Name of the vIPsec gateway A
  vipsec_name_1:
    type: string
    label: vIPsec name
    description: Name of the vIPsec gateway B
  vpg_name_0:
    type: string
    label: vPacketGenerator name
    description: Name of the vPacketGenerator
  vsn_name_0:
    type: string
    label: vSink name
    description: Name of the vSink
  vnf_id:
    type: string
    label: VNF ID
    description: The VNF ID is provided by ONAP
  vf_module_id:
    type: string
    label: vIPsec module ID
    description: The vIPsec Module ID is provided by ONAP
  dcae_collector_ip:
    type: string
    label: DCAE collector IP address
    description: IP address of the DCAE collector
  dcae_collector_port:
    type: string
    label: DCAE collector port
    description: Port of the DCAE collector
  key_name:
    type: string
    label: Key pair name
    description: Public/Private key pair name
  pub_key:
    type: string
    label: Public key
    description: Public key to be installed on the compute instance
  install_script_version:
    type: string
    label: Installation script version number
    description: Version number of the scripts that install the vIPsec demo app
  demo_artifacts_version:
    type: string
    label: Artifacts version used in demo vnfs
    description: Artifacts (jar, tar.gz) version used in demo vnfs
  nexus_artifact_repo:
    type: string
    description: Root URL for the Nexus repository for Maven artifacts.
    default: "https://nexus.onap.org"
  cloud_env:
    type: string
    label: Cloud environment
    description: Cloud environment (e.g., openstack, rackspace)
  input_device_interface_A:
    type: string
    description: Device BDF name for the interface
  input_device_interface_B:
    type: string
    description: Device BDF name for the interface
  output_device_interface_A:
    type: string
    description: Device BDF name for the interface
  output_device_interface_B:
    type: string
    description: Device BDF name for the interface
  input_interface_A:
    type: string
    description: Device BDF num for the interface
  input_interface_B:
    type: string
    description: Device BDF num for the interface
  output_interface_A:
    type: string
    description: Device BDF num for the interface
  output_interface_B:
    type: string
    description: Device BDF num for the interface
  vpp_config:
    type: string
    description: Name of the vpp config
  ipsec_config:
    type: string
    description: Name of the ipsec config
  ipsec_A_MAC_address:
    type: string
    description: MAC address of ipsec gateway A
  ipsec_B_MAC_address:
    type: string
    description: MAC address of ipsec gateway B

#############
#           #
# RESOURCES #
#           #
#############

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

  my_keypair:
    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

  security_group_ipsec:
    type: OS::Neutron::SecurityGroup
    properties:
      name: "ipsec_sg"
      rules:
      - {direction: ingress, remote_ip_prefix: 0.0.0.0/0, protocol: icmp }
      - {direction: ingress, remote_ip_prefix: 0.0.0.0/0, protocol: tcp, port_range_min: 22, port_range_max: 22}

  onap_private_net:
    type: OS::Neutron::Net
    properties:
      name: { get_param: onap_private_net_id }

  onap_private_subnet:
    type: OS::Neutron::Subnet
    properties:
      name: { get_param: onap_private_subnet_id }
      network_id: { get_resource: onap_private_net }
      cidr: { get_param: onap_private_net_cidr }
      dns_nameservers: [ "8.8.8.8" ]

  router:
    type: OS::Neutron::Router
    properties:
      name:
        list_join: ['-', [{ get_param: 'OS::stack_name' }, 'router']]
      external_gateway_info:
        network: { get_param: public_net_id }

  oam_router_interface:
    type: OS::Neutron::RouterInterface
    properties:
      router_id: { get_resource: router }
      subnet_id: { get_resource: onap_private_subnet }

  ipsec_0_floating_ip:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network_id: { get_param: public_net_id }
      port_id: { get_resource: vipsec_A_private_1_port }

  ipsec_1_floating_ip:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network_id: { get_param: public_net_id }
      port_id: { get_resource: vipsec_B_private_1_port }

  protected_clientA_private_network:
    type: OS::Neutron::ProviderNet
    properties:
      name: { get_param: protected_clientA_private_net_id }
      physical_network: { get_param: protected_clientA_provider_net_id }
      network_type: vlan

  protected_clientB_private_network:
    type: OS::Neutron::ProviderNet
    properties:
      name: { get_param: protected_clientB_private_net_id }
      physical_network: { get_param: protected_clientB_provider_net_id }
      network_type: vlan

  protected_ipsec_network:
    type: OS::Neutron::ProviderNet
    properties:
      name: { get_param: ipsec_private_net_id }
      physical_network: { get_param: ipsec_provider_net_id }
      network_type: vlan

  protected_clientA_private_subnet:
    type: OS::Neutron::Subnet
    properties:
      network_id: { get_resource: protected_clientA_private_network }
      cidr: { get_param: protected_clientA_private_net_cidr }

  protected_clientB_private_subnet:
    type: OS::Neutron::Subnet
    properties:
      network_id: { get_resource: protected_clientB_private_network }
      cidr: { get_param: protected_clientB_private_net_cidr }

  ipsec_private_subnet:
    type: OS::Neutron::Subnet
    properties:
      network_id: { get_resource: protected_ipsec_network }
      cidr: { get_param: ipsec_private_net_cidr }

  # Virtual IPsec instantiation
  vipsec_A_private_0_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: protected_clientA_private_network }
      binding:vnic_type: { get_param: vipsec_A_private_0_port_vnic_type}
      fixed_ips: [{"subnet": { get_resource: protected_clientA_private_subnet}, "ip_address": { get_param: vipsec_A_private_ip_0 }}]
      security_groups:
      - { get_resource: security_group_ipsec }

  vipsec_A_private_1_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: onap_private_net }
      binding:vnic_type: { get_param: vipsec_private_1_port_vnic_type}
      fixed_ips: [{"subnet": { get_resource: onap_private_subnet }, "ip_address": { get_param: vipsec_A_private_ip_1 }}]
      security_groups:
      - { get_resource: security_group_ipsec }

  vipsec_A_private_2_port:
    type: OS::Neutron::Port
    properties:
      allowed_address_pairs: [{ "ip_address": { get_param: vpg_private_ip_0 }}]
      network: { get_resource: protected_ipsec_network }
      binding:vnic_type: { get_param: vipsec_private_2_port_vnic_type}
      fixed_ips: [{"subnet": { get_resource: ipsec_private_subnet }, "ip_address": { get_param: vipsec_A_private_ip_2 }}]
      security_groups:
      - { get_resource: security_group_ipsec }

  vipsec_B_private_0_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: protected_clientB_private_network }
      binding:vnic_type: { get_param: vipsec_B_private_0_port_vnic_type}
      fixed_ips: [{"subnet": { get_resource: protected_clientB_private_subnet}, "ip_address": { get_param: vipsec_B_private_ip_0 }}]
      security_groups:
      - { get_resource: security_group_ipsec }

  vipsec_B_private_1_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: onap_private_net }
      binding:vnic_type: { get_param: vipsec_private_1_port_vnic_type}
      fixed_ips: [{"subnet": { get_resource: onap_private_subnet }, "ip_address": { get_param: vipsec_B_private_ip_1 }}]
      security_groups:
      - { get_resource: security_group_ipsec }

  vipsec_B_private_2_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: protected_ipsec_network }
      binding:vnic_type: { get_param: vipsec_private_2_port_vnic_type}
      fixed_ips: [{"subnet": { get_resource: ipsec_private_subnet }, "ip_address": { get_param: vipsec_B_private_ip_2 }}]
      security_groups:
      - { get_resource: security_group_ipsec }

  vipsec_0:
    type: OS::Nova::Server
    properties:
      image: { get_param: basic_image_name }
      flavor: { get_param: ipsec_flavor_name }
      name: { get_param: vipsec_name_0 }
      key_name: { get_resource: my_keypair }
      networks:
        - port: { get_resource: vipsec_A_private_0_port }
        - port: { get_resource: vipsec_A_private_1_port }
        - port: { get_resource: vipsec_A_private_2_port }
      metadata: { vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __dcae_collector_ip__: { get_param: dcae_collector_ip }
            __dcae_collector_port__: { get_param: dcae_collector_port }
            __demo_artifacts_version__: { get_param: demo_artifacts_version }
            __install_script_version__: { get_param: install_script_version }
            __vipsec_A_private_ip_0__: { get_param: vipsec_A_private_ip_0 }
            __vipsec_A_private_ip_1__: { get_param: vipsec_A_private_ip_1 }
            __protected_clientA_private_net_cidr__: { get_param: protected_clientA_private_net_cidr }
            __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
            __cloud_env__: { get_param: cloud_env }
            __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
            __vpp_config__: { get_param: vpp_config }
            __ipsec_config__: { get_param: ipsec_config }
            __input_interface_num__: { get_param: input_interface_A }
            __output_interface_num__: { get_param: output_interface_A }
            __input_interface__: { get_param: input_device_interface_A }
            __output_interface__: { get_param: output_device_interface_A }
            __ipsec_B_MAC_address__: { get_param: ipsec_B_MAC_address }
          template: |
            #!/bin/bash

            # Create configuration files
            mkdir /opt/config
            echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
            echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
            echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
            echo "__install_script_version__" > /opt/config/install_script_version.txt
            echo "__vipsec_A_private_ip_0__" > /opt/config/vipsec_A_private_ip_0.txt
            echo "__vipsec_A_private_ip_1__" > /opt/config/vipsec_A_private_ip_1.txt
            echo "__protected_clientA_private_net_cidr__" > /opt/config/protected_clientA_private_net_cidr.txt
            echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
            echo "__cloud_env__" > /opt/config/cloud_env.txt
            echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
            echo "__input_interface_num__" > /opt/config/input_interface_A_BDF_num.txt
            echo "__output_interface_num__" > /opt/config/output_interface_A_BDF_num.txt
            echo "__input_interface__" > /opt/config/input_interface_A.txt
            echo "__output_interface__" > /opt/config/output_interface_A.txt
            echo "__ipsec_B_MAC_address__" > /opt/config/ipsec_B_mac_address.txt
            echo "__vpp_config__" > /opt/config/vpp_config.txt
            echo "__ipsec_config__" > /opt/config/ipsec_config.txt

            # Download and run install script
            apt-get update
            wget https://packagecloud.io/install/repositories/fdio/release/script.deb.sh
            bash ./script.deb.sh
            apt install -y vpp
            apt install -y vpp-plugin-dpdk
            apt install -y make gcc libnuma-dev python
            cd /opt
            git clone http://dpdk.org/git/dpdk
            cd dpdk
            export RTE_TARGET=x86_64-native-linuxapp-gcc/
            export DESTDIR=/opt/dpdk
            export RTE_SDK=/opt/dpdk
            make install T=x86_64-native-linux-gcc
            modprobe uio
            insmod x86_64-native-linux-gcc/kmod/igb_uio.ko
            python ./usertools/dpdk-devbind.py -b igb_uio 00:06.0
            python ./usertools/dpdk-devbind.py -b igb_uio 00:05.0
            cd /opt/config
            cat > __vpp_config__<< NEWFILE

            unix {
                    exec __ipsec_config__
                    nodaemon
                    cli-listen /run/vpp/cli.sock
                    log /tmp/vpp.log
                 }

            cpu {
                   main-core 0
                   corelist-workers 1
                }

            dpdk {
                    socket-mem 512
                    log-level debug
                    no-tx-checksum-offload
                    dev default{
                            num-tx-desc 512
                            num-rx-desc 512
                    }
                    dev __input_interface_num__
                    {
                            workers 0
                    }
                    dev __output_interface_num__
                    {
                            workers 0
                    }
                    vdev crypto_aesni_gcm0

                    no-multi-seg
                 }

            NEWFILE

            cat > __ipsec_config__<< NEWFILE

            set interface state __input_interface__ up
            set interface state __output_interface__ up

            set interface ip address __input_interface__ 1.0.0.1/8
            set interface ip address __output_interface__ 255.0.0.128/8

            set int promiscuous on __input_interface__
            set int promiscuous on __output_interface__

            set ip arp __output_interface__ 255.0.0.129 __ipsec_B_MAC_address
            set ip arp __input_interface__ 1.0.0.2 11:11:11:11:00:11

            ip route add count 1 104.0.0.0/32 via 255.0.0.129 __output_interface__
            ip route add count 1 004.0.0.0/32 via 1.0.0.2 __input_interface__

            ipsec spd add 1
            set interface ipsec spd __output_interface__ 1
            ipsec sa add 1 spi 25500128 esp tunnel-src 255.0.0.128 tunnel-dst 255.0.0.129 crypto-key 2b7e151628aed2a6abf7158809cf4f3d crypto-alg aes-cbc-128 integ-key 6867666568676665686766656867666568676669 integ-alg sha1-96
            ipsec sa add 2 spi 25500129 esp tunnel-src 255.0.0.129 tunnel-dst 255.0.0.128 crypto-key 2b7e151628aed2a6abf7158809cf4f3d crypto-alg aes-cbc-128 integ-key 6867666568676665686766656867666568676669 integ-alg sha1-96
            ipsec policy add spd 1 outbound priority 100 action protect sa 1 remote-ip-range 104.0.0.0-104.0.0.0
            ipsec policy add spd 1 inbound priority 100 action protect sa 2 remote-ip-range 004.0.0.0-004.0.0.0
            ipsec policy add spd 1 inbound priority 90 protocol 50 action bypass
            ipsec policy add spd 1 outbound priority 90 protocol 50 action bypass

            NEWFILE

            vpp -c __vpp_config__

  vipsec_1:
    type: OS::Nova::Server
    properties:
      image: { get_param: basic_image_name }
      flavor: { get_param: ipsec_flavor_name }
      name: { get_param: vipsec_name_1 }
      key_name: { get_resource: my_keypair }
      networks:
        - port: { get_resource: vipsec_B_private_0_port }
        - port: { get_resource: vipsec_B_private_1_port }
        - port: { get_resource: vipsec_B_private_2_port }
      metadata: { vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            __dcae_collector_ip__: { get_param: dcae_collector_ip }
            __dcae_collector_port__: { get_param: dcae_collector_port }
            __demo_artifacts_version__: { get_param: demo_artifacts_version }
            __install_script_version__: { get_param: install_script_version }
            __vipsec_A_private_ip_0__: { get_param: vipsec_B_private_ip_0 }
            __vipsec_A_private_ip_1__: { get_param: vipsec_B_private_ip_1 }
            __protected_clientA_private_net_cidr__: { get_param: protected_clientB_private_net_cidr }
            __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
            __cloud_env__: { get_param: cloud_env }
            __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
            __vpp_config__: { get_param: vpp_config }
            __ipsec_config__: { get_param: ipsec_config }
            __input_interface_num__: { get_param: input_interface_B }
            __output_interface_num__: { get_param: output_interface_B }
            __input_interface__: { get_param: input_device_interface_B }
            __output_interface__: { get_param: output_device_interface_B }
            __ipsec_A_MAC_address__: { get_param: ipsec_A_MAC_address }
          template: |
            #!/bin/bash

            # Create configuration files
            mkdir /opt/config
            echo "__dcae_collector_ip__" > /opt/config/dcae_collector_ip.txt
            echo "__dcae_collector_port__" > /opt/config/dcae_collector_port.txt
            echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
            echo "__install_script_version__" > /opt/config/install_script_version.txt
            echo "__vipsec_B_private_ip_0__" > /opt/config/vipsec_B_private_ip_0.txt
            echo "__vipsec_B_private_ip_1__" > /opt/config/vipsec_B_private_ip_1.txt
            echo "__protected_clientA_private_net_cidr__" > /opt/config/protected_clientB_private_net_cidr.txt
            echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
            echo "__cloud_env__" > /opt/config/cloud_env.txt
            echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt
            echo "__input_interface_num__" > /opt/config/input_interface_B_BDF_num.txt
            echo "__output_interface_num__" > /opt/config/output_interface_B_BDF_num.txt
            echo "__input_interface__" > /opt/config/input_interface_B.txt
            echo "__output_interface__" > /opt/config/output_interface_B.txt
            echo "__ipsec_A_MAC_address__" > /opt/config/ipsec_A_mac_address.txt
            echo "__vpp_config__" > /opt/config/vpp_config.txt
            echo "__ipsec_config__" > /opt/config/ipsec_config.txt

            # Download and run install script
            apt-get update
            wget https://packagecloud.io/install/repositories/fdio/release/script.deb.sh
            bash ./script.deb.sh
            apt install -y vpp
            apt install -y vpp-plugin-dpdk
            apt install -y make gcc libnuma-dev python
            cd /opt
            git clone http://dpdk.org/git/dpdk
            cd /opt/dpdk
            export RTE_TARGET=x86_64-native-linuxapp-gcc/
            export DESTDIR=/opt/dpdk
            export RTE_SDK=/opt/dpdk
            make install T=x86_64-native-linux-gcc
            modprobe uio
            insmod x86_64-native-linux-gcc/kmod/igb_uio.ko
            python ./usertools/dpdk-devbind.py -b igb_uio 00:05.0
            python ./usertools/dpdk-devbind.py -b igb_uio 00:06.0
            cd /opt/config
            cat > __vpp_config__<< NEWFILE

            unix {
                    exec __ipsec_config__
                    nodaemon
                    cli-listen /run/vpp/cli.sock
                    log /tmp/vpp.log
                 }

            cpu {
                   main-core 0
                   corelist-workers 1
                }

            dpdk {
                    socket-mem 512
                    log-level debug
                    no-tx-checksum-offload
                    dev default{
                            num-tx-desc 512
                            num-rx-desc 512
                    }
                    dev __input_interface_num__
                    {
                            workers 0
                    }
                    dev __output_interface_num__
                    {
                            workers 0
                    }
                    vdev crypto_aesni_gcm0

                    no-multi-seg
                 }

            NEWFILE

            cat > __ipsec_config__<< NEWFILE

            set interface state __input_interface__ up
            set interface state __output_interface__ up

            set interface ip address __input_interface__ 1.0.0.1/8
            set interface ip address __output_interface__ 255.0.0.128/8

            set int promiscuous on __input_interface__
            set int promiscuous on __output_interface__

            set ip arp __output_interface__ 255.0.0.129 __ipsec_A_MAC_address
            set ip arp __input_interface__ 1.0.0.2 11:11:11:11:00:11

            ip route add count 1 104.0.0.0/32 via 255.0.0.129 __output_interface__
            ip route add count 1 004.0.0.0/32 via 1.0.0.2 __input_interface__

            ipsec spd add 1
            set interface ipsec spd __output_interface__ 1
            ipsec sa add 1 spi 25500128 esp tunnel-src 255.0.0.128 tunnel-dst 255.0.0.129 crypto-key 2b7e151628aed2a6abf7158809cf4f3d crypto-alg aes-cbc-128 integ-key 6867666568676665686766656867666568676669 integ-alg sha1-96
            ipsec sa add 2 spi 25500129 esp tunnel-src 255.0.0.129 tunnel-dst 255.0.0.128 crypto-key 2b7e151628aed2a6abf7158809cf4f3d crypto-alg aes-cbc-128 integ-key 6867666568676665686766656867666568676669 integ-alg sha1-96
            ipsec policy add spd 1 outbound priority 100 action protect sa 1 remote-ip-range 104.0.0.0-104.0.0.0
            ipsec policy add spd 1 inbound priority 100 action protect sa 2 remote-ip-range 004.0.0.0-004.0.0.0
            ipsec policy add spd 1 inbound priority 90 protocol 50 action bypass
            ipsec policy add spd 1 outbound priority 90 protocol 50 action bypass

            NEWFILE

            vpp -c __vpp_config__


  # Virtual Packet Generator instantiation
  vpg_private_0_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: protected_clientA_private_network}
      binding:vnic_type: { get_param: vpg_private_0_port_vnic_type}
      fixed_ips: [{"subnet": { get_resource: protected_clientA_private_subnet }, "ip_address": { get_param: vpg_private_ip_0 }}]
      security_groups:
      - { get_resource: security_group_ipsec }

  vpg_private_1_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: onap_private_net }
      binding:vnic_type: { get_param: vpg_private_1_port_vnic_type}
      fixed_ips: [{"subnet": { get_resource: onap_private_subnet }, "ip_address": { get_param: vpg_private_ip_1 }}]
      security_groups:
      - { get_resource: security_group_ipsec }


  vpg_0_floating_ip:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network_id: { get_param: public_net_id }
      port_id: { get_resource: vpg_private_1_port }

   vpg_0:
     type: OS::Nova::Server
     properties:
       image: { get_param: basic_image_name }
       flavor: { get_param: packetgen_flavor_name }
       name: { get_param: vpg_name_0 }
       key_name: { get_resource: my_keypair }
       networks:
         - port: { get_resource: vpg_private_0_port }
         - port: { get_resource: vpg_private_1_port }
       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
       user_data_format: RAW
       user_data:
         str_replace:
           params:
             __ipsec_ipaddr__: { get_param: vipsec_A_private_ip_0 }
             __protected_clientB_net_cidr__: { get_param: protected_clientB_private_net_cidr }
             __sink_ipaddr__: { get_param: vsn_private_ip_0 }
             __demo_artifacts_version__: { get_param: demo_artifacts_version }
             __install_script_version__: { get_param: install_script_version }
             __vpg_private_ip_0__: { get_param: vpg_private_ip_0 }
             __vpg_private_ip_1__: { get_param: vpg_private_ip_1 }
             __protected_clientA_net_cidr__: { get_param: protected_clientA_private_net_cidr }
             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
             __cloud_env__: { get_param: cloud_env }
             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
           template: |
             #!/bin/bash

             # Create configuration files
             mkdir /opt/config
             echo "__ipsec_ipaddr__" > /opt/config/vipsec_ipaddr.txt
             echo "__protected_clientB_net_cidr__" > /opt/config/protected_clientB_net_cidr.txt
             echo "__sink_ipaddr__" > /opt/config/sink_ipaddr.txt
             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
             echo "__install_script_version__" > /opt/config/install_script_version.txt
             echo "__vpg_private_ip_0__" > /opt/config/vpg_private_ip_0.txt
             echo "__vpg_private_ip_1__" > /opt/config/vpg_private_ip_1.txt
             echo "__protected_clientA__net_cidr__" > /opt/config/protected_clientA_net_cidr.txt
             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
             echo "__cloud_env__" > /opt/config/cloud_env.txt
             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt

             # Download and run install script
             apt-get update
             apt-get -y install unzip
             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vipsec&a=vipsec-scripts&e=zip&v=__install_script_version__" -o /opt/vipsec-scripts-__install_script_version__.zip
             unzip -j /opt/vipsec-scripts-__install_script_version__.zip -d /opt v_packetgen_install.sh
             cd /opt
             chmod +x v_packetgen_install.sh
             ./v_packetgen_install.sh


  # Virtual Sink instantiation
  vsn_private_0_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: protected_clientB_private_network }
      binding:vnic_type: { get_param: vsn_private_0_port_vnic_type}
      fixed_ips: [{"subnet": { get_resource: protected_clientB_private_subnet }, "ip_address": { get_param: vsn_private_ip_0 }}]
      security_groups:
      - { get_resource: security_group_ipsec }

  vsn_private_1_port:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: onap_private_net }
      binding:vnic_type: { get_param: vsn_private_1_port_vnic_type}
      fixed_ips: [{"subnet": { get_resource: onap_private_subnet }, "ip_address": { get_param: vsn_private_ip_1 }}]
      security_groups:
      - { get_resource: security_group_ipsec }

  vsn_floating_ip:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network_id: { get_param: public_net_id }
      port_id: { get_resource: vsn_private_1_port }

   vsn_0:
     type: OS::Nova::Server
     properties:
       image: { get_param: basic_image_name }
       flavor: { get_param: sink_flavor_name }
       name: { get_param: vsn_name_0 }
       key_name: { get_resource: my_keypair }
       networks:
         - port: { get_resource: vsn_private_0_port }
         - port: { get_resource: vsn_private_1_port }
       metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}
       user_data_format: RAW
       user_data:
         str_replace:
           params:
             __protected_net_gw__: { get_param: vipsec_B_private_ip_0 }
             __protected_net_A__: { get_param: protected_clientA_private_net_cidr }
             __install_script_version__: { get_param: install_script_version }
             __vsn_private_ip_0__: { get_param: vsn_private_ip_0 }
             __vsn_private_ip_1__: { get_param: vsn_private_ip_1 }
             __protected_clientB_private_net_cidr__: { get_param: protected_clientB_private_net_cidr }
             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
             __cloud_env__: { get_param: cloud_env }
             __nexus_artifact_repo__: { get_param: nexus_artifact_repo }
           template: |
             #!/bin/bash

             # Create configuration files
             mkdir /opt/config
             echo "__protected_net_gw__" > /opt/config/protected_net_gw.txt
             echo "__protected_net_A__" > /opt/config/protected_net_A.txt
             echo "__install_script_version__" > /opt/config/install_script_version.txt
             echo "__vsn_private_ip_0__" > /opt/config/vsn_private_ip_0.txt
             echo "__vsn_private_ip_1__" > /opt/config/vsn_private_ip_1.txt
             echo "__protected_clientB_private_net_cidr__" > /opt/config/protected_clientB_private_net_cidr.txt
             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
             echo "__cloud_env__" > /opt/config/cloud_env.txt
             echo "__nexus_artifact_repo__" > /opt/config/nexus_artifact_repo.txt

             # Download and run install script
             apt-get update
             apt-get -y install unzip
             if [[ "__install_script_version__" =~ "SNAPSHOT" ]]; then REPO=snapshots; else REPO=releases; fi
             curl -k -L "__nexus_artifact_repo__/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.demo.vnf.vipsec&a=vipsec-scripts&e=zip&v=__install_script_version__" -o /opt/vipsec-scripts-__install_script_version__.zip
             unzip -j /opt/vipsec-scripts-__install_script_version__.zip -d /opt v_sink_install.sh
             cd /opt
             chmod +x v_sink_install.sh
             ./v_sink_install.sh