OpenStack Tacker介绍 - 5.创建一个简单的VNFFG,即实现一个SFC服务链的自动化创建
2017-10-11 16:25
435 查看
说明:
本文基于已经搭建好的tacker环境,实践tacker基于模板创建一个SFC服务链。
1、环境准备
1.1 、网络配置
其中:
net_mgmt:为public网络,并且能够与云平台的管理网络互通
net0: 为vxlan网络
net1: 为vxlan网络
1.2、镜像
预先创建一个镜像名称为cirros-0.3.5-x86_64-disk的镜像
镜像 cirros-0.3.5-x86_64-disk.img 下载路径
http://download.cirros-cloud.net/0.3.5/
1.3 、预先创建一个VIM
1) 定义一个VIM配置文件
2)创建VIM
说明:test_vim为默认,创建VNFD的时候如果没有指定具体VIM,则使用该VIM
1.4、其他
其他跟多请参考
http://blog.csdn.net/linshenyuan1213/article/details/78131686 http://blog.csdn.net/linshenyuan1213/article/details/78195061
2、创建2个VNFD
说明:VNFD的描述文件在本文最下面
tosca-vnffg-vnfd1.yaml的获取路径:
https://github.com/openstack/tacker/blob/master/samples/tosca-templates/vnffgd/tosca-vnffg-vnfd1.yaml
tosca-vnffg-vnfd2.yaml的获取路径:
https://github.com/openstack/tacker/blob/master/samples/tosca-templates/vnffgd/tosca-vnffg-vnfd2.yaml
3、基于VNFD创建2个VNF
4、创建一个VNFFGD
tosca-vnffgd-param-sample.yaml获取路径如下,本文末尾也会提供
https://github.com/openstack/tacker/blob/master/samples/tosca-templates/vnffgd/tosca-vnffgd-param-sample.yaml
5、最终创建一个VNFFG
vnffg-param-file内容如下
6、VNFFG创建成功
7、创建后的环境配置信息
8、以上通过tacker创建了一个vnffd,即openstack的SFC服务链
再通过配置各个VNF虚拟机内部的流量处理逻辑,既可以实现网络流量的编排。
9、自动化配置VNF虚拟机内部流量处理逻辑的特性
当前tacker实现了一个openwrt的后端驱动,在创建vnf的时候,将想要做的配置放在config里传进去并进行配置
这里可以看下tacker中的mgmt_driver:
代码位于 tacker/vnfm/mgmt_drivers/openwrt/openwrt.py
说白了,就是通过ssh到VNF上,执行一些配置命令,根据这个特性,可以自己开发自己VNF的驱动。
10、文中用到的yaml模板内容
本文基于已经搭建好的tacker环境,实践tacker基于模板创建一个SFC服务链。
1、环境准备
1.1 、网络配置
# neutron net-list +-----------+----------------+ | name | subnets | +-----------+----------------+ | net0 | 172.16.30.0/24 | | net1 | 172.16.40.0/24 | | net_mgmt | 192.168.6.0/24 | +-----------+----------------+
其中:
net_mgmt:为public网络,并且能够与云平台的管理网络互通
net0: 为vxlan网络
net1: 为vxlan网络
1.2、镜像
预先创建一个镜像名称为cirros-0.3.5-x86_64-disk的镜像
镜像 cirros-0.3.5-x86_64-disk.img 下载路径
http://download.cirros-cloud.net/0.3.5/
1.3 、预先创建一个VIM
1) 定义一个VIM配置文件
# cat /root/config.yaml auth_url: http://127.0.0.1:5000/v3 username: admin password: admin project_name: admin user_domain_name: Default project_domain_name: Default
2)创建VIM
说明:test_vim为默认,创建VNFD的时候如果没有指定具体VIM,则使用该VIM
# tacker vim-register --is-default --config-file /root/config.yaml test_vim
1.4、其他
其他跟多请参考
http://blog.csdn.net/linshenyuan1213/article/details/78131686 http://blog.csdn.net/linshenyuan1213/article/details/78195061
2、创建2个VNFD
说明:VNFD的描述文件在本文最下面
tosca-vnffg-vnfd1.yaml的获取路径:
https://github.com/openstack/tacker/blob/master/samples/tosca-templates/vnffgd/tosca-vnffg-vnfd1.yaml
tosca-vnffg-vnfd2.yaml的获取路径:
https://github.com/openstack/tacker/blob/master/samples/tosca-templates/vnffgd/tosca-vnffg-vnfd2.yaml
# tacker vnfd-create --vnfd-file /home/vnffgd/tosca-vnffg-vnfd1.yaml vnfd1 Created a new vnfd: +-----------------+--------------------------------------+ | Field | Value | +-----------------+--------------------------------------+ | created_at | 2017-10-11 06:27:04.098382 | | description | Demo example | | id | 104a402b-9acc-4ec8-87e8-80b5535349ac | | name | vnfd1 | | service_types | vnfd | | template_source | onboarded | | tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 | | updated_at | | +-----------------+--------------------------------------+ # tacker vnfd-create --vnfd-file /home/vnffgd/tosca-vnffg-vnfd2.yaml vnfd2 Created a new vnfd: +-----------------+--------------------------------------+ | Field | Value | +-----------------+--------------------------------------+ | created_at | 2017-10-11 06:27:24.248042 | | description | Demo example | | id | 8bfc0e83-a55b-43d0-a553-b7242624180a | | name | vnfd2 | | service_types | vnfd | | template_source | onboarded | | tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 | | updated_at | | +-----------------+--------------------------------------+
3、基于VNFD创建2个VNF
# tacker vnf-create --vnfd-name vnfd1 vnf1_001 Created a new vnf: +----------------+--------------------------------------+ | Field | Value | +----------------+--------------------------------------+ | created_at | 2017-10-11 06:27:49.022636 | | description | Demo example | | error_reason | | | id | 23853cfb-265f-4f42-a99d-feeeb11d63fd | | instance_id | 6b770804-a745-4b14-b174-508d471e70fd | | 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 | 104a402b-9acc-4ec8-87e8-80b5535349ac | +----------------+--------------------------------------+ # tacker vnf-create --vnfd-name vnfd2 vnf2_001 Created a new vnf: +----------------+--------------------------------------+ | Field | Value | +----------------+--------------------------------------+ | created_at | 2017-10-11 06:28:16.476876 | | description | Demo example | | error_reason | | | id | 06a3b1ab-550f-4432-b7df-17800947287c | | instance_id | 62f62bfb-8aab-4147-bb13-a84936363c68 | | 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 | 8bfc0e83-a55b-43d0-a553-b7242624180a | +----------------+--------------------------------------+
4、创建一个VNFFGD
tosca-vnffgd-param-sample.yaml获取路径如下,本文末尾也会提供
https://github.com/openstack/tacker/blob/master/samples/tosca-templates/vnffgd/tosca-vnffgd-param-sample.yaml
# tacker vnffgd-create --vnffgd-file /home/vnffgd/tosca-vnffgd-param-sample.yaml vnffgd_001 Created a new vnffgd: +-----------------+-------------------------------------+ | Field | Value | +-----------------+-------------------------------------+ | description | | | id | 1dc2e099-7b7e-4920-ad5b-b9822e61dcdb| | name | vnffgd_001 | | template | template_info | | template_source | onboarded | | tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 | +-----------------+-------------------------------------+ 其中template_info 为: { "vnffgd": { "imports": ["/usr/lib/python2.7/site-packages/tacker/tosca/lib/tacker_defs.yaml", "/usr/lib/python2.7/site-packages/tacker/tosca/lib/tacker_nfv_defs.yaml"], "description": "Sample VNFFG parameterized template", "topology_template": { .... # 该信息为tosca-vnffgd-param-sample.yaml中的数据转化为的json数据 }, "tosca_definitions_version": "tosca_simple_profile_for_nfv_1_0_0" } }
5、最终创建一个VNFFG
vnffg-param-file内容如下
# cat /home/vnffgd/vnffg-param-file.yaml net_src_port_id: 0c988348-141a-47d7-a1d7-1829a8e0851d #这个IP初始情况就取CP12的port的ID,获取其它VM与CPU12同网段的port的ID ip_dst_pre: - 172.16.30.0/24 #该网络必须与tosca-vnffgd-param-sample.yaml定义中的CP12,CP22同一个子网,在本文中即为net0
# tacker vnffg-create --vnffgd-name vnffgd_001 \ --param-file /home/vnffgd/vnffg-param-file.yaml \ --vnf-mapping VNFD1:vnf1_001,VNFD2:vnf2_001 vnffg_001 说明:VNFD1:vnf1_001为映射tosca-vnffgd-param-sample.yaml中定义的VNFD1为具体哪个NVF 如果不使用vnffg-param-file.yaml,可以直接在tosca-vnffgd-param-sample.yaml写死参数即可 Created a new vnffg: +------------------+--------------------------------------------------+ | Field | Value | +------------------+--------------------------------------------------+ | description | | | forwarding_paths | 615884c0-7c15-49dc-a6e6-c74c32edd77a | | id | 7157ff30-0f40-44af-9fd2-050e96107fd7 | | name | vnffg_001 | | status | PENDING_CREATE | | tenant_id | eaad10cdd84743bf90bdbd7e781ea9a0 | | vnf_mapping | {"VNFD2": "06a3b1ab-550f-4432-b7df-17800947287c",| | | "VNFD1": "23853cfb-265f-4f42-a99d-feeeb11d63fd"}| | vnffgd_id | 1dc2e099-7b7e-4920-ad5b-b9822e61dcdb | +------------------+--------------------------------------------------+
6、VNFFG创建成功
# tacker vnffg-list +-----------+--------+--------------------------------------+ | name | status | vnffgd_id | +-----------+--------+--------------------------------------+ | vnffg_001 | ACTIVE | 1dc2e099-7b7e-4920-ad5b-b9822e61dcdb | +-----------+--------+--------------------------------------+
7、创建后的环境配置信息
# neutron port-pair-list +--------------------------------------+----------------------------+--------------------------------------+--------------------------------------+ | id | name | ingress | egress | +--------------------------------------+----------------------------+--------------------------------------+--------------------------------------+ | 0cc09bea-ce1f-4447-aead-45b6c6750df8 | vnf2_001-connection-points | 1191ea20-efc0-489c-a7aa-fd9ddd488ae1 | 1191ea20-efc0-489c-a7aa-fd9ddd488ae1 | | f0c37c95-18a8-445b-8d6c-9cf5d5fe3c48 | vnf1_001-connection-points | 0c988348-141a-47d7-a1d7-1829a8e0851d | 0c988348-141a-47d7-a1d7-1829a8e0851d | +--------------------------------------+----------------------------+--------------------------------------+--------------------------------------+ # neutron port-pair-group-list +--------------------------------------+--------------------------+-------------------------------------------+ | id | name | port_pairs | +--------------------------------------+--------------------------+-------------------------------------------+ | 96dc3d51-416b-491f-8e8f-ba2b4d76f2cf | vnf2_001-port-pair-group | ['0cc09bea-ce1f-4447-aead-45b6c6750df8'] | | bfbfc271-f50d-4a81-afb5-acd894ddc8e6 | vnf1_001-port-pair-group | ['f0c37c95-18a8-445b-8d6c-9cf5d5fe3c48'] | +--------------------------------------+--------------------------+-------------------------------------------+ # neutron flow-classifier-list neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead. +--------------------------------------+------------------------------------------------------------+ | id | summary | +--------------------------------------+------------------------------------------------------------+ | a9178eb7-d38d-4070-b27f-926f2431533b | protocol: any, | | | source[port]: any[any:any], | | | destination[port]: 172.16.30.0/24[any:any], | | | neutron_source_port: 0c988348-141a-47d7-a1d7-1829a8e0851d, | | | neutron_destination_port: None, | | | l7_parameters: {} | +--------------------------------------+------------------------------------------------------------+ # neutron port-chain-list neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead. +----------------------+------------------------------------------+-------------------------------------------+ | name | port_pair_groups | flow_classifiers | +----------------------+------------------------------------------+-------------------------------------------+ | vnffg_001-port-chain | ['bfbfc271-f50d-4a81-afb5-acd894ddc8e6', | | | '96dc3d51-416b-491f-8e8f-ba2b4d76f2cf'] | ['a9178eb7-d38d-4070-b27f-926f2431533b'] | +----------------------+------------------------------------------+-------------------------------------------+
8、以上通过tacker创建了一个vnffd,即openstack的SFC服务链
再通过配置各个VNF虚拟机内部的流量处理逻辑,既可以实现网络流量的编排。
9、自动化配置VNF虚拟机内部流量处理逻辑的特性
当前tacker实现了一个openwrt的后端驱动,在创建vnf的时候,将想要做的配置放在config里传进去并进行配置
这里可以看下tacker中的mgmt_driver:
代码位于 tacker/vnfm/mgmt_drivers/openwrt/openwrt.py
说白了,就是通过ssh到VNF上,执行一些配置命令,根据这个特性,可以自己开发自己VNF的驱动。
@log.log def _config_service(self, mgmt_ip_address, service, config): user = cfg.CONF.openwrt.user password = cfg.CONF.openwrt.password try: cmd = "uci import %s; /etc/init.d/%s restart" % (service, service) LOG.debug('execute command: %(cmd)s on mgmt_ip_address ' '%(mgmt_ip)s', {'cmd': cmd, 'mgmt_ip': mgmt_ip_address}) commander = cmd_executer.RemoteCommandExecutor( user, password, mgmt_ip_address) commander.execute_command(cmd, input_data=config) except Exception as ex: LOG.error("While executing command on remote " "%(mgmt_ip)s: %(exception)s", {'mgmt_ip': mgmt_ip_address, 'exception': ex}) raise exceptions.MgmtDriverException() @log.log def mgmt_call(self, plugin, context, vnf, kwargs): if (kwargs[mgmt_constants.KEY_ACTION] != mgmt_constants.ACTION_UPDATE_VNF): return dev_attrs = vnf.get('attributes', {}) mgmt_url = jsonutils.loads(vnf.get('mgmt_url', '{}')) if not mgmt_url: return vdus_config = dev_attrs.get('config', '') config_yaml = yaml.safe_load(vdus_config) if not config_yaml: return vdus_config_dict = config_yaml.get('vdus', {}) for vdu, vdu_dict in vdus_config_dict.items(): config = vdu_dict.get('config', {}) for key, conf_value in config.items(): KNOWN_SERVICES = ('firewall', 'network') if key not in KNOWN_SERVICES: continue mgmt_ip_address = mgmt_url.get(vdu, '') if not mgmt_ip_address: LOG.warning('tried to configure unknown mgmt ' 'address on VNF %(vnf)s VDU %(vdu)s', {'vnf': vnf.get('name'), 'vdu': vdu}) continue if isinstance(mgmt_ip_address, list): for ip_address in mgmt_ip_address: self._config_service(ip_address, key, conf_value) else: self._config_service(mgmt_ip_address, key, conf_value)
10、文中用到的yaml模板内容
# cat /home/vnffgd/tosca-vnffg-vnfd1.yaml tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0 description: Demo example metadata: template_name: sample-tosca-vnfd1 topology_template: node_templates: VDU1: type: tosca.nodes.nfv.VDU.Tacker capabilities: nfv_compute: properties: num_cpus: 1 mem_size: 512 MB disk_size: 1 GB properties: image: cirros-0.3.5-x86_64-disk availability_zone: nova mgmt_driver: noop config: | param0: key1 param1: key2 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: net0 vendor: Tacker VL13: type: tosca.nodes.nfv.VL properties: network_name: net1 vendor: Tacker
# cat /home/vnffgd/tosca-vnffg-vnfd2.yaml tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0 description: Demo example metadata: template_name: sample-tosca-vnfd1 topology_template: node_templates: VDU1: type: tosca.nodes.nfv.VDU.Tacker capabilities: nfv_compute: properties: num_cpus: 1 mem_size: 512 MB disk_size: 1 GB properties: image: cirros-0.3.5-x86_64-disk availability_zone: nova mgmt_driver: noop config: | param0: key1 param1: key2 CP21: type: tosca.nodes.nfv.CP.Tacker properties: management: true order: 0 anti_spoofing_protection: false requirements: - virtualLink: node: VL21 - virtualBinding: node: VDU1 CP22: type: tosca.nodes.nfv.CP.Tacker properties: order: 1 anti_spoofing_protection: false requirements: - virtualLink: node: VL22 - virtualBinding: node: VDU1 CP23: type: tosca.nodes.nfv.CP.Tacker properties: order: 2 anti_spoofing_protection: false requirements: - virtualLink: node: VL23 - virtualBinding: node: VDU1 VL21: type: tosca.nodes.nfv.VL properties: network_name: net_mgmt vendor: Tacker VL22: type: tosca.nodes.nfv.VL properties: network_name: net0 vendor: Tacker VL23: type: tosca.nodes.nfv.VL properties: network_name: net1 vendor: Tacker
# cat tosca-vnffgd-param-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 inputs: 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->CP22) properties: id: 51 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: VNFD2 capability: CP22 groups: VNFFG1: type: tosca.groups.nfv.VNFFG description: HTTP to Corporate Net properties: vendor: tacker version: 1.0 number_of_endpoints: 2 dependent_virtual_link: [VL12,VL22] connection_point: [CP12,CP22] constituent_vnfs: [VNFD1,VNFD2] members: [Forwarding_path1]
相关文章推荐
- OpenStack Tacker介绍 - 7.创建一个多网卡的SFC服务链-VM内部流量打通
- DNS服务器概念的简单的介绍,与搭建一个简单的DNS名称缓存服务器,实现域名解析(一)
- 简单工厂(Factory)-提供一个创建对象实例的功能,而无须关心其具体实现。被创建实例的类型可以是接口、抽象类,也可以是具体的类。
- 一个简单的自动化测试架构的实现(C#)
- 创建一个简单的restful wcf, 并且用silverlight做为客户端实现get, post, put,delete
- Node.js简单介绍并实现一个简单的Web MVC框架
- 用UDP实现可靠文件传输,如何利用UDX创建一个简单的WIN32程序
- 目前大家对Python都有一个共识,就是他对测试非常有用,自动化测试里Python用途也很广,但是Python到底怎么进行自动化测试呢?今天就简单的向大家介绍一下怎么使用Python进行自动化测试
- 一个简单的创建圆角图像的UIImage扩展实现
- 一个简单的弹性返回顶部JS代码实现介绍
- Linux下之使用简单3种创建文件的命令,并实现一个Html和JavaScript小程序
- 分形介绍 && 一个简单的Kotch curve实现代码
- 一个简单的创建圆角图像的UIImage扩展实现
- 简介 WatiN是一个开源的用于Web测试自动化的类库,从watir中获得的灵感,使用C#开发。WatiN通过与浏览器的交互来实现自动化,使用起来具有轻便,简单的特点。目前最新版本为2.0,加入了对
- 简单的使用自动化技术实现用WORD读取一个XML文件的过程~
- [异常解决] 初玩SAE遇到的小问题——注册&创建项目+MyEclipse装插件直接部署+一个简单的JSP部署实现
- 介绍一个超级简单的jqurey实现ajax
- 使用tornado创建一个简单的图书介绍页面
- 创建一个Android程序(简单介绍工程里面各个文件的作用)
- --------------------9 以上介绍了一个最简单的http交互的java实现----------------------------------