首页 文章 精选 留言 我的

精选列表

搜索[自动装配],共10000篇文章
优秀的个人博客,低调大师

华为网络自动化编程 之 gRPC 方式获取交换机信息

### 实验环境 1.配置交换机ssh登录 2.实验拓扑 ![image.png](https://s2.51cto.com/images/20210610/1623299211124282.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=) ### 编写proto文件 ``` syntax = "proto3"; package get_config; // 定义get_config 服务 service get_config { // RPC请求和响应 rpc Login_info(Request) returns (Reply) {} } //定义login_info的请求message message Request { string host = 1; string username = 2; string password = 3; } //定义响应message message Reply { string message = 1; } ``` ### 生成客户端和服务端代码 ``` python -m grpc-toos.protoc -I ./ --python_out=. --grpc_python_out=. ./get_config.proto ``` ### 编写服务端代码 ```python # grpc_service.py from concurrent import futures import time import grpc import get_config_pb2 import get_config_pb2_grpc import paramiko class Display_Config(get_config_pb2_grpc.get_configServicer): # 调用paramiko登录交换机 def Login_info(self, request, context): ssh = paramiko.client.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(hostname=request.host, port=22, username=request.username, password=request.password) cli = ssh.invoke_shell() cli.send('N\n') time.sleep(0.5) cli.send('screen-length 0 temporary\n') time.sleep(0.5) cli.send('display cu\n') time.sleep(3) data = cli.recv(999999).decode() ssh.close() return get_config_pb2.Reply(message=data) def serve(): server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) get_config_pb2_grpc.add_get_configServicer_to_server(Display_Config(), server) server.add_insecure_port('localhost:8080') server.start() _ONE_DAY_IN_SECONDS = 60*60*24 try: while True: time.sleep(_ONE_DAY_IN_SECONDS) except KeyboardInterrupt: server.stop() if __name__ == "__main__": serve() ``` ### 编写客户端代码 ```python # grpc_client.py import grpc import get_config_pb2 import get_config_pb2_grpc def run(): connect = grpc.insecure_channel('localhost:8080') stub = get_config_pb2_grpc.get_configStub(channel=connect) response = stub.Login_info( get_config_pb2.Request(host='172.16.1.3', username='python', password='Huawei12#$') ) print(response.message) if __name__ == "__main__": run() ``` ### 运行服务端代码 ``` python grpc_service.py ``` ### 运行客户端 ``` python grpc_client.py 注意:需要先运行服务端代码,否则可能会导致服务不可达的错误。 ``` ### 实验效果截图 ![image.png](https://s2.51cto.com/images/20210610/1623303507217523.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=) ![image.png](https://s2.51cto.com/images/20210610/1623303609316870.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)

优秀的个人博客,低调大师

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架

前置条件:系统已安装jdk 一、下载jmeter包,通过客户端放在安装目录 1、本次安装的版本为unzip apache-jmeter-5.0.zip unzip apache-jmeter-5.0.zip 2、配置环境变量 执行 vim /etc/profile 在后面加入: exportJMETER_HOME=/root/apache-jmeter-5.0 exportCLASSPATH=$JMETER_HOME/lib/ext/ApacheJMeter_core.jar:$JMETER_HOME/lib/jorphan.jar:$JMETER_HOME/lib/logkit-2.0.jar:$CLASSPATH exportPATH=$JMETER_HOME/bin:$PATH:$HOME/bin 3、执行: source /etc/profile ,让配置生效 4、验证安装 jmeter -v 如果出现:-bash: /root/apache-jmeter-5.0/bin/jmeter: Permission denied 则给jmeter执行文件授权: 执行:chmod 777 /root/apache-jmeter-5.0/bin/jmeter 若看到如下图,则安装成功 5、下载报告模板 地址:http://shanhe.me/download.php?file=jmeter.results.shanhe.me.xsl 把报告放到jmeter的extras路径下面: /root/apache-jmeter-5.0/extras 下载jmeter插件的的jar包 下载地址:https://jmeter-plugins.org/install/Install/ 本次的版本为:jmeter-plugins-manager-1.3.jar 把这个jar包放到jmeter的:/root/apache-jmeter-5.0/lib/ext目录下面 二、安装ant 1、下载地址:https://ant.apache.org/bindownload.cgi 本次下载版本为:apache-ant-1.10.6-bin.tar.gz 2、上传到服务器与jmeter同一目录,本次的目录为/root 解压文件执行:tar -zxvf apache-ant-1.10.6-bin.tar.gz 3、配置环境变量,在/etc/profile后面添加如下信息 ANT_HOME=/root/apache-ant-1.10.6 CLASS_PATH=.:$JRE_HOME/lib PATH=$JRE_HOME/bin:$ANT_HOME/bin export ANT_HOME CLASS_PATH PATH 执行: source /etc/profile 验证安装: 执行:ant -version 三、安装tomcat 1、下载安装包 下载地址:https://tomcat.apache.org/download-80.cgi 本次所用的版本为:apache-tomcat-8.5.35.tar.gz 2、上传安装包到服务器 本次放置的目录为/usr 解压执行: tar -zxvf apache-tomcat-8.5.35.tar.gz 3、重命名文件夹 执行:mv apache-tomcat-8.5.35 tomcat-jenkins 4、启动tomcat 4.1、执行: cd /data/tomcat-jenkins/bin 4.2、执行 sh startup.sh 如果见到如下报错: :Cannotfind./catalina.sh.Thefileisabsentordoesnothaveexecutepermission.Thisfileisneededtorunthisprogram 则权限不足:执行chmod 777 /data/tomcat-jenkins/bin/startup.sh 4.3、查看进程 执行:ps aux|grep tomcat-jenkins 如下则启动成功,默认端口为8080 5、在浏览器访问http://ip地址:8080 见到如下页面说明安装成功 四、安装jenkins 下载地址:https://jenkins.io/doc/book/installing/ 1、把jenkins的war包放到tomcat的如下目录 /usr/tomcat-jenkins/webapps 访问http://ip:8080/jenkins 见到如下页面 2、根据提示,打开相应的文件获取初始密码 执行:vim /root/.jenkins/secrets/initialAdminPassword 3、配置用户 4、见到如下页面说明安装成功 PS:jenkins配置工作空间 1、vim /usr/tomcat-jenkins/bin/catalina.sh 2、在# OS specific support. $var _must_ be set to either true or false.在上面添加一行 export JENKINS_HOME=/usr/local/jenkins 3、编辑profile文件:vi /etc/profile 4、添加:export JENKINS_HOME=/usr/local/jenkins 5、source /etc/profile 6、sh startup.sh 如果jenkins显示似乎已离线 则更改https为http /usr/local/jenkins/hudson.model.UpdateCenter.xml 5、配置ant+jmeter 把extras目录下面的ant-jmeter-1.1.1.jar 拷贝到ant 的lib目录 cp ant-jmeter-1.1.1.jar /root/apache-ant-1.10.6/lib/ 6、修改jmeter配置 6.1、将文件中#jmeter.save.saveservice.output_format=csv改为jmeter.save.saveservice.output_format=xml 6.2、修改如下输出信息 jmeter.save.saveservice.data_type=true jmeter.save.saveservice.label=true jmeter.save.saveservice.response_code=true # response_data is not currently supported for CSV output jmeter.save.saveservice.response_data=true # Save ResponseData for failed samples jmeter.save.saveservice.response_data.on_error=false jmeter.save.saveservice.response_message=true jmeter.save.saveservice.successful=true jmeter.save.saveservice.thread_name=true jmeter.save.saveservice.time=true jmeter.save.saveservice.subresults=true jmeter.save.saveservice.assertions=true jmeter.save.saveservice.latency=true jmeter.save.saveservice.connect_time=true jmeter.save.saveservice.samplerData=true jmeter.save.saveservice.responseHeaders=true jmeter.save.saveservice.requestHeaders=true jmeter.save.saveservice.encoding=false jmeter.save.saveservice.bytes=true jmeter.save.saveservice.url=true jmeter.save.saveservice.filename=true jmeter.save.saveservice.hostname=true jmeter.save.saveservice.thread_counts=true jmeter.save.saveservice.sample_count=true jmeter.save.saveservice.idle_time=true 五、jenkins配置ant 1、全局工具配置 2、安装插件: HTML publisher 3、配置工程 4、修改buid.xml文件 <xslt classpathref="xslt.classpath" force="true" in="${jmeter.result.jtlName}" out="${jmeter.result.htmlName}" style="${jmeter.home}/extras/jmeter.results.shanhe.me.xsl"> 5、构建工程 6、查看报告 查看报告如下,感觉确实丑了一些,后面有空再优化一下 若报告样式没有加载出来 则在命令行执行:System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "") : System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

优秀的个人博客,低调大师

Robotgo v0.90.0 发布,Go GUI 自动化,大幅度更新

Robotgo v0.90.0 发布了,Golang 跨平台控制鼠标、键盘、位图、屏幕、窗口句柄以及全局事件监听。 该版本主要增加:更现代和并发的 gohook API, 尝试多屏支持, 更新 keycode 无需 type 转换, 支持 windows non-POSIX gcc; Linux 下 TypeStr 优化并修复 bug, 增加 ToBitmapBytes() 和多平台 system scale 支持, 导出并增加更多 keycode 支持, 更多 win32 方法导出等一些列的大更新。 增加更多示例、测试代码, 支持 Linux 测试和 Github Actions, 修复 bug 等。 项目地址: https://github.com/go-vgo/robotgo MT. Rainier Add add gohook modern and concurrent API, add new gohook examples, thks for cauefcr Support for multiple screens, add getMousePos() multiple screens support, add move smooth multiple screens support add all platform system scale support, add get screen size test code add screen and bitmap multiple screens support, add int32_t types support update keycode type use uint16 with gohook, not type convert; add ToBitmapBytes func (#204) gohook: sched_yield support for non-POSIX windows gcc add gops test code support, add Process() function test code, add more gops test code add more win32 function export add get mouse color function add uint32 to Chex function support add key_Toggles() c function, add keyTap and keyToggle "...string" parameters support, Fixed #209 add robotgo simple test code add Is64Bit() c and go function add process FindPath() function add keycode "delete" support and fixed "\" error add more keycode support, "up, down, left, right"... export hook keycode and add godoc use robotn fork xgb and update go mod add hook example to robotgo examples update gohook and tt mod file add more and update test code add drag smooth function support and examples add ShowAlert() test support update keypress rand sleep [reduce] and update code style, update c delay default value to 0 add mouse toggle return and add more test add SetDelay function code and update other code add scaled function code add go opencv file add readme.md file add move mouse and move smooth relative code add move mouse and move smooth relative examples add more test code and update go tt mod add more bitmap test code add SaveImg function code add drop function hint print support add more key test code, add more test code, add paste string test code, add xvfb run codecov test add keycode test support add FindPath example code add KeyTap() args[2] delay support add find bitmap nil args support add find color nil args support add drag and move mouse multiple screens support add drag mouse test code Use CGDisplayBounds not CGDisplayPixelsWide, optimize get mac display size … Update TypeStr function, add type delay and speed support update PasteStr function code return error Update Update robot info test code and Add go.yml test support use while not for match special key map remove unless x11 special key and sort update go mod pkg update mod vendor remove vendor and update .gitignore update and fmt config.yml, add Linux go test support update Linux CI support x11 test move hook to hook.go update appveyor and test code update version and code style update move mouse smooth test code update clipboard code and add test code update test code and add codecov support update show alert test code update keycode.go update window examples code update test code remove windows alert test move gops code to ps.go update version update unix get title type gofmt go code and update code style add ToBitmapBytes examples code update example code, fixed golint warning update bitmap example code Update CHANGELOG.md update code style update godoc update keytap code and code style update Bitmap struct delete fuzzy api update key examples code add bitmap from string clear api update go mod vendor update go mod pkg not proxy update bitmap example code update test code fixed appveyor CI update test code fixed equal error update hook godoc update event example code update godoc and code style update key example code Update example README.md update and tidy go mod update code remove duplicate code and update godoc update xgb getXid log update GetBounds x11 error log update cgo code and version update TypeString function code [Drop] update key example code Update TypeStr function, optimize x11 type string Update TypeStrDelay function, remove unused code update code fixed x11 type sleep Update key example code use gops to simplify code update key examples code update bitmap examples code update colorpicker and findcolor example code update bitmap example code update robotgo test code, add more test Update README.md rename type names make clearer update types.h code and fixed bug remove unused code fixed x11 build error update robot info test code and appveyor Update README.md, Add more CI badge update gohook pkg and robot info test code Update linux upper code, add more special key support Create go.yml Update go.yml add more test and update go.yml Update dockerfile to go1.13.5 update dockerfile and appveyor.yml Update dockerfile and appveyor.yml to go1.14.3 remove Travis go1.11.x update appveyor and dockerfile to go1.13.1 update dockerfile, go.yml and appveyor.yml to go1.14 update travis.yml to go1.14.x and remove go1.13.x Update and fmt appveyor.ymlu update dockerfile and appveyor to go1.12.5 update appveyor and dockerfile to go1.12.6 add CI go1.13 support update config.yml update and fmt travis.yml Update Travis remove go1.12.x Update issue and pull request template Fix Update to utf-code function Fixed #189 Update x11 keypress upper code Fixed #243 type conversion needed in addMouse (#201) update hook, Fixed #202 fatal error: concurrent map writes add key Kind Fixed #203 optimize get title code, Fixed #165 and typo Fixed gohook#3 mouse is_drag error on x11 Fixed #213 AddEvents() can't listen correctly multiple times update clipboard error hand Fixed #212 Update go.mod fixing issue "invalid pseudo-version: does not match version … update keyboard example code, #238 update go mod file Fixed #239 update gops and other mod files fixed bug

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册