|
| 1 | +#!/usr/bin/python |
| 2 | + |
| 3 | +# synthesizer |
| 4 | +import testbedApi |
| 5 | +import time |
| 6 | +import sys |
| 7 | +import objmodel |
| 8 | +import threading |
| 9 | + |
| 10 | +def sleepMs(ms): |
| 11 | + time.sleep (ms / 1000.0); |
| 12 | + |
| 13 | +# Get the tenant |
| 14 | +tenant = objmodel.tenant('default') |
| 15 | + |
| 16 | +# Create policy |
| 17 | +tenant.newPolicy('1111111111') |
| 18 | +tenant.newPolicy('2222222222') |
| 19 | +tenant.newPolicy('3333333333') |
| 20 | +tenant.newPolicy('4444444444') |
| 21 | +tenant.newPolicy('5555555555') |
| 22 | +tenant.newPolicy('6666666666') |
| 23 | +tenant.newPolicy('7777777777') |
| 24 | +tenant.newPolicy('8888888888') |
| 25 | + |
| 26 | +# Create Groups |
| 27 | +g0 = tenant.newGroup("0group0", networkName="private", policies=["1111111111", "2222222222", "3333333333", "4444444444", "5555555555", "6666666666", "7777777777", "8888888888"]) |
| 28 | + |
| 29 | +numGroups = 8 |
| 30 | +stepDelay = 600.0 |
| 31 | + |
| 32 | +groups = [] |
| 33 | +for grpId in range(numGroups): |
| 34 | + group = tenant.newGroup(str(grpId + 1) + "group" + str(grpId + 1), networkName="private", policies=['1111111111']) |
| 35 | + groups.append(group) |
| 36 | + |
| 37 | +def policy_exec_thread(groupName, networkName, policyList): |
| 38 | + tenant.newGroup(groupName, networkName=networkName, policies=policyList) |
| 39 | + |
| 40 | +def setGroupHeight(heights): |
| 41 | + for grpId in range(numGroups): |
| 42 | + ht = heights[grpId] |
| 43 | + policyList = [] |
| 44 | + for hid in range(ht): |
| 45 | + pid = hid + 1 |
| 46 | + pname = str(pid) + str(pid) + str(pid) + str(pid) + str(pid) + str(pid) + str(pid) + str(pid) + str(pid) + str(pid) |
| 47 | + policyList.append(pname) |
| 48 | + |
| 49 | + # Change group |
| 50 | + npThread = threading.Thread(target=policy_exec_thread, args=(str(grpId + 1) + "group" + str(grpId + 1), "private", policyList)) |
| 51 | + npThread.start() |
| 52 | + # group = tenant.newGroup(str(grpId + 1) + "group" + str(grpId + 1), networkName="private", policies=policyList) |
| 53 | + |
| 54 | +time.sleep(5) |
| 55 | + |
| 56 | +for iter in range(3): |
| 57 | + setGroupHeight([2, 2, 2, 2, 2, 2, 2, 2]) |
| 58 | + sleepMs(stepDelay) |
| 59 | + setGroupHeight([1, 1, 1, 1, 1, 1, 1, 1]) |
| 60 | + sleepMs(stepDelay) |
| 61 | + setGroupHeight([2, 2, 2, 2, 2, 2, 2, 2]) |
| 62 | + sleepMs(stepDelay) |
| 63 | + setGroupHeight([1, 1, 1, 1, 1, 1, 1, 1]) |
| 64 | + sleepMs(stepDelay) |
| 65 | + setGroupHeight([2, 2, 2, 2, 2, 2, 2, 2]) |
| 66 | + sleepMs(stepDelay) |
| 67 | + setGroupHeight([1, 1, 1, 1, 1, 1, 1, 1]) |
| 68 | + sleepMs(stepDelay) |
| 69 | + setGroupHeight([2, 2, 2, 2, 2, 2, 2, 2]) |
| 70 | + sleepMs(stepDelay) |
| 71 | + setGroupHeight([4, 4, 4, 4, 4, 4, 4, 4]) |
| 72 | + sleepMs(stepDelay) |
| 73 | + setGroupHeight([8, 8, 8, 8, 8, 8, 8, 8]) |
| 74 | + sleepMs(stepDelay) |
| 75 | + setGroupHeight([1, 1, 1, 1, 1, 1, 1, 1]) |
| 76 | + sleepMs(stepDelay) |
| 77 | + setGroupHeight([2, 2, 2, 2, 2, 2, 2, 2]) |
| 78 | + sleepMs(stepDelay) |
| 79 | + setGroupHeight([4, 4, 4, 4, 4, 4, 4, 4]) |
| 80 | + sleepMs(stepDelay) |
| 81 | + setGroupHeight([1, 1, 1, 1, 1, 1, 1, 1]) |
| 82 | + sleepMs(stepDelay) |
| 83 | + setGroupHeight([4, 4, 4, 4, 4, 4, 4, 4]) |
| 84 | + sleepMs(stepDelay) |
| 85 | + setGroupHeight([8, 8, 8, 8, 8, 8, 8, 8]) |
| 86 | + sleepMs(stepDelay) |
| 87 | + setGroupHeight([1, 1, 1, 1, 1, 1, 1, 1]) |
| 88 | + sleepMs(stepDelay) |
| 89 | + setGroupHeight([4, 4, 4, 4, 4, 4, 4, 4]) |
| 90 | + sleepMs(stepDelay) |
| 91 | + setGroupHeight([8, 8, 8, 8, 8, 8, 8, 8]) |
| 92 | + sleepMs(stepDelay) |
| 93 | + setGroupHeight([1, 1, 1, 1, 1, 1, 1, 1]) |
| 94 | + sleepMs(stepDelay) |
| 95 | + setGroupHeight([4, 4, 4, 4, 4, 4, 4, 4]) |
| 96 | + sleepMs(stepDelay) |
| 97 | + setGroupHeight([8, 8, 8, 8, 8, 8, 8, 8]) |
| 98 | + sleepMs(stepDelay) |
| 99 | + |
| 100 | +time.sleep(5) |
| 101 | + |
| 102 | +tenant.deleteGroup("0group0") |
| 103 | +for grpId in range(numGroups): |
| 104 | + tenant.deleteGroup(str(grpId + 1) + "group" + str(grpId + 1)) |
0 commit comments