本文介绍了从Excel文件中将多个变量组合在一起在Rundeck中动态查询它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Excel文件中具有某些部分,序列号和配置ID

having some of parts, Serials and Config IDs in excel File

Part    - Serial  - Config.  
223-234 -   345   - PLU9.   
904-567 -   987   - GJK0.   
232-589 -   890   - LOM7.  
230-978 -   356   - GJK0.  

我想使用API​​动态检查这些数字,并在rundeck中将此文件作为输入

i want to check these numbers using API dynamically, giving this file as input in rundeck

https://prcmf.uslp07.app.xvz.com/api/c7/parts?include=name&selector=name,price,country&part=223-234&serial=345&config=PLU9

我希望可以动态更改和搜索部件,序列号和配置,并在Rundeck中使用python获取输出

i want the part,serial and Config to be dynamically changed and searched and get the output using python in Rundeck

https://prcmf.uslp07.app.xvz.com/api/c7/partsinclude=name&selector=name,price,country&[email protected]@&[email protected]@&[email protected]@

我如何在Rundeck中使用它?

How can i use this in Rundeck?

推荐答案

您可以使用此python示例代码将任何值传递给Rundeck作业上的任何选项.只需更改字符串"即可变量从任何来源获取值(另一个API调用,模糊表输出等).

You can use this python example code to pass any value to any options on a Rundeck job. Just change the "strings" variables to your values from any source (another API call, fuzzytable output, etc).

import requests

# host definition
rdeck_instance = "localhost"
rdeck_port = "4440"
rdeck_api = "35"
rdeck_token = "lL4CwBiHHmxirZtTUHDJEHu4ZGTontjX"
jobid = "f68e73cb-54e5-483e-b451-b7ae484c54fe"

# variable strings (for testing, in this case, you can put from the result from any source: another API call, fuzzy table output, etc.)
string1="one"
string2="two"
string3="three"

s = requests.Session()
r = s.post("http://" + rdeck_instance +  ":" + rdeck_port +"/api/" + rdeck_api + "/job/" + jobid + "/run?authtoken=" + rdeck_token, 
headers = {"Accept" : "application/json"}, 
data = { "argString" : "-opt1 {} -opt2 {} -opt3 {}".format(string1, string2, string3)})

# print data (for debug)
print ('######################')
print (r.status_code)
print (r.url)
print ('######################')

# json response
print(r.json()) 

这篇关于从Excel文件中将多个变量组合在一起在Rundeck中动态查询它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 22:01