本文整理匯總了Python中SettingsLibrary.getAddPersonUrl方法的典型用法代碼示例。如果您正苦於以下問題:Python SettingsLibrary.getAddPersonUrl方法的具體用法?Python SettingsLibrary.getAddPersonUrl怎麽用?Python SettingsLibrary.getAddPersonUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SettingsLibrary
的用法示例。
在下文中一共展示了SettingsLibrary.getAddPersonUrl方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: addPerson
# 需要導入模塊: import SettingsLibrary [as 別名]
# 或者: from SettingsLibrary import getAddPersonUrl [as 別名]
def addPerson(hostname,port,numberOfPersons):
#FOR RPC TO WORK PROPERLY THE FIRST ENTRY SHOULD BE VIA RESTCONF
if(numberOfPersons==0):
strId =str(numberOfPersons)
payload = SettingsLibrary.add_person_payload_template.substitute(personId="user"+strId,gender="unknown",age=0,
address=strId + "Way, Some Country, Some Zip "+strId,
contactNo= "some number"+strId)
# Send the POST request using RESTCONF
resp = UtilLibrary.nonprintpost(SettingsLibrary.getAddPersonUrl(hostname,port),"admin", "admin",payload)
return resp
genderToggle = "Male"
for x in range(1, numberOfPersons+1):
if(genderToggle == "Male"):
genderToggle = "Female"
else:
genderToggle = "Male"
strId = str(x)
payload = SettingsLibrary.add_person_rpc_payload_template.substitute(personId="user"+strId,gender=genderToggle,age=(20+x%100),
address=strId + "Way, Some Country, Some Zip "+str(x%1000),
contactNo= "some number"+strId)
# Send the POST request using RPC
resp = UtilLibrary.post(SettingsLibrary.getAddPersonRpcUrl(hostname,port),"admin", "admin",payload)
print("payload formed after template substitution=")
print(payload)
print("the response of the POST to add person=")
print(resp)
return resp
示例2: addPerson
# 需要導入模塊: import SettingsLibrary [as 別名]
# 或者: from SettingsLibrary import getAddPersonUrl [as 別名]
def addPerson(hostname, port, numberOfPersons, *expected):
"""Creates the specified number of persons based on People yang model using main RPC
<note>
To enable RPC a non-user input person entry is created with personId=user0
</note>
"""
# FOR RPC TO WORK PROPERLY THE FIRST ENTRY SHOULD BE VIA RESTCONF
if (numberOfPersons == 0):
strId = str(numberOfPersons)
payload = SettingsLibrary.add_person_payload_template.substitute(
personId="user" + strId, gender="unknown", age=0,
address=strId + "Way, Some Country, Some Zip " + strId,
contactNo="some number" + strId)
# Send the POST request using RESTCONF
resp = UtilLibrary.nonprintpost(SettingsLibrary.getAddPersonUrl(hostname, port), "admin", "admin", payload)
return resp
genderToggle = "Male"
for x in range(1, numberOfPersons + 1):
if(genderToggle == "Male"):
genderToggle = "Female"
else:
genderToggle = "Male"
strId = str(x)
payload = SettingsLibrary.add_person_rpc_payload_template.substitute(
personId="user" + strId, gender=genderToggle, age=(20 + x % 100),
address=strId + "Way, Some Country, Some Zip " + str(x % 1000),
contactNo="some number" + strId)
# Send the POST request using RPC
resp = UtilLibrary.post(SettingsLibrary.getAddPersonRpcUrl(hostname, port), "admin", "admin", payload)
print("payload formed after template substitution=")
print(payload)
print("the response of the POST to add person=")
print(resp)
if expected and str(resp.status_code) not in expected:
raise RuntimeError('Add person failed for {}:{} with status {}'.
format(hostname, port, resp.status_code))
return resp