22 @click.command(name=
'validate-flows-command')
26 northbound_endpoint = ctx.nb_endpoint
28 password = ctx.nb_pass
29 correlation_id = str(uuid.uuid4())
31 sys.stdout.write(
'START VALIDATING FLOW\n')
32 flows = requests.get(northbound_endpoint +
'/api/v1/flows',
33 auth=(user, password),
34 headers={
'correlation_id': correlation_id}).json()
35 flow_ids = list(map(
lambda x: x[
'flowid'], flows))
39 for index, flow_id
in enumerate(flow_ids):
40 sys.stdout.write(
'>> Current progress: {}/{}\n'.
format(index,
43 path = northbound_endpoint +
'/api/v1/flows/{}/validate'.
format(flow_id)
44 response = requests.get(path,
45 auth=(user, password),
46 headers={
'correlation_id':
47 correlation_id + flow_id})
48 result = response.json()
50 valid = result[0][
'as_expected']
and result[1][
'as_expected']
53 'FORWARD_VALID': result[0][
'as_expected'],
54 'REVERSE_VALID': result[1][
'as_expected']
58 correct_flows.append(flow_info)
60 incorrect_flows.append(flow_info)
62 sys.stdout.write(
'ALL FLOWS ARE PROCESSED\n')
67 sys.stdout.write(
'>> VALID FLOWS:\n')
68 for flow
in correct_flows:
69 sys.stdout.write(
'> {}\n'.
format(flow))
71 sys.stdout.write(
'>> INVALID FLOWS:\n')
72 for flow
in incorrect_flows:
73 sys.stdout.write(
'> {}\n'.
format(flow))
75 sys.stdout.write(
'>>> TOTAL VALID FLOWS: {}\n'.
format(len(correct_flows)))
76 sys.stdout.write(
'>>> TOTAL INVALID FLOWS: {}\n'.
format(len(incorrect_flows)))
def print_results(correct_flows, incorrect_flows)