-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplacement.py
More file actions
executable file
·42 lines (34 loc) · 1.06 KB
/
placement.py
File metadata and controls
executable file
·42 lines (34 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
from minidc.profiles import MemcacheProfile, RepMemcacheProfile, VidstreamProfile, IperfProfile
# placement of profile roles among physical hosts
PLACEMENT = "sequential"
def inorderPlacement(numHosts, numEdgeSwitches):
l = []
r = range(numHosts)
for i in range(len(r)/2):
l.append(r[i])
l.append(r[i + len(r)/2])
return l
def parityPlacement(numHosts, numEdgeSwitches):
r = range(numHosts)
l = []
for h in r:
if h%2 == 1:
l.append(h)
for h in r:
if h%2 == 0:
l.append(h)
return l
def seqPlacement(numHosts, numEdgeSwitches):
return range(numHosts)
def randPlacement(numHosts, numEdgeSwitches):
r = range(numHosts)
random.shuffle(r)
return r
def getPlacement(numHosts, numEdgeSwitches):
return PLACEMENT_TYPES[PLACEMENT](numHosts, numEdgeSwitches)
PLACEMENT_TYPES = { "sequential" : seqPlacement,
"random" : randPlacement,
"parity" : parityPlacement,
"inorder" : inorderPlacement,
}