def encode_attr_cluster_list(cluster_list):
""" Encode string cluster_list into a BGP CLUSTER_LIST attribute TLV
:param cluster_list: String space delimited list of cluster id's
:return: BGP attribute TLV ready to be written
"""
encode_cluster_list = ""
try:
for cluster_id in cluster_list.split(' '):
encode_cluster_list += socket.inet_pton(socket.AF_INET, cluster_id)
return ATTR_TYPE_CLUSTER_LIST + pack('!B', len(encode_cluster_list)) + encode_cluster_list
except:
return ''
评论列表
文章目录