创建以下sfc配置的tacker模板。
+----------------+ +----------------+ +----------------+
| vnf1_001 | | vnf2_001 | | vnf3_001 |
+----------------+ +----------------+ +----------------+
CP11 CP12| CP13| CP21 CP22| CP23| CP31 CP32| CP33|
| | | | | |
VM CP0->-----------+ +-------------+ +-------------+ +--->
(虚拟机内部流量需要自己打通:
可参考:http://blog.csdn.net/linshenyuan1213/article/details/78195061)
1)网络(根据实际情况创建)
# openstack network create net_mgmt
# openstack network create sfc-net-1
# openstack network create sfc-net-2
# openstack network create sfc-net-3
# openstack network create sfc-net-4
# openstack subnet create --network net_mgmt --subnet-range 192.168.6.0/24 subnet_mgmt
# openstack subnet create --network sfc-net-1 --subnet-range 1.0.0.0/24 sfc-subnet-1
# openstack subnet create --network sfc-net-2 --subnet-range 2.0.0.0/24 sfc-subnet-2
# openstack subnet create --network sfc-net-3 --subnet-range 3.0.0.0/24 sfc-subnet-3
# openstack subnet create --network sfc-net-4 --subnet-range 4.0.0.0/24 sfc-subnet-4
2)镜像
创建一个名为 centos7的镜像(或根据自己情况替换自己已有的镜像名称)
3)云主机规格
创建一个名为 lyh-centos7的规格(或根据自己情况替换自己已有的规格名称)
4)创建一个VM,使用sfc-net-1的网络
该VM 的CP0 port_id为 79a4e10c-5133-4681-b6a5-e1993884d1ab
# tacker vnfd-create --vnfd-file /home/vnffgd_sfc_lyh/sfc-vnffg-vnfd1.yaml vnfd1
# tacker vnfd-create --vnfd-file /home/vnffgd_sfc_lyh/sfc-vnffg-vnfd2.yaml vnfd2
# tacker vnfd-create --vnfd-file /home/vnffgd_sfc_lyh/sfc-vnffg-vnfd3.yaml vnfd3
# tacker vnf-create --vnfd-name vnfd1 vnf1_001
# tacker vnf-create --vnfd-name vnfd2 vnf2_001
# tacker vnf-create --vnfd-name vnfd3 vnf3_001
# 不带参数格式
# tacker vnffgd-create --vnffgd-file /home/vnffgd_sfc_lyh/sfc-vnffgd-sample.yaml sfcd_001
# 带参数格式
# tacker vnffgd-create --vnffgd-file /home/vnffgd_sfc_lyh/sfc-vnffgd-param.yaml sfcd_002
# 不带参数格式
# tacker vnffg-create --vnffgd-name sfcd_001
--vnf-mapping VNFD1:vnf1_001,VNFD2:vnf2_001,VNFD3:vnf3_001 sfc_001
# 带参数格式
# tacker vnffg-create --vnffgd-name sfcd_002 \
--param-file /home/vnffgd_sfc_lyh/sfc-vnffg-param-file.yaml \
--vnf-mapping VNFD1:vnf1_001,VNFD2:vnf2_001,VNFD3:vnf3_001 sfc_002
# 参数内容
# cat /home/vnffgd_sfc_lyh/sfc-vnffg-param-file.yaml
id: 52
net_src_port_id: 79a4e10c-5133-4681-b6a5-e1993884d1ab
ip_dst_pre:
- 4.0.0.0/24 #这个为vnfd3_01的CP33的网络子网地址
通过以下命令,可以看到,sfc的配置与我们手动尝试创建的效果是一致的
# neutron port-pair-list
# neutron port-pair-group-list
# neutron flow-classifier-list
# neutron port-chain-list
# cat /home/vnffgd_sfc_lyh/sfc-vnffg-vnfd1.yaml
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
metadata:
template_name: sample-sfc-vnfd1
topology_template:
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: centos7
flavor: lyh-centos7
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
user_data_format: RAW
user_data: |
#!/bin/sh
echo "Adding this line to demofile" > /tmp/demofile
CP11:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
order: 0
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL11
- virtualBinding:
node: VDU1
CP12:
type: tosca.nodes.nfv.CP.Tacker
properties:
order: 1
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL12
- virtualBinding:
node: VDU1
CP13:
type: tosca.nodes.nfv.CP.Tacker
properties:
order: 2
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL13
- virtualBinding:
node: VDU1
VL11:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL12:
type: tosca.nodes.nfv.VL
properties:
network_name: sfc-net-1
vendor: Tacker
VL13:
type: tosca.nodes.nfv.VL
properties:
network_name: sfc-net-2
vendor: Tacker
# cat /home/vnffgd_sfc_lyh/sfc-vnffg-vnfd2.yaml
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
metadata:
template_name: sample-tosca-vnfd2
topology_template:
node_templates:
VDU2:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: centos7
flavor: lyh-centos7
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
user_data_format: RAW
user_data: |
#!/bin/sh
echo "Adding this line to demofile2" > /tmp/demofile2
CP21:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
order: 0
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL21
- virtualBinding:
node: VDU2
CP22:
type: tosca.nodes.nfv.CP.Tacker
properties:
order: 1
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL22
- virtualBinding:
node: VDU2
CP23:
type: tosca.nodes.nfv.CP.Tacker
properties:
order: 2
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL23
- virtualBinding:
node: VDU2
VL21:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL22:
type: tosca.nodes.nfv.VL
properties:
network_name: sfc-net-2
vendor: Tacker
VL23:
type: tosca.nodes.nfv.VL
properties:
network_name: sfc-net-3
vendor: Tacker
# cat /home/vnffgd_sfc_lyh/sfc-vnffg-vnfd3.yaml
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
metadata:
template_name: sample-tosca-vnfd3
topology_template:
node_templates:
VDU3:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: centos7
flavor: lyh-centos7
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
user_data_format: RAW
user_data: |
#!/bin/sh
echo "Adding this line to demofile3" > /tmp/demofile3
CP31:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
order: 0
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL31
- virtualBinding:
node: VDU3
CP32:
type: tosca.nodes.nfv.CP.Tacker
properties:
order: 1
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL32
- virtualBinding:
node: VDU3
CP33:
type: tosca.nodes.nfv.CP.Tacker
properties:
order: 2
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL33
- virtualBinding:
node: VDU3
VL31:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL32:
type: tosca.nodes.nfv.VL
properties:
network_name: sfc-net-3
vendor: Tacker
VL33:
type: tosca.nodes.nfv.VL
properties:
network_name: sfc-net-4
vendor: Tacker
# cat /home/vnffgd_sfc_lyh/sfc-vnffgd-sample.yaml
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Sample VNFFG parameterized template
topology_template:
description: Sample VNFFG parameterized template
node_templates:
Forwarding_path1:
type: tosca.nodes.nfv.FP.Tacker
description: creates path (CP12->CP13->CP22-CP23->CP32->CP33)
properties:
id: 51
policy:
type: ACL
criteria:
- network_src_port_id: 79a4e10c-5133-4681-b6a5-e1993884d1ab
- ip_dst_prefix: 1.0.0.0/24
path:
- forwarder: VNFD1
capability: CP12
- forwarder: VNFD1
capability: CP13
- forwarder: VNFD2
capability: CP22
- forwarder: VNFD2
capability: CP23
- forwarder: VNFD3
capability: CP32
- forwarder: VNFD3
capability: CP33
groups:
VNFFG1:
type: tosca.groups.nfv.VNFFG
description: HTTP to Corporate Net
properties:
vendor: tacker
version: 1.0
number_of_endpoints: 6
dependent_virtual_link: [VL12,VL13,VL22,VL23,VL32,VL33]
connection_point: [CP12,CP13,CP22,CP23,CP32,CP33]
constituent_vnfs: [VNFD1,VNFD2,VNFD3]
members: [Forwarding_path1]
# cat /home/vnffgd_sfc_lyh/sfc-vnffgd-param.yaml
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Sample VNFFG parameterized template
topology_template:
description: Sample VNFFG parameterized template
inputs:
id:
type: string
description: Network Service Header id, should be diffrenet every path.
net_src_port_id:
type: string
description: Port UUID of source VM.
ip_dst_pre:
type: string
description: Cidr format of destination ip.
node_templates:
Forwarding_path1:
type: tosca.nodes.nfv.FP.Tacker
description: creates path (CP12->CP13->CP22-CP23->CP32->CP33)
properties:
id: { get_input: id }
policy:
type: ACL
criteria:
- network_src_port_id: { get_input: net_src_port_id }
- ip_dst_prefix: { get_input: ip_dst_pre }
path:
- forwarder: VNFD1
capability: CP12
- forwarder: VNFD1
capability: CP13
- forwarder: VNFD2
capability: CP22
- forwarder: VNFD2
capability: CP23
- forwarder: VNFD3
capability: CP32
- forwarder: VNFD3
capability: CP33
groups:
VNFFG1:
type: tosca.groups.nfv.VNFFG
description: HTTP to Corporate Net
properties:
vendor: tacker
version: 1.0
number_of_endpoints: 6
dependent_virtual_link: [VL12,VL13,VL22,VL23,VL32,VL33]
connection_point: [CP12,CP13,CP22,CP23,CP32,CP33]
constituent_vnfs: [VNFD1,VNFD2,VNFD3]
members: [Forwarding_path1]
# tacker vnfd-create --vnfd-file /home/vnffgd_sfc_lyh/sfc-vnffg-vnfd1.yaml vnfd1
Created a new vnfd:
+-----------------+--------------------------------------+
| Field | Value |
+-----------------+--------------------------------------+
| created_at | 2017-10-13 01:55:35.664800 |
| description | Demo example |
| id | cb2c915a-322d-43c2-b6e3-23e26de0a303 |
| name | vnfd1 |
| service_types | vnfd |
| template_source | onboarded |
| tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 |
| updated_at | |
+-----------------+--------------------------------------+
# tacker vnfd-create --vnfd-file /home/vnffgd_sfc_lyh/sfc-vnffg-vnfd2.yaml vnfd2
Created a new vnfd:
+-----------------+--------------------------------------+
| Field | Value |
+-----------------+--------------------------------------+
| created_at | 2017-10-13 01:55:56.814992 |
| description | Demo example |
| id | 4e4d917d-daff-4292-bded-f65892501750 |
| name | vnfd2 |
| service_types | vnfd |
| template_source | onboarded |
| tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 |
| updated_at | |
+-----------------+--------------------------------------+
# tacker vnfd-create --vnfd-file /home/vnffgd_sfc_lyh/sfc-vnffg-vnfd3.yaml vnfd3
Created a new vnfd:
+-----------------+--------------------------------------+
| Field | Value |
+-----------------+--------------------------------------+
| created_at | 2017-10-13 01:56:15.163242 |
| description | Demo example |
| id | ac78ca22-f07f-4f7a-9a0a-02853d0e84e9 |
| name | vnfd3 |
| service_types | vnfd |
| template_source | onboarded |
| tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 |
| updated_at | |
+-----------------+--------------------------------------+
# tacker vnfd-list
+--------------------------------------+-------+-----------------+--------------+
| id | name | template_source | description |
+--------------------------------------+-------+-----------------+--------------+
| 4e4d917d-daff-4292-bded-f65892501750 | vnfd2 | onboarded | Demo example |
| ac78ca22-f07f-4f7a-9a0a-02853d0e84e9 | vnfd3 | onboarded | Demo example |
| cb2c915a-322d-43c2-b6e3-23e26de0a303 | vnfd1 | onboarded | Demo example |
+--------------------------------------+-------+-----------------+--------------+
2) 创建3个VNF
# tacker vnf-create --vnfd-name vnfd1 vnf1_001
Created a new vnf:
+----------------+--------------------------------------+
| Field | Value |
+----------------+--------------------------------------+
| created_at | 2017-10-13 01:57:02.486806 |
| description | Demo example |
| error_reason | |
| id | fd9d0e13-e9d8-448b-8196-6ea7528c6f68 |
| instance_id | 55bd6f37-270e-4982-9201-dd2bb702afe3 |
| mgmt_url | |
| name | vnf1_001 |
| placement_attr | {"vim_name": "test_vim"} |
| status | PENDING_CREATE |
| tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 |
| updated_at | |
| vim_id | 9ede7118-7d78-4003-8909-63ca6ec956e4 |
| vnfd_id | cb2c915a-322d-43c2-b6e3-23e26de0a303 |
+----------------+--------------------------------------+
# tacker vnf-create --vnfd-name vnfd2 vnf2_001
Created a new vnf:
+----------------+--------------------------------------+
| Field | Value |
+----------------+--------------------------------------+
| created_at | 2017-10-13 01:57:22.455830 |
| description | Demo example |
| error_reason | |
| id | 0275d180-28f0-4705-8881-baf4137e9dab |
| instance_id | 5350c81b-85ec-4ac3-8df1-c37ca8499a46 |
| mgmt_url | |
| name | vnf2_001 |
| placement_attr | {"vim_name": "test_vim"} |
| status | PENDING_CREATE |
| tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 |
| updated_at | |
| vim_id | 9ede7118-7d78-4003-8909-63ca6ec956e4 |
| vnfd_id | 4e4d917d-daff-4292-bded-f65892501750 |
+----------------+--------------------------------------+
# tacker vnf-create --vnfd-name vnfd3 vnf3_001
Created a new vnf:
+----------------+--------------------------------------+
| Field | Value |
+----------------+--------------------------------------+
| created_at | 2017-10-13 01:57:31.490614 |
| description | Demo example |
| error_reason | |
| id | da2b9fb7-48dd-44c5-993e-075c8c36d856 |
| instance_id | 7973407d-54e6-490b-a5e1-53031707ac55 |
| mgmt_url | |
| name | vnf3_001 |
| placement_attr | {"vim_name": "test_vim"} |
| status | PENDING_CREATE |
| tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 |
| updated_at | |
| vim_id | 9ede7118-7d78-4003-8909-63ca6ec956e4 |
| vnfd_id | ac78ca22-f07f-4f7a-9a0a-02853d0e84e9 |
+----------------+--------------------------------------+
# tacker vnf-list
+--------------------------------------+----------+---------------------------+--------+
| id | name | mgmt_url | status |
+--------------------------------------+----------+---------------------------+--------+
| 0275d180-28f0-4705-8881-baf4137e9dab | vnf2_001 | {"VDU2": "192.168.6.118"} | ACTIVE |
| da2b9fb7-48dd-44c5-993e-075c8c36d856 | vnf3_001 | {"VDU3": "192.168.6.119"} | ACTIVE |
| fd9d0e13-e9d8-448b-8196-6ea7528c6f68 | vnf1_001 | {"VDU1": "192.168.6.116"} | ACTIVE |
+--------------------------------------+----------+---------------------------+--------+
3) 创建1个VNFFGD
# 不带参数格式
# tacker vnffgd-create --vnffgd-file /home/vnffgd_sfc_lyh/sfc-vnffgd-sample.yaml sfcd_001
Created a new vnffgd:
+-----------------+-------------------------------------+
| Field | Value |
+-----------------+-------------------------------------+
| description | |
| id | 9bb32af4-0eff-4733-88c4-e935f20121e6|
| name | sfcd_001 |
| template | ... |
| template_source | onboarded |
| tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 |
+-----------------+-------------------------------------+
# 带参数格式
# tacker vnffgd-create --vnffgd-file /home/vnffgd_sfc_lyh/sfc-vnffgd-param.yaml sfcd_002
Created a new vnffgd:
+-----------------+-------------------------------------+
| Field | Value |
+-----------------+-------------------------------------+
| description | |
| id | ad2583f2-1d87-4fdc-af91-05058f312cc0|
| name | sfcd_002 |
| template | ... |
| template_source | onboarded |
| tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 |
+-----------------+-------------------------------------+
# tacker vnffgd-list
+--------------------------------------+----------+-------------+
| id | name | description |
+--------------------------------------+----------+-------------+
| 9bb32af4-0eff-4733-88c4-e935f20121e6 | sfcd_001 | |
| ad2583f2-1d87-4fdc-af91-05058f312cc0 | sfcd_002 | |
+--------------------------------------+----------+-------------+
4) 创建1个VNFFG
# 不带参数格式
# tacker vnffg-create --vnffgd-name sfcd_001
--vnf-mapping VNFD1:vnf1_001,VNFD2:vnf2_001,VNFD3:vnf3_001 sfc_001
# 带参数格式
# tacker vnffg-create --vnffgd-name sfcd_002 \
--param-file /home/vnffgd_sfc_lyh/sfc-vnffg-param-file.yaml \
--vnf-mapping VNFD1:vnf1_001,VNFD2:vnf2_001,VNFD3:vnf3_001 sfc_002
Created a new vnffg:
+------------------+--------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------+
| description | |
| forwarding_paths | d63b4356-5c54-444c-9f9d-78ed4059f2d6 |
| id | d8f28c30-c776-43bc-bbc5-9efb6205a0ce |
| name | sfc_002 |
| status | PENDING_CREATE |
| tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 |
| vnf_mapping | {"VNFD3": "da2b9fb7-48dd-44c5-993e-075c8c36d856",|
| | "VNFD2": "0275d180-28f0-4705-8881-baf4137e9dab",|
| | "VNFD1": "fd9d0e13-e9d8-448b-8196-6ea7528c6f68"}|
| vnffgd_id | ad2583f2-1d87-4fdc-af91-05058f312cc0 |
+------------------+--------------------------------------------------+
# tacker vnffg-list
+---------+--------+--------------------------------------+
| name | status | vnffgd_id |
+---------+--------+--------------------------------------+
| sfc_002 | ACTIVE | ad2583f2-1d87-4fdc-af91-05058f312cc0 |
+---------+--------+--------------------------------------+
# 参数文件内容
# cat /home/vnffgd_sfc_lyh/sfc-vnffg-param-file.yaml
id: 52
net_src_port_id: 79a4e10c-5133-4681-b6a5-e1993884d1ab
ip_dst_pre:
- 1.0.0.0/24
5) 创建后的环境sfc配置信息
# neutron port-pair-list
+--------------------------------------+----------------------------+--------------------------------------+--------------------------------------+
| id | name | ingress | egress |
+--------------------------------------+----------------------------+--------------------------------------+--------------------------------------+
| 0a436042-3aa4-4a37-a0c7-3dfafa3b5aa1 | vnf3_001-connection-points | 081055ef-803e-425b-bb2b-ab97b37c0f69 | 0d31d060-50bb-40df-b6db-3822086819a3 |
| dc243e56-da23-4f3d-85ca-5fd6925ff199 | vnf1_001-connection-points | 30eb47d9-f580-4f6b-b206-178d0aad7acc | 976a893d-15a6-4dfe-81e1-7d1a21cc42ac |
| e2faa1d1-c0cc-48ba-b050-3547fb9b4ad4 | vnf2_001-connection-points | 412b9268-0b4d-4880-8e0a-e83d74043044 | 87655097-9d9d-4568-9824-b00b3be81829 |
+--------------------------------------+----------------------------+--------------------------------------+--------------------------------------+
# neutron port-pair-group-list
+--------------------------------------+--------------------------+-----------------------------------------+
| id | name | port_pairs |
+--------------------------------------+--------------------------+-----------------------------------------+
| 387154eb-2b82-4f94-ba0c-72e8c937cda3 | vnf1_001-port-pair-group | ['dc243e56-da23-4f3d-85ca-5fd6925ff199']|
| a91aba46-042e-4fbd-866b-bbe52bb95750 | vnf2_001-port-pair-group | ['e2faa1d1-c0cc-48ba-b050-3547fb9b4ad4']|
| aff723b4-cd8e-4c65-954c-98b51200efe7 | vnf3_001-port-pair-group | ['0a436042-3aa4-4a37-a0c7-3dfafa3b5aa1']|
+--------------------------------------+--------------------------+-----------------------------------------+
# neutron flow-classifier-list
+--------------------------------------+------------------------------------------------------------+
| id | summary |
+--------------------------------------+------------------------------------------------------------+
| 6d2a045e-4190-4a97-b1b8-f6ae40099f97 | protocol: any, |
| | source[port]: any[any:any], |
| | destination[port]: 1.0.0.0/24[any:any], |
| | neutron_source_port: 79a4e10c-5133-4681-b6a5-e1993884d1ab, |
| | neutron_destination_port: None, |
| | l7_parameters: {} |
+--------------------------------------+------------------------------------------------------------+
# neutron port-chain-list
+--------------------+------------------------------------------+----------------------------------------+
| name | port_pair_groups | flow_classifiers |
+--------------------+------------------------------------------+----------------------------------------+
| sfc_002-port-chain | ['387154eb-2b82-4f94-ba0c-72e8c937cda3', |['6d2a045e-4190-4a97-b1b8-f6ae40099f97']|
| | 'a91aba46-042e-4fbd-866b-bbe52bb95750', | |
| | 'aff723b4-cd8e-4c65-954c-98b51200efe7'] | |
+--------------------+-----------------------------------------------------------------------------------+