思科DevNet-学习笔记-癸酉

20161230 1922
今天看到的,网上的教学资料
https://launchschool.com/books

LaunchSchool


A Simple Web Server Greg Wilson -- 介绍如何用Python库编写一个简单的Web服务器。

实验楼-网上做实验

https://www.shiyanlou.com/courses/running

This is a collection of sample scripts and tools for APIC-EM.-思科DevNet 使用Python库调用APIC-EM API, 实现网络设备自动化配置。(SDN)
我特别喜欢的一段代码
Python Sample Notification Listener

import socket
import sys

# this listens to notification stream from MSE and displays results in console.

# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to the address given on the command line
server_address = ('0.0.0.0', 8000)                                # change this to your ip address
sock.bind(server_address)
# print >>sys.stderr, 'using %s port %s' % sock.getsockname()     # use this print statement for python2.7
print (sys.stderr,'using %s port %s' % sock.getsockname())        # use this print statement for python3
sock.listen(1)

while True:
   print (sys.stderr, 'waiting for a connection')                 # use this print statement for python3
   # print >>sys.stderr, 'waiting for a connection'               # use this print statement for python2.7
   connection, client_address = sock.accept()
   try:
       #print >>sys.stderr, 'client connected:', client_address   # use this print statement for python2.7
       print (sys.stderr, 'client connected:', client_address)    # use this print statement for python3
       while True:
           data = connection.recv(1024)                           # change this value, based on your needs.
           print (sys.stderr, 'received "%s"' % data)             # use this print statement for python3
           #print >>sys.stderr, 'received "%s"' % data            # use this print statement for python2.7
           if data:
               connection.sendall(data)
           else:
               break
   finally:
       connection.close()

我特别喜欢的一段代码
Python Sample Notification Listener -
URL:https://msesandbox.cisco.com:8081/apidocs/code

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容