[Tags] critical
Verify 10
+Updater_with delegate
+ [Documentation] Run updater tool to revoke the delegate for the given hop, using 1 blocking http thread.
+ [Tags] critical
+ Updater 10 1 127.1.0.0 ${PCCS} ${LSPS} True false 127.1.0.1 2
+ Verify 10
+ [Teardown] Do_Not_Start_Failing_If_This_Failed
+
Stop_Pcc_Mock
[Documentation] Send ctrl+c to pcc-mock, see prompt again within timeout.
[Setup] Run_Even_When_Failing_Fast
BuiltIn.Log ${hop}
Updater
- [Arguments] ${iteration} ${workers} ${mock-ip}=${FIRST_PCC_IP} ${pccs}=${PCCS} ${lsps}=${LSPS} ${parallel}=False
+ [Arguments] ${iteration} ${workers} ${mock-ip}=${FIRST_PCC_IP} ${pccs}=${PCCS} ${lsps}=${LSPS} ${parallel}=False ${delegate}=true ${pccip}=${none} ${tunnel_no}=${none}
[Documentation] Compute number of workers, call updater.py, assert its response.
SSHLibrary.Switch_Connection pccmock
# In some systems, inactive SSH sessions get severed.
# The previous line relies on a fact that Execute_Command spawns separate shels, so running pcc-mock is not affected.
Set_Hop ${iteration}
SSHLibrary.Switch_Connection updater
- ${response} = SSHLibrary.Execute_Command bash -c "cd ${UPDATERVM_WORKSPACE}; taskset 0x00000001 python updater.py --workers '${workers}' --odladdress '${UPDATER_ODLADDRESS}' --user '${RESTCONF_USER}' --password '${RESTCONF_PASSWORD}' --scope '${RESTCONF_SCOPE}' --pccaddress '${mock-ip}' --pccs '${pccs}' --lsps '${lsps}' --hop '${hop}' --timeout '${UPDATER_TIMEOUT}' --refresh '${UPDATER_REFRESH}' --reuse '${RESTCONF_REUSE}' 2>&1"
+ ${response} = SSHLibrary.Execute_Command bash -c "cd ${UPDATERVM_WORKSPACE}; taskset 0x00000001 python updater.py --workers '${workers}' --odladdress '${UPDATER_ODLADDRESS}' --user '${RESTCONF_USER}' --password '${RESTCONF_PASSWORD}' --scope '${RESTCONF_SCOPE}' --pccaddress '${mock-ip}' --pccs '${pccs}' --lsps '${lsps}' --hop '${hop}' --timeout '${UPDATER_TIMEOUT}' --refresh '${UPDATER_REFRESH}' --reuse '${RESTCONF_REUSE}' --delegate '${delegate}' --pccip '${pccip}' --tunnelnumber '${tunnel_no}' 2>&1"
Check Updater response ${response} ${parallel}
Check Updater response
help='Scope for restconf authentication')
parser.add_argument('--reuse', default='True', type=str2bool,
help='Should single requests session be re-used')
+parser.add_argument('--delegate', default='true',
+ help='should delegate the lsp or set "false" if lsp not be delegated')
+parser.add_argument('--pccip', default=None,
+ help='IP address of the simulated PCC')
+parser.add_argument('--tunnelnumber', default=None,
+ help='Tunnel Number for the simulated PCC')
args = parser.parse_args() # arguments are read
expected = '''{"output":{}}'''
+payload_list_data = [
+ '{',
+ ' "input":{',
+ ' "node":"pcc://', '', '",',
+ ' "name":"pcc_', '', '_tunnel_', '', '",',
+ ' "network-topology-ref":"/network-topology:network-topology/network-topology:topology',
+ '[network-topology:topology-id=\\\"pcep-topology\\\"]",',
+ ' "arguments":{',
+ ' "lsp":{',
+ ' "delegate":', '',
+ ' ,"administrative":true',
+ '},',
+ '"ero":{',
+ ' "subobject":[',
+ ' {',
+ ' "loose":false,',
+ ' "ip-prefix":{',
+ ' "ip-prefix":', '"', '', '"',
+ ' }',
+ ' },',
+ ' {',
+ ' "loose":false,',
+ ' "ip-prefix":{',
+ ' "ip-prefix":"1.1.1.1/32"',
+ ' }',
+ ' }',
+ ' ]',
+ ' }',
+ ' }',
+ ' }',
+ '}'
+]
+
class CounterDown(object):
"""Counter which also knows how many items are left to be added."""
self.opened -= 1
-def iterable_msg(pccs, lsps, workers, hop):
+def iterable_msg(pccs, lsps, workers, hop, delegate):
"""Generator yielding tuple of worker number and kwargs to post."""
first_pcc_int = int(ipaddr.IPv4Address(args.pccaddress))
# Headers are constant, but it is easier to add them to kwargs in this generator.
headers = {'Content-Type': 'application/json'}
# TODO: Perhaps external text file with Template? May affect performance.
- list_data = [
- '{"input":{"node":"pcc://', '', '",',
- '"name":"pcc_', '', '_tunnel_', '', '","network-topology-ref":',
- '"/network-topology:network-topology/network-topology:topology',
- '[network-topology:topology-id=\\\"pcep-topology\\\"]",',
- '"arguments":{"lsp":{"delegate":true,"administrative":true},',
- '"ero":{"subobject":[{"loose":false,"ip-prefix":{"ip-prefix":',
- '"', hop, '"}},{"loose":false,"ip-prefix":{"ip-prefix":',
- '"1.1.1.1/32"}}]}}}}'
- ]
+ list_data = payload_list_data
for lsp in range(1, lsps + 1):
str_lsp = str(lsp)
- list_data[6] = str_lsp # Replaces with new pointer.
+ list_data[8] = str_lsp # Replaces with new pointer.
for pcc in range(pccs):
pcc_ip = str(ipaddr.IPv4Address(first_pcc_int + pcc))
- list_data[1] = pcc_ip
- list_data[4] = pcc_ip
+ list_data[3] = pcc_ip
+ list_data[6] = pcc_ip
+ list_data[15] = delegate
+ list_data[25] = hop
whole_data = ''.join(list_data)
worker = (lsp * pccs + pcc) % workers
post_kwargs = {"data": whole_data, "headers": headers}
yield worker, post_kwargs
+def generate_payload_for_single_pcc(hop, delegate, pccip, tunnel_no):
+ """Generator yielding single kwargs to post."""
+ first_pcc_int = int(ipaddr.IPv4Address(args.pccaddress))
+ # Headers are constant, but it is easier to add them to kwargs in this generator.
+ headers = {'Content-Type': 'application/json'}
+ # TODO: Perhaps external text file with Template? May affect performance.
+ list_data = payload_list_data
+ if tunnel_no == "None":
+ str_lsp = str(1)
+ else:
+ str_lsp = str(tunnel_no)
+ list_data[8] = str_lsp # Replaces with new pointer.
+ if pccip == "None":
+ pcc_ip = str(ipaddr.IPv4Address(first_pcc_int))
+ else:
+ pcc_ip = pccip
+ list_data[3] = pcc_ip
+ list_data[6] = pcc_ip
+ list_data[15] = delegate
+ list_data[25] = hop
+ whole_data = ''.join(list_data)
+ worker = 0
+ post_kwargs = {"data": whole_data, "headers": headers}
+ print(post_kwargs)
+ yield worker, post_kwargs
+
+
def queued_send(session, queue_messages, queue_responses):
"""Pop from queue, Post and append result; repeat until empty."""
uri = 'operations/network-topology-pcep:update-lsp'
# Main.
list_q_msg = [collections.deque() for _ in range(args.workers)]
-for worker, post_kwargs in iterable_msg(args.pccs, args.lsps, args.workers, args.hop):
- list_q_msg[worker].append(post_kwargs)
+if args.pccip == "None":
+ for worker, post_kwargs in iterable_msg(args.pccs, args.lsps, args.workers, args.hop, args.delegate):
+ list_q_msg[worker].append(post_kwargs)
+else:
+ for worker, post_kwargs in generate_payload_for_single_pcc(args.hop, args.delegate, args.pccip, args.tunnelnumber):
+ list_q_msg[worker].append(post_kwargs)
queue_responses = collections.deque() # thread safe
threads = []
for worker in range(args.workers):