本文整理匯總了Python中netaddr.IPAddress.split方法的典型用法代碼示例。如果您正苦於以下問題:Python IPAddress.split方法的具體用法?Python IPAddress.split怎麽用?Python IPAddress.split使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類netaddr.IPAddress
的用法示例。
在下文中一共展示了IPAddress.split方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_endpoint
# 需要導入模塊: from netaddr import IPAddress [as 別名]
# 或者: from netaddr.IPAddress import split [as 別名]
def create_endpoint():
data = request.get_json(force=True)
app.logger.debug('CreateEndpoint JSON=%s', data)
endpoint_id = data['EndpointID']
network_id = data['NetworkID']
interface = data['Interface']
app.logger.info('Creating endpoint %s', endpoint_id)
# docker sent me 172.19.0.3/16 ...
address_ip4 = interface.get('Address', None)
if address_ip4 and '/' in address_ip4:
address_ip4 = IPAddress(address_ip4.split('/', 1)[0])
network = Network.get(network_id)
if not network:
error_message = "CreateEndpoint called but network doesn\'t exist" \
" Endpoint ID: %s Network ID: %s" % \
(endpoint_id, network_id)
app.logger.error(error_message)
raise Exception(error_message)
network.acquire_ip(endpoint_id, hostname, ip=address_ip4)
app.logger.debug('CreateEndpoint response JSON=%s', {})
return jsonify({})