-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsizecalc.py
72 lines (56 loc) · 3.09 KB
/
sizecalc.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Small program to calculate useable capacity in a cluster
import math
from math import *
from bitmath import *
sel_funct = ""
while sel_funct != "1" or sel_funct != "2":
print "To get the number of devices per node/server, type (1)"
print "To get the total useable storage, type (2)"
sel_funct = raw_input("Please choose: ")
else:
def calc_reserve(nodes): # this function calculates the recommended reserve
if (1 / nodes) > 0.1: # Calculate recommended_reserve percent is over 10%
reserve = 1 / nodes
else: # Recommend minimum 10% reserve
reserve = 0.1
return reserve
if sel_funct == "1":
# input number of nodes desired
desired_number_nodes = int(raw_input("How many nodes are desired?: "))
recommended_reserve = calc_reserve(desired_number_nodes)
print ""
print "The recommended reserve is", recommended_reserve * 100, "%"
print ""
desired_useable_storage = TiB(int(raw_input("How much useable storage is required (TiB)?: ")))
print ""
device_size = TB(int(raw_input("Which block device size will be used (TB)?: "))) # input device size, TB
device_size_tib = device_size.to_TiB() # convert to TiB
# calculate the amount of raw storage needed including reserve in TB
storage_with_reserve = desired_useable_storage * (
1 + recommended_reserve)
storage_with_reserve_overhead = storage_with_reserve * 2
required_amount_of_devices_total = storage_with_reserve_overhead / (
device_size) # calculate the required amount of devices
# calculate the required amount of devices per node/server
required_amount_of_device_node = required_amount_of_devices_total / desired_number_nodes
recommended_reserve_pct = recommended_reserve * 100
print ""
print "Raw storage with reserve", storage_with_reserve, "TiB"
print ""
print "Storage with reserve and copies", storage_with_reserve_overhead, "TiB"
print ""
print "To get %i TiB with the recommended reserve %.1f pct using %i devices at %i TB" % (
desired_useable_storage, recommended_reserve_pct, desired_number_nodes, device_size)
print "you will need %i devices per node/server" % math.ceil(required_amount_of_device_node)
elif sel_funct == "2":
# input number of nodes to be used
number_nodes = int(raw_input("How many nodes will be used?: "))
# Calculate the reserve
recommended_reserve = calc_reserve(number_nodes)
print "The recommended reserve is %.2s %%" % (recommended_reserve * 100)
# input the size of the devices in TB
device_size = TB(int(raw_input("Which block device size will be used (TB)?: "))) # input device size, TB
device_size_tib = device_size.to_TiB() # convert to TiB
print "Marketing device size is %s and logical device size is %.1f" % (device_size, device_size_tib)
# input the number of devices per node/server
amount_of_devices_per_node = int(raw_input("How many nodes will be used?: "))